summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/Backup.java7
-rw-r--r--Essentials/src/com/earth2me/essentials/Console.java32
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java115
-rw-r--r--Essentials/src/com/earth2me/essentials/FakeWorld.java18
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/NetherPortal.java167
-rw-r--r--Essentials/src/com/earth2me/essentials/OfflinePlayer.java15
-rw-r--r--Essentials/src/com/earth2me/essentials/PlayerWrapper.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java40
-rw-r--r--Essentials/src/com/earth2me/essentials/Teleport.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java9
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandheal.java1
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandnick.java8
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandrepair.java8
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandworld.java43
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/Method.java17
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/Methods.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java23
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java23
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java38
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java27
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java20
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java2
-rw-r--r--Essentials/src/config.yml6
-rw-r--r--Essentials/src/plugin.yml2
-rw-r--r--Essentials/test/com/earth2me/essentials/EssentialsTest.java45
-rw-r--r--Essentials/test/com/earth2me/essentials/FakeServer.java73
-rw-r--r--EssentialsGroupManager/src/Changelog.txt15
-rw-r--r--EssentialsGroupManager/src/config.yml7
-rw-r--r--[-rwxr-xr-x]EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java89
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java69
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java1
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java33
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java68
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMWorldListener.java43
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java11
-rw-r--r--EssentialsGroupManager/src/plugin.yml2
-rw-r--r--lib/bPermissions.jarbin117907 -> 109921 bytes
-rw-r--r--lib/bukkit-0.0.1-SNAPSHOT.jarbin3556599 -> 4358533 bytes
-rw-r--r--lib/craftbukkit-0.0.1-SNAPSHOT.jarbin8748701 -> 9565109 bytes
44 files changed, 558 insertions, 575 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Backup.java b/Essentials/src/com/earth2me/essentials/Backup.java
index b7b441b1e..02a3d54ba 100644
--- a/Essentials/src/com/earth2me/essentials/Backup.java
+++ b/Essentials/src/com/earth2me/essentials/Backup.java
@@ -5,6 +5,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
@@ -12,7 +13,7 @@ import org.bukkit.craftbukkit.CraftServer;
public class Backup implements Runnable
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
- private transient final CraftServer server;
+ private transient final Server server;
private transient final IEssentials ess;
private transient boolean running = false;
private transient int taskId = -1;
@@ -21,7 +22,7 @@ public class Backup implements Runnable
public Backup(final IEssentials ess)
{
this.ess = ess;
- server = (CraftServer)ess.getServer();
+ server = ess.getServer();
if (server.getOnlinePlayers().length > 0)
{
startTask();
@@ -60,7 +61,7 @@ public class Backup implements Runnable
return;
}
LOGGER.log(Level.INFO, Util.i18n("backupStarted"));
- final CommandSender cs = server.getServer().console;
+ final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off");
diff --git a/Essentials/src/com/earth2me/essentials/Console.java b/Essentials/src/com/earth2me/essentials/Console.java
index 882c4f2c8..dcdb65a0d 100644
--- a/Essentials/src/com/earth2me/essentials/Console.java
+++ b/Essentials/src/com/earth2me/essentials/Console.java
@@ -2,33 +2,35 @@ package com.earth2me.essentials;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
-import org.bukkit.craftbukkit.CraftServer;
-public final class Console implements IReplyTo {
+
+public final class Console implements IReplyTo
+{
private static Console instance = new Console();
private CommandSender replyTo;
public final static String NAME = "Console";
-
- private Console() {
-
+
+ private Console()
+ {
}
-
- public static CommandSender getCommandSender(Server server) throws Exception {
- if (! (server instanceof CraftServer)) {
- throw new Exception(Util.i18n("invalidServer"));
- }
- return ((CraftServer)server).getServer().console;
+
+ public static CommandSender getCommandSender(Server server) throws Exception
+ {
+ return server.getConsoleSender();
}
- public void setReplyTo(CommandSender user) {
+ public void setReplyTo(CommandSender user)
+ {
replyTo = user;
}
- public CommandSender getReplyTo() {
+ public CommandSender getReplyTo()
+ {
return replyTo;
}
-
- public static Console getConsoleReplyTo() {
+
+ public static Console getConsoleReplyTo()
+ {
return instance;
}
}
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index c98671d94..fe0c3560c 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -201,11 +201,6 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvent(Type.PLAYER_TELEPORT, 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);
final EssentialsTimer timer = new EssentialsTimer(this);
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java
index 2eda73540..f5d6cec48 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java
@@ -84,10 +84,12 @@ public class EssentialsEntityListener extends EntityListener
@Override
public void onFoodLevelChange(FoodLevelChangeEvent event)
- {
+ {
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
- {
+ {
+ //TODO: Remove the following line, when we're happy to remove backwards compatability with 1185.
event.setFoodLevel(20);
+ event.setCancelled(true);
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index 2f690910f..026e4632b 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -46,11 +46,11 @@ public class EssentialsPlayerListener extends PlayerListener
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
final User user = ess.getUser(event.getPlayer());
- user.setDisplayName(user.getNick());
+ user.setDisplayNick(user.getNick());
updateCompass(user);
if (ess.getSettings().changeDisplayName())
{
- user.setDisplayName(user.getNick());
+ user.setDisplayNick(user.getNick());
}
}
@@ -76,7 +76,7 @@ public class EssentialsPlayerListener extends PlayerListener
user.updateActivity(true);
if (ess.getSettings().changeDisplayName())
{
- user.setDisplayName(user.getNick());
+ user.setDisplayNick(user.getNick());
}
}
@@ -100,114 +100,11 @@ public class EssentialsPlayerListener extends PlayerListener
return;
}
- Location afk = user.getAfkPosition();
+ final Location afk = user.getAfkPosition();
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
{
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
@@ -262,7 +159,7 @@ public class EssentialsPlayerListener extends PlayerListener
if (ess.getSettings().changeDisplayName())
{
- user.setDisplayName(user.getNick());
+ user.setDisplayNick(user.getNick());
}
user.updateActivity(false);
if (user.isAuthorized("essentials.sleepingignored"))
@@ -351,7 +248,7 @@ public class EssentialsPlayerListener extends PlayerListener
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().changeDisplayName())
{
- user.setDisplayName(user.getNick());
+ user.setDisplayNick(user.getNick());
}
updateCompass(user);
}
diff --git a/Essentials/src/com/earth2me/essentials/FakeWorld.java b/Essentials/src/com/earth2me/essentials/FakeWorld.java
index 8894e8df1..0b5d68be1 100644
--- a/Essentials/src/com/earth2me/essentials/FakeWorld.java
+++ b/Essentials/src/com/earth2me/essentials/FakeWorld.java
@@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.BlockChangeDelegate;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
+import org.bukkit.Difficulty;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.TreeType;
@@ -437,4 +438,21 @@ public class FakeWorld implements World
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
+ public Difficulty getDifficulty()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setDifficulty(Difficulty difficulty)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getSeaLevel()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index af95e2cbc..54d1b1495 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -35,8 +35,6 @@ public interface ISettings extends IConf
int getDefaultStackSize();
- boolean getGenerateExitPortals();
-
double getHealCooldown();
Object getKit(String name);
@@ -45,12 +43,6 @@ public interface ISettings extends IConf
String getLocale();
- String getNetherName();
-
- boolean getNetherPortalsEnabled();
-
- double getNetherRatio();
-
String getNewbieSpawn();
String getNicknamePrefix();
@@ -105,8 +97,6 @@ public interface ISettings extends IConf
boolean isEcoDisabled();
- boolean isNetherEnabled();
-
boolean isTradeInStacks(int id);
List<Integer> itemSpawnBlacklist();
@@ -117,8 +107,6 @@ public interface ISettings extends IConf
boolean spawnIfNoHome();
- boolean use1to1RatioInNether();
-
boolean warnOnBuildDisallow();
boolean warnOnSmite();
diff --git a/Essentials/src/com/earth2me/essentials/NetherPortal.java b/Essentials/src/com/earth2me/essentials/NetherPortal.java
deleted file mode 100644
index 8c8c9e52f..000000000
--- a/Essentials/src/com/earth2me/essentials/NetherPortal.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
index 07092d0bb..1b0058f24 100644
--- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
+++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java
@@ -695,7 +695,7 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
-
+
@Override
public Location getBedSpawnLocation()
{
@@ -713,5 +713,16 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
-
+
+ @Override
+ public void setPlayerListName(String name)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getPlayerListName()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java
index 2b6dd92ad..4b998af47 100644
--- a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java
+++ b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java
@@ -744,4 +744,16 @@ public class PlayerWrapper implements Player
base.setSprinting(bln);
}
+ @Override
+ public void setPlayerListName(String name)
+ {
+ base.setPlayerListName(name);
+ }
+
+ @Override
+ public String getPlayerListName()
+ {
+ return base.getPlayerListName();
+ }
+
}
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index 3c06fb300..d6a649786 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -96,12 +96,6 @@ public class Settings implements ISettings
}
@Override
- public boolean getNetherPortalsEnabled()
- {
- return isNetherEnabled() && config.getBoolean("nether.portals-enabled", false);
- }
-
- @Override
public boolean isCommandDisabled(final IEssentialsCommand cmd)
{
return isCommandDisabled(cmd.getName());
@@ -258,18 +252,6 @@ public class Settings implements ISettings
}
@Override
- public String getNetherName()
- {
- return config.getString("nether.folder", "nether");
- }
-
- @Override
- public boolean isNetherEnabled()
- {
- return config.getBoolean("nether.enabled", false);
- }
-
- @Override
public int getSpawnMobLimit()
{
return config.getInt("spawnmob-limit", 10);
@@ -319,12 +301,6 @@ public class Settings implements ISettings
}
@Override
- public boolean getGenerateExitPortals()
- {
- return config.getBoolean("nether.generate-exit-portals", true);
- }
-
- @Override
public boolean getAnnounceNewPlayers()
{
return !config.getString("newbies.announce-format", "-").isEmpty();
@@ -404,22 +380,6 @@ public class Settings implements ISettings
}
@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
public boolean isDebug()
{
return config.getBoolean("debug", false);
diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java
index 608663561..845f9c3a3 100644
--- a/Essentials/src/com/earth2me/essentials/Teleport.java
+++ b/Essentials/src/com/earth2me/essentials/Teleport.java
@@ -256,7 +256,7 @@ public class Teleport implements Runnable
public void back() throws Exception
{
- back(null);
+ now(new Target(user.getLastLocation()));
}
public void home(IUser user, String home, Trade chargeFor) throws Exception
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index b68e93656..3e335a1df 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -282,6 +282,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return nickname.toString();
}
+
+ public void setDisplayNick(String name)
+ {
+ setDisplayName(name);
+ //TODO: Maybe we need to limit nick length, or try use a string trim.
+ if (name.length() <= 16) {
+ setPlayerListName(name);
+ }
+ }
public Teleport getTeleport()
{
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
index 52409049d..c1b0ed7bf 100644
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ b/Essentials/src/com/earth2me/essentials/Util.java
@@ -266,9 +266,9 @@ public class Util
throw new Exception(Util.i18n("destinationNotSet"));
}
final World world = loc.getWorld();
- int x = (int)Math.round(loc.getX());
+ int x = loc.getBlockX();
int y = (int)Math.round(loc.getY());
- int z = (int)Math.round(loc.getZ());
+ int z = loc.getBlockZ();
while (isBlockAboveAir(world, x, y, z))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
index d60fc09fe..68de488af 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
@@ -34,6 +34,7 @@ public class Commandheal extends EssentialsCommand
user.healCooldown();
}
user.setHealth(20);
+ user.setFoodLevel(20);
user.sendMessage(Util.i18n("heal"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
index 253ec7646..f2165aebc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
@@ -41,7 +41,7 @@ public class Commandnick extends EssentialsCommand
String nick = args[0];
if ("off".equalsIgnoreCase(nick) || user.getName().equalsIgnoreCase(nick))
{
- user.setDisplayName(user.getName());
+ user.setDisplayNick(user.getName());
user.setNickname(null);
user.sendMessage(Util.i18n("nickNoMore"));
return;
@@ -67,7 +67,7 @@ public class Commandnick extends EssentialsCommand
}
}
- user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
+ user.setDisplayNick(ess.getSettings().getNicknamePrefix() + nick);
user.setNickname(nick);
user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7."));
}
@@ -95,13 +95,13 @@ public class Commandnick extends EssentialsCommand
String nick = args[1];
if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick))
{
- target.setDisplayName(target.getName());
+ target.setDisplayNick(target.getName());
target.setNickname(null);
target.sendMessage(Util.i18n("nickNoMore"));
}
else
{
- target.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
+ target.setDisplayNick(ess.getSettings().getNicknamePrefix() + nick);
target.setNickname(nick);
target.sendMessage(Util.format("nickSet", target.getDisplayName() + "§7."));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
index 029901867..d6bcad464 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
@@ -30,6 +30,10 @@ public class Commandrepair extends EssentialsCommand
if (args[0].equalsIgnoreCase("hand"))
{
final ItemStack item = user.getItemInHand();
+ if (item == null)
+ {
+ throw new Exception(Util.i18n("repairInvalidType"));
+ }
final String itemName = item.getType().toString().toLowerCase();
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
@@ -84,6 +88,10 @@ public class Commandrepair extends EssentialsCommand
{
for (ItemStack item : items)
{
+ if (item == null)
+ {
+ continue;
+ }
final String itemName = item.getType().toString().toLowerCase();
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
try
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java
index 77db8e5e3..557f46dbf 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java
@@ -17,26 +17,28 @@ public class Commandworld extends EssentialsCommand
}
@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;
- List<World> worlds = server.getWorlds();
if (args.length < 1)
{
- World nether = server.getWorld(ess.getSettings().getNetherName());
- if (nether == null) {
- for (World world2 : worlds)
+ World nether = null;
+
+ final List<World> worlds = server.getWorlds();
+
+ for (World world2 : worlds)
+ {
+ if (world2.getEnvironment() == World.Environment.NETHER)
{
- if (world2.getEnvironment() == World.Environment.NETHER) {
- nether = world2;
- break;
- }
- }
- if (nether == null) {
- return;
+ nether = world2;
+ break;
}
}
+ if (nether == null)
+ {
+ return;
+ }
world = user.getWorld() == nether ? worlds.get(0) : nether;
}
else
@@ -54,23 +56,22 @@ public class Commandworld extends EssentialsCommand
double factor;
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;
}
- Location loc = user.getLocation();
- loc = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
+ final Location loc = user.getLocation();
+ 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);
- user.getTeleport().teleport(loc, charge);
+ user.getTeleport().teleport(target, charge);
throw new NoChargeException();
}
}
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Method.java b/Essentials/src/com/earth2me/essentials/register/payment/Method.java
index f8bd814ef..ea4477077 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/Method.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/Method.java
@@ -91,6 +91,23 @@ public interface Method
public boolean hasBankAccount(String bank, String name);
/**
+ * Forces an account creation
+ *
+ * @param name Account name
+ * @return <code>boolean</code>
+ */
+ public boolean createAccount(String name);
+
+ /**
+ * Forces an account creation
+ *
+ * @param name Account name
+ * @param balance Initial account balance
+ * @return <code>boolean</code>
+ */
+ public boolean createAccount(String name, Double balance);
+
+ /**
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
*
* @param name Account name
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
index 0fc65534f..34acf9837 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
@@ -2,6 +2,7 @@ package com.earth2me.essentials.register.payment;
import java.util.HashSet;
import java.util.Set;
+
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@@ -168,7 +169,7 @@ public class Methods
}
plugin = manager.getPlugin(name);
- if (plugin == null)
+ if (plugin == null || !plugin.isEnabled())
{
continue;
}
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java
index 7c83c9b76..bc3893d5e 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE6.java
@@ -71,6 +71,29 @@ public class BOSE6 implements Method
|| this.BOSEconomy.isBankMember(bank, name);
}
+ public boolean createAccount(String name)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ this.BOSEconomy.registerPlayer(name);
+ return true;
+ }
+
+ public boolean createAccount(String name, Double balance)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ this.BOSEconomy.registerPlayer(name);
+ this.BOSEconomy.setPlayerMoney(name, balance, false);
+ return true;
+ }
+
public MethodAccount getAccount(String name)
{
if (!hasAccount(name))
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java
index 288e4a5c5..72d1f763e 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/BOSE7.java
@@ -70,6 +70,29 @@ public class BOSE7 implements Method
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
}
+ public boolean createAccount(String name)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ this.BOSEconomy.registerPlayer(name);
+ return true;
+ }
+
+ public boolean createAccount(String name, Double balance)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ this.BOSEconomy.registerPlayer(name);
+ this.BOSEconomy.setPlayerMoney(name, balance, false);
+ return true;
+ }
+
public MethodAccount getAccount(String name)
{
if (!hasAccount(name))
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java
index 6248b1b91..53d8ed120 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/MCUR.java
@@ -64,6 +64,18 @@ public class MCUR implements Method
return false;
}
+ public boolean createAccount(String name)
+ {
+ CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, 0);
+ return true;
+ }
+
+ public boolean createAccount(String name, Double balance)
+ {
+ CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, balance);
+ return true;
+ }
+
public MethodAccount getAccount(String name)
{
return new MCurrencyAccount(name);
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java
index fcdb7c43b..1f33df12c 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo4.java
@@ -64,6 +64,44 @@ public class iCo4 implements Method
return false;
}
+ public boolean createAccount(String name)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ try
+ {
+ com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name);
+ }
+ catch (Exception E)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean createAccount(String name, Double balance)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ try
+ {
+ com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name, balance);
+ }
+ catch (Exception E)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
public MethodAccount getAccount(String name)
{
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java
index 462cb76d5..d56873c3f 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo5.java
@@ -67,6 +67,33 @@ public class iCo5 implements Method
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
}
+ public boolean createAccount(String name)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ return com.iConomy.iConomy.Accounts.create(name);
+ }
+
+ public boolean createAccount(String name, Double balance)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ if (!com.iConomy.iConomy.Accounts.create(name))
+ {
+ return false;
+ }
+
+ getAccount(name).set(balance);
+
+ return true;
+ }
+
public MethodAccount getAccount(String name)
{
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java
index b74367173..1feee30af 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/iCo6.java
@@ -66,6 +66,26 @@ public class iCo6 implements Method
return false;
}
+ public boolean createAccount(String name)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ return (new Accounts()).create(name);
+ }
+
+ public boolean createAccount(String name, Double balance)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ return (new Accounts()).create(name, balance);
+ }
+
public MethodAccount getAccount(String name)
{
return new iCoAccount((new Accounts()).get(name));
diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
index 026fb0557..b9d224cec 100644
--- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
+++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
@@ -223,7 +223,7 @@ public class EssentialsSign
if (signblock.getType() == Material.WALL_SIGN)
{
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;
}
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index 7b1525d40..61cb7aefa 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -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.
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
spawnmob-limit: 10
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index 0c5f689a7..61a054c45 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -293,7 +293,7 @@ commands:
togglejail:
description: Prevents a player from interacting with the world and teleports him/her to the the jail specified
usage: /<command> [player] [jailname] <datediff>
- aliases: [tjail,etogglejail]
+ aliases: [tjail,unjail,eunjail,etogglejail]
top:
description: Teleport to the highest block at your current position.
usage: /<command>
diff --git a/Essentials/test/com/earth2me/essentials/EssentialsTest.java b/Essentials/test/com/earth2me/essentials/EssentialsTest.java
deleted file mode 100644
index 26c5c68e9..000000000
--- a/Essentials/test/com/earth2me/essentials/EssentialsTest.java
+++ /dev/null
@@ -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());
- }
- }
-}
diff --git a/Essentials/test/com/earth2me/essentials/FakeServer.java b/Essentials/test/com/earth2me/essentials/FakeServer.java
index ac5636c61..2344c4513 100644
--- a/Essentials/test/com/earth2me/essentials/FakeServer.java
+++ b/Essentials/test/com/earth2me/essentials/FakeServer.java
@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import com.avaje.ebean.config.ServerConfig;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -14,7 +15,9 @@ import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.World.Environment;
+import org.bukkit.WorldCreator;
import org.bukkit.command.CommandSender;
+import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
@@ -43,41 +46,48 @@ public class FakeServer implements Server
return "1.0";
}
+ @Override
public Player[] getOnlinePlayers()
{
return players.toArray(new Player[0]);
}
-
+
public void setOnlinePlayers(List<Player> players)
{
this.players = players;
}
+ @Override
public int getMaxPlayers()
{
return 100;
}
+ @Override
public int getPort()
{
return 25565;
}
+ @Override
public String getIp()
{
return "127.0.0.1";
}
+ @Override
public String getServerName()
{
return "Test Server";
}
+ @Override
public String getServerId()
{
return "Test Server";
}
+ @Override
public int broadcastMessage(String string)
{
int i = 0;
@@ -89,11 +99,19 @@ public class FakeServer implements Server
return i;
}
+ @Override
public String getUpdateFolder()
{
return "update";
}
+ @Override
+ public File getUpdateFolderFile()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
public Player getPlayer(String string)
{
for (Player player : players)
@@ -106,6 +124,7 @@ public class FakeServer implements Server
return null;
}
+ @Override
public List<Player> matchPlayer(String string)
{
List<Player> matches = new ArrayList<Player>();
@@ -119,15 +138,17 @@ public class FakeServer implements Server
return matches;
}
+ @Override
public PluginManager getPluginManager()
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public BukkitScheduler getScheduler()
{
- return new BukkitScheduler() {
-
+ return new BukkitScheduler()
+ {
@Override
public int scheduleSyncDelayedTask(Plugin plugin, Runnable r, long l)
{
@@ -215,16 +236,19 @@ public class FakeServer implements Server
};
}
+ @Override
public ServicesManager getServicesManager()
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public List<World> getWorlds()
{
return worlds;
}
+ @Override
public World createWorld(String string, Environment e)
{
World w = new FakeWorld(string, e);
@@ -232,6 +256,7 @@ public class FakeServer implements Server
return w;
}
+ @Override
public World createWorld(String string, Environment e, long l)
{
World w = new FakeWorld(string, e);
@@ -239,45 +264,54 @@ public class FakeServer implements Server
return w;
}
+ @Override
public World getWorld(String string)
{
for (World world : worlds)
{
- if (world.getName().equalsIgnoreCase(string)) {
+ if (world.getName().equalsIgnoreCase(string))
+ {
return world;
}
}
return null;
}
+ @Override
public void reload()
{
}
+ @Override
public Logger getLogger()
{
return Logger.getLogger("Minecraft");
}
+ @Override
public PluginCommand getPluginCommand(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public void savePlayers()
{
}
+ @Override
public boolean dispatchCommand(CommandSender cs, String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public void configureDbConfig(ServerConfig sc)
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public boolean addRecipe(Recipe recipe)
{
throw new UnsupportedOperationException("Not supported yet.");
@@ -287,7 +321,7 @@ public class FakeServer implements Server
{
players.add(base1);
}
-
+
public OfflinePlayer createPlayer(String name, IEssentials ess)
{
OfflinePlayer player = new OfflinePlayer(name, ess);
@@ -295,41 +329,55 @@ public class FakeServer implements Server
return player;
}
+ @Override
public World createWorld(String string, Environment e, ChunkGenerator cg)
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public World createWorld(String string, Environment e, long l, ChunkGenerator cg)
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
+ public World createWorld(WorldCreator creator)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
public boolean unloadWorld(String string, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public boolean unloadWorld(World world, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public Map<String, String[]> getCommandAliases()
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public int getSpawnRadius()
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public void setSpawnRadius(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public boolean getOnlineMode()
{
throw new UnsupportedOperationException("Not supported yet.");
@@ -340,6 +388,7 @@ public class FakeServer implements Server
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
public World getWorld(UUID uuid)
{
throw new UnsupportedOperationException("Not supported yet.");
@@ -454,7 +503,19 @@ public class FakeServer implements Server
}
@Override
- public void setDefaultGameMode(GameMode gm)
+ public void setDefaultGameMode(GameMode gamemode)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public ConsoleCommandSender getConsoleSender()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Set getOperators()
{
throw new UnsupportedOperationException("Not supported yet.");
}
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 4f90b82cd..e90d7e368 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -23,4 +23,17 @@ v 1.1:
- Fix for GM not checking inheritance for known superperms nodes.
- Optimized getAllPlayersPermissions and fixed pushing unknown perms to superperms.
v 1.2:
- - Changed priority if Registered events to lowest. \ No newline at end of file
+ - Changed priority of Registered events to lowest.
+ - 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
+ - Added an opOverride setting in config.
+ If present and set to false, op's will not get overriding permissions in GroupManager.
+ (one op will not be able to alter another op's settings)
+ - GM will now create all relevant world data files for non mirrored worlds.
+ (for all worlds named in config.yml)
+ - Attempt to stop GM wiping groups/users yml's on a bad shut down.
+ - Added event handling to manage new world creation at runtime.
+ - 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)
+ - Fix for Bukkit passing a null To location on a player portaling. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/config.yml b/EssentialsGroupManager/src/config.yml
index 688d3f3ea..a5bca810e 100644
--- a/EssentialsGroupManager/src/config.yml
+++ b/EssentialsGroupManager/src/config.yml
@@ -1,12 +1,19 @@
settings:
+ config:
+ # With this enabled anyone set as op has full permissions when managing GroupManager
+ opOverrides: true
data:
save:
+ # How often GroupManager will save it's data back to groups and users.yml
minutes: 10
logging:
+ # level of detail GroupManager will use when logging.
+ # Acceptable entries are - ALL,CONFIG,FINE,FINER,FINEST,INFO,OFF,SEVERE,WARNING
level: INFO
permission:
world:
mirror:
+ # Worlds listed here have their permissions mirrored in their children.
world:
- world_nether
- world2
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
index 153221ed9..aa838d9e8 100755..100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
@@ -5,15 +5,12 @@
package org.anjocaido.groupmanager;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
+
import org.anjocaido.groupmanager.utils.Tasks;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.SafeConstructor;
-import org.yaml.snakeyaml.reader.UnicodeReader;
+import org.bukkit.util.config.Configuration;
/**
*
@@ -22,9 +19,9 @@ import org.yaml.snakeyaml.reader.UnicodeReader;
public class GMConfiguration {
private GroupManager plugin;
- private Map<String, Object> rootDataNode;
private File configFile;
-
+ private Configuration GMconfig;
+
public GMConfiguration(GroupManager plugin) {
this.plugin = plugin;
load();
@@ -44,77 +41,37 @@ public class GMConfiguration {
}
}
- Yaml yaml = new Yaml(new SafeConstructor());
- FileInputStream rx = null;
- try {
- rx = new FileInputStream(configFile);
- } catch (FileNotFoundException ex) {
- GroupManager.logger.log(Level.SEVERE, null, ex);
- }
+ GMconfig = new Configuration(configFile);
+
try {
- rootDataNode = (Map<String, Object>) yaml.load(new UnicodeReader(rx));
- if (rootDataNode == null) {
- throw new NullPointerException();
- }
+ GMconfig.load();
} catch (Exception ex) {
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + configFile.getPath(), ex);
- } finally {
- try {
- rx.close();
- } catch (IOException ex) {
- }
}
adjustLoggerLevel();
}
+
+ public boolean isOpOverride() {
+ return GMconfig.getBoolean("settings.config.opOverrides", true);
+ }
- public Map<String, Object> getMirrorsMap() {
- if (rootDataNode.get("settings") instanceof Map) {
- Map<String, Object> settingsNode = (Map<String, Object>) rootDataNode.get("settings");
- if (settingsNode.get("permission") instanceof Map) {
- Map<String, Object> permissionNode = (Map<String, Object>) settingsNode.get("permission");
- if (permissionNode.get("world") instanceof Map) {
- Map<String, Object> worldsNode = (Map<String, Object>) permissionNode.get("world");
- if (worldsNode.get("mirror") instanceof Map) {
- Map<String, Object> mirrorsNode = (Map<String, Object>) worldsNode.get("mirror");
- return mirrorsNode;
- }
- }
- }
- }
- return null;
+ @SuppressWarnings("unchecked")
+ public Map<String, Object> getMirrorsMap() {
+ return (Map<String, Object>) GMconfig.getProperty("settings.permission.world.mirror");
}
- public Integer getSaveInterval() {
- if (rootDataNode.get("settings") instanceof Map) {
- Map<String, Object> settingsNode = (Map<String, Object>) rootDataNode.get("settings");
- if (settingsNode.get("data") instanceof Map) {
- Map<String, Object> dataNode = (Map<String, Object>) settingsNode.get("data");
- if (dataNode.get("save") instanceof Map) {
- Map<String, Object> saveNode = (Map<String, Object>) dataNode.get("save");
- if (saveNode.get("minutes") instanceof Integer) {
- return (Integer) saveNode.get("minutes");
- }
- }
- }
- }
- return 10;
+ public Integer getSaveInterval() {
+ return GMconfig.getInt("settings.data.save.minutes", 10);
}
public void adjustLoggerLevel() {
- if (rootDataNode.get("settings") instanceof Map) {
- Map<String, Object> settingsNode = (Map<String, Object>) rootDataNode.get("settings");
- if (settingsNode.get("logging") instanceof Map) {
- Map<String, Object> loggingNode = (Map<String, Object>) settingsNode.get("logging");
- if (loggingNode.get("level") instanceof String) {
- String level = (String) loggingNode.get("level");
- try {
- GroupManager.logger.setLevel(Level.parse(level));
- return;
- } catch (Exception e) {
- }
- }
- }
+
+ try {
+ GroupManager.logger.setLevel(Level.parse(GMconfig.getString("settings.logging.level", "INFO")));
+ return;
+ } catch (Exception e) {
}
- GroupManager.logger.setLevel(Level.INFO);
+
+ GroupManager.logger.setLevel(Level.INFO);
}
} \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index dcec36639..0fe8a15d4 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
+import org.anjocaido.groupmanager.events.GMWorldListener;
import org.anjocaido.groupmanager.utils.GMLoggerHandler;
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
import org.anjocaido.groupmanager.utils.Tasks;
@@ -32,9 +33,12 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.world.WorldListener;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
+
@SuppressWarnings("unused")
/**
*
@@ -55,6 +59,7 @@ public class GroupManager extends JavaPlugin {
private GMConfiguration config;
private GMLoggerHandler ch;
public static BukkitPermissions BukkitPermissions;
+ private static WorldListener WorldEvents;
public static final Logger logger = Logger.getLogger(GroupManager.class.getName());
//PERMISSIONS FOR COMMAND BEING LOADED
@@ -69,6 +74,10 @@ public class GroupManager extends JavaPlugin {
worldsHolder.saveChanges();
}
disableScheduler();
+
+ WorldEvents = null;
+ BukkitPermissions = null;
+
// EXAMPLE: Custom code, here we just output some info so we can check all is well
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!");
@@ -94,8 +103,10 @@ public class GroupManager extends JavaPlugin {
throw new IllegalStateException("An error ocurred while loading GroupManager");
}
+ // Initialize the world listener and bukkit permissions to handle events.
+ WorldEvents = new GMWorldListener(this);
BukkitPermissions = new BukkitPermissions(this);
-
+
enableScheduler();
/*
@@ -108,9 +119,10 @@ public class GroupManager extends JavaPlugin {
setLoaded(true);
}
- //setLoaded(true);
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
}
+
+
public static boolean isLoaded() {
return isLoaded;
@@ -232,6 +244,7 @@ public class GroupManager extends JavaPlugin {
Player senderPlayer = null, targetPlayer = null;
Group senderGroup = null;
User senderUser = null;
+ boolean isOpOverride = config.isOpOverride();
//DETERMINING PLAYER INFORMATION
@@ -239,8 +252,10 @@ public class GroupManager extends JavaPlugin {
senderPlayer = (Player) sender;
senderUser = worldsHolder.getWorldData(senderPlayer).getUser(senderPlayer.getName());
senderGroup = senderUser.getGroup();
+ isOpOverride = (isOpOverride && senderPlayer.isOp());
+
System.out.println("[PLAYER_COMMAND] " + senderPlayer.getName() + ": /" + commandLabel + " " + Tasks.join(args, " "));
- if (senderPlayer.isOp() || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager." + cmd.getName())) {
+ if (isOpOverride || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager." + cmd.getName())) {
playerCanDo = true;
}
} else if (sender instanceof ConsoleCommandSender) {
@@ -338,27 +353,19 @@ public class GroupManager extends JavaPlugin {
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don't inherit.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
- sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
- return false;
- }
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
- sender.sendMessage(ChatColor.RED + "The new group must be a higher rank.");
- return false;
- }
-
+
//PARECE OK
auxUser.setGroup(auxGroup);
sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'.");
@@ -392,7 +399,7 @@ public class GroupManager extends JavaPlugin {
auxUser = dataHolder.getUser(args[0]);
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
@@ -436,7 +443,7 @@ public class GroupManager extends JavaPlugin {
return false;
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
@@ -472,7 +479,7 @@ public class GroupManager extends JavaPlugin {
auxUser = dataHolder.getUser(args[0]);
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
@@ -557,7 +564,7 @@ public class GroupManager extends JavaPlugin {
return false;
}
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
- if (!isConsole && !senderPlayer.isOp() && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
+ if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
sender.sendMessage(ChatColor.RED + "Can't add a permission you don't have.");
return false;
@@ -620,12 +627,12 @@ public class GroupManager extends JavaPlugin {
auxUser = dataHolder.getUser(args[0]);
}
//VALIDANDO SUA PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same group than you, or higher.");
return false;
}
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
- if (!isConsole && !senderPlayer.isOp() && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
+ if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
sender.sendMessage(ChatColor.RED + "Can't remove a permission you don't have.");
return false;
@@ -1554,23 +1561,23 @@ public class GroupManager extends JavaPlugin {
return false;
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don't inherit.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "The new group must be a higher rank.");
return false;
}
@@ -1612,23 +1619,23 @@ public class GroupManager extends JavaPlugin {
return false;
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don' inherit.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "The new group must be a lower rank.");
return false;
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java
index 27951112d..f4b805c35 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java
@@ -18,6 +18,7 @@ public class BukkitPermsUpdateTask implements Runnable {
public void run() {
// Signal loaded and update BukkitPermissions.
GroupManager.setLoaded(true);
+ GroupManager.BukkitPermissions.collectPermissions();
GroupManager.BukkitPermissions.updateAllPlayers();
GroupManager.logger.info("Bukkit Permissions Updated!");
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
index 77d933fa0..4a9f806d8 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
@@ -767,13 +767,15 @@ public class WorldDataHolder {
aGroupMap.put("permissions", group.getPermissionList());
}
- DumperOptions opt = new DumperOptions();
- opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- final Yaml yaml = new Yaml(opt);
- try {
- yaml.dump(root, new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8"));
- } catch (UnsupportedEncodingException ex) {
- } catch (FileNotFoundException ex) {
+ if (!root.isEmpty()) {
+ DumperOptions opt = new DumperOptions();
+ opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ final Yaml yaml = new Yaml(opt);
+ try {
+ yaml.dump(root, new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8"));
+ } catch (UnsupportedEncodingException ex) {
+ } catch (FileNotFoundException ex) {
+ }
}
/*FileWriter tx = null;
@@ -829,13 +831,16 @@ public class WorldDataHolder {
aUserMap.put("subgroups", user.subGroupListStringCopy());
//END SUBGROUPS NODE - BETA
}
- DumperOptions opt = new DumperOptions();
- opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- final Yaml yaml = new Yaml(opt);
- try {
- yaml.dump(root, new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8"));
- } catch (UnsupportedEncodingException ex) {
- } catch (FileNotFoundException ex) {
+
+ if (!root.isEmpty()) {
+ DumperOptions opt = new DumperOptions();
+ opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ final Yaml yaml = new Yaml(opt);
+ try {
+ yaml.dump(root, new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8"));
+ } catch (UnsupportedEncodingException ex) {
+ } catch (FileNotFoundException ex) {
+ }
}
/*FileWriter tx = null;
try {
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index a2c34be16..50e6ef547 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -21,6 +21,7 @@ import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
import org.anjocaido.groupmanager.utils.Tasks;
+import org.bukkit.World;
import org.bukkit.entity.Player;
/**
@@ -52,6 +53,7 @@ public class WorldsHolder {
*/
public WorldsHolder(GroupManager plugin) {
this.plugin = plugin;
+ // Setup folders and check files exist for the primary world
verifyFirstRun();
initialLoad();
if (defaultWorld == null) {
@@ -60,21 +62,48 @@ public class WorldsHolder {
}
private void initialLoad() {
+ // load the initial world
initialWorldLoading();
+ // Configure and load any mirrors and additional worlds as defined in config.yml
mirrorSetUp();
+ // search the worlds folder for any manually created worlds (not listed in config.yml)
+ loadAllSearchedWorlds();
}
private void initialWorldLoading() {
- //LOAD EVERY WORLD POSSIBLE
+ //Load the default world
loadWorld(serverDefaultWorldName);
defaultWorld = worldsData.get(serverDefaultWorldName);
-
+ }
+
+ private void loadAllSearchedWorlds() {
+
+ /*
+ * Read all known worlds from Bukkit
+ * Create the data files if they don't already exist,
+ * and they are not mirrored.
+ */
+ for (World world: plugin.getServer().getWorlds())
+ if ((!worldsData.containsKey(world.getName().toLowerCase()))
+ && (!mirrors.containsKey(world.getName().toLowerCase())))
+ setupWorldFolder(world.getName());
+ /*
+ * Loop over all folders within the worlds folder
+ * and attempt to load the world data
+ */
for (File folder : worldsFolder.listFiles()) {
- if (folder.getName().equalsIgnoreCase(serverDefaultWorldName)) {
- continue;
- }
- if (folder.isDirectory()) {
- loadWorld(folder.getName());
+ if (folder.isDirectory()) {
+ GroupManager.logger.info("World Found: " + folder.getName());
+
+ /*
+ * don't load any worlds which are already loaded
+ * or mirrored worlds that don't need data.
+ */
+ if (worldsData.containsKey(folder.getName().toLowerCase())
+ || mirrors.containsKey(folder.getName().toLowerCase())) {
+ continue;
+ }
+ loadWorld(folder.getName());
}
}
}
@@ -85,6 +114,12 @@ public class WorldsHolder {
Map<String, Object> mirrorsMap = plugin.getConfig().getMirrorsMap();
if (mirrorsMap != null) {
for (String source : mirrorsMap.keySet()) {
+ // Make sure all non mirrored worlds have a set of data files.
+ setupWorldFolder(source);
+ // Load the world data
+ if (!worldsData.containsKey(source.toLowerCase()))
+ loadWorld(source);
+
if (mirrorsMap.get(source) instanceof ArrayList) {
ArrayList mirrorList = (ArrayList) mirrorsMap.get(source);
for (Object o : mirrorList) {
@@ -246,18 +281,25 @@ public class WorldsHolder {
}
private void verifyFirstRun() {
- worldsFolder = new File(plugin.getDataFolder(), "worlds");
- if (!worldsFolder.exists()) {
- worldsFolder.mkdirs();
- }
+
Properties server = new Properties();
try {
server.load(new FileInputStream(new File("server.properties")));
+ serverDefaultWorldName = server.getProperty("level-name").toLowerCase();
+ setupWorldFolder(serverDefaultWorldName);
} catch (IOException ex) {
GroupManager.logger.log(Level.SEVERE, null, ex);
}
- serverDefaultWorldName = server.getProperty("level-name").toLowerCase();
- File defaultWorldFolder = new File(worldsFolder, serverDefaultWorldName);
+
+ }
+
+ public void setupWorldFolder(String worldName) {
+ worldsFolder = new File(plugin.getDataFolder(), "worlds");
+ if (!worldsFolder.exists()) {
+ worldsFolder.mkdirs();
+ }
+
+ File defaultWorldFolder = new File(worldsFolder, worldName);
if (!defaultWorldFolder.exists()) {
defaultWorldFolder.mkdirs();
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMWorldListener.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMWorldListener.java
new file mode 100644
index 000000000..037971314
--- /dev/null
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMWorldListener.java
@@ -0,0 +1,43 @@
+package org.anjocaido.groupmanager.events;
+
+import org.anjocaido.groupmanager.GroupManager;
+import org.bukkit.event.Event;
+import org.bukkit.event.world.WorldInitEvent;
+import org.bukkit.event.world.WorldListener;
+
+
+/**
+ * @author ElgarL
+ *
+ * Handle new world creation from other plugins
+ *
+ */
+public class GMWorldListener extends WorldListener {
+
+ private final GroupManager plugin;
+
+ public GMWorldListener(GroupManager instance) {
+ plugin = instance;
+ registerEvents();
+ }
+
+ private void registerEvents() {
+ plugin.getServer().getPluginManager().registerEvent(Event.Type.WORLD_INIT, this, Event.Priority.Lowest, plugin);
+ }
+
+ @Override
+ public void onWorldInit(WorldInitEvent event) {
+ String worldName = event.getWorld().getName();
+
+ if (GroupManager.isLoaded() && !plugin.getWorldsHolder().isInList(worldName)) {
+ GroupManager.logger.info("New world detected...");
+ GroupManager.logger.info("Creating data for: " + worldName);
+ plugin.getWorldsHolder().setupWorldFolder(worldName);
+ plugin.getWorldsHolder().loadWorld(worldName);
+ if (plugin.getWorldsHolder().isInList(worldName)) {
+ GroupManager.logger.info("Don't forget to configure/mirror this world in config.yml.");
+ } else
+ GroupManager.logger.severe("Failed to configure this world.");
+ }
+ }
+} \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
index 20f6331bc..19d90854b 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
@@ -43,7 +43,6 @@ import org.bukkit.event.server.ServerListener;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
-//import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@@ -93,7 +92,7 @@ public class BukkitPermissions {
manager.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Event.Priority.Normal, plugin);
}
- private void collectPermissions() {
+ public void collectPermissions() {
registeredPermissions.clear();
for (Plugin bukkitPlugin : Bukkit.getServer().getPluginManager().getPlugins()) {
for(Permission permission : bukkitPlugin.getDescription().getPermissions())
@@ -134,8 +133,8 @@ public class BukkitPermissions {
Boolean value;
for (Permission permission : registeredPermissions) {
value = worldData.getPermissionsHandler().checkUserPermission(user, permission.getName());
-
- attachment.setPermission(permission, value);
+ if (value == true)
+ attachment.setPermission(permission, value);
}
// Add any missing permissions for this player (non bukkit plugins)
@@ -199,7 +198,7 @@ public class BukkitPermissions {
@Override
public void onPlayerPortal(PlayerPortalEvent event) { // will portal into another world
- if(!event.getFrom().getWorld().equals(event.getTo().getWorld())){ // only if world actually changed
+ if(event.getTo() != null && !event.getFrom().getWorld().equals(event.getTo().getWorld())){ // only if world actually changed
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
}
}
@@ -211,7 +210,7 @@ public class BukkitPermissions {
@Override
public void onPlayerTeleport(PlayerTeleportEvent event) { // can be teleported into another world
- if (!event.getFrom().getWorld().equals(event.getTo().getWorld())) { // only if world actually changed
+ if (event.getTo() != null && !event.getFrom().getWorld().equals(event.getTo().getWorld())) { // only if world actually changed
updatePermissions(event.getPlayer(), event.getTo().getWorld().getName());
}
}
diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml
index b0d2bc4d1..a247c7ad0 100644
--- a/EssentialsGroupManager/src/plugin.yml
+++ b/EssentialsGroupManager/src/plugin.yml
@@ -1,5 +1,5 @@
name: GroupManager
-version: "1.2 (Phoenix)"
+version: "1.3 (Phoenix)"
main: org.anjocaido.groupmanager.GroupManager
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.
diff --git a/lib/bPermissions.jar b/lib/bPermissions.jar
index 26ddcb970..8fa949ce6 100644
--- a/lib/bPermissions.jar
+++ b/lib/bPermissions.jar
Binary files differ
diff --git a/lib/bukkit-0.0.1-SNAPSHOT.jar b/lib/bukkit-0.0.1-SNAPSHOT.jar
index 63232deae..b348aa103 100644
--- a/lib/bukkit-0.0.1-SNAPSHOT.jar
+++ b/lib/bukkit-0.0.1-SNAPSHOT.jar
Binary files differ
diff --git a/lib/craftbukkit-0.0.1-SNAPSHOT.jar b/lib/craftbukkit-0.0.1-SNAPSHOT.jar
index 154265890..5e0ccde38 100644
--- a/lib/craftbukkit-0.0.1-SNAPSHOT.jar
+++ b/lib/craftbukkit-0.0.1-SNAPSHOT.jar
Binary files differ