This commit is contained in:
Iaccidentally 2013-01-02 18:24:34 -05:00
commit 9b8991788b
36 changed files with 443 additions and 167 deletions

View File

@ -78,6 +78,7 @@ file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
file.reference.Privileges.jar=..\\lib\\Privileges.jar file.reference.Privileges.jar=..\\lib\\Privileges.jar
file.reference.Vault.jar=../lib/Vault.jar file.reference.Vault.jar=../lib/Vault.jar
file.reference.SimplyPerms.jar=../lib/SimplyPerms.jar
includes=** includes=**
jar.archive.disabled=${jnlp.enabled} jar.archive.disabled=${jnlp.enabled}
jar.compress=true jar.compress=true
@ -97,7 +98,8 @@ javac.classpath=\
${file.reference.bukkit.jar}:\ ${file.reference.bukkit.jar}:\
${file.reference.Vault.jar}:\ ${file.reference.Vault.jar}:\
${file.reference.Privileges.jar}:\ ${file.reference.Privileges.jar}:\
${file.reference.bpermissions2.jar} ${file.reference.bpermissions2.jar}:\
${file.reference.SimplyPerms.jar}
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs=-Xlint:unchecked javac.compilerargs=-Xlint:unchecked
javac.deprecation=false javac.deprecation=false

View File

@ -20,7 +20,7 @@ public class Enchantments
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL); ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
ALIASENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL); ALIASENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL); ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL); ALIASENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
ALIASENCHANTMENTS.put("dal", Enchantment.DAMAGE_ALL); ALIASENCHANTMENTS.put("dal", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS); ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
@ -40,10 +40,16 @@ public class Enchantments
ALIASENCHANTMENTS.put("ds", Enchantment.DIG_SPEED); ALIASENCHANTMENTS.put("ds", Enchantment.DIG_SPEED);
ENCHANTMENTS.put("durability", Enchantment.DURABILITY); ENCHANTMENTS.put("durability", Enchantment.DURABILITY);
ENCHANTMENTS.put("dura", Enchantment.DURABILITY); ALIASENCHANTMENTS.put("dura", Enchantment.DURABILITY);
ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY); ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY);
ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY); ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY);
ENCHANTMENTS.put("thorns", Enchantment.THORNS);
ENCHANTMENTS.put("highcrit", Enchantment.THORNS);
ALIASENCHANTMENTS.put("thorn", Enchantment.THORNS);
ALIASENCHANTMENTS.put("highercrit", Enchantment.THORNS);
ALIASENCHANTMENTS.put("t", Enchantment.THORNS);
ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT); ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT);
ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT); ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT);
ALIASENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT); ALIASENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT);
@ -83,7 +89,7 @@ public class Enchantments
ALIASENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL); ALIASENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL); ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL); ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL); ALIASENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
ALIASENCHANTMENTS.put("pfa", Enchantment.PROTECTION_FALL); ALIASENCHANTMENTS.put("pfa", Enchantment.PROTECTION_FALL);
ALIASENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE); ALIASENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
@ -129,7 +135,7 @@ public class Enchantments
ALIASENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE); ALIASENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE);
ALIASENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE); ALIASENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE);
ALIASENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE); ALIASENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE); ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE);
} }
public static Enchantment getByName(String name) { public static Enchantment getByName(String name) {

View File

@ -50,6 +50,7 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
@ -176,6 +177,8 @@ public class Essentials extends JavaPlugin implements IEssentials
itemDb = new ItemDb(this); itemDb = new ItemDb(this);
confList.add(itemDb); confList.add(itemDb);
execTimer.mark("Init(Worth/ItemDB)"); execTimer.mark("Init(Worth/ItemDB)");
jails = new Jails(this);
confList.add(jails);
reload(); reload();
} }
catch (YAMLException exception) catch (YAMLException exception)
@ -207,6 +210,39 @@ public class Essentials extends JavaPlugin implements IEssentials
backup = new Backup(this); backup = new Backup(this);
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions()); permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
alternativeCommandsHandler = new AlternativeCommandsHandler(this); alternativeCommandsHandler = new AlternativeCommandsHandler(this);
timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
Economy.setEss(this);
execTimer.mark("RegHandler");
final MetricsStarter metricsStarter = new MetricsStarter(this);
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
{
getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1);
}
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
{
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
pm.registerEvents(metricsListener, this);
}
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
}
}
private void registerListeners(PluginManager pm) {
HandlerList.unregisterAll(this);
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Registering Listeners");
}
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this); final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
pm.registerEvents(serverListener, this); pm.registerEvents(serverListener, this);
confList.add(serverListener); confList.add(serverListener);
@ -231,35 +267,10 @@ public class Essentials extends JavaPlugin implements IEssentials
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this); final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
pm.registerEvents(worldListener, this); pm.registerEvents(worldListener, this);
//TODO: Check if this should be here, and not above before reload()
jails = new Jails(this);
confList.add(jails);
pm.registerEvents(tntListener, this); pm.registerEvents(tntListener, this);
timer = new EssentialsTimer(this); jails.resetListener();
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
Economy.setEss(this);
execTimer.mark("RegListeners");
final MetricsStarter metricsStarter = new MetricsStarter(this);
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
{
getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1);
}
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
{
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
pm.registerEvents(metricsListener, this);
}
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
}
} }
@Override @Override
@ -291,6 +302,9 @@ public class Essentials extends JavaPlugin implements IEssentials
} }
i18n.updateLocale(settings.getLocale()); i18n.updateLocale(settings.getLocale());
final PluginManager pm = getServer().getPluginManager();
registerListeners(pm);
} }
@Override @Override

View File

