9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-25 09:59:20 +00:00
This commit is contained in:
XiaoMoMi
2024-10-03 21:38:40 +08:00
parent b189020679
commit 99aa349565
11 changed files with 268 additions and 39 deletions

View File

@@ -223,6 +223,7 @@ public class BukkitCustomCropsPluginImpl extends BukkitCustomCropsPlugin {
this.coolDownManager.reload();
this.translationManager.reload();
this.hologramManager.reload();
this.itemManager.reload();
this.actionManagers.values().forEach(Reloadable::reload);
this.requirementManagers.values().forEach(Reloadable::reload);

View File

@@ -196,7 +196,7 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor<World> {
if (parentDir != null && !parentDir.exists()) {
parentDir.mkdirs();
}
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
try (FileOutputStream fos = new FileOutputStream(file); BufferedOutputStream bos = new BufferedOutputStream(fos)) {
bos.write(serializeRegion(region));
long time2 = System.currentTimeMillis();
BukkitCustomCropsPlugin.getInstance().debug(() -> "[" + world.worldName() + "] Took " + (time2-time1) + "ms to save region " + region.regionPos());

View File

@@ -328,7 +328,9 @@ public class BukkitItemManager extends AbstractItemManager {
if (itemStack == null || itemStack.getType() == Material.AIR) return "AIR";
String id = provider.itemID(itemStack);
if (id != null) return id;
plugin.debug(() -> "Start checking ID from external plugins");
for (ItemProvider p : itemDetectArray) {
plugin.debug(p::identifier);
id = p.itemID(itemStack);
if (id != null) return p.identifier() + ":" + id;
}
@@ -458,6 +460,8 @@ public class BukkitItemManager extends AbstractItemManager {
}
private void handleInteractEvent(String blockID, WrappedInteractEvent wrapped) {
plugin.debug(() -> "Player [" + wrapped.player().getName() + "] interacted [" + blockID + "] with [" + wrapped.itemID() + "] at " + wrapped.location());
CustomCropsItem customCropsItem = Registries.ITEMS.get(wrapped.itemID());
if (customCropsItem != null) {
InteractionResult result = customCropsItem.interactAt(wrapped);

View File

@@ -134,6 +134,12 @@ public class BukkitWorldManager implements WorldManager, Listener {
}
}
@Override
public void unload() {
HandlerList.unregisterAll(this);
this.worldSettings.clear();
}
private void loadConfig() {
YamlDocument config = BukkitConfigManager.getMainConfig();
@@ -170,12 +176,6 @@ public class BukkitWorldManager implements WorldManager, Listener {
}
}
@Override
public void unload() {
HandlerList.unregisterAll(this);
this.worldSettings.clear();
}
@Override
public void disable() {
this.unload();