Илья Глазунов 2625155037
Some checks failed
Build and Release / build (push) Failing after 3s
initial commit
2025-12-22 20:29:34 +03:00

82 lines
2.3 KiB
Java

package com.rpserver.jailplugin.managers;
import com.rpserver.jailplugin.JailPlugin;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class CuffManager {
private final JailPlugin plugin;
private final Set<UUID> cuffedPlayers;
public CuffManager(JailPlugin plugin) {
this.plugin = plugin;
this.cuffedPlayers = new HashSet<>();
}
public boolean isCuffed(Player player) {
return cuffedPlayers.contains(player.getUniqueId());
}
public boolean isCuffed(UUID uuid) {
return cuffedPlayers.contains(uuid);
}
public void cuff(Player player) {
cuffedPlayers.add(player.getUniqueId());
applySlowEffect(player);
}
public void uncuff(Player player) {
cuffedPlayers.remove(player.getUniqueId());
removeSlowEffect(player);
plugin.getLeadManager().unlead(player);
}
private void applySlowEffect(Player player) {
double speedModifier = plugin.getConfig().getDouble("cuff.speed-modifier", 0.5);
int amplifier = (int) ((1.0 - speedModifier) * 4); // 0.5 speed = Slowness 2
player.addPotionEffect(new PotionEffect(
PotionEffectType.SLOWNESS,
Integer.MAX_VALUE,
amplifier,
false,
false,
true
));
}
private void removeSlowEffect(Player player) {
player.removePotionEffect(PotionEffectType.SLOWNESS);
}
public boolean isCommandBlocked(String command) {
if (!plugin.getConfig().getBoolean("cuff.block-commands", true)) {
return false;
}
String cmd = command.toLowerCase().split(" ")[0];
for (String allowed : plugin.getConfig().getStringList("cuff.allowed-commands")) {
if (cmd.equalsIgnoreCase(allowed) || cmd.equalsIgnoreCase(allowed.substring(1))) {
return false;
}
}
return true;
}
public double getCuffDistance() {
return plugin.getConfig().getDouble("cuff.distance", 5.0);
}
public Set<UUID> getCuffedPlayers() {
return new HashSet<>(cuffedPlayers);
}
}