@ -28,8 +28,7 @@ public class EssentialsBlockListener implements Listener
return; return;
} }
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
final boolean unlimitedForUser = user.hasUnlimited(is); if (user.hasUnlimited(is) && user.getGameMode() == GameMode.SURVIVAL)
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
{ {
ess.scheduleSyncDelayedTask( ess.scheduleSyncDelayedTask(
new Runnable() new Runnable()

View File

@ -30,44 +30,40 @@ public class EssentialsEntityListener implements Listener
{ {
final Entity eAttack = event.getDamager(); final Entity eAttack = event.getDamager();
final Entity eDefend = event.getEntity(); final Entity eDefend = event.getEntity();
if (eDefend instanceof Player && eAttack instanceof Player) if (eAttack instanceof Player)
{ {
final User defender = ess.getUser(eDefend);
final User attacker = ess.getUser(eAttack); final User attacker = ess.getUser(eAttack);
onPlayerVsPlayerDamage(event, defender, attacker); if (eDefend instanceof Player)
onPlayerVsPlayerPowertool(event, defender, attacker);
}
else if (eDefend instanceof Player && eAttack instanceof Projectile)
{
Entity shooter = ((Projectile)event.getDamager()).getShooter();
if (shooter instanceof Player)
{ {
final User defender = ess.getUser(eDefend); onPlayerVsPlayerDamage(event, (Player)eDefend, attacker);
final User attacker = ess.getUser(shooter);
onPlayerVsPlayerDamage(event, defender, attacker);
onPlayerVsPlayerPowertool(event, defender, attacker);
} }
} else if (eDefend instanceof Ageable)
else if (eAttack instanceof Player)
{
final User player = ess.getUser(eAttack);
player.updateActivity(true);
if (eDefend instanceof Ageable)
{ {
final ItemStack hand = player.getItemInHand(); final ItemStack hand = attacker.getItemInHand();
if (hand != null && hand.getType() == Material.MILK_BUCKET) if (hand != null && hand.getType() == Material.MILK_BUCKET)
{ {
((Ageable)eDefend).setBaby(); ((Ageable)eDefend).setBaby();
hand.setType(Material.BUCKET); hand.setType(Material.BUCKET);
player.setItemInHand(hand); attacker.setItemInHand(hand);
player.updateInventory(); attacker.updateInventory();
event.setCancelled(true); event.setCancelled(true);
} }
} }
attacker.updateActivity(true);
}
else if (eAttack instanceof Projectile && eDefend instanceof Player)
{
Entity shooter = ((Projectile)event.getDamager()).getShooter();
if (shooter instanceof Player)
{
final User attacker = ess.getUser(shooter);
onPlayerVsPlayerDamage(event, (Player)eDefend, attacker);
attacker.updateActivity(true);
}
} }
} }
private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final User defender, final User attacker) private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
{ {
if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt") if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt")
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay()))) && (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())))
@ -75,7 +71,7 @@ public class EssentialsEntityListener implements Listener
event.setCancelled(true); event.setCancelled(true);
} }
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport()) if (!defender.equals(attacker.getBase()) && (attacker.hasInvulnerabilityAfterTeleport() || ess.getUser(defender).hasInvulnerabilityAfterTeleport()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -90,10 +86,10 @@ public class EssentialsEntityListener implements Listener
event.setCancelled(true); event.setCancelled(true);
} }
attacker.updateActivity(true); onPlayerVsPlayerPowertool(event, defender, attacker);
} }
private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final User defender, final User attacker) private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
{ {
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand()); final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
if (commandList != null && !commandList.isEmpty()) if (commandList != null && !commandList.isEmpty())

View File

@ -15,6 +15,7 @@ import java.util.logging.Logger;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -26,6 +27,7 @@ import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerLoginEvent.Result; import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -76,10 +78,20 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event) public void onPlayerMove(final PlayerMoveEvent event)
{ {
if ((!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers()) if (!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
|| event.getFrom().getBlockX() == event.getTo().getBlockX() {
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ() event.getHandlers().unregister(this);
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Unregistering move listener");
}
return;
}
if (event.getFrom().getBlockX() == event.getTo().getBlockX()
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
{ {
return; return;
} }
@ -131,6 +143,10 @@ public class EssentialsPlayerListener implements Listener
{ {
user.setLastLocation(); user.setLastLocation();
} }
if (user.isRecipeSee())
{
user.getPlayer().getOpenInventory().getTopInventory().clear();
}
user.updateActivity(false); user.updateActivity(false);
user.dispose(); user.dispose();
} }
@ -223,6 +239,24 @@ public class EssentialsPlayerListener implements Listener
user.sendMessage(_("youHaveNewMail", mail.size())); user.sendMessage(_("youHaveNewMail", mail.size()));
} }
} }
if (user.isAuthorized("essentials.fly.safelogin"))
{
final World world = user.getLocation().getWorld();
final int x = user.getLocation().getBlockX();
int y = user.getLocation().getBlockY();
final int z = user.getLocation().getBlockZ();
while (Util.isBlockUnsafe(world, x, y, z) && y > -1)
{
y--;
}
if (user.getLocation().getBlockY() - y > 1 || y < 0)
{
user.setAllowFlight(true);
user.setFlying(true);
user.sendMessage(_("flyMode", _("enabled"), user.getDisplayName()));
}
}
} }
// Makes the compass item ingame always point to the first essentials home. #EasterEgg // Makes the compass item ingame always point to the first essentials home. #EasterEgg
@ -514,10 +548,13 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onInventoryClickEvent(final InventoryClickEvent event) public void onInventoryClickEvent(final InventoryClickEvent event)
{ {
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER) final Inventory top = event.getView().getTopInventory();
final InventoryType type = top.getType();
if (type == InventoryType.PLAYER)
{ {
final User user = ess.getUser(event.getWhoClicked()); final User user = ess.getUser(event.getWhoClicked());
final InventoryHolder invHolder = event.getView().getTopInventory().getHolder(); final InventoryHolder invHolder = top.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity) if (invHolder != null && invHolder instanceof HumanEntity)
{ {
final User invOwner = ess.getUser((HumanEntity)invHolder); final User invOwner = ess.getUser((HumanEntity)invHolder);
@ -526,10 +563,11 @@ public class EssentialsPlayerListener implements Listener
|| !invOwner.isOnline())) || !invOwner.isOnline()))
{ {
event.setCancelled(true); event.setCancelled(true);
user.updateInventory();
} }
} }
} }
else if (event.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST) else if (type == InventoryType.ENDER_CHEST)
{ {
final User user = ess.getUser(event.getWhoClicked()); final User user = ess.getUser(event.getWhoClicked());
if (user.isEnderSee() && (!user.isAuthorized("essentials.enderchest.modify"))) if (user.isEnderSee() && (!user.isAuthorized("essentials.enderchest.modify")))
@ -537,7 +575,7 @@ public class EssentialsPlayerListener implements Listener
event.setCancelled(true); event.setCancelled(true);
} }
} }
else if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH) else if (type == InventoryType.WORKBENCH)
{ {
User user = ess.getUser(event.getWhoClicked()); User user = ess.getUser(event.getWhoClicked());
if (user.isRecipeSee()) if (user.isRecipeSee())
@ -545,30 +583,50 @@ public class EssentialsPlayerListener implements Listener
event.setCancelled(true); event.setCancelled(true);
} }
} }
else if (type == InventoryType.CHEST && top.getSize() == 9)
{
final User user = ess.getUser(event.getWhoClicked());
final InventoryHolder invHolder = top.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity && user.isInvSee())
{
event.setCancelled(true);
}
}
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onInventoryCloseEvent(final InventoryCloseEvent event) public void onInventoryCloseEvent(final InventoryCloseEvent event)
{ {
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER) final Inventory top = event.getView().getTopInventory();
final InventoryType type = top.getType();
if (type == InventoryType.PLAYER)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
user.setInvSee(false); user.setInvSee(false);
} }
else if (event.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST) else if (type == InventoryType.ENDER_CHEST)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
user.setEnderSee(false); user.setEnderSee(false);
} }
if (event.getView().getTopInventory().getType() == InventoryType.WORKBENCH) else if (type == InventoryType.WORKBENCH)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
if(user.isRecipeSee()) if (user.isRecipeSee())
{ {
user.setRecipeSee(false); user.setRecipeSee(false);
event.getView().getTopInventory().clear(); event.getView().getTopInventory().clear();
} }
} }
else if (type == InventoryType.CHEST && top.getSize() == 9)
{
final InventoryHolder invHolder = top.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity)
{
final User user = ess.getUser(event.getPlayer());
user.setInvSee(false);
}
}
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)

