From 0c9bf9bb3a4b6bf2d1ad2edab83d2a4ca81a2edb Mon Sep 17 00:00:00 2001 From: misieur <153451816+misieur@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:58:09 +0200 Subject: [PATCH] Update RTPCommand.java --- .../communaywen/core/commands/RTPCommand.java | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/src/main/java/fr/communaywen/core/commands/RTPCommand.java b/src/main/java/fr/communaywen/core/commands/RTPCommand.java index 84fa3add..053b7eb6 100644 --- a/src/main/java/fr/communaywen/core/commands/RTPCommand.java +++ b/src/main/java/fr/communaywen/core/commands/RTPCommand.java @@ -2,43 +2,49 @@ import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Particle; -import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.scoreboard.Scoreboard; -import org.bukkit.scoreboard.Team; -import org.bukkit.util.Vector; + +import fr.misieur.AywenCraftPlugin.AywenCraftPlugin; import java.util.HashMap; import java.util.UUID; public class RTPCommand implements CommandExecutor { - - - - private final Configs plugin; - public RTPCommand(Congis plugin){ - this.plugin = plugin; - } + private final AywenCraftPlugin plugin; + // Configuration values + private final int COOLDOWN_TIME; + private final int COOLDOWN_ERROR; + private final int MIN_X; + private final int MAX_X; + private final int MIN_Y; + private final int MAX_Y; + private final int MIN_Z; + private final int MAX_Z; - //Merci à ri1ongithub pour le système de cooldown que j'avais la flème de refaire private final HashMap cooldowns = new HashMap<>(); - private static final int COOLDOWN = this.plugin.getConfig().getint("rtp.cooldown"); //temps en secondes - private static final int COOLDOWN_ERROR = this.plugin.getConfig().getint("rtp.cooldown-error"); //temps en secondes - - - - - @Override - public boolean onCommand(final CommandSender sender,final Command command,final String label,final String[] args) { + + public RTPCommand(AywenCraftPlugin plugin) { + this.plugin = plugin; + + // Load configuration values + COOLDOWN_TIME = plugin.getConfig().getInt("rtp.cooldown"); + COOLDOWN_ERROR = plugin.getConfig().getInt("rtp.cooldown-error"); + MIN_X = plugin.getConfig().getInt("rtp.minx"); + MAX_X = plugin.getConfig().getInt("rtp.maxx"); + MIN_Y = plugin.getConfig().getInt("rtp.miny"); + MAX_Y = plugin.getConfig().getInt("rtp.maxy"); + MIN_Z = plugin.getConfig().getInt("rtp.minz"); + MAX_Z = plugin.getConfig().getInt("rtp.maxz"); + } + + @Override + public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { if (sender instanceof Player player) { UUID playerId = player.getUniqueId(); long currentTime = System.currentTimeMillis() / 1000; @@ -53,33 +59,28 @@ public boolean onCommand(final CommandSender sender,final Command command,final return true; } } - int minx = this.plugin.getConfig().getint("rtp.minx"); - int maxx = this.plugin.getConfig().getint("rtp.maxx"); - int miny = this.plugin.getConfig().getint("rtp.miny"); - int maxy = this.plugin.getConfig().getint("rtp.maxy"); - int minz = this.plugin.getConfig().getint("rtp.minz"); - int maxz = this.plugin.getConfig().getint("rtp.maxz"); - int x = (int) ((Math.random() * (maxx - minx)) + minx); - int z = (int) ((Math.random() * (maxz - minz)) + minz); + World world = player.getWorld(); - Location location,belowlocation; - for (int y = miny; y