Merge branch 'master' into groupmanager

This commit is contained in:
snowleo 2011-10-04 22:19:40 +02:00
commit aaf25d8b9a
13 changed files with 32 additions and 405 deletions

View file

@ -201,11 +201,6 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvent(Type.PLAYER_TELEPORT, jailPlayerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_TELEPORT, jailPlayerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_JOIN, jailPlayerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_JOIN, jailPlayerListener, Priority.High, this);
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
{
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
}
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this); pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
final EssentialsTimer timer = new EssentialsTimer(this); final EssentialsTimer timer = new EssentialsTimer(this);

View file

@ -100,114 +100,11 @@ public class EssentialsPlayerListener extends PlayerListener
return; return;
} }
Location afk = user.getAfkPosition(); final Location afk = user.getAfkPosition();
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9) if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
{ {
user.updateActivity(true); user.updateActivity(true);
} }
if (!ess.getSettings().getNetherPortalsEnabled())
{
return;
}
final Block block = event.getPlayer().getWorld().getBlockAt(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
final List<World> worlds = server.getWorlds();
if (block.getType() == Material.PORTAL && worlds.size() > 1 && user.isAuthorized("essentials.portal"))
{
if (user.getJustPortaled())
{
return;
}
World nether = server.getWorld(ess.getSettings().getNetherName());
if (nether == null)
{
for (World world : worlds)
{
if (world.getEnvironment() == World.Environment.NETHER)
{
nether = world;
break;
}
}
if (nether == null)
{
return;
}
}
final World world = user.getWorld() == nether ? worlds.get(0) : nether;
double factor;
if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
{
factor = ess.getSettings().getNetherRatio();
}
else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
{
factor = 1.0 / ess.getSettings().getNetherRatio();
}
else
{
factor = 1.0;
}
Location loc = event.getTo();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
if (user.getWorld().getBlockAt(x, y, z - 1).getType() == Material.PORTAL)
{
z--;
}
if (user.getWorld().getBlockAt(x - 1, y, z).getType() == Material.PORTAL)
{
x--;
}
x = (int)(x * factor);
z = (int)(z * factor);
loc = new Location(world, x + .5, y, z + .5);
Block dest = world.getBlockAt(x, y, z);
NetherPortal portal = NetherPortal.findPortal(dest);
if (portal == null)
{
if (world.getEnvironment() == World.Environment.NETHER || ess.getSettings().getGenerateExitPortals())
{
portal = NetherPortal.createPortal(dest);
LOGGER.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
user.sendMessage(Util.i18n("generatingPortal"));
loc = portal.getSpawn();
}
}
else
{
LOGGER.info(Util.format("userUsedPortal", event.getPlayer().getName()));
user.sendMessage(Util.i18n("usingPortal"));
loc = portal.getSpawn();
}
event.setFrom(loc);
event.setTo(loc);
try
{
user.getTeleport().now(loc, new Trade("portal", ess));
}
catch (Exception ex)
{
user.sendMessage(ex.getMessage());
}
user.setJustPortaled(true);
user.sendMessage(Util.i18n("teleportingPortal"));
event.setCancelled(true);
return;
}
user.setJustPortaled(false);
} }
@Override @Override

View file

@ -35,8 +35,6 @@ public interface ISettings extends IConf
int getDefaultStackSize(); int getDefaultStackSize();
boolean getGenerateExitPortals();
double getHealCooldown(); double getHealCooldown();
Object getKit(String name); Object getKit(String name);
@ -45,12 +43,6 @@ public interface ISettings extends IConf
String getLocale(); String getLocale();
String getNetherName();
boolean getNetherPortalsEnabled();
double getNetherRatio();
String getNewbieSpawn(); String getNewbieSpawn();
String getNicknamePrefix(); String getNicknamePrefix();
@ -105,8 +97,6 @@ public interface ISettings extends IConf
boolean isEcoDisabled(); boolean isEcoDisabled();
boolean isNetherEnabled();
boolean isTradeInStacks(int id); boolean isTradeInStacks(int id);
List<Integer> itemSpawnBlacklist(); List<Integer> itemSpawnBlacklist();
@ -117,8 +107,6 @@ public interface ISettings extends IConf
boolean spawnIfNoHome(); boolean spawnIfNoHome();
boolean use1to1RatioInNether();
boolean warnOnBuildDisallow(); boolean warnOnBuildDisallow();
boolean warnOnSmite(); boolean warnOnSmite();