View File

@ -151,6 +151,8 @@ public interface ISettings extends IConf
Set<String> getNoGodWorlds(); Set<String> getNoGodWorlds();
boolean getUpdateBedAtDaytime(); boolean getUpdateBedAtDaytime();
boolean allowUnsafeEnchantments();
boolean getRepairEnchanted(); boolean getRepairEnchanted();

View File

@ -44,6 +44,10 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
final PluginManager pluginManager = ess.getServer().getPluginManager(); final PluginManager pluginManager = ess.getServer().getPluginManager();
final JailListener blockListener = new JailListener(); final JailListener blockListener = new JailListener();
pluginManager.registerEvents(blockListener, ess); pluginManager.registerEvents(blockListener, ess);
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Registering Jail listener");
}
} }
@Override @Override
@ -55,16 +59,24 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
@Override @Override
public void finishRead() public void finishRead()
{ {
if (enabled == false && getCount() > 0) checkRegister();
{
registerListeners();
}
} }
@Override @Override
public void finishWrite() public void finishWrite()
{ {
if (enabled == false) checkRegister();
}
public void resetListener()
{
enabled = false;
checkRegister();
}
private void checkRegister()
{
if (enabled == false && getCount() > 0)
{ {
registerListeners(); registerListeners();
} }

View File

@ -34,12 +34,13 @@ public class Kit
{ {
throw new Exception(_("kitError"), ex); throw new Exception(_("kitError"), ex);
} }
} }
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws Exception public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws Exception
{ {
if (user.isAuthorized("essentials.kit.exemptdelay")) { if (user.isAuthorized("essentials.kit.exemptdelay"))
{
return; return;
} }
@ -55,7 +56,7 @@ public class Kit
// When was the last kit used? // When was the last kit used?
final long lastTime = user.getKitTimestamp(kitName); final long lastTime = user.getKitTimestamp(kitName);
if (lastTime < earliestLong || lastTime == 0L) if (lastTime < earliestLong || lastTime == 0L)
{ {
user.setKitTimestamp(kitName, time.getTimeInMillis()); user.setKitTimestamp(kitName, time.getTimeInMillis());
@ -80,15 +81,15 @@ public class Kit
throw new NoChargeException(); throw new NoChargeException();
} }
} }
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
{ {
if (kit == null) if (kit == null)
{ {
throw new Exception(_("kitError2")); throw new Exception(_("kitError2"));
} }
try try
{ {
return (List<String>)kit.get("items"); return (List<String>)kit.get("items");
@ -99,7 +100,7 @@ public class Kit
throw new Exception(_("kitErrorHelp"), e); throw new Exception(_("kitErrorHelp"), e);
} }
} }
public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception
{ {
try try
@ -107,7 +108,7 @@ public class Kit
boolean spew = false; boolean spew = false;
for (String d : items) for (String d : items)
{ {
if (d.startsWith(ess.getSettings().getCurrencySymbol())) if (d.startsWith(ess.getSettings().getCurrencySymbol()))
{ {
Double value = Double.parseDouble(d.substring(ess.getSettings().getCurrencySymbol().length()).trim()); Double value = Double.parseDouble(d.substring(ess.getSettings().getCurrencySymbol().length()).trim());
Trade t = new Trade(value, ess); Trade t = new Trade(value, ess);
@ -119,7 +120,7 @@ public class Kit
final int id = Material.getMaterial(Integer.parseInt(item[0])).getId(); final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
final short data = item.length > 1 ? Short.parseShort(item[1]) : 0; final short data = item.length > 1 ? Short.parseShort(item[1]) : 0;
final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1; final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1;
final ItemStack stack = new ItemStack(id, amount, data); final ItemStack stack = new ItemStack(id, amount, data);
if (parts.length > 2) if (parts.length > 2)
{ {
@ -146,7 +147,14 @@ public class Kit
} }
try try
{ {
stack.addEnchantment(enchantment, level); if (ess.getSettings().allowUnsafeEnchantments())
{
stack.addUnsafeEnchantment(enchantment, level);
}
else
{
stack.addEnchantment(enchantment, level);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -154,7 +162,7 @@ public class Kit
} }
} }
} }
final Map<Integer, ItemStack> overfilled; final Map<Integer, ItemStack> overfilled;
if (user.isAuthorized("essentials.oversizedstacks")) if (user.isAuthorized("essentials.oversizedstacks"))
{ {

View File

@ -1150,4 +1150,10 @@ public class OfflinePlayer implements Player
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public void setTexturePack(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
} }

View File

@ -856,6 +856,12 @@ public class Settings implements ISettings
{ {
return config.getBoolean("repair-enchanted", true); return config.getBoolean("repair-enchanted", true);
} }
@Override
public boolean allowUnsafeEnchantments()
{
return config.getBoolean("unsafe-enchantments", false);
}
@Override @Override
public boolean isWorldTeleportPermissions() public boolean isWorldTeleportPermissions()
@ -923,7 +929,7 @@ public class Settings implements ISettings
@Override @Override
public long getTpaAcceptCancellation() public long getTpaAcceptCancellation()
{ {
return config.getLong("tpa-accept-cancellation", 0); return config.getLong("tpa-accept-cancellation", 120);
} }
@Override @Override

View File

@ -16,30 +16,30 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Teleport implements Runnable, ITeleport public class Teleport implements Runnable, ITeleport
{ {
private static final double MOVE_CONSTANT = 0.3; private static final double MOVE_CONSTANT = 0.3;
private class Target private class Target
{ {
private final Location location; private final Location location;
private final String name; private final String name;
Target(Location location) Target(Location location)
{ {
this.location = location; this.location = location;
this.name = null; this.name = null;
} }
Target(Player entity) Target(Player entity)
{ {
this.name = entity.getName(); this.name = entity.getName();
this.location = null; this.location = null;
} }
public Location getLocation() public Location getLocation()
{ {
if (this.name != null) if (this.name != null)
{ {
return ess.getServer().getPlayerExact(name).getLocation(); return ess.getServer().getPlayerExact(name).getLocation();
} }
return location; return location;
@ -63,12 +63,12 @@ public class Teleport implements Runnable, ITeleport
private final IEssentials ess; private final IEssentials ess;
private static final Logger logger = Logger.getLogger("Minecraft"); private static final Logger logger = Logger.getLogger("Minecraft");
private TeleportCause cause; private TeleportCause cause;
private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause) private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause)
{ {
initTimer(delay, user, target, chargeFor, cause, false); initTimer(delay, user, target, chargeFor, cause, false);
} }
private void initTimer(long delay, IUser teleportUser, Target target, Trade chargeFor, TeleportCause cause, boolean respawn) private void initTimer(long delay, IUser teleportUser, Target target, Trade chargeFor, TeleportCause cause, boolean respawn)
{ {
this.started = System.currentTimeMillis(); this.started = System.currentTimeMillis();
@ -83,11 +83,11 @@ public class Teleport implements Runnable, ITeleport
this.cause = cause; this.cause = cause;
this.respawn = respawn; this.respawn = respawn;
} }
@Override @Override
public void run() public void run()
{ {
if (user == null || !user.isOnline() || user.getLocation() == null) if (user == null || !user.isOnline() || user.getLocation() == null)
{ {
cancel(false); cancel(false);
@ -98,7 +98,7 @@ public class Teleport implements Runnable, ITeleport
cancel(false); cancel(false);
return; return;
} }
if (!user.isAuthorized("essentials.teleport.timer.move") if (!user.isAuthorized("essentials.teleport.timer.move")
&& (Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT) != initX && (Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT) != initX
|| Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT) != initY || Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT) != initY
@ -119,10 +119,12 @@ public class Teleport implements Runnable, ITeleport
teleportUser.sendMessage(_("teleportationCommencing")); teleportUser.sendMessage(_("teleportationCommencing"));
try try
{ {
if (respawn) { if (respawn)
{
teleportUser.getTeleport().respawn(cause); teleportUser.getTeleport().respawn(cause);
} }
else { else
{
teleportUser.getTeleport().now(teleportTarget, cause); teleportUser.getTeleport().now(teleportTarget, cause);
} }
cancel(false); cancel(false);
@ -146,13 +148,13 @@ public class Teleport implements Runnable, ITeleport
} }
} }
} }
public Teleport(IUser user, IEssentials ess) public Teleport(IUser user, IEssentials ess)
{ {
this.user = user; this.user = user;
this.ess = ess; this.ess = ess;
} }
public void cooldown(boolean check) throws Exception public void cooldown(boolean check) throws Exception
{ {
final Calendar time = new GregorianCalendar(); final Calendar time = new GregorianCalendar();
@ -168,7 +170,7 @@ public class Teleport implements Runnable, ITeleport
// When was the last teleport used? // When was the last teleport used?
final Long lastTime = user.getLastTeleportTimestamp(); final Long lastTime = user.getLastTeleportTimestamp();
if (lastTime > time.getTimeInMillis()) if (lastTime > time.getTimeInMillis())
{ {
// This is to make sure time didn't get messed up on last kit use. // This is to make sure time didn't get messed up on last kit use.
@ -225,7 +227,7 @@ public class Teleport implements Runnable, ITeleport
} }
now(new Target(loc), cause); now(new Target(loc), cause);
} }
public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
{ {
if (cooldown) if (cooldown)
@ -234,7 +236,7 @@ public class Teleport implements Runnable, ITeleport
} }
now(new Target(entity), cause); now(new Target(entity), cause);
} }
private void now(Target target, TeleportCause cause) throws Exception private void now(Target target, TeleportCause cause) throws Exception
{ {
cancel(false); cancel(false);
@ -249,21 +251,21 @@ public class Teleport implements Runnable, ITeleport
{ {
teleport(loc, chargeFor, TeleportCause.PLUGIN); teleport(loc, chargeFor, TeleportCause.PLUGIN);
} }
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{ {
teleport(new Target(loc), chargeFor, cause); teleport(new Target(loc), chargeFor, cause);
} }
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception
{ {
teleport(new Target(entity), chargeFor, cause); teleport(new Target(entity), chargeFor, cause);
} }
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
{ {
double delay = ess.getSettings().getTeleportDelay(); double delay = ess.getSettings().getTeleportDelay();
if (chargeFor != null) if (chargeFor != null)
{ {
chargeFor.isAffordableFor(user); chargeFor.isAffordableFor(user);
@ -279,11 +281,11 @@ public class Teleport implements Runnable, ITeleport
} }
return; return;
} }
cancel(false); cancel(false);
warnUser(user, delay); warnUser(user, delay);
initTimer((long)(delay * 1000.0), target, chargeFor, cause); initTimer((long)(delay * 1000.0), target, chargeFor, cause);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10); teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
} }
@ -292,7 +294,7 @@ public class Teleport implements Runnable, ITeleport
{ {
Target target = new Target(user); Target target = new Target(user);
double delay = ess.getSettings().getTeleportDelay(); double delay = ess.getSettings().getTeleportDelay();
if (chargeFor != null) if (chargeFor != null)
{ {
chargeFor.isAffordableFor(user); chargeFor.isAffordableFor(user);
@ -308,13 +310,13 @@ public class Teleport implements Runnable, ITeleport
} }
return; return;
} }
cancel(false); cancel(false);
warnUser(otherUser, delay); warnUser(otherUser, delay);
initTimer((long)(delay * 1000.0), otherUser, target, chargeFor, cause, false); initTimer((long)(delay * 1000.0), otherUser, target, chargeFor, cause, false);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10); teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
} }
private void warnUser(final IUser user, final double delay) private void warnUser(final IUser user, final double delay)
{ {
Calendar c = new GregorianCalendar(); Calendar c = new GregorianCalendar();
@ -342,22 +344,27 @@ public class Teleport implements Runnable, ITeleport
} }
return; return;
} }
cancel(false); cancel(false);
warnUser(user, delay);
initTimer((long)(delay * 1000.0), user, null, chargeFor, cause, true); initTimer((long)(delay * 1000.0), user, null, chargeFor, cause, true);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10); teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
} }
public void respawn(TeleportCause cause) throws Exception public void respawn(TeleportCause cause) throws Exception
{ {
final Player player = user.getBase(); final Player player = user.getBase();
Location bed = player.getBedSpawnLocation(); Location bed = player.getBedSpawnLocation();
if (bed != null && bed.getBlock().getType() != Material.BED_BLOCK) if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK)
{ {
now(new Target(bed), cause); now(new Target(bed), cause);
} }
else else
{ {
if (ess.getSettings().isDebug())
{
ess.getLogger().info("Could not find bed spawn, forcing respawn event.");
}
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false); final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
ess.getServer().getPluginManager().callEvent(pre); ess.getServer().getPluginManager().callEvent(pre);
now(new Target(pre.getRespawnLocation()), cause); now(new Target(pre.getRespawnLocation()), cause);

View File

@ -12,6 +12,8 @@ import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class User extends UserData implements Comparable<User>, IReplyTo, IUser public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@ -536,7 +538,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setDisplayNick(); setDisplayNick();
final String msg = _("userIsNotAway", getDisplayName()); final String msg = _("userIsNotAway", getDisplayName());
if (!msg.isEmpty()) if (!msg.isEmpty())
{ {
ess.broadcastMessage(this, msg); ess.broadcastMessage(this, msg);
} }
} }
@ -573,7 +575,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setDisplayNick(); setDisplayNick();
final String msg = _("userIsAway", getDisplayName()); final String msg = _("userIsAway", getDisplayName());
if (!msg.isEmpty()) if (!msg.isEmpty())
{ {
ess.broadcastMessage(this, msg); ess.broadcastMessage(this, msg);
} }
} }
@ -685,6 +687,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
} }
setHidden(true); setHidden(true);
ess.getVanishedPlayers().add(getName()); ess.getVanishedPlayers().add(getName());
if (isAuthorized("essentials.vanish.effect"))
{
this.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
}
} }
else else
{ {
@ -694,6 +700,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
} }
setHidden(false); setHidden(false);
ess.getVanishedPlayers().remove(getName()); ess.getVanishedPlayers().remove(getName());
if (isAuthorized("essentials.vanish.effect"))
{
this.removePotionEffect(PotionEffectType.INVISIBILITY);
}
} }
} }
@ -737,7 +747,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override @Override
public boolean isIgnoreExempt() public boolean isIgnoreExempt()
{ {
return this.isAuthorized("essentials.chat.ignoreexempt"); return this.isAuthorized("essentials.chat.ignoreexempt");
} }
public boolean isRecipeSee() public boolean isRecipeSee()

