Skip to content

Commit

Permalink
feat: reset timer when use command settime
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanekihyouka committed Jan 26, 2024
1 parent 1f0483c commit 9c9fdb0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/main/java/haneki/cloverclear/command/CmdInfo.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package haneki.cloverclear.command;

import com.feed_the_beast.ftblib.lib.command.CmdBase;
import haneki.cloverclear.handler.ClearEventHandler;
import haneki.cloverclear.handler.ConfigHandler;
import haneki.cloverclear.util.ClearUtil;
import net.minecraft.command.CommandException;
Expand All @@ -19,7 +20,8 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
StringBuilder content = new StringBuilder();
content.append("[CloverClear]\n");
content.append("time : ").append(ConfigHandler.setting.time).append("s ")
.append("waringtime : ").append(ConfigHandler.setting.warningTime).append("s");
.append("waringtime : ").append(ConfigHandler.setting.warningTime).append("s ")
.append("nextclear : ").append(ClearEventHandler.timer/20).append("s");

content.append("\n[Whitelist-item] : ");
for (String item:ClearUtil.itemWhitelist){
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/haneki/cloverclear/command/CmdSetTime.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package haneki.cloverclear.command;

import com.feed_the_beast.ftblib.lib.command.CmdBase;
import haneki.cloverclear.handler.ClearEventHandler;
import haneki.cloverclear.handler.ConfigHandler;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
Expand All @@ -20,6 +21,7 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
}else {
if (args[0].matches("^[1-9]\\d*$")){
ConfigHandler.setTime(Integer.parseInt(args[0]));
ClearEventHandler.resetTimer();
sender.sendMessage(new TextComponentString("Cycle has been set to " + args[0] + " seconds."));
}else {
sender.sendMessage(new TextComponentString("NaN"));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/haneki/cloverclear/config/Setting.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

public class Setting {
@Config.Comment({"Time in seconds between each clear"})
public int time = 600;
public int time = 300;
@Config.Comment({"Time in seconds clear is announced to chat before-hand, set to zero to disable warning"})
public int warningTime = 30;
public int warningTime = 10;
@Config.Comment({"Set to false to disable item clearing"})
public boolean clearItems = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ public void onServerTick(TickEvent.ServerTickEvent event) {
}
}
}

public static void resetTimer(){
timer = ConfigHandler.setting.time * 20;
}
}

0 comments on commit 9c9fdb0

Please sign in to comment.