mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-28 03:57:48 +01: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
|
@Override
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled())
|
||||||
if (ess.getSettings().areSignsDisabled()) return;
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ess.getSettings().areSignsDisabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
User user = ess.getUser(event.getPlayer());
|
User user = ess.getUser(event.getPlayer());
|
||||||
if (protectedBlocks.contains(event.getBlock().getType()) && !user.isAuthorized("essentials.signs.protection.override"))
|
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 &&
|
if (checkProtectionSign(event.getBlock(), user) != NOSIGN
|
||||||
checkProtectionSign(event.getBlock(), user) != OWNER)
|
&& checkProtectionSign(event.getBlock(), user) != OWNER)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
|
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
|
||||||
@ -59,8 +65,14 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
@Override
|
@Override
|
||||||
public void onSignChange(SignChangeEvent event)
|
public void onSignChange(SignChangeEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled())
|
||||||
if (ess.getSettings().areSignsDisabled()) return;
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ess.getSettings().areSignsDisabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
User user = ess.getUser(event.getPlayer());
|
User user = ess.getUser(event.getPlayer());
|
||||||
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
|
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();
|
Block block = event.getBlock();
|
||||||
if (user.isAuthorized("essentials.signs.protection.create") && hasAdjacentChest(block) && !isBlockProtected(block, user))
|
if (user.isAuthorized("essentials.signs.protection.create") && hasAdjacentChest(block) && !isBlockProtected(block, user))
|
||||||
|
{
|
||||||
event.setLine(0, "§1[Protection]");
|
event.setLine(0, "§1[Protection]");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
event.setLine(0, "§4[Protection]");
|
event.setLine(0, "§4[Protection]");
|
||||||
|
}
|
||||||
event.setLine(3, username);
|
event.setLine(3, username);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getLine(0).equalsIgnoreCase("[Disposal]"))
|
if (event.getLine(0).equalsIgnoreCase("[Disposal]"))
|
||||||
{
|
{
|
||||||
if (user.isAuthorized("essentials.signs.disposal.create"))
|
if (user.isAuthorized("essentials.signs.disposal.create"))
|
||||||
|
{
|
||||||
event.setLine(0, "§1[Disposal]");
|
event.setLine(0, "§1[Disposal]");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
event.setLine(0, "§4[Disposal]");
|
event.setLine(0, "§4[Disposal]");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getLine(0).equalsIgnoreCase("[Heal]"))
|
if (event.getLine(0).equalsIgnoreCase("[Heal]"))
|
||||||
@ -94,8 +114,14 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
String[] l1 = event.getLine(1).split("[ :-]+", 2);
|
String[] l1 = event.getLine(1).split("[ :-]+", 2);
|
||||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
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 (q1 < 1 || (!m1 && (int)q1 < 1))
|
||||||
if (!m1) ItemDb.get(l1[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(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
|
||||||
}
|
}
|
||||||
event.setLine(0, "§1[Heal]");
|
event.setLine(0, "§1[Heal]");
|
||||||
@ -107,29 +133,40 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
event.setLine(0, "§4[Free]");
|
event.setLine(0, "§4[Free]");
|
||||||
ItemDb.get(event.getLine(1));
|
ItemDb.get(event.getLine(1));
|
||||||
if (user.isAuthorized("essentials.signs.free.create"))
|
if (user.isAuthorized("essentials.signs.free.create"))
|
||||||
|
{
|
||||||
event.setLine(0, "§1[Free]");
|
event.setLine(0, "§1[Free]");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getLine(0).equalsIgnoreCase("[Mail]"))
|
if (event.getLine(0).equalsIgnoreCase("[Mail]"))
|
||||||
{
|
{
|
||||||
if (user.isAuthorized("essentials.signs.mail.create"))
|
if (user.isAuthorized("essentials.signs.mail.create"))
|
||||||
|
{
|
||||||
event.setLine(0, "§1[Mail]");
|
event.setLine(0, "§1[Mail]");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
event.setLine(0, "§4[Mail]");
|
event.setLine(0, "§4[Mail]");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getLine(0).equalsIgnoreCase("[Balance]"))
|
if (event.getLine(0).equalsIgnoreCase("[Balance]"))
|
||||||
{
|
{
|
||||||
if (user.isAuthorized("essentials.signs.balance.create"))
|
if (user.isAuthorized("essentials.signs.balance.create"))
|
||||||
|
{
|
||||||
event.setLine(0, "§1[Balance]");
|
event.setLine(0, "§1[Balance]");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
event.setLine(0, "§4[Balance]");
|
event.setLine(0, "§4[Balance]");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getLine(0).equalsIgnoreCase("[Warp]"))
|
if (event.getLine(0).equalsIgnoreCase("[Warp]"))
|
||||||
{
|
{
|
||||||
event.setLine(0, "§4[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())
|
if (!event.getLine(3).isEmpty())
|
||||||
{
|
{
|
||||||
String[] l1 = event.getLine(3).split("[ :-]+", 2);
|
String[] l1 = event.getLine(3).split("[ :-]+", 2);
|
||||||
@ -139,16 +176,26 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
throw new Exception(Util.format("invalidSignLine", 4));
|
throw new Exception(Util.format("invalidSignLine", 4));
|
||||||
}
|
}
|
||||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||||
if ((int)q1 < 1) throw new Exception(Util.i18n("moreThanZero"));
|
if ((int)q1 < 1)
|
||||||
if (!m1) ItemDb.get(l1[1]);
|
{
|
||||||
|
throw new Exception(Util.i18n("moreThanZero"));
|
||||||
|
}
|
||||||
|
if (!m1)
|
||||||
|
{
|
||||||
|
ItemDb.get(l1[1]);
|
||||||
|
}
|
||||||
event.setLine(3, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + 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!");
|
event.setLine(1, "§dWarp name!");
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ess.getWarps().getWarp(event.getLine(1));
|
ess.getWarps().getWarp(event.getLine(1));
|
||||||
if (event.getLine(2).equalsIgnoreCase("Everyone")) {
|
if (event.getLine(2).equalsIgnoreCase("Everyone"))
|
||||||
|
{
|
||||||
event.setLine(2, "§2Everyone");
|
event.setLine(2, "§2Everyone");
|
||||||
}
|
}
|
||||||
event.setLine(0, "§1[Warp]");
|
event.setLine(0, "§1[Warp]");
|
||||||
@ -158,10 +205,16 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
if (event.getLine(0).equalsIgnoreCase("[Time]"))
|
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]");
|
event.setLine(0, "§1[Time]");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
event.setLine(0, "§4[Time]");
|
event.setLine(0, "§4[Time]");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +231,10 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
@Override
|
@Override
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Block signBlock = event.getBlockAgainst();
|
Block signBlock = event.getBlockAgainst();
|
||||||
if (signBlock.getType() == Material.WALL_SIGN || signBlock.getType() == Material.SIGN_POST)
|
if (signBlock.getType() == Material.WALL_SIGN || signBlock.getType() == Material.SIGN_POST)
|
||||||
{
|
{
|
||||||
@ -193,75 +249,78 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
// Do not rely on getItemInHand();
|
// Do not rely on getItemInHand();
|
||||||
// http://leaky.bukkit.org/issues/663
|
// http://leaky.bukkit.org/issues/663
|
||||||
final ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short)0, event.getBlockPlaced().getData());
|
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);
|
case WOODEN_DOOR:
|
||||||
is.setDurability((short)0);
|
is.setType(Material.WOOD_DOOR);
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
case IRON_DOOR_BLOCK:
|
break;
|
||||||
is.setType(Material.IRON_DOOR);
|
case IRON_DOOR_BLOCK:
|
||||||
is.setDurability((short)0);
|
is.setType(Material.IRON_DOOR);
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
case SIGN_POST:
|
break;
|
||||||
case WALL_SIGN:
|
case SIGN_POST:
|
||||||
is.setType(Material.SIGN);
|
case WALL_SIGN:
|
||||||
is.setDurability((short)0);
|
is.setType(Material.SIGN);
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
case CROPS:
|
break;
|
||||||
is.setType(Material.SEEDS);
|
case CROPS:
|
||||||
is.setDurability((short)0);
|
is.setType(Material.SEEDS);
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
case CAKE_BLOCK:
|
break;
|
||||||
is.setType(Material.CAKE);
|
case CAKE_BLOCK:
|
||||||
is.setDurability((short)0);
|
is.setType(Material.CAKE);
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
case BED_BLOCK:
|
break;
|
||||||
is.setType(Material.BED);
|
case BED_BLOCK:
|
||||||
is.setDurability((short)0);
|
is.setType(Material.BED);
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
case REDSTONE_WIRE:
|
break;
|
||||||
is.setType(Material.REDSTONE);
|
case REDSTONE_WIRE:
|
||||||
is.setDurability((short)0);
|
is.setType(Material.REDSTONE);
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
case REDSTONE_TORCH_OFF:
|
break;
|
||||||
case REDSTONE_TORCH_ON:
|
case REDSTONE_TORCH_OFF:
|
||||||
is.setType(Material.REDSTONE_TORCH_ON);
|
case REDSTONE_TORCH_ON:
|
||||||
is.setDurability((short)0);
|
is.setType(Material.REDSTONE_TORCH_ON);
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
case DIODE_BLOCK_OFF:
|
break;
|
||||||
case DIODE_BLOCK_ON:
|
case DIODE_BLOCK_OFF:
|
||||||
is.setType(Material.DIODE);
|
case DIODE_BLOCK_ON:
|
||||||
is.setDurability((short)0);
|
is.setType(Material.DIODE);
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
case DOUBLE_STEP:
|
break;
|
||||||
is.setType(Material.STEP);
|
case DOUBLE_STEP:
|
||||||
break;
|
is.setType(Material.STEP);
|
||||||
case TORCH:
|
break;
|
||||||
case RAILS:
|
case TORCH:
|
||||||
case LADDER:
|
case RAILS:
|
||||||
case WOOD_STAIRS:
|
case LADDER:
|
||||||
case COBBLESTONE_STAIRS:
|
case WOOD_STAIRS:
|
||||||
case LEVER:
|
case COBBLESTONE_STAIRS:
|
||||||
case STONE_BUTTON:
|
case LEVER:
|
||||||
case FURNACE:
|
case STONE_BUTTON:
|
||||||
case DISPENSER:
|
case FURNACE:
|
||||||
case PUMPKIN:
|
case DISPENSER:
|
||||||
case JACK_O_LANTERN:
|
case PUMPKIN:
|
||||||
case WOOD_PLATE:
|
case JACK_O_LANTERN:
|
||||||
case STONE_PLATE:
|
case WOOD_PLATE:
|
||||||
is.setDurability((short)0);
|
case STONE_PLATE:
|
||||||
break;
|
is.setDurability((short)0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||||
if (unlimitedForUser) {
|
if (unlimitedForUser)
|
||||||
|
{
|
||||||
ess.scheduleSyncDelayedTask(
|
ess.scheduleSyncDelayedTask(
|
||||||
new Runnable() {
|
new Runnable()
|
||||||
|
{
|
||||||
public void run() {
|
public void run()
|
||||||
user.getInventory().addItem(is);
|
{
|
||||||
user.updateInventory();
|
user.getInventory().addItem(is);
|
||||||
}
|
user.updateInventory();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,14 +349,19 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
Sign sign = new CraftSign(block);
|
Sign sign = new CraftSign(block);
|
||||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]") && !user.isAuthorized("essentials.signs.protection.override"))
|
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);
|
String line = sign.getLine(i);
|
||||||
if (line.startsWith("(") && line.endsWith(")")) {
|
if (line.startsWith("(") && line.endsWith(")"))
|
||||||
|
{
|
||||||
line = line.substring(1, line.length() - 1);
|
line = line.substring(1, line.length() - 1);
|
||||||
if (user.inGroup(line)) {
|
if (user.inGroup(line))
|
||||||
|
{
|
||||||
return ALLOWED;
|
return ALLOWED;
|
||||||
}
|
}
|
||||||
} else if (line.equalsIgnoreCase(username)) {
|
}
|
||||||
|
else if (line.equalsIgnoreCase(username))
|
||||||
|
{
|
||||||
return ALLOWED;
|
return ALLOWED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,8 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
User user = ess.getUser(event.getPlayer());
|
User user = ess.getUser(event.getPlayer());
|
||||||
user.setDisplayName(user.getNick());
|
user.setDisplayName(user.getNick());
|
||||||
updateCompass(user);
|
updateCompass(user);
|
||||||
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty()) {
|
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty())
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
|
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
|
||||||
@ -109,15 +110,18 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
|
|
||||||
Location loc = event.getTo();
|
Location loc = event.getTo();
|
||||||
World nether = server.getWorld(ess.getSettings().getNetherName());
|
World nether = server.getWorld(ess.getSettings().getNetherName());
|
||||||
if (nether == null) {
|
if (nether == null)
|
||||||
|
{
|
||||||
for (World world : worlds)
|
for (World world : worlds)
|
||||||
{
|
{
|
||||||
if (world.getEnvironment() == World.Environment.NETHER) {
|
if (world.getEnvironment() == World.Environment.NETHER)
|
||||||
|
{
|
||||||
nether = world;
|
nether = world;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nether == null) {
|
if (nether == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -489,6 +493,22 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
}
|
}
|
||||||
return;
|
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)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user