View File

@ -71,7 +71,7 @@ public class Commandban extends EssentialsCommand
server.getLogger().log(Level.INFO, _("playerBanned", senderName, user.getName(), banReason)); server.getLogger().log(Level.INFO, _("playerBanned", senderName, user.getName(), banReason));
if (nomatch) { if (nomatch) {
sender.sendMessage(_("userUnknown", user.getName())); sender.sendMessage(_("userUnknown", args[0]));
} }
for (Player onlinePlayer : server.getOnlinePlayers()) for (Player onlinePlayer : server.getOnlinePlayers())

View File

@ -35,7 +35,7 @@ public class Commandenchant extends EssentialsCommand
for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet()) for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet())
{ {
final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH); final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName)) if (enchantmentslist.contains(enchantmentName) || (user.isAuthorized("essentials.enchant." + enchantmentName) && entry.getValue().canEnchantItem(stack)))
{ {
enchantmentslist.add(entry.getKey()); enchantmentslist.add(entry.getKey());
//enchantmentslist.add(enchantmentName); //enchantmentslist.add(enchantmentName);
@ -56,7 +56,8 @@ public class Commandenchant extends EssentialsCommand
} }
} }
final Enchantment enchantment = getEnchantment(args[0], user); final Enchantment enchantment = getEnchantment(args[0], user);
if (level < 0 || level > enchantment.getMaxLevel()) final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe");
if (level < 0 || (!allowUnsafe && level > enchantment.getMaxLevel()))
{ {
level = enchantment.getMaxLevel(); level = enchantment.getMaxLevel();
} }
@ -66,7 +67,14 @@ public class Commandenchant extends EssentialsCommand
} }
else else
{ {
stack.addEnchantment(enchantment, level); if (allowUnsafe)
{
stack.addUnsafeEnchantment(enchantment, level);
}
else
{
stack.addEnchantment(enchantment, level);
}
} }
user.getInventory().setItemInHand(stack); user.getInventory().setItemInHand(stack);
user.updateInventory(); user.updateInventory();