View file

@ -1,167 +0,0 @@
/**
* @author SpaceManiac
* @licent MIT
* @origin https://github.com/SpaceManiac/Nether/blob/master/org/innectis/Nether/NetherPortal.java
*/
package com.earth2me.essentials;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.Location;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class NetherPortal
{
private Block block;
public NetherPortal(Block b)
{
block = b;
}
public Block getBlock()
{
return block;
}
public void setBlock(Block b)
{
block = b;
}
// Return a random spawnable location
public Location getSpawn()
{
if (block.getWorld().getBlockAt(block.getX() + 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL)
|| block.getWorld().getBlockAt(block.getX() - 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL))
{
// portal is in X direction
return new Location(block.getWorld(), block.getX() + 1,
block.getY(), block.getZ() + 1 - 2 * Math.round(Math.random()));
}
else
{
// portal is in Z direction
return new Location(block.getWorld(), block.getX() + 1 - 2 * Math.round(Math.random()),
block.getY(), block.getZ() + 1);
}
}
// ==============================
// Find a nearby portal within 16 blocks of the given block
// Not guaranteed to be the nearest
public static NetherPortal findPortal(Block dest)
{
World world = dest.getWorld();
// Get list of columns in a circle around the block
ArrayList<Block> columns = new ArrayList<Block>();
for (int x = dest.getX() - 16; x <= dest.getX() + 16; ++x)
{
for (int z = dest.getZ() - 16; z <= dest.getZ() + 16; ++z)
{
int dx = dest.getX() - x, dz = dest.getZ() - z;
if (dx * dx + dz * dz <= 256)
{
columns.add(world.getBlockAt(x, 0, z));
}
}
}
// For each column try to find a portal block
for (Block col : columns)
{
for (int y = 127; y >= 0; --y)
{
Block b = world.getBlockAt(col.getX(), y, col.getZ());
if (b.getType().equals(Material.PORTAL) && Math.abs(dest.getY() - y) <= 16)
{
// Huzzah!
return new NetherPortal(b);
}
}
}
// Nope!
return null;
}
// Create a new portal at the specified block, fudging position if needed
// Will occasionally end up making portals in bad places, but let's hope not
public static NetherPortal createPortal(Block dest)
{
World world = dest.getWorld();
// Try not to spawn within water or lava
Material m = dest.getType();
while (((m.equals(Material.LAVA) || m.equals(Material.WATER) || m.equals(Material.STATIONARY_LAVA)
|| m.equals(Material.STATIONARY_WATER) || m.equals(Material.SAND) || m.equals(Material.GRAVEL))) &&
dest.getY() < 120)
{
dest = world.getBlockAt(dest.getX(), dest.getY() + 4, dest.getZ());
m = dest.getType();
}
// Not too high or too low overall
if (dest.getY() > 120)
{
dest = world.getBlockAt(dest.getX(), 120, dest.getZ());
}
else if (dest.getY() < 8)
{
dest = world.getBlockAt(dest.getX(), 8, dest.getZ());
}
// Create the physical portal
// For now, don't worry about direction
int x = dest.getX(), y = dest.getY(), z = dest.getZ();
Logger.getLogger("Minecraft").log(Level.INFO, Util.format("creatingPortal", x, y, z));
// Clear area around portal
ArrayList<Block> columns = new ArrayList<Block>();
for (int x2 = x - 4; x2 <= x + 4; ++x2)
{
for (int z2 = z - 4; z2 <= z + 4; ++z2)
{
double dx = x + 0.5f - x2, dz = z - z2;
if (dx * dx + dz * dz <= 13)
{
columns.add(world.getBlockAt(x2, 0, z2));
}
}
}
// Clear area around portal
for (Block col : columns)
{
// Stone platform
world.getBlockAt(col.getX(), y - 1, col.getZ()).setType(Material.STONE);
for (int yd = 0; yd < 4; ++yd)
{
world.getBlockAt(col.getX(), y + yd, col.getZ()).setType(Material.AIR);
}
}
// Build obsidian frame
for (int xd = -1; xd < 3; ++xd)
{
for (int yd = -1; yd < 4; ++yd)
{
if (xd == -1 || yd == -1 || xd == 2 || yd == 3)
{
world.getBlockAt(x + xd, y + yd, z).setType(Material.OBSIDIAN);
}
}
}
// Set it alight!
dest.setType(Material.FIRE);
return new NetherPortal(dest);
}
}

