mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-09-11 04:39:00 +00:00
The rest of Wundarks commit, cleaned
This commit is contained in:
parent
5c258c03dc
commit
640f51564a
|
@ -35,8 +35,14 @@ public class EssentialsBlockListener extends BlockListener
|
|||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (ess.getSettings().areSignsDisabled()) return;
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (protectedBlocks.contains(event.getBlock().getType()) && !user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
|
@ -48,8 +54,8 @@ public class EssentialsBlockListener extends BlockListener
|
|||
}
|
||||
}
|
||||
|
||||
if (checkProtectionSign(event.getBlock(), user) != NOSIGN &&
|
||||
checkProtectionSign(event.getBlock(), user) != OWNER)
|
||||
if (checkProtectionSign(event.getBlock(), user) != NOSIGN
|
||||
&& checkProtectionSign(event.getBlock(), user) != OWNER)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
|
||||
|
@ -59,8 +65,14 @@ public class EssentialsBlockListener extends BlockListener
|
|||
@Override
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (ess.getSettings().areSignsDisabled()) return;
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
|
||||
|
||||
|
@ -70,18 +82,26 @@ public class EssentialsBlockListener extends BlockListener
|
|||
{
|
||||
Block block = event.getBlock();
|
||||
if (user.isAuthorized("essentials.signs.protection.create") && hasAdjacentChest(block) && !isBlockProtected(block, user))
|
||||
{
|
||||
event.setLine(0, "§1[Protection]");
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setLine(0, "§4[Protection]");
|
||||
}
|
||||
event.setLine(3, username);
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Disposal]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.disposal.create"))
|
||||
{
|
||||
event.setLine(0, "§1[Disposal]");
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setLine(0, "§4[Disposal]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Heal]"))
|
||||
|
@ -94,8 +114,14 @@ public class EssentialsBlockListener extends BlockListener
|
|||
String[] l1 = event.getLine(1).split("[ :-]+", 2);
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (q1 < 1 || (!m1 && (int)q1 < 1)) throw new Exception(Util.i18n("moreThanZero"));
|
||||
if (!m1) ItemDb.get(l1[1]);
|
||||
if (q1 < 1 || (!m1 && (int)q1 < 1))
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (!m1)
|
||||
{
|
||||
ItemDb.get(l1[1]);
|
||||
}
|
||||
event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
|
||||
}
|
||||
event.setLine(0, "§1[Heal]");
|
||||
|
@ -107,29 +133,40 @@ public class EssentialsBlockListener extends BlockListener
|
|||
event.setLine(0, "§4[Free]");
|
||||
ItemDb.get(event.getLine(1));
|
||||
if (user.isAuthorized("essentials.signs.free.create"))
|
||||
{
|
||||
event.setLine(0, "§1[Free]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Mail]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.mail.create"))
|
||||
{
|
||||
event.setLine(0, "§1[Mail]");
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setLine(0, "§4[Mail]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Balance]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.balance.create"))
|
||||
{
|
||||
event.setLine(0, "§1[Balance]");
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setLine(0, "§4[Balance]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Warp]"))
|
||||
{
|
||||
event.setLine(0, "§4[Warp]");
|
||||
if (user.isAuthorized("essentials.signs.warp.create")) {
|
||||
if (user.isAuthorized("essentials.signs.warp.create"))
|
||||
{
|
||||
if (!event.getLine(3).isEmpty())
|
||||
{
|
||||
String[] l1 = event.getLine(3).split("[ :-]+", 2);
|
||||
|
@ -139,16 +176,26 @@ public class EssentialsBlockListener extends BlockListener
|
|||
throw new Exception(Util.format("invalidSignLine", 4));
|
||||
}
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if ((int)q1 < 1) throw new Exception(Util.i18n("moreThanZero"));
|
||||
if (!m1) ItemDb.get(l1[1]);
|
||||
if ((int)q1 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (!m1)
|
||||
{
|
||||
ItemDb.get(l1[1]);
|
||||
}
|
||||
event.setLine(3, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
|
||||
}
|
||||
if (event.getLine(1).isEmpty()) {
|
||||
if (event.getLine(1).isEmpty())
|
||||
{
|
||||
event.setLine(1, "§dWarp name!");
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.getWarps().getWarp(event.getLine(1));
|
||||
if (event.getLine(2).equalsIgnoreCase("Everyone")) {
|
||||
if (event.getLine(2).equalsIgnoreCase("Everyone"))
|
||||
{
|
||||
event.setLine(2, "§2Everyone");
|
||||
}
|
||||
event.setLine(0, "§1[Warp]");
|
||||
|
@ -158,10 +205,16 @@ public class EssentialsBlockListener extends BlockListener
|
|||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Time]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.time.create"))
|
||||
if (user.isAuthorized("essentials.signs.time.create")
|
||||
&& (event.getLine(1).equalsIgnoreCase("day")
|
||||
|| event.getLine(1).equalsIgnoreCase("night")))
|
||||
{
|
||||
event.setLine(0, "§1[Time]");
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setLine(0, "§4[Time]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +231,10 @@ public class EssentialsBlockListener extends BlockListener
|
|||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Block signBlock = event.getBlockAgainst();
|
||||
if (signBlock.getType() == Material.WALL_SIGN || signBlock.getType() == Material.SIGN_POST)
|
||||
{
|
||||
|
@ -193,7 +249,8 @@ public class EssentialsBlockListener extends BlockListener
|
|||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short)0, event.getBlockPlaced().getData());
|
||||
switch(is.getType()) {
|
||||
switch (is.getType())
|
||||
{
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
is.setDurability((short)0);
|
||||
|
@ -253,11 +310,13 @@ public class EssentialsBlockListener extends BlockListener
|
|||
break;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser) {
|
||||
if (unlimitedForUser)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
|
@ -290,14 +349,19 @@ public class EssentialsBlockListener extends BlockListener
|
|||
Sign sign = new CraftSign(block);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]") && !user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
for (int i = 1; i <= 2; i++) {
|
||||
for (int i = 1; i <= 2; i++)
|
||||
{
|
||||
String line = sign.getLine(i);
|
||||
if (line.startsWith("(") && line.endsWith(")")) {
|
||||
if (line.startsWith("(") && line.endsWith(")"))
|
||||
{
|
||||
line = line.substring(1, line.length() - 1);
|
||||
if (user.inGroup(line)) {
|
||||
if (user.inGroup(line))
|
||||
{
|
||||
return ALLOWED;
|
||||
}
|
||||
} else if (line.equalsIgnoreCase(username)) {
|
||||
}
|
||||
else if (line.equalsIgnoreCase(username))
|
||||
{
|
||||
return ALLOWED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,8 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||
User user = ess.getUser(event.getPlayer());
|
||||
user.setDisplayName(user.getNick());
|
||||
updateCompass(user);
|
||||
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty()) {
|
||||
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
|
||||
|
@ -109,15 +110,18 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||
|
||||
Location loc = event.getTo();
|
||||
World nether = server.getWorld(ess.getSettings().getNetherName());
|
||||
if (nether == null) {
|
||||
if (nether == null)
|
||||
{
|
||||
for (World world : worlds)
|
||||
{
|
||||
if (world.getEnvironment() == World.Environment.NETHER) {
|
||||
if (world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
nether = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null) {
|
||||
if (nether == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -489,6 +493,22 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Time]") && user.isAuthorized("essentials.signs.time.use"))
|
||||
{
|
||||
long time = user.getWorld().getTime();
|
||||
time -= time % 24000;
|
||||
if ("day".equalsIgnoreCase(sign.getLine(1)))
|
||||
{
|
||||
user.getWorld().setTime(time + 24000);
|
||||
return;
|
||||
}
|
||||
if ("night".equalsIgnoreCase(sign.getLine(1)))
|
||||
{
|
||||
user.getWorld().setTime(time + 37700);
|
||||
return;
|
||||
}
|
||||
throw new Exception(Util.i18n("onlyDayNight"));
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue