1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00
This commit is contained in:
TheBusyBiscuit 2019-10-04 14:05:22 +02:00
commit 5d1c36734e
13 changed files with 137 additions and 167 deletions

View File

@ -36,15 +36,12 @@ public class GPSNetwork {
private static final int[] teleporter_inventory = new int[] {19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43};
public void updateTransmitter(Location l, UUID uuid, NetworkStatus status) {
Set<Location> set = new HashSet<>();
if (transmitters.containsKey(uuid)) set = transmitters.get(uuid);
Set<Location> set = transmitters.getOrDefault(uuid, new HashSet<>());
if (status == NetworkStatus.ONLINE) {
if (!set.contains(l)) {
set.add(l);
if (set.add(l))
transmitters.put(uuid, set);
}
}
else {
set.remove(l);
transmitters.put(uuid, set);
@ -215,7 +212,7 @@ public class GPSNetwork {
}
public Set<Location> getTransmitters(UUID uuid) {
return transmitters.containsKey(uuid) ? transmitters.get(uuid): new HashSet<>();
return transmitters.getOrDefault(uuid, new HashSet<>());
}
public static void openTeleporterGUI(Player p, UUID uuid, Block b, final int complexity) {
@ -258,7 +255,7 @@ public class GPSNetwork {
}
}
catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while creating a Teleporter Menu for Slimefun " + Slimefun.getVersion(), x);
Slimefun.getLogger().log(Level.SEVERE, "An Error occurred while creating a Teleporter Menu for Slimefun " + Slimefun.getVersion(), x);
}
menu.open(p);

View File

@ -82,7 +82,7 @@ public final class TeleportationSequence {
}
destination.getWorld().spawnParticle(Particle.PORTAL,new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()),progress * 2, 0.2F, 0.8F, 0.2F );
destination.getWorld().playSound(destination, Sound.ENTITY_BLAZE_DEATH, 2F, 1.4F);
destination.getWorld().playSound(destination, Sound.ENTITY_BLAZE_DEATH, 1F, 1.4F);
SlimefunPlugin.getUtilities().teleporterUsers.remove(uuid);
}
else {
@ -93,7 +93,7 @@ public final class TeleportationSequence {
subtitle.send(TitleType.SUBTITLE, p);
source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F);
source.getWorld().playSound(source, Sound.UI_BUTTON_CLICK, 1.7F, 0.6F);
source.getWorld().playSound(source, Sound.UI_BUTTON_CLICK, 1F, 0.6F);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L);
}

View File

@ -436,8 +436,7 @@ public class SlimefunItem {
}
public static Set<ItemHandler> getHandlers(String codeid) {
if (SlimefunPlugin.getUtilities().itemHandlers.containsKey(codeid)) return SlimefunPlugin.getUtilities().itemHandlers.get(codeid);
else return new HashSet<>();
return SlimefunPlugin.getUtilities().itemHandlers.getOrDefault(codeid, new HashSet<>());
}
public static void setRadioactive(ItemStack item) {

View File

@ -45,7 +45,7 @@ public class InfusedHopper extends SimpleSlimefunItem<BlockTicker> {
}
if (sound) {
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 5F, 2F);
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F);
}
}

View File

@ -18,7 +18,7 @@ public class MagnetTask extends SlimefunTask {
for (Entity item: Bukkit.getPlayer(uuid).getNearbyEntities(6D, 6D, 6D)) {
if (item instanceof Item && !item.hasMetadata("no_pickup") && ((Item) item).getPickupDelay() <= 0) {
item.teleport(Bukkit.getPlayer(uuid).getEyeLocation());
Bukkit.getPlayer(uuid).getWorld().playSound(Bukkit.getPlayer(uuid).getEyeLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 5L, 2L);
Bukkit.getPlayer(uuid).getWorld().playSound(Bukkit.getPlayer(uuid).getEyeLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F);
}
}
}

View File

