π
pasted-code-1790872132614.txt
txt
1231 lines
βΆ
Create a complete, production-ready Minecraft 1.21.11 Trait SMP plugin using Java and Gradle.
## TARGET
* Minecraft: 1.21.11
* Java: 21
* Server software: Paper
* Build system: Gradle
* Plugin name: TraitSMP
* Main package: `me.traitsmp`
* Main class: `me.traitsmp.TraitSMP`
The plugin must be fully functional and compile successfully with:
```text
./gradlew build
```
Do not leave placeholders such as:
* TODO
* Implement this later
* Your code here
* Example implementation
* Not implemented
Every required class and feature must be completely implemented.
---
# MAIN CONCEPT
Create a Trait SMP system where every player can permanently have **one unique trait**.
Traits are separated into two categories:
* Good Traits
* Bad Traits
A player can only receive **one trait total**.
Traits should be primarily **passive traits**. They should not require players to activate abilities manually.
Do not create active ability buttons or `/trait activate` commands.
The trait effects should automatically work when their conditions are met.
---
# FIRST JOIN SYSTEM
When a player joins the server for the first time, they must be given a special trait selection interface.
This should only happen once per player.
The player should first receive a Minecraft-style GUI/dialog asking them to choose between:
### Good Trait
Description:
```text
Choose from the positive passive traits.
These traits provide useful advantages.
```
### Bad Trait
Description:
```text
Choose from the negative passive traits.
These traits provide disadvantages or unusual drawbacks.
```
Use two clean action buttons:
* Good Trait
* Bad Trait
The interface should use modern Minecraft formatting and clean colors.
After selecting Good Trait or Bad Trait, open another GUI showing all traits belonging to that category.
The player must then select exactly one trait.
After selecting a trait:
* Save it permanently.
* Close the GUI.
* Broadcast that the player received the trait.
* Send the player a title containing the trait name.
* Send a configurable message explaining the trait.
* Play a configurable sound.
* Never ask the player to choose again.
* The trait must survive server restarts.
If the player disconnects during the selection process, remember that they have not completed trait selection and reopen the selection system when they next join.
Do not allow a player to bypass the selection by closing the GUI.
Do not assign a random trait.
---
# TRAIT CATEGORIES
Create two categories.
## GOOD TRAITS
Good traits should be passive and provide beneficial effects.
Create:
### Guardian
* Gains Resistance I when below a configurable health threshold.
* Automatically removes Resistance when above the threshold.
* No manual activation.
* Threshold must be configurable.
### Miner
* Gains Haste I while underground.
* Underground detection should use a configurable Y level.
* Haste should disappear when the player is above the configured Y level.
* No manual activation.
### Vampire
* When damaging another player with a melee attack, has a configurable chance to heal a small amount of health.
* Cannot heal above maximum health.
* Configure healing amount and chance.
### Archer
* When damaging another player using a bow or crossbow, automatically receives a configurable bonus effect.
* Include a configurable cooldown.
* No manual activation.
### Phoenix
* When the player would die, automatically prevent the death if the cooldown has expired.
* Restore a configurable amount of health.
* Play configurable particles and sounds.
* The ability must have a configurable cooldown.
* It cannot trigger repeatedly during the same damage/death event.
* No manual activation.
---
# BAD TRAITS
Bad traits should be passive traits with disadvantages or risky effects.
Create:
### Berserker
* When below a configurable health threshold, the player gains Strength I.
* This is technically beneficial, but the trait should include a configurable drawback such as reduced defensive capability or another passive disadvantage.
* The effect automatically disappears when the player rises above the threshold.
* No manual activation.
* All values configurable.
### Tank
* Takes reduced incoming damage.
* Movement speed is slightly reduced.
* Both values must be configurable.
* The defensive advantage should be balanced by the movement penalty.
* Effects are always passive.
### Assassin
* Gains Speed I while sneaking.
* Gains a short Speed II burst after attacking another player.
* Include a configurable cooldown.
* No manual activation.
### Frost
* When attacking another player, has a configurable chance to apply Slowness for a short duration.
* Include cooldown protection.
* No manual activation.
### Enderman
* Gains configurable bonuses while inside The End.
* Has a configurable chance to teleport a short distance when taking damage.
* Teleport distance and chance must be configurable.
* No manual activation.
---
# TRAIT SYSTEM ARCHITECTURE
Create a clean interface or abstract class for traits.
Required classes:
```text
me.traitsmp.TraitSMP
me.traitsmp.commands.TraitCommand
me.traitsmp.commands.TraitTabCompleter
me.traitsmp.traits.Trait
me.traitsmp.traits.TraitManager
me.traitsmp.traits.impl.BerserkerTrait
me.traitsmp.traits.impl.TankTrait
me.traitsmp.traits.impl.AssassinTrait
me.traitsmp.traits.impl.VampireTrait
me.traitsmp.traits.impl.MinerTrait
me.traitsmp.traits.impl.ArcherTrait
me.traitsmp.traits.impl.PhoenixTrait
me.traitsmp.traits.impl.FrostTrait
me.traitsmp.traits.impl.EndermanTrait
me.traitsmp.traits.impl.GuardianTrait
me.traitsmp.data.PlayerDataManager
me.traitsmp.gui.TraitGUI
me.traitsmp.listeners.TraitListener
me.traitsmp.util.MessageUtil
me.traitsmp.util.CooldownManager
```
The architecture must make it easy to add new traits later.
Each trait should have information such as:
* ID
* Display name
* Description
* Category
* GUI icon
* Passive behavior
Use an enum for trait categories if appropriate:
```text
GOOD
BAD
```
Use UUIDs for player data and cooldown tracking.
Never permanently store Player objects.
---
# COMMANDS
Implement:
```text
/trait
```
Opens the player's trait GUI.
```text
/trait list
```
Shows all available traits separated into Good and Bad categories.
```text
/trait info
```
Shows information about a specific trait.
```text
/trait set
```
Admin command to assign a trait.
```text
/trait remove
```
Removes a player's trait.
```text
/trait reload
```
Reloads config.yml and all configurable trait settings.
Permissions:
```text
traitsmp.admin
traitsmp.trait.set
traitsmp.trait.remove
traitsmp.reload
```
Make sensible permission handling so `/trait set` requires `traitsmp.trait.set`, `/trait remove` requires `traitsmp.trait.remove`, and `/trait reload` requires `traitsmp.reload`.
The normal `/trait`, `/trait list`, and `/trait info` commands should be available to regular players.
---
# TRAIT SETTING RULES
Players can only have one trait.
If an administrator gives a player another trait:
* Replace their existing trait.
* Remove the old trait's effects.
* Save the new trait.
* Notify the player.
* Broadcast the trait assignment.
* Send a title.
* Play the configured sound.
Do not allow duplicate trait assignments unnecessarily.
If the player already has the requested trait, send a configurable message saying they already have that trait.
When a trait is removed:
* Remove all trait-specific effects.
* Remove active potion effects caused by the trait.
* Clear the player's trait cooldowns.
* Save the removal.
* Notify the player.
Removing a trait must persist after restart.
---
# DATA STORAGE
Store player traits in:
```text
plugins/TraitSMP/data.yml
```
Format:
```yaml
players:
UUID:
trait: Berserker
```
Also store whether the player has completed first-join trait selection.
Example:
```yaml
players:
UUID:
trait: Guardian
selected: true
```
Data must survive:
* Server restart
* Plugin reload
* Player disconnect
* Player reconnect
Use safe YAML saving/loading.
Do not save Player objects.
---
# GUI
`/trait` must open a Minecraft inventory GUI.
The GUI must:
* Show the player's current trait.
* Show the trait display name.
* Show the category.
* Show a short description.
* Use different item icons for different traits.
* Use clean names.
* Use clean lore.
* Prevent players from taking GUI items.
* Prevent item movement inside the GUI.
* Have configurable title and size.
For players without a trait, display:
```text
No Trait
```
with instructions explaining that their trait must be assigned.
Administrators should also be able to inspect another player's trait where practical.
---
# FIRST JOIN GUI
Create a dedicated first-join selection GUI.
Title:
```text
Choose Your Trait
```
Display two large choices:
```text
Good Traits
Bad Traits
```
Use appropriate Minecraft item icons.
Good Traits should have positive-looking descriptions.
Bad Traits should clearly explain that they contain disadvantages or risky passive effects.
After selecting a category, open the category trait GUI.
For example:
```text
Choose Your Trait
-----------------
[ Good Traits ] [ Bad Traits ]
```
Then:
```text
Choose a Good Trait
-------------------
[ Guardian ]
[ Miner ]
[ Vampire ]
[ Archer ]
[ Phoenix ]
```
And:
```text
Choose a Bad Trait
------------------
[ Berserker ]
[ Tank ]
[ Assassin ]
[ Frost ]
[ Enderman ]
```
The exact layout must be clean and configurable.
---
# GUI SAFETY
Players must not be able to:
* Take GUI items.
* Move GUI items.
* Place items inside the GUI.
* Drop GUI items.
* Shift-click GUI items.
All inventory interactions must be properly cancelled.
Use `InventoryHolder` or another reliable method to identify TraitSMP GUIs instead of relying only on inventory titles.
---
# CONFIGURATION
Create a complete:
```text
config.yml
```
All important values must be configurable.
Include:
```yaml
prefix: "&5&lTrait SMP &8Β» &7"
```
Include configuration sections for:
* General
* First Join
* GUI
* Good Traits
* Bad Traits
* Cooldowns
* Damage modifiers
* Health thresholds
* Effect durations
* Chances
* Healing
* Movement speed
* Particles
* Sounds
* Messages
Example structure:
```yaml
traits:
guardian:
enabled: true
health-threshold: 10.0
resistance-level: 1
miner:
enabled: true
underground-y: 50
haste-level: 1
vampire:
enabled: true
heal-chance: 20.0
heal-amount: 2.0
tank:
enabled: true
damage-reduction: 0.15
movement-speed-multiplier: 0.90
```
Use appropriate defaults for every trait.
Do not hardcode important gameplay values.
---
# MESSAGES
All player-facing messages must be configurable.
Include messages for:
* Trait assigned
* Trait removed
* Already has trait
* No trait
* Invalid trait
* Invalid player
* No permission
* Reload successful
* First join
* Good trait selection
* Bad trait selection
* Trait selection completed
* Trait information
* Trait list
Use:
```text
&5&lTrait SMP &8Β» &7
```
as the default prefix.
Use Adventure/MiniMessage where appropriate for modern Paper formatting.
Support legacy color codes where practical.
---
# ASSIGNMENT EFFECTS
When a trait is assigned:
1. Remove the old trait effects.
2. Save the new trait.
3. Send the player a configurable message.
4. Broadcast a configurable message.
5. Send a title containing the trait display name.
6. Play a configurable sound.
7. Refresh the player's trait state.
Example broadcast:
```text
Trait SMP Β» Drayx has received the Guardian trait!
```
Do not broadcast duplicate messages.
---
# EVENT HANDLING
Use proper Bukkit/Paper events.
Handle relevant events including:
```text
PlayerJoinEvent
PlayerQuitEvent
EntityDamageByEntityEvent
EntityDamageEvent
EntityDeathEvent
PlayerInteractEvent
PlayerToggleSneakEvent
ProjectileHitEvent
ProjectileLaunchEvent
PlayerRespawnEvent
PlayerChangedWorldEvent
```
Only register events that are actually needed.
Do not create unnecessary repeating tasks.
Use event-driven logic whenever possible.
For effects that need state updates, use efficient scheduling only when necessary.
---
# BERSERKER
Implement:
* Configurable low-health threshold.
* Strength I below the threshold.
* Remove Strength when above threshold.
* Cooldown/state protection so effects are not repeatedly reapplied unnecessarily.
* Configurable drawback so the trait remains a Bad Trait.
* No manual activation.
Do not spam potion-effect updates every tick.
---
# TANK
Implement:
* Configurable damage reduction.
* Configurable movement speed reduction.
* Damage reduction must work through damage events.
* Movement speed modifier must be safely applied and removed.
* Do not permanently stack attribute modifiers after reloads or trait changes.
Use a unique UUID for the custom attribute modifier.
---
# ASSASSIN
Implement:
* Speed I while sneaking.
* Speed II burst after attacking another player.
* Configurable duration.
* Configurable cooldown.
* Remove the sneak effect when the player stops sneaking.
* Do not stack duplicate modifiers/effects.
---
# VAMPIRE
Implement:
* Detect melee damage against another player.
* Configurable chance.
* Configurable healing amount.
* Never heal above maximum health.
* Only trigger for the correct melee damage sources.
* Do not trigger from arrows or unrelated damage.
---
# MINER
Implement:
* Configurable underground Y coordinate.
* Haste I underground.
* Remove Haste when above the configured Y level.
* Do not continuously spam effect applications.
---
# ARCHER
Implement:
* Detect bow/crossbow attacks.
* Configurable bonus potion effect.
* Configurable effect level.
* Configurable duration.
* Configurable cooldown.
* Only trigger when the projectile actually damages another player.
---
# PHOENIX
Implement:
* Detect lethal damage.
* Check Phoenix cooldown.
* Prevent death.
* Restore configurable health.
* Do not allow health to exceed maximum.
* Play configurable sound.
* Spawn configurable particles.
* Start cooldown immediately when activated.
* Prevent multiple triggers from the same event.
The cooldown must survive normal event processing and prevent repeated activation.
---
# FROST
Implement:
* Detect attacks against players.
* Configurable chance to apply Slowness.
* Configurable duration.
* Configurable amplifier.
* Configurable cooldown.
* Do not repeatedly stack unnecessary Slowness effects.
---
# ENDERMAN
Implement:
* Detect when player is in The End.
* Apply configurable passive bonuses.
* Detect incoming damage.
* Configurable teleport chance.
* Configurable teleport distance.
* Safely find a valid destination.
* Never teleport into blocks, lava, or unsafe locations.
* Play configurable sound/particles.
* Include cooldown protection.
---
# GUARDIAN
Implement:
* Configurable health threshold.
* Resistance I below the threshold.
* Remove Resistance above the threshold.
* No manual activation.
* Do not repeatedly spam potion effects.
---
# COOLDOWN SYSTEM
Create:
```text
me.traitsmp.util.CooldownManager
```
It should support:
* Start cooldown.
* Check cooldown.
* Get remaining cooldown.
* Remove cooldown.
* Clear all cooldowns for a UUID.
Use UUIDs rather than Player objects.
Clean cooldown data when players quit.
Do not create unnecessary scheduled tasks.
---
# TRAIT MANAGER
Create:
```text
me.traitsmp.traits.TraitManager
```
It should:
* Register all traits.
* Retrieve traits by ID.
* Retrieve traits by display name.
* Check if a trait exists.
* Get all traits.
* Get Good Traits.
* Get Bad Traits.
* Assign traits.
* Remove traits.
* Handle trait replacement.
* Provide trait information.
Avoid hardcoding trait behavior inside the command class.
---
# PLAYER DATA MANAGER
Create:
```text
me.traitsmp.data.PlayerDataManager
```
It should:
* Load `data.yml`.
* Save `data.yml`.
* Get player trait.
* Set player trait.
* Remove player trait.
* Check whether first-join selection is complete.
* Mark selection as complete.
* Save safely.
* Reload safely.
---
# MESSAGE UTIL
Create:
```text
me.traitsmp.util.MessageUtil
```
It should handle:
* Prefix replacement.
* Color formatting.
* MiniMessage where appropriate.
* Sending messages.
* Sending titles.
* Sending action bars if needed.
Avoid duplicating formatting code throughout the plugin.
---
# TAB COMPLETION
Create:
```text
me.traitsmp.commands.TraitTabCompleter
```
Provide completion for:
```text
/trait
/trait list
/trait info
/trait set
/trait remove
/trait reload
```
Examples:
```text
/trait
list
info
set
remove
reload
```
For:
```text
/trait info
```
show available traits.
For:
```text
/trait set
```
show online players.
For:
```text
/trait set Player
```
show available traits.
For:
```text
/trait remove
```
show online players.
Do not show offline players where online players are specifically requested.
Use `String`/`string` command argument handling compatible with the implementation.
---
# PLUGIN LIFECYCLE
Main class:
```text
me.traitsmp.TraitSMP
```
It should:
* Initialize configuration.
* Initialize PlayerDataManager.
* Initialize CooldownManager.
* Initialize TraitManager.
* Register all traits.
* Register commands.
* Register tab completion.
* Register listeners.
* Load data.
* Save data safely on disable.
* Clean up active effects/modifiers/tasks.
Do not leave resources running after plugin disable.
---
# PLUGIN.YML
Create a valid:
```text
plugin.yml
```
with:
* Name
* Version
* Main
* API version
* Commands
* Permissions
Use:
```text
TraitSMP
```
as the plugin name.
Main:
```text
me.traitsmp.TraitSMP
```
---
# GRADLE
Create:
```text
build.gradle
settings.gradle
gradle.properties
```
Use the correct Paper API dependency for Minecraft 1.21.11.
Use Java 21.
Configure Gradle correctly for:
```text
./gradlew build
```
The final JAR should be generated in:
```text
build/libs/
```
The project must compile without errors or warnings caused by incorrect API usage.
Use modern Paper APIs wherever possible.
---
# PROJECT STRUCTURE
Provide the complete project structure first.
It should look similar to:
```text
TraitSMP/
βββ build.gradle
βββ settings.gradle
βββ gradle.properties
βββ gradlew
βββ gradlew.bat
βββ gradle/
β βββ wrapper/
βββ src/
β βββ main/
β βββ java/
β β βββ me/
β β βββ traitsmp/
β β βββ TraitSMP.java
β β βββ commands/
β β β βββ TraitCommand.java
β β β βββ TraitTabCompleter.java
β β βββ traits/
β β β βββ Trait.java
β β β βββ TraitManager.java
β β β βββ impl/
β β β βββ BerserkerTrait.java
β β β βββ TankTrait.java
β β β βββ AssassinTrait.java
β β β βββ VampireTrait.java
β β β βββ MinerTrait.java
β β β βββ ArcherTrait.java
β β β βββ PhoenixTrait.java
β β β βββ FrostTrait.java
β β β βββ EndermanTrait.java
β β β βββ GuardianTrait.java
β β βββ data/
β β β βββ PlayerDataManager.java
β β βββ gui/
β β β βββ TraitGUI.java
β β βββ listeners/
β β β βββ TraitListener.java
β β βββ util/
β β βββ MessageUtil.java
β β βββ CooldownManager.java
β βββ resources/
β βββ plugin.yml
β βββ config.yml
```
Provide the complete contents of every file.
---
# CODE QUALITY
The code should look like it was written by an experienced Minecraft Java developer.
Do not make the code unnecessarily complicated.
Use:
* Clear class names.
* Clear method names.
* Proper encapsulation.
* Small reusable methods.
* UUID-based data.
* Safe configuration access.
* Proper event handling.
* Proper cleanup.
* No unnecessary repeating tasks.
* No memory leaks.
Do not put the entire plugin into one Java file.
Do not use fake APIs or methods that do not exist in Paper 1.21.11.
Make sure every import is valid.
Make sure every class compiles against the selected Paper API.
---
# EXACT SETUP INSTRUCTIONS
After providing all source files, explain exactly:
## 1. Creating the project
Explain where every folder and file needs to be created.
## 2. Installing Java 21
Explain how to verify Java:
```text
java -version
```
## 3. Running Gradle
Explain:
```text
./gradlew build
```
Also provide the Windows command:
```text
gradlew.bat build
```
## 4. Finding the JAR
Explain that the generated plugin will be inside:
```text
build/libs/
```
## 5. Installing the plugin
Explain how to copy the generated JAR into:
```text
server/plugins/
```
Then restart the Paper server.
## 6. Configuring traits
Explain:
```text
plugins/TraitSMP/config.yml
```
and:
```text
plugins/TraitSMP/data.yml
```
Explain what the important trait settings control.
## 7. Commands
Provide a complete command list:
```text
/trait
/trait list
/trait info
/trait set
/trait remove
/trait reload
```
Also provide all required permissions.
---
# IMPORTANT FINAL REQUIREMENTS
The final answer must contain:
1. Complete project structure.
2. Complete `build.gradle`.
3. Complete `settings.gradle`.
4. Complete `gradle.properties`.
5. Complete `plugin.yml`.
6. Complete `config.yml`.
7. Complete `TraitSMP.java`.
8. Complete `Trait.java`.
9. Complete `TraitManager.java`.
10. Complete every trait implementation.
11. Complete `PlayerDataManager.java`.
12. Complete `TraitGUI.java`.
13. Complete `TraitListener.java`.
14. Complete `MessageUtil.java`.
15. Complete `CooldownManager.java`.
16. Complete `TraitCommand.java`.
17. Complete `TraitTabCompleter.java`.
18. Exact build instructions.
19. Exact installation instructions.
20. Exact configuration instructions.
21. Exact command and permission documentation.
Everything must be copy-paste ready.
Do not omit any source file.
Do not use placeholders.
Do not say that something is left for the user to implement.
Make the implementation compatible with Minecraft 1.21.11, Paper, and Java 21.
Set up the Java 21/Paper Gradle project and plugin configuration.
Implement persistent player data, trait registration, assignment, cooldowns, and messages.
Add all ten passive traits, event handling, commands, and protected selection/status GUIs.
Created the TraitSMP project with the requested Java 21, Paper, Gradle, trait, GUI, command, listener, and persistence files.
TraitSMP/
βββ build.gradle
βββ settings.gradle
βββ gradle.properties
βββ gradlew
βββ gradlew.bat
βββ src/main/
βββ java/me/traitsmp/
β βββ TraitSMP.java
β βββ commands/
β β βββ TraitCommand.java
β β βββ TraitTabCompleter.java
β βββ data/PlayerDataManager.java
β βββ gui/TraitGUI.java
β βββ listeners/TraitListener.java
β βββ traits/
β β βββ Trait.java
β β βββ TraitManager.java
β β βββ impl/
β β βββ GuardianTrait.java
β β βββ MinerTrait.java
β β βββ VampireTrait.java
β β βββ ArcherTrait.java
β β βββ PhoenixTrait.java
β β βββ BerserkerTrait.java
β β βββ TankTrait.java
β β βββ AssassinTrait.java
β β βββ FrostTrait.java
β β βββ EndermanTrait.java
β βββ util/
β βββ CooldownManager.java
β βββ MessageUtil.java
βββ resources/
βββ config.yml
βββ plugin.yml
Build
Install Java 21 and verify it with:
java -version
From the project root, build with:
./gradlew build
On macOS/Linux, if needed, first run chmod +x gradlew. The launcher downloads Gradle 8.14.3 on its first run. On Windows, use:
gradlew.bat build
The plugin JAR is generated in build/libs/, named TraitSMP-1.0.0.jar.
Install and configure
Copy the JAR into server/plugins/, then restart the Paper server. Edit gameplay settings and messages in plugins/TraitSMP/config.yml. Player assignments and first-selection completion are stored in plugins/TraitSMP/data.yml.
The config includes each traitβs thresholds, chances, durations, cooldowns, damage adjustments, effects, movement settings, particles, and sounds. Trait settings can be reloaded with /trait reload.
Commands and permissions
/traitβ open your trait GUI/trait listβ list Good and Bad traits/trait info <trait>β show trait details/trait set <player> <trait>β assign or replace a trait/trait remove <player>β remove a playerβs trait/trait reloadβ reload config and player data
Permissions: traitsmp.admin grants the admin permissions; individual nodes are traitsmp.trait.set, traitsmp.trait.remove, and traitsmp.reload.
package me.traitsmp;
import me.traitsmp.commands.TraitCommand;
import me.traitsmp.commands.TraitTabCompleter;
import me.traitsmp.data.PlayerDataManager;
import me.traitsmp.listeners.TraitListener;
import me.traitsmp.traits.TraitManager;
import me.traitsmp.util.CooldownManager;
import me.traitsmp.util.MessageUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
public final class TraitSMP extends JavaPlugin {
private PlayerDataManager playerDataManager;
private CooldownManager cooldownManager;
private TraitManager traitManager;
private MessageUtil messageUtil;
private BukkitTask refreshTask;
@Override public void onEnable() {
saveDefaultConfig();
messageUtil = new MessageUtil(this);
playerDataManager = new PlayerDataManager(getDataFolder(), getLogger());
cooldownManager = new CooldownManager();
traitManager = new TraitManager(this, cooldownManager);
TraitCommand command = new TraitCommand(this);
if (getCommand("trait") != null) {
getCommand("trait").setExecutor(command);
getCommand("trait").setTabCompleter(new TraitTabCompleter(this));
}
Bukkit.getPluginManager().registerEvents(new TraitListener(this), this);
scheduleRefresh();
for (Player player : Bukkit.getOnlinePlayers()) traitManager.refresh(player);
}
private void scheduleRefresh() {
long period = Math.max(10, getConfig().getLong("general.refresh-period-ticks", 20));
refreshTask = Bukkit.getScheduler().runTaskTimer(this, () -> {
for (Player player : Bukkit.getOnlinePlayers()) traitManager.refresh(player);
}, period, period);
}
public void reloadPluginConfig() {
traitManager.cleanupAll();
reloadConfig();
playerDataManager.reload();
if (refreshTask != null) refreshTask.cancel();
scheduleRefresh();
for (Player player : Bukkit.getOnlinePlayers()) traitManager.refresh(player);
}
@Override public void onDisable() {
if (refreshTask != null) refreshTask.cancel();
if (traitManager != null) traitManager.cleanupAll();
if (playerDataManager != null) playerDataManager.save();
}
public PlayerDataManager getPlayerDataManager() { return playerDataManager; }
public CooldownManager getCooldownManager() { return cooldownManager; }
public TraitManager getTraitManager() { return traitManager; }
public MessageUtil getMessageUtil() { return messageUtil; }
}