View file

@ -95,12 +95,6 @@ public class Settings implements ISettings
return config.getInt("starting-balance", 0); return config.getInt("starting-balance", 0);
} }
@Override
public boolean getNetherPortalsEnabled()
{
return isNetherEnabled() && config.getBoolean("nether.portals-enabled", false);
}
@Override @Override
public boolean isCommandDisabled(final IEssentialsCommand cmd) public boolean isCommandDisabled(final IEssentialsCommand cmd)
{ {
@ -257,18 +251,6 @@ public class Settings implements ISettings
return config.getBoolean("reclaim-onlogout", true); return config.getBoolean("reclaim-onlogout", true);
} }
@Override
public String getNetherName()
{
return config.getString("nether.folder", "nether");
}
@Override
public boolean isNetherEnabled()
{
return config.getBoolean("nether.enabled", false);
}
@Override @Override
public int getSpawnMobLimit() public int getSpawnMobLimit()
{ {
@ -318,12 +300,6 @@ public class Settings implements ISettings
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}")); config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
} }
@Override
public boolean getGenerateExitPortals()
{
return config.getBoolean("nether.generate-exit-portals", true);
}
@Override @Override
public boolean getAnnounceNewPlayers() public boolean getAnnounceNewPlayers()
{ {
@ -403,22 +379,6 @@ public class Settings implements ISettings
return config.getBoolean("protect.disable.warn-on-build-disallow", false); return config.getBoolean("protect.disable.warn-on-build-disallow", false);
} }
@Override
public boolean use1to1RatioInNether()
{
return config.getBoolean("nether.use-1to1-ratio", false);
}
@Override
public double getNetherRatio()
{
if (config.getBoolean("nether.use-1to1-ratio", false))
{
return 1.0;
}
return config.getDouble("nether.ratio", 8.0);
}
@Override @Override
public boolean isDebug() public boolean isDebug()
{ {

View file

@ -256,7 +256,7 @@ public class Teleport implements Runnable
public void back() throws Exception public void back() throws Exception
{ {
back(null); now(new Target(user.getLastLocation()));
} }
public void home(IUser user, String home, Trade chargeFor) throws Exception public void home(IUser user, String home, Trade chargeFor) throws Exception

View file

@ -286,7 +286,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void setDisplayNick(String name) public void setDisplayNick(String name)
{ {
setDisplayName(name); setDisplayName(name);
setPlayerListName(name); //TODO: Maybe we need to limit nick length, or try use a string trim.
if (name.length() <= 16) {
setPlayerListName(name);
}
} }
public Teleport getTeleport() public Teleport getTeleport()

View file

@ -17,26 +17,28 @@ public class Commandworld extends EssentialsCommand
} }
@Override @Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{ {
World world; World world;
List<World> worlds = server.getWorlds();
if (args.length < 1) if (args.length < 1)
{ {
World nether = server.getWorld(ess.getSettings().getNetherName()); World nether = null;
if (nether == null) {
for (World world2 : worlds) final List<World> worlds = server.getWorlds();
for (World world2 : worlds)
{
if (world2.getEnvironment() == World.Environment.NETHER)
{ {
if (world2.getEnvironment() == World.Environment.NETHER) { nether = world2;
nether = world2; break;
break;
}
}
if (nether == null) {
return;
} }
} }
if (nether == null)
{
return;
}
world = user.getWorld() == nether ? worlds.get(0) : nether; world = user.getWorld() == nether ? worlds.get(0) : nether;
} }
else else
@ -54,23 +56,22 @@ public class Commandworld extends EssentialsCommand
double factor; double factor;
if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL) if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
{ {
factor = ess.getSettings().getNetherRatio(); factor = 8.0;
} }
else if (user.getWorld().getEnvironment() != world.getEnvironment()) else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
{ {
factor = 1.0 / ess.getSettings().getNetherRatio(); factor = 1.0 / 8.0;
} }
else else {
{
factor = 1.0; factor = 1.0;
} }
Location loc = user.getLocation(); final Location loc = user.getLocation();
loc = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5); final Location target = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
Trade charge = new Trade(this.getName(), ess); final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user); charge.isAffordableFor(user);
user.getTeleport().teleport(loc, charge); user.getTeleport().teleport(target, charge);
throw new NoChargeException(); throw new NoChargeException();
} }
} }