View File

@ -81,7 +81,19 @@ public class Commandgive extends EssentialsCommand
{ {
level = enchantment.getMaxLevel(); level = enchantment.getMaxLevel();
} }
stack.addEnchantment(enchantment, level); boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
if (allowUnsafe && sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.enchant.allowunsafe"))
{
allowUnsafe = false;
}
if (allowUnsafe)
{
stack.addUnsafeEnchantment(enchantment, level);
}
else
{
stack.addEnchantment(enchantment, level);
}
} }
} }

View File

@ -69,7 +69,7 @@ public class Commandhome extends EssentialsCommand
} }
else if (homes.isEmpty()) else if (homes.isEmpty())
{ {
throw new Exception(player == user ? _("noHomeSet") : _("noHomeSetPlayer")); throw new Exception(_("noHomeSetPlayer"));
} }
else if (homes.size() == 1 && player.equals(user)) else if (homes.size() == 1 && player.equals(user))
{ {

View File

@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.inventory.Inventory;
public class Commandinvsee extends EssentialsCommand public class Commandinvsee extends EssentialsCommand
@ -10,6 +11,8 @@ public class Commandinvsee extends EssentialsCommand
{ {
super("invsee"); super("invsee");
} }
//This method has a hidden param, which if given will display the equip slots. #easteregg
@Override @Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
@ -18,8 +21,20 @@ public class Commandinvsee extends EssentialsCommand
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
final User invUser = getPlayer(server, args, 0); final User invUser = getPlayer(server, args, 0);
Inventory inv;
if (args.length > 1 && user.isAuthorized("essentials.invsee.equip"))
{
inv = server.createInventory(invUser, 9, "Equipped");
inv.setContents(invUser.getInventory().getArmorContents());
}
else
{
inv = invUser.getInventory();
}
user.openInventory(inv);
user.setInvSee(true); user.setInvSee(true);
user.openInventory(invUser.getInventory());
} }
} }

