1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-06 16:27:59 +01:00

Remove useless isEnabled thing from listeners

This commit is contained in:
montlikadani 2020-08-10 19:49:55 +02:00
parent 4bf49034b1
commit 9fdbc0588d
9 changed files with 90 additions and 225 deletions

View File

@ -1208,7 +1208,7 @@ public enum CMIMaterial {
} }
public Material getMaterial() { public Material getMaterial() {
return mat == null ? null : mat; return mat;
} }
public void updateMaterial() { public void updateMaterial() {
@ -1497,7 +1497,7 @@ public enum CMIMaterial {
} }
public boolean isBlock() { public boolean isBlock() {
return getMaterial() == null ? false : getMaterial().isBlock(); return getMaterial() != null && getMaterial().isBlock();
} }
public boolean isEquipment() { public boolean isEquipment() {
@ -1505,12 +1505,12 @@ public enum CMIMaterial {
} }
public boolean isSolid() { public boolean isSolid() {
return getMaterial() == null ? false : getMaterial().isSolid(); return getMaterial() != null && getMaterial().isSolid();
} }
public static boolean isMonsterEgg(Material mat) { public static boolean isMonsterEgg(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isMonsterEgg(); return m != null && m.isMonsterEgg();
} }
public boolean isMonsterEgg() { public boolean isMonsterEgg() {
@ -1595,7 +1595,7 @@ public enum CMIMaterial {
public static boolean isBed(Material mat) { public static boolean isBed(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isBed(); return m != null && m.isBed();
} }
public boolean isBed() { public boolean isBed() {
@ -1626,7 +1626,7 @@ public enum CMIMaterial {
public static boolean isStairs(Material mat) { public static boolean isStairs(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isStairs(); return m != null && m.isStairs();
} }
public boolean isStairs() { public boolean isStairs() {
@ -1678,7 +1678,7 @@ public enum CMIMaterial {
public static boolean isPotion(Material mat) { public static boolean isPotion(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isPotion(); return m != null && m.isPotion();
} }
public boolean isPotion() { public boolean isPotion() {
@ -1695,7 +1695,7 @@ public enum CMIMaterial {
public static boolean isBoat(Material mat) { public static boolean isBoat(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isBoat(); return m != null && m.isBoat();
} }
public boolean isBoat() { public boolean isBoat() {
@ -1715,7 +1715,7 @@ public enum CMIMaterial {
public static boolean isSapling(Material mat) { public static boolean isSapling(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isSapling(); return m != null && m.isSapling();
} }
public boolean isSapling() { public boolean isSapling() {
@ -1735,7 +1735,7 @@ public enum CMIMaterial {
public static boolean isButton(Material mat) { public static boolean isButton(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isButton(); return m != null && m.isButton();
} }
public boolean isButton() { public boolean isButton() {
@ -1758,7 +1758,7 @@ public enum CMIMaterial {
public static boolean isWater(Material mat) { public static boolean isWater(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isWater(); return m != null && m.isWater();
} }
public boolean isWater() { public boolean isWater() {
@ -1774,7 +1774,7 @@ public enum CMIMaterial {
public static boolean isLava(Material mat) { public static boolean isLava(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isLava(); return m != null && m.isLava();
} }
public boolean isLava() { public boolean isLava() {
@ -1790,7 +1790,7 @@ public enum CMIMaterial {
public static boolean isPlate(Material mat) { public static boolean isPlate(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isPlate(); return m != null && m.isPlate();
} }
public boolean isPlate() { public boolean isPlate() {
@ -1816,7 +1816,7 @@ public enum CMIMaterial {
public static boolean isWool(Material mat) { public static boolean isWool(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isWool(); return m != null && m.isWool();
} }
public boolean isWool() { public boolean isWool() {
@ -1846,7 +1846,7 @@ public enum CMIMaterial {
public static boolean isCarpet(Material mat) { public static boolean isCarpet(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isCarpet(); return m != null && m.isCarpet();
} }
public boolean isCarpet() { public boolean isCarpet() {
@ -1876,7 +1876,7 @@ public enum CMIMaterial {
public static boolean isShulkerBox(Material mat) { public static boolean isShulkerBox(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isShulkerBox(); return m != null && m.isShulkerBox();
} }
public boolean isShulkerBox() { public boolean isShulkerBox() {
@ -1907,7 +1907,7 @@ public enum CMIMaterial {
public static boolean isLeatherArmor(Material mat) { public static boolean isLeatherArmor(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isLeatherArmor(); return m != null && m.isLeatherArmor();
} }
public boolean isLeatherArmor() { public boolean isLeatherArmor() {
@ -1925,7 +1925,7 @@ public enum CMIMaterial {
public static boolean isArmor(Material mat) { public static boolean isArmor(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isArmor(); return m != null && m.isArmor();
} }
public boolean isArmor() { public boolean isArmor() {
@ -1969,7 +1969,7 @@ public enum CMIMaterial {
public static boolean isWeapon(Material mat) { public static boolean isWeapon(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isWeapon(); return m != null && m.isWeapon();
} }
public boolean isWeapon() { public boolean isWeapon() {
@ -1992,7 +1992,7 @@ public enum CMIMaterial {
public static boolean isTool(Material mat) { public static boolean isTool(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isTool(); return m != null && m.isTool();
} }
public boolean isTool() { public boolean isTool() {
@ -2036,7 +2036,7 @@ public enum CMIMaterial {
public static boolean isValidItem(Material mat) { public static boolean isValidItem(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isValidItem(); return m != null && m.isValidItem();
} }
public boolean isValidItem() { public boolean isValidItem() {
@ -2049,7 +2049,7 @@ public enum CMIMaterial {
public static boolean isAir(Material mat) { public static boolean isAir(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isAir(); return m != null && m.isAir();
} }
public boolean isAir() { public boolean isAir() {
@ -2066,7 +2066,7 @@ public enum CMIMaterial {
public static boolean isPotted(Material mat) { public static boolean isPotted(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isPotted(); return m != null && m.isPotted();
} }
public boolean isPotted() { public boolean isPotted() {
@ -2105,7 +2105,7 @@ public enum CMIMaterial {
public static boolean isAnvil(Material mat) { public static boolean isAnvil(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isAnvil(); return m != null && m.isAnvil();
} }
public boolean isAnvil() { public boolean isAnvil() {
@ -2122,7 +2122,7 @@ public enum CMIMaterial {
public static boolean isDoor(Material mat) { public static boolean isDoor(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isDoor(); return m != null && m.isDoor();
} }
public boolean isDoor() { public boolean isDoor() {
@ -2161,7 +2161,7 @@ public enum CMIMaterial {
public static boolean isGate(Material mat) { public static boolean isGate(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isGate(); return m != null && m.isGate();
} }
public boolean isGate() { public boolean isGate() {
@ -2184,7 +2184,7 @@ public enum CMIMaterial {
public static boolean isFence(Material mat) { public static boolean isFence(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isFence(); return m != null && m.isFence();
} }
public boolean isFence() { public boolean isFence() {
@ -2208,7 +2208,7 @@ public enum CMIMaterial {
public static boolean isRail(Material mat) { public static boolean isRail(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isRail(); return m != null && m.isRail();
} }
public boolean isRail() { public boolean isRail() {
@ -2226,7 +2226,7 @@ public enum CMIMaterial {
public static boolean isGlassPane(Material mat) { public static boolean isGlassPane(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isGlassPane(); return m != null && m.isGlassPane();
} }
public boolean isGlassPane() { public boolean isGlassPane() {
@ -2257,7 +2257,7 @@ public enum CMIMaterial {
public static boolean isWallSign(Material mat) { public static boolean isWallSign(Material mat) {
CMIMaterial m = get(mat); CMIMaterial m = get(mat);
return m == null ? false : m.isWallSign(); return m != null && m.isWallSign();
} }
public boolean isWallSign() { public boolean isWallSign() {
@ -2280,7 +2280,7 @@ public enum CMIMaterial {
public static boolean isSign(Material mat) { public static boolean isSign(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isSign(); return m != null && m.isSign();
} }
public boolean isSign() { public boolean isSign() {
@ -2322,7 +2322,7 @@ public enum CMIMaterial {
public static boolean isWall(Material mat) { public static boolean isWall(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isWall(); return m != null && m.isWall();
} }
public boolean isWall() { public boolean isWall() {
@ -2351,7 +2351,7 @@ public enum CMIMaterial {
public static boolean isTrapDoor(Material mat) { public static boolean isTrapDoor(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isTrapDoor(); return m != null && m.isTrapDoor();
} }
public boolean isTrapDoor() { public boolean isTrapDoor() {
@ -2374,7 +2374,7 @@ public enum CMIMaterial {
public static boolean isSkull(Material mat) { public static boolean isSkull(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isSkull(); return m != null && m.isSkull();
} }
public boolean isSkull() { public boolean isSkull() {
@ -2396,7 +2396,7 @@ public enum CMIMaterial {
public static boolean isDye(Material mat) { public static boolean isDye(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isDye(); return m != null && m.isDye();
} }
public boolean isDye() { public boolean isDye() {
@ -2434,7 +2434,7 @@ public enum CMIMaterial {
public static boolean isSlab(Material mat) { public static boolean isSlab(Material mat) {
CMIMaterial m = CMIMaterial.get(mat); CMIMaterial m = CMIMaterial.get(mat);
return m == null ? false : m.isSlab(); return m != null && m.isSlab();
} }
public boolean isSlab() { public boolean isSlab() {
@ -2549,12 +2549,6 @@ public enum CMIMaterial {
return CMISlabType.DOUBLE; return CMISlabType.DOUBLE;
} }
case 182: case 182:
switch (block.getData()) {
case 0:
return CMISlabType.BOTTOM;
default:
return CMISlabType.DOUBLE;
}
case 205: case 205:
switch (block.getData()) { switch (block.getData()) {
case 0: case 0:

View File

@ -481,8 +481,6 @@ public class Jobs extends JavaPlugin {
if (dao != null) { if (dao != null) {
dao.closeConnections(); dao.closeConnections();
} }
HandlerList.unregisterAll(instance);
} }
/** /**
@ -783,6 +781,8 @@ public class Jobs extends JavaPlugin {
if (instance == null) if (instance == null)
return; return;
HandlerList.unregisterAll(instance);
// GUIManager.CloseInventories(); // GUIManager.CloseInventories();
// shopManager.CloseInventories(); // shopManager.CloseInventories();
dao.saveExplore(); dao.saveExplore();

View File

@ -60,10 +60,8 @@ public class ConfigManager {
cfg = new ConfigReader(jobFile); cfg = new ConfigReader(jobFile);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}
if (cfg == null)
return; return;
}
cfg.header(Arrays.asList("Jobs configuration.", "", "Edited by roracle to include 1.13 items and item names, prepping for 1.14 as well.", cfg.header(Arrays.asList("Jobs configuration.", "", "Edited by roracle to include 1.13 items and item names, prepping for 1.14 as well.",
"", "",
@ -294,17 +292,16 @@ public class ConfigManager {
} }
public void changeJobsSettings(String path, Object value) { public void changeJobsSettings(String path, Object value) {
File f = jobFile;
InputStreamReader s = null; InputStreamReader s = null;
try { try {
s = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8); s = new InputStreamReader(new FileInputStream(jobFile), StandardCharsets.UTF_8);
} catch (FileNotFoundException e1) { } catch (FileNotFoundException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
if (!f.exists()) { if (!jobFile.exists()) {
try { try {
f.createNewFile(); jobFile.createNewFile();
} catch (IOException e) { } catch (IOException e) {
Jobs.getPluginLogger().severe("Unable to create jobConfig.yml! No jobs were loaded!"); Jobs.getPluginLogger().severe("Unable to create jobConfig.yml! No jobs were loaded!");
try { try {
@ -340,7 +337,7 @@ public class ConfigManager {
conf.set(path, value); conf.set(path, value);
try { try {
conf.save(f); conf.save(jobFile);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -645,18 +642,17 @@ public class ConfigManager {
* @throws IOException * @throws IOException
*/ */
private void loadJobSettings() throws IOException { private void loadJobSettings() throws IOException {
File f = jobFile; if (!jobFile.exists()) {
if (!f.exists()) {
YmlMaker jobConfig = new YmlMaker(Jobs.getInstance(), "jobConfig.yml"); YmlMaker jobConfig = new YmlMaker(Jobs.getInstance(), "jobConfig.yml");
jobConfig.saveDefaultConfig(); jobConfig.saveDefaultConfig();
} }
InputStreamReader s = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8); InputStreamReader s = new InputStreamReader(new FileInputStream(jobFile), StandardCharsets.UTF_8);
java.util.logging.Logger log = Jobs.getPluginLogger(); java.util.logging.Logger log = Jobs.getPluginLogger();
if (!f.exists()) { if (!jobFile.exists()) {
try { try {
f.createNewFile(); jobFile.createNewFile();
} catch (IOException e) { } catch (IOException e) {
log.severe("Unable to create jobConfig.yml! No jobs were loaded!"); log.severe("Unable to create jobConfig.yml! No jobs were loaded!");
s.close(); s.close();
@ -1051,10 +1047,8 @@ public class ConfigManager {
name = itemSection.getString("name"); name = itemSection.getString("name");
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
if (itemSection.contains("lore")) if (itemSection.isList("lore"))
for (String eachLine : itemSection.getStringList("lore")) { itemSection.getStringList("lore").stream().map(CMIChatColor::translate).forEach(lore::add);
lore.add(CMIChatColor.translate(eachLine));
}
HashMap<Enchantment, Integer> enchants = new HashMap<>(); HashMap<Enchantment, Integer> enchants = new HashMap<>();
if (itemSection.contains("enchants")) if (itemSection.contains("enchants"))
@ -1276,7 +1270,7 @@ public class ConfigManager {
private double updateValue(CurrencyType type, double amount) { private double updateValue(CurrencyType type, double amount) {
Double mult = Jobs.getGCManager().getGeneralMulti(type); Double mult = Jobs.getGCManager().getGeneralMulti(type);
amount = amount + (amount * mult); amount += (amount * mult);
return amount; return amount;
} }
} }

View File

@ -137,7 +137,7 @@ public class Job {
} }
public boolean isSame(Job job) { public boolean isSame(Job job) {
return job == null ? false : getName().equalsIgnoreCase(job.getName()); return job != null && getName().equalsIgnoreCase(job.getName());
} }
public int getTotalPlayers() { public int getTotalPlayers() {
@ -149,7 +149,7 @@ public class Job {
} }
public void updateTotalPlayers() { public void updateTotalPlayers() {
this.totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(this.jobName); totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(jobName);
updateBonus(); updateBonus();
} }

View File

@ -1192,7 +1192,7 @@ public abstract class JobsDAO {
ResultSet res = null; ResultSet res = null;
try { try {
Job job = Jobs.getJob(JobName); Job job = Jobs.getJob(JobName);
if (job != null && job.getId() != 0) { if (job != null) {
prest = conn.prepareStatement("SELECT COUNT(*) FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.jobid + "` = ?;"); prest = conn.prepareStatement("SELECT COUNT(*) FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.jobid + "` = ?;");
prest.setInt(1, job.getId()); prest.setInt(1, job.getId());
res = prest.executeQuery(); res = prest.executeQuery();

View File

@ -146,7 +146,7 @@ public class JobsListener implements Listener {
if (iih == null || iih.getType() == Material.AIR) if (iih == null || iih.getType() == Material.AIR)
return; return;
if (!iih.getType().equals(CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())) if (iih.getType() != CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())
return; return;
if (!Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
@ -155,7 +155,7 @@ public class JobsListener implements Listener {
if (!player.hasPermission("jobs.area.select")) if (!player.hasPermission("jobs.area.select"))
return; return;
if (player.getGameMode().equals(GameMode.CREATIVE)) if (player.getGameMode() == GameMode.CREATIVE)
event.setCancelled(true); event.setCancelled(true);
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
@ -180,10 +180,6 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(final PlayerJoinEvent event) { public void onPlayerJoin(final PlayerJoinEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
if (!Jobs.getGCManager().MultiServerCompatability()) if (!Jobs.getGCManager().MultiServerCompatability())
Jobs.getPlayerManager().playerJoin(event.getPlayer()); Jobs.getPlayerManager().playerJoin(event.getPlayer());
else { else {
@ -210,10 +206,6 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Jobs.getPlayerManager().playerQuit(event.getPlayer()); Jobs.getPlayerManager().playerQuit(event.getPlayer());
} }
@ -228,9 +220,6 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSignInteract(PlayerInteractEvent event) { public void onSignInteract(PlayerInteractEvent event) {
if (!plugin.isEnabled())
return;
if (!Jobs.getGCManager().SignsEnabled) if (!Jobs.getGCManager().SignsEnabled)
return; return;
@ -264,9 +253,6 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSignDestroy(BlockBreakEvent event) { public void onSignDestroy(BlockBreakEvent event) {
if (!plugin.isEnabled())
return;
if (!Jobs.getGCManager().SignsEnabled) if (!Jobs.getGCManager().SignsEnabled)
return; return;
@ -301,9 +287,6 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onSignTopListCreate(SignChangeEvent event) { public void onSignTopListCreate(SignChangeEvent event) {
if (!plugin.isEnabled())
return;
if (!Jobs.getGCManager().SignsEnabled) if (!Jobs.getGCManager().SignsEnabled)
return; return;
@ -371,9 +354,6 @@ public class JobsListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onSignChange(SignChangeEvent event) { public void onSignChange(SignChangeEvent event) {
if (!plugin.isEnabled())
return;
if (!Jobs.getGCManager().SignsEnabled) if (!Jobs.getGCManager().SignsEnabled)
return; return;
@ -415,9 +395,6 @@ public class JobsListener implements Listener {
// Adding to chat prefix job name // Adding to chat prefix job name
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) { public void onPlayerChat(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled())
return;
if (!Jobs.getGCManager().getModifyChat()) if (!Jobs.getGCManager().getModifyChat())
return; return;
@ -434,9 +411,6 @@ public class JobsListener implements Listener {
// Changing chat prefix variable to job name // Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerChatLow(AsyncPlayerChatEvent event) { public void onPlayerChatLow(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled())
return;
if (Jobs.getGCManager().getModifyChat()) if (Jobs.getGCManager().getModifyChat())
return; return;
@ -456,9 +430,6 @@ public class JobsListener implements Listener {
// Changing chat prefix variable to job name // Changing chat prefix variable to job name
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChatHigh(AsyncPlayerChatEvent event) { public void onPlayerChatHigh(AsyncPlayerChatEvent event) {
if (!plugin.isEnabled())
return;
if (Jobs.getGCManager().getModifyChat()) if (Jobs.getGCManager().getModifyChat())
return; return;
@ -601,15 +572,15 @@ public class JobsListener implements Listener {
boolean shift = false, numberkey = false; boolean shift = false, numberkey = false;
ClickType click = event.getClick(); ClickType click = event.getClick();
if (click.equals(ClickType.SHIFT_LEFT) || click.equals(ClickType.SHIFT_RIGHT)) if (click == ClickType.SHIFT_LEFT || click == ClickType.SHIFT_RIGHT)
shift = true; shift = true;
if (click.equals(ClickType.NUMBER_KEY)) if (click == ClickType.NUMBER_KEY)
numberkey = true; numberkey = true;
SlotType slotType = event.getSlotType(); SlotType slotType = event.getSlotType();
if ((slotType != SlotType.ARMOR || slotType != SlotType.QUICKBAR) && !event.getInventory().getType().equals(InventoryType.CRAFTING)) if ((slotType != SlotType.ARMOR || slotType != SlotType.QUICKBAR) && event.getInventory().getType() != InventoryType.CRAFTING)
return; return;
if (!(event.getWhoClicked() instanceof Player)) if (!(event.getWhoClicked() instanceof Player))
@ -635,13 +606,13 @@ public class JobsListener implements Listener {
PlayerInventory inv = player.getInventory(); PlayerInventory inv = player.getInventory();
if (newArmorType.equals(ArmorTypes.HELMET) && if (newArmorType == ArmorTypes.HELMET &&
(equipping ? inv.getHelmet() == null : inv.getHelmet() != null) || (equipping ? inv.getHelmet() == null : inv.getHelmet() != null) ||
(newArmorType.equals(ArmorTypes.CHESTPLATE) || newArmorType.equals(ArmorTypes.ELYTRA)) && (newArmorType == ArmorTypes.CHESTPLATE || newArmorType == ArmorTypes.ELYTRA) &&
(equipping ? inv.getChestplate() == null : inv.getChestplate() != null) || (equipping ? inv.getChestplate() == null : inv.getChestplate() != null) ||
newArmorType.equals(ArmorTypes.LEGGINGS) && newArmorType == ArmorTypes.LEGGINGS &&
(equipping ? inv.getLeggings() == null : inv.getLeggings() != null) || (equipping ? inv.getLeggings() == null : inv.getLeggings() != null) ||
newArmorType.equals(ArmorTypes.BOOTS) && newArmorType == ArmorTypes.BOOTS &&
(equipping ? inv.getBoots() == null : inv.getBoots() != null)) { (equipping ? inv.getBoots() == null : inv.getBoots() != null)) {
JobsArmorChangeEvent armorEquipEvent = new JobsArmorChangeEvent(player, EquipMethod.SHIFT_CLICK, newArmorType, equipping ? null : event JobsArmorChangeEvent armorEquipEvent = new JobsArmorChangeEvent(player, EquipMethod.SHIFT_CLICK, newArmorType, equipping ? null : event
.getCurrentItem(), equipping ? event.getCurrentItem() : null); .getCurrentItem(), equipping ? event.getCurrentItem() : null);
@ -655,7 +626,7 @@ public class JobsListener implements Listener {
ItemStack newArmorPiece = event.getCursor(); ItemStack newArmorPiece = event.getCursor();
ItemStack oldArmorPiece = event.getCurrentItem(); ItemStack oldArmorPiece = event.getCurrentItem();
if (numberkey) { if (numberkey) {
if (event.getClickedInventory().getType().equals(InventoryType.PLAYER)) { if (event.getClickedInventory().getType() == InventoryType.PLAYER) {
ItemStack hotbarItem = event.getClickedInventory().getItem(event.getHotbarButton()); ItemStack hotbarItem = event.getClickedInventory().getItem(event.getHotbarButton());
if (hotbarItem != null) { if (hotbarItem != null) {
newArmorType = ArmorTypes.matchType(hotbarItem); newArmorType = ArmorTypes.matchType(hotbarItem);
@ -669,7 +640,7 @@ public class JobsListener implements Listener {
if (newArmorType != null && event.getRawSlot() == newArmorType.getSlot()) { if (newArmorType != null && event.getRawSlot() == newArmorType.getSlot()) {
EquipMethod method = EquipMethod.DRAG; EquipMethod method = EquipMethod.DRAG;
if (event.getAction().equals(InventoryAction.HOTBAR_SWAP) || numberkey) if (event.getAction() == InventoryAction.HOTBAR_SWAP || numberkey)
method = EquipMethod.HOTBAR_SWAP; method = EquipMethod.HOTBAR_SWAP;
JobsArmorChangeEvent armorEquipEvent = new JobsArmorChangeEvent((Player) event.getWhoClicked(), method, newArmorType, oldArmorPiece, newArmorPiece); JobsArmorChangeEvent armorEquipEvent = new JobsArmorChangeEvent((Player) event.getWhoClicked(), method, newArmorType, oldArmorPiece, newArmorPiece);
Bukkit.getServer().getPluginManager().callEvent(armorEquipEvent); Bukkit.getServer().getPluginManager().callEvent(armorEquipEvent);
@ -694,13 +665,13 @@ public class JobsListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerInventory inv = player.getInventory(); PlayerInventory inv = player.getInventory();
if (newArmorType.equals(ArmorTypes.HELMET) && if (newArmorType == ArmorTypes.HELMET &&
inv.getHelmet() == null || inv.getHelmet() == null ||
(newArmorType.equals(ArmorTypes.CHESTPLATE) || newArmorType.equals(ArmorTypes.ELYTRA)) && (newArmorType == ArmorTypes.CHESTPLATE || newArmorType == ArmorTypes.ELYTRA) &&
inv.getChestplate() == null || inv.getChestplate() == null ||
newArmorType.equals(ArmorTypes.LEGGINGS) && newArmorType == ArmorTypes.LEGGINGS &&
inv.getLeggings() == null || inv.getLeggings() == null ||
newArmorType.equals(ArmorTypes.BOOTS) && newArmorType == ArmorTypes.BOOTS &&
inv.getBoots() == null) { inv.getBoots() == null) {
JobsArmorChangeEvent armorEquipEvent = new JobsArmorChangeEvent(player, EquipMethod.HOTBAR, ArmorTypes.matchType(event.getItem()), null, event JobsArmorChangeEvent armorEquipEvent = new JobsArmorChangeEvent(player, EquipMethod.HOTBAR, ArmorTypes.matchType(event.getItem()), null, event
.getItem()); .getItem());
@ -728,10 +699,10 @@ public class JobsListener implements Listener {
Location ploc = p.getLocation(); Location ploc = p.getLocation();
if (loc.getBlockY() - ploc.getBlockY() >= -1 && loc.getBlockY() - ploc.getBlockY() <= 1) { if (loc.getBlockY() - ploc.getBlockY() >= -1 && loc.getBlockY() - ploc.getBlockY() <= 1) {
if (p.getInventory().getHelmet() == null && type.equals(ArmorTypes.HELMET) || if (p.getInventory().getHelmet() == null && type == ArmorTypes.HELMET ||
p.getInventory().getChestplate() == null && (type.equals(ArmorTypes.CHESTPLATE) || type.equals(ArmorTypes.ELYTRA)) || p.getInventory().getChestplate() == null && (type == ArmorTypes.CHESTPLATE || type == ArmorTypes.ELYTRA) ||
p.getInventory().getLeggings() == null && type.equals(ArmorTypes.LEGGINGS) || p.getInventory().getLeggings() == null && type == ArmorTypes.LEGGINGS ||
p.getInventory().getBoots() == null && type.equals(ArmorTypes.BOOTS)) { p.getInventory().getBoots() == null && type == ArmorTypes.BOOTS) {
if (!(event.getBlock().getState() instanceof Dispenser)) if (!(event.getBlock().getState() instanceof Dispenser))
continue; continue;

View File

@ -25,16 +25,10 @@ public class JobsPayment14Listener implements Listener {
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onCook(BlockCookEvent event) { public void onCook(BlockCookEvent event) {
if (!Jobs.getInstance().isEnabled())
return;
if (event.isCancelled()) if (event.isCancelled())
return; return;
if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld()) || !(event.getBlock().getState() instanceof Campfire))
return;
if (!(event.getBlock().getState() instanceof Campfire))
return; return;
for (Iterator<Entry<PlayerCamp, Player>> it = campPlayers.entrySet().iterator(); it.hasNext();) { for (Iterator<Entry<PlayerCamp, Player>> it = campPlayers.entrySet().iterator(); it.hasNext();) {
@ -61,17 +55,11 @@ public class JobsPayment14Listener implements Listener {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onCampPlace(PlayerInteractEvent ev) { public void onCampPlace(PlayerInteractEvent ev) {
if (!Jobs.getInstance().isEnabled())
return;
org.bukkit.block.Block click = ev.getClickedBlock(); org.bukkit.block.Block click = ev.getClickedBlock();
if (click == null || !click.getType().isBlock() || !click.getType().equals(org.bukkit.Material.CAMPFIRE)) if (click == null || !click.getType().isBlock() || click.getType() != org.bukkit.Material.CAMPFIRE)
return; return;
if (!Jobs.getGCManager().canPerformActionInWorld(click.getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(click.getWorld()) || !(click.getState() instanceof Campfire))
return;
if (!(click.getState() instanceof Campfire))
return; return;
if (!ev.hasItem()) if (!ev.hasItem())

View File

@ -105,8 +105,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void villagerTradeInventoryClick(InventoryClickEvent event) { public void villagerTradeInventoryClick(InventoryClickEvent event) {
// make sure plugin is enabled if (event.isCancelled())
if (!plugin.isEnabled() || event.isCancelled())
return; return;
//disabling plugin in world //disabling plugin in world
@ -184,10 +183,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCowMilking(PlayerInteractEntityEvent event) { public void onCowMilking(PlayerInteractEntityEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
//disabling plugin in world //disabling plugin in world
if (!player.isOnline() || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld())) if (!player.isOnline() || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
@ -251,10 +246,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShear(PlayerShearEntityEvent event) { public void onEntityShear(PlayerShearEntityEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
//disabling plugin in world //disabling plugin in world
if (!player.isOnline() || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld())) if (!player.isOnline() || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
@ -294,9 +285,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBrewEvent(BrewEvent event) { public void onBrewEvent(BrewEvent event) {
if (!plugin.isEnabled())
return;
Block block = event.getBlock(); Block block = event.getBlock();
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
@ -339,10 +327,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Block block = event.getBlock(); Block block = event.getBlock();
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
@ -388,11 +372,8 @@ public class JobsPaymentListener implements Listener {
if (!payForItemDurabilityLoss(player)) if (!payForItemDurabilityLoss(player))
return; return;
// restricted area multiplier
// Item in hand
ItemStack item = Jobs.getNms().getItemInMainHand(player); ItemStack item = Jobs.getNms().getItemInMainHand(player);
if (item != null && !item.getType().equals(Material.AIR)) { if (item != null && item.getType() != Material.AIR) {
// Protection for block break with silktouch // Protection for block break with silktouch
if (Jobs.getGCManager().useSilkTouchProtection) { if (Jobs.getGCManager().useSilkTouchProtection) {
for (Entry<Enchantment, Integer> one : item.getEnchantments().entrySet()) { for (Entry<Enchantment, Integer> one : item.getEnchantments().entrySet()) {
@ -421,10 +402,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Block block = event.getBlock(); Block block = event.getBlock();
//disabling plugin in world //disabling plugin in world
@ -471,10 +448,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) { public void onPlayerFish(PlayerFishEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(player.getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
@ -506,10 +479,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAnimalTame(EntityTameEvent event) { public void onAnimalTame(EntityTameEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
@ -552,10 +521,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryCraft(CraftItemEvent event) { public void onInventoryCraft(CraftItemEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
return; return;
@ -571,12 +536,10 @@ public class JobsPaymentListener implements Listener {
break; break;
} }
if (!event.getSlotType().equals(SlotType.RESULT)) if (event.getSlotType() != SlotType.RESULT)
return; return;
ItemStack resultStack = event.getRecipe().getResult(); ItemStack resultStack = event.getRecipe().getResult();
if (resultStack == null)
return;
if (!(event.getWhoClicked() instanceof Player)) if (!(event.getWhoClicked() instanceof Player))
return; return;
@ -795,10 +758,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryRepair(InventoryClickEvent event) { public void onInventoryRepair(InventoryClickEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getWhoClicked().getWorld()))
return; return;
@ -821,7 +780,7 @@ public class JobsPaymentListener implements Listener {
return; return;
int slot = event.getSlot(); int slot = event.getSlot();
if (!event.getSlotType().equals(SlotType.RESULT) || (slot != 2 && slot != 1)) if (event.getSlotType() != SlotType.RESULT || (slot != 2 && slot != 1))
return; return;
if ((Version.isCurrentEqualOrHigher(Version.v1_14_R1) && !(inv instanceof StonecutterInventory)) && slot == 1) if ((Version.isCurrentEqualOrHigher(Version.v1_14_R1) && !(inv instanceof StonecutterInventory)) && slot == 1)
@ -888,7 +847,7 @@ public class JobsPaymentListener implements Listener {
// Fix money dupping issue when clicking continuously in the result item, but if in the // Fix money dupping issue when clicking continuously in the result item, but if in the
// cursor have item, then dupping the money, #438 // cursor have item, then dupping the money, #438
if (event.isLeftClick() && !event.getCursor().getType().equals(Material.AIR)) if (event.isLeftClick() && event.getCursor().getType() != Material.AIR)
return; return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
@ -924,10 +883,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEnchantItem(EnchantItemEvent event) { public void onEnchantItem(EnchantItemEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
if (event.isCancelled()) if (event.isCancelled())
return; return;
@ -986,9 +941,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) { public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) {
if (!plugin.isEnabled())
return;
if (!Jobs.getGCManager().PreventHopperFillUps) if (!Jobs.getGCManager().PreventHopperFillUps)
return; return;
@ -1030,9 +982,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryMoveItemEventToBrewingStand(InventoryMoveItemEvent event) { public void onInventoryMoveItemEventToBrewingStand(InventoryMoveItemEvent event) {
if (!plugin.isEnabled())
return;
if (event.getDestination().getType() != InventoryType.BREWING) if (event.getDestination().getType() != InventoryType.BREWING)
return; return;
@ -1054,9 +1003,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFurnaceSmelt(FurnaceSmeltEvent event) { public void onFurnaceSmelt(FurnaceSmeltEvent event) {
if (!plugin.isEnabled())
return;
Block block = event.getBlock(); Block block = event.getBlock();
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(block.getWorld()))
@ -1103,7 +1049,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDamageByPlayer(EntityDamageEvent event) { public void onEntityDamageByPlayer(EntityDamageEvent event) {
//disabling plugin in world //disabling plugin in world
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
if (!Jobs.getGCManager().MonsterDamageUse) if (!Jobs.getGCManager().MonsterDamageUse)
@ -1176,10 +1122,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
@ -1292,7 +1234,7 @@ public class JobsPaymentListener implements Listener {
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
if (event.getSpawnReason().equals(SpawnReason.SPAWNER) || event.getSpawnReason().equals(SpawnReason.SPAWNER_EGG)) { if (event.getSpawnReason() == SpawnReason.SPAWNER || event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
LivingEntity creature = event.getEntity(); LivingEntity creature = event.getEntity();
creature.setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(plugin, true)); creature.setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(plugin, true));
} }
@ -1300,10 +1242,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHangingPlaceEvent(HangingPlaceEvent event) { public void onHangingPlaceEvent(HangingPlaceEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
@ -1332,15 +1270,11 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHangingBreakEvent(HangingBreakByEntityEvent event) { public void onHangingBreakEvent(HangingBreakByEntityEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
if (event.getRemover() == null || !(event.getRemover() instanceof Player)) if (!(event.getRemover() instanceof Player))
return; return;
Player player = (Player) event.getRemover(); Player player = (Player) event.getRemover();
@ -1479,10 +1413,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureBreed(CreatureSpawnEvent event) { public void onCreatureBreed(CreatureSpawnEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
@ -1507,7 +1437,6 @@ public class JobsPaymentListener implements Listener {
closest = dist; closest = dist;
player = i; player = i;
} }
} }
if (player != null && closest < 30.0) { if (player != null && closest < 30.0) {
@ -1532,10 +1461,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerEat(FoodLevelChangeEvent event) { public void onPlayerEat(FoodLevelChangeEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
//disabling plugin in world //disabling plugin in world
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
@ -1570,9 +1495,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTntExplode(EntityExplodeEvent event) { public void onTntExplode(EntityExplodeEvent event) {
if (!plugin.isEnabled())
return;
Entity e = event.getEntity(); Entity e = event.getEntity();
if (!Jobs.getGCManager().canPerformActionInWorld(e)) if (!Jobs.getGCManager().canPerformActionInWorld(e))
return; return;
@ -1647,9 +1569,6 @@ public class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (!plugin.isEnabled())
return;
Player p = event.getPlayer(); Player p = event.getPlayer();
if (!Jobs.getGCManager().canPerformActionInWorld(p.getWorld())) if (!Jobs.getGCManager().canPerformActionInWorld(p.getWorld()))
return; return;
@ -1772,8 +1691,7 @@ public class JobsPaymentListener implements Listener {
@EventHandler @EventHandler
public void onExplore(JobsChunkChangeEvent event) { public void onExplore(JobsChunkChangeEvent event) {
// make sure plugin is enabled if (event.isCancelled())
if (!plugin.isEnabled() || event.isCancelled())
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -27,9 +27,9 @@ public class PistonProtectionListener implements Listener {
BlockFace dir = event.getDirection(); BlockFace dir = event.getDirection();
int x = dir.getModX(); int x = dir.getModX(),
int y = dir.getModY(); y = dir.getModY(),
int z = dir.getModZ(); z = dir.getModZ();
for (Block one : event.getBlocks()) { for (Block one : event.getBlocks()) {
Location oldLoc = one.getLocation(); Location oldLoc = one.getLocation();
Location newLoc = oldLoc.clone().add(x, y, z); Location newLoc = oldLoc.clone().add(x, y, z);
@ -56,9 +56,9 @@ public class PistonProtectionListener implements Listener {
BlockFace dir = event.getDirection(); BlockFace dir = event.getDirection();
int x = dir.getModX(); int x = dir.getModX(),
int y = dir.getModY(); y = dir.getModY(),
int z = dir.getModZ(); z = dir.getModZ();
for (Block one : Jobs.getNms().getPistonRetractBlocks(event)) { for (Block one : Jobs.getNms().getPistonRetractBlocks(event)) {
Location oldLoc = one.getLocation(); Location oldLoc = one.getLocation();