mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Merge pull request #1152 from WalshyDev/performance-improvements
Some performance improvements
This commit is contained in:
commit
561445768d
@ -36,14 +36,11 @@ 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);
|
||||
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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 + ")");
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<>();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -100,29 +100,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);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -130,35 +109,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++;
|
||||
@ -189,6 +148,30 @@ public class TickerTask implements Runnable {
|
||||
time = System.currentTimeMillis() - timestamp;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -212,11 +195,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 {
|
||||
@ -248,12 +231,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 {
|
||||
@ -266,7 +252,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++;
|
||||
}
|
||||
}
|
||||
@ -275,15 +262,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) {
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user