View File

@ -16,7 +16,7 @@ public class Commanditem extends EssentialsCommand
{ {
super("item"); super("item");
} }
@Override @Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{ {
@ -25,7 +25,7 @@ public class Commanditem extends EssentialsCommand
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
final ItemStack stack = ess.getItemDb().get(args[0]); final ItemStack stack = ess.getItemDb().get(args[0]);
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (ess.getSettings().permissionBasedItemSpawn() if (ess.getSettings().permissionBasedItemSpawn()
? (!user.isAuthorized("essentials.itemspawn.item-all") ? (!user.isAuthorized("essentials.itemspawn.item-all")
@ -69,7 +69,14 @@ public class Commanditem extends EssentialsCommand
{ {
level = enchantment.getMaxLevel(); level = enchantment.getMaxLevel();
} }
stack.addEnchantment(enchantment, level); if (ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe"))
{
stack.addUnsafeEnchantment(enchantment, level);
}
else
{
stack.addEnchantment(enchantment, level);
}
} }
} }
} }
@ -77,12 +84,12 @@ public class Commanditem extends EssentialsCommand
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
if (stack.getType() == Material.AIR) if (stack.getType() == Material.AIR)
{ {
throw new Exception(_("cantSpawnItem", "Air")); throw new Exception(_("cantSpawnItem", "Air"));
} }
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' '); final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName)); user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
if (user.isAuthorized("essentials.oversizedstacks")) if (user.isAuthorized("essentials.oversizedstacks"))

View File

@ -97,13 +97,21 @@ public class Commandrecipe extends EssentialsCommand
final User user = ess.getUser(sender); final User user = ess.getUser(sender);
user.setRecipeSee(true); user.setRecipeSee(true);
final InventoryView view = user.openWorkbench(null, true); final InventoryView view = user.openWorkbench(null, true);
final String shapeMap = recipe.getShape().length == 2 ? " abecdfghi" : " abcdefghi"; final String[] recipeShape = recipe.getShape();
for (Entry<Character, ItemStack> e : ((ShapedRecipe)recipe).getIngredientMap().entrySet()) final Map<Character, ItemStack> ingredientMap = recipe.getIngredientMap();
{ for (int j = 0; j < recipeShape.length; j++)
e.getValue().setAmount(0); {
view.setItem(shapeMap.indexOf(e.getKey()), e.getValue()); for (int k = 0; k < recipeShape[j].length(); k++)
{
final ItemStack item = ingredientMap.get(recipeShape[j].toCharArray()[k]);
if(item == null)
{
continue;
}
item.setAmount(0);
view.getTopInventory().setItem(j * 3 + k + 1, item);
}
} }
} }
else else
{ {
@ -186,4 +194,4 @@ public class Commandrecipe extends EssentialsCommand
} }
return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH); return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH);
} }
} }

View File

@ -47,7 +47,7 @@ public class Commandtempban extends EssentialsCommand
final long banTimestamp = Util.parseDateDiff(time, true); final long banTimestamp = Util.parseDateDiff(time, true);
final long maxBanLength = ess.getSettings().getMaxTempban() * 1000; final long maxBanLength = ess.getSettings().getMaxTempban() * 1000;
if(maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength) && ess.getUser(sender).isAuthorized("essentials.tempban.unlimited")) if(maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength) && !(ess.getUser(sender).isAuthorized("essentials.tempban.unlimited")))
{ {
sender.sendMessage(_("oversizedTempban")); sender.sendMessage(_("oversizedTempban"));
throw new NoChargeException(); throw new NoChargeException();

View File

@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -23,12 +24,19 @@ public class Commandunban extends EssentialsCommand
try try
{ {
final User player = getPlayer(server, args, 0, true); final User user = getPlayer(server, args, 0, true);
player.setBanned(false); user.setBanned(false);
sender.sendMessage(_("unbannedPlayer")); sender.sendMessage(_("unbannedPlayer"));
} }
catch (NoSuchFieldException e) catch (NoSuchFieldException e)
{ {
final OfflinePlayer player = server.getOfflinePlayer(args[0]);
if (player.isBanned()) {
player.setBanned(false);
sender.sendMessage(_("unbannedPlayer"));
return;
}
throw new Exception(_("playerNotFound"), e); throw new Exception(_("playerNotFound"), e);
} }
} }

