refactor: generator minigame system (gui + text), fix color codes, holograms, messages, & config

This commit is contained in:
loki5512344 2026-06-14 16:04:25 +02:00
parent 957ab4a5a2
commit 7c7562a8d4
48 changed files with 1628 additions and 733 deletions

View file

@ -1,11 +1,12 @@
package dev.loki.killer;
import dev.loki.config.GameConfig;
import dev.loki.config.MessagesConfig;
import dev.loki.mdbd;
import dev.loki.objective.Generator;
import dev.loki.objective.GeneratorManager;
import dev.loki.player.Killer;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -29,6 +30,7 @@ public class GeneratorKick {
private final Plugin plugin;
private final GameConfig config;
private final GeneratorManager generatorManager;
private final MessagesConfig messages;
/** UUID → ongoing charging task */
private final Map<UUID, BukkitTask> chargingTasks = new HashMap<>();
@ -41,6 +43,7 @@ public class GeneratorKick {
this.plugin = plugin;
this.config = config;
this.generatorManager = generatorManager;
this.messages = mdbd.getInstance().getConfigManager().getMessages();
}
// -------------------------------------------------------------------------
@ -55,7 +58,7 @@ public class GeneratorKick {
Player p = killer.getPlayer();
if (p != null) {
int secsLeft = (int) Math.ceil(globalCooldownTicks / 20.0);
p.sendMessage(Component.text("[DBD] Кулдаун удара: " + secsLeft + " сек", NamedTextColor.RED));
p.sendMessage(messages.get("generator.kicked.cooldown", secsLeft));
}
return false;
}
@ -66,6 +69,12 @@ public class GeneratorKick {
Generator gen = generatorManager.getNearestGenerator(p.getLocation(),
config.getGeneratorInteractionRange());
if (gen == null || !gen.canBeRepaired()) return false;
if (gen.getProgress() <= 0) {
if (p.isOnline()) {
p.sendMessage(messages.get("generator.kicked.already-broken"));
}
return false;
}
int chargeTicks = config.getKickChargeSeconds() * 20;
@ -92,7 +101,7 @@ public class GeneratorKick {
elapsed++;
double pct = (double) elapsed / chargeTicks * 100;
player.sendActionBar(Component.text("§c⚡ Разрушение: " + (int) pct + "%"));
player.sendActionBar(messages.get("generator.kicked.actionbar", (int) pct));
if (elapsed >= chargeTicks) {
executeKick(killer, gen);
@ -102,7 +111,7 @@ public class GeneratorKick {
}.runTaskTimer(plugin, 1L, 1L);
chargingTasks.put(uuid, task);
if (p.isOnline()) p.sendMessage(Component.text("[DBD] Держите Shift для разрушения генератора...", NamedTextColor.RED));
if (p.isOnline()) p.sendMessage(messages.get("generator.kicked.begin"));
return true;
}
@ -146,12 +155,12 @@ public class GeneratorKick {
Player p = killer.getPlayer();
if (p != null && p.isOnline()) {
p.sendActionBar(Component.empty());
p.sendMessage(Component.text("[DBD] Генератор поврежден! -" + (int) regPct + "% прогресса", NamedTextColor.RED));
p.sendMessage(messages.get("generator.kicked.success", (int) regPct));
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.6f, 1.3f);
}
// Notify all players
Bukkit.broadcast(Component.text("[DBD] ⚡ Маньяк разрушил генератор! -" + (int)regPct + "%", NamedTextColor.DARK_RED));
Bukkit.broadcast(messages.get("generator.kicked.broadcast", (int) regPct));
// Unblock generator after kick-duration (separate from global cooldown)
int unblockTicks = config.getKickDuration() * 20;