mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2026-01-03 22:26:22 +00:00
improve compatibility with CraftEngine
This commit is contained in:
@@ -21,8 +21,10 @@ import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.momirealms.customcrops.api.BukkitCustomCropsPlugin;
|
||||
import net.momirealms.customcrops.api.context.Context;
|
||||
import net.momirealms.customcrops.api.context.ContextKeys;
|
||||
import net.momirealms.customcrops.api.core.ConfigManager;
|
||||
import net.momirealms.customcrops.api.misc.value.MathValue;
|
||||
import net.momirealms.customcrops.api.util.LocationUtils;
|
||||
import net.momirealms.customcrops.api.util.PluginUtils;
|
||||
import net.momirealms.customcrops.common.helper.VersionHelper;
|
||||
import net.momirealms.sparrow.heart.SparrowHeart;
|
||||
import net.momirealms.sparrow.heart.feature.entity.FakeEntity;
|
||||
@@ -58,7 +60,7 @@ public class ActionFakeItem<T> extends AbstractBuiltInAction<T> {
|
||||
super(plugin, chance);
|
||||
String itemID = section.getString("item", "");
|
||||
String[] split = itemID.split(":");
|
||||
if (split.length >= 2) itemID = split[split.length - 1];
|
||||
if (split.length >= 2 && !ConfigManager.hasNamespace()) itemID = split[split.length - 1];
|
||||
this.itemID = itemID;
|
||||
this.duration = MathValue.auto(section.get("duration", 20));
|
||||
this.other = section.getString("position", "other").equals("other");
|
||||
|
||||
@@ -57,7 +57,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class AbstractCustomEventListener implements Listener {
|
||||
|
||||
private final HashSet<EntityType> entities = new HashSet<>();
|
||||
private final HashSet<Material> blocks = new HashSet<>();
|
||||
|
||||
|
||||
@@ -485,8 +485,12 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
|
||||
return conditions.toArray(new GrowCondition[0]);
|
||||
}
|
||||
|
||||
public static boolean hasNamespace() {
|
||||
return PluginUtils.isEnabled("ItemsAdder") || PluginUtils.isEnabled("CraftEngine");
|
||||
}
|
||||
|
||||
protected void addDefaultNamespace(File file) {
|
||||
boolean hasNamespace = PluginUtils.isEnabled("ItemsAdder") || PluginUtils.isEnabled("CraftEngine");
|
||||
boolean hasNamespace = hasNamespace();
|
||||
String line;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
|
||||
|
||||
@@ -7,8 +7,8 @@ repositories {
|
||||
dependencies {
|
||||
compileOnly(project(":api"))
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("net.momirealms:craft-engine-core:0.0.34")
|
||||
compileOnly("net.momirealms:craft-engine-bukkit:0.0.34")
|
||||
compileOnly("net.momirealms:craft-engine-core:0.0.40")
|
||||
compileOnly("net.momirealms:craft-engine-bukkit:0.0.40")
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
|
||||
@@ -82,7 +82,7 @@ public class CraftEngineListener extends AbstractCustomEventListener {
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlaceCustomBlock(CustomBlockAttemptPlaceEvent event) {
|
||||
public void onPlaceCustomBlock(CustomBlockPlaceEvent event) {
|
||||
EquipmentSlot slot = event.hand() == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND;
|
||||
itemManager.handlePlayerPlace(
|
||||
event.getPlayer(),
|
||||
@@ -95,13 +95,13 @@ public class CraftEngineListener extends AbstractCustomEventListener {
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlaceFurniture(FurnitureAttemptPlaceEvent event) {
|
||||
public void onPlaceFurniture(FurniturePlaceEvent event) {
|
||||
EquipmentSlot slot = event.hand() == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND;
|
||||
Player player = event.getPlayer();
|
||||
itemManager.handlePlayerPlace(
|
||||
player,
|
||||
event.location(),
|
||||
event.furniture().id().toString(),
|
||||
event.furniture().furnitureId().toString(),
|
||||
slot,
|
||||
event.getPlayer().getInventory().getItem(slot),
|
||||
new DummyCancellable()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=3.6.32
|
||||
project_version=3.6.33
|
||||
config_version=42
|
||||
project_group=net.momirealms
|
||||
|
||||
|
||||
@@ -203,7 +203,9 @@ public class BukkitCustomCropsPluginImpl extends BukkitCustomCropsPlugin {
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
debug(() -> "Disabling worldManager");
|
||||
this.worldManager.disable();
|
||||
debug(() -> "Disabled worldManager");
|
||||
this.placeholderManager.disable();
|
||||
this.hologramManager.disable();
|
||||
this.integrationManager.disable();
|
||||
@@ -211,6 +213,8 @@ public class BukkitCustomCropsPluginImpl extends BukkitCustomCropsPlugin {
|
||||
if (!Bukkit.getServer().isStopping()) {
|
||||
this.commandManager.unregisterFeatures();
|
||||
}
|
||||
this.scheduler.shutdownScheduler();
|
||||
this.scheduler.shutdownExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -145,15 +145,20 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
plugin.debug(() -> "Saving Worlds");
|
||||
this.unload();
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
plugin.debug(() -> "Unloading " + world.getName());
|
||||
unloadWorld(world, true);
|
||||
plugin.debug(() -> "Unloaded " + world.getName());
|
||||
}
|
||||
plugin.debug(() -> "Unload adaptors");
|
||||
for (WorldAdaptor<?> adaptor : this.adaptors) {
|
||||
if (adaptor instanceof Listener listener) {
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
}
|
||||
plugin.debug(() -> "Unloaded Worlds");
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
@@ -250,9 +255,12 @@ public class BukkitWorldManager implements WorldManager, Listener {
|
||||
return false;
|
||||
}
|
||||
removedWorld.setTicking(false);
|
||||
plugin.debug(() -> "Unloading -> Saving");
|
||||
removedWorld.save(false, disabling);
|
||||
plugin.debug(() -> "Saving -> Shutdown");
|
||||
removedWorld.scheduler().shutdownScheduler();
|
||||
removedWorld.scheduler().shutdownExecutor();
|
||||
plugin.debug(() -> "Finished Shutdown");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user