Skip to content

Commit

Permalink
Merge pull request #34 from JWJUN233233/main
Browse files Browse the repository at this point in the history
移除energy.totalTicks
  • Loading branch information
lijinhong11 authored Jun 12, 2024
2 parents c9160c6 + 3f5be78 commit d170c7e
Show file tree
Hide file tree
Showing 33 changed files with 122 additions and 167 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</properties>

<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,8 +46,8 @@ public void onEnable() {

addonManager.setup(this);

new BlockBreak();
new SingleItemRecipeGuide();
new BlockListener();
new SingleItemRecipeGuideListener();

ExceptionHandler.info("RykenSlimeCustomizer加载成功!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors;
package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors;

import java.awt.*;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Colors;
package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.colors;

import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.Version;
package org.lins.mmmjjkx.rykenslimefuncustomizer.libraries.version;

public enum MinecraftPlatform {
paper,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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<ItemStack> inputs = List.of(rmr.getInput());
ItemStack[] outputs = recipe.getOutput();
Expand Down Expand Up @@ -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);
Expand All @@ -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" : "");
}
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -44,9 +43,6 @@ public class CustomMenu {
@Getter
private ItemStack progress;

@Setter
private InventoryBlock invb;

@Setter
private boolean playerInvClickable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit d170c7e

Please sign in to comment.