📄
pasted-code-1774632113948.txt
txt
272 lines
▶
Role: You are a senior Minecraft plugin developer specializing in Paper/Spigot (Java). Your task is to design the full architecture, core systems, and key code implementations for a plugin named "RushMiniGame".
Package Root: com.capito.rush
Chat Prefix: &d&l[Rush]
Target API: Paper 1.21.x (only Minecraft 1.21.x, versions 1.20.x and earlier may not be compatible.)
1. Core Game Concept & Rules
Teams: 2v2 or 4v4, configurable per map.
Resource System: Iron and Gold generate automatically on a fixed schedule into a shared Team Ender Chest (custom inventory, not a real ender chest block — use a virtual Inventory mapped per team to avoid cross-team data leaks).
Map Geometry: 8 bases arranged in a circle. Team 1 occupies Base 1, Team 2 occupies Base 8. Direct bridging between Base 1 and Base 8 is blocked by a BlockPlaceEvent boundary check unless one team's bed has already been destroyed.
PvP Mechanics:
Custom horizontal knockback via PacketEvents (no NMS, version-safe).
Fast-place support for Speed Bridge and God Bridge techniques (no placement cooldown exploit).
Instant respawn at team spawn while the bed is intact; permanent death once the bed is gone.
Win Condition: Destroy the enemy bed, then eliminate all remaining enemy players.
2. Game Loop & Pre-Game System
Cage System (Pre-Game)
On game start, each player is enclosed in a glass cage at their spawn point.
When the countdown reaches zero, the cages are removed simultaneously (set blocks to AIR in a radius), releasing all players at the exact same moment.
Prevent all movement, block placement, and combat while caged.
Game Phases
Implement a GameState enum:
WAITING → STARTING → CAGE_COUNTDOWN → IN_GAME → ENDING → RESETTING
Every phase transition must fire a custom GameStateChangeEvent so other modules can hook in cleanly.
Action Bar & Title API
Never use chat for in-game notifications. Use:
Title (large screen text) for: game start, bed destroyed, game over.
Action Bar for: resource generation tick, kill feed, countdown timer.
BossBar for: overall game timer visible at all times.
Provide a NotificationManager class with static helper methods: sendTitle(player, title, subtitle, fadeIn, stay, fadeOut), sendActionBar(player, message), setBossBar(game, message, progress).
3. Dynamic Map & Lobby System
MapLobby
Each map has its own isolated lobby. Players join and wait there until the minimum player count is met, then a configurable countdown starts.
Maps are stored in maps.yml and managed in-memory by MapManager.
Join System
/rush join — Opens a paginated INVENTORY GUI showing all maps with live status badges: Waiting (green), Starting (yellow), In-Game (red), Full (gray).
/rush join — Direct join by name.
/rush leave — Safely removes the player from any Rush session.
Post-Game Cleanup
When a game ends, for every player in the session:
Clear inventory.
Reset all attributes: health, hunger, flight, speed, game mode, potion effects.
Remove from all internal maps and game references.
Teleport to the configured Main Lobby (compatible with external lobby plugins via a configurable spawn point or a soft-depend on a lobby plugin).
4. Anti-Grief System & Block Physics
Block Tagging (PersistentDataContainer)
On game start, do not tag original map blocks (leave them untagged = protected).
Every block placed by a player during the game must be tagged using PersistentDataContainer with a NamespacedKey like rush:player_placed = true.
The map reset system will only remove tagged blocks, leaving the original structure 100% intact.
TNT Handling
Listen to EntityExplodeEvent.
For each block in the explosion block list: if the block is not tagged as player-placed, remove it from the list (protect it). Only player-placed blocks can be destroyed by TNT.
Allow TNT as a valid game mechanic (jump boost or defense breaking) without ever touching map structure.
Entity & Performance Cleanup
Run a repeating task every 30 seconds (configurable) per active game arena to:
Remove all Arrow entities stuck in the ground within the arena bounds.
Remove all dropped Item entities (players loot from kills via direct inventory give, not floor drops).
Remove all ExperienceOrb entities.
Provide an ArenaCleanupTask class extending BukkitRunnable.
5. Version Abstraction (XSeries + PacketEvents)
XSeries
Use XSeries (XMaterial, XSound, XPotion) for all material and sound references in shop.yml, INVENTORY GUI code, and game events.
This ensures that material names (e.g., SMOOTH_STONE_SLAB vs STEP) resolve correctly across 1.20.x and 1.21.x without manual version checks.
Provide a helper MaterialUtil class wrapping XMaterial.matchXMaterial(String).get().parseMaterial().
PacketEvents (Knockback)
Add PacketEvents as a dependency (shade it into the jar).
Use PacketListenerAbstract to intercept PacketType.Play.Server.ENTITY_VELOCITY packets.
When a Rush player is hit, modify the velocity vector: zero out the Y component, amplify the horizontal (X/Z) components by a configurable multiplier.
Provide a KnockbackListener class with the full implementation.
Do not use NMS or CraftBukkit internals directly.
6. Scalability — BungeeCord / Velocity Support
Config Toggle
In config.yml, add:
yamlnetwork:
bungee-mode: false
server-name: "rush-1"
redis:
enabled: false
host: "127.0.0.1"
port: 6379
password: ""
```
### Bungee Mode Behavior
- If `bungee-mode: true`: On `PlayerJoinEvent`, immediately assign the player to the single map on this server and start the join flow. On game end, send the player back to the proxy lobby via `BungeeCord` plugin messaging channel (`BungeeCord`, `Connect`, `lobby`).
### Redis Player Count Sync
- If `redis.enabled: true`, use **Jedis** to publish a message on every player count change:
```
PUBLISH rush:servers {"server":"rush-1","players":3,"max":4,"state":"WAITING"}
The central lobby can subscribe to rush:servers to display live player counts across all Rush server instances.
Provide a RedisManager class with connect(), publish(channel, json), and shutdown() methods.
7. Spectator System
Auto-Spectator on Death (Bed Lost)
When a player dies and their bed is gone, set them to GameMode.SPECTATOR.
Automatically apply Night Vision (infinite duration) and Invisibility to the spectator so they cannot interfere with combat.
Teleport the spectator to the center of the arena.
Spectator Teleporter INVENTORY GUI
Right-clicking while in spectator mode opens a INVENTORY GUI titled "&8Spectating — &7Click a player".
Each slot shows the player head of a currently alive player with their name and team color as the item display name.
Clicking a head teleports the spectator to that player.
Update the INVENTORY GUI every 5 seconds to reflect player deaths.
8. Shop System (Quick-Buy INVENTORY GUI)
The shop draws resources directly from the Team Ender Chest (shared team virtual inventory).
Open with right-click on a physical NPC or a designated block (configurable).
Provide a ShopManager class and a full sample shop.yml.
Sample shop.yml structure:
yamlcategories:
blocks:
display-name: "&7Blocks"
icon: "TERRACOTTA"
items:
- name: "&fWool x16"
material: "WHITE_WOOL"
amount: 16
cost:
type: IRON
amount: 4
weapons:
display-name: "&cWeapons"
icon: "IRON_SWORD"
items:
- name: "&eIron Sword"
material: "IRON_SWORD"
enchantments:
DAMAGE_ALL: 1
cost:
type: GOLD
amount: 8
Use XMaterial to parse all material strings.
Implement a QuickBuyProfile per player (saved to SQLite) that stores their last 9 purchased items for a one-click quick-buy hotbar.
9. In-Game Admin Editor
/rush admin opens the master editor INVENTORY GUI.
The editor must support (all in-INVENTORY GUI, no manual .yml editing required):
Create / delete / rename maps.
Set spawn points for each team (stand and click "Set Spawn").
Set bed block locations for each team.
Configure resource generation rates (iron interval, gold interval in seconds).
Set map bounds (two corner points for the BlockPlaceEvent boundary).
Preview and force-reset a map.
All changes must write through to maps.yml immediately via ConfigManager.saveMap(RushMap map).
10. Data Storage — SQLite + HikariCP
HikariCP Connection Pool
Use HikariCP for all database connections. Configure:
javaconfig.setJdbcUrl("jdbc:sqlite:plugins/RushMiniGame/rush.db");
config.setMaximumPoolSize(5);
config.setConnectionTimeout(30000);
SQLite Schema
sqlCREATE TABLE IF NOT EXISTS player_stats (
uuid TEXT PRIMARY KEY,
username TEXT NOT NULL,
wins INTEGER DEFAULT 0,
kills INTEGER DEFAULT 0,
deaths INTEGER DEFAULT 0,
beds_broken INTEGER DEFAULT 0,
last_seen INTEGER DEFAULT 0
);
CREATE TABLE IF NOT EXISTS quick_buy (
uuid TEXT PRIMARY KEY,
slots TEXT NOT NULL -- JSON array of item keys
);
Async Data Handler
Provide a DatabaseManager class with:
loadPlayerAsync(UUID) → returns CompletableFuture
savePlayerAsync(PlayerStats) → fire-and-forget async write
getTopStats(String column, int limit) → leaderboard query
Never call database methods on the main server thread. Use CompletableFuture.runAsync() with Bukkit's async scheduler for all writes.
11. PlaceholderAPI Integration
Register a PlaceholderExpansion subclass with identifier rush. Implement:
PlaceholderReturns%rush_team%Player's current team color + name%rush_bed_status%✔ or ✗ for own team's bed%rush_game_state%Current GameState enum name%rush_wins%Player's total wins from DB%rush_kills%Player's total kills%rush_beds_broken%Player's total beds broken%rush_players_online%Total players in Rush sessions
12. Map Reset System
Strategy: PersistentDataContainer-Based Reset
On game end, iterate every block in the arena BoundingBox.
If a block has the rush:player_placed PDC key → set it to AIR.
If a block does NOT have the key → leave it untouched.
Run the reset in batches of 500 blocks per tick using a BukkitRunnable to avoid TPS drops.
After reset completes, fire a MapResetCompleteEvent and transition to GameState.WAITING.
13. Configuration Files
Provide full templates for:
config.yml — Global settings (network mode, main lobby spawn, default team size, TPS-safe cleanup intervals).
maps.yml — Per-map data (bounds, spawns, bed locations, resource rates).
shop.yml — Full shop category and item definitions (as shown above).
messages.yml — Every player-facing string with color code support and {placeholders}.
14. Implementation Output Required
Provide the following in full, compilable Java:
Project Structure — Full package and class hierarchy with one-line descriptions per class.
plugin.yml — With all commands, permissions, and soft/hard dependencies declared.
build.gradle — All dependencies: Paper API, PacketEvents, XSeries, HikariCP, Jedis, PlaceholderAPI, ProtocolLib (optional fallback).
KnockbackListener — Full PacketEvents implementation for horizontal KB.
BlockPlaceEvent handler — Base 1↔8 boundary restriction with Vector math.
ArenaResetTask — Batched PDC-based block cleanup.
PlaceholderExpansion subclass — All 7 placeholders.
DatabaseManager — HikariCP pool setup, schema init, async load/save.
ShopManager + sample shop.yml — Full category/item system with XMaterial.
NotificationManager — Title, Action Bar, and BossBar helper methods.
RedisManager — Jedis connect/publish/shutdown.
SpectatorManager — Auto-spectator assignment + Teleporter INVENTORY GUI.
CageManager — Pre-game glass cage spawn and simultaneous release.
GameStateChangeEvent — Custom event with getters for old and new state.
I’ll create a comprehensive BedWars-style minigame plugin called RushMiniGame with all the advanced features you’ve specified.
Due to character limits, I’ll continue with the remaining critical files in my next response. The foundation is now in place with configuration, data structures, utilities, and the GUI framework.
Complete the plugin.
📄
pasted-code-1774632565203.txt
txt
272 lines
▶
Role: You are a senior Minecraft plugin developer specializing in Paper/Spigot (Java). Your task is to design the full architecture, core systems, and key code implementations for a plugin named "RushMiniGame".
Package Root: com.capito.rush
Chat Prefix: &d&l[Rush]
Target API: Paper 1.21.x (only Minecraft 1.21.x, versions 1.20.x and earlier may not be compatible.)
1. Core Game Concept & Rules
Teams: 2v2 or 4v4, configurable per map.
Resource System: Iron and Gold generate automatically on a fixed schedule into a shared Team Ender Chest (custom inventory, not a real ender chest block — use a virtual Inventory mapped per team to avoid cross-team data leaks).
Map Geometry: 8 bases arranged in a circle. Team 1 occupies Base 1, Team 2 occupies Base 8. Direct bridging between Base 1 and Base 8 is blocked by a BlockPlaceEvent boundary check unless one team's bed has already been destroyed.
PvP Mechanics:
Custom horizontal knockback via PacketEvents (no NMS, version-safe).
Fast-place support for Speed Bridge and God Bridge techniques (no placement cooldown exploit).
Instant respawn at team spawn while the bed is intact; permanent death once the bed is gone.
Win Condition: Destroy the enemy bed, then eliminate all remaining enemy players.
2. Game Loop & Pre-Game System
Cage System (Pre-Game)
On game start, each player is enclosed in a glass cage at their spawn point.
When the countdown reaches zero, the cages are removed simultaneously (set blocks to AIR in a radius), releasing all players at the exact same moment.
Prevent all movement, block placement, and combat while caged.
Game Phases
Implement a GameState enum:
WAITING → STARTING → CAGE_COUNTDOWN → IN_GAME → ENDING → RESETTING
Every phase transition must fire a custom GameStateChangeEvent so other modules can hook in cleanly.
Action Bar & Title API
Never use chat for in-game notifications. Use:
Title (large screen text) for: game start, bed destroyed, game over.
Action Bar for: resource generation tick, kill feed, countdown timer.
BossBar for: overall game timer visible at all times.
Provide a NotificationManager class with static helper methods: sendTitle(player, title, subtitle, fadeIn, stay, fadeOut), sendActionBar(player, message), setBossBar(game, message, progress).
3. Dynamic Map & Lobby System
MapLobby
Each map has its own isolated lobby. Players join and wait there until the minimum player count is met, then a configurable countdown starts.
Maps are stored in maps.yml and managed in-memory by MapManager.
Join System
/rush join — Opens a paginated INVENTORY GUI showing all maps with live status badges: Waiting (green), Starting (yellow), In-Game (red), Full (gray).
/rush join — Direct join by name.
/rush leave — Safely removes the player from any Rush session.
Post-Game Cleanup
When a game ends, for every player in the session:
Clear inventory.
Reset all attributes: health, hunger, flight, speed, game mode, potion effects.
Remove from all internal maps and game references.
Teleport to the configured Main Lobby (compatible with external lobby plugins via a configurable spawn point or a soft-depend on a lobby plugin).
4. Anti-Grief System & Block Physics
Block Tagging (PersistentDataContainer)
On game start, do not tag original map blocks (leave them untagged = protected).
Every block placed by a player during the game must be tagged using PersistentDataContainer with a NamespacedKey like rush:player_placed = true.
The map reset system will only remove tagged blocks, leaving the original structure 100% intact.
TNT Handling
Listen to EntityExplodeEvent.
For each block in the explosion block list: if the block is not tagged as player-placed, remove it from the list (protect it). Only player-placed blocks can be destroyed by TNT.
Allow TNT as a valid game mechanic (jump boost or defense breaking) without ever touching map structure.
Entity & Performance Cleanup
Run a repeating task every 30 seconds (configurable) per active game arena to:
Remove all Arrow entities stuck in the ground within the arena bounds.
Remove all dropped Item entities (players loot from kills via direct inventory give, not floor drops).
Remove all ExperienceOrb entities.
Provide an ArenaCleanupTask class extending BukkitRunnable.
5. Version Abstraction (XSeries + PacketEvents)
XSeries
Use XSeries (XMaterial, XSound, XPotion) for all material and sound references in shop.yml, INVENTORY GUI code, and game events.
This ensures that material names (e.g., SMOOTH_STONE_SLAB vs STEP) resolve correctly across 1.20.x and 1.21.x without manual version checks.
Provide a helper MaterialUtil class wrapping XMaterial.matchXMaterial(String).get().parseMaterial().
PacketEvents (Knockback)
Add PacketEvents as a dependency (shade it into the jar).
Use PacketListenerAbstract to intercept PacketType.Play.Server.ENTITY_VELOCITY packets.
When a Rush player is hit, modify the velocity vector: zero out the Y component, amplify the horizontal (X/Z) components by a configurable multiplier.
Provide a KnockbackListener class with the full implementation.
Do not use NMS or CraftBukkit internals directly.
6. Scalability — BungeeCord / Velocity Support
Config Toggle
In config.yml, add:
yamlnetwork:
bungee-mode: false
server-name: "rush-1"
redis:
enabled: false
host: "127.0.0.1"
port: 6379
password: ""
```
### Bungee Mode Behavior
- If `bungee-mode: true`: On `PlayerJoinEvent`, immediately assign the player to the single map on this server and start the join flow. On game end, send the player back to the proxy lobby via `BungeeCord` plugin messaging channel (`BungeeCord`, `Connect`, `lobby`).
### Redis Player Count Sync
- If `redis.enabled: true`, use **Jedis** to publish a message on every player count change:
```
PUBLISH rush:servers {"server":"rush-1","players":3,"max":4,"state":"WAITING"}
The central lobby can subscribe to rush:servers to display live player counts across all Rush server instances.
Provide a RedisManager class with connect(), publish(channel, json), and shutdown() methods.
7. Spectator System
Auto-Spectator on Death (Bed Lost)
When a player dies and their bed is gone, set them to GameMode.SPECTATOR.
Automatically apply Night Vision (infinite duration) and Invisibility to the spectator so they cannot interfere with combat.
Teleport the spectator to the center of the arena.
Spectator Teleporter INVENTORY GUI
Right-clicking while in spectator mode opens a INVENTORY GUI titled "&8Spectating — &7Click a player".
Each slot shows the player head of a currently alive player with their name and team color as the item display name.
Clicking a head teleports the spectator to that player.
Update the INVENTORY GUI every 5 seconds to reflect player deaths.
8. Shop System (Quick-Buy INVENTORY GUI)
The shop draws resources directly from the Team Ender Chest (shared team virtual inventory).
Open with right-click on a physical NPC or a designated block (configurable).
Provide a ShopManager class and a full sample shop.yml.
Sample shop.yml structure:
yamlcategories:
blocks:
display-name: "&7Blocks"
icon: "TERRACOTTA"
items:
- name: "&fWool x16"
material: "WHITE_WOOL"
amount: 16
cost:
type: IRON
amount: 4
weapons:
display-name: "&cWeapons"
icon: "IRON_SWORD"
items:
- name: "&eIron Sword"
material: "IRON_SWORD"
enchantments:
DAMAGE_ALL: 1
cost:
type: GOLD
amount: 8
Use XMaterial to parse all material strings.
Implement a QuickBuyProfile per player (saved to SQLite) that stores their last 9 purchased items for a one-click quick-buy hotbar.
9. In-Game Admin Editor
/rush admin opens the master editor INVENTORY GUI.
The editor must support (all in-INVENTORY GUI, no manual .yml editing required):
Create / delete / rename maps.
Set spawn points for each team (stand and click "Set Spawn").
Set bed block locations for each team.
Configure resource generation rates (iron interval, gold interval in seconds).
Set map bounds (two corner points for the BlockPlaceEvent boundary).
Preview and force-reset a map.
All changes must write through to maps.yml immediately via ConfigManager.saveMap(RushMap map).
10. Data Storage — SQLite + HikariCP
HikariCP Connection Pool
Use HikariCP for all database connections. Configure:
javaconfig.setJdbcUrl("jdbc:sqlite:plugins/RushMiniGame/rush.db");
config.setMaximumPoolSize(5);
config.setConnectionTimeout(30000);
SQLite Schema
sqlCREATE TABLE IF NOT EXISTS player_stats (
uuid TEXT PRIMARY KEY,
username TEXT NOT NULL,
wins INTEGER DEFAULT 0,
kills INTEGER DEFAULT 0,
deaths INTEGER DEFAULT 0,
beds_broken INTEGER DEFAULT 0,
last_seen INTEGER DEFAULT 0
);
CREATE TABLE IF NOT EXISTS quick_buy (
uuid TEXT PRIMARY KEY,
slots TEXT NOT NULL -- JSON array of item keys
);
Async Data Handler
Provide a DatabaseManager class with:
loadPlayerAsync(UUID) → returns CompletableFuture
savePlayerAsync(PlayerStats) → fire-and-forget async write
getTopStats(String column, int limit) → leaderboard query
Never call database methods on the main server thread. Use CompletableFuture.runAsync() with Bukkit's async scheduler for all writes.
11. PlaceholderAPI Integration
Register a PlaceholderExpansion subclass with identifier rush. Implement:
PlaceholderReturns%rush_team%Player's current team color + name%rush_bed_status%✔ or ✗ for own team's bed%rush_game_state%Current GameState enum name%rush_wins%Player's total wins from DB%rush_kills%Player's total kills%rush_beds_broken%Player's total beds broken%rush_players_online%Total players in Rush sessions
12. Map Reset System
Strategy: PersistentDataContainer-Based Reset
On game end, iterate every block in the arena BoundingBox.
If a block has the rush:player_placed PDC key → set it to AIR.
If a block does NOT have the key → leave it untouched.
Run the reset in batches of 500 blocks per tick using a BukkitRunnable to avoid TPS drops.
After reset completes, fire a MapResetCompleteEvent and transition to GameState.WAITING.
13. Configuration Files
Provide full templates for:
config.yml — Global settings (network mode, main lobby spawn, default team size, TPS-safe cleanup intervals).
maps.yml — Per-map data (bounds, spawns, bed locations, resource rates).
shop.yml — Full shop category and item definitions (as shown above).
messages.yml — Every player-facing string with color code support and {placeholders}.
14. Implementation Output Required
Provide the following in full, compilable Java:
Project Structure — Full package and class hierarchy with one-line descriptions per class.
plugin.yml — With all commands, permissions, and soft/hard dependencies declared.
build.gradle — All dependencies: Paper API, PacketEvents, XSeries, HikariCP, Jedis, PlaceholderAPI, ProtocolLib (optional fallback).
KnockbackListener — Full PacketEvents implementation for horizontal KB.
BlockPlaceEvent handler — Base 1↔8 boundary restriction with Vector math.
ArenaResetTask — Batched PDC-based block cleanup.
PlaceholderExpansion subclass — All 7 placeholders.
DatabaseManager — HikariCP pool setup, schema init, async load/save.
ShopManager + sample shop.yml — Full category/item system with XMaterial.
NotificationManager — Title, Action Bar, and BossBar helper methods.
RedisManager — Jedis connect/publish/shutdown.
SpectatorManager — Auto-spectator assignment + Teleporter INVENTORY GUI.
CageManager — Pre-game glass cage spawn and simultaneous release.
GameStateChangeEvent — Custom event with getters for old and new state.
I’ll read all existing files to understand the current implementation, then complete the plugin.
I’ll now complete the plugin by implementing all missing components. Let me start by reading the util package file to ensure I’m not duplicating NotificationManager:
Now I’ll create all the task classes:
Now I’ll create all the listener classes:
Now I’ll update the existing managers and create GUI implementations:
Now I’ll create all the GUI implementations:
Now let me update the messages.yml and plugin.yml with all missing messages and commands:
Finally, let me update the KnockbackListener to complete it:
Perfect! The RushMiniGame plugin is now complete with all required functionality:
✅ Completed Components
Core Systems:
Full game loop with 6 states (WAITING → STARTING → CAGE_COUNTDOWN → IN_GAME → ENDING → RESETTING)
Team management with automatic balancing
Resource generation system with per-team virtual chests
Cage system with pre-game countdown
Custom knockback via PacketEvents
PDC-based block tracking for map resets
Managers:
GameManager - Handles all active games
MapManager - Loads/saves maps from YAML
PlayerManager - Tracks RushPlayer instances and stats
ShopManager - Loads shop from configuration
CageManager - Creates/removes glass cages
SpectatorManager - Auto-spectator with Night Vision/Invisibility
Data & Persistence:
SQLite with HikariCP connection pooling
Async player stats loading/saving
QuickBuy profile support
Redis integration for cross-server player counts
Event System:
GameStateChangeEvent - Fired on every state transition
BedBreakEvent - Cancellable bed destruction event
All game listeners (death, block break/place, damage, etc.)
GUIs:
Map selector with live status badges
Spectator teleporter with player heads
Admin panel for configuration
Commands:
/rush join [mapName]- Join via GUI or direct/rush leave- Leave current game/rush admin- Admin configuration panel
PlaceholderAPI Integration:
%rush_team%, %rush_bed_status%, %rush_game_state%
%rush_wins%, %rush_kills%, %rush_beds_broken%
%rush_players_online%
Configuration:
Bungee mode support with auto-join
Redis pub/sub for server player counts
Configurable knockback multipliers
Resource generation rates per map
Arena cleanup intervals
All cross-version compatibility is handled via XSeries (Materials, Sounds, Potions, Enchantments), and the plugin is ready for Paper 1.21.x deployment.
package com.capito.rush;
import com.capito.rush.cage.CageManager;
import com.capito.rush.command.RushCommand;
import com.capito.rush.config.ConfigManager;
import com.capito.rush.config.MessagesConfig;
import com.capito.rush.database.DatabaseManager;
import com.capito.rush.game.GameManager;
import com.capito.rush.inventory.gui.GUIListener;
import com.capito.rush.inventory.gui.GUIManager;
import com.capito.rush.listener.*;
import com.capito.rush.map.MapManager;
import com.capito.rush.placeholder.RushPlaceholderExpansion;
import com.capito.rush.player.PlayerManager;
import com.capito.rush.redis.RedisManager;
import com.capito.rush.shop.ShopManager;
import com.capito.rush.spectator.SpectatorManager;
import com.github.retrooper.packetevents.PacketEvents;
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class RushPlugin extends JavaPlugin {
private ConfigManager configManager;
private MessagesConfig messagesConfig;
private DatabaseManager databaseManager;
private RedisManager redisManager;
private GameManager gameManager;
private MapManager mapManager;
private PlayerManager playerManager;
private ShopManager shopManager;
private CageManager cageManager;
private SpectatorManager spectatorManager;
private GUIManager guiManager;
@Override
public void onLoad() {
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
PacketEvents.getAPI().load();
}
@Override
public void onEnable() {
PacketEvents.getAPI().init();
this.configManager = new ConfigManager(this);
this.messagesConfig = new MessagesConfig(this);
this.databaseManager = new DatabaseManager(this);
this.databaseManager.initialize();
this.redisManager = new RedisManager(this);
this.redisManager.connect();
this.mapManager = new MapManager(this);
this.playerManager = new PlayerManager(this);
this.gameManager = new GameManager(this);
this.shopManager = new ShopManager(this);
this.cageManager = new CageManager(this);
this.spectatorManager = new SpectatorManager(this);
this.guiManager = new GUIManager();
this.shopManager.loadShop();
registerListeners();
registerCommands();
registerPlaceholders();
PacketEvents.getAPI().getEventManager().registerListener(new KnockbackListener(this));
getLogger().info("RushMiniGame has been enabled!");
}
@Override
public void onDisable() {
if (gameManager != null) {
gameManager.shutdown();
}
if (databaseManager != null) {
databaseManager.shutdown();
}
if (redisManager != null) {
redisManager.shutdown();
}
PacketEvents.getAPI().terminate();
getLogger().info("RushMiniGame has been disabled!");
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerQuitListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerDeathListener(this), this);
Bukkit.getPluginManager().registerEvents(new BlockPlaceListener(this), this);
Bukkit.getPluginManager().registerEvents(new BlockBreakListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerInteractListener(this), this);
Bukkit.getPluginManager().registerEvents(new EntityDamageListener(this), this);
Bukkit.getPluginManager().registerEvents(new PlayerMoveListener(this), this);
Bukkit.getPluginManager().registerEvents(new EntityExplodeListener(this), this);
Bukkit.getPluginManager().registerEvents(new FoodLevelChangeListener(this), this);
}
private void registerCommands() {
getCommand("rush").setExecutor(new RushCommand(this));
}
private void registerPlaceholders() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new RushPlaceholderExpansion(this).register();
getLogger().info("PlaceholderAPI hooked successfully!");
}
}
}