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

View File

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

View File

@ -60,10 +60,8 @@ public class ConfigManager {
cfg = new ConfigReader(jobFile);
} catch (Exception e) {
e.printStackTrace();
}
if (cfg == null)
return;
}
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) {
File f = jobFile;
InputStreamReader s = null;
try {
s = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8);
s = new InputStreamReader(new FileInputStream(jobFile), StandardCharsets.UTF_8);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
if (!f.exists()) {
if (!jobFile.exists()) {
try {
f.createNewFile();
jobFile.createNewFile();
} catch (IOException e) {
Jobs.getPluginLogger().severe("Unable to create jobConfig.yml! No jobs were loaded!");
try {
@ -340,7 +337,7 @@ public class ConfigManager {
conf.set(path, value);
try {
conf.save(f);
conf.save(jobFile);
} catch (IOException e) {
e.printStackTrace();
}
@ -645,18 +642,17 @@ public class ConfigManager {
* @throws IOException
*/
private void loadJobSettings() throws IOException {
File f = jobFile;
if (!f.exists()) {
if (!jobFile.exists()) {
YmlMaker jobConfig = new YmlMaker(Jobs.getInstance(), "jobConfig.yml");
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();
if (!f.exists()) {
if (!jobFile.exists()) {
try {
f.createNewFile();
jobFile.createNewFile();
} catch (IOException e) {
log.severe("Unable to create jobConfig.yml! No jobs were loaded!");
s.close();
@ -1051,10 +1047,8 @@ public class ConfigManager {
name = itemSection.getString("name");
List<String> lore = new ArrayList<>();
if (itemSection.contains("lore"))
for (String eachLine : itemSection.getStringList("lore")) {
lore.add(CMIChatColor.translate(eachLine));
}
if (itemSection.isList("lore"))
itemSection.getStringList("lore").stream().map(CMIChatColor::translate).forEach(lore::add);
HashMap<Enchantment, Integer> enchants = new HashMap<>();
if (itemSection.contains("enchants"))
@ -1276,7 +1270,7 @@ public class ConfigManager {
private double updateValue(CurrencyType type, double amount) {
Double mult = Jobs.getGCManager().getGeneralMulti(type);
amount = amount + (amount * mult);
amount += (amount * mult);
return amount;
}
}

View File

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

View File

@ -1192,7 +1192,7 @@ public abstract class JobsDAO {
ResultSet res = null;
try {
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.setInt(1, job.getId());
res = prest.executeQuery();

View File

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

View File

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

View File

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

View File

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