diff --git a/pom.xml b/pom.xml index 45250e5..6ec1907 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ + clean package org.apache.maven.plugins diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/RykenSlimefunCustomizer.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/RykenSlimefunCustomizer.java index c7c5507..3d2a6d4 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/RykenSlimefunCustomizer.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/RykenSlimefunCustomizer.java @@ -7,15 +7,12 @@ import java.nio.file.Paths; import java.util.Objects; import net.guizhanss.guizhanlibplugin.updater.GuizhanUpdater; -import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.plugin.java.JavaPluginLoader; -import org.bukkit.plugin.java.PluginClassLoader; 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.BlockBreak; -import org.lins.mmmjjkx.rykenslimefuncustomizer.listeners.SingleItemRecipeGuide; +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; @@ -49,8 +46,8 @@ public void onEnable() { addonManager.setup(this); - new BlockBreak(); - new SingleItemRecipeGuide(); + new BlockListener(); + new SingleItemRecipeGuideListener(); ExceptionHandler.info("RykenSlimeCustomizer加载成功!"); diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/commands/MainCommand.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/commands/MainCommand.java index 65cb5d5..7c9ba74 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/commands/MainCommand.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/commands/MainCommand.java @@ -19,7 +19,7 @@ import org.jetbrains.annotations.Nullable; import org.lins.mmmjjkx.rykenslimefuncustomizer.ProjectAddonManager; import org.lins.mmmjjkx.rykenslimefuncustomizer.RykenSlimefunCustomizer; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors.CMIChatColor; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors.CMIChatColor; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddon; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddonLoader; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.CommonUtils; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Colors/CMIChatColor.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/colors/CMIChatColor.java similarity index 99% rename from src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Colors/CMIChatColor.java rename to src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/colors/CMIChatColor.java index 337c7f7..385c649 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Colors/CMIChatColor.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/colors/CMIChatColor.java @@ -1,4 +1,4 @@ -package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors; +package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors; import java.util.*; import java.util.Map.Entry; @@ -7,7 +7,7 @@ import lombok.Getter; import org.bukkit.ChatColor; import org.bukkit.Color; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Version.Version; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.version.Version; public class CMIChatColor { diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Colors/CMIColors.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/colors/CMIColors.java similarity index 96% rename from src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Colors/CMIColors.java rename to src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/colors/CMIColors.java index 985ed65..6a70200 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Colors/CMIColors.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/colors/CMIColors.java @@ -1,4 +1,4 @@ -package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors; +package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors; import java.awt.*; import lombok.Getter; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Colors/CMICustomColors.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/colors/CMICustomColors.java similarity index 99% rename from src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Colors/CMICustomColors.java rename to src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/colors/CMICustomColors.java index 34480a9..f047601 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Colors/CMICustomColors.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/colors/CMICustomColors.java @@ -1,4 +1,4 @@ -package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors; +package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors; import lombok.Getter; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Version/MinecraftPlatform.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/version/MinecraftPlatform.java similarity index 64% rename from src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Version/MinecraftPlatform.java rename to src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/version/MinecraftPlatform.java index 3bbc5d0..add39d0 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Version/MinecraftPlatform.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/version/MinecraftPlatform.java @@ -1,4 +1,4 @@ -package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Version; +package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.version; public enum MinecraftPlatform { paper, diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Version/Version.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/version/Version.java similarity index 99% rename from src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Version/Version.java rename to src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/version/Version.java index c4386e3..b6b3c52 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/Version/Version.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/libraries/version/Version.java @@ -1,4 +1,4 @@ -package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Version; +package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.version; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/BlockBreak.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/BlockListener.java similarity index 90% rename from src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/BlockBreak.java rename to src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/BlockListener.java index 7f649e5..05feb6a 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/BlockBreak.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/BlockListener.java @@ -10,8 +10,8 @@ import org.lins.mmmjjkx.rykenslimefuncustomizer.RykenSlimefunCustomizer; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.global.DropFromBlock; -public class BlockBreak implements Listener { - public BlockBreak() { +public class BlockListener implements Listener { + public BlockListener() { Bukkit.getPluginManager().registerEvents(this, RykenSlimefunCustomizer.INSTANCE); } @@ -28,7 +28,7 @@ public void onBlockBreak(BlockBreakEvent e) { } } - private boolean matchChance(int chance) { + private static boolean matchChance(int chance) { if (chance >= 100) return true; Random rand = new Random(); diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuide.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuideListener.java similarity index 92% rename from src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuide.java rename to src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuideListener.java index 23aeab3..9605766 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuide.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/listeners/SingleItemRecipeGuideListener.java @@ -26,20 +26,21 @@ import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; import org.lins.mmmjjkx.rykenslimefuncustomizer.RykenSlimefunCustomizer; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors.CMIChatColor; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors.CMIChatColor; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.CustomMenu; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.machine.CustomRecipeMachine; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.RecipeMachineRecipe; +import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.CustomMachineRecipe; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.slimefun.AsyncChanceRecipeTask; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.CommonUtils; +import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.TimeUtils; @SuppressWarnings("deprecation") -public class SingleItemRecipeGuide implements Listener { +public class SingleItemRecipeGuideListener implements Listener { private static final NamespacedKey RECIPE_KEY = new NamespacedKey(RykenSlimefunCustomizer.INSTANCE, "rsc_recipe"); private static final NamespacedKey RECIPE_INDEX_KEY = new NamespacedKey(RykenSlimefunCustomizer.INSTANCE, "rsc_recipe_index"); - public SingleItemRecipeGuide() { + public SingleItemRecipeGuideListener() { Bukkit.getPluginManager().registerEvents(this, RykenSlimefunCustomizer.INSTANCE); } @@ -184,7 +185,7 @@ public RecipeMenu(AContainer item, Player p, int index) { } } - if (recipe instanceof RecipeMachineRecipe rmr) { + if (recipe instanceof CustomMachineRecipe rmr) { int outputSlot = outputSlots[0]; List inputs = List.of(rmr.getInput()); ItemStack[] outputs = recipe.getOutput(); @@ -233,7 +234,7 @@ public RecipeMenu(AContainer item, Player p, int index) { String rawName = "&e制作时间: &b" + seconds + "&es"; if (seconds > 60) { - rawName = rawName.concat("(" + formatSeconds(seconds) + "&e)"); + rawName = rawName.concat("(" + TimeUtils.formatSeconds(seconds) + "&e)"); } progressBar = new CustomItemStack(progressBar, rawName); @@ -256,19 +257,4 @@ private ItemStack tagOutputChance(ItemStack item, int chance) { return item; } } - - public static String formatSeconds(int seconds) { - if (seconds < 60) { - return "&b" + seconds + "&es"; - } else if (seconds > 60 && seconds < 3600) { - int m = seconds / 60; - int s = seconds % 60; - return "&b" + m + "&emin" + (s != 0 ? "&b" + s + "&es" : ""); - } else { - int h = seconds / 3600; - int m = (seconds % 3600) / 60; - int s = (seconds % 3600) % 60; - return "&b" + h + "&eh" + (m != 0 ? "&b" + m + "&emin" : "") + (s != 0 ? "&b" + s + "&es" : ""); - } - } } diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/CustomCraftingOperation.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/CustomCraftingOperation.java new file mode 100644 index 0000000..32202f8 --- /dev/null +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/CustomCraftingOperation.java @@ -0,0 +1,24 @@ +package org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs; + +import io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation; +import io.github.thebusybiscuit.slimefun4.libraries.commons.lang.Validate; +import javax.annotation.Nonnull; +import lombok.Getter; +import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.CustomMachineRecipe; + +@Getter +public class CustomCraftingOperation extends CraftingOperation { + private CustomMachineRecipe recipe; + + public CustomCraftingOperation(@Nonnull CustomMachineRecipe recipe) { + super(recipe.getInput(), recipe.getOutput(), recipe.getTicks()); + Validate.isTrue( + recipe.getTicks() >= 0, + "The amount of total ticks must be a positive integer or zero, received: " + recipe.getTicks()); + this.recipe = recipe; + } + + public int getTotalTicks() { + return recipe.getTicks(); + } +} 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 7f8f96f..724de68 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 @@ -9,7 +9,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -18,7 +17,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.lins.mmmjjkx.rykenslimefuncustomizer.bulit_in.JavaScriptEval; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors.CMIChatColor; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors.CMIChatColor; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.machine.CustomMachine; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.machine.CustomNoEnergyMachine; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.machine.CustomRecipeMachine; @@ -44,9 +43,6 @@ public class CustomMenu { @Getter private ItemStack progress; - @Setter - private InventoryBlock invb; - @Setter private boolean playerInvClickable; 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 82f2b7b..88a420f 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 @@ -56,7 +56,6 @@ public CustomGenerator( super(itemGroup, item, recipeType, recipe); if (menu != null) { - menu.setInvb(this); this.processor.setProgressBar(menu.getProgressBarItem()); createPreset(this, menu::apply); diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomMachine.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomMachine.java index 32dc06e..af56829 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomMachine.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomMachine.java @@ -61,7 +61,6 @@ public CustomMachine( this.processor = new MachineProcessor<>(this); if (menu != null) { - menu.setInvb(this); this.processor.setProgressBar(menu.getProgressBarItem()); createPreset(this, menu::apply); @@ -90,16 +89,7 @@ public void preRegister() { protected void tick(Block b, SlimefunItem item, SlimefunBlockData data) { if (eval != null) { BlockMenu blockMenu = StorageCacheUtils.getMenu(b.getLocation()); - MachineInfo info = new MachineInfo( - blockMenu, - data, - item, - b, - theRecord.totalTicks(), - theRecord.getProgress(), - processor, - theRecord, - this); + MachineInfo info = new MachineInfo(blockMenu, data, item, b, processor, null, this); eval.evalFunction("tick", info); } } 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 1256c2a..339a22f 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 @@ -11,12 +11,11 @@ import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; +import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; - -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 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 482d003..d2f2582 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 @@ -10,35 +10,32 @@ import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; import io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation; import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; -import java.util.*; - import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import java.util.*; import lombok.Getter; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.lins.mmmjjkx.rykenslimefuncustomizer.RykenSlimefunCustomizer; -import org.lins.mmmjjkx.rykenslimefuncustomizer.listeners.SingleItemRecipeGuide; +import org.lins.mmmjjkx.rykenslimefuncustomizer.listeners.SingleItemRecipeGuideListener; +import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.CustomCraftingOperation; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.CustomMenu; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.RecipeMachineRecipe; +import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.CustomMachineRecipe; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.CommonUtils; +import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.TimeUtils; public class CustomRecipeMachine extends AContainer implements RecipeDisplayItem { - private final ItemStack RECIPE_SPLITTER = - new CustomItemStack(Material.GRAY_STAINED_GLASS_PANE, "&a").setCustomModel(2200002); - private final ItemStack AIR = new ItemStack(Material.AIR); private final MachineProcessor processor; - private final List input; - private final List output; - private final List raw_recipes; - private final List recipes; + private final int[] input; + private final int[] output; + private final List raw_recipes; + private final List recipes; private final int energyPerCraft; private final int capacity; @@ -50,16 +47,14 @@ public class CustomRecipeMachine extends AContainer implements RecipeDisplayItem @Getter @Nullable private final CustomMenu menu; - private final Map currentRecipe = new HashMap<>(); - public CustomRecipeMachine( ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, - List input, - List output, - List recipes, + int[] input, + int[] output, + List recipes, int energyPerCraft, int capacity, @Nullable CustomMenu menu, @@ -81,7 +76,6 @@ public CustomRecipeMachine( } if (menu != null) { - menu.setInvb(this); this.processor.setProgressBar(menu.getProgressBarItem()); createPreset(this, menu::apply); @@ -142,14 +136,14 @@ public ItemStack getProgressBar() { List displayRecipes = new ArrayList<>(); int i = 0; - for (RecipeMachineRecipe recipe : raw_recipes) { + for (CustomMachineRecipe recipe : raw_recipes) { ItemStack[] input = recipe.getInput(); ItemStack[] output = recipe.getOutput(); if (input.length == 1) { displayRecipes.add(input[0]); } else { - ItemStack in = SingleItemRecipeGuide.tagItemRecipe(RECIPE_INPUT, i); + ItemStack in = SingleItemRecipeGuideListener.tagItemRecipe(RECIPE_INPUT, i); displayRecipes.add(in); } @@ -158,12 +152,12 @@ public ItemStack getProgressBar() { ItemStack out = output[0].clone(); String rawLore = "&e制作时间: &b" + seconds + "&es"; if (seconds > 60) { - rawLore = rawLore.concat("(" + SingleItemRecipeGuide.formatSeconds(seconds) + "&e)"); + rawLore = rawLore.concat("(" + TimeUtils.formatSeconds(seconds) + "&e)"); } CommonUtils.addLore(out, true, rawLore); displayRecipes.add(out); } else { - ItemStack out = SingleItemRecipeGuide.tagItemRecipe(RECIPE_OUTPUT, i); + ItemStack out = SingleItemRecipeGuideListener.tagItemRecipe(RECIPE_OUTPUT, i); displayRecipes.add(out); } @@ -175,12 +169,12 @@ public ItemStack getProgressBar() { @Override public int[] getInputSlots() { - return input.stream().mapToInt(i -> i).toArray(); + return input; } @Override public int[] getOutputSlots() { - return output.stream().mapToInt(i -> i).toArray(); + return output; } @Override @@ -199,7 +193,7 @@ protected void constructMenu(BlockMenuPreset preset) {} @Override protected void tick(Block b) { BlockMenu inv = StorageCacheUtils.getMenu(b.getLocation()); - CraftingOperation currentOperation = this.processor.getOperation(b); + CustomCraftingOperation currentOperation = (CustomCraftingOperation) this.processor.getOperation(b); int progressSlot = this.menu == null || this.menu.getProgressSlot() == -1 ? 22 : this.menu.getProgressSlot(); if (inv != null) { if (currentOperation != null) { @@ -208,9 +202,10 @@ protected void tick(Block b) { this.processor.updateProgressBar(inv, progressSlot, currentOperation); currentOperation.addProgress(1); } else { - RecipeMachineRecipe currentRecipe = this.currentRecipe.get(b.getLocation()); + CustomMachineRecipe currentRecipe = currentOperation.getRecipe(); if (currentRecipe != null) { - ItemStack[] outputs = currentRecipe.getMatchChanceResult().toArray(new ItemStack[]{}); + ItemStack[] outputs = + currentRecipe.getMatchChanceResult().toArray(ItemStack[]::new); if (!currentRecipe.isChooseOneIfHas()) { for (ItemStack o : outputs) { @@ -233,20 +228,19 @@ protected void tick(Block b) { if (this.menu == null) { progress = ChestMenuUtils.getBackground(); } else { - progress = this.menu.getSlotMap().getOrDefault(progressSlot, ChestMenuUtils.getBackground()); + progress = + this.menu.getSlotMap().getOrDefault(progressSlot, ChestMenuUtils.getBackground()); } inv.replaceExistingItem(progressSlot, progress); - this.currentRecipe.remove(b.getLocation()); this.processor.endOperation(b); } } } else { MachineRecipe next = this.findNextRecipe(inv); if (next != null) { - RecipeMachineRecipe currentRecipe = (RecipeMachineRecipe) next; - currentOperation = new CraftingOperation(currentRecipe); - this.currentRecipe.put(b.getLocation(), currentRecipe); + CustomMachineRecipe currentRecipe = (CustomMachineRecipe) next; + currentOperation = new CustomCraftingOperation(currentRecipe); this.processor.startOperation(b, currentOperation); this.processor.updateProgressBar(inv, progressSlot, currentOperation); } diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomTemplateMachine.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomTemplateMachine.java index 2f51e73..e8d3ab6 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomTemplateMachine.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/customs/machine/CustomTemplateMachine.java @@ -19,8 +19,8 @@ import org.jetbrains.annotations.NotNull; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.CustomMenu; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.parent.AbstractEmptyMachine; +import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.CustomMachineRecipe; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.MachineTemplate; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.RecipeMachineRecipe; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.CommonUtils; public class CustomTemplateMachine extends AbstractEmptyMachine implements RecipeDisplayItem { @@ -97,16 +97,16 @@ protected void tick(Block b, SlimefunItem item, SlimefunBlockData data) { ItemStack templateItem = m.getItemInSlot(templateSlot); MachineTemplate template = CommonUtils.getIf(templates, t -> t.isSimilar(templateItem)); if (template != null) { - RecipeMachineRecipe recipe = findRecipe(template, m); + CustomMachineRecipe recipe = findRecipe(template, m); } } } - private RecipeMachineRecipe findRecipe(MachineTemplate currentTemplate, BlockMenu menu) { + private CustomMachineRecipe findRecipe(MachineTemplate currentTemplate, BlockMenu menu) { // TODO: Implement recipe finding // 需要等待 https://github.com/Slimefun/Slimefun4/pull/4177 被合并 - RecipeMachineRecipe recipe = currentTemplate.recipes().get(0).getFirstValue(); + CustomMachineRecipe recipe = currentTemplate.recipes().get(0).getFirstValue(); int cost = currentTemplate.recipes().stream() .filter(k -> Objects.equals(k.getFirstValue(), recipe)) diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/global/XMaterial.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/global/XMaterial.java index 8d53ca5..b805d1d 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/global/XMaterial.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/global/XMaterial.java @@ -184,7 +184,7 @@ public enum XMaterial { BLACKSTONE_WALL, BLACK_BANNER("STANDING_BANNER", "BANNER"), /** - * Version 1.12+ interprets "BED" as BLACK_BED due to enum alphabetic ordering. + * version 1.12+ interprets "BED" as BLACK_BED due to enum alphabetic ordering. */ BLACK_BED(supports(12) ? 15 : 0, "BED_BLOCK", "BED"), BLACK_CANDLE, diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/RecipeMachineRecipe.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/CustomMachineRecipe.java similarity index 94% rename from src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/RecipeMachineRecipe.java rename to src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/CustomMachineRecipe.java index 80d05c2..34d35d9 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/RecipeMachineRecipe.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/CustomMachineRecipe.java @@ -7,7 +7,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import org.bukkit.inventory.ItemStack; -public class RecipeMachineRecipe extends MachineRecipe { +public class CustomMachineRecipe extends MachineRecipe { @Getter private final List chances; @@ -19,7 +19,7 @@ public class RecipeMachineRecipe extends MachineRecipe { private final Random RNG = new Random(); - public RecipeMachineRecipe( + public CustomMachineRecipe( int seconds, ItemStack[] input, ItemStack[] output, diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineInfo.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineInfo.java index bf3c713..e4179d8 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineInfo.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineInfo.java @@ -15,8 +15,6 @@ public record MachineInfo( SlimefunBlockData data, SlimefunItem machineItem, Block block, - int totalTicks, - int progress, MachineProcessor processor, MachineOperation operation, CustomMachine machine) { diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineRecord.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineRecord.java index 928547d..c1ad95e 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineRecord.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineRecord.java @@ -1,26 +1,3 @@ package org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; - -public record MachineRecord(int capacity, int totalTicks) implements MachineOperation { - private static int progress = 0; - - @Override - public void addProgress(int i) { - if (progress >= totalTicks) { - progress = i; - return; - } - progress += i; - } - - @Override - public int getProgress() { - return progress; - } - - @Override - public int getTotalTicks() { - return totalTicks; - } -} +public record MachineRecord(int capacity) {} diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineTemplate.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineTemplate.java index de70ca4..7b11737 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineTemplate.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/machine/MachineTemplate.java @@ -1,12 +1,11 @@ package org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine; import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair; -import java.util.List; - import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import java.util.List; import org.bukkit.inventory.ItemStack; -public record MachineTemplate(ItemStack item, int cost, List> recipes) { +public record MachineTemplate(ItemStack item, int cost, List> recipes) { public boolean isSimilar(ItemStack item) { return SlimefunUtils.isItemSimilar(item, this.item, true); } diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/script/parent/ScriptEval.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/script/parent/ScriptEval.java index a57f8ca..5762542 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/script/parent/ScriptEval.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/script/parent/ScriptEval.java @@ -28,7 +28,7 @@ import org.bukkit.inventory.ItemStack; import org.graalvm.polyglot.HostAccess; import org.jetbrains.annotations.Nullable; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors.CMIChatColor; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors.CMIChatColor; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddon; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.script.enhanced.NBTAPIIntegration; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.script.lambda.CiConsumer; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/slimefun/ItemGroupButton.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/slimefun/ItemGroupButton.java index 2cf426f..ef424ab 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/slimefun/ItemGroupButton.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/slimefun/ItemGroupButton.java @@ -11,7 +11,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Nullable; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors.CMIChatColor; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors.CMIChatColor; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.script.ban.CommandSafe; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.ExceptionHandler; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/ResearchReader.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/ResearchReader.java index 455d34c..0e53f1f 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/ResearchReader.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/ResearchReader.java @@ -9,7 +9,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.lins.mmmjjkx.rykenslimefuncustomizer.RykenSlimefunCustomizer; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors.CMIChatColor; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors.CMIChatColor; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddon; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.ExceptionHandler; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/item/GeoResourceReader.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/item/GeoResourceReader.java index f23619a..7191e2c 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/item/GeoResourceReader.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/item/GeoResourceReader.java @@ -179,14 +179,12 @@ public int getMaxDeviation() { return maxDeviation; } - @NotNull - @Override + @NotNull @Override public String getName() { return name; } - @NotNull - @Override + @NotNull @Override public ItemStack getItem() { return item; } diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/item/ItemReader.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/item/ItemReader.java index 4586dc5..4be78f5 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/item/ItemReader.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/item/ItemReader.java @@ -22,7 +22,7 @@ import org.bukkit.inventory.ItemStack; import org.lins.mmmjjkx.rykenslimefuncustomizer.RykenSlimefunCustomizer; import org.lins.mmmjjkx.rykenslimefuncustomizer.bulit_in.JavaScriptEval; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors.CMIChatColor; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors.CMIChatColor; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddon; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.item.CustomDefaultItem; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.item.CustomUnplaceableItem; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/MachineReader.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/MachineReader.java index 6bdb533..c502450 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/MachineReader.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/MachineReader.java @@ -103,23 +103,7 @@ public AbstractEmptyMachine readEach(String s) { -1); return machine; } - int totalTicks = energySettings.getInt("totalTicks"); - if (totalTicks < 1) { - ExceptionHandler.handleError( - "无法读取在附属" + addon.getAddonId() + "中的机器" + s + "的能源设置,已转为无电机器,原因: 总粘液刻不能小于1"); - machine = new CustomNoEnergyMachine( - group.getSecondValue(), - slimefunItemStack, - rt.getSecondValue(), - recipe, - menu, - input, - output, - eval, - -1); - return machine; - } - MachineRecord record = new MachineRecord(capacity, totalTicks); + MachineRecord record = new MachineRecord(capacity); String encType = energySettings.getString("type"); Pair enc = ExceptionHandler.handleEnumValueOf( "无法读取在附属" + addon.getAddonId() + "中的机器" + s + "的能源设置,已转为无电机器,原因: 错误的能源网络组件类型" + encType, @@ -169,10 +153,6 @@ public AbstractEmptyMachine readEach(String s) { workSlots); } - if (menu != null) { - menu.setInvb(machine); - } - machine.register(RykenSlimefunCustomizer.INSTANCE); return machine; } diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/MaterialGeneratorReader.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/MaterialGeneratorReader.java index 103b4d5..3f32247 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/MaterialGeneratorReader.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/MaterialGeneratorReader.java @@ -104,7 +104,6 @@ public CustomMaterialGenerator readEach(String s) { menu, per); - menu.setInvb(cmg); menu.addMenuClickHandler(status, ChestMenuUtils.getEmptyClickHandler()); return cmg; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/RecipeMachineReader.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/RecipeMachineReader.java index ad6b060..ad010e7 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/RecipeMachineReader.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/objects/yaml/machine/RecipeMachineReader.java @@ -12,7 +12,7 @@ import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddon; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.CustomMenu; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.machine.CustomRecipeMachine; -import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.RecipeMachineRecipe; +import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.machine.CustomMachineRecipe; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.yaml.YamlReader; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.CommonUtils; import org.lins.mmmjjkx.rykenslimefuncustomizer.utils.ExceptionHandler; @@ -36,8 +36,8 @@ public CustomRecipeMachine readEach(String s) { Pair group = ExceptionHandler.handleItemGroupGet(addon, igId); if (group.getFirstValue() == ExceptionHandler.HandleResult.FAILED) return null; - SlimefunItemStack sfis = getPreloadItem(id); - if (sfis == null) return null; + SlimefunItemStack slimefunItemStack = getPreloadItem(id); + if (slimefunItemStack == null) return null; ItemStack[] recipe = CommonUtils.readRecipe(section.getConfigurationSection("recipe"), addon); String recipeType = section.getString("recipe_type", "NULL"); @@ -86,15 +86,15 @@ public CustomRecipeMachine readEach(String s) { return null; } - List mr = readRecipes(s, input.size(), output.size(), recipes, addon); + List mr = readRecipes(s, input.size(), output.size(), recipes, addon); return new CustomRecipeMachine( group.getSecondValue(), - sfis, + slimefunItemStack, rt.getSecondValue(), recipe, - input, - output, + input.stream().mapToInt(x -> x).toArray(), + output.stream().mapToInt(x -> x).toArray(), mr, energy, capacity, @@ -119,9 +119,9 @@ public List preloadItems(String s) { return List.of(new SlimefunItemStack(id, stack)); } - private List readRecipes( + private List readRecipes( String s, int inputSize, int outputSize, ConfigurationSection section, ProjectAddon addon) { - List list = new ArrayList<>(); + List list = new ArrayList<>(); if (section == null) { return list; } @@ -182,7 +182,7 @@ private List readRecipes( input = removeNulls(input); output = removeNulls(output); - list.add(new RecipeMachineRecipe(seconds, input, output, chances, chooseOne, forDisplay)); + list.add(new CustomMachineRecipe(seconds, input, output, chances, chooseOne, forDisplay)); } return list; } diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/CommonUtils.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/CommonUtils.java index 93452fb..95251ff 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/CommonUtils.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/CommonUtils.java @@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.lins.mmmjjkx.rykenslimefuncustomizer.RykenSlimefunCustomizer; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors.CMIChatColor; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors.CMIChatColor; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddon; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.item.RSCItemStack; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.global.XMaterial; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/ExceptionHandler.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/ExceptionHandler.java index 33db078..8a280d3 100644 --- a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/ExceptionHandler.java +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/ExceptionHandler.java @@ -10,7 +10,7 @@ import org.bukkit.command.ConsoleCommandSender; import org.jetbrains.annotations.NotNull; import org.lins.mmmjjkx.rykenslimefuncustomizer.RykenSlimefunCustomizer; -import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors.CMIChatColor; +import org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors.CMIChatColor; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.ProjectAddon; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.customs.CustomMenu; import org.lins.mmmjjkx.rykenslimefuncustomizer.objects.global.RecipeTypeMap; diff --git a/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/TimeUtils.java b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/TimeUtils.java new file mode 100644 index 0000000..c2ac599 --- /dev/null +++ b/src/main/java/org/lins/mmmjjkx/rykenslimefuncustomizer/utils/TimeUtils.java @@ -0,0 +1,18 @@ +package org.lins.mmmjjkx.rykenslimefuncustomizer.utils; + +public class TimeUtils { + public static String formatSeconds(int seconds) { + if (seconds < 60) { + return "&b" + seconds + "&es"; + } else if (seconds > 60 && seconds < 3600) { + int m = seconds / 60; + int s = seconds % 60; + return "&b" + m + "&emin" + (s != 0 ? "&b" + s + "&es" : ""); + } else { + int h = seconds / 3600; + int m = (seconds % 3600) / 60; + int s = (seconds % 3600) % 60; + return "&b" + h + "&eh" + (m != 0 ? "&b" + m + "&emin" : "") + (s != 0 ? "&b" + s + "&es" : ""); + } + } +}