diff --git a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CropGrowthAccelerator.java b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CropGrowthAccelerator.java index 27c71c2f9..7cb6a9412 100644 --- a/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CropGrowthAccelerator.java +++ b/src/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/machines/CropGrowthAccelerator.java @@ -1,6 +1,6 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines; -import java.util.HashMap; +import java.util.EnumMap; import java.util.Map; import org.bukkit.Material; @@ -32,7 +32,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem { private static final int[] border = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}; - public static final Map crops = new HashMap<>(); + public static final Map crops = new EnumMap<>(Material.class); static { crops.put(Material.WHEAT, 7); @@ -41,6 +41,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem { crops.put(Material.NETHER_WART, 3); crops.put(Material.BEETROOTS, 3); crops.put(Material.COCOA, 8); + crops.put(Material.SWEET_BERRY_BUSH, 3); } public CropGrowthAccelerator(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunManager.java b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunManager.java index f96bc6a72..5748b5c94 100644 --- a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunManager.java +++ b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunManager.java @@ -1,7 +1,7 @@ package me.mrCookieSlime.Slimefun.Setup; import java.util.ArrayList; -import java.util.HashMap; +import java.util.EnumMap; import java.util.List; import java.util.Map; @@ -23,7 +23,7 @@ public final class SlimefunManager { public static SlimefunStartup plugin; public static String PREFIX; - public static Map> drops = new HashMap<>(); + public static Map> drops = new EnumMap<>(EntityType.class); public static void registerArmorSet(ItemStack baseComponent, ItemStack[] items, String idSyntax, PotionEffect[][] effects, boolean special, boolean slimefun) { String[] components = new String[] {"_HELMET", "_CHESTPLATE", "_LEGGINGS", "_BOOTS"}; @@ -33,10 +33,12 @@ public final class SlimefunManager { recipes.add(new ItemStack[] {baseComponent, null, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent}); recipes.add(new ItemStack[] {baseComponent, baseComponent, baseComponent, baseComponent, null, baseComponent, baseComponent, null, baseComponent}); recipes.add(new ItemStack[] {null, null, null, baseComponent, null, baseComponent, baseComponent, null, baseComponent}); + for (int i = 0; i < 4; i++) { - if ((effects.length - 1) >= i) if (effects[i].length > 0) { + if (i < effects.length && effects[i].length > 0) { new SlimefunArmorPiece(cat, items[i], idSyntax + components[i], RecipeType.ARMOR_FORGE, recipes.get(i), effects[i]).register(slimefun); - } else { + } + else { new SlimefunItem(cat, items[i], idSyntax + components[i], RecipeType.ARMOR_FORGE, recipes.get(i)).register(slimefun); } } @@ -50,10 +52,12 @@ public final class SlimefunManager { recipes.add(new ItemStack[] {baseComponent, null, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent, baseComponent}); recipes.add(new ItemStack[] {baseComponent, baseComponent, baseComponent, baseComponent, null, baseComponent, baseComponent, null, baseComponent}); recipes.add(new ItemStack[] {null, null, null, baseComponent, null, baseComponent, baseComponent, null, baseComponent}); + for (int i = 0; i < 4; i++) { if (vanilla) { new VanillaItem(cat, items[i], idSyntax + components[i], RecipeType.ARMOR_FORGE, recipes.get(i)).register(slimefun); - } else { + } + else { new SlimefunItem(cat, items[i], idSyntax + components[i], RecipeType.ARMOR_FORGE, recipes.get(i)).register(slimefun); } } diff --git a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java index b1cf9e257..8cb9d9a27 100644 --- a/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java +++ b/src/me/mrCookieSlime/Slimefun/Setup/SlimefunSetup.java @@ -2102,10 +2102,11 @@ public final class SlimefunSetup { SlimefunStartup.instance.getUtilities().blocks.add(block.getUniqueId()); } for (Entity n: ground.getChunk().getEntities()) { - if (n instanceof LivingEntity && n.getLocation().distance(ground) <= 2.0D && n.getUniqueId() != p.getUniqueId()) { + if (n instanceof LivingEntity && n.getLocation().distance(ground) <= 2.0D && !n.getUniqueId().equals(p.getUniqueId())) { Vector vector = n.getLocation().toVector().subtract(p.getLocation().toVector()).normalize().multiply(1.4); vector.setY(0.9); n.setVelocity(vector); + if (p.getWorld().getPVP()) { EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, n, DamageCause.ENTITY_ATTACK, 6D); Bukkit.getPluginManager().callEvent(event); @@ -2414,9 +2415,10 @@ public final class SlimefunSetup { public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.SCROLL_OF_DIMENSIONAL_TELEPOSITION, true)) { for (Entity n: p.getNearbyEntities(10.0, 10.0, 10.0)) { - if (n instanceof LivingEntity && !(n instanceof ArmorStand) &&n.getUniqueId() != p.getUniqueId()) { + if (n instanceof LivingEntity && !(n instanceof ArmorStand) && !n.getUniqueId().equals(p.getUniqueId())) { float yaw = n.getLocation().getYaw() + 180.0F; if (yaw > 360.0F) yaw = yaw - 360.0F; + n.teleport(new Location(n.getWorld(), n.getLocation().getX(), n.getLocation().getY(), n.getLocation().getZ(), yaw, n.getLocation().getPitch())); } } diff --git a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java index a6a9e38de..068576e8c 100644 --- a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java +++ b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java @@ -80,7 +80,6 @@ public final class SlimefunStartup extends JavaPlugin { public static SlimefunStartup instance; - private static PluginUtils utils; private static Config researches; private static Config items; private static Config whitelist; @@ -142,7 +141,7 @@ public final class SlimefunStartup extends JavaPlugin { System.out.println("[Slimefun] Loading Config..."); - utils = new PluginUtils(this); + PluginUtils utils = new PluginUtils(this); utils.setupConfig(); // Loading all extra configs diff --git a/src/me/mrCookieSlime/Slimefun/api/BlockStorage.java b/src/me/mrCookieSlime/Slimefun/api/BlockStorage.java index e20e3b891..5a61f55e1 100644 --- a/src/me/mrCookieSlime/Slimefun/api/BlockStorage.java +++ b/src/me/mrCookieSlime/Slimefun/api/BlockStorage.java @@ -89,7 +89,8 @@ public class BlockStorage { File f = new File(path_blocks + w.getName()); if (f.exists()) { - long total = f.listFiles().length, start = System.currentTimeMillis(); + long total = f.listFiles().length; + long start = System.currentTimeMillis(); long done = 0; long timestamp = System.currentTimeMillis(); long totalBlocks = 0; @@ -525,7 +526,9 @@ public class BlockStorage { if (item != null && item.isTicking()) { String chunk_string = locationToChunkString(l); if (value != null) { - Set locations = ticking_chunks.containsKey(chunk_string) ? ticking_chunks.get(chunk_string): new HashSet<>(); + Set locations = ticking_chunks.get(chunk_string); + if (locations == null) locations = new HashSet<>(); + locations.add(l); ticking_chunks.put(chunk_string, locations); if (!loaded_tickers.contains(chunk_string)) loaded_tickers.add(chunk_string); @@ -723,6 +726,6 @@ public class BlockStorage { public boolean hasUniversalInventory(Location l) { String id = checkID(l); - return id == null ? false: hasUniversalInventory(id); + return id != null && hasUniversalInventory(id); } } diff --git a/src/me/mrCookieSlime/Slimefun/api/network/Network.java b/src/me/mrCookieSlime/Slimefun/api/network/Network.java index b3a84cd24..1f5dd3e72 100644 --- a/src/me/mrCookieSlime/Slimefun/api/network/Network.java +++ b/src/me/mrCookieSlime/Slimefun/api/network/Network.java @@ -162,15 +162,12 @@ public abstract class Network { } public void display() { - SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { - @Override - public void run() { - for(Location l: connectedLocations) { - try { - ParticleEffect.REDSTONE.display(l.clone().add(0.5, 0.5, 0.5), 0, 0, 0, 1, 1); - } catch(Exception e) { - e.printStackTrace(); - } + SlimefunStartup.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, () -> { + for(Location l: connectedLocations) { + try { + ParticleEffect.REDSTONE.display(l.clone().add(0.5, 0.5, 0.5), 0, 0, 0, 1, 1); + } catch(Exception e) { + e.printStackTrace(); } } }); diff --git a/src/me/mrCookieSlime/Slimefun/holograms/CargoHologram.java b/src/me/mrCookieSlime/Slimefun/holograms/CargoHologram.java index 6c02b84c8..e34b796de 100644 --- a/src/me/mrCookieSlime/Slimefun/holograms/CargoHologram.java +++ b/src/me/mrCookieSlime/Slimefun/holograms/CargoHologram.java @@ -34,9 +34,7 @@ public final class CargoHologram { } if (!createIfNonExists) return null; - - ArmorStand hologram = ArmorStandFactory.createHidden(l); - return hologram; + else return ArmorStandFactory.createHidden(l); } } diff --git a/src/me/mrCookieSlime/Slimefun/holograms/EnergyHologram.java b/src/me/mrCookieSlime/Slimefun/holograms/EnergyHologram.java index 784233265..583d4cb30 100644 --- a/src/me/mrCookieSlime/Slimefun/holograms/EnergyHologram.java +++ b/src/me/mrCookieSlime/Slimefun/holograms/EnergyHologram.java @@ -41,9 +41,7 @@ public final class EnergyHologram { } if (!createIfNonExists) return null; - - ArmorStand hologram = ArmorStandFactory.createHidden(l); - return hologram; + else return ArmorStandFactory.createHidden(l); } } diff --git a/src/me/mrCookieSlime/Slimefun/listeners/DamageListener.java b/src/me/mrCookieSlime/Slimefun/listeners/DamageListener.java index 648546c60..38b1d906f 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/DamageListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/DamageListener.java @@ -64,7 +64,7 @@ public class DamageListener implements Listener { Soul.storeItem(e.getEntity().getUniqueId(), item); drops.remove(); } - else if (SlimefunItem.getByItem(removeEnchantments(item)) != null && SlimefunItem.getByItem(removeEnchantments(item)) instanceof SoulboundItem) { + else if (SlimefunItem.getByItem(removeEnchantments(item)) instanceof SoulboundItem) { Soul.storeItem(e.getEntity().getUniqueId(), item); drops.remove(); } diff --git a/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java b/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java index aaa2f32a0..29620130f 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/ItemListener.java @@ -329,7 +329,8 @@ public class ItemListener implements Listener { } else if (item.getType() == Material.POTION) { SlimefunItem sfItem = SlimefunItem.getByItem(item); - if (sfItem != null && sfItem instanceof Juice) { + + if (sfItem instanceof Juice) { // Fix for Saturation on potions is no longer working for (PotionEffect effect : ((PotionMeta) item.getItemMeta()).getCustomEffects()) { if (effect.getType().equals(PotionEffectType.SATURATION)) { @@ -401,10 +402,10 @@ public class ItemListener implements Listener { } } else if (e.getEntity() instanceof Wither) { - SlimefunItem item = BlockStorage.check(e.getBlock()); - if (item != null) { - if (item.getID().equals("WITHER_PROOF_OBSIDIAN")) e.setCancelled(true); - else if (item.getID().equals("WITHER_PROOF_GLASS")) e.setCancelled(true); + String id = BlockStorage.checkID(e.getBlock()); + if (id != null) { + if (id.equals("WITHER_PROOF_OBSIDIAN")) e.setCancelled(true); + else if (id.equals("WITHER_PROOF_GLASS")) e.setCancelled(true); } } } @@ -414,11 +415,14 @@ public class ItemListener implements Listener { if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.ANVIL) { ItemStack slot0 = e.getInventory().getContents()[0]; ItemStack slot1 = e.getInventory().getContents()[1]; + if (SlimefunManager.isItemSimiliar(slot0, SlimefunItems.ELYTRA, true)) return; + if (SlimefunItem.getByItem(slot0) != null && !SlimefunItem.isDisabled(slot0)) { e.setCancelled(true); Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true); - } else if (SlimefunItem.getByItem(slot1) != null && !SlimefunItem.isDisabled(slot1)) { + } + else if (SlimefunItem.getByItem(slot1) != null && !SlimefunItem.isDisabled(slot1)) { e.setCancelled(true); Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true); } @@ -427,7 +431,8 @@ public class ItemListener implements Listener { if (SlimefunManager.isItemSimiliar(slot0, SlimefunGuide.getItem(BookDesign.BOOK), true)) { e.setCancelled(true); Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true); - } else if (SlimefunManager.isItemSimiliar(slot0, SlimefunGuide.getItem(BookDesign.CHEST), true)) { + } + else if (SlimefunManager.isItemSimiliar(slot0, SlimefunGuide.getItem(BookDesign.CHEST), true)) { e.setCancelled(true); Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true); } @@ -435,7 +440,8 @@ public class ItemListener implements Listener { if (SlimefunManager.isItemSimiliar(slot1, SlimefunGuide.getItem(BookDesign.BOOK), true)) { e.setCancelled(true); Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true); - } else if (SlimefunManager.isItemSimiliar(slot1, SlimefunGuide.getItem(BookDesign.CHEST), true)) { + } + else if (SlimefunManager.isItemSimiliar(slot1, SlimefunGuide.getItem(BookDesign.CHEST), true)) { e.setCancelled(true); Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true); } diff --git a/src/me/mrCookieSlime/Slimefun/listeners/TalismanListener.java b/src/me/mrCookieSlime/Slimefun/listeners/TalismanListener.java index 6c0926fa7..015acfe20 100644 --- a/src/me/mrCookieSlime/Slimefun/listeners/TalismanListener.java +++ b/src/me/mrCookieSlime/Slimefun/listeners/TalismanListener.java @@ -52,7 +52,8 @@ public class TalismanListener implements Listener { ((Player) ((EntityDamageByEntityEvent) e).getDamager()).playSound(((EntityDamageByEntityEvent) e).getDamager().getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.7F, 0.7F); ((Player) ((EntityDamageByEntityEvent) e).getDamager()).addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1)); } - if (e.getEntity() instanceof Player && !e.isCancelled()) { + + if (e.getEntity() instanceof Player) { if (e.getCause() == DamageCause.LAVA) Talisman.checkFor(e, SlimefunItem.getByID("LAVA_TALISMAN")); if (e.getCause() == DamageCause.DROWNING) Talisman.checkFor(e, SlimefunItem.getByID("WATER_TALISMAN")); if (e.getCause() == DamageCause.FALL) Talisman.checkFor(e, SlimefunItem.getByID("ANGEL_TALISMAN"));