mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-14 12:11:25 +01:00
Merge pull request #210 from ShadowRanger/2.x
[Fix] Properly apply damage causes
This commit is contained in:
commit
3edfec2491
@ -34,6 +34,7 @@ public class Commandkill extends EssentialsLoopCommand {
|
|||||||
if (ede.isCancelled() && sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.kill.force")) {
|
if (ede.isCancelled() && sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.kill.force")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ede.getEntity().setLastDamageCause(ede);
|
||||||
matchPlayer.damage(Short.MAX_VALUE);
|
matchPlayer.damage(Short.MAX_VALUE);
|
||||||
|
|
||||||
if (matchPlayer.getHealth() > 0) {
|
if (matchPlayer.getHealth() > 0) {
|
||||||
|
@ -16,6 +16,7 @@ public class Commandsuicide extends EssentialsCommand {
|
|||||||
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 {
|
||||||
EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, Short.MAX_VALUE);
|
EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, Short.MAX_VALUE);
|
||||||
server.getPluginManager().callEvent(ede);
|
server.getPluginManager().callEvent(ede);
|
||||||
|
ede.getEntity().setLastDamageCause(ede);
|
||||||
user.getBase().damage(Short.MAX_VALUE);
|
user.getBase().damage(Short.MAX_VALUE);
|
||||||
if (user.getBase().getHealth() > 0) {
|
if (user.getBase().getHealth() > 0) {
|
||||||
user.getBase().setHealth(0);
|
user.getBase().setHealth(0);
|
||||||
|
@ -16,52 +16,69 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
|
|
||||||
public class LocationUtil {
|
public class LocationUtil {
|
||||||
// The player can stand inside these materials
|
// The player can stand inside these materials
|
||||||
public static final Set<Integer> HOLLOW_MATERIALS = new HashSet<Integer>();
|
public static final Set<Material> HOLLOW_MATERIALS = new HashSet<>();
|
||||||
private static final HashSet<Byte> TRANSPARENT_MATERIALS = new HashSet<Byte>();
|
private static final Set<Material> TRANSPARENT_MATERIALS = new HashSet<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
HOLLOW_MATERIALS.add(Material.AIR.getId());
|
// Materials from Material.isTransparent()
|
||||||
HOLLOW_MATERIALS.add(Material.SAPLING.getId());
|
HOLLOW_MATERIALS.add(Material.AIR);
|
||||||
HOLLOW_MATERIALS.add(Material.POWERED_RAIL.getId());
|
HOLLOW_MATERIALS.add(Material.SAPLING);
|
||||||
HOLLOW_MATERIALS.add(Material.DETECTOR_RAIL.getId());
|
HOLLOW_MATERIALS.add(Material.POWERED_RAIL);
|
||||||
HOLLOW_MATERIALS.add(Material.LONG_GRASS.getId());
|
HOLLOW_MATERIALS.add(Material.DETECTOR_RAIL);
|
||||||
HOLLOW_MATERIALS.add(Material.DEAD_BUSH.getId());
|
HOLLOW_MATERIALS.add(Material.LONG_GRASS);
|
||||||
HOLLOW_MATERIALS.add(Material.YELLOW_FLOWER.getId());
|
HOLLOW_MATERIALS.add(Material.DEAD_BUSH);
|
||||||
HOLLOW_MATERIALS.add(Material.RED_ROSE.getId());
|
HOLLOW_MATERIALS.add(Material.YELLOW_FLOWER);
|
||||||
HOLLOW_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
|
HOLLOW_MATERIALS.add(Material.RED_ROSE);
|
||||||
HOLLOW_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
HOLLOW_MATERIALS.add(Material.BROWN_MUSHROOM);
|
||||||
HOLLOW_MATERIALS.add(Material.TORCH.getId());
|
HOLLOW_MATERIALS.add(Material.RED_MUSHROOM);
|
||||||
HOLLOW_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
HOLLOW_MATERIALS.add(Material.TORCH);
|
||||||
HOLLOW_MATERIALS.add(Material.SEEDS.getId());
|
HOLLOW_MATERIALS.add(Material.FIRE);
|
||||||
HOLLOW_MATERIALS.add(Material.SIGN_POST.getId());
|
HOLLOW_MATERIALS.add(Material.REDSTONE_WIRE);
|
||||||
HOLLOW_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
HOLLOW_MATERIALS.add(Material.CROPS);
|
||||||
HOLLOW_MATERIALS.add(Material.LADDER.getId());
|
HOLLOW_MATERIALS.add(Material.LADDER);
|
||||||
HOLLOW_MATERIALS.add(Material.RAILS.getId());
|
HOLLOW_MATERIALS.add(Material.RAILS);
|
||||||
HOLLOW_MATERIALS.add(Material.WALL_SIGN.getId());
|
HOLLOW_MATERIALS.add(Material.LEVER);
|
||||||
HOLLOW_MATERIALS.add(Material.LEVER.getId());
|
HOLLOW_MATERIALS.add(Material.REDSTONE_TORCH_OFF);
|
||||||
HOLLOW_MATERIALS.add(Material.STONE_PLATE.getId());
|
HOLLOW_MATERIALS.add(Material.REDSTONE_TORCH_ON);
|
||||||
HOLLOW_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
HOLLOW_MATERIALS.add(Material.STONE_BUTTON);
|
||||||
HOLLOW_MATERIALS.add(Material.WOOD_PLATE.getId());
|
HOLLOW_MATERIALS.add(Material.SNOW);
|
||||||
HOLLOW_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
HOLLOW_MATERIALS.add(Material.SUGAR_CANE_BLOCK);
|
||||||
HOLLOW_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
HOLLOW_MATERIALS.add(Material.PORTAL);
|
||||||
HOLLOW_MATERIALS.add(Material.STONE_BUTTON.getId());
|
HOLLOW_MATERIALS.add(Material.DIODE_BLOCK_OFF);
|
||||||
HOLLOW_MATERIALS.add(Material.SNOW.getId());
|
HOLLOW_MATERIALS.add(Material.DIODE_BLOCK_ON);
|
||||||
HOLLOW_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
HOLLOW_MATERIALS.add(Material.PUMPKIN_STEM);
|
||||||
HOLLOW_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
HOLLOW_MATERIALS.add(Material.MELON_STEM);
|
||||||
HOLLOW_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
HOLLOW_MATERIALS.add(Material.VINE);
|
||||||
HOLLOW_MATERIALS.add(Material.PUMPKIN_STEM.getId());
|
HOLLOW_MATERIALS.add(Material.WATER_LILY);
|
||||||
HOLLOW_MATERIALS.add(Material.MELON_STEM.getId());
|
HOLLOW_MATERIALS.add(Material.NETHER_WARTS);
|
||||||
HOLLOW_MATERIALS.add(Material.VINE.getId());
|
HOLLOW_MATERIALS.add(Material.ENDER_PORTAL);
|
||||||
HOLLOW_MATERIALS.add(Material.FENCE_GATE.getId());
|
HOLLOW_MATERIALS.add(Material.COCOA);
|
||||||
HOLLOW_MATERIALS.add(Material.WATER_LILY.getId());
|
HOLLOW_MATERIALS.add(Material.TRIPWIRE_HOOK);
|
||||||
HOLLOW_MATERIALS.add(Material.NETHER_WARTS.getId());
|
HOLLOW_MATERIALS.add(Material.TRIPWIRE);
|
||||||
HOLLOW_MATERIALS.add(Material.CARPET.getId());
|
HOLLOW_MATERIALS.add(Material.FLOWER_POT);
|
||||||
|
HOLLOW_MATERIALS.add(Material.CARROT);
|
||||||
|
HOLLOW_MATERIALS.add(Material.POTATO);
|
||||||
|
HOLLOW_MATERIALS.add(Material.WOOD_BUTTON);
|
||||||
|
HOLLOW_MATERIALS.add(Material.SKULL);
|
||||||
|
HOLLOW_MATERIALS.add(Material.REDSTONE_COMPARATOR_OFF);
|
||||||
|
HOLLOW_MATERIALS.add(Material.REDSTONE_COMPARATOR_ON);
|
||||||
|
HOLLOW_MATERIALS.add(Material.ACTIVATOR_RAIL);
|
||||||
|
HOLLOW_MATERIALS.add(Material.CARPET);
|
||||||
|
HOLLOW_MATERIALS.add(Material.DOUBLE_PLANT);
|
||||||
|
|
||||||
for (Integer integer : HOLLOW_MATERIALS) {
|
// Additional Materials added in by Essentials
|
||||||
TRANSPARENT_MATERIALS.add(integer.byteValue());
|
HOLLOW_MATERIALS.add(Material.SEEDS);
|
||||||
}
|
HOLLOW_MATERIALS.add(Material.SIGN_POST);
|
||||||
TRANSPARENT_MATERIALS.add((byte) Material.WATER.getId());
|
HOLLOW_MATERIALS.add(Material.WOODEN_DOOR);
|
||||||
TRANSPARENT_MATERIALS.add((byte) Material.STATIONARY_WATER.getId());
|
HOLLOW_MATERIALS.add(Material.WALL_SIGN);
|
||||||
|
HOLLOW_MATERIALS.add(Material.STONE_PLATE);
|
||||||
|
HOLLOW_MATERIALS.add(Material.IRON_DOOR_BLOCK);
|
||||||
|
HOLLOW_MATERIALS.add(Material.WOOD_PLATE);
|
||||||
|
HOLLOW_MATERIALS.add(Material.FENCE_GATE);
|
||||||
|
|
||||||
|
TRANSPARENT_MATERIALS.addAll(HOLLOW_MATERIALS);
|
||||||
|
TRANSPARENT_MATERIALS.add(Material.WATER);
|
||||||
|
TRANSPARENT_MATERIALS.add(Material.STATIONARY_WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int RADIUS = 3;
|
public static final int RADIUS = 3;
|
||||||
@ -190,7 +207,7 @@ public class LocationUtil {
|
|||||||
if (y > world.getMaxHeight()) {
|
if (y > world.getMaxHeight()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
|
return HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBlockUnsafeForUser(final IUser user, final World world, final int x, final int y, final int z) {
|
public static boolean isBlockUnsafeForUser(final IUser user, final World world, final int x, final int y, final int z) {
|
||||||
@ -222,7 +239,7 @@ public class LocationUtil {
|
|||||||
if (below.getType() == Material.BED_BLOCK) {
|
if (below.getType() == Material.BED_BLOCK) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId())) || (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId()));
|
return (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y, z).getType())) || (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not needed if using getSafeDestination(loc)
|
// Not needed if using getSafeDestination(loc)
|
||||||
|
Loading…
Reference in New Issue
Block a user