Compare commits

...

3 Commits

Author SHA1 Message Date
Intelli 704f0aaf9b Update build version 2024-05-07 17:51:02 -06:00
Intelli 4daaf6cc02 Fixed lookups on legacy data not matching against legacy materials 2024-05-07 14:18:43 -06:00
Intelli 5426e69fb8 Improved hopper logging to prevent infinite attempts on failed pushes
E.g. when a hopper is repeatedly trying to push into a smoker, but no items are actually being transferred
2024-05-07 14:08:59 -06:00
8 changed files with 60 additions and 4 deletions

View File

@ -41,7 +41,7 @@ Maven
<dependency>
<groupId>net.coreprotect</groupId>
<artifactId>coreprotect</artifactId>
<version>22.2</version>
<version>22.3</version>
<scope>provided</scope>
</dependency>
```

View File

@ -7,7 +7,7 @@ plugins {
}
group = 'net.coreprotect'
String projectVersion = '22.2'
String projectVersion = '22.3'
String projectBranch = ''
version = projectVersion // `version` might be modified, we don't always want that (e.g. plugin.yml)
description = 'Provides block protection for your server.'

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.coreprotect</groupId>
<artifactId>CoreProtect</artifactId>
<version>22.2</version>
<version>22.3</version>
<properties>
<project.branch></project.branch>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -101,6 +101,7 @@ public class ConfigHandler extends Queue {
public static ConcurrentHashMap<String, List<ItemStack>> itemsSell = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, List<ItemStack>> itemsBuy = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, Object[]> hopperAbort = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, Object[]> hopperSuccess = new ConcurrentHashMap<>();
public static Map<String, List<ItemStack[]>> forceContainer = syncMap();
public static Map<String, Integer> lookupType = syncMap();
public static Map<String, Object[]> lookupThrottle = syncMap();

View File

@ -1,12 +1,16 @@
package net.coreprotect.consumer.process;
import java.sql.PreparedStatement;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import net.coreprotect.config.ConfigHandler;
@ -41,6 +45,41 @@ class ContainerTransactionProcess {
ConfigHandler.transactingChest.remove(transactingChestId);
}
}
else if (loggingChestId.startsWith("#hopper")) {
if (force_size == 0 && ConfigHandler.oldContainer.get(loggingChestId).size() == 1 && ConfigHandler.transactingChest.get(transactingChestId).isEmpty()) {
int loopCount = ConfigHandler.loggingChest.get(loggingChestId);
int maxInventorySize = (99 * 54);
try {
Inventory checkInventory = (Inventory) inventory;
maxInventorySize = checkInventory.getSize() * checkInventory.getMaxStackSize();
}
catch (Exception e) {
// use default of 5,346
}
if (loopCount > maxInventorySize) {
ItemStack[] destinationContents = null;
ItemStack movedItem = null;
String hopperPush = "#hopper-push." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
Object[] hopperPushData = ConfigHandler.hopperSuccess.remove(hopperPush);
if (hopperPushData != null) {
destinationContents = (ItemStack[]) hopperPushData[0];
movedItem = (ItemStack) hopperPushData[1];
}
if (destinationContents != null) {
Set<ItemStack> movedItems = new HashSet<>();
Object[] lastAbort = ConfigHandler.hopperAbort.get(hopperPush);
if (lastAbort != null && Arrays.equals(destinationContents, (ItemStack[]) lastAbort[1])) {
((Set<?>) lastAbort[0]).forEach(itemStack -> movedItems.add((ItemStack) itemStack));
}
movedItems.add(movedItem);
ConfigHandler.hopperAbort.put(hopperPush, new Object[] { movedItems, destinationContents });
}
}
}
}
}
inventories.remove(id);
}

View File

@ -161,6 +161,7 @@ public class ContainerLogger extends Queue {
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null) {
return;
}
boolean success = false;
int slot = 0;
for (ItemStack item : items) {
if (item != null) {
@ -190,10 +191,17 @@ public class ContainerLogger extends Queue {
int data = 0;
int amount = item.getAmount();
ContainerStatement.insert(preparedStmt, batchCount, time, userId, wid, x, y, z, typeId, data, amount, metadata, action, 0);
success = true;
}
}
slot++;
}
if (success && user.equals("#hopper")) {
String hopperPush = "#hopper-push." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
ConfigHandler.hopperSuccess.remove(hopperPush);
ConfigHandler.hopperAbort.remove(hopperPush);
}
}
catch (Exception e) {
e.printStackTrace();

View File

@ -19,7 +19,8 @@ import net.coreprotect.utility.Util;
public final class HopperPushListener {
static void processHopperPush(Location location, InventoryHolder sourceHolder, InventoryHolder destinationHolder, ItemStack item) {
String loggingChestId = "#hopper-push." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
Location destinationLocation = destinationHolder.getInventory().getLocation();
String loggingChestId = "#hopper-push." + destinationLocation.getBlockX() + "." + destinationLocation.getBlockY() + "." + destinationLocation.getBlockZ();
Object[] lastAbort = ConfigHandler.hopperAbort.get(loggingChestId);
if (lastAbort != null) {
ItemStack[] destinationContents = destinationHolder.getInventory().getContents();
@ -55,6 +56,9 @@ public final class HopperPushListener {
ConfigHandler.hopperAbort.put(loggingChestId, new Object[] { movedItems, Util.getContainerState(destinationContents) });
return;
}
else {
ConfigHandler.hopperSuccess.put(loggingChestId, new Object[] { destinationContainer, movedItem });
}
List<Object> list = ConfigHandler.transactingChest.get(location.getWorld().getUID().toString() + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ());
if (list != null) {

View File

@ -1039,6 +1039,10 @@ public class Util extends Queue {
name = BukkitAdapter.ADAPTER.parseLegacyName(name);
material = Material.getMaterial(name);
if (material == null) {
material = Material.getMaterial(name, true);
}
}
return material;