View File

@ -134,6 +134,17 @@ public class PermissionsHandler implements IPermissionsHandler
return; return;
} }
final Plugin simplyPermsPlugin = pluginManager.getPlugin("SimplyPerms");
if (simplyPermsPlugin != null && simplyPermsPlugin.isEnabled())
{
if (!(handler instanceof SimplyPermsHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using SimplyPerms based permissions.");
handler = new SimplyPermsHandler(simplyPermsPlugin);
}
return;
}
final Plugin privPlugin = pluginManager.getPlugin("Privileges"); final Plugin privPlugin = pluginManager.getPlugin("Privileges");
if (privPlugin != null && privPlugin.isEnabled()) if (privPlugin != null && privPlugin.isEnabled())
{ {

View File

@ -0,0 +1,53 @@
package com.earth2me.essentials.perm;
import java.util.List;
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class SimplyPermsHandler extends SuperpermsHandler {
private final transient SimplyAPI api;
public SimplyPermsHandler(final Plugin plugin) {
this.api = ((SimplyPlugin) plugin).getAPI();
}
@Override
public String getGroup(final Player base)
{
final List<String> groups = api.getPlayerGroups(base.getName());
if (groups == null || groups.isEmpty()) return null;
return groups.get(0);
}
@Override
public List<String> getGroups(final Player base)
{
return api.getPlayerGroups(base.getName());
}
@Override
public boolean inGroup(final Player base, final String group)
{
final List<String> groups = api.getPlayerGroups(base.getName());
for (String group1 : groups)
{
if (group1.equalsIgnoreCase(group))
{
return true;
}
}
return false;
}
@Override
public boolean canBuild(Player base, String group)
{
return hasPermission(base, "essentials.build") || hasPermission(base, "permissions.allow.build");
}
}

View File

@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
public class EssentialsSign public class EssentialsSign
{ {
private static final Set<Material> EMPTY_SET = new HashSet<Material>(); private static final Set<Material> EMPTY_SET = new HashSet<Material>();
protected transient final String signName; protected transient final String signName;
public EssentialsSign(final String signName) public EssentialsSign(final String signName)
@ -258,6 +259,11 @@ public class EssentialsSign
{ {
return EMPTY_SET; return EMPTY_SET;
} }
public boolean areHeavyEventRequired()
{
return false;
}
protected final void validateTrade(final ISign sign, final int index, final IEssentials ess) throws SignException protected final void validateTrade(final ISign sign, final int index, final IEssentials ess) throws SignException
{ {

View File

@ -32,6 +32,7 @@ public class SignBlockListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
@ -65,7 +66,7 @@ public class SignBlockListener implements Listener
} }
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (sign.getBlocks().contains(block.getType()) if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())
&& !sign.onBlockBreak(block, player, ess)) && !sign.onBlockBreak(block, player, ess))
{ {
LOGGER.log(Level.INFO, "A block was protected by a sign."); LOGGER.log(Level.INFO, "A block was protected by a sign.");
@ -80,6 +81,7 @@ public class SignBlockListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
User user = ess.getUser(event.getPlayer()); User user = ess.getUser(event.getPlayer());
@ -105,6 +107,7 @@ public class SignBlockListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
@ -129,6 +132,7 @@ public class SignBlockListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
@ -148,7 +152,7 @@ public class SignBlockListener implements Listener
} }
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (sign.getBlocks().contains(block.getType()) if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())
&& !sign.onBlockPlace(block, event.getPlayer(), ess)) && !sign.onBlockPlace(block, event.getPlayer(), ess))
{ {
event.setCancelled(true); event.setCancelled(true);
@ -162,6 +166,7 @@ public class SignBlockListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
@ -176,7 +181,7 @@ public class SignBlockListener implements Listener
} }
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (sign.getBlocks().contains(block.getType()) if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())
&& !sign.onBlockBurn(block, ess)) && !sign.onBlockBurn(block, ess))
{ {
event.setCancelled(true); event.setCancelled(true);
@ -190,6 +195,7 @@ public class SignBlockListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
@ -204,7 +210,7 @@ public class SignBlockListener implements Listener
} }
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (sign.getBlocks().contains(block.getType()) if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())
&& !sign.onBlockIgnite(block, ess)) && !sign.onBlockIgnite(block, ess))
{ {
event.setCancelled(true); event.setCancelled(true);
@ -218,6 +224,7 @@ public class SignBlockListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
@ -233,7 +240,7 @@ public class SignBlockListener implements Listener
} }
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (sign.getBlocks().contains(block.getType()) if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())
&& !sign.onBlockPush(block, ess)) && !sign.onBlockPush(block, ess))
{ {
event.setCancelled(true); event.setCancelled(true);
@ -248,6 +255,7 @@ public class SignBlockListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
@ -264,7 +272,7 @@ public class SignBlockListener implements Listener
} }
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (sign.getBlocks().contains(block.getType()) if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())
&& !sign.onBlockPush(block, ess)) && !sign.onBlockPush(block, ess))
{ {
event.setCancelled(true); event.setCancelled(true);

View File

@ -24,6 +24,7 @@ public class SignEntityListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
@ -39,7 +40,7 @@ public class SignEntityListener implements Listener
} }
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (sign.getBlocks().contains(block.getType())) if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()))
{ {
event.setCancelled(!sign.onBlockExplode(block, ess)); event.setCancelled(!sign.onBlockExplode(block, ess));
return; return;
@ -53,6 +54,7 @@ public class SignEntityListener implements Listener
{ {
if (ess.getSettings().areSignsDisabled()) if (ess.getSettings().areSignsDisabled())
{ {
event.getHandlers().unregister(this);
return; return;
} }
@ -67,7 +69,7 @@ public class SignEntityListener implements Listener
} }
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (sign.getBlocks().contains(block.getType()) if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())
&& !sign.onBlockBreak(block, ess)) && !sign.onBlockBreak(block, ess))
{ {
event.setCancelled(true); event.setCancelled(true);

View File

@ -25,11 +25,15 @@ public class SignPlayerListener implements Listener
//Right clicking signs with a block in hand, can now fire cancelled events. //Right clicking signs with a block in hand, can now fire cancelled events.
//This is because when the block place is cancelled (for example not enough space for the block to be placed), //This is because when the block place is cancelled (for example not enough space for the block to be placed),
//the event will be marked as cancelled, thus preventing 30% of sign purchases. //the event will be marked as cancelled, thus preventing 30% of sign purchases.
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(final PlayerInteractEvent event) public void onPlayerInteract(final PlayerInteractEvent event)
{ {
if (ess.getSettings().areSignsDisabled() || (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR)) if (ess.getSettings().areSignsDisabled())
{
event.getHandlers().unregister(this);
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR)
{ {
return; return;
} }
@ -62,10 +66,10 @@ public class SignPlayerListener implements Listener
final int mat = block.getTypeId(); final int mat = block.getTypeId();
if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId()) if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId())
{ {
final Sign csign = (Sign)block.getState(); final String csign = ((Sign)block.getState()).getLine(0);
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName())) if (csign.equalsIgnoreCase(sign.getSuccessName()))
{ {
sign.onSignInteract(block, event.getPlayer(), ess); sign.onSignInteract(block, event.getPlayer(), ess);
event.setCancelled(true); event.setCancelled(true);
@ -77,7 +81,7 @@ public class SignPlayerListener implements Listener
{ {
for (EssentialsSign sign : ess.getSettings().enabledSigns()) for (EssentialsSign sign : ess.getSettings().enabledSigns())
{ {
if (sign.getBlocks().contains(block.getType()) if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())
&& !sign.onBlockInteract(block, event.getPlayer(), ess)) && !sign.onBlockInteract(block, event.getPlayer(), ess))
{ {
event.setCancelled(true); event.setCancelled(true);

View File

@ -241,6 +241,12 @@ public class SignProtection extends EssentialsSign
{ {
return protectedBlocks; return protectedBlocks;
} }
@Override
public boolean areHeavyEventRequired()
{
return true;
}
@Override @Override
protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException

View File

@ -334,6 +334,10 @@ oversized-stacksize: 64
# essentials.repair.enchanted # essentials.repair.enchanted
repair-enchanted: true repair-enchanted: true
# Allow 'unsafe' enchantments in kits and item spawning.
# Warning: Mixing and overleveling some enchantments can cause issues with clients, servers and plugins.
unsafe-enchantments: false
#Do you want essentials to keep track of previous location for /back in the teleport listener? #Do you want essentials to keep track of previous location for /back in the teleport listener?
#If you set this to true any plugin that uses teleport will have the previous location registered. #If you set this to true any plugin that uses teleport will have the previous location registered.
register-back-in-listener: false register-back-in-listener: false
@ -379,7 +383,7 @@ sethome-multiple:
# Set timeout in seconds for players to accept tpa before request is cancelled. # Set timeout in seconds for players to accept tpa before request is cancelled.
# Set to 0 for no timeout # Set to 0 for no timeout
tpa-accept-cancellation: 0 tpa-accept-cancellation: 120
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #

View File

@ -134,14 +134,10 @@ public abstract class EssentialsChatPlayer implements Listener
return; return;
} }
for (Player onlinePlayer : server.getOnlinePlayers()) for (Player onlinePlayer : event.getRecipients())
{ {
String type = _("chatTypeLocal"); String type = _("chatTypeLocal");
final User onlineUser = ess.getUser(onlinePlayer); final User onlineUser = ess.getUser(onlinePlayer);
if (onlineUser.isIgnoredPlayer(sender))
{
continue;
}
if (!onlineUser.equals(sender)) if (!onlineUser.equals(sender))
{ {
boolean abort = false; boolean abort = false;

View File

@ -233,7 +233,7 @@ public class EssentialsProtectEntityListener implements Listener
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
// This code will prevent explosions near protected rails, signs or protected chests // This code will prevent explosions near protected rails, signs or protected chests
// TODO: Use protect db instead of this code // TODO: Use protect db instead of this code

View File

@ -11,6 +11,7 @@ import java.util.logging.Handler;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jivesoftware.smack.*; import org.jivesoftware.smack.*;
import org.jivesoftware.smack.Roster.SubscriptionMode; import org.jivesoftware.smack.Roster.SubscriptionMode;
@ -22,6 +23,7 @@ import org.jivesoftware.smack.util.StringUtils;
public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IConf public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IConf
{ {
private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static final Logger LOGGER = Logger.getLogger("Minecraft");
private static final SimpleFormatter formatter = new SimpleFormatter();
private final transient EssentialsConf config; private final transient EssentialsConf config;
private transient XMPPConnection connection; private transient XMPPConnection connection;
private transient ChatManager chatManager; private transient ChatManager chatManager;
@ -262,7 +264,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
XMPPManager.this.startChat(user); XMPPManager.this.startChat(user);
for (LogRecord logRecord : copy) for (LogRecord logRecord : copy)
{ {
final String message = String.format("[" + logRecord.getLevel().getLocalizedName() + "] " + logRecord.getMessage(), logRecord.getParameters()); final String message = formatter.format(logRecord);
if (!XMPPManager.this.sendMessage(user, Util.stripLogColorFormat(message))) if (!XMPPManager.this.sendMessage(user, Util.stripLogColorFormat(message)))
{ {
failedUsers.add(user); failedUsers.add(user);

BIN
lib/SimplyPerms.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.