refactor: generator minigame system (gui + text), fix color codes, holograms, messages, & config
This commit is contained in:
parent
957ab4a5a2
commit
7c7562a8d4
48 changed files with 1628 additions and 733 deletions
|
|
@ -4,6 +4,7 @@ import dev.loki.chest.ChestManager;
|
|||
import dev.loki.chest.ChestOpening;
|
||||
import dev.loki.config.GameConfig;
|
||||
import dev.loki.core.GameSession;
|
||||
import dev.loki.gate.ExitGate;
|
||||
import dev.loki.gate.GateManager;
|
||||
import dev.loki.gate.GateOpening;
|
||||
import dev.loki.hook.HookManager;
|
||||
|
|
@ -15,6 +16,8 @@ import dev.loki.hook.HookStruggle;
|
|||
import dev.loki.item.ChestLoot;
|
||||
import dev.loki.killer.GeneratorKick;
|
||||
import dev.loki.mdbd;
|
||||
import dev.loki.minigames.GeneratorMinigame;
|
||||
import dev.loki.minigames.generator.GuiRouletteMinigame;
|
||||
import dev.loki.objective.GeneratorManager;
|
||||
import dev.loki.player.BasePlayer;
|
||||
import dev.loki.player.PlayerState;
|
||||
|
|
@ -22,7 +25,6 @@ import dev.loki.player.Survivor;
|
|||
import dev.loki.ui.ActionBar;
|
||||
import dev.loki.ui.TitleUI;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
|
@ -91,8 +93,7 @@ public class GameplayPhase implements Phase {
|
|||
world.setStorm(false);
|
||||
}
|
||||
|
||||
Bukkit.broadcast(Component.text(
|
||||
"[DBD] Игра началась! Выжившие, чините генераторы!", NamedTextColor.GREEN));
|
||||
Bukkit.broadcast(session.getPlugin().getConfigManager().getMessages().get("game.start"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -133,7 +134,7 @@ public class GameplayPhase implements Phase {
|
|||
damageSystem.clear();
|
||||
damageSystem.clearManagers();
|
||||
|
||||
Bukkit.broadcast(Component.text("[DBD] Игровая фаза завершена!", NamedTextColor.GOLD));
|
||||
Bukkit.broadcast(session.getPlugin().getConfigManager().getMessages().get("game.end"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -164,6 +165,18 @@ public class GameplayPhase implements Phase {
|
|||
ActionBar ab = new ActionBar();
|
||||
HookRecovery hookRecovery = new HookRecovery(plugin, cfg);
|
||||
titleUI = new TitleUI(plugin);
|
||||
|
||||
String genMinigameType = cfg.getGeneratorMinigame();
|
||||
GeneratorMinigame genMinigame;
|
||||
if ("gui".equalsIgnoreCase(genMinigameType)) {
|
||||
genMinigame = new GuiRouletteMinigame(plugin);
|
||||
} else if ("text".equalsIgnoreCase(genMinigameType)) {
|
||||
genMinigame = new dev.loki.minigames.generator.TextSkillCheckMinigame(plugin);
|
||||
} else {
|
||||
plugin.getLogger().warning("Unknown generator minigame: " + genMinigameType + ", using gui");
|
||||
genMinigame = new GuiRouletteMinigame(plugin);
|
||||
}
|
||||
|
||||
hookStruggle = new HookStruggle(plugin, titleUI, cfg);
|
||||
HookSacrifice hookSacrifice = new HookSacrifice(plugin, null);
|
||||
hookSabotage = new HookSabotage(plugin, cfg, hookManager);
|
||||
|
|
@ -176,11 +189,19 @@ public class GameplayPhase implements Phase {
|
|||
chestManager.startLootResetTimer();
|
||||
chestOpening = new ChestOpening(plugin);
|
||||
chestOpening.setChestLoot(new ChestLoot(cfg));
|
||||
|
||||
var gameWorld = plugin.getLobbyManager().getGameWorld();
|
||||
if (gameWorld != null) {
|
||||
for (var h : hookManager.getAllHooks()) h.getLocation().setWorld(gameWorld);
|
||||
for (var c : chestManager.getAllChests()) c.getLocation().setWorld(gameWorld);
|
||||
for (var g : generatorManager.getAllGenerators()) g.getLocation().setWorld(gameWorld);
|
||||
}
|
||||
|
||||
spawnGameBlocks(plugin, cfg);
|
||||
|
||||
generatorKick = new GeneratorKick(plugin, cfg, generatorManager);
|
||||
|
||||
generatorRepair = new dev.loki.objective.GeneratorRepair(plugin, generatorManager);
|
||||
generatorRepair = new dev.loki.objective.GeneratorRepair(plugin, generatorManager, genMinigame);
|
||||
// Голограммы ВСЕГДА включены
|
||||
generatorHologram = new dev.loki.objective.GeneratorHologram(plugin, generatorManager);
|
||||
generatorHologram.start();
|
||||
|
|
@ -222,11 +243,12 @@ public class GameplayPhase implements Phase {
|
|||
if (p != null && p.isOnline()) p.getInventory().clear();
|
||||
}
|
||||
|
||||
// Register skill check GUI listener
|
||||
dev.loki.listener.SkillCheckListener skillCheckListener =
|
||||
new dev.loki.listener.SkillCheckListener(plugin,
|
||||
generatorRepair.getSkillCheckGUI());
|
||||
skillCheckListener.register();
|
||||
GeneratorMinigame gm = generatorRepair.getMinigame();
|
||||
if (gm instanceof GuiRouletteMinigame gui) {
|
||||
dev.loki.listener.SkillCheckListener listener =
|
||||
new dev.loki.listener.SkillCheckListener(plugin, gui);
|
||||
listener.register();
|
||||
}
|
||||
|
||||
interaction.wire(session);
|
||||
}
|
||||
|
|
@ -241,8 +263,7 @@ public class GameplayPhase implements Phase {
|
|||
allGensDone = true;
|
||||
interaction.setAllGensDone(true);
|
||||
gateManager.activateEndgame();
|
||||
Bukkit.broadcast(Component.text(
|
||||
"[DBD] Все генераторы починены! Открывайте ворота!", NamedTextColor.GREEN));
|
||||
Bukkit.broadcast(session.getPlugin().getConfigManager().getMessages().get("generator.repair.all-done"));
|
||||
for (BasePlayer bp : session.getPlayers().values()) {
|
||||
Player p = bp.getPlayer();
|
||||
if (p != null) p.playSound(p.getLocation(), Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1.0f, 1.0f);
|
||||
|
|
@ -289,6 +310,12 @@ public class GameplayPhase implements Phase {
|
|||
if (b.getType() != hookMat) b.setType(hookMat, false);
|
||||
}
|
||||
plugin.getLogger().info("[GameplayPhase] Spawned blocks for " + hookManager.getAllHooks().size() + " hooks");
|
||||
|
||||
// Спавн блоков на местах ворот (Hopper — для открытия через ПКМ)
|
||||
for (ExitGate gate : gateManager.getAllGates()) {
|
||||
gate.spawnGateBlock();
|
||||
}
|
||||
plugin.getLogger().info("[GameplayPhase] Spawned blocks for " + gateManager.getAllGates().size() + " gates");
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
|
@ -342,6 +369,13 @@ public class GameplayPhase implements Phase {
|
|||
if (hookStruggle != null) hookStruggle.clear();
|
||||
if (chestManager != null) chestManager.stopLootResetTimer();
|
||||
if (chestHologram != null) chestHologram.stop();
|
||||
// Clean up gate blocks
|
||||
if (gateManager != null) {
|
||||
for (ExitGate gate : gateManager.getAllGates()) {
|
||||
gate.removeGateBlock();
|
||||
}
|
||||
gateManager.resetAll();
|
||||
}
|
||||
session.getPlugin().getInteractListener().setGeneratorManager(null);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue