diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/RykenSlimefunCustomizer.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/RykenSlimefunCustomizer.java index 3d2a6d4..49f0fc9 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/RykenSlimefunCustomizer.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/RykenSlimefunCustomizer.java @@ -9,11 +9,9 @@ import net.guizhanss.guizhanlibplugin.updater.GuizhanUpdater; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; -import org.lins.mmmjjkx.rykenslimefuncustomizer.bulit_in.JavaScriptCreator; import org.lins.mmmjjkx.rykenslimefuncustomizer.commands.MainCommand; import org.lins.mmmjjkx.rykenslimefuncustomizer.listeners.BlockListener; import org.lins.mmmjjkx.rykenslimefuncustomizer.listeners.SingleItemRecipeGuideListener; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.global.ScriptCreators; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.CommonUtils; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.ExceptionHandler; @@ -23,11 +21,6 @@ public final class RykenSlimefunCustomizer extends JavaPlugin implements Slimefu public static RykenSlimefunCustomizer INSTANCE; public static ProjectAddonManager addonManager; - @Override - public void onLoad() { - ScriptCreators.pushScriptCreator(new JavaScriptCreator()); - } - @Override public void onEnable() { // Plugin startup logic diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/bulit_in/JavaScriptCreator.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/bulit_in/JavaScriptCreator.java deleted file mode 100644 index 3f18279..0000000 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/bulit_in/JavaScriptCreator.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.lins.mmmjjkx.rykenslimefuncustomizer.bulit_in; - -import java.io.File; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddon; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.script.parent.ScriptCreator; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.script.parent.ScriptEval; - -public final class JavaScriptCreator implements ScriptCreator { - @Override - public String scriptKey() { - return "script"; - } - - @Override - public String getFileName(String name) { - return name + ".js"; - } - - @Override - public ScriptEval createScript(File file, ProjectAddon addon) { - return new JavaScriptEval(file, addon); - } -} diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/bulit_in/JavaScriptEval.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/bulit_in/JavaScriptEval.java index 1db5b07..7172121 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/bulit_in/JavaScriptEval.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/bulit_in/JavaScriptEval.java @@ -13,7 +13,6 @@ import java.io.IOException; import java.util.logging.FileHandler; import javax.script.ScriptException; - import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotAccess; import org.graalvm.polyglot.io.IOAccess; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuideListener.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuideListener.java index 9605766..357258f 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuideListener.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuideListener.java @@ -247,7 +247,7 @@ public void open(Player... players) { super.open(players); if (!recipeTask.isEmpty()) { - recipeTask.start(getInventory()); + recipeTask.start(toInventory()); } } diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/CustomMenu.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/CustomMenu.java index 724de68..12eefd6 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/CustomMenu.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/CustomMenu.java @@ -25,9 +25,6 @@ @SuppressWarnings("deprecation") public class CustomMenu { - @Getter - private final Map slotMap; - @Getter private final JavaScriptEval eval; @@ -52,11 +49,12 @@ public class CustomMenu { @Setter private ChestMenu.MenuCloseHandler menuCloseHandler = p -> {}; + @Getter private final Map items; + private final Map clickHandlers; public CustomMenu(String id, String title, CustomMenu menu) { - this.slotMap = menu.slotMap; this.eval = menu.eval; this.title = CMIChatColor.translate(title); this.id = id; @@ -109,13 +107,12 @@ public CustomMenu( this.id = id; this.title = CMIChatColor.translate(title); - this.slotMap = mi; this.eval = eval; this.progress = progressBar != null ? progressBar.clone() : mi.get(progress); this.progressSlot = progress; this.playerInvClickable = playerInvClickable; - this.items = new HashMap<>(); + this.items = mi; this.clickHandlers = new HashMap<>(); if (eval != null) { @@ -123,7 +120,7 @@ public CustomMenu( } for (int i = 0; i < 54; i++) { - ItemStack item = slotMap.get(i); + ItemStack item = items.get(i); if (item != null) { addItem(i, item, (RSCClickHandler) (p, slot, is, ca) -> { if (eval != null) { @@ -139,12 +136,12 @@ public CustomMenu( } } - private void addItem(int i, ItemStack item, ChestMenu.MenuClickHandler onClick) { + public void addItem(int i, ItemStack item, ChestMenu.MenuClickHandler onClick) { items.put(i, item); clickHandlers.put(i, onClick); } - private void addItem(int i, ItemStack item) { + public void addItem(int i, ItemStack item) { items.put(i, item); } diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomGenerator.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomGenerator.java index 88a420f..602bbd7 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomGenerator.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomGenerator.java @@ -117,7 +117,7 @@ public int getGeneratedOutput(@NotNull Location l, @NotNull SlimefunBlockData da if (menu == null) { progress = ChestMenuUtils.getBackground(); } else { - progress = menu.getSlotMap().getOrDefault(progressSlot, ChestMenuUtils.getBackground()); + progress = menu.getItems().getOrDefault(progressSlot, ChestMenuUtils.getBackground()); } inv.replaceExistingItem(progressSlot, progress); diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomMaterialGenerator.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomMaterialGenerator.java index 339a22f..7b64a5f 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomMaterialGenerator.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomMaterialGenerator.java @@ -68,8 +68,7 @@ public void onBlockBreak(@NotNull Block block) { } }); - menu.getSlotMap().put(statusSlot, ChestMenuUtils.getBackground()); - menu.addMenuClickHandler(statusSlot, (player, slot, i, clickType) -> false); + menu.addItem(statusSlot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); createPreset(this, menu::apply); diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomRecipeMachine.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomRecipeMachine.java index d2f2582..8ed6714 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomRecipeMachine.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomRecipeMachine.java @@ -228,8 +228,7 @@ protected void tick(Block b) { if (this.menu == null) { progress = ChestMenuUtils.getBackground(); } else { - progress = - this.menu.getSlotMap().getOrDefault(progressSlot, ChestMenuUtils.getBackground()); + progress = this.menu.getItems().getOrDefault(progressSlot, ChestMenuUtils.getBackground()); } inv.replaceExistingItem(progressSlot, progress); diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/global/ScriptCreators.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/global/ScriptCreators.java deleted file mode 100644 index 208c17b..0000000 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/global/ScriptCreators.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.lins.mmmjjkx.rykenslimefuncustomizer.objects.global; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import org.jetbrains.annotations.Nullable; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.script.parent.ScriptCreator; - -public class ScriptCreators { - private static final Map scriptCreators; - - static { - scriptCreators = new HashMap<>(); - } - - public static void pushScriptCreator(ScriptCreator scriptCreator) { - scriptCreators.put(scriptCreator.scriptKey().toUpperCase(), scriptCreator); - } - - public static void clearScriptCreators() { - scriptCreators.clear(); - } - - public static Set scriptKeys() { - return scriptCreators.keySet(); - } - - @Nullable public static ScriptCreator getScriptCreator(String s) { - return scriptCreators.get(s); - } -} diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/script/parent/ScriptCreator.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/script/parent/ScriptCreator.java deleted file mode 100644 index a1cb246..0000000 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/script/parent/ScriptCreator.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.lins.mmmjjkx.rykenslimefuncustomizer.objects.script.parent; - -import java.io.File; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddon; - -public interface ScriptCreator { - String scriptKey(); - - String getFileName(String name); - - ScriptEval createScript(File file, ProjectAddon addon); -} diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/GeneratorReader.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/GeneratorReader.java index 9086b7c..8e3e313 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/GeneratorReader.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/GeneratorReader.java @@ -6,7 +6,6 @@ import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; import java.util.ArrayList; import java.util.List; - import lombok.SneakyThrows; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; import org.bukkit.configuration.ConfigurationSection;