@ -110,7 +110,7 @@ public class RitualAnimation implements Runnable {
else {
particles.add(pedestal.getLocation().add(0.5, 1.5, 0.5));
items.add(AncientAltarListener.fixItemStack(item.getItemStack(), item.getCustomName()));
pedestal.getWorld().playSound(pedestal.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 5F, 2F);
pedestal.getWorld().playSound(pedestal.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F);
try {
l.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE,pedestal.getLocation().add(0.5, 1.5, 0.5),16, 0.3F, 0.2F, 0.3F);
@ -132,7 +132,7 @@ public class RitualAnimation implements Runnable {
// This should re-enable altar blocks on craft failure.
utilities.altarinuse.remove(altar.getLocation());
l.getWorld().playSound(l, Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 5F, 1F);
l.getWorld().playSound(l, Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1F, 1F);
itemLock.clear();
altars.remove(altar);
}

View File

@ -45,7 +45,7 @@ public class BlockInfoConfig extends Config {
private void checkPath(String path) {
if (path.contains(".")) {
if (path.indexOf('.') != -1) {
throw new UnsupportedOperationException("BlockInfoConfig only supports Map<String,String> (path: " + path + ")");
}
}

View File

@ -526,7 +526,7 @@ public class BlockStorage {
}
private static void refreshCache(BlockStorage storage, Location l, String key, String value, boolean updateTicker) {
Config cfg = storage.blocksCache.containsKey(key) ? storage.blocksCache.get(key): new Config(path_blocks + l.getWorld().getName() + '/' + key + ".sfb");
Config cfg = storage.blocksCache.getOrDefault(key, new Config(path_blocks + l.getWorld().getName() + '/' + key + ".sfb"));
cfg.setValue(serializeLocation(l), value);
storage.blocksCache.put(key, cfg);
@ -540,7 +540,7 @@ public class BlockStorage {
locations.add(l);
SlimefunPlugin.getUtilities().tickingChunks.put(chunkString, locations);
if (!SlimefunPlugin.getUtilities().loadedTickers.contains(chunkString)) SlimefunPlugin.getUtilities().loadedTickers.add(chunkString);
SlimefunPlugin.getUtilities().loadedTickers.add(chunkString);
}
}
}

View File

@ -26,23 +26,23 @@ public class TickerTask implements Runnable {
private boolean halted = false;
protected Map<Location, Location> move = new HashMap<>();
protected Map<Location, Boolean> delete = new HashMap<>();
protected Map<Location, Long> blockTimings = new HashMap<>();
protected final Map<Location, Location> move = new HashMap<>();
protected final Map<Location, Boolean> delete = new HashMap<>();
private final Map<Location, Long> blockTimings = new HashMap<>();
private Set<BlockTicker> tickers = new HashSet<>();
private final Set<BlockTicker> tickers = new HashSet<>();
private int skipped = 0;
private int chunks = 0;
private int machines = 0;
private long time = 0;
private Map<String, Integer> chunkItemCount = new HashMap<>();
private Map<String, Integer> machineCount = new HashMap<>();
private Map<String, Long> machineTimings = new HashMap<>();
private Map<String, Long> chunkTimings = new HashMap<>();
private Set<String> chunksSkipped = new HashSet<>();
private Map<Location, Integer> buggedBlocks = new HashMap<>();
private final Map<String, Integer> chunkItemCount = new HashMap<>();
private final Map<String, Integer> machineCount = new HashMap<>();
private final Map<String, Long> machineTimings = new HashMap<>();
private final Map<String, Long> chunkTimings = new HashMap<>();
private final Set<String> chunksSkipped = new HashSet<>();
private final Map<Location, Integer> buggedBlocks = new HashMap<>();
private boolean running = false;
@ -109,29 +109,8 @@ public class TickerTask implements Runnable {
machineCount.put(item.getID(), (machine != null ? machine: 0) + 1);
blockTimings.put(l, System.currentTimeMillis() - timestamp3);
} catch (Exception x) {
int errors = 0;
if (bugged.containsKey(l)) errors = bugged.get(l);
errors++;
if (errors == 1) {
// Generate a new Error-Report
new ErrorReport(x, this, l, item);
buggedBlocks.put(l, errors);
}
else if (errors == 4) {
Slimefun.getLogger().log(Level.SEVERE, "X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + '(' + item.getID() + ")");
Slimefun.getLogger().log(Level.SEVERE, "has thrown 4 Exceptions in the last 4 Ticks, the Block has been terminated.");
Slimefun.getLogger().log(Level.SEVERE, "Check your /plugins/Slimefun/error-reports/ folder for details.");
Slimefun.getLogger().log(Level.SEVERE, " ");
BlockStorage._integrated_removeBlockInfo(l, true);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> l.getBlock().setType(Material.AIR));
}
else {
buggedBlocks.put(l, errors);
}
int errors = bugged.getOrDefault(l, 0);
reportErrors(l, item, x, errors);
}
});
}
@ -139,35 +118,15 @@ public class TickerTask implements Runnable {
long timestamp3 = System.currentTimeMillis();
item.getBlockTicker().tick(b, item, BlockStorage.getLocationInfo(l));
machineTimings.put(item.getID(), (machineTimings.containsKey(item.getID()) ? machineTimings.get(item.getID()): 0) + (System.currentTimeMillis() - timestamp3));
chunkItemCount.put(c, (chunkItemCount.containsKey(c) ? chunkItemCount.get(c): 0) + 1);
machineCount.put(item.getID(), (machineCount.containsKey(item.getID()) ? machineCount.get(item.getID()): 0) + 1);
machineTimings.merge(item.getID(), (System.currentTimeMillis() - timestamp3), Long::sum);
chunkItemCount.merge(c, 1, Integer::sum);
machineCount.merge(item.getID(), 1, Integer::sum);
blockTimings.put(l, System.currentTimeMillis() - timestamp3);
}
tickers.add(item.getBlockTicker());
} catch (Exception x) {
int errors = 0;
if (bugged.containsKey(l)) errors = bugged.get(l);
errors++;
if (errors == 1) {
// Generate a new Error-Report
new ErrorReport(x, this, l, item);
buggedBlocks.put(l, errors);
}
else if (errors == 4) {
Slimefun.getLogger().log(Level.SEVERE, "X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + '(' + item.getID() + ")");
Slimefun.getLogger().log(Level.SEVERE, "has thrown 4 Exceptions in the last 4 Ticks, the Block has been terminated.");
Slimefun.getLogger().log(Level.SEVERE, "Check your /plugins/Slimefun/error-reports/ folder for details.");
Slimefun.getLogger().log(Level.SEVERE, " ");
BlockStorage._integrated_removeBlockInfo(l, true);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> l.getBlock().setType(Material.AIR));
}
else {
buggedBlocks.put(l, errors);
}
int errors = bugged.getOrDefault(l, 0);
reportErrors(l, item, x, errors);
}
}
else skipped++;
@ -199,6 +158,30 @@ public class TickerTask implements Runnable {
running = false;
}
private void reportErrors(Location l, SlimefunItem item, Exception x, int errors) {
errors++;
if (errors == 1) {
// Generate a new Error-Report
new ErrorReport(x, this, l, item);
buggedBlocks.put(l, errors);
}
else if (errors == 4) {
Slimefun.getLogger().log(Level.SEVERE, "X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + '(' + item.getID() + ")");
Slimefun.getLogger().log(Level.SEVERE, "has thrown 4 Exceptions in the last 4 Ticks, the Block has been terminated.");
Slimefun.getLogger().log(Level.SEVERE, "Check your /plugins/Slimefun/error-reports/ folder for details.");
Slimefun.getLogger().log(Level.SEVERE, " ");
BlockStorage._integrated_removeBlockInfo(l, true);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> l.getBlock().setType(Material.AIR));
}
else {
buggedBlocks.put(l, errors);
}
}
public long getTime() {
return time;
}
@ -222,11 +205,11 @@ public class TickerTask implements Runnable {
for (Map.Entry<String, Integer> entry: machineCount.entrySet()) {
long timings = machineTimings.get(entry.getKey());
if (timings > 0) hover.append("\n&c" + entry.getKey() + " - " + entry.getValue()+ "x &7(" + timings + "ms)");
if (timings > 0) hover.append("\n&c").append(entry.getKey()).append(" - ").append(entry.getValue()).append("x &7(").append(timings).append("ms)");
else hidden++;
}
hover.append("\n\n&c+ &4" + hidden + " Hidden");
hover.append("\n\n&c+ &4").append(hidden).append(" Hidden");
tellraw.addHoverEvent(HoverAction.SHOW_TEXT, hover.toString());
try {
@ -258,12 +241,15 @@ public class TickerTask implements Runnable {
for (Map.Entry<String, Long> entry: chunkTimings.entrySet()) {
if (!chunksSkipped.contains(entry.getKey())) {
if (entry.getValue() > 0) hover.append("\n&c" + entry.getKey().replace("CraftChunk", "") + " - " + (chunkItemCount.containsKey(entry.getKey()) ? chunkItemCount.get(entry.getKey()): 0) + "x &7(" + entry.getValue() + "ms)");
if (entry.getValue() > 0)
hover.append("\n&c").append(entry.getKey().replace("CraftChunk", "")).append(" - ")
.append(chunkItemCount.getOrDefault(entry.getKey(), 0))
.append("x &7(").append(entry.getValue()).append("ms)");
else hidden++;
}
}
hover.append("\n\n&c+ &4" + hidden + " Hidden");
hover.append("\n\n&c+ &4").append(hidden).append(" Hidden");
tellraw.addHoverEvent(HoverAction.SHOW_TEXT, hover.toString());
try {
@ -276,7 +262,8 @@ public class TickerTask implements Runnable {
int hidden = 0;
for (Map.Entry<String, Long> entry: chunkTimings.entrySet()) {
if (!chunksSkipped.contains(entry.getKey())) {
if (entry.getValue() > 0) sender.sendMessage(" &c" + entry.getKey().replace("CraftChunk", "") + " - " + (chunkItemCount.containsKey(entry.getKey()) ? chunkItemCount.get(entry.getKey()): 0) + "x &7(" + entry.getValue() + "ms)");
if (entry.getValue() > 0) sender.sendMessage(" &c" + entry.getKey().replace("CraftChunk", "") + " - "
+ (chunkItemCount.getOrDefault(entry.getKey(), 0)) + "x &7(" + entry.getValue() + "ms)");
else hidden++;
}
}
@ -285,15 +272,15 @@ public class TickerTask implements Runnable {
}
public long getTimings(Block b) {
return blockTimings.containsKey(b.getLocation()) ? blockTimings.get(b.getLocation()): 0L;
return blockTimings.getOrDefault(b.getLocation(), 0L);
}
public long getTimings(String item) {
return machineTimings.containsKey(item) ? machineTimings.get(item): 0L;
return machineTimings.getOrDefault(item, 0L);
}
public long getTimings(Chunk c) {
return chunkTimings.containsKey(c.toString()) ? chunkTimings.get(c.toString()): 0L;
return chunkTimings.getOrDefault(c.toString(), 0L);
}
public void addBlockTimings(Location l, long time) {

View File

@ -155,30 +155,38 @@ public class CargoNet extends Network {
final Map<Integer, List<Location>> output = new HashMap<>();
Set<Location> combinedOutputNodes = outputNodes;
combinedOutputNodes.addAll(advancedOutputNodes);
for (Location outputNode: outputNodes) {
List<Location> list = new ArrayList<>();
int lastFrequency = -1;
for (Location outputNode: combinedOutputNodes) {
Integer frequency = getFrequency(outputNode);
if (!output.containsKey(frequency)) {
output.put(frequency, new ArrayList<Location>());
list.add(outputNode);
if (frequency != lastFrequency && lastFrequency != -1) {
output.merge(frequency, list, (list1, list2) -> {
list1.addAll(list2);
return list1;
});
list.clear();
}
output.get(frequency).add(outputNode);
}
for (Location outputNode: advancedOutputNodes) {
Integer frequency = getFrequency(outputNode);
if (!output.containsKey(frequency)) {
output.put(frequency, new ArrayList<Location>());
}
output.get(frequency).add(outputNode);
lastFrequency = frequency;
}
if (!list.isEmpty())
output.merge(lastFrequency, list, (list1, list2) -> {
list1.addAll(list2);
return list1;
});
//Chest Terminal Stuff
final Set<Location> providers = new HashSet<>();
final Set<Location> destinations;
if (output.containsKey(16)) {
destinations = new HashSet<>(output.get(16));
} else {
destinations = new HashSet<>();
}
final Set<Location> destinations = new HashSet<>();
List<Location> output16 = output.get(16);
if (output16 != null)
destinations.addAll(output16);
for (Location inputNode: inputNodes) {
int frequency = getFrequency(inputNode);
if (frequency == 16) {
@ -346,11 +354,7 @@ public class CargoNet extends Network {
List<Location> outputlist = new ArrayList<>(output.get(frequency));
if (roundrobin) {
if (!SlimefunPlugin.getUtilities().roundRobin.containsKey(input)) {
SlimefunPlugin.getUtilities().roundRobin.put(input, 0);
}
int cIndex = SlimefunPlugin.getUtilities().roundRobin.get(input);
int cIndex = SlimefunPlugin.getUtilities().roundRobin.getOrDefault(input, 0);
if (cIndex < outputlist.size()) {
for (int i = 0; i < cIndex; i++) {
@ -398,19 +402,7 @@ public class CargoNet extends Network {
UniversalBlockMenu menu = storage.getUniversalInventory(target);
for (int slot: menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) {
ItemStack is = menu.getItemInSlot(slot);
if (is != null && CargoManager.matchesFilter(l.getBlock(), is, -1)) {
boolean add = true;
for (StoredItem item: items) {
if (SlimefunManager.isItemSimiliar(is, item.getItem(), true)) {
add = false;
item.add(is.getAmount());
}
}
if (add) {
items.add(new StoredItem(new CustomItem(is, 1), is.getAmount()));
}
}
filter(is, items, l);
}
}
else if (storage.hasInventory(target.getLocation())) {
@ -435,40 +427,13 @@ public class CargoNet extends Network {
}
}
else {
for (int slot: menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) {
ItemStack is = menu.getItemInSlot(slot);
if (is != null && CargoManager.matchesFilter(l.getBlock(), is, -1)) {
boolean add = true;
for (StoredItem item: items) {
if (SlimefunManager.isItemSimiliar(is, item.getItem(), true)) {
add = false;
item.add(is.getAmount());
}
}
if (add) {
items.add(new StoredItem(new CustomItem(is, 1), is.getAmount()));
}
}
}
handleWithdraw(menu, items, l);
}
}
else if (target.getState() instanceof InventoryHolder) {
Inventory inv = ((InventoryHolder) target.getState()).getInventory();
for (ItemStack is: inv.getContents()) {
if (is != null && CargoManager.matchesFilter(l.getBlock(), is, -1)) {
boolean add = true;
for (StoredItem item: items) {
if (SlimefunManager.isItemSimiliar(is, item.getItem(), true)) {
add = false;
item.add(is.getAmount());
}
}
if (add) {
items.add(new StoredItem(new CustomItem(is, 1), is.getAmount()));
}
}
filter(is, items, l);
}
}
}
@ -495,17 +460,19 @@ public class CargoNet extends Network {
lore.add(ChatColor.translateAlternateColorCodes('&', "&7Stored Items: &r" + DoubleHandler.getFancyDouble(item.getAmount())));
if (stack.getMaxStackSize() > 1) lore.add(ChatColor.translateAlternateColorCodes('&', "&7<Left Click: Request 1 | Right Click: Request " + (item.getAmount() > stack.getMaxStackSize() ? stack.getMaxStackSize(): item.getAmount()) + ">"));
else lore.add(ChatColor.translateAlternateColorCodes('&', "&7<Left Click: Request 1>"));
lore.add("");
if (im.hasLore()) {
for (String line: im.getLore()) {
lore.add(line);
}
if (im.getLore() != null) {
lore.addAll(im.getLore());
}
im.setLore(lore);
stack.setItemMeta(im);
menu.replaceExistingItem(slot, stack);
menu.addMenuClickHandler(slot, (p, sl, is, action) -> {
SlimefunPlugin.getUtilities().itemRequests.add(new ItemRequest(l, 44, new CustomItem(item.getItem(), action.isRightClicked() ? (item.getAmount() > item.getItem().getMaxStackSize() ? item.getItem().getMaxStackSize(): item.getAmount()): 1), ItemTransportFlow.WITHDRAW));
int amount = item.getAmount() > item.getItem().getMaxStackSize() ? item.getItem().getMaxStackSize() : item.getAmount();
SlimefunPlugin.getUtilities().itemRequests.add(new ItemRequest(l, 44,
new CustomItem(item.getItem(), action.isRightClicked() ? amount : 1), ItemTransportFlow.WITHDRAW));
return false;
});
@ -539,4 +506,26 @@ public class CargoNet extends Network {
return freq;
}
private void handleWithdraw(BlockMenu menu, List<StoredItem> items, Location l) {
for (int slot: menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) {
ItemStack is = menu.getItemInSlot(slot);
filter(is, items, l);
}
}
private void filter(ItemStack is, List<StoredItem> items, Location l) {
if (is != null && CargoManager.matchesFilter(l.getBlock(), is, -1)) {
boolean add = true;
for (StoredItem item: items) {
if (SlimefunManager.isItemSimiliar(is, item.getItem(), true)) {
add = false;
item.add(is.getAmount());
}
}
if (add) {
items.add(new StoredItem(new CustomItem(is, 1), is.getAmount()));
}
}
}
}

View File

@ -59,7 +59,7 @@ public class ArmorListener implements Listener {
&& e.getCause() == DamageCause.FALL
) {
e.setCancelled(true);
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 2F, 2F);
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
p.setVelocity(new Vector(0.0, 0.7, 0.0));
for (Entity n: p.getNearbyEntities(4, 4, 4)) {
if (n instanceof LivingEntity && !n.getUniqueId().equals(p.getUniqueId())) {

View File

@ -57,8 +57,8 @@ public class BackpackListener implements Listener {
@EventHandler
public void onClick(InventoryClickEvent e) {
if (SlimefunPlugin.getUtilities().backpack.containsKey(e.getWhoClicked().getUniqueId())) {
ItemStack item = SlimefunPlugin.getUtilities().backpack.get(e.getWhoClicked().getUniqueId());
if (item != null) {
if (e.getClick() == ClickType.NUMBER_KEY) {
ItemStack hotbarItem = e.getWhoClicked().getInventory().getItem(e.getHotbarButton());
SlimefunItem sfItem = SlimefunItem.getByItem(hotbarItem);

View File

@ -54,8 +54,8 @@ public class ToolListener implements Listener {
sensitiveMaterials.add(Material.STONE_PRESSURE_PLATE);
sensitiveMaterials.add(Material.LIGHT_WEIGHTED_PRESSURE_PLATE);
sensitiveMaterials.add(Material.HEAVY_WEIGHTED_PRESSURE_PLATE);
Tag.SAPLINGS.getValues().forEach(sensitiveMaterials::add);
Tag.WOODEN_PRESSURE_PLATES.getValues().forEach(sensitiveMaterials::add);
sensitiveMaterials.addAll(Tag.SAPLINGS.getValues());
sensitiveMaterials.addAll(Tag.WOODEN_PRESSURE_PLATES.getValues());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -97,10 +97,8 @@ public class ToolListener implements Listener {
public void onBlockPlace(BlockPlaceEvent e) {
ItemStack item = e.getItemInHand();
if (utilities.cancelPlace.contains(e.getPlayer().getUniqueId())) {
if (utilities.cancelPlace.remove(e.getPlayer().getUniqueId()))
e.setCancelled(true);
utilities.cancelPlace.remove(e.getPlayer().getUniqueId());
}
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BASIC_CIRCUIT_BOARD, true)) e.setCancelled(true);
else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.ADVANCED_CIRCUIT_BOARD, true)) e.setCancelled(true);
@ -187,7 +185,7 @@ public class ToolListener implements Listener {
public void onBlockBreak(BlockBreakEvent e) {
boolean allow = true;
List<ItemStack> drops = new ArrayList<>();
ItemStack item = e.getPlayer().getEquipment().getItemInMainHand();
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
int fortune = 1;
Block block2 = e.getBlock().getRelative(BlockFace.UP);