Merge branch 'master' of github.com:essentials/Essentials

This commit is contained in:
KHobbits 2012-04-14 15:58:12 +01:00
commit b3847270fa
7 changed files with 44 additions and 31 deletions

View File

@ -232,8 +232,11 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvents(worldListener, this);
//TODO: Check if this should be here, and not above before reload()
jails = new Jails(this);
confList.add(jails);
if (settings.isJailsEnabled())
{
jails = new Jails(this);
confList.add(jails);
}
pm.registerEvents(tntListener, this);
@ -428,9 +431,16 @@ public class Essentials extends JavaPlugin implements IEssentials
}
@Override
public IJails getJails()
public IJails getJails() throws UnsupportedOperationException
{
return jails;
if (jails == null)
{
throw new UnsupportedOperationException("Jails are not enabled in your configuration");
}
else
{
return jails;
}
}
@Override

View File

@ -31,13 +31,11 @@ import org.bukkit.inventory.ItemStack;
public class EssentialsPlayerListener implements Listener
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Server server;
private final transient IEssentials ess;
public EssentialsPlayerListener(final IEssentials parent)
{
this.ess = parent;
this.server = parent.getServer();
}
@EventHandler(priority = EventPriority.NORMAL)
@ -218,7 +216,7 @@ public class EssentialsPlayerListener implements Listener
return;
}
User user = ess.getUser(event.getPlayer());
final User user = ess.getUser(event.getPlayer());
if (user.isNPC())
{
user.setNPC(false);
@ -247,8 +245,8 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
boolean backListener = ess.getSettings().registerBackInListener();
boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability();
final boolean backListener = ess.getSettings().registerBackInListener();
final boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability();
if (backListener || teleportInvulnerability)
{
final User user = ess.getUser(event.getPlayer());
@ -320,19 +318,16 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
{
final User user = ess.getUser(event.getPlayer());
final User user = ess.getUser(event.getPlayer());
final String newWorld = event.getPlayer().getLocation().getWorld().getName();
user.setDisplayNick();
updateCompass(user);
if (ess.getSettings().getNoGodWorlds().contains(newWorld))
if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw())
{
if (user.isGodModeEnabledRaw())
{
user.sendMessage(_("noGodWorldWarning"));
}
user.sendMessage(_("noGodWorldWarning"));
}
if(!event.getPlayer().getWorld().getName().equals(newWorld))
if (!event.getPlayer().getWorld().getName().equals(newWorld))
{
user.sendMessage(_("currentWorld", newWorld));
}
@ -344,11 +339,7 @@ public class EssentialsPlayerListener implements Listener
switch (event.getAction())
{
case RIGHT_CLICK_BLOCK:
if (event.isCancelled())
{
return;
}
if (event.getClickedBlock().getTypeId() == Material.BED_BLOCK.getId() && ess.getSettings().getUpdateBedAtDaytime())
if (!event.isCancelled() && event.getClickedBlock().getTypeId() == Material.BED_BLOCK.getId() && ess.getSettings().getUpdateBedAtDaytime())
{
event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
}
@ -409,14 +400,12 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerPickupItem(final PlayerPickupItemEvent event)
{
if (!ess.getSettings().getDisableItemPickupWhileAfk())
if (ess.getSettings().getDisableItemPickupWhileAfk())
{
return;
}
final User user = ess.getUser(event.getPlayer());
if (user.isAfk())
{
event.setCancelled(true);
if (ess.getUser(event.getPlayer()).isAfk())
{
event.setCancelled(true);
}
}
}

View File

@ -37,7 +37,7 @@ public interface IEssentials extends Plugin
BukkitScheduler getScheduler();
IJails getJails();
IJails getJails() throws UnsupportedOperationException;
Warps getWarps();

View File

@ -173,4 +173,6 @@ public interface ISettings extends IConf
long getTeleportInvulnerability();
boolean isTeleportInvulnerability();
boolean isJailsEnabled();
}

View File

@ -780,4 +780,10 @@ public class Settings implements ISettings
{
return teleportInvulnerability;
}
@Override
public boolean isJailsEnabled()
{
return config.getBoolean("enable-jails", true);
}
}

View File

@ -171,6 +171,9 @@ public class MetricsStarter implements Runnable
metrics.start();
}
catch (UnsupportedOperationException ex)
{
}
catch (Exception ex)
{

View File

@ -44,6 +44,9 @@ change-displayname: true
# Don't forget to remove the # infront of the line
#add-prefix-suffix: false
# Whether or not jails are activated
enable-jails: true
# The delay, in seconds, required between /home, /tp, etc.
teleport-cooldown: 0
@ -584,7 +587,7 @@ newbies:
# When we spawn for the first time, which spawnpoint do we use?
# Set to "none" if you want to use the spawn point of the world.
spawnpoint: newbies
# Do we want to give users anything on first join? Set to '' to disable
# This kit will be given reguardless of cost, and permissions.
#kit: ''