View file

@ -223,7 +223,7 @@ public class EssentialsSign
if (signblock.getType() == Material.WALL_SIGN) if (signblock.getType() == Material.WALL_SIGN)
{ {
final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign)signblock.getState().getData(); final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign)signblock.getState().getData();
if (signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock))) if (signMat != null && signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock)))
{ {
return true; return true;
} }

View file

@ -79,12 +79,6 @@ reclaim-onlogout: false
# Should primitive spawn protection be enabled? For most servers, this should be flase; it is better to use a third-party plugin to protect it. # Should primitive spawn protection be enabled? For most servers, this should be flase; it is better to use a third-party plugin to protect it.
spawn-protection: false spawn-protection: false
# Nether settings
# Sets wether you want to change the default behaviour of the nether portals.
nether:
portals-enabled: false
generate-exit-portals: false
# Mob limit on spawnmob # Mob limit on spawnmob
spawnmob-limit: 10 spawnmob-limit: 10

View file

@ -1,45 +0,0 @@
package com.earth2me.essentials;
import junit.framework.TestCase;
public class EssentialsTest extends TestCase
{
public EssentialsTest(String testName)
{
super(testName);
}
private static void should(String what)
{
System.out.println("Essentials should " + what);
}
public void testLoadClasses()
{
should("make all classes accessible");
try
{
ItemDb itemDb = null;
Mob mob = null;
NetherPortal netherPortal = null;
OfflinePlayer offlinePlayer = null;
Settings settings = null;
Spawn spawn = null;
TargetBlock targetBlock = null;
User user = null;
assertNull(itemDb);
assertNull(mob);
assertNull(netherPortal);
assertNull(offlinePlayer);
assertNull(settings);
assertNull(spawn);
assertNull(targetBlock);
assertNull(user);
}
catch (Throwable ex)
{
fail(ex.toString());
}
}
}

View file

@ -25,6 +25,7 @@ v 1.1:
v 1.2: v 1.2:
- Changed priority of Registered events to lowest. - Changed priority of Registered events to lowest.
- Fixed an issue with superperms where plugins define perms with inheritance after the root perms - Fixed an issue with superperms where plugins define perms with inheritance after the root perms
v 1.3:
- Rewrote Config loading to use Bukkits Configuration features - Rewrote Config loading to use Bukkits Configuration features
- Added an opOverride setting in config. - Added an opOverride setting in config.
If present and set to false, op's will not get overriding permissions in GroupManager. If present and set to false, op's will not get overriding permissions in GroupManager.
@ -35,4 +36,4 @@ v 1.2:
- Added event handling to manage new world creation at runtime. - Added event handling to manage new world creation at runtime.
- Added the ability to handle unknown worlds at server start. - Added the ability to handle unknown worlds at server start.
(GM will create the data files for any worlds it finds which are not in the config.yml) (GM will create the data files for any worlds it finds which are not in the config.yml)
- Fix for Bukkit passing a null To location on a player Portaling - Fix for Bukkit passing a null To location on a player portaling.

View file

@ -1,5 +1,5 @@
name: GroupManager name: GroupManager
version: "1.2 (Phoenix)" version: "1.3 (Phoenix)"
main: org.anjocaido.groupmanager.GroupManager main: org.anjocaido.groupmanager.GroupManager
website: http://www.anjocaido.info/ website: http://www.anjocaido.info/
description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule. description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule.