Minor changes, formatting, comments.

One notable thing added was the inclusion of more of the new mobs in one of the events.
This commit is contained in:
matt 2018-12-27 00:46:32 -05:00
parent 75bcd1adec
commit a529518b91
6 changed files with 179 additions and 147 deletions

View File

@ -32,7 +32,8 @@ import java.util.HashSet;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass; import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
@SuppressWarnings("unused") public class ChunkListener implements Listener { @SuppressWarnings("unused")
public class ChunkListener implements Listener {
private RefMethod methodGetHandleChunk; private RefMethod methodGetHandleChunk;
private RefField mustSave; private RefField mustSave;
@ -143,7 +144,8 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
return plot != null && plot.hasOwner(); return plot != null && plot.hasOwner();
} }
@EventHandler public void onChunkUnload(ChunkUnloadEvent event) { @EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
if (ignoreUnload) { if (ignoreUnload) {
return; return;
} }
@ -161,11 +163,13 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
} }
} }
@EventHandler public void onChunkLoad(ChunkLoadEvent event) { @EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
processChunk(event.getChunk(), false); processChunk(event.getChunk(), false);
} }
@EventHandler(priority = EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) { @EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
Item entity = event.getEntity(); Item entity = event.getEntity();
Chunk chunk = entity.getLocation().getChunk(); Chunk chunk = entity.getLocation().getChunk();
if (chunk == this.lastChunk) { if (chunk == this.lastChunk) {

View File

@ -58,7 +58,8 @@ import java.util.regex.Pattern;
/** /**
* Player Events involving plots. * Player Events involving plots.
*/ */
@SuppressWarnings("unused") public class PlayerEvents extends PlotListener implements Listener { @SuppressWarnings("unused")
public class PlayerEvents extends PlotListener implements Listener {
private boolean pistonBlocks = true; private boolean pistonBlocks = true;
private float lastRadius; private float lastRadius;
@ -172,6 +173,13 @@ import java.util.regex.Pattern;
case MULE: case MULE:
case ZOMBIE_HORSE: case ZOMBIE_HORSE:
case SKELETON_HORSE: case SKELETON_HORSE:
case PARROT:
case TURTLE:
case COD:
case SALMON:
case DOLPHIN:
case PUFFERFISH:
case TROPICAL_FISH:
// animal // animal
return EntityUtil return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
@ -202,12 +210,14 @@ import java.util.regex.Pattern;
case EVOKER: case EVOKER:
case VEX: case VEX:
case ZOMBIE_VILLAGER: case ZOMBIE_VILLAGER:
case DROWNED:
case ILLUSIONER:
// monster // monster
return EntityUtil return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP); .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
default: default:
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
if (entity instanceof Animals) { if (entity instanceof Animals || entity instanceof WaterMob) {
return EntityUtil return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
} else if (entity instanceof Monster) { } else if (entity instanceof Monster) {
@ -227,7 +237,8 @@ import java.util.regex.Pattern;
} }
} }
@EventHandler public void onRedstoneEvent(BlockRedstoneEvent event) { @EventHandler
public void onRedstoneEvent(BlockRedstoneEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
switch (block.getType()) { switch (block.getType()) {
case OBSERVER: case OBSERVER:
@ -405,7 +416,8 @@ import java.util.regex.Pattern;
} }
} }
@EventHandler public void onProjectileLaunch(ProjectileLaunchEvent event) { @EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
if (!(entity instanceof ThrownPotion)) { if (!(entity instanceof ThrownPotion)) {
return; return;
@ -426,7 +438,8 @@ import java.util.regex.Pattern;
} }
} }
@EventHandler public boolean onProjectileHit(ProjectileHitEvent event) { @EventHandler
public boolean onProjectileHit(ProjectileHitEvent event) {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
Location loc = BukkitUtil.getLocation(entity); Location loc = BukkitUtil.getLocation(entity);
if (!PlotSquared.get().hasPlotArea(loc.getWorld())) { if (!PlotSquared.get().hasPlotArea(loc.getWorld())) {
@ -835,7 +848,8 @@ import java.util.regex.Pattern;
} }
} }
@EventHandler(priority = EventPriority.LOW) public void onChat(AsyncPlayerChatEvent event) { @EventHandler(priority = EventPriority.LOW)
public void onChat(AsyncPlayerChatEvent event) {
if (event.isCancelled()) if (event.isCancelled())
return; return;
@ -887,7 +901,8 @@ import java.util.regex.Pattern;
PlotSquared.debug(full); PlotSquared.debug(full);
} }
@EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) { @EventHandler(priority = EventPriority.LOWEST)
public void blockDestroy(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Location location = BukkitUtil.getLocation(event.getBlock().getLocation()); Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
@ -1972,10 +1987,13 @@ import java.util.regex.Pattern;
return; return;
} }
CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
//TODO needs an overhaul for the increased number of spawn reasons added to this event.
//I can't believe they waited so damn long to expand this API set.
switch (reason) { switch (reason) {
case SPAWNER_EGG: case SPAWNER_EGG:
case DISPENSE_EGG: case DISPENSE_EGG:
case OCELOT_BABY: case OCELOT_BABY:
case EGG:
if (!area.SPAWN_EGGS) { if (!area.SPAWN_EGGS) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -2053,7 +2071,8 @@ import java.util.regex.Pattern;
} }
} }
@EventHandler public void onPrime(ExplosionPrimeEvent event) { @EventHandler
public void onPrime(ExplosionPrimeEvent event) {
this.lastRadius = event.getRadius() + 1; this.lastRadius = event.getRadius() + 1;
} }
@ -2213,7 +2232,8 @@ import java.util.regex.Pattern;
PlotInventory.removePlotInventoryOpen(BukkitUtil.getPlayer(player)); PlotInventory.removePlotInventoryOpen(BukkitUtil.getPlayer(player));
} }
@EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerQuitEvent event) { @EventHandler(priority = EventPriority.MONITOR)
public void onLeave(PlayerQuitEvent event) {
TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName()); TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName());
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
pp.unregister(); pp.unregister();
@ -2501,7 +2521,8 @@ import java.util.regex.Pattern;
} }
} }
@SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGHEST) @SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) { public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
EntityDamageByEntityEvent eventChange; EntityDamageByEntityEvent eventChange;
eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(),

View File

@ -30,7 +30,8 @@ import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@SuppressWarnings("unused") public class PlotPlusListener extends PlotListener implements Listener { @SuppressWarnings("unused")
public class PlotPlusListener extends PlotListener implements Listener {
private static final HashMap<UUID, Interval> feedRunnable = new HashMap<>(); private static final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
private static final HashMap<UUID, Interval> healRunnable = new HashMap<>(); private static final HashMap<UUID, Interval> healRunnable = new HashMap<>();
@ -80,7 +81,8 @@ import java.util.UUID;
}, 0L, 20L); }, 0L, 20L);
} }
@EventHandler(priority = EventPriority.HIGH) public void onInteract(BlockDamageEvent event) { @EventHandler(priority = EventPriority.HIGH)
public void onInteract(BlockDamageEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player.getGameMode() != GameMode.SURVIVAL) { if (player.getGameMode() != GameMode.SURVIVAL) {
return; return;
@ -99,7 +101,8 @@ import java.util.UUID;
} }
} }
@EventHandler(priority = EventPriority.HIGH) public void onDamage(EntityDamageEvent event) { @EventHandler(priority = EventPriority.HIGH)
public void onDamage(EntityDamageEvent event) {
if (event.getEntityType() != EntityType.PLAYER) { if (event.getEntityType() != EntityType.PLAYER) {
return; return;
} }
@ -113,7 +116,8 @@ import java.util.UUID;
} }
} }
@EventHandler public void onItemDrop(PlayerDropItemEvent event) { @EventHandler
public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot(); Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
@ -128,7 +132,8 @@ import java.util.UUID;
} }
} }
@EventHandler public void onPlotEnter(PlayerEnterPlotEvent event) { @EventHandler
public void onPlotEnter(PlayerEnterPlotEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Plot plot = event.getPlot(); Plot plot = event.getPlot();
Optional<Integer[]> feed = plot.getFlag(Flags.FEED); Optional<Integer[]> feed = plot.getFlag(Flags.FEED);
@ -143,13 +148,15 @@ import java.util.UUID;
} }
} }
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) { @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
feedRunnable.remove(player.getUniqueId()); feedRunnable.remove(player.getUniqueId());
healRunnable.remove(player.getUniqueId()); healRunnable.remove(player.getUniqueId());
} }
@EventHandler public void onPlotLeave(PlayerLeavePlotEvent event) { @EventHandler
public void onPlotLeave(PlayerLeavePlotEvent event) {
Player leaver = event.getPlayer(); Player leaver = event.getPlayer();
Plot plot = event.getPlot(); Plot plot = event.getPlot();
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
@ -160,7 +167,8 @@ import java.util.UUID;
healRunnable.remove(leaver.getUniqueId()); healRunnable.remove(leaver.getUniqueId());
} }
@EventHandler public void onItemPickup(EntityPickupItemEvent event) { @EventHandler
public void onItemPickup(EntityPickupItemEvent event) {
LivingEntity ent = event.getEntity(); LivingEntity ent = event.getEntity();
if (ent instanceof Player) { if (ent instanceof Player) {
Player player = (Player) ent; Player player = (Player) ent;
@ -181,7 +189,7 @@ import java.util.UUID;
final int interval; final int interval;
final int amount; final int amount;
final int max; final int max;
public int count = 0; int count = 0;
Interval(int interval, int amount, int max) { Interval(int interval, int amount, int max) {
this.interval = interval; this.interval = interval;

View File

@ -1072,22 +1072,22 @@ public class BukkitChunkManager extends ChunkManager {
} }
for (short y = 0; y <= maxY; y++) { for (short y = 0; y <= maxY; y++) {
Block block = world.getBlockAt(x, y, z); Block block = world.getBlockAt(x, y, z);
Material id = block.getType(); Material blockType = block.getType();
if (storeNormal) { if (storeNormal) {
if (id.name().contains("AIR")) { if (blockType.name().contains("AIR")) {
ids[y] = StringPlotBlock.EVERYTHING; ids[y] = StringPlotBlock.EVERYTHING;
} else { } else {
ids[y] = PlotBlock.get(id.name()); ids[y] = PlotBlock.get(blockType.name());
} }
} }
if (!id.name().contains("AIR")) { if (!blockType.name().contains("AIR")) {
try { try {
BlockLoc bl = new BlockLoc(x + offsetX, y, z + offsetZ); BlockLoc bl = new BlockLoc(x + offsetX, y, z + offsetZ);
if (block.getState() instanceof InventoryHolder) { if (block.getState() instanceof InventoryHolder) {
InventoryHolder inventoryHolder = (InventoryHolder) block.getState(); InventoryHolder inventoryHolder = (InventoryHolder) block.getState();
ItemStack[] inventory = ItemStack[] inventory =
inventoryHolder.getInventory().getContents().clone(); inventoryHolder.getInventory().getContents().clone();
switch (id) { switch (blockType) {
case CHEST: case CHEST:
this.chestContents.put(bl, inventory); this.chestContents.put(bl, inventory);
break; break;

View File

@ -11,12 +11,10 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
public class SinglePlotArea extends GridPlotWorld { public class SinglePlotArea extends GridPlotWorld {
private final SinglePlotArea instance;
public boolean VOID = false; public boolean VOID = false;
public SinglePlotArea() { public SinglePlotArea() {
super("*", null, new SingleWorldGenerator(), null, null); super("*", null, new SingleWorldGenerator(), null, null);
instance = this;
this.ALLOW_SIGNS = false; this.ALLOW_SIGNS = false;
this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE); this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
} }

View File

@ -1,5 +1,6 @@
#Fri Dec 21 16:11:33 EST 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip