Merge remote-tracking branch 'origin/v7.0' into v7.0

This commit is contained in:
Esophose 2019-12-28 18:02:32 -07:00
commit c0c9ef48ce
132 changed files with 5985 additions and 4833 deletions

17
.github/workflows/gradle.yml vendored Normal file
View file

@ -0,0 +1,17 @@
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Gradle
run: ./gradlew build

28
.gitignore vendored
View file

@ -1,31 +1,9 @@
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.settings
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/.gradle/
/.settings/
.idea/
build/
target/
*.iml
/bin/
/bin/
/doc/
/images/

View file

@ -7,6 +7,7 @@ plugins {
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
group = 'dev.esophose.playerparticles'
version = '7.0'
@ -16,19 +17,21 @@ repositories {
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'https://repo.codemc.org/repository/maven-public' }
maven { url = 'http://repo.extendedclip.com/content/repositories/placeholderapi/' }
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'org.slf4j:slf4j-nop:1.7.25'
compile 'com.zaxxer:HikariCP:3.2.0'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
shadow 'org.xerial:sqlite-jdbc:3.23.1'
shadow 'org.spigotmc:spigot-api:1.14.3-R0.1-SNAPSHOT'
shadow 'me.clip:placeholderapi:2.10.4'
shadow 'org.xerial:sqlite-jdbc:3.23.1'
shadow 'org.spigotmc:spigot-api:1.15-R0.1-SNAPSHOT'
}
shadowJar {
archiveClassifier.set(null)
minimize()
}
processResources {

View file

@ -1,22 +1,18 @@
=== v7.0 ===
* Huge changes
* The config will no longer reset for each and every update
+ Added settings for each effect located in the /effects folder
+ Added settings for each style located in the /styles folder
+ All command and parameter names can now be edited in the new commands.yml file
+ Added support for what I'm calling language packs
- Language packs have the ability to overwrite any message in the plugin
+ Added de_DE language pack
+ Added language settings for all material names which can be changed in a languge pack
* The command '/pp fixed clear <radius>' now accepts an optional location/world as '/pp fixed clear <radius> [<x> <y> <z> [world]]'
+ Added setting 'allow-duplicate-styles' which, when false, will not allow 2 particles with the same style to display at the same time.
- For example, doing '/pp add flame spiral' then '/pp add witchmagic spiral' will only keep the effect of 'witchmagic'
* Effect/Style permissions are no longer required for a player to have particles applied to them
- This mainly changes '/ppo' to allow any command to execute successfully
+ Added a developer API for editing particles, groups, and fixed effects for players
+ Added support for Minecraft 1.15 particles, the future is now
- 'falling_honey', 'falling_nectar', 'landing_honey'
+ Added support for 1.8.8 for those who refuse to accept the future (this is the only version of 1.8.x that will be supported, I will eventually drop support for it again in the future)
* Coming soon
=== v6.6 ===
+ Added support for Minecraft 1.15
+ Added 1.15 effects: 'dripping_honey', 'falling_honey', 'falling_nectar', and 'landing_honey'
+ Added new lang file de_DE.lang (German)
* Fixed an issue where the 'arrows' style wouldn't load properly with preset groups
* Fixed an issue where shooting an arrow into a portal would throw errors
=== v6.5 ===
+ Added Russian translation file ru_RU.lang
+ Added slightly better vanish plugin support
* Players no longer need an effect permission to open the GUI when gui-presets-only is true in the config.yml
* Fixed error with the celebration style
* Fixed error with the arrows style in 1.14+
* Fixed '/pp reload' not being allowed from console
=== v6.4 ===
+ Added support for Minecraft 1.14
+ Added 1.14 effects: 'campfire_cosy_smoke', 'campfire_signal_smoke', 'composter', 'falling_lava', 'falling_water', 'landing_lava', 'sneeze'

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

4
gradlew vendored Normal file → Executable file
View file

@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

View file

@ -1,184 +1,140 @@
/*
* TODO: v6.4
* TODO: v7.0
* * Added an API, accessible through the dev.esophose.playerparticles.api.PlayerParticlesAPI class
* + Add ability to create/manage fixed effects from the GUI
* * Convert fixed effect ids into names
* + Add command '/pp fixed teleport <id>' that requires the permission playerparticles.fixed.teleport
* + Add named colors to the color data
* + Add named colors to the color data autocomplete
* * Clean up duplicated command parsing
*/
/*
* TODO: v6.5
* + Add effect/style name customization through config files
* + Add effect/style settings folder that lets you disable effects/style and edit style properties
* + Added PlaceholderAPI support for message strings
* + Added setting to disable particles while in combat
*/
/*
* * Refactored and cleaned up code to remove static abuse
* * Changed the package names
* + Config and lang files will no longer reset every update
* + Added PlaceholderAPI support (no placeholders, just placeholder replacing in messages)
*/
package dev.esophose.playerparticles;
import java.io.File;
import dev.esophose.playerparticles.command.ParticleCommandHandler;
import dev.esophose.playerparticles.database.DatabaseConnector;
import dev.esophose.playerparticles.database.MySqlDatabaseConnector;
import dev.esophose.playerparticles.database.SqliteDatabaseConnector;
import dev.esophose.playerparticles.gui.GuiHandler;
import dev.esophose.playerparticles.gui.hook.PlayerChatHook;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.CommandManager;
import dev.esophose.playerparticles.manager.ConfigurationManager;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.DataMigrationManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.Manager;
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.manager.SettingManager;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.PluginUpdateManager;
import dev.esophose.playerparticles.particles.PPlayerMovementListener;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.updater.DataUpdater;
import dev.esophose.playerparticles.updater.PluginUpdateListener;
import dev.esophose.playerparticles.updater.Updater;
import dev.esophose.playerparticles.util.Metrics;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
/**
* @author Esophose
*/
public class PlayerParticles extends JavaPlugin {
/**
* The running instance of PlayerParticles on the server
*/
private static PlayerParticles pluginInstance;
private static PlayerParticles INSTANCE;
/**
* The version a new update has, will be null if the config has it disabled
* or if there is no new version
/*
* The plugin managers
*/
private String updateVersion = null;
/**
* The database connection manager
*/
private DatabaseConnector databaseConnector = null;
/**
* The task that spawns the particles
*/
private BukkitTask particleTask = null;
private Map<Class<?>, Manager> managers;
/**
* Executes essential tasks for starting up the plugin
*/
@Override
public void onEnable() {
pluginInstance = (PlayerParticles) Bukkit.getServer().getPluginManager().getPlugin("PlayerParticles");
this.registerCommands();
INSTANCE = this;
this.managers = new HashMap<>();
this.reload();
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new ParticleManager(), this);
pm.registerEvents(new PluginUpdateListener(), this);
pm.registerEvents(new GuiHandler(), this);
pm.registerEvents(new PPlayerMovementListener(), this);
pm.registerEvents(new PlayerChatHook(), this);
this.saveDefaultConfig();
double configVersion = PSetting.VERSION.getDouble();
double currentVersion = Double.parseDouble(this.getDescription().getVersion());
boolean updatePluginSettings = configVersion < currentVersion;
if (updatePluginSettings) {
this.configureDatabase(PSetting.DATABASE_ENABLE.getBoolean());
DataUpdater.updateData(configVersion, currentVersion);
this.databaseConnector.closeConnection();
this.databaseConnector = null;
File configFile = new File(this.getDataFolder(), "config.yml");
if (configFile.exists()) {
configFile.delete();
}
this.saveDefaultConfig();
this.reloadConfig();
this.getLogger().warning("The config.yml has been updated to v" + this.getDescription().getVersion() + "!");
}
if (PSetting.CHECK_UPDATES.getBoolean()) {
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
try { // This can throw an exception if the server has no internet connection or if the Curse API is down
Updater updater = new Updater(pluginInstance, 82823, getFile(), Updater.UpdateType.NO_DOWNLOAD, false);
if (Double.parseDouble(updater.getLatestName().replaceAll("PlayerParticles v", "")) > Double.parseDouble(getPlugin().getDescription().getVersion())) {
updateVersion = updater.getLatestName().replaceAll("PlayerParticles v", "");
getLogger().info("An update (v" + updateVersion + ") is available! You are running v" + getPlugin().getDescription().getVersion());
}
} catch (Exception e) {
getLogger().warning("An error occurred checking for an update. There is either no established internet connection or the Curse API is down.");
}
});
}
if (PSetting.SEND_METRICS.getBoolean()) {
if (Setting.SEND_METRICS.getBoolean())
new Metrics(this);
}
this.reload(updatePluginSettings);
}
/**
* Clean up database connection if it's open
* Close all users with an open PlayerParticles GUI
*/
@Override
public void onDisable() {
this.databaseConnector.closeConnection();
GuiHandler.forceCloseAllOpenGUIs();
this.managers.values().forEach(Manager::disable);
this.managers.clear();
}
/**
* Registers the commands for the plugin
*/
private void registerCommands() {
ParticleCommandHandler pch = new ParticleCommandHandler();
PluginCommand pp = this.getCommand("pp");
PluginCommand ppo = this.getCommand("ppo");
if (pp == null || ppo == null) {
Bukkit.getPluginManager().disablePlugin(this);
return;
/**
* Gets a manager instance
*
* @param managerClass The class of the manager instance to get
* @param <T> The manager type
* @return The manager instance or null if one does not exist
*/
@SuppressWarnings("unchecked")
public <T extends Manager> T getManager(Class<T> managerClass) {
if (this.managers.containsKey(managerClass))
return (T) this.managers.get(managerClass);
try {
T manager = managerClass.getConstructor(this.getClass()).newInstance(this);
this.managers.put(managerClass, manager);
manager.reload();
return manager;
} catch (ReflectiveOperationException ex) {
ex.printStackTrace();
return null;
}
pp.setTabCompleter(pch);
pp.setExecutor(pch);
ppo.setTabCompleter(pch);
ppo.setExecutor(pch);
}
/**
* Returns the file which contains this plugin
* Exposes the JavaPlugin.getFile() method
*
* @return File containing this plugin
*/
public File getJarFile() {
return this.getFile();
}
/**
* Reloads the settings of the plugin
*
* @param updatePluginSettings True if the settings should be updated to the latest version of the plugin
* Reloads the plugin
*/
public void reload(boolean updatePluginSettings) {
this.reloadConfig();
// If not null, plugin is already loaded
if (this.particleTask != null) {
this.particleTask.cancel();
this.particleTask = null;
this.databaseConnector.closeConnection();
this.databaseConnector = null;
GuiHandler.forceCloseAllOpenGUIs();
} else {
DefaultStyles.registerStyles(); // Only ever load styles once
}
// This runs before the SettingManager is reloaded, the credentials will not be stored in memory for more than a few milliseconds
this.configureDatabase(PSetting.DATABASE_ENABLE.getBoolean());
DataUpdater.tryCreateTables();
SettingManager.reload();
LangManager.reload(updatePluginSettings);
ParticleGroupPresetManager.reload();
GuiHandler.setup();
public void reload() {
this.managers.values().forEach(Manager::disable);
this.managers.clear();
this.getManager(CommandManager.class);
this.getManager(ParticleStyleManager.class);
this.getManager(ParticleGroupPresetManager.class);
this.getManager(ConfigurationManager.class);
this.getManager(DataMigrationManager.class);
this.getManager(PluginUpdateManager.class);
this.getManager(ParticleManager.class);
this.getManager(LocaleManager.class);
this.getManager(ConfigurationManager.class);
this.getManager(PermissionManager.class);
this.getManager(PluginUpdateManager.class);
PlayerChatHook.setup();
ParticleManager.refreshData();
this.startParticleTask();
}
/**
@ -186,61 +142,8 @@ public class PlayerParticles extends JavaPlugin {
*
* @return The PlayerParticles plugin instance
*/
public static PlayerParticles getPlugin() {
return pluginInstance;
}
/**
* Gets the DatabaseConnector that allows querying the database
*
* @return The DatabaseConnector
*/
public DatabaseConnector getDBConnector() {
return this.databaseConnector;
}
/**
* Gets the latest available version of the plugin
* Will be null if no update is available
*
* @return The latest version available for the plugin
*/
public String getUpdateVersion() {
return this.updateVersion;
}
/**
* Determines if we should use MySQL or SQLite based on the useMySql parameter and if we were able to connect successfully
*
* @param useMySql If we should use MySQL as the database type, if false, uses SQLite
*/
private void configureDatabase(boolean useMySql) {
if (useMySql) {
this.databaseConnector = new MySqlDatabaseConnector();
} else {
try {
Class.forName("org.sqlite.JDBC"); // This is required to put here for Spigot 1.9 and 1.10 for some reason
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
this.databaseConnector = new SqliteDatabaseConnector(this.getDataFolder().getAbsolutePath());
}
if (!this.databaseConnector.isInitialized()) {
this.getLogger().severe("Unable to connect to the MySQL database! Is your login information correct? Falling back to SQLite database instead.");
this.configureDatabase(false);
}
}
/**
* Starts the task responsible for spawning particles
* Run in the synchronous task so it starts after all plugins have loaded, including extensions
*/
private void startParticleTask() {
Bukkit.getScheduler().runTaskLater(pluginInstance, () -> {
long ticks = PSetting.TICKS_PER_PARTICLE.getLong();
this.particleTask = new ParticleManager().runTaskTimer(pluginInstance, 5, ticks);
}, 1);
public static PlayerParticles getInstance() {
return INSTANCE;
}
}

View file

@ -0,0 +1,7 @@
package dev.esophose.playerparticles.api;
public final class PlayerParticlesAPI {
}

View file

@ -1,18 +1,9 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.styles.api.ParticleStyleManager;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
@ -21,6 +12,14 @@ import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
public class AddCommandModule implements CommandModule {
@ -29,28 +28,31 @@ public class AddCommandModule implements CommandModule {
CommandModule.printUsage(pplayer, this);
return;
}
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
int maxParticlesAllowed = PermissionManager.getMaxParticlesAllowed(pplayer.getPlayer());
int maxParticlesAllowed = permissionManager.getMaxParticlesAllowed(pplayer.getPlayer());
if (pplayer.getActiveParticles().size() >= maxParticlesAllowed) {
LangManager.sendMessage(pplayer, Lang.ADD_REACHED_MAX, maxParticlesAllowed);
localeManager.sendMessage(pplayer, "add-reached-max", StringPlaceholders.single("amount", maxParticlesAllowed));
return;
}
ParticleEffect effect = ParticleEffect.fromName(args[0]);
if (effect == null) {
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
localeManager.sendMessage(pplayer, "effect-invalid", StringPlaceholders.single("effect", args[0]));
return;
} else if (!PermissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
LangManager.sendMessage(pplayer, Lang.EFFECT_NO_PERMISSION, effect.getName());
} else if (!permissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
localeManager.sendMessage(pplayer, "effect-no-permission", StringPlaceholders.single("effect", effect.getName()));
return;
}
ParticleStyle style = ParticleStyle.fromName(args[1]);
if (style == null) {
LangManager.sendMessage(pplayer, Lang.STYLE_INVALID, args[1]);
localeManager.sendMessage(pplayer, "style-invalid", StringPlaceholders.single("style", args[1]));
return;
} else if (!PermissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
LangManager.sendMessage(pplayer, Lang.STYLE_NO_PERMISSION, args[1]);
} else if (!permissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
localeManager.sendMessage(pplayer, "style-no-permission", StringPlaceholders.single("style", args[1]));
return;
}
@ -71,12 +73,12 @@ public class AddCommandModule implements CommandModule {
try {
note = Integer.parseInt(args[2]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
localeManager.sendMessage(pplayer, "data-invalid-note");
return;
}
if (note < 0 || note > 24) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
localeManager.sendMessage(pplayer, "data-invalid-note");
return;
}
@ -95,12 +97,12 @@ public class AddCommandModule implements CommandModule {
g = Integer.parseInt(args[3]);
b = Integer.parseInt(args[4]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_COLOR);
localeManager.sendMessage(pplayer, "data-invalid-color");
return;
}
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_COLOR);
localeManager.sendMessage(pplayer, "data-invalid-color");
return;
}
@ -113,7 +115,7 @@ public class AddCommandModule implements CommandModule {
blockData = ParticleUtils.closestMatch(args[2]);
if (blockData == null || !blockData.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_BLOCK);
localeManager.sendMessage(pplayer, "data-invalid-block");
return;
}
} else if (effect == ParticleEffect.ITEM) {
@ -121,7 +123,7 @@ public class AddCommandModule implements CommandModule {
itemData = ParticleUtils.closestMatch(args[2]);
if (itemData == null || itemData.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_ITEM);
localeManager.sendMessage(pplayer, "data-invalid-item");
return;
}
}
@ -131,24 +133,28 @@ public class AddCommandModule implements CommandModule {
ParticleGroup group = pplayer.getActiveParticleGroup();
ParticlePair newParticle = new ParticlePair(pplayer.getUniqueId(), pplayer.getNextActiveParticleId(), effect, style, itemData, blockData, colorData, noteColorData);
group.getParticles().add(newParticle);
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
StringPlaceholders addParticlePlaceholders = StringPlaceholders.builder("effect", newParticle.getEffect().getName())
.addPlaceholder("style", newParticle.getStyle().getName())
.addPlaceholder("data", newParticle.getDataString()).build();
localeManager.sendMessage(pplayer, "add-particle-applied", addParticlePlaceholders);
LangManager.sendMessage(pplayer, Lang.ADD_PARTICLE_APPLIED, newParticle.getEffect().getName(), newParticle.getStyle().getName(), newParticle.getDataString());
if (ParticleStyleManager.isCustomHandled(newParticle.getStyle())) {
LangManager.sendMessage(pplayer, Lang.STYLE_EVENT_SPAWNING_INFO, newParticle.getStyle().getName());
if (PlayerParticles.getInstance().getManager(ParticleStyleManager.class).isCustomHandled(newParticle.getStyle())) {
localeManager.sendMessage(pplayer, "style-event-spawning-info", StringPlaceholders.single("style", newParticle.getStyle().getName()));
}
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
Player p = pplayer.getPlayer();
List<String> matches = new ArrayList<>();
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
if (args.length <= 1) { // Effect name
if (args.length == 0) matches = PermissionManager.getEffectNamesUserHasPermissionFor(p);
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectNamesUserHasPermissionFor(p), matches);
if (args.length == 0) matches = permissionManager.getEffectNamesUserHasPermissionFor(p);
else StringUtil.copyPartialMatches(args[0], permissionManager.getEffectNamesUserHasPermissionFor(p), matches);
} else if (args.length == 2) { // Style name
StringUtil.copyPartialMatches(args[1], PermissionManager.getStyleNamesUserHasPermissionFor(p), matches);
StringUtil.copyPartialMatches(args[1], permissionManager.getStyleNamesUserHasPermissionFor(p), matches);
} else { // Data
ParticleEffect effect = ParticleEffect.fromName(args[0]);
if (effect != null) {
@ -191,8 +197,8 @@ public class AddCommandModule implements CommandModule {
return "add";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_ADD;
public String getDescriptionKey() {
return "command-description-add";
}
public String getArguments() {

View file

@ -1,10 +1,10 @@
package dev.esophose.playerparticles.command;
import java.util.List;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.List;
public interface CommandModule {
@ -33,11 +33,11 @@ public interface CommandModule {
String getName();
/**
* Gets the Lang description of this command
* Gets the locale description key of this command
*
* @return The description of this command
* @return The locale description key of this command
*/
Lang getDescription();
String getDescriptionKey();
/**
* Gets any arguments this command has
@ -65,7 +65,8 @@ public interface CommandModule {
* @param command The command to display usage for
*/
static void printUsage(PPlayer pplayer, CommandModule command) {
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_USAGE, command.getName(), command.getArguments());
StringPlaceholders placeholders = StringPlaceholders.builder("cmd", command.getName()).addPlaceholder("args", command.getArguments()).build();
PlayerParticles.getInstance().getManager(LocaleManager.class).sendMessage(pplayer, "command-descriptions-usage", placeholders);
}
/**
@ -75,10 +76,18 @@ public interface CommandModule {
* @param command The command to display usage for
*/
static void printUsageWithDescription(PPlayer pplayer, CommandModule command) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (command.getArguments().length() == 0) {
LangManager.sendSimpleMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_HELP_1, command.getName(), LangManager.getText(command.getDescription()));
StringPlaceholders placeholders = StringPlaceholders.builder("cmd", command.getName())
.addPlaceholder("desc", localeManager.getLocaleMessage(command.getDescriptionKey()))
.build();
localeManager.sendSimpleMessage(pplayer, "command-descriptions-help-1", placeholders);
} else {
LangManager.sendSimpleMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_HELP_2, command.getName(), command.getArguments(), LangManager.getText(command.getDescription()));
StringPlaceholders placeholders = StringPlaceholders.builder("cmd", command.getName())
.addPlaceholder("args", command.getArguments())
.addPlaceholder("desc", localeManager.getLocaleMessage(command.getDescriptionKey()))
.build();
localeManager.sendSimpleMessage(pplayer, "command-descriptions-help-2", placeholders);
}
}

View file

@ -1,7 +1,6 @@
package dev.esophose.playerparticles.command;
import java.util.List;
import org.bukkit.command.CommandSender;
public interface CommandModuleSecondary {

View file

@ -1,52 +1,57 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.util.StringUtil;
public class DataCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (args.length > 0) {
ParticleEffect effect = ParticleEffect.fromName(args[0]);
if (effect == null) {
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
localeManager.sendMessage(pplayer, "effect-invalid", StringPlaceholders.single("effect", args[0]));
return;
}
if (effect.hasProperty(ParticleProperty.COLORABLE)) {
if (effect == ParticleEffect.NOTE) {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_NOTE, effect.getName());
localeManager.sendMessage(pplayer, "data-usage-note", StringPlaceholders.single("effect", effect.getName()));
} else {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_COLOR, effect.getName());
localeManager.sendMessage(pplayer, "data-usage-color", StringPlaceholders.single("effect", effect.getName()));
}
} else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.ITEM) {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_ITEM, effect.getName());
localeManager.sendMessage(pplayer, "data-usage-item", StringPlaceholders.single("effect", effect.getName()));
} else {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_BLOCK, effect.getName());
localeManager.sendMessage(pplayer, "data-usage-block", StringPlaceholders.single("effect", effect.getName()));
}
} else {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_NONE, effect.getName());
localeManager.sendMessage(pplayer, "data-usage-none", StringPlaceholders.single("effect", effect.getName()));
}
} else {
LangManager.sendMessage(pplayer, Lang.DATA_NO_ARGS);
localeManager.sendMessage(pplayer, "data-no-args");
}
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
List<String> matches = new ArrayList<>();
if (args.length <= 1) {
if (args.length == 0) matches = PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer());
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()), matches);
if (args.length == 0) {
matches = permissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer());
} else {
StringUtil.copyPartialMatches(args[0], permissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()), matches);
}
}
return matches;
}
@ -55,8 +60,8 @@ public class DataCommandModule implements CommandModule {
return "data";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_DATA;
public String getDescriptionKey() {
return "command-description-data";
}
public String getArguments() {

View file

@ -1,23 +1,22 @@
package dev.esophose.playerparticles.command;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.CommandManager;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.particles.PPlayer;
public class DefaultCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
// The default command just opens the GUI, execute the GUICommandModule
ParticleCommandHandler.findMatchingCommand("gui").onCommandExecute(pplayer, new String[] { "_byDefault_" });
PlayerParticles.getInstance().getManager(CommandManager.class).findMatchingCommand("gui").onCommandExecute(pplayer, new String[] { "_byDefault_" });
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
List<String> matches = new ArrayList<>();
List<String> commandNames = ParticleCommandHandler.getCommandNames();
List<String> commandNames = PlayerParticles.getInstance().getManager(CommandManager.class).getCommandNames();
if (args.length == 0) return commandNames;
@ -30,8 +29,8 @@ public class DefaultCommandModule implements CommandModule {
return "";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_DEFAULT;
public String getDescriptionKey() {
return "command-description-default";
}
public String getArguments() {

View file

@ -1,29 +1,30 @@
package dev.esophose.playerparticles.command;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
public class EditCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (args.length < 3) {
CommandModule.printUsage(pplayer, this);
return;
@ -33,17 +34,17 @@ public class EditCommandModule implements CommandModule {
try {
id = Integer.parseInt(args[0]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.ID_INVALID);
localeManager.sendMessage(pplayer, "id-invalid");
return;
}
if (id <= 0) {
LangManager.sendMessage(pplayer, Lang.ID_INVALID);
localeManager.sendMessage(pplayer, "id-invalid");
return;
}
if (pplayer.getActiveParticle(id) == null) {
LangManager.sendMessage(pplayer, Lang.ID_UNKNOWN, id);
localeManager.sendMessage(pplayer, "id-unknown", StringPlaceholders.single("id", id));
return;
}
@ -61,7 +62,7 @@ public class EditCommandModule implements CommandModule {
this.editData(pplayer, id, cmdArgs);
break;
default:
LangManager.sendMessage(pplayer, Lang.EDIT_INVALID_PROPERTY, args[1]);
localeManager.sendMessage(pplayer, "edit-invalid-property", StringPlaceholders.single("prop", args[1]));
break;
}
}
@ -74,12 +75,14 @@ public class EditCommandModule implements CommandModule {
* @param args The rest of the args
*/
private void editEffect(PPlayer pplayer, int id, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
ParticleEffect effect = ParticleEffect.fromName(args[0]);
if (effect == null) {
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
localeManager.sendMessage(pplayer, "effect-invalid", StringPlaceholders.single("effect", args[0]));
return;
} else if (!PermissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
LangManager.sendMessage(pplayer, Lang.EFFECT_NO_PERMISSION, effect.getName());
} else if (!PlayerParticles.getInstance().getManager(PermissionManager.class).hasEffectPermission(pplayer.getPlayer(), effect)) {
localeManager.sendMessage(pplayer, "effect-no-permission", StringPlaceholders.single("effect", effect.getName()));
return;
}
@ -91,8 +94,8 @@ public class EditCommandModule implements CommandModule {
}
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
LangManager.sendMessage(pplayer, Lang.EDIT_SUCCESS_EFFECT, id, effect.getName());
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
localeManager.sendMessage(pplayer, "edit-success-effect", StringPlaceholders.builder("id", id).addPlaceholder("effect", effect.getName()).build());
}
/**
@ -103,12 +106,14 @@ public class EditCommandModule implements CommandModule {
* @param args The rest of the args
*/
private void editStyle(PPlayer pplayer, int id, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
ParticleStyle style = ParticleStyle.fromName(args[0]);
if (style == null) {
LangManager.sendMessage(pplayer, Lang.STYLE_INVALID, args[0]);
localeManager.sendMessage(pplayer, "style-invalid", StringPlaceholders.single("style", args[0]));
return;
} else if (!PermissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
LangManager.sendMessage(pplayer, Lang.STYLE_NO_PERMISSION, style.getName());
} else if (!PlayerParticles.getInstance().getManager(PermissionManager.class).hasStylePermission(pplayer.getPlayer(), style)) {
localeManager.sendMessage(pplayer, "style-no-permission", StringPlaceholders.single("style", style.getName()));
return;
}
@ -119,9 +124,9 @@ public class EditCommandModule implements CommandModule {
break;
}
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
LangManager.sendMessage(pplayer, Lang.EDIT_SUCCESS_STYLE, id, style.getName());
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
localeManager.sendMessage(pplayer, "edit-success-style", StringPlaceholders.builder("id", id).addPlaceholder("style", style.getName()).build());
}
/**
@ -132,6 +137,8 @@ public class EditCommandModule implements CommandModule {
* @param args The rest of the args
*/
private void editData(PPlayer pplayer, int id, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
Material itemData = null;
Material blockData = null;
OrdinaryColor colorData = null;
@ -150,12 +157,12 @@ public class EditCommandModule implements CommandModule {
try {
note = Integer.parseInt(args[0]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
localeManager.sendMessage(pplayer, "data-invalid-note");
return;
}
if (note < 0 || note > 24) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
localeManager.sendMessage(pplayer, "data-invalid-note");
return;
}
@ -174,12 +181,12 @@ public class EditCommandModule implements CommandModule {
g = Integer.parseInt(args[1]);
b = Integer.parseInt(args[2]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_COLOR);
localeManager.sendMessage(pplayer, "data-invalid-color");
return;
}
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_COLOR);
localeManager.sendMessage(pplayer, "data-invalid-color");
return;
}
@ -192,7 +199,7 @@ public class EditCommandModule implements CommandModule {
blockData = ParticleUtils.closestMatch(args[0]);
if (blockData == null || !blockData.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_BLOCK);
localeManager.sendMessage(pplayer, "data-invalid-block");
return;
}
} else if (effect == ParticleEffect.ITEM) {
@ -200,7 +207,7 @@ public class EditCommandModule implements CommandModule {
itemData = ParticleUtils.closestMatch(args[0]);
if (itemData == null || itemData.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_ITEM);
localeManager.sendMessage(pplayer, "data-invalid-item");
return;
}
}
@ -218,12 +225,13 @@ public class EditCommandModule implements CommandModule {
break;
}
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
LangManager.sendMessage(pplayer, Lang.EDIT_SUCCESS_DATA, id, updatedDataString);
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
localeManager.sendMessage(pplayer, "edit-success-data", StringPlaceholders.builder("id", id).addPlaceholder("data", updatedDataString).build());
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
Player p = pplayer.getPlayer();
List<String> matches = new ArrayList<>();
List<String> ids = new ArrayList<>();
@ -253,11 +261,11 @@ public class EditCommandModule implements CommandModule {
switch (args[1].toLowerCase()) {
case "effect":
if (args.length == 3)
StringUtil.copyPartialMatches(args[2], PermissionManager.getEffectNamesUserHasPermissionFor(p), matches);
StringUtil.copyPartialMatches(args[2], permissionManager.getEffectNamesUserHasPermissionFor(p), matches);
break;
case "style":
if (args.length == 3)
StringUtil.copyPartialMatches(args[2], PermissionManager.getStyleNamesUserHasPermissionFor(p), matches);
StringUtil.copyPartialMatches(args[2], permissionManager.getStyleNamesUserHasPermissionFor(p), matches);
break;
case "data":
ParticleEffect effect = pplayer.getActiveParticle(id).getEffect();
@ -302,8 +310,8 @@ public class EditCommandModule implements CommandModule {
return "edit";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_EDIT;
public String getDescriptionKey() {
return "command-description-edit";
}
public String getArguments() {

View file

@ -1,23 +1,24 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
public class EffectsCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
Player p = pplayer.getPlayer();
List<String> effectList = PermissionManager.getEffectNamesUserHasPermissionFor(p);
List<String> effectList = PlayerParticles.getInstance().getManager(PermissionManager.class).getEffectNamesUserHasPermissionFor(p);
if (effectList.isEmpty()) {
LangManager.sendMessage(pplayer, Lang.EFFECT_LIST_EMPTY);
localeManager.sendMessage(pplayer, "effect-list-empty");
return;
}
@ -30,7 +31,7 @@ public class EffectsCommandModule implements CommandModule {
toSend = new StringBuilder(toSend.substring(0, toSend.length() - 2));
}
LangManager.sendMessage(pplayer, Lang.EFFECT_LIST, toSend.toString());
localeManager.sendMessage(pplayer, "effect-list", StringPlaceholders.single("effects", toSend.toString()));
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
@ -41,8 +42,8 @@ public class EffectsCommandModule implements CommandModule {
return "effects";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_EFFECTS;
public String getDescriptionKey() {
return "command-description-effects";
}
public String getArguments() {

View file

@ -1,24 +1,8 @@
package dev.esophose.playerparticles.command;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.FixedParticleEffect;
@ -28,24 +12,41 @@ import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
public class FixedCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
Player p = pplayer.getPlayer();
if (!PermissionManager.canUseFixedEffects(p)) {
LangManager.sendMessage(pplayer, Lang.FIXED_NO_PERMISSION);
if (!PlayerParticles.getInstance().getManager(PermissionManager.class).canUseFixedEffects(p)) {
localeManager.sendMessage(pplayer, "fixed-no-permission");
return;
}
if (args.length == 0) { // General information on command
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_CREATE);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_EDIT);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_REMOVE);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_LIST);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_INFO);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_CLEAR);
localeManager.sendMessage(pplayer, "command-description-fixed-create");
localeManager.sendMessage(pplayer, "command-description-fixed-edit");
localeManager.sendMessage(pplayer, "command-description-fixed-remove");
localeManager.sendMessage(pplayer, "command-description-fixed-list");
localeManager.sendMessage(pplayer, "command-description-fixed-info");
localeManager.sendMessage(pplayer, "command-description-fixed-clear");
return;
}
@ -74,13 +75,13 @@ public class FixedCommandModule implements CommandModule {
this.handleClear(pplayer, p, cmdArgs);
return;
default:
LangManager.sendMessage(pplayer, Lang.FIXED_INVALID_COMMAND);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_CREATE);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_EDIT);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_REMOVE);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_LIST);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_INFO);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_FIXED_CLEAR);
localeManager.sendMessage(pplayer, "fixed-invalid-command");
localeManager.sendMessage(pplayer, "command-description-fixed-create");
localeManager.sendMessage(pplayer, "command-description-fixed-edit");
localeManager.sendMessage(pplayer, "command-description-fixed-remove");
localeManager.sendMessage(pplayer, "command-description-fixed-list");
localeManager.sendMessage(pplayer, "command-description-fixed-info");
localeManager.sendMessage(pplayer, "command-description-fixed-clear");
}
}
@ -92,24 +93,26 @@ public class FixedCommandModule implements CommandModule {
* @param args The command arguments
*/
private void handleCreate(PPlayer pplayer, Player p, String[] args) {
boolean reachedMax = PermissionManager.hasPlayerReachedMaxFixedEffects(pplayer);
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
boolean reachedMax = permissionManager.hasPlayerReachedMaxFixedEffects(pplayer);
if (reachedMax) {
LangManager.sendMessage(pplayer, Lang.FIXED_MAX_REACHED);
localeManager.sendMessage(pplayer, "fixed-max-reached");
return;
}
if (args.length < 5 && !(args.length > 0 && args[0].equalsIgnoreCase("looking") && args.length >= 3)) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_MISSING_ARGS, 5 - args.length);
localeManager.sendMessage(pplayer, "fixed-create-missing-args", StringPlaceholders.single("amount", 5 - args.length));
return;
}
double xPos, yPos, zPos;
if (args[0].equalsIgnoreCase("looking")) {
Block targetBlock = p.getTargetBlock((Set<Material>) null, 8);
Block targetBlock = p.getTargetBlock((Set<Material>) null, 8); // Need the Set<Material> cast for 1.9 support
int maxDistanceSqrd = 6 * 6;
if (targetBlock.getLocation().distanceSquared(p.getLocation()) > maxDistanceSqrd) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_LOOKING_TOO_FAR);
localeManager.sendMessage(pplayer, "fixed-create-looking-too-far");
return;
}
@ -149,38 +152,38 @@ public class FixedCommandModule implements CommandModule {
zPos = Double.parseDouble(args[2]);
}
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_INVALID_COORDS);
localeManager.sendMessage(pplayer, "fixed-create-invalid-coords");
return;
}
}
double distanceFromEffect = p.getLocation().distance(new Location(p.getWorld(), xPos, yPos, zPos));
int maxCreationDistance = PermissionManager.getMaxFixedEffectCreationDistance();
int maxCreationDistance = permissionManager.getMaxFixedEffectCreationDistance();
if (maxCreationDistance != 0 && distanceFromEffect > maxCreationDistance) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_OUT_OF_RANGE, maxCreationDistance);
localeManager.sendMessage(pplayer, "fixed-create-out-of-range", StringPlaceholders.single("range", maxCreationDistance));
return;
}
ParticleEffect effect = ParticleEffect.fromName(args[3]);
if (effect == null) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_EFFECT_INVALID, args[3]);
localeManager.sendMessage(pplayer, "fixed-create-effect-invalid", StringPlaceholders.single("effect", args[3]));
return;
} else if (!PermissionManager.hasEffectPermission(p, effect)) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_EFFECT_NO_PERMISSION, effect.getName());
} else if (!permissionManager.hasEffectPermission(p, effect)) {
localeManager.sendMessage(pplayer, "fixed-create-effect-no-permission", StringPlaceholders.single("effect", effect.getName()));
return;
}
ParticleStyle style = ParticleStyle.fromName(args[4]);
if (style == null) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_STYLE_INVALID, args[4]);
localeManager.sendMessage(pplayer, "fixed-create-style-invalid", StringPlaceholders.single("style", args[4]));
return;
} else if (!PermissionManager.hasStylePermission(p, style)) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_STYLE_NO_PERMISSION, args[4]);
} else if (!permissionManager.hasStylePermission(p, style)) {
localeManager.sendMessage(pplayer, "fixed-create-style-no-permission", StringPlaceholders.single("style", args[4]));
return;
}
if (!style.canBeFixed()) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_STYLE_NON_FIXABLE, style.getName());
localeManager.sendMessage(pplayer, "fixed-create-style-non-fixable", StringPlaceholders.single("style", style.getName()));
return;
}
@ -201,12 +204,12 @@ public class FixedCommandModule implements CommandModule {
try {
note = Integer.parseInt(args[5]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-create-data-error");
return;
}
if (note < 0 || note > 24) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-create-data-error");
return;
}
@ -225,12 +228,12 @@ public class FixedCommandModule implements CommandModule {
g = Integer.parseInt(args[6]);
b = Integer.parseInt(args[7]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-create-data-error");
return;
}
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-create-data-error");
return;
}
@ -245,7 +248,7 @@ public class FixedCommandModule implements CommandModule {
if (material == null) material = Material.matchMaterial(args[5]);
if (material == null || !material.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-create-data-error");
return;
}
@ -257,7 +260,7 @@ public class FixedCommandModule implements CommandModule {
if (material == null) material = Material.matchMaterial(args[5]);
if (material == null || material.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-create-data-error");
return;
}
@ -270,8 +273,8 @@ public class FixedCommandModule implements CommandModule {
ParticlePair particle = new ParticlePair(pplayer.getUniqueId(), nextFixedEffectId, effect, style, itemData, blockData, colorData, noteColorData);
FixedParticleEffect fixedEffect = new FixedParticleEffect(p.getUniqueId(), nextFixedEffectId, p.getLocation().getWorld().getName(), xPos, yPos, zPos, particle);
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_SUCCESS);
DataManager.saveFixedEffect(fixedEffect);
localeManager.sendMessage(pplayer, "fixed-create-success");
PlayerParticles.getInstance().getManager(DataManager.class).saveFixedEffect(fixedEffect);
}
/**
@ -282,8 +285,11 @@ public class FixedCommandModule implements CommandModule {
* @param args The command arguments
*/
private void handleEdit(PPlayer pplayer, Player p, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
if (args.length < 3) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_MISSING_ARGS);
localeManager.sendMessage(pplayer, "fixed-edit-missing-args");
return;
}
@ -291,13 +297,13 @@ public class FixedCommandModule implements CommandModule {
try {
id = Integer.parseInt(args[0]);
} catch (Exception ex) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_ID);
localeManager.sendMessage(pplayer, "fixed-edit-invalid-id");
return;
}
FixedParticleEffect fixedEffect = pplayer.getFixedEffectById(id);
if (fixedEffect == null) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_ID);
localeManager.sendMessage(pplayer, "fixed-edit-invalid-id");
return;
}
@ -307,10 +313,10 @@ public class FixedCommandModule implements CommandModule {
double xPos, yPos, zPos;
if (args[2].equalsIgnoreCase("looking")) {
Block targetBlock = p.getTargetBlock((Set<Material>) null, 8);
Block targetBlock = p.getTargetBlock((Set<Material>) null, 8); // Need the Set<Material> cast for 1.9 support
int maxDistanceSqrd = 6 * 6;
if (targetBlock.getLocation().distanceSquared(p.getLocation()) > maxDistanceSqrd) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_LOOKING_TOO_FAR);
localeManager.sendMessage(pplayer, "fixed-edit-looking-too-far");
return;
}
@ -342,15 +348,15 @@ public class FixedCommandModule implements CommandModule {
zPos = Double.parseDouble(args[4]);
}
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_COORDS);
localeManager.sendMessage(pplayer, "fixed-edit-invalid-coords");
return;
}
}
double distanceFromEffect = p.getLocation().distance(new Location(p.getWorld(), xPos, yPos, zPos));
int maxCreationDistance = PermissionManager.getMaxFixedEffectCreationDistance();
int maxCreationDistance = permissionManager.getMaxFixedEffectCreationDistance();
if (maxCreationDistance != 0 && distanceFromEffect > maxCreationDistance) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_OUT_OF_RANGE, maxCreationDistance);
localeManager.sendMessage(pplayer, "fixed-edit-out-of-range", StringPlaceholders.single("range", maxCreationDistance));
return;
}
@ -359,10 +365,10 @@ public class FixedCommandModule implements CommandModule {
case "effect": {
ParticleEffect effect = ParticleEffect.fromName(args[2]);
if (effect == null) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_EFFECT_INVALID, args[2]);
localeManager.sendMessage(pplayer, "fixed-edit-effect-invalid", StringPlaceholders.single("effect", args[2]));
return;
} else if (!PermissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_EFFECT_NO_PERMISSION, effect.getName());
} else if (!permissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
localeManager.sendMessage(pplayer, "fixed-edit-effect-no-permission", StringPlaceholders.single("effect", effect.getName()));
return;
}
@ -372,13 +378,13 @@ public class FixedCommandModule implements CommandModule {
case "style":
ParticleStyle style = ParticleStyle.fromName(args[2]);
if (style == null) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_STYLE_INVALID, args[2]);
localeManager.sendMessage(pplayer, "fixed-edit-style-invalid", StringPlaceholders.single("style", args[2]));
return;
} else if (!PermissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_STYLE_NO_PERMISSION, style.getName());
} else if (!permissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
localeManager.sendMessage(pplayer, "fixed-edit-style-no-permission", StringPlaceholders.single("style", style.getName()));
return;
} else if (!style.canBeFixed()) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_STYLE_NON_FIXABLE, style.getName());
localeManager.sendMessage(pplayer, "fixed-edit-style-non-fixable", StringPlaceholders.single("style", style.getName()));
return;
}
@ -402,12 +408,12 @@ public class FixedCommandModule implements CommandModule {
try {
note = Integer.parseInt(args[2]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-edit-data-error");
return;
}
if (note < 0 || note > 24) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-edit-data-error");
return;
}
@ -426,12 +432,12 @@ public class FixedCommandModule implements CommandModule {
g = Integer.parseInt(args[3]);
b = Integer.parseInt(args[4]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-edit-data-error");
return;
}
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-edit-data-error");
return;
}
@ -446,7 +452,7 @@ public class FixedCommandModule implements CommandModule {
if (material == null) material = Material.matchMaterial(args[2]);
if (material == null || !material.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-edit-data-error");
return;
}
@ -458,14 +464,14 @@ public class FixedCommandModule implements CommandModule {
if (material == null) material = Material.matchMaterial(args[2]);
if (material == null || material.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
localeManager.sendMessage(pplayer, "fixed-edit-data-error");
return;
}
itemData = material;
}
} else {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_NONE);
localeManager.sendMessage(pplayer, "fixed-edit-data-none");
return;
}
@ -476,12 +482,12 @@ public class FixedCommandModule implements CommandModule {
break;
}
default:
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_PROPERTY);
localeManager.sendMessage(pplayer, "fixed-edit-invalid-property");
return;
}
DataManager.updateFixedEffect(fixedEffect);
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_SUCCESS, editType, id);
PlayerParticles.getInstance().getManager(DataManager.class).updateFixedEffect(fixedEffect);
localeManager.sendMessage(pplayer, "fixed-edit-success", StringPlaceholders.builder("prop", editType).addPlaceholder("id", id).build());
}
/**
@ -492,8 +498,10 @@ public class FixedCommandModule implements CommandModule {
* @param args The command arguments
*/
private void handleRemove(PPlayer pplayer, Player p, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (args.length < 1) {
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_NO_ARGS);
localeManager.sendMessage(pplayer, "fixed-remove-no-args");
return;
}
@ -501,15 +509,15 @@ public class FixedCommandModule implements CommandModule {
try {
id = Integer.parseInt(args[0]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_ARGS_INVALID);
localeManager.sendMessage(pplayer, "fixed-remove-args-invalid");
return;
}
if (pplayer.getFixedEffectById(id) != null) {
DataManager.removeFixedEffect(pplayer.getUniqueId(), id);
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_SUCCESS, id);
PlayerParticles.getInstance().getManager(DataManager.class).removeFixedEffect(pplayer.getUniqueId(), id);
localeManager.sendMessage(pplayer, "fixed-remove-success", StringPlaceholders.single("id", id));
} else {
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_INVALID, id);
localeManager.sendMessage(pplayer, "fixed-remove-invalid", StringPlaceholders.single("id", id));
}
}
@ -521,11 +529,13 @@ public class FixedCommandModule implements CommandModule {
* @param args The command arguments
*/
private void handleList(PPlayer pplayer, Player p, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
List<Integer> ids = pplayer.getFixedEffectIds();
Collections.sort(ids);
if (ids.isEmpty()) {
LangManager.sendMessage(pplayer, Lang.FIXED_LIST_NONE);
localeManager.sendMessage(pplayer, "fixed-list-none");
return;
}
@ -537,7 +547,7 @@ public class FixedCommandModule implements CommandModule {
msg.append(id);
}
LangManager.sendMessage(pplayer, Lang.FIXED_LIST_SUCCESS, msg.toString());
localeManager.sendMessage(pplayer, "fixed-list-success", StringPlaceholders.single("ids", msg.toString()));
}
/**
@ -548,8 +558,10 @@ public class FixedCommandModule implements CommandModule {
* @param args The command arguments
*/
private void handleInfo(PPlayer pplayer, Player p, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (args.length < 1) {
LangManager.sendMessage(pplayer, Lang.FIXED_INFO_NO_ARGS);
localeManager.sendMessage(pplayer, "fixed-info-no-args");
return;
}
@ -557,30 +569,29 @@ public class FixedCommandModule implements CommandModule {
try {
id = Integer.parseInt(args[0]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_INFO_INVALID_ARGS);
localeManager.sendMessage(pplayer, "fixed-info-invalid-args");
return;
}
FixedParticleEffect fixedEffect = pplayer.getFixedEffectById(id);
if (fixedEffect == null) {
LangManager.sendMessage(pplayer, Lang.FIXED_INFO_INVALID, id);
localeManager.sendMessage(pplayer, "fixed-info-invalid", StringPlaceholders.single("id", id));
return;
}
ParticlePair particle = fixedEffect.getParticlePair();
DecimalFormat df = new DecimalFormat("0.##"); // Decimal formatter so the coords aren't super long
LangManager.sendMessage(pplayer,
Lang.FIXED_INFO_SUCCESS,
fixedEffect.getId(),
fixedEffect.getLocation().getWorld().getName(),
df.format(fixedEffect.getLocation().getX()),
df.format(fixedEffect.getLocation().getY()),
df.format(fixedEffect.getLocation().getZ()),
particle.getEffect().getName(),
particle.getStyle().getName(),
particle.getDataString()
);
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", fixedEffect.getId())
.addPlaceholder("world", fixedEffect.getLocation().getWorld().getName())
.addPlaceholder("x", df.format(fixedEffect.getLocation().getX()))
.addPlaceholder("y", df.format(fixedEffect.getLocation().getY()))
.addPlaceholder("z", df.format(fixedEffect.getLocation().getZ()))
.addPlaceholder("effect", particle.getEffect().getName())
.addPlaceholder("style", particle.getStyle().getName())
.addPlaceholder("data", particle.getDataString())
.build();
localeManager.sendMessage(pplayer, "fixed-info-success", stringPlaceholders);
}
/**
@ -591,13 +602,18 @@ public class FixedCommandModule implements CommandModule {
* @param args The command arguments
*/
private void handleClear(PPlayer pplayer, Player p, String[] args) {
if (!PermissionManager.canClearFixedEffects(p)) {
LangManager.sendMessage(pplayer, Lang.FIXED_CLEAR_NO_PERMISSION);
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
if (!permissionManager.canClearFixedEffects(p)) {
localeManager.sendMessage(pplayer, "fixed-clear-no-permission");
return;
}
if (args.length < 1) {
LangManager.sendMessage(pplayer, Lang.FIXED_CLEAR_NO_ARGS);
localeManager.sendMessage(pplayer, "fixed-clear-no-args");
return;
}
@ -605,24 +621,26 @@ public class FixedCommandModule implements CommandModule {
try {
radius = Math.abs(Integer.parseInt(args[0]));
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.FIXED_CLEAR_INVALID_ARGS);
localeManager.sendMessage(pplayer, "fixed-clear-invalid-args");
return;
}
ArrayList<FixedParticleEffect> fixedEffectsToRemove = new ArrayList<>();
for (PPlayer ppl : ParticleManager.getPPlayers())
for (PPlayer ppl : particleManager.getPPlayers())
for (FixedParticleEffect fixedEffect : ppl.getFixedParticles())
if (fixedEffect.getLocation().getWorld().equals(p.getLocation().getWorld()) && fixedEffect.getLocation().distance(p.getLocation()) <= radius)
if (fixedEffect.getLocation().getWorld() == p.getLocation().getWorld() && fixedEffect.getLocation().distance(p.getLocation()) <= radius)
fixedEffectsToRemove.add(fixedEffect);
for (FixedParticleEffect fixedEffect : fixedEffectsToRemove)
DataManager.removeFixedEffect(fixedEffect.getOwnerUniqueId(), fixedEffect.getId());
dataManager.removeFixedEffect(fixedEffect.getOwnerUniqueId(), fixedEffect.getId());
LangManager.sendMessage(pplayer, Lang.FIXED_CLEAR_SUCCESS, fixedEffectsToRemove.size(), radius);
localeManager.sendMessage(pplayer, "fixed-clear-success", StringPlaceholders.builder("amount", fixedEffectsToRemove.size()).addPlaceholder("range", radius).build());
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
Player p = pplayer.getPlayer();
List<String> matches = new ArrayList<>();
@ -657,9 +675,9 @@ public class FixedCommandModule implements CommandModule {
}
if (args.length == 5) {
StringUtil.copyPartialMatches(args[4], PermissionManager.getEffectNamesUserHasPermissionFor(p), matches);
StringUtil.copyPartialMatches(args[4], permissionManager.getEffectNamesUserHasPermissionFor(p), matches);
} else if (args.length == 6) {
StringUtil.copyPartialMatches(args[5], PermissionManager.getFixableStyleNamesUserHasPermissionFor(p), matches);
StringUtil.copyPartialMatches(args[5], permissionManager.getFixableStyleNamesUserHasPermissionFor(p), matches);
} else if (args.length >= 7) {
ParticleEffect effect = ParticleEffect.fromName(args[4]);
if (effect != null) {
@ -717,9 +735,9 @@ public class FixedCommandModule implements CommandModule {
}
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
} else if (property.equals("effect") && args.length == 4) {
StringUtil.copyPartialMatches(args[3], PermissionManager.getEffectNamesUserHasPermissionFor(p), matches);
StringUtil.copyPartialMatches(args[3], permissionManager.getEffectNamesUserHasPermissionFor(p), matches);
} else if (property.equals("style") && args.length == 4) {
StringUtil.copyPartialMatches(args[3], PermissionManager.getFixableStyleNamesUserHasPermissionFor(p), matches);
StringUtil.copyPartialMatches(args[3], permissionManager.getFixableStyleNamesUserHasPermissionFor(p), matches);
} else if (property.equals("data")) {
int id = -1;
try {
@ -781,8 +799,8 @@ public class FixedCommandModule implements CommandModule {
return "fixed";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_FIXED;
public String getDescriptionKey() {
return "command-description-fixed";
}
public String getArguments() {

View file

@ -1,42 +1,44 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.gui.GuiHandler;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
public class GUICommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
boolean byDefault = false;
if (args.length > 0 && args[0].equals("_byDefault_")) {
byDefault = true;
}
if (GuiHandler.isGuiDisabled()) {
if (guiManager.isGuiDisabled()) {
if (byDefault) {
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN);
localeManager.sendMessage(pplayer, "command-error-unknown");
} else {
LangManager.sendMessage(pplayer, Lang.GUI_DISABLED);
localeManager.sendMessage(pplayer, "gui-disabled");
}
return;
}
if (!PSetting.GUI_PRESETS_ONLY.getBoolean() && PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()).isEmpty()) {
if (!Setting.GUI_PRESETS_ONLY.getBoolean() && PlayerParticles.getInstance().getManager(PermissionManager.class).getEffectNamesUserHasPermissionFor(pplayer.getPlayer()).isEmpty()) {
if (byDefault) {
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_NO_EFFECTS);
localeManager.sendMessage(pplayer, "command-error-no-effects");
} else {
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN);
localeManager.sendMessage(pplayer, "command-error-unknown");
}
return;
}
GuiHandler.openDefault(pplayer);
guiManager.openDefault(pplayer);
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
@ -47,8 +49,8 @@ public class GUICommandModule implements CommandModule {
return "gui";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_GUI;
public String getDescriptionKey() {
return "command-description-gui";
}
public String getArguments() {

View file

@ -1,38 +1,39 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticleGroupPreset;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
public class GroupCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
List<String> validCommands = Arrays.asList("save", "load", "remove", "info", "list");
if (args.length == 0 || !validCommands.contains(args[0])) {
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_SAVE);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_LOAD);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_REMOVE);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_INFO);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_LIST);
localeManager.sendMessage(pplayer, "command-description-group-save");
localeManager.sendMessage(pplayer, "command-description-group-load");
localeManager.sendMessage(pplayer, "command-description-group-remove");
localeManager.sendMessage(pplayer, "command-description-group-info");
localeManager.sendMessage(pplayer, "command-description-group-list");
return;
}
if (args.length == 1 && !args[0].equalsIgnoreCase("list")) {
LangManager.sendMessage(pplayer, Lang.GROUP_NO_NAME, args[0].toLowerCase());
localeManager.sendMessage(pplayer, "group-no-name", StringPlaceholders.single("cmd", args[0].toLowerCase()));
return;
}
@ -53,11 +54,11 @@ public class GroupCommandModule implements CommandModule {
this.onList(pplayer);
break;
default:
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_SAVE);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_LOAD);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_REMOVE);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_INFO);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_LIST);
localeManager.sendMessage(pplayer, "command-description-group-save");
localeManager.sendMessage(pplayer, "command-description-group-load");
localeManager.sendMessage(pplayer, "command-description-group-remove");
localeManager.sendMessage(pplayer, "command-description-group-info");
localeManager.sendMessage(pplayer, "command-description-group-list");
break;
}
}
@ -69,15 +70,17 @@ public class GroupCommandModule implements CommandModule {
* @param groupName The target group name
*/
private void onSave(PPlayer pplayer, String groupName) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
// Check that the groupName isn't the reserved name
if (groupName.equalsIgnoreCase(ParticleGroup.DEFAULT_NAME)) {
LangManager.sendMessage(pplayer, Lang.GROUP_RESERVED);
localeManager.sendMessage(pplayer, "group-reserved");
return;
}
// Check if the player actually has any particles
if (pplayer.getActiveParticles().size() == 0) {
LangManager.sendMessage(pplayer, Lang.GROUP_SAVE_NO_PARTICLES);
localeManager.sendMessage(pplayer, "group-save-no-particles");
return;
}
@ -87,8 +90,8 @@ public class GroupCommandModule implements CommandModule {
}
// Check if they are creating a new group, if they are, check that they haven't gone over their limit
if (pplayer.getParticleGroupByName(groupName) == null && PermissionManager.hasPlayerReachedMaxGroups(pplayer)) {
LangManager.sendMessage(pplayer, Lang.GROUP_SAVE_REACHED_MAX);
if (pplayer.getParticleGroupByName(groupName) == null && PlayerParticles.getInstance().getManager(PermissionManager.class).hasPlayerReachedMaxGroups(pplayer)) {
localeManager.sendMessage(pplayer, "group-save-reached-max");
return;
}
@ -105,11 +108,11 @@ public class GroupCommandModule implements CommandModule {
}
// Apply changes and notify player
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
if (groupUpdated) {
LangManager.sendMessage(pplayer, Lang.GROUP_SAVE_SUCCESS_OVERWRITE, groupName);
localeManager.sendMessage(pplayer, "group-save-success-overwrite", StringPlaceholders.single("name", groupName));
} else {
LangManager.sendMessage(pplayer, Lang.GROUP_SAVE_SUCCESS, groupName);
localeManager.sendMessage(pplayer, "group-save-success", StringPlaceholders.single("name", groupName));
}
}
@ -120,9 +123,11 @@ public class GroupCommandModule implements CommandModule {
* @param groupName The target group name
*/
private void onLoad(PPlayer pplayer, String groupName) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
// Check that the groupName isn't the reserved name
if (groupName.equalsIgnoreCase(ParticleGroup.DEFAULT_NAME)) {
LangManager.sendMessage(pplayer, Lang.GROUP_RESERVED);
localeManager.sendMessage(pplayer, "group-reserved");
return;
}
@ -131,14 +136,14 @@ public class GroupCommandModule implements CommandModule {
ParticleGroup group = pplayer.getParticleGroupByName(groupName);
if (group == null) {
// Didn't find a saved group, look at the presets
ParticleGroupPreset presetGroup = ParticleGroupPresetManager.getPresetGroup(groupName);
ParticleGroupPreset presetGroup = PlayerParticles.getInstance().getManager(ParticleGroupPresetManager.class).getPresetGroup(groupName);
if (presetGroup == null) {
LangManager.sendMessage(pplayer, Lang.GROUP_INVALID, groupName);
localeManager.sendMessage(pplayer, "group-invalid", StringPlaceholders.single("name", groupName));
return;
}
if (!presetGroup.canPlayerUse(pplayer.getPlayer())) {
LangManager.sendMessage(pplayer, Lang.GROUP_PRESET_NO_PERMISSION, groupName);
localeManager.sendMessage(pplayer, "group-preset-no-permission", StringPlaceholders.single("group", groupName));
return;
}
@ -147,7 +152,7 @@ public class GroupCommandModule implements CommandModule {
}
if (!group.canPlayerUse(pplayer.getPlayer())) {
LangManager.sendMessage(pplayer, Lang.GROUP_NO_PERMISSION, groupName);
localeManager.sendMessage(pplayer, "group-no-permission", StringPlaceholders.single("group", groupName));
return;
}
@ -158,12 +163,12 @@ public class GroupCommandModule implements CommandModule {
activeGroup.getParticles().add(particle.clone());
// Update group and notify player
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), activeGroup);
if (!isPreset)
LangManager.sendMessage(pplayer, Lang.GROUP_LOAD_SUCCESS, activeGroup.getParticles().size(), groupName);
localeManager.sendMessage(pplayer, "group-load-success", StringPlaceholders.builder("amount", activeGroup.getParticles().size()).addPlaceholder("name", groupName).build());
else
LangManager.sendMessage(pplayer, Lang.GROUP_LOAD_PRESET_SUCCESS, activeGroup.getParticles().size(), groupName);
localeManager.sendMessage(pplayer, "group-load-preset-success", StringPlaceholders.builder("amount", activeGroup.getParticles().size()).addPlaceholder("name", groupName).build());
}
/**
@ -173,28 +178,30 @@ public class GroupCommandModule implements CommandModule {
* @param groupName The target group name
*/
private void onRemove(PPlayer pplayer, String groupName) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
// Check that the groupName isn't the reserved name
if (groupName.equalsIgnoreCase(ParticleGroup.DEFAULT_NAME)) {
LangManager.sendMessage(pplayer, Lang.GROUP_RESERVED);
localeManager.sendMessage(pplayer, "group-reserved");
return;
}
ParticleGroup group = pplayer.getParticleGroupByName(groupName);
if (group == null) {
// Didn't find a saved group, look at the presets
ParticleGroupPreset presetGroup = ParticleGroupPresetManager.getPresetGroup(groupName);
ParticleGroupPreset presetGroup = PlayerParticles.getInstance().getManager(ParticleGroupPresetManager.class).getPresetGroup(groupName);
if (presetGroup == null) {
LangManager.sendMessage(pplayer, Lang.GROUP_INVALID, groupName);
localeManager.sendMessage(pplayer, "group-invalid", StringPlaceholders.single("name", groupName));
} else {
LangManager.sendMessage(pplayer, Lang.GROUP_REMOVE_PRESET);
localeManager.sendMessage(pplayer, "group-remove-preset");
}
return;
}
// Delete the group and notify player
DataManager.removeParticleGroup(pplayer.getUniqueId(), group);
LangManager.sendMessage(pplayer, Lang.GROUP_REMOVE_SUCCESS, groupName);
PlayerParticles.getInstance().getManager(DataManager.class).removeParticleGroup(pplayer.getUniqueId(), group);
localeManager.sendMessage(pplayer, "group-remove-success", StringPlaceholders.single("name", groupName));
}
/**
@ -204,23 +211,25 @@ public class GroupCommandModule implements CommandModule {
* @param groupName The target group name
*/
private void onInfo(PPlayer pplayer, String groupName) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
// Check that the groupName isn't the reserved name
if (groupName.equalsIgnoreCase(ParticleGroup.DEFAULT_NAME)) {
LangManager.sendMessage(pplayer, Lang.GROUP_RESERVED);
localeManager.sendMessage(pplayer, "group-reserved");
return;
}
ParticleGroup group = pplayer.getParticleGroupByName(groupName);
if (group == null) {
// Didn't find a saved group, look at the presets
ParticleGroupPreset presetGroup = ParticleGroupPresetManager.getPresetGroup(groupName);
ParticleGroupPreset presetGroup = PlayerParticles.getInstance().getManager(ParticleGroupPresetManager.class).getPresetGroup(groupName);
if (presetGroup == null) {
LangManager.sendMessage(pplayer, Lang.GROUP_INVALID, groupName);
localeManager.sendMessage(pplayer, "group-invalid", StringPlaceholders.single("name", groupName));
return;
}
if (!presetGroup.canPlayerUse(pplayer.getPlayer())) {
LangManager.sendMessage(pplayer, Lang.GROUP_PRESET_NO_PERMISSION, groupName);
localeManager.sendMessage(pplayer, "group-preset-no-permission", StringPlaceholders.single("group", groupName));
return;
}
@ -230,9 +239,15 @@ public class GroupCommandModule implements CommandModule {
List<ParticlePair> particles = group.getParticles();
particles.sort(Comparator.comparingInt(ParticlePair::getId));
LangManager.sendMessage(pplayer, Lang.GROUP_INFO_HEADER, groupName);
for (ParticlePair particle : particles)
LangManager.sendMessage(pplayer, Lang.LIST_OUTPUT, particle.getId(), particle.getEffect().getName(), particle.getStyle().getName(), particle.getDataString());
localeManager.sendMessage(pplayer, "group-info-header", StringPlaceholders.single("group", groupName));
for (ParticlePair particle : particles) {
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId())
.addPlaceholder("effect", particle.getEffect().getName())
.addPlaceholder("style", particle.getStyle().getName())
.addPlaceholder("data", particle.getDataString())
.build();
localeManager.sendMessage(pplayer, "list-output", stringPlaceholders);
}
}
/**
@ -241,6 +256,8 @@ public class GroupCommandModule implements CommandModule {
* @param pplayer The PPlayer
*/
private void onList(PPlayer pplayer) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
List<ParticleGroup> groups = pplayer.getParticleGroups();
groups.sort(Comparator.comparing(ParticleGroup::getName));
@ -254,23 +271,23 @@ public class GroupCommandModule implements CommandModule {
groupsList = new StringBuilder(groupsList.substring(0, groupsList.length() - 2));
StringBuilder presetsList = new StringBuilder();
for (ParticleGroupPreset group : ParticleGroupPresetManager.getPresetGroupsForPlayer(pplayer.getPlayer()))
for (ParticleGroupPreset group : PlayerParticles.getInstance().getManager(ParticleGroupPresetManager.class).getPresetGroupsForPlayer(pplayer.getPlayer()))
presetsList.append(group.getGroup().getName()).append(", ");
if (presetsList.toString().endsWith(", "))
presetsList = new StringBuilder(presetsList.substring(0, presetsList.length() - 2));
if ((groupsList.length() == 0) && (presetsList.length() == 0)) {
LangManager.sendMessage(pplayer, Lang.GROUP_LIST_NONE);
localeManager.sendMessage(pplayer, "group-list-none");
return;
}
if (groupsList.length() > 0) {
LangManager.sendMessage(pplayer, Lang.GROUP_LIST_OUTPUT, groupsList.toString());
localeManager.sendMessage(pplayer, "group-list-output", StringPlaceholders.single("info", groupsList.toString()));
}
if (presetsList.length() > 0) {
LangManager.sendMessage(pplayer, Lang.GROUP_LIST_PRESETS, presetsList.toString());
localeManager.sendMessage(pplayer, "group-list-presets", StringPlaceholders.single("info", presetsList.toString()));
}
}
@ -290,7 +307,7 @@ public class GroupCommandModule implements CommandModule {
if (!group.getName().equals(ParticleGroup.DEFAULT_NAME))
groupNames.add(group.getName());
if (!args[0].equals("remove"))
for (ParticleGroupPreset group : ParticleGroupPresetManager.getPresetGroupsForPlayer(pplayer.getPlayer()))
for (ParticleGroupPreset group : PlayerParticles.getInstance().getManager(ParticleGroupPresetManager.class).getPresetGroupsForPlayer(pplayer.getPlayer()))
groupNames.add(group.getGroup().getName());
StringUtil.copyPartialMatches(args[1], groupNames, matches);
}
@ -303,8 +320,8 @@ public class GroupCommandModule implements CommandModule {
return "group";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_GROUP;
public String getDescriptionKey() {
return "command-description-group";
}
public String getArguments() {

View file

@ -1,21 +1,23 @@
package dev.esophose.playerparticles.command;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.CommandManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.particles.PPlayer;
public class HelpCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTIONS);
List<CommandModule> cmds = ParticleCommandHandler.getCommands();
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
localeManager.sendMessage(pplayer, "command-descriptions");
List<CommandModule> cmds = PlayerParticles.getInstance().getManager(CommandManager.class).getCommands();
for (CommandModule cmd : cmds)
if (!(cmd instanceof DefaultCommandModule))
CommandModule.printUsageWithDescription(pplayer, cmd);
LangManager.sendSimpleMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_HELP_OTHER);
localeManager.sendSimpleMessage(pplayer, "command-descriptions-help-other");
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
@ -26,8 +28,8 @@ public class HelpCommandModule implements CommandModule {
return "help";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_HELP;
public String getDescriptionKey() {
return "command-description-help";
}
public String getArguments() {

View file

@ -1,32 +1,35 @@
package dev.esophose.playerparticles.command;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
public class ListCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
List<ParticlePair> particles = pplayer.getActiveParticles();
particles.sort(Comparator.comparingInt(ParticlePair::getId));
if (particles.isEmpty()) {
LangManager.sendMessage(pplayer, Lang.LIST_NONE);
localeManager.sendMessage(pplayer, "list-none");
return;
}
LangManager.sendMessage(pplayer, Lang.LIST_YOU_HAVE);
localeManager.sendMessage(pplayer, "list-you-have");
for (ParticlePair particle : particles) {
int id = particle.getId();
String effect = particle.getEffect().getName();
String style = particle.getStyle().getName();
String data = particle.getDataString();
LangManager.sendMessage(pplayer, Lang.LIST_OUTPUT, id, effect, style, data);
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId())
.addPlaceholder("effect", particle.getEffect())
.addPlaceholder("style", particle.getStyle())
.addPlaceholder("data", particle.getDataString())
.build();
localeManager.sendMessage(pplayer, "list-output", stringPlaceholders);
}
}
@ -38,8 +41,8 @@ public class ListCommandModule implements CommandModule {
return "list";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_LIST;
public String getDescriptionKey() {
return "command-description-list";
}
public String getArguments() {

View file

@ -1,56 +1,59 @@
package dev.esophose.playerparticles.command;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.CommandManager;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.OtherPPlayer;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.OtherPPlayer;
import dev.esophose.playerparticles.particles.PPlayer;
public class OtherCommandModule implements CommandModuleSecondary {
public void onCommandExecute(CommandSender sender, String[] args) {
if (!PermissionManager.canOverride(sender)) {
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_NO_PERMISSION);
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
if (!permissionManager.canOverride(sender)) {
localeManager.sendMessage(sender, "other-no-permission");
return;
}
if (args.length < 2) {
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_MISSING_ARGS);
localeManager.sendMessage(sender, "other-missing-args");
return;
}
Player other = Bukkit.getPlayer(args[0]);
if (other == null) {
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_UNKNOWN_PLAYER, args[0]);
localeManager.sendMessage(sender, "other-unknown-player", StringPlaceholders.single("player", args[0]));
return;
}
CommandModule commandModule = ParticleCommandHandler.findMatchingCommand(args[1]);
CommandModule commandModule = PlayerParticles.getInstance().getManager(CommandManager.class).findMatchingCommand(args[1]);
if (commandModule == null) {
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_UNKNOWN_COMMAND, args[1]);
localeManager.sendMessage(sender, "other-unknown-command", StringPlaceholders.single("cmd", args[1]));
return;
}
if (commandModule.requiresEffects() && PermissionManager.getEffectNamesUserHasPermissionFor(other).isEmpty()) {
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_SUCCESS, other.getName());
LangManager.sendCommandSenderMessage(sender, Lang.COMMAND_ERROR_NO_EFFECTS);
if (commandModule.requiresEffects() && permissionManager.getEffectNamesUserHasPermissionFor(other).isEmpty()) {
localeManager.sendMessage(sender, "other-success", StringPlaceholders.single("player", other.getName()));
localeManager.sendMessage(sender, "command-error-no-effects");
return;
}
DataManager.getPPlayer(other.getUniqueId(), (pplayer) -> {
PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(other.getUniqueId(), (pplayer) -> {
OtherPPlayer otherPPlayer = new OtherPPlayer(sender, pplayer);
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_SUCCESS, other.getName());
localeManager.sendMessage(sender, "other-success", StringPlaceholders.single("player", other.getName()));
String[] cmdArgs = Arrays.copyOfRange(args, 2, args.length);
commandModule.onCommandExecute(otherPPlayer, cmdArgs);
@ -68,14 +71,14 @@ public class OtherCommandModule implements CommandModuleSecondary {
if (args.length == 0) completions = playerNames;
else StringUtil.copyPartialMatches(args[0], playerNames, completions);
} else if (args.length == 2) {
List<String> commandNames = ParticleCommandHandler.getCommandNames();
List<String> commandNames = PlayerParticles.getInstance().getManager(CommandManager.class).getCommandNames();
StringUtil.copyPartialMatches(args[1], commandNames, completions);
} else {
Player otherPlayer = Bukkit.getPlayer(args[0]);
if (otherPlayer != null) {
PPlayer other = DataManager.getPPlayer(otherPlayer.getUniqueId());
PPlayer other = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(otherPlayer.getUniqueId());
if (other != null) {
CommandModule commandModule = ParticleCommandHandler.findMatchingCommand(args[1]);
CommandModule commandModule = PlayerParticles.getInstance().getManager(CommandManager.class).findMatchingCommand(args[1]);
if (commandModule != null) {
String[] cmdArgs = Arrays.copyOfRange(args, 2, args.length);
completions = commandModule.onTabComplete(other, cmdArgs);

View file

@ -1,168 +0,0 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import dev.esophose.playerparticles.particles.OtherPPlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import net.md_5.bungee.api.ChatColor;
public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
/**
* A list of all commands
*/
private static List<CommandModule> commands;
private static CommandModuleSecondary ppoCommand;
static {
commands = new ArrayList<>();
commands.add(new AddCommandModule());
commands.add(new DataCommandModule());
commands.add(new DefaultCommandModule());
commands.add(new EditCommandModule());
commands.add(new EffectsCommandModule());
commands.add(new FixedCommandModule());
commands.add(new GroupCommandModule());
commands.add(new GUICommandModule());
commands.add(new HelpCommandModule());
commands.add(new ListCommandModule());
commands.add(new ReloadCommandModule());
commands.add(new RemoveCommandModule());
commands.add(new ResetCommandModule());
commands.add(new StylesCommandModule());
commands.add(new ToggleCommandModule());
commands.add(new VersionCommandModule());
commands.add(new WorldsCommandModule());
ppoCommand = new OtherCommandModule();
}
/**
* Finds a matching CommandModule by its name
*
* @param commandName The command name
* @return The found CommandModule, otherwise null
*/
public static CommandModule findMatchingCommand(String commandName) {
for (CommandModule commandModule : commands)
if (commandModule.getName().equalsIgnoreCase(commandName))
return commandModule;
return null;
}
/**
* Get a list of all available commands
*
* @return A List of all CommandModules registered
*/
public static List<CommandModule> getCommands() {
return commands;
}
/**
* Get all available command names
*
* @return All available command names
*/
public static List<String> getCommandNames() {
List<String> commandNames = new ArrayList<>();
for (CommandModule cmd : commands)
commandNames.add(cmd.getName());
return commandNames;
}
/**
* Called when a player executes a PlayerParticles command
* Checks what PlayerParticles command it is and calls the corresponding module
*
* @param sender Who executed the command
* @param cmd The command
* @param label The command label
* @param args The arguments following the command
* @return true
*/
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("pp")) {
String commandName = args.length > 0 ? args[0] : "";
CommandModule commandModule = findMatchingCommand(commandName);
if (commandModule == null) {
sender.sendMessage(LangManager.getText(Lang.COMMAND_ERROR_UNKNOWN));
return true;
}
String[] cmdArgs = args.length > 1 ? Arrays.copyOfRange(args, 1, args.length) : new String[0];
if (!commandModule.canConsoleExecute()) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Error: This command can only be executed by a player.");
return true;
}
} else {
commandModule.onCommandExecute(new OtherPPlayer(sender), cmdArgs);
return true;
}
Player p = (Player) sender;
DataManager.getPPlayer(p.getUniqueId(), (pplayer) -> {
if (commandModule.requiresEffects() && PermissionManager.getEffectNamesUserHasPermissionFor(p).isEmpty()) {
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_NO_EFFECTS);
} else {
commandModule.onCommandExecute(pplayer, cmdArgs);
}
});
} else if (cmd.getName().equalsIgnoreCase("ppo")) {
ppoCommand.onCommandExecute(sender, args);
}
return true;
}
/**
* Activated when a user pushes tab in chat prefixed with /pp
*
* @param sender The sender that hit tab, should always be a player
* @param cmd The command the player is executing
* @param alias The possible alias for the command
* @param args All arguments following the command
* @return A list of commands available to the sender
*/
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
if (cmd.getName().equalsIgnoreCase("pp")) {
if (!(sender instanceof Player)) return new ArrayList<>();
PPlayer pplayer = DataManager.getPPlayer(((Player) sender).getUniqueId());
if (pplayer == null) return new ArrayList<>();
if (args.length <= 1) {
CommandModule commandModule = findMatchingCommand(""); // Get the default command module
return commandModule.onTabComplete(pplayer, args);
} else {
CommandModule commandModule = findMatchingCommand(args[0]);
if (commandModule != null) {
String[] cmdArgs = Arrays.copyOfRange(args, 1, args.length);
return commandModule.onTabComplete(pplayer, cmdArgs);
}
}
} else if (cmd.getName().equalsIgnoreCase("ppo")) {
return ppoCommand.onTabComplete(sender, args);
}
return new ArrayList<>();
}
}

View file

@ -1,23 +1,22 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
public class ReloadCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
if (PermissionManager.canReloadPlugin(pplayer.getMessageDestination())) {
PlayerParticles.getPlugin().reload(false);
LangManager.sendMessage(pplayer, Lang.RELOAD_SUCCESS);
PlayerParticles.getPlugin().getLogger().info("Reloaded configuration.");
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (PlayerParticles.getInstance().getManager(PermissionManager.class).canReloadPlugin(pplayer.getMessageDestination())) {
PlayerParticles.getInstance().reload();
localeManager.sendMessage(pplayer, "reload-success");
PlayerParticles.getInstance().getLogger().info("Reloaded configuration.");
} else {
LangManager.sendMessage(pplayer, Lang.RELOAD_NO_PERMISSION);
localeManager.sendMessage(pplayer, "reload-no-permission");
}
}
@ -29,8 +28,8 @@ public class ReloadCommandModule implements CommandModule {
return "reload";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_RELOAD;
public String getDescriptionKey() {
return "command-description-reload";
}
public String getArguments() {

View file

@ -1,27 +1,29 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import org.apache.commons.lang.StringUtils;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.bukkit.util.StringUtil;
public class RemoveCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
if (args.length == 0) {
LangManager.sendMessage(pplayer, Lang.REMOVE_NO_ARGS);
localeManager.sendMessage(pplayer, "remove-no-args");
return;
}
@ -30,12 +32,12 @@ public class RemoveCommandModule implements CommandModule {
try {
id = Integer.parseInt(args[0]);
} catch (Exception ex) {
LangManager.sendMessage(pplayer, Lang.ID_INVALID);
localeManager.sendMessage(pplayer, "id-invalid");
return;
}
if (id <= 0) {
LangManager.sendMessage(pplayer, Lang.ID_INVALID);
localeManager.sendMessage(pplayer, "id-invalid");
return;
}
@ -50,12 +52,12 @@ public class RemoveCommandModule implements CommandModule {
}
if (!removed) {
LangManager.sendMessage(pplayer, Lang.ID_UNKNOWN, id);
localeManager.sendMessage(pplayer, "id-unknown", StringPlaceholders.single("id", id));
return;
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
LangManager.sendMessage(pplayer, Lang.REMOVE_ID_SUCCESS, id);
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
localeManager.sendMessage(pplayer, "remove-id-success", StringPlaceholders.single("id", id));
} else { // Removing by effect/style name
ParticleEffect effect = ParticleEffect.fromName(args[0]);
ParticleStyle style = ParticleStyle.fromName(args[0]);
@ -71,10 +73,10 @@ public class RemoveCommandModule implements CommandModule {
}
if (removedCount > 0) {
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
LangManager.sendMessage(pplayer, Lang.REMOVE_EFFECT_SUCCESS, removedCount, effect.getName());
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
localeManager.sendMessage(pplayer, "remove-effect-success", StringPlaceholders.builder("amount", removedCount).addPlaceholder("effect", effect.getName()).build());
} else {
LangManager.sendMessage(pplayer, Lang.REMOVE_EFFECT_NONE, effect.getName());
localeManager.sendMessage(pplayer, "remove-effect-none", StringPlaceholders.single("effect", effect.getName()));
}
} else if (style != null) {
int removedCount = 0;
@ -87,13 +89,13 @@ public class RemoveCommandModule implements CommandModule {
}
if (removedCount > 0) {
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
LangManager.sendMessage(pplayer, Lang.REMOVE_STYLE_SUCCESS, removedCount, style.getName());
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
localeManager.sendMessage(pplayer, "remove-style-success", StringPlaceholders.builder("amount", removedCount).addPlaceholder("style", style.getName()).build());
} else {
LangManager.sendMessage(pplayer, Lang.REMOVE_STYLE_NONE, style.getName());
localeManager.sendMessage(pplayer, "remove-style-none", StringPlaceholders.single("style", style.getName()));
}
} else {
LangManager.sendMessage(pplayer, Lang.REMOVE_UNKNOWN, args[0]);
localeManager.sendMessage(pplayer, "remove-unknown", StringPlaceholders.single("name", args[0]));
}
}
}
@ -118,8 +120,8 @@ public class RemoveCommandModule implements CommandModule {
return "remove";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_REMOVE;
public String getDescriptionKey() {
return "command-description-remove";
}
public String getArguments() {
@ -127,7 +129,7 @@ public class RemoveCommandModule implements CommandModule {
}
public boolean requiresEffects() {
return true;
return false;
}
public boolean canConsoleExecute() {

View file

@ -1,20 +1,20 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
public class ResetCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
int particleCount = pplayer.getActiveParticles().size();
DataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
LangManager.sendMessage(pplayer, Lang.RESET_SUCCESS, particleCount);
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
PlayerParticles.getInstance().getManager(LocaleManager.class).sendMessage(pplayer, "reset-success", StringPlaceholders.single("amount", particleCount));
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
@ -25,8 +25,8 @@ public class ResetCommandModule implements CommandModule {
return "reset";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_RESET;
public String getDescriptionKey() {
return "command-description-reset";
}
public String getArguments() {

View file

@ -1,21 +1,20 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
public class StylesCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
Player p = pplayer.getPlayer();
List<String> styleNames = PermissionManager.getStyleNamesUserHasPermissionFor(p);
List<String> styleNames = PlayerParticles.getInstance().getManager(PermissionManager.class).getStyleNamesUserHasPermissionFor(p);
StringBuilder toSend = new StringBuilder();
for (String name : styleNames) {
toSend.append(name).append(", ");
@ -25,7 +24,7 @@ public class StylesCommandModule implements CommandModule {
toSend = new StringBuilder(toSend.substring(0, toSend.length() - 2));
}
LangManager.sendMessage(pplayer, Lang.STYLE_LIST, toSend.toString());
PlayerParticles.getInstance().getManager(LocaleManager.class).sendMessage(pplayer, "style-list", StringPlaceholders.single("styles", toSend.toString()));
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
@ -36,8 +35,8 @@ public class StylesCommandModule implements CommandModule {
return "styles";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_STYLES;
public String getDescriptionKey() {
return "command-description-styles";
}
public String getArguments() {

View file

@ -1,23 +1,23 @@
package dev.esophose.playerparticles.command;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.particles.PPlayer;
public class ToggleCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
boolean canSee = pplayer.canSeeParticles();
DataManager.updateSettingParticlesHidden(pplayer.getUniqueId(), canSee);
PlayerParticles.getInstance().getManager(DataManager.class).updateSettingParticlesHidden(pplayer.getUniqueId(), canSee);
if (canSee) {
LangManager.sendMessage(pplayer, Lang.TOGGLE_OFF);
localeManager.sendMessage(pplayer, "toggle-off");
} else {
LangManager.sendMessage(pplayer, Lang.TOGGLE_ON);
localeManager.sendMessage(pplayer, "toggle-on");
}
}
@ -29,8 +29,8 @@ public class ToggleCommandModule implements CommandModule {
return "toggle";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_TOGGLE;
public String getDescriptionKey() {
return "command-description-toggle";
}
public String getArguments() {

View file

@ -1,20 +1,18 @@
package dev.esophose.playerparticles.command;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.particles.PPlayer;
public class VersionCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LangManager.sendCustomMessage(pplayer, ChatColor.YELLOW + "Running PlayerParticles " + ChatColor.AQUA + "v" + PlayerParticles.getPlugin().getDescription().getVersion());
LangManager.sendCustomMessage(pplayer, ChatColor.YELLOW + "Plugin created by: " + ChatColor.AQUA + "Esophose");
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
localeManager.sendCustomMessage(pplayer, ChatColor.YELLOW + "Running PlayerParticles " + ChatColor.AQUA + "v" + PlayerParticles.getInstance().getDescription().getVersion());
localeManager.sendCustomMessage(pplayer, ChatColor.YELLOW + "Plugin created by: " + ChatColor.AQUA + "Esophose");
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
@ -25,8 +23,8 @@ public class VersionCommandModule implements CommandModule {
return "version";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_VERSION;
public String getDescriptionKey() {
return "command-description-version";
}
public String getArguments() {

View file

@ -1,28 +1,29 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
public class WorldsCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
if (PermissionManager.getDisabledWorlds() == null || PermissionManager.getDisabledWorlds().isEmpty()) {
LangManager.sendMessage(pplayer, Lang.DISABLED_WORLDS_NONE);
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
if (permissionManager.getDisabledWorlds() == null || permissionManager.getDisabledWorlds().isEmpty()) {
localeManager.sendMessage(pplayer, "disabled-worlds-none");
return;
}
StringBuilder worlds = new StringBuilder();
for (String s : PermissionManager.getDisabledWorlds()) {
for (String s : permissionManager.getDisabledWorlds()) {
worlds.append(s).append(", ");
}
if (worlds.length() > 2) worlds = new StringBuilder(worlds.substring(0, worlds.length() - 2));
LangManager.sendCustomMessage(pplayer, LangManager.getText(Lang.DISABLED_WORLDS) + " " + worlds);
localeManager.sendCustomMessage(pplayer, localeManager.getLocaleMessage("disabled-worlds") + " " + worlds);
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
@ -33,8 +34,8 @@ public class WorldsCommandModule implements CommandModule {
return "worlds";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_WORLDS;
public String getDescriptionKey() {
return "command-description-worlds";
}
public String getArguments() {

View file

@ -0,0 +1,393 @@
package dev.esophose.playerparticles.config;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class CommentedConfigurationSection implements ConfigurationSection {
protected ConfigurationSection config;
public CommentedConfigurationSection(ConfigurationSection configuration) {
this.config = configuration;
}
/**
* Gets a defaulted boolean value. These accept values of either "default", true, or false
*
* @param path The value key
* @return null for "default", otherwise true or false
*/
public Boolean getDefaultedBoolean(String path) {
if (this.isBoolean(path)) {
return this.getBoolean(path);
} else if (this.isString(path)) {
String stringValue = this.getString(path);
if (stringValue != null && stringValue.equalsIgnoreCase("default"))
return null;
}
return null;
}
/**
* Gets a defaulted boolean value. These accept values of either "default", true, or false
*
* @param path The value key
* @param def The value to return if the key is not found
* @return null for "default", otherwise true or false
*/
public Boolean getDefaultedBoolean(String path, Boolean def) {
Object value = this.get(path);
if (value instanceof Boolean) {
return (Boolean) value;
} else if (value instanceof String) {
String stringValue = (String) value;
if (stringValue.equalsIgnoreCase("default"))
return null;
}
if (value == null)
return def;
return null;
}
@Override
public Set<String> getKeys(boolean b) {
return this.config.getKeys(b);
}
@Override
public Map<String, Object> getValues(boolean b) {
return this.config.getValues(b);
}
@Override
public boolean contains(String s) {
return this.config.contains(s);
}
@Override
public boolean contains(String s, boolean b) {
return this.config.contains(s, b);
}
@Override
public boolean isSet(String s) {
return this.config.isSet(s);
}
@Override
public String getCurrentPath() {
return this.config.getCurrentPath();
}
@Override
public String getName() {
return this.config.getName();
}
@Override
public Configuration getRoot() {
return this.config.getRoot();
}
@Override
public ConfigurationSection getParent() {
return this.config.getParent();
}
@Override
public Object get(String s) {
return this.config.get(s);
}
@Override
public Object get(String s, Object o) {
return this.config.get(s, o);
}
@Override
public void set(String s, Object o) {
this.config.set(s, o);
}
@Override
public CommentedConfigurationSection createSection(String s) {
return new CommentedConfigurationSection(this.config.createSection(s));
}
@Override
public CommentedConfigurationSection createSection(String s, Map<?, ?> map) {
return new CommentedConfigurationSection(this.config.createSection(s, map));
}
@Override
public String getString(String s) {
return this.config.getString(s);
}
@Override
public String getString(String s, String s1) {
return this.config.getString(s, s1);
}
@Override
public boolean isString(String s) {
return this.config.isString(s);
}
@Override
public int getInt(String s) {
return this.config.getInt(s);
}
@Override
public int getInt(String s, int i) {
return this.config.getInt(s, i);
}
@Override
public boolean isInt(String s) {
return this.config.isInt(s);
}
@Override
public boolean getBoolean(String s) {
return this.config.getBoolean(s);
}
@Override
public boolean getBoolean(String s, boolean b) {
return this.config.getBoolean(s, b);
}
@Override
public boolean isBoolean(String s) {
return this.config.isBoolean(s);
}
@Override
public double getDouble(String s) {
return this.config.getDouble(s);
}
@Override
public double getDouble(String s, double v) {
return this.config.getDouble(s, v);
}
@Override
public boolean isDouble(String s) {
return this.config.isDouble(s);
}
@Override
public long getLong(String s) {
return this.config.getLong(s);
}
@Override
public long getLong(String s, long l) {
return this.config.getLong(s, l);
}
@Override
public boolean isLong(String s) {
return this.config.isLong(s);
}
@Override
public List<?> getList(String s) {
return this.config.getList(s);
}
@Override
public List<?> getList(String s, List<?> list) {
return this.config.getList(s, list);
}
@Override
public boolean isList(String s) {
return this.config.isList(s);
}
@Override
public List<String> getStringList(String s) {
return this.config.getStringList(s);
}
@Override
public List<Integer> getIntegerList(String s) {
return this.config.getIntegerList(s);
}
@Override
public List<Boolean> getBooleanList(String s) {
return this.config.getBooleanList(s);
}
@Override
public List<Double> getDoubleList(String s) {
return this.config.getDoubleList(s);
}
@Override
public List<Float> getFloatList(String s) {
return this.config.getFloatList(s);
}
@Override
public List<Long> getLongList(String s) {
return this.config.getLongList(s);
}
@Override
public List<Byte> getByteList(String s) {
return this.config.getByteList(s);
}
@Override
public List<Character> getCharacterList(String s) {
return this.config.getCharacterList(s);
}
@Override
public List<Short> getShortList(String s) {
return this.config.getShortList(s);
}
@Override
public List<Map<?, ?>> getMapList(String s) {
return this.config.getMapList(s);
}
@Override
public <T> T getObject(String s, Class<T> aClass) {
return this.config.getObject(s, aClass);
}
@Override
public <T> T getObject(String s, Class<T> aClass, T t) {
return this.config.getObject(s, aClass, t);
}
@Override
public <T extends ConfigurationSerializable> T getSerializable(String s, Class<T> aClass) {
return this.config.getSerializable(s, aClass);
}
@Override
public <T extends ConfigurationSerializable> T getSerializable(String s, Class<T> aClass, T t) {
return this.config.getSerializable(s, aClass, t);
}
@Override
public Vector getVector(String s) {
return this.config.getVector(s);
}
@Override
public Vector getVector(String s, Vector vector) {
return this.config.getVector(s, vector);
}
@Override
public boolean isVector(String s) {
return this.config.isVector(s);
}
@Override
public OfflinePlayer getOfflinePlayer(String s) {
return this.config.getOfflinePlayer(s);
}
@Override
public OfflinePlayer getOfflinePlayer(String s, OfflinePlayer offlinePlayer) {
return this.config.getOfflinePlayer(s, offlinePlayer);
}
@Override
public boolean isOfflinePlayer(String s) {
return this.config.isOfflinePlayer(s);
}
@Override
public ItemStack getItemStack(String s) {
return this.config.getItemStack(s);
}
@Override
public ItemStack getItemStack(String s, ItemStack itemStack) {
return this.config.getItemStack(s, itemStack);
}
@Override
public boolean isItemStack(String s) {
return this.config.isItemStack(s);
}
@Override
public Color getColor(String s) {
return this.config.getColor(s);
}
@Override
public Color getColor(String s, Color color) {
return this.config.getColor(s, color);
}
@Override
public boolean isColor(String s) {
return this.config.isColor(s);
}
@Override
public Location getLocation(String path) {
return this.getSerializable(path, Location.class);
}
@Override
public Location getLocation(String path, Location def) {
return this.getSerializable(path, Location.class, def);
}
@Override
public boolean isLocation(String path) {
return this.getSerializable(path, Location.class) != null;
}
@Override
public CommentedConfigurationSection getConfigurationSection(String s) {
ConfigurationSection section = this.config.getConfigurationSection(s);
if (section == null)
return this.createSection(s);
return new CommentedConfigurationSection(section);
}
@Override
public boolean isConfigurationSection(String s) {
return this.config.isConfigurationSection(s);
}
@Override
public CommentedConfigurationSection getDefaultSection() {
return new CommentedConfigurationSection(this.config.getDefaultSection());
}
@Override
public void addDefault(String s, Object o) {
this.config.addDefault(s, o);
}
}

View file

@ -0,0 +1,90 @@
package dev.esophose.playerparticles.config;
import java.io.File;
import java.io.Reader;
import java.lang.reflect.Field;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import org.yaml.snakeyaml.DumperOptions;
public class CommentedFileConfiguration extends CommentedConfigurationSection {
private int comments;
private CommentedFileConfigurationHelper helper;
private File file;
public CommentedFileConfiguration(Reader configStream, File configFile, int comments, JavaPlugin plugin) {
super(YamlConfiguration.loadConfiguration(configStream));
this.comments = comments;
this.helper = new CommentedFileConfigurationHelper(plugin);
this.file = configFile;
}
public static CommentedFileConfiguration loadConfiguration(JavaPlugin plugin, File file) {
return new CommentedFileConfigurationHelper(plugin).getNewConfig(file);
}
public void set(String path, Object value, String... comments) {
if (!this.contains(path)) {
int subpathIndex = path.lastIndexOf('.');
String subpath = subpathIndex == -1 ? "" : path.substring(0, subpathIndex) + '.';
for (String comment : comments) {
this.set(subpath + this.helper.getPluginName() + "_COMMENT_" + this.comments, " " + comment);
this.comments++;
}
}
this.set(path, value);
}
public void addComments(String... comments) {
for (String comment : comments) {
this.set(this.helper.getPluginName() + "_COMMENT_" + this.comments, " " + comment);
this.comments++;
}
}
public void reloadConfig() {
this.config = YamlConfiguration.loadConfiguration(this.helper.getConfigContent(this.file));
}
public void save() {
this.save(false);
}
public void save(boolean compactLines) {
String config = this.getConfigAsString();
this.helper.saveConfig(config, this.file, compactLines);
}
public void save(File file) {
this.save(file, false);
}
public void save(File file, boolean compactLines) {
String config = this.getConfigAsString();
this.helper.saveConfig(config, file, compactLines);
}
private String getConfigAsString() {
if (!(this.config instanceof YamlConfiguration))
throw new UnsupportedOperationException("Cannot get config string of non-YamlConfiguration");
YamlConfiguration yamlConfiguration = (YamlConfiguration) this.config;
// Edit the configuration to how we want it
try {
Field field_yamlOptions = YamlConfiguration.class.getDeclaredField("yamlOptions");
field_yamlOptions.setAccessible(true);
DumperOptions yamlOptions = (DumperOptions) field_yamlOptions.get(yamlConfiguration);
yamlOptions.setWidth(Integer.MAX_VALUE);
yamlOptions.setIndicatorIndent(2);
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
return yamlConfiguration.saveToString();
}
}

View file

@ -0,0 +1,226 @@
package dev.esophose.playerparticles.config;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.plugin.java.JavaPlugin;
public class CommentedFileConfigurationHelper {
private JavaPlugin plugin;
/**
* Manage custom configurations and files
*/
public CommentedFileConfigurationHelper(JavaPlugin plugin) {
this.plugin = plugin;
}
/**
* Get new configuration
*
* @param file - Path to file
* @return - New SimpleConfig
*/
public CommentedFileConfiguration getNewConfig(File file) {
if (!this.plugin.getDataFolder().exists())
this.plugin.getDataFolder().mkdir();
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
return new CommentedFileConfiguration(this.getConfigContent(file), file, this.getCommentsNum(file), this.plugin);
}
/**
* Read file and make comments SnakeYAML friendly
*
* @param file - Path to file
* @return - File as Input Stream
*/
public Reader getConfigContent(File file) {
if (!file.exists())
return new InputStreamReader(new ByteArrayInputStream(new byte[0]));
try {
int commentNum = 0;
String pluginName = this.getPluginName();
StringBuilder whole = new StringBuilder();
BufferedReader reader = Files.newBufferedReader(Paths.get(file.getAbsolutePath()), StandardCharsets.UTF_8);
String currentLine;
while ((currentLine = reader.readLine()) != null) {
// Convert comments into keys
if (currentLine.trim().startsWith("#")) {
String addLine = currentLine.replaceAll(Pattern.quote("'"), Matcher.quoteReplacement("''"))
.replaceFirst("#", pluginName + "_COMMENT_" + commentNum++ + ": '") + "'";
whole.append(addLine).append("\n");
} else {
whole.append(currentLine).append("\n");
}
}
String config = whole.toString();
Reader configStream = new StringReader(config);
reader.close();
return configStream;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* Get comments from file
*
* @param file - File
* @return - Comments number
*/
private int getCommentsNum(File file) {
if (!file.exists())
return 0;
try {
int comments = 0;
String currentLine;
BufferedReader reader = Files.newBufferedReader(Paths.get(file.getAbsolutePath()), StandardCharsets.UTF_8);
while ((currentLine = reader.readLine()) != null)
if (currentLine.trim().startsWith("#"))
comments++;
reader.close();
return comments;
} catch (IOException e) {
e.printStackTrace();
return 0;
}
}
private String prepareConfigString(String configString) {
boolean lastLine = false;
String[] lines = configString.split("\n");
StringBuilder config = new StringBuilder();
for (String line : lines) {
if (line.trim().startsWith(this.getPluginName() + "_COMMENT")) {
int whitespaceIndex = line.indexOf(line.trim());
String comment = line.substring(0, whitespaceIndex) + "#" + line.substring(line.indexOf(":") + 3, line.length() - 1);
String normalComment;
if (comment.trim().startsWith("#'")) {
normalComment = comment.substring(0, comment.length() - 1).replaceFirst("#'", "# ");
} else {
normalComment = comment;
}
normalComment = normalComment.replaceAll("''", "'");
if (!lastLine) {
config.append(normalComment).append("\n");
} else {
config.append("\n").append(normalComment).append("\n");
}
lastLine = false;
} else {
config.append(line).append("\n");
lastLine = true;
}
}
return config.toString();
}
/**
* Saves configuration to file
*
* @param configString - Config string
* @param file - Config file
* @param compactLines - If lines should forcefully be separated by only one newline character
*/
public void saveConfig(String configString, File file, boolean compactLines) {
String configuration = this.prepareConfigString(configString).replaceAll("\n\n", "\n");
// Apply post-processing to config string to make it pretty
StringBuilder stringBuilder = new StringBuilder();
try (Scanner scanner = new Scanner(configuration)) {
boolean lastLineHadContent = false;
int lastCommentSpacing = -1;
int lastLineSpacing = -1;
boolean forceCompact = false;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
boolean lineHadContent = false;
boolean lineWasComment = false;
int commentSpacing = -1;
int lineSpacing = line.indexOf(line.trim());
if (line.trim().startsWith("#")) {
lineWasComment = true;
String trimmed = line.trim().replaceFirst("#", "");
commentSpacing = trimmed.indexOf(trimmed.trim());
} else if (!line.trim().isEmpty()) {
lineHadContent = true;
if (line.trim().startsWith("-"))
forceCompact = true;
}
if (!compactLines && !forceCompact && (
(lastLineSpacing != -1 && lineSpacing != lastLineSpacing)
|| (commentSpacing != -1 && commentSpacing < lastCommentSpacing)
|| (lastLineHadContent && lineHadContent)
|| (lineWasComment && lastLineHadContent))
&& !(lastLineHadContent && !lineWasComment)) {
stringBuilder.append('\n');
}
stringBuilder.append(line).append('\n');
lastLineHadContent = lineHadContent;
lastCommentSpacing = commentSpacing;
lastLineSpacing = lineSpacing;
forceCompact = false;
}
}
try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(file.getAbsolutePath()), StandardCharsets.UTF_8)) {
writer.write(stringBuilder.toString());
writer.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
public String getPluginName() {
return this.plugin.getDescription().getName();
}
}

View file

@ -0,0 +1,31 @@
package dev.esophose.playerparticles.database;
import java.sql.Connection;
import java.sql.SQLException;
public abstract class DataMigration {
private final int revision;
public DataMigration(int revision) {
this.revision = revision;
}
/**
* Migrates the database to this migration stage
*
* @param connector The connector for the database
* @param connection The connection to the database
* @param tablePrefix The prefix of the database
* @throws SQLException Any error that occurs during the SQL execution
*/
public abstract void migrate(DatabaseConnector connector, Connection connection, String tablePrefix) throws SQLException;
/**
* @return the revision number of this migration
*/
public int getRevision() {
return this.revision;
}
}

View file

@ -7,8 +7,8 @@ public interface DatabaseConnector {
/**
* Checks if the connection to the database has been created
*
* @return If the connection is created or not
*
* @return true if the connection is created, otherwise false
*/
boolean isInitialized();
@ -19,16 +19,16 @@ public interface DatabaseConnector {
/**
* Executes a callback with a Connection passed and automatically closes it when finished
*
*
* @param callback The callback to execute once the connection is retrieved
*/
void connect(ConnectionCallback callback);
/**
* Allows Lambda expressions to be used to reduce duplicated code for getting connections
* Wraps a connection in a callback which will automagically handle catching sql errors
*/
interface ConnectionCallback {
void execute(Connection connection) throws SQLException;
void accept(Connection connection) throws SQLException;
}
}

View file

@ -1,31 +1,25 @@
package dev.esophose.playerparticles.database;
import java.sql.Connection;
import java.sql.SQLException;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import java.sql.Connection;
import java.sql.SQLException;
import org.bukkit.plugin.Plugin;
public class MySqlDatabaseConnector implements DatabaseConnector {
public class MySQLConnector implements DatabaseConnector {
private final Plugin plugin;
private HikariDataSource hikari;
private boolean initializedSuccessfully;
public MySqlDatabaseConnector() {
String hostname = PSetting.DATABASE_HOSTNAME.getString();
String port = PSetting.DATABASE_PORT.getString();
String database = PSetting.DATABASE_NAME.getString();
String user = PSetting.DATABASE_USER_NAME.getString();
String pass = PSetting.DATABASE_USER_PASSWORD.getString();
boolean useSSL = PSetting.DATABASE_USE_SSL.getBoolean();
public MySQLConnector(Plugin plugin, String hostname, int port, String database, String username, String password, boolean useSSL) {
this.plugin = plugin;
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database + "?useSSL=" + useSSL);
config.setUsername(user);
config.setPassword(pass);
config.setMaximumPoolSize(3);
config.setUsername(username);
config.setPassword(password);
config.setMaximumPoolSize(5);
try {
this.hikari = new HikariDataSource(config);
@ -45,9 +39,10 @@ public class MySqlDatabaseConnector implements DatabaseConnector {
public void connect(ConnectionCallback callback) {
try (Connection connection = this.hikari.getConnection()) {
callback.execute(connection);
callback.accept(connection);
} catch (SQLException ex) {
PlayerParticles.getPlugin().getLogger().severe("An error occurred retrieving a MySQL database connection: " + ex.getMessage());
this.plugin.getLogger().severe("An error occurred executing a MySQL query: " + ex.getMessage());
ex.printStackTrace();
}
}

View file

@ -0,0 +1,58 @@
package dev.esophose.playerparticles.database;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.bukkit.plugin.Plugin;
public class SQLiteConnector implements DatabaseConnector {
private final Plugin plugin;
private final String connectionString;
private Connection connection;
public SQLiteConnector(Plugin plugin) {
this.plugin = plugin;
this.connectionString = "jdbc:sqlite:" + plugin.getDataFolder() + File.separator + plugin.getDescription().getName().toLowerCase() + ".db";
try {
Class.forName("org.sqlite.JDBC"); // This is required to put here for Spigot 1.10 and below for some reason
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public boolean isInitialized() {
return true; // Always available
}
public void closeConnection() {
try {
if (this.connection != null) {
this.connection.close();
}
} catch (SQLException ex) {
this.plugin.getLogger().severe("An error occurred closing the SQLite database connection: " + ex.getMessage());
}
}
public void connect(ConnectionCallback callback) {
if (this.connection == null) {
try {
this.connection = DriverManager.getConnection(this.connectionString);
} catch (SQLException ex) {
this.plugin.getLogger().severe("An error occurred retrieving the SQLite database connection: " + ex.getMessage());
}
}
try {
callback.accept(this.connection);
} catch (Exception ex) {
this.plugin.getLogger().severe("An error occurred executing an SQLite query: " + ex.getMessage());
ex.printStackTrace();
}
}
}

View file

@ -1,49 +0,0 @@
package dev.esophose.playerparticles.database;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import dev.esophose.playerparticles.PlayerParticles;
public class SqliteDatabaseConnector implements DatabaseConnector {
private final String connectionString;
private Connection connection;
public SqliteDatabaseConnector(String directory) {
this.connectionString = "jdbc:sqlite:" + directory + File.separator + "playerparticles.db";
}
public boolean isInitialized() {
return true; // Always available
}
public void closeConnection() {
try {
if (this.connection != null) {
this.connection.close();
}
} catch (SQLException ex) {
PlayerParticles.getPlugin().getLogger().severe("An error occurred closing the SQLite database connection: " + ex.getMessage());
}
}
public void connect(ConnectionCallback callback) {
if (this.connection == null) {
try {
this.connection = DriverManager.getConnection(this.connectionString);
} catch (SQLException ex) {
PlayerParticles.getPlugin().getLogger().severe("An error occurred retrieving the SQLite database connection: " + ex.getMessage());
}
}
try {
callback.execute(this.connection);
} catch (SQLException ex) {
PlayerParticles.getPlugin().getLogger().severe("An error occurred retrieving the SQLite database connection: " + ex.getMessage());
}
}
}

View file

@ -0,0 +1,90 @@
package dev.esophose.playerparticles.database.migrations;
import dev.esophose.playerparticles.database.DataMigration;
import dev.esophose.playerparticles.database.DatabaseConnector;
import dev.esophose.playerparticles.database.SQLiteConnector;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
public class _1_InitialMigration extends DataMigration {
public _1_InitialMigration() {
super(1);
}
@Override
public void migrate(DatabaseConnector connector, Connection connection, String tablePrefix) throws SQLException {
// Check if we are still running legacy data
boolean hasLegacy;
String legacyQuery;
if (connector instanceof SQLiteConnector) {
legacyQuery = "SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?";
} else {
legacyQuery = "SHOW TABLES LIKE ?";
}
try (PreparedStatement statement = connection.prepareStatement(legacyQuery)) {
statement.setString(1, "pp_data_note");
hasLegacy = statement.executeQuery().next();
}
if (hasLegacy) {
// Drop legacy tables
try (Statement statement = connection.createStatement()) {
statement.addBatch("DROP TABLE IF EXISTS pp_users");
statement.addBatch("DROP TABLE IF EXISTS pp_fixed");
statement.addBatch("DROP TABLE IF EXISTS pp_data_item");
statement.addBatch("DROP TABLE IF EXISTS pp_data_block");
statement.addBatch("DROP TABLE IF EXISTS pp_data_color");
statement.addBatch("DROP TABLE IF EXISTS pp_data_note");
statement.executeBatch();
}
}
// Check if we are still running legacy data
boolean hasTables;
String tablesQuery;
if (connector instanceof SQLiteConnector) {
tablesQuery = "SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?";
} else {
tablesQuery = "SHOW TABLES LIKE ?";
}
try (PreparedStatement statement = connection.prepareStatement(tablesQuery)) {
statement.setString(1, "pp_settings");
hasTables = statement.executeQuery().next();
}
// Rename the tables if they aleady exist
if (hasTables) {
try (Statement statement = connection.createStatement()) {
if (connector instanceof SQLiteConnector) {
statement.addBatch("ALTER TABLE pp_settings RENAME TO " + tablePrefix + "settings");
statement.addBatch("ALTER TABLE pp_particle RENAME TO " + tablePrefix + "particle");
statement.addBatch("ALTER TABLE pp_group RENAME TO " + tablePrefix + "group");
statement.addBatch("ALTER TABLE pp_fixed RENAME TO " + tablePrefix + "fixed");
} else {
statement.addBatch("RENAME TABLE pp_settings TO " + tablePrefix + "settings");
statement.addBatch("RENAME TABLE pp_particle TO " + tablePrefix + "particle");
statement.addBatch("RENAME TABLE pp_group TO " + tablePrefix + "group");
statement.addBatch("RENAME TABLE pp_fixed TO " + tablePrefix + "fixed");
}
statement.executeBatch();
}
} else { // Otherwise create them
try (Statement createStatement = connection.createStatement()) {
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "settings (player_uuid VARCHAR(36), particles_hidden TINYINT)");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "particle (uuid VARCHAR(36), group_uuid VARCHAR(36), id SMALLINT, effect VARCHAR(100), style VARCHAR(100), item_material VARCHAR(100), block_material VARCHAR(100), note SMALLINT, r SMALLINT, g SMALLINT, b SMALLINT, PRIMARY KEY(uuid))");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "group (uuid VARCHAR(36), owner_uuid VARCHAR(36), name VARCHAR(100), PRIMARY KEY(uuid))");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "fixed (owner_uuid VARCHAR(36), id SMALLINT, particle_uuid VARCHAR(36), world VARCHAR(100), xPos DOUBLE, yPos DOUBLE, zPos DOUBLE, PRIMARY KEY(owner_uuid, id), FOREIGN KEY(particle_uuid) REFERENCES pp_particle(uuid) ON DELETE CASCADE)");
createStatement.executeBatch();
}
}
}
}

View file

@ -1,8 +1,10 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.gui.GuiInventoryEditData.ColorData;
import dev.esophose.playerparticles.hook.PlaceholderAPIHook;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemFlag;
@ -10,8 +12,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Dye;
import dev.esophose.playerparticles.gui.GuiInventoryEditData.ColorData;
public class GuiActionButton {
private int slot;
@ -95,10 +95,11 @@ public class GuiActionButton {
/**
* Gets the ItemStack icon that goes into the GUI
*
*
* @param pplayer The PPlayer that is viewing the icon
* @return The icon ItemStack for the GUI
*/
public ItemStack getIcon() {
public ItemStack getIcon(PPlayer pplayer) {
ItemStack itemStack;
if (this.icons != null) {
itemStack = new ItemStack(this.icons[this.iconIndex]);
@ -112,8 +113,8 @@ public class GuiActionButton {
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta != null) {
itemMeta.setDisplayName(this.name);
itemMeta.setLore(parseLore(this.lore));
itemMeta.setDisplayName(PlaceholderAPIHook.applyPlaceholders(pplayer.getPlayer(), this.name));
itemMeta.setLore(parseLore(pplayer, this.lore));
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS);
itemStack.setItemMeta(itemMeta);
}
@ -151,11 +152,12 @@ public class GuiActionButton {
* Builds lore from a list of Strings
* Parses \n as a new lore line
* Ignores empty lore lines
*
*
* @param pplayer The PPlayer viewing the lore
* @param lore The lines of lore
* @return A parsed list of lore text
*/
public static List<String> parseLore(String... lore) {
public static List<String> parseLore(PPlayer pplayer, String... lore) {
List<String> parsedLore = new ArrayList<>();
for (String line : lore) {
// Try to maintain the color going to the next line if it's split
@ -169,7 +171,7 @@ public class GuiActionButton {
String[] splitLines = line.split("\n");
for (String parsedLine : splitLines) {
if (ChatColor.stripColor(parsedLine).isEmpty()) continue;
parsedLore.add(lineColor + parsedLine);
parsedLore.add(PlaceholderAPIHook.applyPlaceholders(pplayer.getPlayer(), lineColor + parsedLine));
}
}
return parsedLore;

View file

@ -1,8 +1,12 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.ParticleUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -13,12 +17,8 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.ParticleUtils;
public abstract class GuiInventory implements InventoryHolder {
protected enum BorderColor {
WHITE(0, "WHITE_STAINED_GLASS_PANE"),
ORANGE(1, "ORANGE_STAINED_GLASS_PANE"),
@ -124,7 +124,7 @@ public abstract class GuiInventory implements InventoryHolder {
*/
protected void populate() {
for (GuiActionButton button : this.actionButtons) {
this.inventory.setItem(button.getSlot(), button.getIcon());
this.inventory.setItem(button.getSlot(), button.getIcon(this.pplayer));
}
}
@ -135,7 +135,7 @@ public abstract class GuiInventory implements InventoryHolder {
for (GuiActionButton button : this.actionButtons) {
if (button.isTickable()) {
button.onTick();
this.inventory.setItem(button.getSlot(), button.getIcon());
this.inventory.setItem(button.getSlot(), button.getIcon(this.pplayer));
}
}
}
@ -154,7 +154,7 @@ public abstract class GuiInventory implements InventoryHolder {
for (GuiActionButton button : this.actionButtons) {
if (button.getSlot() == slot) {
button.handleClick(isShiftClick);
if (PSetting.GUI_BUTTON_SOUND.getBoolean() && event.getWhoClicked() instanceof Player) {
if (Setting.GUI_BUTTON_SOUND.getBoolean() && event.getWhoClicked() instanceof Player) {
Player player = (Player) event.getWhoClicked();
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 0.5f, 1);
}
@ -162,10 +162,5 @@ public abstract class GuiInventory implements InventoryHolder {
}
}
}
@FunctionalInterface
public interface GuiInventoryEditFinishedCallback {
void execute();
}
}

View file

@ -1,30 +1,35 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("deprecation")
public class GuiInventoryDefault extends GuiInventory {
public GuiInventoryDefault(PPlayer pplayer) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_PLAYERPARTICLES)));
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-playerparticles")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.WHITE);
@ -39,15 +44,15 @@ public class GuiInventoryDefault extends GuiInventory {
SkullMeta currentIconMeta = (SkullMeta) headIcon.getItemMeta();
if (currentIconMeta != null) {
currentIconMeta.setDisplayName(LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + pplayer.getPlayer().getName());
currentIconMeta.setDisplayName(localeManager.getLocaleMessage("gui-color-icon-name") + pplayer.getPlayer().getName());
String[] currentIconLore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_ACTIVE_PARTICLES, pplayer.getActiveParticles().size()),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SAVED_GROUPS, pplayer.getParticleGroups().size() - 1),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_FIXED_EFFECTS, pplayer.getFixedEffectIds().size()),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-active-particles", StringPlaceholders.single("amount", pplayer.getActiveParticles().size())),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-saved-groups", StringPlaceholders.single("amount", pplayer.getParticleGroups().size() - 1)),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-fixed-effects", StringPlaceholders.single("amount", pplayer.getFixedEffectIds().size())),
" ",
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_COMMANDS_INFO)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-commands-info")
};
currentIconMeta.setLore(GuiActionButton.parseLore(currentIconLore));
currentIconMeta.setLore(GuiActionButton.parseLore(this.pplayer, currentIconLore));
currentIconMeta.setOwner(pplayer.getPlayer().getName());
headIcon.setItemMeta(currentIconMeta);
}
@ -55,8 +60,8 @@ public class GuiInventoryDefault extends GuiInventory {
this.inventory.setItem(13, headIcon);
// Define what slots to put the icons at based on what other slots are visible
boolean manageGroupsVisible = PermissionManager.canPlayerSaveGroups(pplayer);
boolean loadPresetGroupVisible = !ParticleGroupPresetManager.getPresetGroupsForPlayer(pplayer.getPlayer()).isEmpty();
boolean manageGroupsVisible = PlayerParticles.getInstance().getManager(PermissionManager.class).canPlayerSaveGroups(pplayer);
boolean loadPresetGroupVisible = !PlayerParticles.getInstance().getManager(ParticleGroupPresetManager.class).getPresetGroupsForPlayer(pplayer.getPlayer()).isEmpty();
int manageParticlesSlot = -1, manageGroupsSlot = -1, loadPresetGroupSlot = -1;
if (!manageGroupsVisible && !loadPresetGroupVisible) {
@ -77,9 +82,9 @@ public class GuiInventoryDefault extends GuiInventory {
GuiActionButton manageYourParticlesButton = new GuiActionButton(
manageParticlesSlot,
GuiIcon.PARTICLES.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES_DESCRIPTION)},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryManageParticles(pplayer)));
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-manage-your-particles"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-manage-your-particles-description")},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryManageParticles(pplayer)));
this.actionButtons.add(manageYourParticlesButton);
// Manage Your Groups button
@ -87,9 +92,9 @@ public class GuiInventoryDefault extends GuiInventory {
GuiActionButton manageYourGroupsButton = new GuiActionButton(
manageGroupsSlot,
GuiIcon.GROUPS.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS_DESCRIPTION)},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryManageGroups(pplayer)));
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-manage-your-groups"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-manage-your-groups-description")},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryManageGroups(pplayer)));
this.actionButtons.add(manageYourGroupsButton);
}
@ -98,9 +103,9 @@ public class GuiInventoryDefault extends GuiInventory {
GuiActionButton loadPresetGroups = new GuiActionButton(
loadPresetGroupSlot,
GuiIcon.PRESET_GROUPS.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP_DESCRIPTION)},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryLoadPresetGroups(pplayer, false)));
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-load-a-preset-group"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-load-a-preset-group-description")},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryLoadPresetGroups(pplayer, false)));
this.actionButtons.add(loadPresetGroups);
}
@ -112,12 +117,12 @@ public class GuiInventoryDefault extends GuiInventory {
GuiActionButton editPrimaryEffect = new GuiActionButton(
38,
GuiIcon.EDIT_EFFECT.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_EFFECT),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_EFFECT_DESCRIPTION)},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-primary-effect"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-effect-description")},
(button, isShiftClick) -> {
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
List<Runnable> callbacks = new ArrayList<>();
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup();
if (canEditPrimaryStyleAndData) {
@ -130,36 +135,36 @@ public class GuiInventoryDefault extends GuiInventory {
} else {
group.getParticles().add(editingParticle);
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
GuiHandler.transition(new GuiInventoryDefault(pplayer));
guiManager.transition(new GuiInventoryDefault(pplayer));
});
callbacks.get(1).execute();
callbacks.get(1).run();
});
this.actionButtons.add(editPrimaryEffect);
// Edit Primary Style
String[] editPrimaryStyleLore;
if (canEditPrimaryStyleAndData) {
editPrimaryStyleLore = new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE_DESCRIPTION)};
editPrimaryStyleLore = new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-style-description")};
} else {
editPrimaryStyleLore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE_DESCRIPTION),
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE_MISSING_EFFECT)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-style-description"),
localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-edit-primary-style-missing-effect")
};
}
GuiActionButton editPrimaryStyle = new GuiActionButton(
40,
GuiIcon.EDIT_STYLE.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE),
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-primary-style"),
editPrimaryStyleLore,
(button, isShiftClick) -> {
if (!canEditPrimaryStyleAndData) return;
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
List<Runnable> callbacks = new ArrayList<>();
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) {
@ -168,41 +173,41 @@ public class GuiInventoryDefault extends GuiInventory {
break;
}
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
GuiHandler.transition(new GuiInventoryDefault(pplayer));
guiManager.transition(new GuiInventoryDefault(pplayer));
});
callbacks.get(1).execute();
callbacks.get(1).run();
});
this.actionButtons.add(editPrimaryStyle);
// Edit Primary Data
String[] editPrimaryDataLore;
if (canEditPrimaryStyleAndData && doesEffectUseData) {
editPrimaryDataLore = new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_DESCRIPTION)};
editPrimaryDataLore = new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-data-description")};
} else if (canEditPrimaryStyleAndData) {
editPrimaryDataLore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_DESCRIPTION),
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_UNAVAILABLE)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-data-description"),
localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-edit-primary-data-unavailable")
};
} else {
editPrimaryDataLore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_DESCRIPTION),
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_MISSING_EFFECT)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-data-description"),
localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-edit-primary-data-missing-effect")
};
}
GuiActionButton editPrimaryData = new GuiActionButton(
42,
GuiIcon.EDIT_DATA.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA),
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-primary-data"),
editPrimaryDataLore,
(button, isShiftClick) -> {
if (!canEditPrimaryStyleAndData || !doesEffectUseData) return;
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
List<Runnable> callbacks = new ArrayList<>();
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) {
@ -214,12 +219,12 @@ public class GuiInventoryDefault extends GuiInventory {
break;
}
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
GuiHandler.transition(new GuiInventoryDefault(pplayer));
guiManager.transition(new GuiInventoryDefault(pplayer));
});
callbacks.get(1).execute();
callbacks.get(1).run();
});
this.actionButtons.add(editPrimaryData);

View file

@ -1,8 +1,9 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
@ -11,6 +12,11 @@ import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.NMSUtil;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
@ -18,11 +24,6 @@ import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@SuppressWarnings("deprecation")
public class GuiInventoryEditData extends GuiInventory {
@ -33,22 +34,22 @@ public class GuiInventoryEditData extends GuiInventory {
static {
colorMapping = new ColorData[]{
new ColorData(DyeColor.RED, ParticleUtils.closestMatchWithFallback(false, "RED_DYE", "ROSE_RED"), new OrdinaryColor(255, 0, 0), Lang.GUI_EDIT_DATA_COLOR_RED),
new ColorData(DyeColor.ORANGE, ParticleUtils.closestMatchWithFallback(false, "ORANGE_DYE"), new OrdinaryColor(255, 140, 0), Lang.GUI_EDIT_DATA_COLOR_ORANGE),
new ColorData(DyeColor.YELLOW, ParticleUtils.closestMatchWithFallback(false, "YELLOW_DYE", "DANDELION_YELLOW"), new OrdinaryColor(255, 255, 0), Lang.GUI_EDIT_DATA_COLOR_YELLOW),
new ColorData(DyeColor.LIME, ParticleUtils.closestMatchWithFallback(false, "LIME_DYE"), new OrdinaryColor(50, 205, 50), Lang.GUI_EDIT_DATA_COLOR_LIME_GREEN),
new ColorData(DyeColor.GREEN, ParticleUtils.closestMatchWithFallback(false, "GREEN_DYE", "CACTUS_GREEN"), new OrdinaryColor(0, 128, 0), Lang.GUI_EDIT_DATA_COLOR_GREEN),
new ColorData(DyeColor.BLUE, ParticleUtils.closestMatchWithFallback(false, "BLUE_DYE", "LAPIS_LAZULI"), new OrdinaryColor(0, 0, 255), Lang.GUI_EDIT_DATA_COLOR_BLUE),
new ColorData(DyeColor.CYAN, ParticleUtils.closestMatchWithFallback(false, "CYAN_DYE"), new OrdinaryColor(0, 139, 139), Lang.GUI_EDIT_DATA_COLOR_CYAN),
new ColorData(DyeColor.LIGHT_BLUE, ParticleUtils.closestMatchWithFallback(false, "LIGHT_BLUE_DYE"), new OrdinaryColor(173, 216, 230), Lang.GUI_EDIT_DATA_COLOR_LIGHT_BLUE),
new ColorData(DyeColor.PURPLE, ParticleUtils.closestMatchWithFallback(false, "PURPLE_DYE"), new OrdinaryColor(138, 43, 226), Lang.GUI_EDIT_DATA_COLOR_PURPLE),
new ColorData(DyeColor.MAGENTA, ParticleUtils.closestMatchWithFallback(false, "MAGENTA_DYE"), new OrdinaryColor(202, 31, 123), Lang.GUI_EDIT_DATA_COLOR_MAGENTA),
new ColorData(DyeColor.PINK, ParticleUtils.closestMatchWithFallback(false, "PINK_DYE"), new OrdinaryColor(255, 182, 193), Lang.GUI_EDIT_DATA_COLOR_PINK),
new ColorData(DyeColor.BROWN, ParticleUtils.closestMatchWithFallback(false, "BROWN_DYE", "COCOA_BEANS"), new OrdinaryColor(139, 69, 19), Lang.GUI_EDIT_DATA_COLOR_BROWN),
new ColorData(DyeColor.BLACK, ParticleUtils.closestMatchWithFallback(false, "BLACK_DYE", "INK_SAC"), new OrdinaryColor(0, 0, 0), Lang.GUI_EDIT_DATA_COLOR_BLACK),
new ColorData(DyeColor.GRAY, ParticleUtils.closestMatchWithFallback(false, "GRAY_DYE"), new OrdinaryColor(128, 128, 128), Lang.GUI_EDIT_DATA_COLOR_GRAY),
new ColorData(DyeColor.getByDyeData((byte) 7), ParticleUtils.closestMatchWithFallback(false, "LIGHT_GRAY_DYE"), new OrdinaryColor(192, 192, 192), Lang.GUI_EDIT_DATA_COLOR_LIGHT_GRAY),
new ColorData(DyeColor.WHITE, ParticleUtils.closestMatchWithFallback(false, "WHITE_DYE", "BONE_MEAL"), new OrdinaryColor(255, 255, 255), Lang.GUI_EDIT_DATA_COLOR_WHITE),
new ColorData(DyeColor.RED, ParticleUtils.closestMatchWithFallback(false, "RED_DYE", "ROSE_RED"), new OrdinaryColor(255, 0, 0), "gui-edit-data-color-red"),
new ColorData(DyeColor.ORANGE, ParticleUtils.closestMatchWithFallback(false, "ORANGE_DYE"), new OrdinaryColor(255, 140, 0), "gui-edit-data-color-orange"),
new ColorData(DyeColor.YELLOW, ParticleUtils.closestMatchWithFallback(false, "YELLOW_DYE", "DANDELION_YELLOW"), new OrdinaryColor(255, 255, 0), "gui-edit-data-color-yellow"),
new ColorData(DyeColor.LIME, ParticleUtils.closestMatchWithFallback(false, "LIME_DYE"), new OrdinaryColor(50, 205, 50), "gui-edit-data-color-lime-green"),
new ColorData(DyeColor.GREEN, ParticleUtils.closestMatchWithFallback(false, "GREEN_DYE", "CACTUS_GREEN"), new OrdinaryColor(0, 128, 0), "gui-edit-data-color-green"),
new ColorData(DyeColor.BLUE, ParticleUtils.closestMatchWithFallback(false, "BLUE_DYE", "LAPIS_LAZULI"), new OrdinaryColor(0, 0, 255), "gui-edit-data-color-blue"),
new ColorData(DyeColor.CYAN, ParticleUtils.closestMatchWithFallback(false, "CYAN_DYE"), new OrdinaryColor(0, 139, 139), "gui-edit-data-color-cyan"),
new ColorData(DyeColor.LIGHT_BLUE, ParticleUtils.closestMatchWithFallback(false, "LIGHT_BLUE_DYE"), new OrdinaryColor(173, 216, 230), "gui-edit-data-color-light-blue"),
new ColorData(DyeColor.PURPLE, ParticleUtils.closestMatchWithFallback(false, "PURPLE_DYE"), new OrdinaryColor(138, 43, 226), "gui-edit-data-color-purple"),
new ColorData(DyeColor.MAGENTA, ParticleUtils.closestMatchWithFallback(false, "MAGENTA_DYE"), new OrdinaryColor(202, 31, 123), "gui-edit-data-color-magenta"),
new ColorData(DyeColor.PINK, ParticleUtils.closestMatchWithFallback(false, "PINK_DYE"), new OrdinaryColor(255, 182, 193), "gui-edit-data-color-pink"),
new ColorData(DyeColor.BROWN, ParticleUtils.closestMatchWithFallback(false, "BROWN_DYE", "COCOA_BEANS"), new OrdinaryColor(139, 69, 19), "gui-edit-data-color-brown"),
new ColorData(DyeColor.BLACK, ParticleUtils.closestMatchWithFallback(false, "BLACK_DYE", "INK_SAC"), new OrdinaryColor(0, 0, 0), "gui-edit-data-color-black"),
new ColorData(DyeColor.GRAY, ParticleUtils.closestMatchWithFallback(false, "GRAY_DYE"), new OrdinaryColor(128, 128, 128), "gui-edit-data-color-gray"),
new ColorData(DyeColor.getByDyeData((byte) 7), ParticleUtils.closestMatchWithFallback(false, "LIGHT_GRAY_DYE"), new OrdinaryColor(192, 192, 192), "gui-edit-data-color-light-gray"),
new ColorData(DyeColor.WHITE, ParticleUtils.closestMatchWithFallback(false, "WHITE_DYE", "BONE_MEAL"), new OrdinaryColor(255, 255, 255), "gui-edit-data-color-white"),
};
rainbowColorMapping = new ColorData[]{
@ -138,8 +139,10 @@ public class GuiInventoryEditData extends GuiInventory {
}
}
public GuiInventoryEditData(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_DATA)));
public GuiInventoryEditData(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-data")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
this.fillBorder(BorderColor.MAGENTA);
@ -162,9 +165,9 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1,
GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
new String[]{},
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).run());
this.actionButtons.add(backButton);
this.populate();
@ -178,7 +181,9 @@ public class GuiInventoryEditData extends GuiInventory {
* @param callbackList The List of GuiInventoryEditFinishedCallbacks
* @param callbackListPosition The index of the callbackList we're currently at
*/
private void populateColorData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
private void populateColorData(ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
int index = 10;
int nextWrap = 17;
for (ColorData colorData : colorMapping) {
@ -189,10 +194,10 @@ public class GuiInventoryEditData extends GuiInventory {
index,
colorData,
colorData.getName(),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, formattedDisplayColor)},
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", formattedDisplayColor))},
(button, isShiftClick) -> {
editingParticle.setColor(colorData.getOrdinaryColor());
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(setColorButton);
@ -207,11 +212,11 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton setRainbowColorButton = new GuiActionButton(
39,
rainbowColorMapping,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RAINBOW),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RAINBOW))},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("rainbow"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("rainbow")))},
(button, isShiftClick) -> {
editingParticle.setColor(new OrdinaryColor(999, 999, 999));
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(setRainbowColorButton);
@ -222,11 +227,11 @@ public class GuiInventoryEditData extends GuiInventory {
randomizedColors = randomizedColorsList.toArray(randomizedColors);
GuiActionButton setRandomColorButton = new GuiActionButton(41,
randomizedColors,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RANDOM),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RANDOM))},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("random"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("random")))},
(button, isShiftClick) -> {
editingParticle.setColor(new OrdinaryColor(998, 998, 998));
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(setRandomColorButton);
}
@ -239,7 +244,10 @@ public class GuiInventoryEditData extends GuiInventory {
* @param pageNumber The current page number
* @param callbackListPosition The index of the callbackList we're currently at
*/
private void populateNoteData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
private void populateNoteData(ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
int numberOfItems = noteColorMapping.length;
int itemsPerPage = 14;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
@ -249,8 +257,8 @@ public class GuiInventoryEditData extends GuiInventory {
for (int i = (pageNumber - 1) * itemsPerPage; i < numberOfItems; i++) {
ColorData colorData = NMSUtil.getVersionNumber() > 13 ? noteColorMapping[i] : noteColorMappingOld[i];
String formattedDisplayName = LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, i) + " (" + colorData.getName() + LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ")";
String formattedDescription = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, i));
String formattedDisplayName = localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-select-data-note", StringPlaceholders.single("note", i)) + " (" + colorData.getName() + localeManager.getLocaleMessage("gui-color-icon-name") + ")";
String formattedDescription = localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("gui-select-data-note", StringPlaceholders.single("note", i))));
// Note Color Buttons
int noteIndex = i;
@ -261,7 +269,7 @@ public class GuiInventoryEditData extends GuiInventory {
new String[]{formattedDescription},
(button, isShiftClick) -> {
editingParticle.setNoteColor(new NoteColor(noteIndex));
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(setColorButton);
@ -277,11 +285,11 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton setRainbowColorButton = new GuiActionButton(
39,
rainbowColorMapping,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RAINBOW),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RAINBOW))},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("rainbow"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("rainbow")))},
(button, isShiftClick) -> {
editingParticle.setNoteColor(new NoteColor(99));
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(setRainbowColorButton);
@ -293,11 +301,11 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton setRandomColorButton = new GuiActionButton(
41,
randomizedColors,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RANDOM),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RANDOM))},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("random"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("random")))},
(button, isShiftClick) -> {
editingParticle.setNoteColor(new NoteColor(98));
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(setRandomColorButton);
@ -306,9 +314,9 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
@ -317,9 +325,9 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}
}
@ -332,7 +340,10 @@ public class GuiInventoryEditData extends GuiInventory {
* @param pageNumber The current page number
* @param callbackListPosition The index of the callbackList we're currently at
*/
private void populateItemData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
private void populateItemData(ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
int numberOfItems = ITEM_MATERIALS.size();
int itemsPerPage = 28;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
@ -346,11 +357,11 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton setRainbowColorButton = new GuiActionButton(
slot,
material,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + material.name().toLowerCase(),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, material.name().toLowerCase())},
localeManager.getLocaleMessage("gui-color-icon-name") + material.name().toLowerCase(),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", material.name().toLowerCase()))},
(button, isShiftClick) -> {
editingParticle.setItemMaterial(material);
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(setRainbowColorButton);
@ -367,9 +378,9 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
@ -378,9 +389,9 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}
}
@ -393,7 +404,10 @@ public class GuiInventoryEditData extends GuiInventory {
* @param pageNumber The current page number
* @param callbackListPosition The index of the callbackList we're currently at
*/
private void populateBlockData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
private void populateBlockData(ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
int numberOfItems = BLOCK_MATERIALS.size();
int itemsPerPage = 28;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
@ -407,11 +421,11 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton setRainbowColorButton = new GuiActionButton(
slot,
material,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + material.name().toLowerCase(),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, material.name().toLowerCase())},
localeManager.getLocaleMessage("gui-color-icon-name") + material.name().toLowerCase(),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", material.name().toLowerCase()))},
(button, isShiftClick) -> {
editingParticle.setBlockMaterial(material);
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(setRainbowColorButton);
@ -428,9 +442,9 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
@ -439,9 +453,9 @@ public class GuiInventoryEditData extends GuiInventory {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}
}
@ -453,13 +467,13 @@ public class GuiInventoryEditData extends GuiInventory {
private DyeColor dyeColor;
private Material material;
private OrdinaryColor ordinaryColor;
private Lang name;
private String nameKey;
public ColorData(DyeColor dyeColor, Material material, OrdinaryColor ordinaryColor, Lang name) {
public ColorData(DyeColor dyeColor, Material material, OrdinaryColor ordinaryColor, String nameKey) {
this.dyeColor = dyeColor;
this.material = material;
this.ordinaryColor = ordinaryColor;
this.name = name;
this.nameKey = nameKey;
}
/**
@ -495,7 +509,7 @@ public class GuiInventoryEditData extends GuiInventory {
* @return The name of this color
*/
public String getName() {
return LangManager.getText(this.name);
return PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage(this.nameKey);
}
}

View file

@ -1,26 +1,30 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.List;
import org.bukkit.Bukkit;
public class GuiInventoryEditEffect extends GuiInventory {
public GuiInventoryEditEffect(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_EFFECT)));
public GuiInventoryEditEffect(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-effect")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.LIGHT_BLUE);
// Select Effect Buttons
List<ParticleEffect> effectsUserHasPermissionFor = PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer());
List<ParticleEffect> effectsUserHasPermissionFor = PlayerParticles.getInstance().getManager(PermissionManager.class).getEffectsUserHasPermissionFor(pplayer.getPlayer());
int numberOfItems = effectsUserHasPermissionFor.size();
int itemsPerPage = 28;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
@ -33,11 +37,11 @@ public class GuiInventoryEditEffect extends GuiInventory {
GuiActionButton selectButton = new GuiActionButton(
slot,
GuiIcon.EFFECT.get(effect.getName()),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ParticleUtils.formatName(effect.getName()),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, ParticleUtils.formatName(effect.getName()))},
localeManager.getLocaleMessage("gui-color-icon-name") + ParticleUtils.formatName(effect.getName()),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-effect-description", StringPlaceholders.single("effect", ParticleUtils.formatName(effect.getName())))},
(button, isShiftClick) -> {
editingParticle.setEffect(effect);
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(selectButton);
@ -53,9 +57,9 @@ public class GuiInventoryEditEffect extends GuiInventory {
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1,
GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
new String[]{},
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).run());
this.actionButtons.add(backButton);
// Previous page button
@ -63,9 +67,9 @@ public class GuiInventoryEditEffect extends GuiInventory {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
@ -74,9 +78,9 @@ public class GuiInventoryEditEffect extends GuiInventory {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}

View file

@ -1,32 +1,42 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import org.bukkit.Bukkit;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
public class GuiInventoryEditParticle extends GuiInventory {
public GuiInventoryEditParticle(PPlayer pplayer, ParticlePair editingParticle) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_EDITING_PARTICLE, editingParticle.getId())));
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-editing-particle", StringPlaceholders.single("id", editingParticle.getId()))));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.RED);
// Particle Info Icon
String particleInfo = LangManager.getText(Lang.GUI_PARTICLE_INFO, editingParticle.getId(), editingParticle.getEffect().getName(), editingParticle.getStyle().getName(), editingParticle.getDataString());
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", editingParticle.getId())
.addPlaceholder("effect", editingParticle.getEffect().getName())
.addPlaceholder("style", editingParticle.getStyle().getName())
.addPlaceholder("data", editingParticle.getDataString())
.build();
String particleInfo = localeManager.getLocaleMessage("gui-particle-info", stringPlaceholders);
GuiActionButton particleInfoIcon = new GuiActionButton(
13,
GuiIcon.PARTICLES.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_PARTICLE_NAME, editingParticle.getId()),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + particleInfo},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-particle-name", StringPlaceholders.single("id", editingParticle.getId())),
new String[]{localeManager.getLocaleMessage("gui-color-info") + particleInfo},
(button, isShiftClick) -> { });
this.actionButtons.add(particleInfoIcon);
@ -34,12 +44,12 @@ public class GuiInventoryEditParticle extends GuiInventory {
GuiActionButton editEffectButton = new GuiActionButton(
38,
GuiIcon.EDIT_EFFECT.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_EFFECT),
new String[]{LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_EFFECT_DESCRIPTION)},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-effect"),
new String[]{localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-edit-effect-description")},
(button, isShiftClick) -> {
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
List<Runnable> callbacks = new ArrayList<>();
callbacks.add(() -> guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) {
@ -48,24 +58,24 @@ public class GuiInventoryEditParticle extends GuiInventory {
break;
}
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
});
callbacks.get(1).execute();
callbacks.get(1).run();
});
this.actionButtons.add(editEffectButton);
// Edit Style Button
GuiActionButton editStyleButton = new GuiActionButton(40,
GuiIcon.EDIT_STYLE.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_STYLE),
new String[]{LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_STYLE_DESCRIPTION)},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-style"),
new String[]{localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-edit-style-description")},
(button, isShiftClick) -> {
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
List<Runnable> callbacks = new ArrayList<>();
callbacks.add(() -> guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) {
@ -74,12 +84,12 @@ public class GuiInventoryEditParticle extends GuiInventory {
break;
}
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
});
callbacks.get(1).execute();
callbacks.get(1).run();
});
this.actionButtons.add(editStyleButton);
@ -87,14 +97,14 @@ public class GuiInventoryEditParticle extends GuiInventory {
boolean usesData = editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA);
GuiActionButton editDataButton = new GuiActionButton(42,
GuiIcon.EDIT_DATA.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_DATA),
usesData ? new String[]{LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_DATA_DESCRIPTION)} :
new String[]{LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_DATA_UNAVAILABLE)},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-data"),
usesData ? new String[]{localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-edit-data-description")} :
new String[]{localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-edit-data-unavailable")},
(button, isShiftClick) -> {
if (usesData) {
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
List<Runnable> callbacks = new ArrayList<>();
callbacks.add(() -> guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) {
@ -106,12 +116,12 @@ public class GuiInventoryEditParticle extends GuiInventory {
break;
}
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
});
callbacks.get(1).execute();
callbacks.get(1).run();
}
});
this.actionButtons.add(editDataButton);
@ -120,9 +130,9 @@ public class GuiInventoryEditParticle extends GuiInventory {
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1,
GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryManageParticles(pplayer)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryManageParticles(pplayer)));
this.actionButtons.add(backButton);
this.populate();

View file

@ -1,26 +1,30 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.List;
import org.bukkit.Bukkit;
public class GuiInventoryEditStyle extends GuiInventory {
public GuiInventoryEditStyle(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_STYLE)));
public GuiInventoryEditStyle(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-style")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.BLUE);
// Select Style Buttons
List<ParticleStyle> stylesUserHasPermissionFor = PermissionManager.getStylesUserHasPermissionFor(pplayer.getPlayer());
List<ParticleStyle> stylesUserHasPermissionFor = PlayerParticles.getInstance().getManager(PermissionManager.class).getStylesUserHasPermissionFor(pplayer.getPlayer());
int numberOfItems = stylesUserHasPermissionFor.size();
int itemsPerPage = 28;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
@ -33,11 +37,11 @@ public class GuiInventoryEditStyle extends GuiInventory {
GuiActionButton selectButton = new GuiActionButton(
slot,
GuiIcon.STYLE.get(style.getName()),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ParticleUtils.formatName(style.getName()),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, ParticleUtils.formatName(style.getName()))},
localeManager.getLocaleMessage("gui-color-icon-name") + ParticleUtils.formatName(style.getName()),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-style-description", StringPlaceholders.single("style", ParticleUtils.formatName(style.getName())))},
(button, isShiftClick) -> {
editingParticle.setStyle(style);
callbackList.get(callbackListPosition + 1).execute();
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(selectButton);
@ -53,9 +57,9 @@ public class GuiInventoryEditStyle extends GuiInventory {
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1,
GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
new String[]{},
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).run());
this.actionButtons.add(backButton);
// Previous page button
@ -63,9 +67,9 @@ public class GuiInventoryEditStyle extends GuiInventory {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
@ -74,9 +78,9 @@ public class GuiInventoryEditStyle extends GuiInventory {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}

View file

@ -1,26 +1,31 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticleGroupPreset;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.Comparator;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class GuiInventoryLoadPresetGroups extends GuiInventory {
public GuiInventoryLoadPresetGroups(PPlayer pplayer, boolean isEndPoint) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP)));
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-load-a-preset-group")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.GREEN);
@ -29,7 +34,7 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
int index = 10;
int nextWrap = 17;
int maxIndex = 43;
List<ParticleGroupPreset> groups = ParticleGroupPresetManager.getPresetGroupsForPlayer(pplayer.getPlayer());
List<ParticleGroupPreset> groups = PlayerParticles.getInstance().getManager(ParticleGroupPresetManager.class).getPresetGroupsForPlayer(pplayer.getPlayer());
for (ParticleGroupPreset group : groups) {
if (!group.getGroup().canPlayerUse(player))
continue;
@ -38,22 +43,30 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
particles.sort(Comparator.comparingInt(ParticlePair::getId));
String[] lore = new String[particles.size() + 1];
lore[0] = LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_CLICK_TO_LOAD, particles.size());
lore[0] = localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-click-to-load", StringPlaceholders.single("amount", particles.size()));
int i = 1;
for (ParticlePair particle : particles) {
lore[i] = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PARTICLE_INFO, particle.getId(), ParticleUtils.formatName(particle.getEffect().getName()), ParticleUtils.formatName(particle.getStyle().getName()), particle.getDataString());
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId())
.addPlaceholder("effect", ParticleUtils.formatName(particle.getEffect().getName()))
.addPlaceholder("style", ParticleUtils.formatName(particle.getStyle().getName()))
.addPlaceholder("data", particle.getDataString())
.build();
lore[i] = localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-particle-info", stringPlaceholders);
i++;
}
// Load Group Buttons
GuiActionButton groupButton = new GuiActionButton(index, group.getGuiIcon(), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + group.getDisplayName(), lore, (button, isShiftClick) -> {
GuiActionButton groupButton = new GuiActionButton(index, group.getGuiIcon(), localeManager.getLocaleMessage("gui-color-icon-name") + group.getDisplayName(), lore, (button, isShiftClick) -> {
ParticleGroup activeGroup = pplayer.getActiveParticleGroup();
activeGroup.getParticles().clear();
for (ParticlePair particle : particles)
activeGroup.getParticles().add(particle.clone());
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
for (ParticlePair particle : particles) {
ParticlePair clonedParticle = particle.clone();
clonedParticle.setOwner(pplayer);
activeGroup.getParticles().add(clonedParticle);
}
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
if (PSetting.GUI_CLOSE_AFTER_GROUP_SELECTED.getBoolean()) {
if (Setting.GUI_CLOSE_AFTER_GROUP_SELECTED.getBoolean()) {
pplayer.getPlayer().closeInventory();
}
});
@ -71,20 +84,20 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
// Back Button
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1, GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryDefault(pplayer)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryDefault(pplayer)));
this.actionButtons.add(backButton);
} else {
// Reset Particles Button
GuiActionButton resetParticles = new GuiActionButton(
49,
GuiIcon.RESET.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_RESET_PARTICLES),
new String[]{LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_RESET_PARTICLES_DESCRIPTION)},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-reset-particles"),
new String[]{localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-reset-particles-description")},
(button, isShiftClick) -> {
// Reset particles
DataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
dataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
});
this.actionButtons.add(resetParticles);
}

View file

@ -1,27 +1,32 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.gui.hook.PlayerChatHook;
import dev.esophose.playerparticles.gui.hook.PlayerChatHookData;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.bukkit.Bukkit;
public class GuiInventoryManageGroups extends GuiInventory {
public GuiInventoryManageGroups(PPlayer pplayer) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS)));
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-manage-your-groups")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.BROWN);
@ -38,23 +43,28 @@ public class GuiInventoryManageGroups extends GuiInventory {
particles.sort(Comparator.comparingInt(ParticlePair::getId));
String[] lore = new String[particles.size() + 2];
lore[0] = LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_CLICK_TO_LOAD, particles.size());
lore[0] = localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-click-to-load", StringPlaceholders.single("amount", particles.size()));
int i = 1;
for (ParticlePair particle : particles) {
lore[i] = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PARTICLE_INFO, particle.getId(), ParticleUtils.formatName(particle.getEffect().getName()), ParticleUtils.formatName(particle.getStyle().getName()), particle.getDataString());
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId())
.addPlaceholder("effect", ParticleUtils.formatName(particle.getEffect().getName()))
.addPlaceholder("style", ParticleUtils.formatName(particle.getStyle().getName()))
.addPlaceholder("data", particle.getDataString())
.build();
lore[i] = localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-particle-info", stringPlaceholders);
i++;
}
lore[i] = LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_SHIFT_CLICK_TO_DELETE);
lore[i] = localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-shift-click-to-delete");
// Load Group Buttons
GuiActionButton groupButton = new GuiActionButton(
index,
GuiIcon.GROUPS.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + group.getName(),
localeManager.getLocaleMessage("gui-color-icon-name") + group.getName(),
lore,
(button, isShiftClick) -> {
if (isShiftClick) {
DataManager.removeParticleGroup(pplayer.getUniqueId(), group);
dataManager.removeParticleGroup(pplayer.getUniqueId(), group);
this.actionButtons.remove(button);
this.inventory.setItem(button.getSlot(), null);
@ -63,9 +73,9 @@ public class GuiInventoryManageGroups extends GuiInventory {
activeGroup.getParticles().clear();
for (ParticlePair particle : particles)
activeGroup.getParticles().add(particle.clone());
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
if (PSetting.GUI_CLOSE_AFTER_GROUP_SELECTED.getBoolean()) {
if (Setting.GUI_CLOSE_AFTER_GROUP_SELECTED.getBoolean()) {
pplayer.getPlayer().closeInventory();
}
}
@ -80,41 +90,41 @@ public class GuiInventoryManageGroups extends GuiInventory {
if (index > maxIndex) break; // Overflowed the available space
}
boolean hasReachedMax = PermissionManager.hasPlayerReachedMaxGroups(pplayer);
boolean hasReachedMax = PlayerParticles.getInstance().getManager(PermissionManager.class).hasPlayerReachedMaxGroups(pplayer);
boolean hasParticles = !pplayer.getActiveParticles().isEmpty();
String[] lore;
if (hasReachedMax) {
lore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SAVE_GROUP_DESCRIPTION),
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_SAVE_GROUP_FULL)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-save-group-description"),
localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-save-group-full")
};
} else if (!hasParticles) {
lore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SAVE_GROUP_DESCRIPTION),
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_SAVE_GROUP_NO_PARTICLES)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-save-group-description"),
localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-save-group-no-particles")
};
} else {
lore = new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SAVE_GROUP_DESCRIPTION)};
lore = new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-save-group-description")};
}
// Save Group Button
GuiActionButton saveGroupButton = new GuiActionButton(
40,
GuiIcon.CREATE.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SAVE_GROUP),
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-save-group"),
lore,
(button, isShiftClick) -> {
if (hasReachedMax || !hasParticles) return;
PlayerChatHook.addHook(new PlayerChatHookData(pplayer.getUniqueId(), 15, (textEntered) -> {
if (textEntered == null || textEntered.equalsIgnoreCase("cancel")) {
GuiHandler.transition(new GuiInventoryManageGroups(pplayer));
guiManager.transition(new GuiInventoryManageGroups(pplayer));
} else {
String groupName = textEntered.split(" ")[0];
// Check that the groupName isn't the reserved name
if (groupName.equalsIgnoreCase(ParticleGroup.DEFAULT_NAME)) {
LangManager.sendMessage(pplayer, Lang.GROUP_RESERVED);
localeManager.sendMessage(pplayer, "group-reserved");
return;
}
@ -136,14 +146,14 @@ public class GuiInventoryManageGroups extends GuiInventory {
}
// Apply changes and notify player
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
if (groupUpdated) {
LangManager.sendMessage(pplayer, Lang.GROUP_SAVE_SUCCESS_OVERWRITE, groupName);
localeManager.sendMessage(pplayer, "group-save-success-overwrite", StringPlaceholders.single("name", groupName));
} else {
LangManager.sendMessage(pplayer, Lang.GROUP_SAVE_SUCCESS, groupName);
localeManager.sendMessage(pplayer, "group-save-success", StringPlaceholders.single("name", groupName));
}
GuiHandler.transition(new GuiInventoryManageGroups(pplayer));
guiManager.transition(new GuiInventoryManageGroups(pplayer));
}
}));
pplayer.getPlayer().closeInventory();
@ -154,9 +164,9 @@ public class GuiInventoryManageGroups extends GuiInventory {
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1,
GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryDefault(pplayer)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryDefault(pplayer)));
this.actionButtons.add(backButton);
this.populate();

View file

@ -1,25 +1,30 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.bukkit.Bukkit;
public class GuiInventoryManageParticles extends GuiInventory {
public GuiInventoryManageParticles(PPlayer pplayer) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES)));
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-manage-your-particles")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.ORANGE);
@ -31,18 +36,23 @@ public class GuiInventoryManageParticles extends GuiInventory {
int nextWrap = 17;
int maxIndex = 35;
for (ParticlePair particle : particles) {
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId())
.addPlaceholder("effect", ParticleUtils.formatName(particle.getEffect().getName()))
.addPlaceholder("style", ParticleUtils.formatName(particle.getStyle().getName()))
.addPlaceholder("data", particle.getDataString())
.build();
GuiActionButton selectButton = new GuiActionButton(
index,
GuiIcon.PARTICLES.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_PARTICLE_NAME, particle.getId()),
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-particle-name", StringPlaceholders.single("id", particle.getId())),
new String[]{
LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_CLICK_TO_EDIT_PARTICLE, particles.size()),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PARTICLE_INFO, particle.getId(), ParticleUtils.formatName(particle.getEffect().getName()), ParticleUtils.formatName(particle.getStyle().getName()), particle.getDataString()),
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_SHIFT_CLICK_TO_DELETE)
localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-click-to-edit-particle"),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-particle-info", stringPlaceholders),
localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-shift-click-to-delete")
},
(button, isShiftClick) -> {
if (!isShiftClick) {
GuiHandler.transition(new GuiInventoryEditParticle(pplayer, particle));
guiManager.transition(new GuiInventoryEditParticle(pplayer, particle));
} else {
// Delete particle
ParticleGroup activeGroup = pplayer.getActiveParticleGroup();
@ -52,7 +62,7 @@ public class GuiInventoryManageParticles extends GuiInventory {
break;
}
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
// Update inventory to reflect deletion
this.actionButtons.remove(button);
@ -70,51 +80,51 @@ public class GuiInventoryManageParticles extends GuiInventory {
}
// Create New Particle Button
boolean canCreate = pplayer.getActiveParticles().size() < PermissionManager.getMaxParticlesAllowed(pplayer.getPlayer());
String lore = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_CREATE_PARTICLE_DESCRIPTION);
boolean canCreate = pplayer.getActiveParticles().size() < PlayerParticles.getInstance().getManager(PermissionManager.class).getMaxParticlesAllowed(pplayer.getPlayer());
String lore = localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-create-particle-description");
GuiActionButton createNewParticle = new GuiActionButton(
38,
GuiIcon.CREATE.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_CREATE_PARTICLE),
canCreate ? new String[]{lore} : new String[]{lore, LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_CREATE_PARTICLE_UNAVAILABLE)},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-create-particle"),
canCreate ? new String[]{lore} : new String[]{lore, localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-create-particle-unavailable")},
(button, isShiftClick) -> {
if (!canCreate) return;
ParticlePair editingParticle = ParticlePair.getNextDefault(pplayer);
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryManageParticles(pplayer)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 2)));
List<Runnable> callbacks = new ArrayList<>();
callbacks.add(() -> guiManager.transition(new GuiInventoryManageParticles(pplayer)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 2)));
callbacks.add(() -> {
if (editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 3));
guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 3));
} else {
callbacks.get(4).execute();
callbacks.get(4).run();
}
});
callbacks.add(() -> {
// Save new particle
ParticleGroup group = pplayer.getActiveParticleGroup();
group.getParticles().add(editingParticle);
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
// Reopen the manage particle inventory
GuiHandler.transition(new GuiInventoryManageParticles(pplayer));
guiManager.transition(new GuiInventoryManageParticles(pplayer));
});
callbacks.get(1).execute();
callbacks.get(1).run();
});
this.actionButtons.add(createNewParticle);
// Reset Particles Button
GuiActionButton resetParticles = new GuiActionButton(42,
GuiIcon.RESET.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_RESET_PARTICLES),
new String[]{LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_RESET_PARTICLES_DESCRIPTION)},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-reset-particles"),
new String[]{localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-reset-particles-description")},
(button, isShiftClick) -> {
// Reset particles
DataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
dataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
// Reopen this same inventory to refresh it
GuiHandler.transition(new GuiInventoryManageParticles(pplayer));
guiManager.transition(new GuiInventoryManageParticles(pplayer));
});
this.actionButtons.add(resetParticles);
@ -122,9 +132,9 @@ public class GuiInventoryManageParticles extends GuiInventory {
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1,
GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryDefault(pplayer)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryDefault(pplayer)));
this.actionButtons.add(backButton);
this.populate();

View file

@ -1,9 +1,13 @@
package dev.esophose.playerparticles.gui.hook;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.util.NMSUtil;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.HashSet;
import java.util.Set;
import dev.esophose.playerparticles.util.NMSUtil;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -12,13 +16,6 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
public class PlayerChatHook extends BukkitRunnable implements Listener {
private static Set<PlayerChatHookData> hooks;
@ -31,7 +28,7 @@ public class PlayerChatHook extends BukkitRunnable implements Listener {
hooks = new HashSet<>();
if (hookTask != null)
hookTask.cancel();
hookTask = new PlayerChatHook().runTaskTimer(PlayerParticles.getPlugin(), 0, 20);
hookTask = new PlayerChatHook().runTaskTimer(PlayerParticles.getInstance(), 0, 20);
}
/**
@ -45,7 +42,7 @@ public class PlayerChatHook extends BukkitRunnable implements Listener {
if (hook.getPlayerUUID().equals(event.getPlayer().getUniqueId())) {
event.setCancelled(true);
hooks.remove(hook);
Bukkit.getScheduler().scheduleSyncDelayedTask(PlayerParticles.getPlugin(), () -> hook.triggerCallback(event.getMessage()));
Bukkit.getScheduler().scheduleSyncDelayedTask(PlayerParticles.getInstance(), () -> hook.triggerCallback(event.getMessage()));
return;
}
}
@ -69,11 +66,12 @@ public class PlayerChatHook extends BukkitRunnable implements Listener {
if (player == null) {
hooksToRemove.remove(hook);
} else {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (NMSUtil.getVersionNumber() == 9) {
if (hook.getMaxHookLength() == hook.getTimeRemaining())
player.sendMessage(LangManager.getText(Lang.GUI_SAVE_GROUP_HOTBAR_MESSAGE, hook.getTimeRemaining()));
player.sendMessage(localeManager.getLocaleMessage("gui-save-group-hotbar-message", StringPlaceholders.single("seconds", hook.getTimeRemaining())));
} else {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(LangManager.getText(Lang.GUI_SAVE_GROUP_HOTBAR_MESSAGE, hook.getTimeRemaining())));
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(localeManager.getLocaleMessage("gui-save-group-hotbar-message", StringPlaceholders.single("seconds", hook.getTimeRemaining()))));
}
}
}

View file

@ -1,15 +1,16 @@
package dev.esophose.playerparticles.gui.hook;
import java.util.UUID;
import java.util.function.Consumer;
public class PlayerChatHookData {
private UUID playerUUID;
private int maxHookLength;
private int hookLength;
private PlayerChatHookCallback hookCallback;
private Consumer<String> hookCallback;
public PlayerChatHookData(UUID playerUUID, int hookLength, PlayerChatHookCallback hookCallback) {
public PlayerChatHookData(UUID playerUUID, int hookLength, Consumer<String> hookCallback) {
this.playerUUID = playerUUID;
this.maxHookLength = hookLength;
this.hookLength = hookLength;
@ -65,15 +66,7 @@ public class PlayerChatHookData {
* @param textEntered The text that was entered by the player
*/
public void triggerCallback(String textEntered) {
this.hookCallback.onPlayerChat(textEntered);
}
/**
* Allows simple hooking into the player chat for a specific time interval
*/
@FunctionalInterface
public interface PlayerChatHookCallback {
void onPlayerChat(String textEntered);
this.hookCallback.accept(textEntered);
}
}

View file

@ -0,0 +1,33 @@
package dev.esophose.playerparticles.hook;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import me.clip.placeholderapi.PlaceholderAPI;
public final class PlaceholderAPIHook {
private static Boolean enabled;
/**
* @return true if PlaceholderAPI is enabled, otherwise false
*/
public static boolean enabled() {
if (enabled != null)
return enabled;
return enabled = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
}
/**
* Applies placeholders from PlaceholderAPI to strings
*
* @param player The Player to apply placeholders with
* @param text The text to replace placeholders
* @return A string with replaced placeholders
*/
public static String applyPlaceholders(Player player, String text) {
if (enabled())
return PlaceholderAPI.setPlaceholders(player, text);
return text;
}
}

View file

@ -0,0 +1,327 @@
package dev.esophose.playerparticles.locale;
import java.util.LinkedHashMap;
import java.util.Map;
public class EnglishLocale implements Locale {
@Override
public String getLocaleName() {
return "en_US";
}
@Override
public String getTranslatorName() {
return "Esophose";
}
@Override
public Map<String, String> getDefaultLocaleStrings() {
return new LinkedHashMap<String, String>() {{
this.put("#0", "Plugin Message Prefix");
this.put("prefix", "&7[&3PlayerParticles&7] ");
this.put("#1", "Command Description Messages");
this.put("command-error-no-effects", "&cYou must have access to effects to use this command!");
this.put("command-error-unknown", "&cUnknown command, use &b/pp help &cfor a list of commands.");
this.put("command-descriptions", "&eThe following commands are available:");
this.put("command-descriptions-usage", "&e/pp %cmd% %args%");
this.put("command-descriptions-help-1", "&7> &b/pp %cmd% &e- %desc%");
this.put("command-descriptions-help-2", "&7> &b/pp %cmd% %args% &e- %desc%");
this.put("command-descriptions-help-other", "&7> &b/ppo <player> <command> &e- Run a /pp command as a player");
this.put("command-description-add", "Add a new particle");
this.put("command-description-data", "Check what type of data an effect uses");
this.put("command-description-default", "The main command. By default, opens the GUI");
this.put("command-description-edit", "Edit a particle");
this.put("command-description-effects", "Display a list of effects you can use");
this.put("command-description-fixed", "Manage your fixed effects");
this.put("command-description-group", "Manage your groups");
this.put("command-description-gui", "Display the GUI for easy editing of particles");
this.put("command-description-help", "Displays the help menu... You have arrived");
this.put("command-description-info", "Gets the description of one of your active particles");
this.put("command-description-list", "Lists the IDs of your active particles");
this.put("command-description-reload", "Reloads the config.yml and lang file");
this.put("command-description-remove", "Removes some particles");
this.put("command-description-reset", "Removes all your active particles");
this.put("command-description-styles", "Display a list of styles you can use");
this.put("command-description-toggle", "Toggles particle visibility on/off");
this.put("command-description-version", "Display the plugin version and author");
this.put("command-description-worlds", "Find out what worlds particles are disabled in");
this.put("#2", "Fixed Particle Command Description Messages");
this.put("command-description-fixed-create", "&e/pp fixed create <<x> <y> <z>|<looking>> <effect> <style> [data] - Creates a new fixed effect");
this.put("command-description-fixed-edit", "&e/pp fixed edit <id> <effect|style|data> <args> - Edit part of a fixed effect by its ID");
this.put("command-description-fixed-remove", "&e/pp fixed remove <ID> - Removes a fixed effect by its ID");
this.put("command-description-fixed-list", "&e/pp fixed list - Lists all IDs of your fixed effects");
this.put("command-description-fixed-info", "&e/pp fixed info <ID> - Gets info on one of your fixed effects");
this.put("command-description-fixed-clear", "&e/pp fixed clear <radius> - Clears all fixed effects of all players within the given radius");
this.put("command-description-group-save", "&e/pp group save <name> - Saves all active particles in a new group");
this.put("command-description-group-load", "&e/pp group load <name> - Loads all particles saved in a group");
this.put("command-description-group-remove", "&e/pp group remove <name> - Removes a group you have saved");
this.put("command-description-group-list", "&e/pp group list <name> - List all particle groups you have saved");
this.put("command-description-group-info", "&e/pp group info <name> - List the particles saved in the group");
this.put("#3", "ID Messages");
this.put("id-invalid", "&cThe ID you entered is invalid, it must be a positive whole number!");
this.put("id-unknown", "&cYou do not have a particle applied with the ID &b%id%&c!");
this.put("#4", "Other Messages");
this.put("other-no-permission", "&cYou do not have permission to execute PlayerParticles commands for other players!");
this.put("other-missing-args", "&cYou are missing some arguments. &b/ppo <player> <command>");
this.put("other-unknown-player", "&cThe player &b%player% &cwas not found. They must be online.");
this.put("other-unknown-command", "&cThe command &b/pp %cmd% &cdoes not exist.");
this.put("other-success", "&eExecuted /pp command for &b%player%&e. Output:");
this.put("#5", "Add Messages");
this.put("add-reached-max", "&cUnable to apply particle, you have reached the maximum amount of &b%amount% &callowed!");
this.put("add-particle-applied", "&aA new particle has been applied with the effect &b%effect%&a, style &b%style%&a, and data &b%data%&a!");
this.put("data-no-args", "&cMissing argument for effect! Command usage: &b/pp data <effect>");
this.put("#6", "Edit Messages");
this.put("edit-invalid-property", "&cAn invalid property &b%prop% &cwas provided. Valid properties: &beffect&c, &bstyle&c, &bdata");
this.put("edit-success-effect", "&aYour particle with an ID of &b%id% &ahas had its effect changed to &b%effect%&a!");
this.put("edit-success-style", "&aYour particle with an ID of &b%id% &ahas had its style changed to &b%style%&a!");
this.put("edit-success-data", "&aYour particle with an ID of &b%id% &ahas had its data changed to &b%data%&a!");
this.put("#7", "Group Messages");
this.put("group-invalid", "&cA saved group or preset group does not exist with the name &b%name%&c!");
this.put("group-no-permission", "&cYou are missing permission for an effect or style to use the group &b%group%&c!");
this.put("group-preset-no-permission", "&cYou are missing permission for an effect or style to use the preset group &b%group%&c!");
this.put("group-reserved", "&cThe group name &bactive &cis reserved and cannot be used!");
this.put("group-no-name", "&cYou did not provide a group name! &b/pp %cmd% <groupName>");
this.put("group-save-reached-max", "&cUnable to save group, you have reached the max number of groups!");
this.put("group-save-no-particles", "&cUnable to save group, you do not have any particles applied!");
this.put("group-save-success", "&aYour current particles have been saved under the group named &b%name%&a!");
this.put("group-save-success-overwrite", "&aThe group named &b%name% &ahas been updated with your current particles!");
this.put("group-load-success", "&aApplied &b%amount% &aparticle(s) from your saved group named &b%name%&a!");
this.put("group-load-preset-success", "&aApplied &b%amount% &aparticle(s) from the preset group named &b%name%&a!");
this.put("group-remove-preset", "&cYou cannot remove a preset group!");
this.put("group-remove-success", "&aRemoved the particle group named &b%name%&a!");
this.put("group-info-header", "&eThe group &b%group% &ehas the following particles:");
this.put("group-list-none", "&eYou do not have any particle groups saved!");
this.put("group-list-output", "&eYou have the following groups saved: &b%info%");
this.put("group-list-presets", "&eThe following preset groups are available: &b%info%");
this.put("#8", "Reload Messages");
this.put("reload-success", "&aThe plugin has been reloaded!");
this.put("reload-no-permission", "&cYou do not have permission to reload the plugin settings!");
this.put("#9", "Remove Messages");
this.put("remove-no-args", "&cYou did not specify an ID to remove! &b/pp remove <ID>");
this.put("remove-id-success", "&aYour particle with the ID &b%id% &ahas been removed!");
this.put("remove-effect-success", "&aRemoved &b%amount% &aof your particles with the effect of &b%effect%&a!");
this.put("remove-effect-none", "&cYou do not have any particles applied with the effect &b%effect%&c!");
this.put("remove-style-success", "&aRemoved &b%amount% &aof your particles with the style of &b%style%&a!");
this.put("remove-style-none", "&cYou do not have any particles applied with the style &b%style%&c!");
this.put("remove-unknown", "&cAn effect or style with the name of &b%name% &cdoes not exist!");
this.put("#10", "List Messages");
this.put("list-none", "&eYou do not have any active particles!");
this.put("list-you-have", "&eYou have the following particles applied:");
this.put("list-output", "&eID: &b%id% &eEffect: &b%effect% &eStyle: &b%style% &eData: &b%data%");
this.put("#11", "Toggle Messages");
this.put("toggle-on", "&eParticles have been toggled &aON&e!");
this.put("toggle-off", "&eParticles have been toggled &cOFF&e!");
this.put("#12", "Color Messages");
this.put("rainbow", "&cR&6a&ei&an&bb&9o&dw");
this.put("random", "Random");
this.put("#13", "Effect Messages");
this.put("effect-no-permission", "&cYou do not have permission to use the effect &b%effect%&c!");
this.put("effect-invalid", "&cThe effect &b%effect% &cdoes not exist! Use &b/pp effects &cfor a list of effects you can use.");
this.put("effect-list", "&eYou can use the following effects: &b%effects%");
this.put("effect-list-empty", "&cYou do not have permission to use any effects!");
this.put("#14", "Style Messages");
this.put("style-no-permission", "&cYou do not have permission to use the style &b%style%&c!");
this.put("style-event-spawning-info", "&eNote: The style &b%style% &espawns particles based on an event.");
this.put("style-invalid", "&cThe style &b%style% &cdoes not exist! Use &b/pp styles &cfor a list of styles you can use.");
this.put("style-list", "&eYou can use the following styles: &b%styles%");
this.put("#15", "Data Messages");
this.put("data-usage-none", "&eThe effect &b%effect% &edoes not use any data!");
this.put("data-usage-block", "&eThe effect &b%effect% &erequires &bblock &edata! &bFormat: <blockName>");
this.put("data-usage-item", "&eThe effect &b%effect% &erequires &bitem &edata! &bFormat: <itemName>");
this.put("data-usage-color", "&eThe effect &b%effect% &erequires &bcolor &edata! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-usage-note", "&eThe effect &b%effect% &erequires &bnote &edata! &bFormat: <0-24>|<rainbow>|<random>");
this.put("data-invalid-block", "&cThe &bblock &cdata you entered is invalid! &bFormat: <blockName>");
this.put("data-invalid-item", "&cThe &bitem &cdata you entered is invalid! &bFormat: <itemName>");
this.put("data-invalid-color", "&cThe &bcolor &cdata you entered is invalid! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-invalid-note", "&cThe &bnote &cdata you entered is invalid! &bFormat: <0-24>|<rainbow>|<random>");
this.put("data-invalid-material-not-item", "&cThe &bitem &cmaterial &b%material% &cyou entered is not an item!");
this.put("data-invalid-material-not-block", "&cThe &bblock &cmaterial &b%material% &cyou entered is not a block!");
this.put("data-invalid-material-item", "&cThe &bitem &cmaterial &b%material% you entered does not exist!");
this.put("data-invalid-material-block", "&cThe &bblock &cmaterial &b%material% you entered does not exist!");
this.put("#16", "World Messages");
this.put("disabled-worlds", "&eParticles are disabled in these worlds: &b%worlds%");
this.put("disabled-worlds-none", "&eParticles are not disabled in any worlds.");
this.put("#17", "Reset Message");
this.put("reset-success", "&aRemoved &b%amount% &aactive particle(s)!");
this.put("#18", "Fixed Create Messages");
this.put("fixed-create-missing-args", "&cUnable to create fixed effect, you are missing &b%amount% &crequired arguments!");
this.put("fixed-create-invalid-coords", "&cUnable to create fixed effect, one or more coordinates you entered is invalid!");
this.put("fixed-create-out-of-range", "&cUnable to create fixed effect, you must be within &b%range% &cblocks of your desired location!");
this.put("fixed-create-looking-too-far", "&cUnable to create fixed effect, you are standing too far away from the block you are looking at!");
this.put("fixed-create-effect-invalid", "&cUnable to create fixed effect, an effect with the name &b%effect% &cdoes not exist!");
this.put("fixed-create-effect-no-permission", "&cUnable to create fixed effect, you do not have permission to use the effect &b%effect%&c!");
this.put("fixed-create-style-invalid", "&cUnable to create fixed effect, a style with the name &b%style% &cdoes not exist!");
this.put("fixed-create-style-no-permission", "&cUnable to create fixed effect, you do not have permission to use the style &b%style%&c!");
this.put("fixed-create-style-non-fixable", "&cUnable to create fixed effect, the style &b%style% &ccan not be used in fixed effects!");
this.put("fixed-create-data-error", "&cUnable to create fixed effect, the data provided is not correct! Use &b/pp data <effect> &cto find the correct data format!");
this.put("fixed-create-success", "&aYour fixed effect has been created!");
this.put("#19", "Fixed Edit Messages");
this.put("fixed-edit-missing-args", "&cUnable to edit fixed effect, you are missing some arguments!");
this.put("fixed-edit-invalid-id", "&cUnable to edit fixed effect, the ID specified is invalid or does not exist!");
this.put("fixed-edit-invalid-property", "&cUnable to edit fixed effect, an invalid property was specified! Only &blocation&c, &beffect&c, &bstyle&c, and &bdata &care valid.");
this.put("fixed-edit-invalid-coords", "&cUnable to edit fixed effect, one or more coordinates you entered is invalid!");
this.put("fixed-edit-out-of-range", "&cUnable to edit fixed effect, you must be within &b%range% &cblocks of your desired location!");
this.put("fixed-edit-looking-too-far", "&cUnable to edit fixed effect, you are standing too far away from the block you are looking at!");
this.put("fixed-edit-effect-invalid", "&cUnable to edit fixed effect, an effect with the name &b%effect% &cdoes not exist!");
this.put("fixed-edit-effect-no-permission", "&cUnable to edit fixed effect, you do not have permission to use the effect &b%effect%&c!");
this.put("fixed-edit-style-invalid", "&cUnable to edit fixed effect, a style with the name &b%style% &cdoes not exist!");
this.put("fixed-edit-style-no-permission", "&cUnable to edit fixed effect, you do not have permission to use the style &b%style%&c!");
this.put("fixed-edit-style-non-fixable", "&cUnable to edit fixed effect, the style &b%style% &ccan not be used in fixed effects!");
this.put("fixed-edit-data-error", "&cUnable to edit fixed effect, the data provided is not correct! Use &b/pp data <effect> &cto find the correct data format!");
this.put("fixed-edit-data-none", "&cUnable to edit fixed effect, the effect does not require any data!");
this.put("fixed-edit-success", "&aUpdated the &b%prop% &aof the fixed effect with an ID of &b%id%&a!");
this.put("#20", "Fixed Remove Messages");
this.put("fixed-remove-invalid", "&cUnable to remove fixed effect, you do not have a fixed effect with the ID of &b%id%&c!");
this.put("fixed-remove-no-args", "&cYou did not specify an ID to remove!");
this.put("fixed-remove-args-invalid", "&cUnable to remove, the ID specified must be a number!");
this.put("fixed-remove-success", "&aYour fixed effect with the ID &b%id% &ahas been removed!");
this.put("#21", "Fixed List Messages");
this.put("fixed-list-none", "&eYou do not have any fixed effects!");
this.put("fixed-list-success", "&eYou have fixed effects with these IDs: &b%ids%");
this.put("#22", "Fixed Info Messages");
this.put("fixed-info-invalid", "&cUnable to get info, you do not have a fixed effect with the ID of &b%id%&c!");
this.put("fixed-info-no-args", "&cYou did not specify an ID to display info for!");
this.put("fixed-info-invalid-args", "&cUnable to get info, the ID specified must be a number!");
this.put("fixed-info-success", "&eID: &b%id% &eWorld: &b%world% &eX: &b%x% &eY: &b%y% &eZ: &b%z% &eEffect: &b%effect% &eStyle: &b%style% &eData: &b%data%");
this.put("#23", "Fixed Clear Messages");
this.put("fixed-clear-no-permission", "&cYou do not have permission to clear nearby fixed effects!");
this.put("fixed-clear-no-args", "&cYou did not provide a radius to clear fixed effects for!");
this.put("fixed-clear-invalid-args", "&cThe radius you provided is invalid, it must be a positive whole number!");
this.put("fixed-clear-success", "&aCleared &b%amount% &afixed effects within &b%range% &ablocks of your location!");
this.put("#24", "Fixed Other Messages");
this.put("fixed-no-permission", "&cYou do not have permission to use fixed effects!");
this.put("fixed-max-reached", "&cYou have reached the maximum allowed fixed effects!");
this.put("fixed-invalid-command", "&cInvalid sub-command for &b/pp fixed&c!");
this.put("#25", "Plugin Update Message");
this.put("update-available", "&eAn update (&b%new%&e) is available! You are running &bv%current%&e. https://www.spigotmc.org/resources/playerparticles.40261/");
this.put("#26", "GUI Messages");
this.put("gui-disabled", "&cThe server administrator has disabled the GUI!");
this.put("#27", "GUI Color Messages");
this.put("gui-color-icon-name", "&a");
this.put("gui-color-info", "&e");
this.put("gui-color-subtext", "&b");
this.put("gui-color-unavailable", "&c");
this.put("#28", "GUI Info Messages");
this.put("gui-commands-info", "Find info about commands with &b/pp help");
this.put("gui-back-button", "Go Back");
this.put("gui-next-page-button", "Next Page (%start%/%end%)");
this.put("gui-previous-page-button", "Previous Page (%start%/%end%)");
this.put("gui-click-to-load", "Click to load the following %amount% particle(s):");
this.put("gui-shift-click-to-delete", "Shift click to delete");
this.put("gui-particle-info", " - ID: &b%id% &eEffect: &b%effect% &eStyle: &b%style% &eData: &b%data%");
this.put("gui-playerparticles", "PlayerParticles");
this.put("gui-active-particles", "Active Particles: &b%amount%");
this.put("gui-saved-groups", "Saved Groups: &b%amount%");
this.put("gui-fixed-effects", "Fixed Effects: &b%amount%");
this.put("#29", "GUI Edit Primary Messages");
this.put("gui-edit-primary-effect", "Edit Primary Effect");
this.put("gui-edit-primary-effect-description", "Edit the effect of your primary particle");
this.put("gui-edit-primary-style", "Edit Primary Style");
this.put("gui-edit-primary-style-missing-effect", "You must select an effect first");
this.put("gui-edit-primary-style-description", "Edit the style of your primary particle");
this.put("gui-edit-primary-data", "Edit Primary Data");
this.put("gui-edit-primary-data-missing-effect", "You must select an effect first");
this.put("gui-edit-primary-data-unavailable", "Your primary effect does not use any data");
this.put("gui-edit-primary-data-description", "Edit the data of your primary particle");
this.put("#30", "GUI Manage Particles Messages");
this.put("gui-manage-your-particles", "Manage Your Particles");
this.put("gui-manage-your-particles-description", "Create, edit, and delete your particles");
this.put("gui-manage-your-groups", "Manage Your Groups");
this.put("gui-manage-your-groups-description", "Create, delete, and load your particle groups");
this.put("#31", "GUI Load Messages");
this.put("gui-load-a-preset-group", "Load A Preset Group");
this.put("gui-load-a-preset-group-description", "Load a premade particle group");
this.put("#32", "GUI Save Messages");
this.put("gui-save-group", "Save New Group");
this.put("gui-save-group-description", "Click to save a new group. You will be prompted\nto enter the new group name in chat.");
this.put("gui-save-group-full", "You have reached the max number of groups");
this.put("gui-save-group-no-particles", "You do not have any particles applied");
this.put("gui-save-group-hotbar-message", "&eType &b1 &eword in chat for the new group name. Type &ccancel&e to cancel. (&b%seconds%&es left)");
this.put("#33", "GUI Reset Messages");
this.put("gui-reset-particles", "Reset Your Particles");
this.put("gui-reset-particles-description", "Deletes all your active particles");
this.put("#34", "GUI Misc Messages");
this.put("gui-particle-name", "Particle #%id%");
this.put("gui-click-to-edit-particle", "Click to edit the effect, style, or data of this particle");
this.put("gui-editing-particle", "Editing Particle #%id%");
this.put("#35", "GUI Edit Messages");
this.put("gui-edit-effect", "Edit Effect");
this.put("gui-edit-effect-description", "Click to edit the effect of this particle");
this.put("gui-edit-style", "Edit Style");
this.put("gui-edit-style-description", "Click to edit the style of this particle");
this.put("gui-edit-data", "Edit Data");
this.put("gui-edit-data-description", "Click to edit the data of this particle");
this.put("gui-edit-data-unavailable", "The effect of this particle does not use any data");
this.put("gui-data-none", "none");
this.put("#36", "GUI Create Messages");
this.put("gui-create-particle", "Create A New Particle");
this.put("gui-create-particle-description", "Create a new particle with an effect, style, and data");
this.put("gui-create-particle-unavailable", "You have reached the maximum amount of particles you can create");
this.put("#37", "GUI Select Messages");
this.put("gui-select-effect", "Select Particle Effect");
this.put("gui-select-effect-description", "Sets the particle effect to &b%effect%");
this.put("gui-select-style", "Select Particle Style");
this.put("gui-select-style-description", "Sets the particle style to &b%style%");
this.put("gui-select-data", "Select Particle Data");
this.put("gui-select-data-description", "Sets the particle data to &b%data%");
this.put("gui-select-data-note", "note #%note%");
this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&cred");
this.put("gui-edit-data-color-orange", "&6orange");
this.put("gui-edit-data-color-yellow", "&eyellow");
this.put("gui-edit-data-color-lime-green", "&alime green");
this.put("gui-edit-data-color-green", "&2green");
this.put("gui-edit-data-color-blue", "&1blue");
this.put("gui-edit-data-color-cyan", "&3cyan");
this.put("gui-edit-data-color-light-blue", "&blight blue");
this.put("gui-edit-data-color-purple", "&5purple");
this.put("gui-edit-data-color-magenta", "&dmagenta");
this.put("gui-edit-data-color-pink", "&dpink");
this.put("gui-edit-data-color-brown", "&6brown");
this.put("gui-edit-data-color-black", "&8black");
this.put("gui-edit-data-color-gray", "&8gray");
this.put("gui-edit-data-color-light-gray", "&7light gray");
this.put("gui-edit-data-color-white", "&fwhite");
}};
}
}

View file

@ -0,0 +1,326 @@
package dev.esophose.playerparticles.locale;
import java.util.LinkedHashMap;
import java.util.Map;
public class FrenchLocale implements Locale {
@Override
public String getLocaleName() {
return "fr_FR";
}
@Override
public String getTranslatorName() {
return "maxime_n2 & SevenX";
}
@Override
public Map<String, String> getDefaultLocaleStrings() {
return new LinkedHashMap<String, String>() {{
this.put("#0", "Plugin Message Prefix");
this.put("prefix", "&7[&3PlayerParticles&7] ");
this.put("#1", "Command Description Messages");
this.put("command-error-no-effects", "&cVous n'avez pas la permission d'utiliser cette commande.");
this.put("command-error-unknown", "&cCommande inconnue, utilisez &b/pp help &cpour afficher la liste des commandes disponibles pour ce plugin.");
this.put("command-descriptions", "&eLes commandes suivantes sont disponibles :");
this.put("command-descriptions-usage", "&e/pp %cmd% %args%");
this.put("command-descriptions-help-1", "&7> &b/pp %cmd% &e- %desc%");
this.put("command-descriptions-help-2", "&7> &b/pp %cmd% %args% &e- %desc%");
this.put("command-descriptions-help-other", "&7> &b/ppo <player> <command> &e- Exécute une commande /pp en tant qu'un autre joueur.");
this.put("command-description-add", "Ajoutez une nouvelle particule");
this.put("command-description-data", "Voir les paramètres utilisées par la particule");
this.put("command-description-default", "Commande principale. Par défaut elle ouvre l'interface.");
this.put("command-description-edit", "Modifiez une particule");
this.put("command-description-effects", "Affichez une liste des effets utilisés");
this.put("command-description-fixed", "Gérez vos effets fixes");
this.put("command-description-group", "Gérez vos groupes d'effets");
this.put("command-description-gui", "Affichez l'interface pour modifier facilement les effets");
this.put("command-description-help", "Affichez le menu d'aide... Vous y êtes déjà !");
this.put("command-description-info", "Voir la description d'une de vos particules actives");
this.put("command-description-list", "Listez les IDs de vos particules actives");
this.put("command-description-reload", "Rechargez le fichier config.yml et de langue");
this.put("command-description-remove", "Supprimez vos particules actives.");
this.put("command-description-reset", "Supprimez toutes vos particules actives");
this.put("command-description-styles", "Affichez une liste des styles de particules que vous utilisez");
this.put("command-description-toggle", "Activez ou désactivez vos particules actives");
this.put("command-description-version", "Affichez la version du plugin et son créateur");
this.put("command-description-worlds", "Voir les mondes où ce plugin n'est pas autorisé");
this.put("#2", "Fixed Particle Command Description Messages");
this.put("command-description-fixed-create", "&e/pp fixed create <<x> <y> <z>|<looking>> <effect> <style> [data] - Créez une particule fixe");
this.put("command-description-fixed-edit", "&e/pp fixed edit <id> <effect|style|data> <args> - Modifiez une partie d'une particule fixe par son ID");
this.put("command-description-fixed-remove", "&e/pp fixed remove <ID> - Supprimez une particule fixe par son ID");
this.put("command-description-fixed-list", "&e/pp fixed list - Affiche l'ID de tous vos effets fixes");
this.put("command-description-fixed-info", "&e/pp fixed info <ID> - Voir des informations sur l'une de vos particules fixe");
this.put("command-description-fixed-clear", "&e/pp fixed clear <radius> - Supprimez tous les effets fixe de tous les joueurs d'un rayon");
this.put("command-description-group-save", "&e/pp group save <name> - Sauvegardez toutes les particules actives dans un nouveau groupe");
this.put("command-description-group-load", "&e/pp group load <name> - Chargez toutes les particules sauvegardées dans un groupe");
this.put("command-description-group-remove", "&e/pp group remove <name> - Supprimez un groupe que vous avez créé");
this.put("command-description-group-list", "&e/pp group list <name> - Voir toutes les particules sauvegardées d'un groupe que vous avez créé");
this.put("command-description-group-info", "&e/pp group info <name> - Voir toutes les particules sauvegardées du groupe");
this.put("#3", "ID Messages");
this.put("id-invalid", "&cL'ID rentrée n'est pas valide, il doit être un nombre entier positif");
this.put("id-unknown", "&cVous n'avez pas de particules appliquées avec : &b%id% &c!");
this.put("#4", "Other Messages");
this.put("other-no-permission", "&cVous n'avez pas la permission pour exécuter une commande /pp en tant qu'un autre joueur.");
this.put("other-missing-args", "&cVous oubliez des arguments dans votre commande. &b/ppo <player> <command>");
this.put("other-unknown-player", "&cLe joueur &b%player% &cn'a pas été trouvé. Il doit être en ligne.");
this.put("other-unknown-command", "&cLa commande &b/pp %cmd% &cn existe pas.");
this.put("other-success", "&Commande /pp exécutée. &b%player%&e. Retour de la commande :");
this.put("#5", "Add Messages");
this.put("add-reached-max", "Impossible d'appliquer la particule, vous avez atteint la limite de particules qui est de &b%amount% &c!");
this.put("add-particle-applied", "&aUne nouvelle particule est appliquée avec l'effet &b%effect%&a, le style &b%style%&a, et les paramètres &b%data% &a!");
this.put("data-no-args", "&cVous oubliez des arguments dans l'effet. Utilisation de la commande: &b/pp data <effect>");
this.put("#6", "Edit Messages");
this.put("edit-invalid-property", "cLa propriété &b%prop% &cest interdite. Propriétés valides : &beffect&c, &bstyle&c, &bdata");
this.put("edit-success-effect", "&aVotre particule avec l'ID de &b%id% &aa son effet changé à &b%effect% &a!");
this.put("edit-success-style", "&aVotre particule avec l'ID de &b%id% &aa son style changé à &b%style% &a!");
this.put("edit-success-data", "&aVotre particule avec l'ID de &b%id% &aa ses paramètres changés à &b%data% &a!");
this.put("#7", "Group Messages");
this.put("group-invalid", "&cUn groupe ou un preset de groupe sauvegardé n'existe pas avec le nom &b%name% &c!");
this.put("group-no-permission", "&cVous oubliez une permission pour un style ou un effet afin d'utiliser les groupe &b%group% &c!");
this.put("group-preset-no-permission", "&cVous oubliez une permission pour un style ou un effet afin d'utiliser les presets du groupe &b%group% &c!");
this.put("group-reserved", "&cLe nom de groupe &bactive &cest réservé et ne peut pas être utiliser !");
this.put("group-no-name", "&cVous n'avez pas rentré de nom de groupe ! &b/pp %cmd% <groupName>");
this.put("group-save-reached-max", "&cImpossible de sauvegarder le groupe, vous avez atteint le nombre maximun de groupes !");
this.put("group-save-no-particles", "&cImpossible de sauvegarder le groupe, vous n'avez pas appliqué de particules !");
this.put("group-save-success", "&aVos particules actuelles ont été sauvegardées sous le nom de groupe &b%name% &a!");
this.put("group-save-success-overwrite", "&aLe groupe &b%name% &aa été mis à jour avec vos particules actuelle !");
this.put("group-load-success", "&b%amount% &aparticule(s) appliqués venant du groupe sauvegardé nommé &b%name% &a!");
this.put("group-load-preset-success", "&b%amount% &aparticule(s) appliqués venant du preset sauvegardé nommé &b%name% &a!");
this.put("group-remove-preset", "&cVous ne pouvez pas supprimer un groupe de presets !");
this.put("group-remove-success", "&aGroupe de particules &b%name% &asupprimé !");
this.put("group-info-header", "&eLe groupe &b%group% &eposséde les particules suivantes :");
this.put("group-list-none", "&eVous n'avez pas de groupes de particules sauvegardés !");
this.put("group-list-output", "&eVous avez ces groupes suivants sauvegardés : &b%info%");
this.put("group-list-presets", "&eCes presets de groupes suivants sont disponibles : &b%info%");
this.put("#8", "Reload Messages");
this.put("reload-success", "&aLe plugin a été rechargé...");
this.put("reload-no-permission", "&cVous n'avez pas la permission pour recharger la configuration de ce plugin !");
this.put("#9", "Remove Messages");
this.put("remove-no-args", "&cVous n'avez pas rentrer d'ID à supprimer ! &b/pp remove <ID>");
this.put("remove-id-success", "&aVotre particule avec l'ID &b%id% &aa été supprimée !");
this.put("remove-effect-success", "&aSuppression de &b%amount% &ade votre particule avec l'effet &b%effect% &a!");
this.put("remove-effect-none", "&cVous n'avez pas de particules appliquées avec l'effet &b%effect% &c!");
this.put("remove-style-success", "&aSuppression &b%amount% &ade votre particule avec le style &b%style% &a!");
this.put("remove-style-none", "&cVous n'avez pas de particules appliquées avec le style &b%style% &c!");
this.put("remove-unknown", "&cL'effect avec le nom ou le style &b%name% &cn'existe pas !");
this.put("#10", "List Messages");
this.put("list-none", "&eVous n'avez pas de particules actives.");
this.put("list-you-have", "&eVous avez les particules suivantes appliquées :");
this.put("list-output", "&eID: &b%id% &eEffet: &b%effect% &eStyle: &b%style% &eParamètre: &b%data%");
this.put("#11", "Toggle Messages");
this.put("toggle-on", "&eLes particules sont maintenant en mode &aON &e!");
this.put("toggle-off", "&eLes particules sont maintenant en mode &cOFF &e!");
this.put("#12", "Color Messages");
this.put("rainbow", "&cr&6a&ei&an&bb&9o&dw");
this.put("random", "aléatoire");
this.put("#13", "Effect Messages");
this.put("effect-no-permission", "&cVous n'avez pas la permission pour utiliser la particule &b%effect% &c!");
this.put("effect-invalid", "&cL'effet &b%effect% &cn existe pas ! Utilisez &b/pp effects &cpour afficher les effets disponibles.");
this.put("effect-list", "&eVous pouvez utiliser les effets suivants : &b%effects%");
this.put("effect-list-empty", "&cVous n'avez pas la permission pour utiliser des effets !");
this.put("#14", "Style Messages");
this.put("style-no-permission", "&cVous n'avez pas la permission pour utiliser le style &b%style% &c!");
this.put("style-event-spawning-info", "&eNote: Le style &b%style% &efait apparaitre des particules seulement lors d'évènements spécifiques.");
this.put("style-invalid", "&cLe style &b%style% &cn'existe pas ! Utilisez &b/pp styles &cpour afficher les styles disponibles.");
this.put("style-list", "&eVous pouvez utiliser les styles suivants : &b%styles%");
this.put("#15", "Data Messages");
this.put("data-usage-none", "&eL'effet &b%effect% &en'est pas paramétrable.");
this.put("data-usage-block", "&eL'effet &b%effect% &erequière l'ID du bloc ! &bFormat: <blockName>");
this.put("data-usage-item", "&eL'effet &b%effect% &erequière l'ID de l'item ! &bFormat: <itemName>");
this.put("data-usage-color", "&eL'effet &b%effect% &erequière l'ID de la couleur ! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-usage-note", "&eL'effet&b%effect% &erequière l'ID de la note ! &bFormat: <0-24>|<rainbow>|<random>");
this.put("data-invalid-block", "&cL'ID du bloc que vous avez rentré n'est pas valide ! &bFormat: <blockName>");
this.put("data-invalid-item", "&cL'ID de l'item que vous avez rentré n'est pas valide ! &bFormat: <itemName>");
this.put("data-invalid-color", "&cL'ID de la couleur que vous avez rentré n'est pas valide ! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-invalid-note", "&cL'ID du bloc que vous avez rentré n'est pas valide ! &bFormat: <0-24>|<rainbow>|<random>");
this.put("data-invalid-material-not-item", "&cL'ID &b%material% &cne correspond pas à un item !");
this.put("data-invalid-material-not-block", "&cL'ID &b%material% &cne correspond pas à un bloc !");
this.put("data-invalid-material-item", "&cL'ID &b%material% n'existe pas !");
this.put("data-invalid-material-block", "&cL'ID&b%material% n'existe pas !");
this.put("#16", "World Messages");
this.put("disabled-worlds", "&eLes particules sont désactivées dans ces mondes : &b%worlds%");
this.put("disabled-worlds-none", "&Les particules sont désactivées dans aucuns mondes.");
this.put("#17", "Reset Message");
this.put("reset-success", "&b%amount% &aparticule(s) actives supprimées !");
this.put("#18", "Fixed Create Messages");
this.put("fixed-create-missing-args", "&cImpossible de créer un effet fixe, vous oubliez des arguments : &b%amount%");
this.put("fixed-create-invalid-coords", "&cImpossible de créer un effet fixe, coordonnées invalides !");
this.put("fixed-create-out-of-range", "&cImpossible de créer un effet fixe, Vous devez être à &b%range% &cblocs de la position rentrée !");
this.put("fixed-create-looking-too-far", "&cImpossible de créer un effet fixe, vous êtes trop loin du bloc que vous regardez !");
this.put("fixed-create-effect-invalid", "&cImpossible de créer un effet fixe, l effet &b%effect% &cn'existe pas !");
this.put("fixed-create-effect-no-permission", "&cImpossible de créer un effet fixe, vous n'avez pas la permission pour utiliser le style &b%effect% &c!");
this.put("fixed-create-style-invalid", "&cImpossible de créer un effet fixe, le style &b%style% &cn'existe pas!");
this.put("fixed-create-style-no-permission", "&cImpossible de créer un effet fixe, vous n'avez pas la permission pour utiliser le style &b%style% &c!");
this.put("fixed-create-style-non-fixable", "&cImpossible de créer un effet fixe, le style &b%style% &cne peut pas être utilisé en tant qu'effet fixe !");
this.put("fixed-create-data-error", "&cImpossible de créer un effet fixe, l'ID rentrée n'est pas valide ! Utilisez &b/pp data <effect> &cpour afficher les IDs valides.");
this.put("fixed-create-success", "&aL'effet fixe à été créer.");
this.put("#19", "Fixed Edit Messages");
this.put("fixed-edit-missing-args", "&cImpossible de modifier l'effet fixe, vous oubliez des arguments !");
this.put("fixed-edit-invalid-id", "&cImpossible de modifier l'effet fixe, ID incorrecte !");
this.put("fixed-edit-invalid-property", "&cImpossible de modifier l'effet fixe, argument incorrect ! Seuls localisation, effet, style, et paramètre sont valides.");
this.put("fixed-edit-invalid-coords", "&cImpossible de modifier l'effet fixe, coordonnée incorrecte !");
this.put("fixed-edit-out-of-range", "&cImpossible de modifier l'effet fixe, vous devez être à &b%range% &cblocs de l'emplacement désiré !");
this.put("fixed-edit-looking-too-far", "&cImpossible de modifier l'effet fixe, vous êtes trop loin du bloc que vous regardez !");
this.put("fixed-edit-effect-invalid", "&cImpossible de modifier l'effet fixe, l'effet &b%effect% &cn'existe pas !");
this.put("fixed-edit-effect-no-permission", "&cImpossible de modifier l'effet fixe, vous n'avez pas la permission pour utiliser l'effet &b%effect% &c!");
this.put("fixed-edit-style-invalid", "&cImpossible de modifier l'effet fixe, le style &b%style% &cn'existe pas !");
this.put("fixed-edit-style-no-permission", "&cImpossible de modifier l'effet fixe, vous n'avez pas la permission pour utiliser le style &b%style% &c!");
this.put("fixed-edit-style-non-fixable", "&cImpossible de modifier l'effet fixe, the style &b%style% &cne peut pas être utilisé dans des effets fixes !");
this.put("fixed-edit-data-error", "&cImpossible de modifier l'effet fixe, paramètre incorrect ! Utilisez &b/pp data <effect> pour afficher les paramètres valides.");
this.put("fixed-edit-data-none", "&cImpossible de modifier l'effet fixe, l'effet ne requière pas de paramètres !");
this.put("fixed-edit-success", "&aMise à jour de &b%prop% &ade l'effet fixe avec l'ID &b%id% &a!");
this.put("#20", "Fixed Remove Messages");
this.put("fixed-remove-invalid", "&cImpossible de supprimer l'effet fixe, vous n'avez pas d effets fixes avec l'ID &b%id% &c!");
this.put("fixed-remove-no-args", "&cVous n'avez pas rentrer d'ID à supprimer !");
this.put("fixed-remove-args-invalid", "&cImpossible de supprimer, l'ID doit être un nombre !");
this.put("fixed-remove-success", "&aTous vos effets fixes avec l'ID &b%id% &aont été supprimés !");
this.put("#21", "Fixed List Messages");
this.put("fixed-list-none", "&eVous n'avez pas d'effets fixes !");
this.put("fixed-list-success", "&eVous avez des effets fixes avec ces IDs :&b%ids%");
this.put("#22", "Fixed Info Messages");
this.put("fixed-info-invalid", "&cImpossible d'obtenir l'information, vous n'avez pas de particules fixes avec l'ID &b%id%& c!");
this.put("fixed-info-no-args", "&cVous n'avez pas rentrée d'ID pour obtenir d'infomations !");
this.put("fixed-info-invalid-args", "&cImpossible d'obtenir l'information, vous n'avez pas de particules fixes avec l'ID, l'ID spécifiée doit être un nombre !");
this.put("fixed-info-success", "&eID: &b%id% &eWorld: &b%world% &eX: &b%x% &eY: &b%y% &eZ: &b%z% &eEffect: &b%effect% &eStyle: &b%style% &eData: &b%data%");
this.put("#23", "Fixed Clear Messages");
this.put("fixed-clear-no-permission", "&cVous n'avez la permission pour supprimer les effets proches !");
this.put("fixed-clear-no-args", "&cVous n'avez pas rentré de rayon !");
this.put("fixed-clear-invalid-args", "&cLe rayon rentré n'est pas valide, il doit être un nombre rond !");
this.put("fixed-clear-success", "&b%amount% &aeffets ont été supprimés dans un rayon &b%range% &cblocs !");
this.put("#24", "Fixed Other Messages");
this.put("fixed-no-permission", "&cVous n'avez pas la permission d'ajouter des effets fixes !");
this.put("fixed-max-reached", "&cVous avez atteint le nombre maximum de particules fixes !");
this.put("fixed-invalid-command", "&cArguments invalides pour la commande &b/pp fixed&c!");
this.put("#25", "Plugin Update Message");
this.put("update-available", "&eLa version (&b%new%&e) est disponible ! vous utilisez la version &bv%current%&d. https://www.spigotmc.org/resources/playerparticles.40261/");
this.put("#26", "GUI Messages");
this.put("gui-disabled", "&cL'interface du plugin à été désactivée !");
this.put("#27", "GUI Color Messages");
this.put("gui-color-icon-name", "&a");
this.put("gui-color-info", "&e");
this.put("gui-color-subtext", "&b");
this.put("gui-color-unavailable", "&c");
this.put("#28", "GUI Info Messages");
this.put("gui-commands-info", "Affichez des informations avec &b/pp help");
this.put("gui-back-button", "Retour en arrière");
this.put("gui-next-page-button", "Page Suivante (%start%/%end%)");
this.put("gui-previous-page-button", "Page Précédente (%start%/%end%)");
this.put("gui-click-to-load", "Cliquez pour charger : %amount%");
this.put("gui-shift-click-to-delete", "Touche SHIFT + clic-gauche pour effacer un effet");
this.put("gui-particle-info", " - ID: &b%id% &eEffet: &b%effect% &eStyle: &b%style% &eParamètre: &b%data%");
this.put("gui-playerparticles", "PlayerParticles");
this.put("gui-active-particles", "Particules actives: &b%amount%");
this.put("gui-saved-groups", "Groupes sauvegardés: &b%amount%");
this.put("gui-fixed-effects", "Effets fixes: &b%amount%");
this.put("#29", "GUI Edit Primary Messages");
this.put("gui-edit-primary-effect", "Editez l'effet primaire");
this.put("gui-edit-primary-effect-description", "Editez l effet d une de vos particules primaire");
this.put("gui-edit-primary-style", "Editez le style primaire");
this.put("gui-edit-primary-style-missing-effect", "Vous devez d'abord sélectionner un effet !");
this.put("gui-edit-primary-style-description", "Editez le style d'une particule primaire");
this.put("gui-edit-primary-data", "Editez les paramètres d'une particules primaire");
this.put("gui-edit-primary-data-missing-effect", "Vous devez d'abord sélectionner un effet");
this.put("gui-edit-primary-data-unavailable", "Votre effet primaire n'est pas paramétrable");
this.put("gui-edit-primary-data-description", "Editer les paramères de votre effet primaire");
this.put("#30", "GUI Manage Particles Messages");
this.put("gui-manage-your-particles", "Gérez vos particules");
this.put("gui-manage-your-particles-description", "Créez, éditez, et supprimez vos particules");
this.put("gui-manage-your-groups", "Gérez vos groupes");
this.put("gui-manage-your-groups-description", "Créez, éditez, et supprimez vos groupes particules");
this.put("#31", "GUI Load Messages");
this.put("gui-load-a-preset-group", "Chargez un groupe de presets");
this.put("gui-load-a-preset-group-description", "Chargez un groupe de particules déjà fait");
this.put("#32", "GUI Save Messages");
this.put("gui-save-group", "Sauvegardez un nouveau groupe");
this.put("gui-save-group-description", "Cliquez pour sauvegardez un nouveau groupe. Vous allez être invité\nà écrire un nouveau nom dans le tchat.");
this.put("gui-save-group-full", "Vous avez atteint le nombre maximal de groupe !");
this.put("gui-save-group-no-particles", "Vous avez aucunes particules appliquées");
this.put("gui-save-group-hotbar-message", "&eTapez &b1 &enom dans le tchat pour le nouveau nom du groupe. Tapez &ccancel&e pour annuler. (&b%seconds%&es restants)");
this.put("#33", "GUI Reset Messages");
this.put("gui-reset-particles", "Réinitialisez vos particules");
this.put("gui-reset-particles-description", "Supprimez vos particules actives");
this.put("#34", "GUI Misc Messages");
this.put("gui-particle-name", "Particule #%id%");
this.put("gui-click-to-edit-particle", "Cliquez pour éditer cette particule");
this.put("gui-editing-particle", "Edition particule #%id%");
this.put("#35", "GUI Edit Messages");
this.put("gui-edit-effect", "Editez l'effet");
this.put("gui-edit-effect-description", "Cliquez pour éditer l'effet de cette particule");
this.put("gui-edit-style", "Editez le style");
this.put("gui-edit-style-description", "Cliquez pour éditer le style de cette particule");
this.put("gui-edit-data", "Editez les paramères");
this.put("gui-edit-data-description", "Cliquez pour éditer les paramètres de la particule");
this.put("gui-edit-data-unavailable", "Cliquez pour éditer les paramères de cette particule");
this.put("gui-data-none", "aucuns");
this.put("#36", "GUI Create Messages");
this.put("gui-create-particle", "Créez une nouvelle particule");
this.put("gui-create-particle-description", "Créez une nouvelle particule");
this.put("gui-create-particle-unavailable", "Vous avez atteint le nombre maximum de particules que vous pouvez créer");
this.put("#37", "GUI Select Messages");
this.put("gui-select-effect", "Sélectionnez les effets");
this.put("gui-select-effect-description", "Mettez les effets de la particules à &b%effect%");
this.put("gui-select-style", "Sélectionnez le style");
this.put("gui-select-style-description", "Mets le style de la particule à &b%style%");
this.put("gui-select-data", "Sélectionnez les paramètres");
this.put("gui-select-data-description", "Mets les paramètres de la particule à &b%data%");
this.put("gui-select-data-note", "note #%note%");
this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&crouge");
this.put("gui-edit-data-color-orange", "&6orange");
this.put("gui-edit-data-color-yellow", "&ejaune");
this.put("gui-edit-data-color-lime-green", "&avert citron");
this.put("gui-edit-data-color-green", "&2vert");
this.put("gui-edit-data-color-blue", "&1bleu");
this.put("gui-edit-data-color-cyan", "&3cyan");
this.put("gui-edit-data-color-light-blue", "&bbleu clair");
this.put("gui-edit-data-color-purple", "&5mauve");
this.put("gui-edit-data-color-magenta", "&dmagenta");
this.put("gui-edit-data-color-pink", "&drose");
this.put("gui-edit-data-color-brown", "&6brun");
this.put("gui-edit-data-color-black", "&8noir");
this.put("gui-edit-data-color-gray", "&8gris");
this.put("gui-edit-data-color-light-gray", "&7gris clair");
this.put("gui-edit-data-color-white", "&fblanc");
}};
}
}

View file

@ -0,0 +1,325 @@
package dev.esophose.playerparticles.locale;
import java.util.LinkedHashMap;
import java.util.Map;
public class GermanLocale implements Locale {
@Override
public String getLocaleName() {
return "de_DE";
}
@Override
public String getTranslatorName() {
return "Drynael";
}
@Override
public Map<String, String> getDefaultLocaleStrings() {
return new LinkedHashMap<String, String>() {{
this.put("#0", "Plugin Message Prefix");
this.put("prefix", "&7[&3PlayerParticles&7] ");
this.put("#1", "Command Description Messages");
this.put("command-error-no-effects", "&cSie müssen Zugriff auf Effekte haben, um diesen Befehl verwenden zu können!");
this.put("command-error-unknown", "&cUnbekannter Befehl. Verwenden Sie &b/pp help &c, um eine Liste der Befehle anzuzeigen.");
this.put("command-descriptions", "Die folgenden Befehle stehen zur Auswahl:");
this.put("command-descriptions-usage", "&e/pp %cmd% %args%");
this.put("command-descriptions-help-1", "&7> &b/pp %cmd% &e- %desc%");
this.put("command-descriptions-help-2", "&7> &b/pp %cmd% %args% &e- %desc%");
this.put("command-descriptions-help-other", "&7> &b/ppo <player> <command> &e- Führe /pp als einen Spieler aus");
this.put("command-description-add", "Fügen Sie einen neuen Partikel hinzu");
this.put("command-description-data", "Üprüfen Sie, welche Art von Daten ein Effekt verwendet");
this.put("command-description-default", "Der Hauptbefehl. Standardmäßig wird die GUI geöffnet");
this.put("command-description-edit", "Bearbeiten Sie ein Partikel");
this.put("command-description-effects", "Zeigen Sie eine Liste der Effekte an, die Sie verwenden können");
this.put("command-description-fixed", "Verwalten Sie Ihre festen Effekte");
this.put("command-description-group", "Verwalten Sie Ihre Gruppen");
this.put("command-description-gui", "Zeigen Sie die GUI zum einfachen Bearbeiten von Partikeln an");
this.put("command-description-help", "Zeigt das Hilfemenü an ... Sie sind angekommen");
this.put("command-description-info", "Ruft die Beschreibung eines Ihrer aktiven Partikel ab");
this.put("command-description-list", "Listet die IDs Ihrer aktiven Partikel auf");
this.put("command-description-reload", "Lädt die Dateien config.yml und Sprache neu");
this.put("command-description-remove", "Entfernt einen Partikel");
this.put("command-description-reset", "Entfernt alle aktiven Partikel");
this.put("command-description-styles", "Zeigen Sie eine Liste der Stile an, die Sie verwenden können");
this.put("command-description-toggle", "Schaltet die Partikelsichtbarkeit ein / aus");
this.put("command-description-version", "Zeigen Sie die Plugin-Version und den Autor an");
this.put("command-description-worlds", "Finde heraus, in welchen Welten Partikel deaktiviert sind");
this.put("#2", "Fixed Particle Command Description Messages");
this.put("command-description-fixed-create", "&e/pp fixed create <<x> <y> <z>|<looking>> <effect> <style> [data] - Erstellt einen neun fixen Effekt");
this.put("command-description-fixed-edit", "&e/pp fixed edit <id> <effect|style|data> <args> - Bearbeiten Sie einen Teil eines festen Effekts anhand seiner ID");
this.put("command-description-fixed-remove", "&e/pp fixed remove <ID> - Entfernt einen festen Effekt anhand seiner ID");
this.put("command-description-fixed-list", "&e/pp fixed list - Listet alle IDs Ihrer festen Effekte auf");
this.put("command-description-fixed-info", "&e/pp fixed info <ID> - Ruft Informationen zu einem Ihrer Fixen Effekte ab");
this.put("command-description-fixed-clear", "&e/pp fixed clear <radius> - Löscht alle festen Effekte aller Spieler innerhalb des angegebenen Radius");
this.put("command-description-group-save", "&e/pp group save <name> - Speichert alle aktiven Partikel in einer neuen Gruppe");
this.put("command-description-group-load", "&e/pp group load <name> - Lädt alle in einer Gruppe gespeicherten Partikel");
this.put("command-description-group-remove", "&e/pp group remove <name> - Entfernt eine gespeicherte Gruppe");
this.put("command-description-group-list", "&e/pp group list <name> - Listen Sie alle Partikelgruppen auf, die Sie gespeichert haben");
this.put("command-description-group-info", "&e/pp group info <name> - Listen Sie die in der Gruppe gespeicherten Partikel auf");
this.put("#3", "ID Messages");
this.put("id-invalid", "&cDie eingegebene ID ist ungültig, es muss eine positive ganze Zahl sein!");
this.put("id-unknown", "&cSie haben kein Partikel mit der ID &b%id%&cangelegt!");
this.put("#4", "Other Messages");
this.put("other-no-permission", "&cSie haben keine Berechtigung, PlayerParticles-Befehle für andere Spieler auszuführen!");
this.put("other-missing-args", "&cEs fehlen einige Argumente. &b/ppo <player> <command>");
this.put("other-unknown-player", "&cDer Spieler &b%player% &cwurde nicht gefunden. Der Spieler mussen online sein.");
this.put("other-unknown-command", "&cDer Befehl &b/pp %cmd% &cexistiert nicht.");
this.put("other-success", "&eBefehl /pp command für &b%player%&eausgeführt. Ausgabe:");
this.put("#5", "Add Messages");
this.put("add-reached-max", "&cPartikel kann nicht angewendet werden, Sie haben die maximal zulässige Menge von &b%amount% &cerreicht!");
this.put("add-particle-applied", "&aEs wurde ein neues Partikel mit dem Effekt &b%effect%&a, dem Stil &b%style%&aund den Daten &b%data%&aangewendet!");
this.put("data-no-args", "&cFehlendes Argument für die Wirkung! Befehlsverwendung: &b/pp data <effect>");
this.put("#6", "Edit Messages");
this.put("edit-invalid-property", "&cEine ungültige Eigenschaft &b%prop% &cwurde angegeben. Gültige Eigenschaften: &beffect&c, &bstyle&c, &bdata");
this.put("edit-success-effect", "&aDer Effekt Ihres Partikels mit der ID &b%id% &awurde in &b%effect%&ageändert!");
this.put("edit-success-style", "&aDer Stil Ihres Partikels mit der ID &b%id% &awurde in &b%style%&ageändert!");
this.put("edit-success-data", "&aDie Daten Ihres Partikels mit der ID &b%id% &awurden in &b%data%&ageändert!");
this.put("#7", "Group Messages");
this.put("group-invalid", "&cEs existiert keine gespeicherte Gruppe oder Voreinstellungsgruppe mit dem Namen &b%name%&c!");
this.put("group-no-permission", "&cSie haben keine Berechtigung für einen Effekt oder Stil, um die Gruppe &b%group%&czu verwenden!");
this.put("group-preset-no-permission", "&cEs fehlt die Berechtigung für einen Effekt oder Stil, um die voreingestellte Gruppe &b%group%&czu verwenden!");
this.put("group-reserved", "&cDer Gruppenname &bactive &cist reserviert und kann nicht verwendet werden!");
this.put("group-no-name", "&cSie haben keinen Gruppennamen angegeben! &b/pp %cmd% <groupName>");
this.put("group-save-reached-max", "&cDie Gruppe kann nicht gespeichert werden, Sie haben die maximale Anzahl von Gruppen erreicht!");
this.put("group-save-no-particles", "&cGruppe kann nicht gespeichert werden, es wurden keine Partikel angewendet!");
this.put("group-save-success", "&aIhre aktuellen Partikel wurden unter der Gruppe &b%name%&agespeichert!");
this.put("group-save-success-overwrite", "&aDie Gruppe mit dem Namen &b%name% &awurde mit Ihren aktuellen Partikeln aktualisiert!");
this.put("group-load-success", "&aAngewendete &b%amount% &aPartikel aus Ihrer gespeicherten Gruppe mit dem Namen &b%name%&a!");
this.put("group-load-preset-success", "&aAngewendete &b%amount% &aPartikel aus der voreingestellten Gruppe mit dem Namen &b%name%&a!");
this.put("group-remove-preset", "&cSie können keine voreingestellte Gruppe entfernen!");
this.put("group-remove-success", "&aDie Partikelgruppe mit dem Namen &b%name%&awurde entfernt!");
this.put("group-info-header", "&eDie Gruppe &b%group% &eenthält die folgenden Partikel:");
this.put("group-list-none", "&eSie haben keine Partikelgruppen gespeichert!");
this.put("group-list-output", "&eFolgende Gruppen wurden gespeichert: &b%info%");
this.put("group-list-presets", "&eDie folgenden voreingestellten Gruppen sind verfügbar: &b%info%");
this.put("#8", "Reload Messages");
this.put("reload-success", "&aDas Plugin wurde neu geladen!");
this.put("reload-no-permission", "&cSie haben keine Berechtigung, die Plugin-Einstellungen neu zu laden!");
this.put("#9", "Remove Messages");
this.put("remove-no-args", "&cSie haben keine ID zum Entfernen angegeben! &b/pp remove <ID>");
this.put("remove-id-success", "&aDein Partikel mit der ID &b%id% &awurde entfernt!");
this.put("remove-effect-success", "&aEntferne &b%amount% &adeiner Partikel mit dem Effekt von &b%effect%&a!");
this.put("remove-effect-none", "&cSie haben keine Partikel mit dem Effekt &b%effect%&cangelegt!");
this.put("remove-style-success", "&b%amount% &adeiner Partikel im Stil von &b%style% &aentfernt!");
this.put("remove-style-none", "&cSie haben keine Partikel mit dem Stil &b%style%&cangelegt!");
this.put("remove-unknown", "&cEs existiert kein Effekt oder Stil mit dem Namen &b%name%&c!");
this.put("#10", "List Messages");
this.put("list-none", "&eSie haben keine aktiven Partikel!");
this.put("list-you-have", "&eSie haben die folgenden Partikel angewendet:");
this.put("list-output", "&eID: &b%id% &eEffekt: &b%effect% &eStil: &b%style% &eDaten: &b%data%");
this.put("#11", "Toggle Messages");
this.put("toggle-on", "&ePartikel wurden umgeschaltet &aAN&e!");
this.put("toggle-off", "&ePartikel wurden umgeschaltet &cAUS&e!");
this.put("#12", "Color Messages");
this.put("rainbow", "&cR&6e&eg&ae&bn&9b&do&cg&4e&2n");
this.put("random", "Zufällig");
this.put("#13", "Effect Messages");
this.put("effect-no-permission", "&cSie haben keine Berechtigung, den Effekt &b%effect% &czu verwenden!");
this.put("effect-invalid", "&cDer Effekt &b%effect% &cexistiert nicht! Verwenden Sie &b/pp effects &c, um eine Liste der Effekte anzuzeigen, die Sie verwenden können.");
this.put("effect-list", "&eSie können die folgenden Effekte verwenden: &b%effects%");
this.put("effect-list-empty", "&cSie haben keine Berechtigung, Effekte zu verwenden!");
this.put("#14", "Style Messages");
this.put("style-no-permission", "&cSie haben keine Berechtigung, den Stil &b%style% &czu verwenden!");
this.put("style-event-spawning-info", "&eHinweis: Der Stil &b%style% &eerzeugt Partikel basierend auf einem Ereignis.");
this.put("style-invalid", "&cDer Stil &b%style% &cexistiert nicht! Verwenden Sie &b/pp styles &cfür eine Liste der Stile, die Sie verwenden können.");
this.put("style-list", "&eSie können die folgenden Stile verwenden: &b%styles%");
this.put("#15", "Data Messages");
this.put("data-usage-none", "&eDer Effekt &b%effect% &everwendet keine Daten!");
this.put("data-usage-block", "&eFür den Effekt &b%effect% &ewerden &bBlockdaten &ebenötigt! &bFormat: <blockName>");
this.put("data-usage-item", "&eFür den Effekt &b%effect% &esind &bItem &eDaten erforderlich! &bFormat: <itemName>");
this.put("data-usage-color", "&eFür den Effekt &b%effect% &esind &bFarbdaten &eerforderlich! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-usage-note", "&eFür den Effekt &b%effect% &esind &bAnmeldedaten &eerforderlich! &bFormat: <0-24>|<rainbow>|<random>");
this.put("data-invalid-block", "&cDie von Ihnen eingegebenen &bBlock &cDaten sind ungültig! &bFormat: <blockName>");
this.put("data-invalid-item", "&cDie von Ihnen eingegebenen &bItem &cDaten sind ungültig! &bFormat: <itemName>");
this.put("data-invalid-color", "&cDie von Ihnen eingegebenen &bFarbdaten &csind ungültig! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-invalid-note", "&cDie von Ihnen eingegebenen &bNotizdaten &csind ungültig! &bFormat: <0-24>|<rainbow>|<random>");
this.put("data-invalid-material-not-item", "&cDas von Ihnen eingegebene &bItem &cMaterial &b%material% &cist kein Item!");
this.put("data-invalid-material-not-block", "&cDas von Ihnen eingegebene &bBlock &cMaterial &b%material% &cist kein Block!");
this.put("data-invalid-material-item", "&cDas von Ihnen eingegebene &bItem &cMaterial &b%material% &cexistiert nicht!");
this.put("data-invalid-material-block", "&cDas von Ihnen eingegebene &bBlock &cMaterial &b%material% &cexistiert nicht!");
this.put("#16", "World Messages");
this.put("disabled-worlds", "&ePartikel sind in diesen Welten deaktiviert: &b%worlds%");
this.put("disabled-worlds-none", "&ePartikel sind in keiner Welt deaktiviert.");
this.put("#17", "Reset Message");
this.put("reset-success", "&b%amount% &aaktive Partikel entfernt!");
this.put("#18", "Fixed Create Messages");
this.put("fixed-create-missing-args", "&cFixer Effekt kann nicht erstellt werden, es fehlen &b%amount% &cerforderliche Argumente!");
this.put("fixed-create-invalid-coords", "&cEin fester Effekt kann nicht erstellt werden, eine oder mehrere von Ihnen eingegebene Koordinaten sind ungültig!");
this.put("fixed-create-out-of-range", "&cSie können keinen festen Effekt erstellen. Sie müssen sich innerhalb von &b%range% &cBlöcken von Ihrem gewünschten Standort befinden.");
this.put("fixed-create-looking-too-far", "&cSie können keinen festen Effekt erzielen, da Sie zu weit von dem Block entfernt sind, den Sie gerade betrachten.");
this.put("fixed-create-effect-invalid", "&cEs kann kein fester Effekt erstellt werden, ein Effekt mit dem Namen &b%effect% &cist nicht vorhanden!");
this.put("fixed-create-effect-no-permission", "&cSie können keinen festen Effekt erstellen. Sie haben keine Berechtigung, den Effekt zu verwenden. &b%effect%&c!");
this.put("fixed-create-style-invalid", "&cEs kann kein fester Effekt erstellt werden. Ein Stil mit dem Namen &b%style% &cist nicht vorhanden.");
this.put("fixed-create-style-no-permission", "&cEs kann kein fester Effekt erstellt werden. Sie haben keine Berechtigung, den Stil &b%style%&czu verwenden.");
this.put("fixed-create-style-non-fixable", "&cFeste Effekte können nicht erstellt werden. Der Stil &b%style% &ckann nicht für feste Effekte verwendet werden!");
this.put("fixed-create-data-error", "&cEs kann kein fester Effekt erstellt werden, die angegebenen Daten sind nicht korrekt! Verwenden Sie &b/pp data <effect> &c, um das richtige Datenformat zu finden!");
this.put("fixed-create-success", "&aDein fester Effekt wurde erstellt!");
this.put("#19", "Fixed Edit Messages");
this.put("fixed-edit-missing-args", "&cFixer Effekt kann nicht bearbeitet werden, es fehlen einige Argumente!");
this.put("fixed-edit-invalid-id", "&cDer festgelegte Effekt kann nicht bearbeitet werden, die angegebene ID ist ungültig oder existiert nicht!");
this.put("fixed-edit-invalid-property", "&cFixeffekt kann nicht bearbeitet werden, es wurde eine ungültige Eigenschaft angegeben! Es sind nur &bPositionsdaten&c, &bEffektdaten&c, &bStildaten&cund &bDaten &cgültig.");
this.put("fixed-edit-invalid-coords", "&cFixer Effekt kann nicht bearbeitet werden, eine oder mehrere von Ihnen eingegebene Koordinaten sind ungültig!");
this.put("fixed-edit-out-of-range", "&cFixierter Effekt kann nicht bearbeitet werden. Sie müssen sich innerhalb von &b%range% &cBlöcken von Ihrem gewünschten Standort befinden!");
this.put("fixed-edit-looking-too-far", "&cEin fester Effekt kann nicht bearbeitet werden. Sie befinden sich zu weit entfernt von dem Block, den Sie gerade ansehen.");
this.put("fixed-edit-effect-invalid", "&cFixer Effekt kann nicht bearbeitet werden, ein Effekt mit dem Namen &b%effect% &cist nicht vorhanden!");
this.put("fixed-edit-effect-no-permission", "&cFixierter Effekt kann nicht bearbeitet werden. Sie haben keine Berechtigung, den Effekt zu verwenden. &b%effect%&c!");
this.put("fixed-edit-style-invalid", "&cEin fester Effekt kann nicht bearbeitet werden, ein Stil mit dem Namen &b%style% &cist nicht vorhanden!");
this.put("fixed-edit-style-no-permission", "&cFixierter Effekt kann nicht bearbeitet werden. Sie haben keine Berechtigung, den Stil &b%style%&czu verwenden.");
this.put("fixed-edit-style-non-fixable", "&cFixer Effekt kann nicht bearbeitet werden. Der Stil &b%style% &ckann nicht für fixe Effekte verwendet werden!");
this.put("fixed-edit-data-error", "&cFixeffekt kann nicht bearbeitet werden, die angegebenen Daten sind nicht korrekt! Verwenden Sie &b/pp data <effect> &c, um das richtige Datenformat zu finden!");
this.put("fixed-edit-data-none", "&cFixierter Effekt kann nicht bearbeitet werden, für den Effekt sind keine Daten erforderlich!");
this.put("fixed-edit-success", "&aAktualisiert die &b%prop% &ades festen Effekts mit einer ID von &b%id%&a!");
this.put("#20", "Fixed Remove Messages");
this.put("fixed-remove-invalid", "&cFixierter Effekt kann nicht entfernt werden, Sie haben keinen Fixierten Effekt mit der ID &b%id%&c!");
this.put("fixed-remove-no-args", "&cSie haben keine ID zum Entfernen angegeben!");
this.put("fixed-remove-args-invalid", "&cKann nicht entfernt werden, die angegebene ID muss eine Zahl sein!");
this.put("fixed-remove-success", "&aDein fester Effekt mit der ID &b%id% &awurde entfernt!");
this.put("#21", "Fixed List Messages");
this.put("fixed-list-none", "&eDu hast keine festen Effekte!");
this.put("fixed-list-success", "&eSie haben feste Effekte mit der ID: &b%ids%");
this.put("#22", "Fixed Info Messages");
this.put("fixed-info-invalid", "&cInformationen können nicht abgerufen werden. Sie haben keinen festen Effekt mit der ID &b%id%&c.");
this.put("fixed-info-no-args", "&cSie haben keine ID angegeben, für die Informationen angezeigt werden sollen!");
this.put("fixed-info-invalid-args", "&cInformationen können nicht abgerufen werden, die angegebene ID muss eine Zahl sein!");
this.put("fixed-info-success", "&eID: &b%id% &eWelt: &b%world% &eX: &b%x% &eY: &b%y% &eZ: %z% &b &eEffekt: &b%effect% &eStil: &b%style% &eDaten: &b%data%");
this.put("#23", "Fixed Clear Messages");
this.put("fixed-clear-no-permission", "&cSie haben keine Berechtigung, in der Nähe befindliche Fixeffekte zu löschen!");
this.put("fixed-clear-no-args", "&cSie haben keinen Radius zum Löschen fester Effekte für angegeben!");
this.put("fixed-clear-invalid-args", "&cDer von Ihnen angegebene Radius ist ungültig. Es muss sich um eine positive ganze Zahl handeln.");
this.put("fixed-clear-success", "&aEntfernte &b%amount% &aEffekte in &b%range% &aBlöcken von Ihrem Standort entfernt!");
this.put("#24", "Fixed Other Messages");
this.put("fixed-no-permission", "&cSie haben keine Berechtigung, Fixeffekte zu verwenden!");
this.put("fixed-max-reached", "&cSie haben die maximal zulässigen festen Effekte erreicht!");
this.put("fixed-invalid-command", "&cUngültiger Parameter für &b/pp fixed&c!");
this.put("#25", "Plugin Update Message");
this.put("update-available", "&eEin Update (&b%new%&e) ist verfügbar! Aktuelle Version: &bv%current%&e. https://www.spigotmc.org/resources/playerparticles.40261/");
this.put("#26", "GUI Messages");
this.put("gui-disabled", "&cDer Serveradministrator hat die GUI deaktiviert!");
this.put("#27", "GUI Color Messages");
this.put("gui-color-icon-name", "&a");
this.put("gui-color-info", "&e");
this.put("gui-color-subtext", "&b");
this.put("#28", "GUI Info Messages");
this.put("gui-commands-info", "Informationen zu Befehlen finden Sie mit Hilfe von &b/pp help");
this.put("gui-back-button", "Zurück");
this.put("gui-next-page-button", "Nächste Seite (%start%/%end%)");
this.put("gui-previous-page-button", "Vorherige Seite (%start%/%end%)");
this.put("gui-click-to-load", "Klicken Sie, um die folgenden %amount% Partikel zu laden:");
this.put("gui-shift-click-to-delete", "Umschaltklick zum Löschen");
this.put("gui-particle-info", "- ID: &b%id% &eEffekt: &b%effect% &eStil: &b%style% &eDaten: &b%data%");
this.put("gui-playerparticles", "PlayerParticles");
this.put("gui-active-particles", "Aktive Partikel: &b%amount%");
this.put("gui-saved-groups", "Gespeicherte Gruppen: &b%amount%");
this.put("gui-fixed-effects", "feste Effekte: &b%amount%");
this.put("#29", "GUI Edit Primary Messages");
this.put("gui-edit-primary-effect", "Primäreffekt bearbeiten");
this.put("gui-edit-primary-effect-description", "Bearbeiten Sie den Effekt Ihres Primärpartikel");
this.put("gui-edit-primary-style", "Primärer Stil");
this.put("gui-edit-primary-style-missing-effect", "Sie müssen zuerst einen Effekt auswählen");
this.put("gui-edit-primary-style-description", "Bearbeiten Sie den Stil Ihres Primärpartikel");
this.put("gui-edit-primary-data", "Primärdaten");
this.put("gui-edit-primary-data-missing-effect", "Sie müssen zuerst einen Effekt auswählen");
this.put("gui-edit-primary-data-unavailable", "Ihr primärer Effekt verwendet keine Daten");
this.put("gui-edit-primary-data-description", "Bearbeiten Sie die Daten Ihres Primärpartikel");
this.put("#30", "GUI Manage Particles Messages");
this.put("gui-manage-your-particles", "Verwalten Sie Ihre Partikel");
this.put("gui-manage-your-particles-description", "Erstellen, bearbeiten und löschen Sie Ihre Partikel");
this.put("gui-manage-your-groups", "Verwalten Sie Ihre Gruppen");
this.put("gui-manage-your-groups-description", "Erstellen, löschen und laden Sie Ihre Partikelgruppen");
this.put("#31", "GUI Load Messages");
this.put("gui-load-a-preset-group", "Laden Sie eine vorgefertigte Gruppe");
this.put("gui-load-a-preset-group-description", "Laden Sie eine vorgefertigte Partikelgruppe");
this.put("#32", "GUI Save Messages");
this.put("gui-save-group", "Neue Gruppe");
this.put("gui-save-group-description", "Klicken Sie hier, um eine neue Gruppe zu speichern. Sie werden aufgefordert, den neuen Gruppennamen im Chat einzugeben.");
this.put("gui-save-group-full", "Sie haben die maximale Anzahl von Gruppen erreicht");
this.put("gui-save-group-no-particles", "Sie haben keine Partikel");
this.put("gui-save-group-hotbar-message", "&eGeben Sie im Chat &b1 &eWort für den neuen Gruppennamen ein. Geben Sie &ccancel&e ein, um den Vorgang abzubrechen. (Noch&b%seconds%&e)");
this.put("#33", "GUI Reset Messages");
this.put("gui-reset-particles", "Setzen Sie Ihre Partikel zurück");
this.put("gui-reset-particles-description", "Löscht alle Ihre aktiven Partikel");
this.put("#34", "GUI Misc Messages");
this.put("gui-particle-name", "Partikel");
this.put("gui-click-to-edit-particle", "Klicken Sie hier, um den Effekt, den Stil oder die Daten dieses Partikels zu bearbeiten");
this.put("gui-editing-particle", "Partikel #%id% bearbeiten");
this.put("#35", "GUI Edit Messages");
this.put("gui-edit-effect", "Effekt bearbeiten");
this.put("gui-edit-effect-description", "Klicken Sie, um den Effekt dieses Partikels zu bearbeiten");
this.put("gui-edit-style", "Stil bearbeiten");
this.put("gui-edit-style-description", "Klicken Sie, um den Stil dieses Partikels zu bearbeiten");
this.put("gui-edit-data", "Daten bearbeiten");
this.put("gui-edit-data-description", "Klicken Sie, um die Daten dieses Partikels zu bearbeiten");
this.put("gui-edit-data-unavailable", "Für die Wirkung dieses Partikels werden keine Daten verwendet");
this.put("gui-data-none", "kein");
this.put("#36", "GUI Create Messages");
this.put("gui-create-particle", "Erstellen Sie einen neuen Partikel");
this.put("gui-create-particle-description", "Erstellen Sie ein neues Partikel mit einem Effekt, einem Stil und Daten");
this.put("gui-create-particle-unavailable", "Sie haben die maximale Partikelmenge erreicht, die Sie erstellen können");
this.put("#37", "GUI Select Messages");
this.put("gui-select-effect", "Wählen Sie Partikeleffekt");
this.put("gui-select-effect-description", "Setzt den Partikeleffekt auf &b%effect%");
this.put("gui-select-style", "Wählen Sie Partikelstil");
this.put("gui-select-style-description", "Legt den Partikelstil auf &b%style% fest");
this.put("gui-select-data", "Wählen Sie Partikeldaten");
this.put("gui-select-data-description", "Setzt die Partikeldaten auf &b%data%");
this.put("gui-select-data-note", "Hinweis #%note%");
this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "Rot");
this.put("gui-edit-data-color-orange", "Orange");
this.put("gui-edit-data-color-yellow", "Gelb");
this.put("gui-edit-data-color-lime-green", "Limetten-Grün");
this.put("gui-edit-data-color-green", "Grün");
this.put("gui-edit-data-color-blue", "Blau");
this.put("gui-edit-data-color-cyan", "Cyan");
this.put("gui-edit-data-color-light-blue", "Hellblau");
this.put("gui-edit-data-color-purple", "Lila");
this.put("gui-edit-data-color-magenta", "Magenta");
this.put("gui-edit-data-color-pink", "Pink");
this.put("gui-edit-data-color-brown", "Braun");
this.put("gui-edit-data-color-black", "Schwarz");
this.put("gui-edit-data-color-gray", "Grau");
this.put("gui-edit-data-color-light-gray", "Hellgrau");
this.put("gui-edit-data-color-white", "Weiss");
}};
}
}

View file

@ -0,0 +1,13 @@
package dev.esophose.playerparticles.locale;
import java.util.Map;
public interface Locale {
String getLocaleName();
String getTranslatorName();
Map<String, String> getDefaultLocaleStrings();
}

View file

@ -0,0 +1,326 @@
package dev.esophose.playerparticles.locale;
import java.util.LinkedHashMap;
import java.util.Map;
public class RussianLocale implements Locale {
@Override
public String getLocaleName() {
return "ru_RU";
}
@Override
public String getTranslatorName() {
return "Dimatron74";
}
@Override
public Map<String, String> getDefaultLocaleStrings() {
return new LinkedHashMap<String, String>() {{
this.put("#0", "Plugin Message Prefix");
this.put("prefix", "&7[&3PlayerParticles&7] ");
this.put("#1", "Command Description Messages");
this.put("command-error-no-effects", "&cВы должны иметь доступ к эффектам чтобы использовать эту команду!");
this.put("command-error-unknown", "&cНеизвестная команда, напишите &b/pp help &c, чтобы узнать команды.");
this.put("command-descriptions", "&eВам доступны команды ниже:");
this.put("command-descriptions-usage", "&e/pp %cmd% %args%");
this.put("command-descriptions-help-1", "&7> &b/pp %cmd% &e- %desc%");
this.put("command-descriptions-help-2", "&7> &b/pp %cmd% %args% &e- %desc%");
this.put("command-descriptions-help-other", "&7> &b/ppo <Игрок> <Команда> &e- Посмотреть командны /pp от лица другого игрока.");
this.put("command-description-add", "Добавить новые частицы.");
this.put("command-description-data", "Проверить, какой тип данных использует эффект.");
this.put("command-description-default", "Главная команда. Обычно открывает интерфейс.");
this.put("command-description-edit", "Изменить частицы.");
this.put("command-description-effects", "Показать список эффектов, которые Вы можете использовать.");
this.put("command-description-fixed", "Управление Вашими исправными эффектами.");
this.put("command-description-group", "Управление Вашими группами.");
this.put("command-description-gui", "Показать интерфейс для простого изменения частиц.");
this.put("command-description-help", "Показать список команд... в котором Вы находитесь.");
this.put("command-description-info", "Показать описание одного из Ваших активных эффектов.");
this.put("command-description-list", "Списки ID Ваших активных частиц.");
this.put("command-description-reload", "Перезапустить конфигурацию.");
this.put("command-description-remove", "Убрать некоторые частицы.");
this.put("command-description-reset", "Убрать все Ваши активные частицы.");
this.put("command-description-styles", "Показать список стилей, которые Вы можете использовать.");
this.put("command-description-toggle", "Сделать частицы видимыми или невидимыми.");
this.put("command-description-version", "Показать версию и создателя плагина.");
this.put("command-description-worlds", "Узнать, в каком мире Ваши частицы отключены.");
this.put("#2", "Fixed Particle Command Description Messages");
this.put("command-description-fixed-create", "&e/pp fixed create «x> <y> <z>|<looking» <Эффект> <Стиль> [данные] - Создаёт новый эффект.");
this.put("command-description-fixed-edit", "&e/pp fixed edit <id> <Эффект|Стиль|Данные> <аргумент> - Изменяет чать эффекта по его ID.");
this.put("command-description-fixed-remove", "&e/pp fixed remove <ID> - Удаляет эффект по его ID.");
this.put("command-description-fixed-list", "&e/pp fixed list - Показывает список ID всех Ваших эффектов.");
this.put("command-description-fixed-info", "&e/pp fixed info <ID> - Показывает информацию об одном из Ваших эффектов.");
this.put("command-description-fixed-clear", "&e/pp fixed clear <Радиус> - Удаляет все эффекты игроков, находящихся в заданном радиусе.");
this.put("command-description-group-save", "&e/pp group save <Имя> - Сохраняет все активные частицы в новой группе.");
this.put("command-description-group-load", "&e/pp group load <name> - Загружает все частицы, сохранённые в группе.");
this.put("command-description-group-remove", "&e/pp group remove <name> - Удаляет сохранённую Вами группу.");
this.put("command-description-group-list", "&e/pp group list <name> - Список всех групп частиц, которые Вы сохранили.");
this.put("command-description-group-info", "&e/pp group info <name> - Показывает частицы, сохранённые в группе.");
this.put("#3", "ID Messages");
this.put("id-invalid", "&cID, который Вы ввели, недействительный, это должно быть целое число!");
this.put("id-unknown", "&cВы не имеете частиц с ID &b%id%&c!");
this.put("#4", "Other Messages");
this.put("other-no-permission", "&cВы не имеете права, чтобы выполнять команды от других игроков!");
this.put("other-missing-args", "&cВы не ввели некоторые аргументы. &b/ppo <Игрок> <Команда>");
this.put("other-unknown-player", "&cИгрок &b%player% &cwas не найден. Скорее всего игрок оффлайн.");
this.put("other-unknown-command", "&cКоманды &b/pp %cmd% &cне существует.");
this.put("other-success", "&eВыполнена команда /pp от лица &b%player%&e. Результат:");
this.put("#5", "Add Messages");
this.put("add-reached-max", "&cНевозможно применить частицу, Вы использовали &b%amount% &c, максимум допустимых!");
this.put("add-particle-applied", "&aНовая частица была приложена к эффекту &b%effect%&a, стилю &b%style%&a и данным &b%data%&a!");
this.put("data-no-args", "&cВы не ввели аргумент для эффекта! Используйте &b/pp data <Эффект>");
this.put("#6", "Edit Messages");
this.put("edit-invalid-property", "&cНедействительное свойство &b%prop% &cпредусмотрено. Действительные свойства: &bЭффект&c, &bСтиль&c, &bДанные.");
this.put("edit-success-effect", "&aЭффект Ваших частиц под ID &b%id% &aбыл изменён на &b%effect%&a!");
this.put("edit-success-style", "&aСтиль Ваших частиц под ID &b%id% &aбыл изменён на &b%style%&a!");
this.put("edit-success-data", "&aДанные Ваших частиц под ID &b%id% &aбыли изменены на &b%data%&a!");
this.put("#7", "Group Messages");
this.put("group-invalid", "&cСохранённая или заданная группа под названием &b%name%&cне существует!");
this.put("group-no-permission", "&cВы потеряли право использовать эффект или стиль в группе &b%group%&c!");
this.put("group-preset-no-permission", "&cВы потеряли право использовать эффект или стиль в заданной группе &b%group%&c!");
this.put("group-reserved", "&cНазвание группы &bактивно &cи не может быть использованно!");
this.put("group-no-name", "&cВы не ввели название группы! &b/pp %cmd% <названиеГруппы>");
this.put("group-save-reached-max", "&cНевозможно сохранить группу, Вы превысили максимальное количество групп!");
this.put("group-save-no-particles", "&cНевозможно сохранить группу, у Вас нет никаких приложенных частиц!");
this.put("group-save-success", "&aВаши эффекты были сохранены в группе под названием &b%name%&a!");
this.put("group-save-success-overwrite", "&aГруппа &b%name% &aбыла обновлена с Вашими частицами!");
this.put("group-load-success", "&aИз группы &b%name%&a прикреплено частиц - &b%amount%!");
this.put("group-load-preset-success", "&aИз группы &b%name%&a прикреплено частиц - &b%amount%");
this.put("group-remove-preset", "&cВы не можете удалить заданную группу!");
this.put("group-remove-success", "&aУдалена группа под названием &b%name%&a!");
this.put("group-info-header", "&eГруппа &b%group% &eимеет следующие частицы:");
this.put("group-list-none", "&eУ Вас нет никаких сохранённых групп с частицами!");
this.put("group-list-output", "&eУ Вас есть следующие сохранённые группы: &b%info%");
this.put("group-list-presets", "&eДоступны следующие заданные группы: &b%info%");
this.put("#8", "Reload Messages");
this.put("reload-success", "&aКонфигурация перезагружена!");
this.put("reload-no-permission", "&cВы не имеете права, чтобы перезагружать параметры плагина!");
this.put("#9", "Remove Messages");
this.put("remove-no-args", "&cВы не ввели ID для удаления! &b/pp remove <ID>");
this.put("remove-id-success", "&aВаши частицы под ID &b%id% &aбыли успешно удалены!");
this.put("remove-effect-success", "&aКоличество удалённых частиц - &b%amount% &a, эффектов - &b%effect%&a!");
this.put("remove-effect-none", "&cУ Вас нет каких-либо частиц с эффектом &b%effect%&c!");
this.put("remove-style-success", "&aКоличество удалённых частиц - &b%amount% &a, стилей - &b%style%&a!");
this.put("remove-style-none", "&cУ Вас нет каких-либо частиц со стилем &b%style%&c!");
this.put("remove-unknown", "&cЭффект или стиль под названием &b%name% &cне существует!");
this.put("#10", "List Messages");
this.put("list-none", "&eУ вас нет каких-либо активных частиц!");
this.put("list-you-have", "&eУ Вас есть следующие частицы:");
this.put("list-output", "&eID: &b%id% &eЭффект: &b%effect% &eСтиль: &b%style% &eДанные: &b%data%");
this.put("#11", "Toggle Messages");
this.put("toggle-on", "&eЧастицы были &aВКЛЮЧЕНЫ&e!");
this.put("toggle-off", "&eЧастицы были &cВЫКЛЮЧЕНЫ&e!");
this.put("#12", "Color Messages");
this.put("rainbow", "&cР&6а&eд&aу&bг&9а&d!");
this.put("random", "Random");
this.put("#13", "Effect Messages");
this.put("effect-no-permission", "&cУ Вас нет прав использовать эффект &b%effect% &c!");
this.put("effect-invalid", "&cЭффект &b%effect% &cне существует! Введите &b/pp effects, &cчтобы узнать доступные Вам эффекты.");
this.put("effect-list", "&eВы можете использовать следующие эффекты: &b%effects%");
this.put("effect-list-empty", "&cУ Вас нет права использовать какие-либо эффекты!");
this.put("#14", "Style Messages");
this.put("style-no-permission", "&cУ Вас нет прав использовать стиль &b%style% &c!");
this.put("style-event-spawning-info", "&eЗаписка: стиль &b%style% &eспавнит частицы во время Ивента.");
this.put("style-invalid", "&cСтиль &b%style% &cне существует! Введите &b/pp styles &cчтобы узнать доступные Вам стили.");
this.put("style-list", "&eВы можете использовать следующие стили: &b%styles%");
this.put("#15", "Data Messages");
this.put("data-usage-none", "&eЭффект &b%effect% &eне использует какие-либо данные!");
this.put("data-usage-block", "&eЭффект &b%effect% &eзапрашивает &bблок &eданных! &bФормат: <названиеБлока>");
this.put("data-usage-item", "&eЭффект &b%effect% &eзапрашивает &bпредмет &eданных! &bФормат: <названиеПредмета>");
this.put("data-usage-color", "&eЭффект &b%effect% &eзапрашивает &bцвет &eданных! &bФормат: «0-255> <0-255> <0-255»|<rainbow>|<random>");
this.put("data-usage-note", "&eЭффект &b%effect% &eзапрашивает &bноту &eданных! &bФормат: <0-24>|<rainbow>|<random>");
this.put("data-invalid-block", "&bБлок &cданных, который Вы ввели, недействителен! &bФормат: <названиеБлока>");
this.put("data-invalid-item", "&bПредмет &cданных, который Вы ввели, недействителен! &bФормат: <названиеПредмета>");
this.put("data-invalid-color", "&bЦвет &cданных, который Вы ввели, недействителен! &bФормат: «0-255> <0-255> <0-255»|<rainbow>|<random>");
this.put("data-invalid-note", "&bНота &cданных, которую Вы ввели, недействительна! &bФормат: <0-24>|<rainbow>|<random>");
this.put("data-invalid-material-not-item", "&bМатериал &cпредмета&b%material%&c, который Вы ввели, не является предметом!");
this.put("data-invalid-material-not-block", "&bМатериал &cблока&b%material%&c, который Вы ввели, не является блоком!");
this.put("data-invalid-material-item", "&bМатериал &cпредмета&b%material%, который Вы ввели, не существует!");
this.put("data-invalid-material-block", "&bМатериал &cблока&b%material%, который Вы ввели, не существует!");
this.put("#16", "World Messages");
this.put("disabled-worlds", "&b%worlds% &eне поддерживает данные частицы.");
this.put("disabled-worlds-none", "&eЧастицы не поддерживаются ни в каком мире.");
this.put("#17", "Reset Message");
this.put("reset-success", "&aУдалено &aактивных частиц - &b%amount%!");
this.put("#18", "Fixed Create Messages");
this.put("fixed-create-missing-args", "&cНевозможно создать эффект, не введено запрашиваемых аргументов - &b%amount%!");
this.put("fixed-create-invalid-coords", "&cНевозможно создать эффект, одни или несколько координат, которые Вы ввели, неверны!");
this.put("fixed-create-out-of-range", "&cНевозможно создать эффект, Вы должны быть в &b%range% &cблоках от желаемой локации!");
this.put("fixed-create-looking-too-far", "&cНевозможно создать эффект, Вы стоите слишком далеко от блока, на который смотрите!");
this.put("fixed-create-effect-invalid", "&cНевозможно создать эффект, эффект под названием &b%effect% &cне существует!");
this.put("fixed-create-effect-no-permission", "&cНевозможно создать эффект, у Вас нет права использовать эффект &b%effect%&c!");
this.put("fixed-create-style-invalid", "&cНевозможно создать эффект, стиль под названием &b%style% &cне существует!");
this.put("fixed-create-style-no-permission", "&cНевозможно создать эффект, у Вас нет права использовать стиль &b%style%&c!");
this.put("fixed-create-style-non-fixable", "&cНевозможно создать эффект, стиль &b%style% &cне может быть использован!");
this.put("fixed-create-data-error", "&cНевозможно создать эффект, введённые данные неверны! Введите &b/pp data <Эффект>&c, чтобы найти правильный формат данных!");
this.put("fixed-create-success", "&aВаш эффект был создан!");
this.put("#19", "Fixed Edit Messages");
this.put("fixed-edit-missing-args", "&cНевозможно изменить эффект, Вы не ввели некоторые аргументы!");
this.put("fixed-edit-invalid-id", "&cНевозможно изменить эффект, введённый ID недействителен или не существует!");
this.put("fixed-edit-invalid-property", "&cНевозможно изменить эффект, указано недействительное свойство! Только &bлокация&c, &bэффект&c, &bстиль&c, и &bданные &cдействительны.");
this.put("fixed-edit-invalid-coords", "&cНевозможно изменить эффект, одни или несколько координат, которые Вы ввели, недействительны!");
this.put("fixed-edit-out-of-range", "&cНевозможно изменить эффект, Вы должны быть в &b%range% &cблоках от желаемой локации!");
this.put("fixed-edit-looking-too-far", "&cНевозможно изменить эффект, Вы стоите слишком далеко от блока, на который смотрите!");
this.put("fixed-edit-effect-invalid", "&cНевозможно изменить эффект, эффект под названием &b%effect% &cне существует!");
this.put("fixed-edit-effect-no-permission", "&cНевозможно создать эффект, у Вас нет права использовать эффект &b%effect%&c!");
this.put("fixed-edit-style-invalid", "&cНевозможно изменить эффект, стиль под названием &b%style% &cне существует!");
this.put("fixed-edit-style-no-permission", "&cНевозможно изменить эффект, у Вас нет права использовать стиль &b%style%&c!");
this.put("fixed-edit-style-non-fixable", "&cНевозможно изменить эффект, стиль &b%style% &cне может быть использован!");
this.put("fixed-edit-data-error", "&cНевозможно создать эффект, введённые данные неверны! Введите &b/pp data <Эффект>&c, чтобы найти правильный формат данных!");
this.put("fixed-edit-data-none", "&cНевозможно изменить эффект, эффект не запрашивает какие-либо данные!");
this.put("fixed-edit-success", "&aОбновлено эффектов под ID &b%id%&a - &b%prop%&a!");
this.put("#20", "Fixed Remove Messages");
this.put("fixed-remove-invalid", "&cНевозможно удалить эффект, у Вас нет эффекта под ID &b%id%&c!");
this.put("fixed-remove-no-args", "&cYou did not specify an ID to remove!");
this.put("fixed-remove-args-invalid", "&cНевозможно удалить, введённый ID должен состоять из чисел!");
this.put("fixed-remove-success", "&aВаш эффект под ID &b%id% &aбыл удалён!");
this.put("#21", "Fixed List Messages");
this.put("fixed-list-none", "&eУ Вас нет каких-либо эффектов!");
this.put("fixed-list-success", "&eУ Вас есть эффекты с этими ID: &b%ids%");
this.put("#22", "Fixed Info Messages");
this.put("fixed-info-invalid", "&cНевозможно получить информацию, у Вас нет эффекта под ID &b%id%&c!");
this.put("fixed-info-no-args", "&cВы не ввели ID, по которому нужно узнать информацию!");
this.put("fixed-info-invalid-args", "&cНевозможно получить информацию, введённый ID должен состоять из чисел!");
this.put("fixed-info-success", "&eID: &b%id% &eМир: &b%world% &eX: &b%x% &eY: &b%y% &eZ: &b%z% &eЭффект: &b%effect% &eСтиль: &b%style% &eДанные: &b%data%");
this.put("#23", "Fixed Clear Messages");
this.put("fixed-clear-no-permission", "&cУ Вас нет права, чтобы убрать ближайшие эффекты!");
this.put("fixed-clear-no-args", "&cВы не ввели радиус, на котором необходимо убрать эффекты!");
this.put("fixed-clear-invalid-args", "&cВведённый радиус недействителен, это должно быть целое число!");
this.put("fixed-clear-success", "&aУбрано эффектов - &b%amount%&a!");
this.put("#24", "Fixed Other Messages");
this.put("fixed-no-permission", "&cУ Вас нет права, чтобы использовать этот эффект!");
this.put("fixed-max-reached", "&cВы достигли максимального количества эффектов!");
this.put("fixed-invalid-command", "&cНедействительная команда для &b/pp fixed&c!");
this.put("#25", "Plugin Update Message");
this.put("update-available", "&eОбновление (&b%new%&e) доступно! Ваша версия - &bv%current%&e. https://www.spigotmc.org/resources/playerparticles.40261/");
this.put("#26", "GUI Messages");
this.put("gui-disabled", "&cАдминистратор отключил интерфейс!");
this.put("#27", "GUI Color Messages");
this.put("gui-color-icon-name", "&a");
this.put("gui-color-info", "&e");
this.put("gui-color-subtext", "&b");
this.put("gui-color-unavailable", "&c");
this.put("#28", "GUI Info Messages");
this.put("gui-commands-info", "Узнать подробнее о командах - &b/pp help");
this.put("gui-back-button", "Назад");
this.put("gui-next-page-button", "Следующая страница (%start%/%end%)");
this.put("gui-previous-page-button", "Предыдущая страница (%start%/%end%)");
this.put("gui-click-to-load", "Доступны %amount% частицы для загрузки:");
this.put("gui-shift-click-to-delete", "Shift+ЛКМ для удаления");
this.put("gui-particle-info", " - ID: &b%id% &eЭффект: &b%effect% &eСтиль: &b%style% &eДанные: &b%data%");
this.put("gui-playerparticles", "Выбор частиц");
this.put("gui-active-particles", "Активные частицы - &b%amount%");
this.put("gui-saved-groups", "Сохранённые группы - &b%amount%");
this.put("gui-fixed-effects", "Эффекты - &b%amount%");
this.put("#29", "GUI Edit Primary Messages");
this.put("gui-edit-primary-effect", "Изменить эффект");
this.put("gui-edit-primary-effect-description", "Изменение эффекта Ваших частиц");
this.put("gui-edit-primary-style", "Изменить стиль");
this.put("gui-edit-primary-style-missing-effect", "Для начала выберите эффект");
this.put("gui-edit-primary-style-description", "Изменение стиля Ваших частиц");
this.put("gui-edit-primary-data", "Изменить данные");
this.put("gui-edit-primary-data-missing-effect", "Для начала выберите эффект");
this.put("gui-edit-primary-data-unavailable", "Ваш эффект не использует какие-либо данные");
this.put("gui-edit-primary-data-description", "Изменение данных Ваших частиц");
this.put("#30", "GUI Manage Particles Messages");
this.put("gui-manage-your-particles", "Создать свой эффект");
this.put("gui-manage-your-particles-description", "Создание, изменение и удаление Ваших частиц");
this.put("gui-manage-your-groups", "Управление группами");
this.put("gui-manage-your-groups-description", "Создание, изменение и удаление Ваших групп");
this.put("#31", "GUI Load Messages");
this.put("gui-load-a-preset-group", "Установить группу");
this.put("gui-load-a-preset-group-description", "Установка готовой группы частиц");
this.put("#32", "GUI Save Messages");
this.put("gui-save-group", "Сохранить новую группу");
this.put("gui-save-group-description", "Нажмите, чтобы сохранить группу. Вам нужно будет ввести новое название группы в чат.");
this.put("gui-save-group-full", "Вы достигли максимального числа групп!");
this.put("gui-save-group-no-particles", "У Вас нет каких-либо активных частиц!");
this.put("gui-save-group-hotbar-message", "&eВведите &b1 &eслово в чат, которое будет названием группы. Введите &cотмена&e для отмены.");
this.put("#33", "GUI Reset Messages");
this.put("gui-reset-particles", "Удалить ваши частицы");
this.put("gui-reset-particles-description", "Убирает все Ваши активные частицы");
this.put("#34", "GUI Misc Messages");
this.put("gui-particle-name", "Частицы #%id%");
this.put("gui-click-to-edit-particle", "Нажмите, чтобы изменить эффект, стиль или данные частиц");
this.put("gui-editing-particle", "Изменение частиц #%id%");
this.put("#35", "GUI Edit Messages");
this.put("gui-edit-effect", "Изменить эффект");
this.put("gui-edit-effect-description", "Нажмите, чтобы изменить эффект частиц");
this.put("gui-edit-style", "Изменить стиль");
this.put("gui-edit-style-description", "Нажмите, чтобы изменить стиль частиц");
this.put("gui-edit-data", "Изменить данные");
this.put("gui-edit-data-description", "Нажмите, чтобы изменить данные частиц");
this.put("gui-edit-data-unavailable", "Эффект этих частиц не использует каких-либо данных");
this.put("gui-data-none", "пусто");
this.put("#36", "GUI Create Messages");
this.put("gui-create-particle", "Создать новые частицы");
this.put("gui-create-particle-description", "Создать новые частицы с эффектом, стилем и данными");
this.put("gui-create-particle-unavailable", "Вы достигли максимального числа частиц, которые можно создать");
this.put("#37", "GUI Select Messages");
this.put("gui-select-effect", "Выбор эффекта частиц");
this.put("gui-select-effect-description", "Выбрать эффект для частиц &b%effect%");
this.put("gui-select-style", "Выбор стиля частиц");
this.put("gui-select-style-description", "Выбрать стиль для частиц &b%style%");
this.put("gui-select-data", "Выбор данных частиц");
this.put("gui-select-data-description", "Выбрать данные для частиц &b%data%");
this.put("gui-select-data-note", "записка #%note%");
this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&cкрасный");
this.put("gui-edit-data-color-orange", "&6оранжевый");
this.put("gui-edit-data-color-yellow", "&eжелтый");
this.put("gui-edit-data-color-lime-green", "&aзеленый лайм");
this.put("gui-edit-data-color-green", "&2зеленый");
this.put("gui-edit-data-color-blue", "&1синий");
this.put("gui-edit-data-color-cyan", "&3циан");
this.put("gui-edit-data-color-light-blue", "&bсветло-синий");
this.put("gui-edit-data-color-purple", "&5фиолетовый");
this.put("gui-edit-data-color-magenta", "&dфуксин");
this.put("gui-edit-data-color-pink", "&dрозовый");
this.put("gui-edit-data-color-brown", "&6коричневый");
this.put("gui-edit-data-color-black", "&8черный");
this.put("gui-edit-data-color-gray", "&8серый");
this.put("gui-edit-data-color-light-gray", "&7светло-серый");
this.put("gui-edit-data-color-white", "&fбелый");
}};
}
}

View file

@ -0,0 +1,327 @@
package dev.esophose.playerparticles.locale;
import java.util.LinkedHashMap;
import java.util.Map;
public class SimplifiedChineseLocale implements Locale {
@Override
public String getLocaleName() {
return "zh_CN";
}
@Override
public String getTranslatorName() {
return "qsefthuopq";
}
@Override
public Map<String, String> getDefaultLocaleStrings() {
return new LinkedHashMap<String, String>() {{
this.put("#0", "Plugin Message Prefix");
this.put("prefix", "&7[&3PlayerParticles&7] ");
this.put("#1", "Command Description Messages");
this.put("command-error-no-effects", "&c你必须有权限使用特效才能使用这个指令!");
this.put("command-error-unknown", "&c未知的指令 请使用 &b/pp help &c查看指令列表。");
this.put("command-descriptions", "&e你可以使用以下指令:");
this.put("command-descriptions-usage", "&e/pp %cmd% %args%");
this.put("command-descriptions-help-1", "&7> &b/pp %cmd% &e- %desc%");
this.put("command-descriptions-help-2", "&7> &b/pp %cmd% %args% &e- %desc%");
this.put("command-descriptions-help-other", "&7> &b/ppo <player> <command> &e- 以玩家身份输入 /pp ");
this.put("command-description-add", "添加新的粒子特效");
this.put("command-description-data", "查看粒子特效使用的数据");
this.put("command-description-default", "主指令,默认打开菜单");
this.put("command-description-edit", "编辑粒子");
this.put("command-description-effects", "显示你可以使用的粒子效果");
this.put("command-description-fixed", "管理你的定点特效");
this.put("command-description-group", "管理你的特效组");
this.put("command-description-gui", "打开粒子特效编辑菜单");
this.put("command-description-help", "显示帮助... 就是这里");
this.put("command-description-info", "查看你使用的粒子特效的描述");
this.put("command-description-list", "你使用的粒子特效的id");
this.put("command-description-reload", "重载配置和语言文件");
this.put("command-description-remove", "删除一些粒子特效");
this.put("command-description-reset", "删除你身上所有特效");
this.put("command-description-styles", "显示你可以使用的粒子风格");
this.put("command-description-toggle", "开启或关闭粒子效果显示");
this.put("command-description-version", "显示插件版本和作者");
this.put("command-description-worlds", "查看禁用粒子特效的世界");
this.put("#2", "Fixed Particle Command Description Messages");
this.put("command-description-fixed-create", "&e/pp fixed create <<x> <y> <z>|<looking>> <特效名> <风格名> [数据名] - 创建新的定点特效");
this.put("command-description-fixed-edit", "&e/pp fixed edit <id> <特效名|风格名|数据名> <参数> - 根据ID编辑定点特效");
this.put("command-description-fixed-remove", "&e/pp fixed remove <ID> - 根据ID删除定点特效");
this.put("command-description-fixed-list", "&e/pp fixed list - 列出所有定点特效的ID");
this.put("command-description-fixed-info", "&e/pp fixed info <ID> - 获取定点特效的详细信息");
this.put("command-description-fixed-clear", "&e/pp fixed clear <半径> - 清空指定范围内的所有定点特效");
this.put("command-description-group-save", "&e/pp group save <组名> - 保存所有你使用的特效到新的组内");
this.put("command-description-group-load", "&e/pp group load <组名> - 加载所有你保存组内的特效");
this.put("command-description-group-remove", "&e/pp group remove <组名> - 删除一组你保存的特效");
this.put("command-description-group-list", "&e/pp group list <组名> - 列出所有你保存的特效组");
this.put("command-description-group-info", "&e/pp group info <组名> - 列出组内的特效信息");
this.put("#3", "ID Messages");
this.put("id-invalid", "&c你输入的ID无效 必须是正整数!");
this.put("id-unknown", "&c你没有ID为&b%id%&c的特效!");
this.put("#4", "Other Messages");
this.put("other-no-permission", "&c你没有权限对其他玩家使用PlayerParticles的指令!");
this.put("other-missing-args", "&c缺少参数。 &b/ppo <player> <command>");
this.put("other-unknown-player", "&c找不到玩家&b%player%&c。玩家必须在线。");
this.put("other-unknown-command", "&c指令&b/pp %cmd% &c不存在。");
this.put("other-success", "&e已为&b%player%&e执行指令 /pp 。 输出:");
this.put("#5", "Add Messages");
this.put("add-reached-max", "&c无法使用粒子效果你已达到上限:&b%amount%&c!");
this.put("add-particle-applied", "&a成功添加新的粒子特效 &b%effect%&a 风格: &b%style%&a数据 &b%data%&a!");
this.put("data-no-args", "&c该特效缺失参数! 指令用法: &b/pp data <effect>");
this.put("#6", "Edit Messages");
this.put("edit-invalid-property", "&c您输入的参数&b%prop%&c无效。 有效参数为: &beffect&c &bstyle&c &bdata");
this.put("edit-success-effect", "&aID为&b%id%&a的粒子的特效已更改为&b%effect%&a!");
this.put("edit-success-style", "&aID为&b%id%&a的粒子的风格已更改为&b%style%&a!");
this.put("edit-success-data", "&aID为&b%id%&a的粒子的数据已更改为&b%data%&a!");
this.put("#7", "Group Messages");
this.put("group-invalid", "&c名为&b%name%&c的粒子组不存在!");
this.put("group-no-permission", "&c你没有使用&b%group%&c的权限!");
this.put("group-preset-no-permission", "&c你没有使用预设粒子组&b%group%&c的权限!");
this.put("group-reserved", "&c该组名&b&c无法使用!");
this.put("group-no-name", "&c你没有输入组名! &b/pp %cmd% <组名>");
this.put("group-save-reached-max", "&c无法保存粒子组你已达到可使用粒子组的上限!");
this.put("group-save-no-particles", "&c无法保存粒子组你没有添加任何粒子!");
this.put("group-save-success", "&a你当前使用的粒子特效已成功保存入粒子组&b%name%&a内!");
this.put("group-save-success-overwrite", "&a已将你当前使用的粒子特效加入到粒子组&b%name%&a内!");
this.put("group-load-success", "&a已将&b%amount%&a个粒子特效加入你已保存的粒子组&b%name%&a内!");
this.put("group-load-preset-success", "&a已使用&b%name%&a预设组内的&b%amount%&a个粒子特效!");
this.put("group-remove-preset", "&c你无法删除预设粒子组!");
this.put("group-remove-success", "&a成功删除粒子组&b%name%&a!");
this.put("group-info-header", "&e粒子组&b%group%&e拥有以下粒子特效:");
this.put("group-list-none", "&e你没有保存任何粒子组!");
this.put("group-list-output", "&e你已成功保存以下粒子组: &b%info%");
this.put("group-list-presets", "&e可使用以下预设粒子组: &b%info%");
this.put("#8", "Reload Messages");
this.put("reload-success", "&a插件已重载!");
this.put("reload-no-permission", "&c你没有重载插件配置的指令!");
this.put("#9", "Remove Messages");
this.put("remove-no-args", "&c你没有指定要删除的ID! &b/pp remove <ID>");
this.put("remove-id-success", "&a你已成功删除ID为&b%id%&a的粒子特效!");
this.put("remove-effect-success", "&a成功删除&b%amount%&a个&b%effect%&a特效的粒子!");
this.put("remove-effect-none", "&c你没有使用特效&b%effect%&c的粒子!");
this.put("remove-style-success", "&已成功删除&b%amount%&a个使用了风格&b%style%&a的粒子!");
this.put("remove-style-none", "&c你没有已使用风格&b%style%&c的粒子!");
this.put("remove-unknown", "&c名为&b%name%&c的特效或风格不存在!");
this.put("#10", "List Messages");
this.put("list-none", "&e你没有任何激活的特效!");
this.put("list-you-have", "&e你使用了以下粒子特效:");
this.put("list-output", "&eID: &b%id% &e特效: &b%effect% &e风格: &b%style% &e数据: &b%data%");
this.put("#11", "Toggle Messages");
this.put("toggle-on", "&e粒子特效已&a开启&e!");
this.put("toggle-off", "&e粒子特效已&c关闭&e!");
this.put("#12", "Color Messages");
this.put("rainbow", "&c彩&6虹");
this.put("random", "随机");
this.put("#13", "Effect Messages");
this.put("effect-no-permission", "&c你没有使用特效&b%effect%的权限&c!");
this.put("effect-invalid", "&c特效&b%effect% &c不存在! 请输入&b/pp effects &c查看你可以使用的特效。");
this.put("effect-list", "&e你可以使用以下特效: &b%effects%");
this.put("effect-list-empty", "&c你没有使用任何特效的权限!");
this.put("#14", "Style Messages");
this.put("style-no-permission", "&c你没有权限使用&b%style%这一风格&c!");
this.put("style-event-spawning-info", "&e提醒: 风格&b%style%&e基于事件生成。");
this.put("style-invalid", "&c风格&b%style%&c不存在! 请输入&b/pp styles &c查看你可以使用的风格。");
this.put("style-list", "&e你可以使用以下风格: &b%styles%");
this.put("#15", "Data Messages");
this.put("data-usage-none", "&e粒子特效&b%effect%&e不使用任何数据!");
this.put("data-usage-block", "&e粒子特效&b%effect%&e需要设置&b方块&e数据! &b格式: <方块ID>");
this.put("data-usage-item", "&e粒子特效&b%effect%&e需要设置&b物品&e数据! &b格式: <物品ID>");
this.put("data-usage-color", "&e粒子特效&b%effect%&e需要设置&b颜色&e数据! &b格式: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-usage-note", "&e粒子特效&b%effect%&e需要设置&b音符&e数据! &b格式: <0-24>|<rainbow>|<random>");
this.put("data-invalid-block", "&c你输入的&b方块&c数据 无效! &b格式: <方块ID>");
this.put("data-invalid-item", "&c你输入的&b物品&c数据 无效! &b格式: <物品ID>");
this.put("data-invalid-color", "&c你输入的&b颜色&c数据 无效! &b格式: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-invalid-note", "&c你输入的&b音符&c数据 无效! &b格式: <0-24>|<rainbow>|<random>");
this.put("data-invalid-material-not-item", "&c你输入的&b物品&c材料名 &b%material%&c不是一件物品!");
this.put("data-invalid-material-not-block", "&c你输入的&b方块&c材料名&b%material%&c不是一个方块!");
this.put("data-invalid-material-item", "&c你输入的&b物品&c材料&b%material%不存在!");
this.put("data-invalid-material-block", "&c你输入的&b方块&c材料&b%material%!");
this.put("#16", "World Messages");
this.put("disabled-worlds", "&e这些世界禁用粒子特效: &b%worlds%");
this.put("disabled-worlds-none", "&e所有世界都禁用粒子特效。");
this.put("#17", "Reset Message");
this.put("reset-success", "&a已删除&b%amount%个&a激活的粒子特效!");
this.put("#18", "Fixed Create Messages");
this.put("fixed-create-missing-args", "&c无法创建定点特效 缺少 &b%amount% &c必要参数!");
this.put("fixed-create-invalid-coords", "&c无法创建定点特效 你输入的坐标无效!");
this.put("fixed-create-out-of-range", "&c无法创建定点特效你必须在目标地点&b%range%&c格内!");
this.put("fixed-create-looking-too-far", "&c无法创建定点特效 你离目标方块太远了!");
this.put("fixed-create-effect-invalid", "&c无法创建定点特效名为&b%effect%&c的特效不存在!");
this.put("fixed-create-effect-no-permission", "&c无法创建定点特效 你没有权限使用特效&b%effect%&c!");
this.put("fixed-create-style-invalid", "&c无法创建定点特效 名为&b%style%&c的风格不存在!");
this.put("fixed-create-style-no-permission", "&c无法创建定点特效 你没有权限使用风格&b%style%&c!");
this.put("fixed-create-style-non-fixable", "&c无法创建定点特效 风格&b%style%&c无法用于定点特效!");
this.put("fixed-create-data-error", "&c无法创建定点特效 你所给出的数据有误! 请输入 &b/pp data <effect> &c查看正确的数据格式!");
this.put("fixed-create-success", "&a成功创建定点特效!");
this.put("#19", "Fixed Edit Messages");
this.put("fixed-edit-missing-args", "&c无法编辑定点特效 缺失参数!");
this.put("fixed-edit-invalid-id", "&c无法编辑定点特效 ID无效或不存在!");
this.put("fixed-edit-invalid-property", "&c无法编辑定点特效 参数无效! 只有&blocation&c、&beffect&c、&bstyle&c和&bdata &c才有效。");
this.put("fixed-edit-invalid-coords", "&c无法编辑定点特效 你输入的一个或多个坐标无效!");
this.put("fixed-edit-out-of-range", "&c无法编辑定点特效你必须在目标地点&b%range%&c格内才能进行编辑!");
this.put("fixed-edit-looking-too-far", "&c无法编辑定点特效 你离目标地点太远了!");
this.put("fixed-edit-effect-invalid", "&c无法编辑定点特效 名为&b%effect%&c的特效不存在!");
this.put("fixed-edit-effect-no-permission", "&c无法编辑定点特效 你没有权限使用特效&b%effect%&c!");
this.put("fixed-edit-style-invalid", "&c无法编辑定点特效 名为&b%style%&c的风格不存在!");
this.put("fixed-edit-style-no-permission", "&c无法编辑定点特效 你没有权限使用风格&b%style%&c!");
this.put("fixed-edit-style-non-fixable", "&c无法编辑定点特效 风格 &b%style% &c无法用于定点特效!");
this.put("fixed-edit-data-error", "&c无法编辑定点特效 数据有误! 请输入 &b/pp data <effect> &cto 来获取正确的数据格式!");
this.put("fixed-edit-data-none", "&c无法编辑定点特效 该特效无需数据!");
this.put("fixed-edit-success", "&a已更新&b%prop%&a个ID为&b%id%&a的定点特效!");
this.put("#20", "Fixed Remove Messages");
this.put("fixed-remove-invalid", "&c无法删除定点特效 你没有ID为&b%id%&c的定点特效!");
this.put("fixed-remove-no-args", "&c你没有指定要删除的ID!");
this.put("fixed-remove-args-invalid", "&c无法删除ID必须是数字!");
this.put("fixed-remove-success", "&a已删除ID为&b%id%&a的定点特效!");
this.put("#21", "Fixed List Messages");
this.put("fixed-list-none", "&e你没有定点特效!");
this.put("fixed-list-success", "&e你的定点特效ID为: &b%ids%");
this.put("#22", "Fixed Info Messages");
this.put("fixed-info-invalid", "&c无法获取信息 你没有ID为&b%id%&c的定点特效!");
this.put("fixed-info-no-args", "&c你未指定ID!");
this.put("fixed-info-invalid-args", "&c无法获取信息 ID必须是数字!");
this.put("fixed-info-success", "&eID: &b%id% &e世界: &b%world% &eX: &b%x% &eY: &b%y% &eZ: &b%z% &e特效: &b%effect% &e风格: &b%style% &e数据: &b%data%");
this.put("#23", "Fixed Clear Messages");
this.put("fixed-clear-no-permission", "&c你没有清空附近定点特效的权限!");
this.put("fixed-clear-no-args", "&c你没有给出清空定点特效的范围!");
this.put("fixed-clear-invalid-args", "&c你输入的范围无效范围必须是正整数!");
this.put("fixed-clear-success", "&a已清除&b%amount%&a个&b%range%&a格内的定点特效!");
this.put("#24", "Fixed Other Messages");
this.put("fixed-no-permission", "&c你没有使用定点特效的权限!");
this.put("fixed-max-reached", "&c你已达到可使用定点特效的数量上限!");
this.put("fixed-invalid-command", "&c你输入了无效的子指令!");
this.put("#25", "Plugin Update Message");
this.put("update-available", "&e有新版本更新(&b%new%&e)!你使用的版本为&bv%current%&e。 https://songoda.com/marketplace/product/32");
this.put("#26", "GUI Messages");
this.put("gui-disabled", "&c服务器管理员已关闭菜单!");
this.put("#27", "GUI Color Messages");
this.put("gui-color-icon-name", "&a");
this.put("gui-color-info", "&e");
this.put("gui-color-subtext", "&b");
this.put("gui-color-unavailable", "&c");
this.put("#28", "GUI Info Messages");
this.put("gui-commands-info", "商人 &b/pp help 查看指令帮助");
this.put("gui-back-button", "返回");
this.put("gui-next-page-button", "下一页 (%start%/%end%)");
this.put("gui-previous-page-button", "上一页 (%start%/%end%)");
this.put("gui-click-to-load", "点击加载%amount% 个粒子特效:");
this.put("gui-shift-click-to-delete", "Shift+点击 删除");
this.put("gui-particle-info", " - ID: &b%id% &e特效: &b%effect% &e风格: &b%style% &e数据: &b%data%");
this.put("gui-playerparticles", "粒子特效");
this.put("gui-active-particles", "激活的粒子: &b%amount%");
this.put("gui-saved-groups", "已保存的粒子组: &b%amount%");
this.put("gui-fixed-effects", "定点特效: &b%amount%");
this.put("#29", "GUI Edit Primary Messages");
this.put("gui-edit-primary-effect", "编辑之前使用的粒子的特效");
this.put("gui-edit-primary-effect-description", "编辑之前使用的粒子的特效");
this.put("gui-edit-primary-style", "编辑之前使用粒子的风格");
this.put("gui-edit-primary-style-missing-effect", "你必须先选择一个特效");
this.put("gui-edit-primary-style-description", "编辑之前使用粒子的风格");
this.put("gui-edit-primary-data", "编辑之前使用粒子的数据");
this.put("gui-edit-primary-data-missing-effect", "你必须先选择一个特效");
this.put("gui-edit-primary-data-unavailable", "你之前使用的特效没有使用任何数据");
this.put("gui-edit-primary-data-description", "编辑之前使用的特效的数据");
this.put("#30", "GUI Manage Particles Messages");
this.put("gui-manage-your-particles", "管理你的粒子特效");
this.put("gui-manage-your-particles-description", "创建、编辑和删除你的粒子特效");
this.put("gui-manage-your-groups", "管理你的特效组");
this.put("gui-manage-your-groups-description", "创建、删除和加载你的粒子组");
this.put("#31", "GUI Load Messages");
this.put("gui-load-a-preset-group", "加载预设粒子组");
this.put("gui-load-a-preset-group-description", "加载预设粒子组");
this.put("#32", "GUI Save Messages");
this.put("gui-save-group", "保存新的粒子组");
this.put("gui-save-group-description", "点击保存为新的粒子组。你需要\n在聊天框内输入名称。");
this.put("gui-save-group-full", "你已达到粒子组上限");
this.put("gui-save-group-no-particles", "你没有使用粒子特效");
this.put("gui-save-group-hotbar-message", "&e请在聊天框内输入&b1 &e新的粒子组名。 输入 &ccancel&e 取消。 (剩余&b%seconds%&e秒)");
this.put("#33", "GUI Reset Messages");
this.put("gui-reset-particles", "重置你的粒子特效");
this.put("gui-reset-particles-description", "删除你激活的所有粒子特效");
this.put("#34", "GUI Misc Messages");
this.put("gui-particle-name", "粒子 #%id%");
this.put("gui-click-to-edit-particle", "点击编辑粒子特效、风格或数据");
this.put("gui-editing-particle", "编辑粒子#%id%中");
this.put("#35", "GUI Edit Messages");
this.put("gui-edit-effect", "编辑特效");
this.put("gui-edit-effect-description", "点击编辑粒子特效");
this.put("gui-edit-style", "编辑风格");
this.put("gui-edit-style-description", "点击编辑粒子风格");
this.put("gui-edit-data", "编辑数据");
this.put("gui-edit-data-description", "点击编辑粒子数据");
this.put("gui-edit-data-unavailable", "这个粒子特效不使用数据");
this.put("gui-data-none", "");
this.put("#36", "GUI Create Messages");
this.put("gui-create-particle", "创建新的粒子特效");
this.put("gui-create-particle-description", "创建新的粒子特效");
this.put("gui-create-particle-unavailable", "你不能创建更多的粒子特效");
this.put("#37", "GUI Select Messages");
this.put("gui-select-effect", "选择粒子特效");
this.put("gui-select-effect-description", "将粒子特效设置为 &b%effect%");
this.put("gui-select-style", "选择粒子风格");
this.put("gui-select-style-description", "将粒子风格设置为 &b%style%");
this.put("gui-select-data", "选择粒子数据");
this.put("gui-select-data-description", "将粒子数据设置为&b%data%");
this.put("gui-select-data-note", "note #%note%");
this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&c红色");
this.put("gui-edit-data-color-orange", "&6橙黄");
this.put("gui-edit-data-color-yellow", "&e黄色");
this.put("gui-edit-data-color-lime-green", "&a淡绿");
this.put("gui-edit-data-color-green", "&2绿色");
this.put("gui-edit-data-color-blue", "&1蓝色");
this.put("gui-edit-data-color-cyan", "&3青色");
this.put("gui-edit-data-color-light-blue", "&b淡蓝色");
this.put("gui-edit-data-color-purple", "&5紫色");
this.put("gui-edit-data-color-magenta", "&d洋红");
this.put("gui-edit-data-color-pink", "&d粉色");
this.put("gui-edit-data-color-brown", "&6棕色");
this.put("gui-edit-data-color-black", "&8黑色");
this.put("gui-edit-data-color-gray", "&8灰色");
this.put("gui-edit-data-color-light-gray", "&7淡灰");
this.put("gui-edit-data-color-white", "&f白色");
}};
}
}

View file

@ -0,0 +1,326 @@
package dev.esophose.playerparticles.locale;
import java.util.LinkedHashMap;
import java.util.Map;
public class VietnameseLocale implements Locale {
@Override
public String getLocaleName() {
return "vi_VN";
}
@Override
public String getTranslatorName() {
return "DUYSONGLOI";
}
@Override
public Map<String, String> getDefaultLocaleStrings() {
return new LinkedHashMap<String, String>() {{
this.put("#0", "Plugin Message Prefix");
this.put("prefix", "&7[&3PlayerParticles&7] ");
this.put("#1", "Command Description Messages");
this.put("command-error-no-effects", "&cBạn phải có quyền sử dụng hiệu ứng để làm điều này!");
this.put("command-error-unknown", "&cLệnh không đúng, &6/pp help &cđể xem danh sách các câu lệnh.");
this.put("command-descriptions", "&eCác lệnh có sẵn:");
this.put("command-descriptions-usage", "&e/pp %cmd% %args%");
this.put("command-descriptions-help-1", "&7> &b/pp %cmd% &e- %desc%");
this.put("command-descriptions-help-2", "&7> &b/pp %cmd% %args% &e- %desc%");
this.put("command-descriptions-help-other", "&7> &b/ppo <player> <command> &e- Chạy lệnh /pp bằng player");
this.put("command-description-add", "Thêm một hiệu ứng mới");
this.put("command-description-data", "Kiểm tra laoị dữ liệu mà hiệu ứng sử dụng");
this.put("command-description-default", "Đã mở GUI hiệu ứng");
this.put("command-description-edit", "Chỉnh sửa một hiệu ứng");
this.put("command-description-effects", "Hiển thị danh sách hiệu ứng mà bạn có thể sử dụng");
this.put("command-description-fixed", "Quản lí hiệu ứng cố định của bạn");
this.put("command-description-group", "Quản lí Group của bạn");
this.put("command-description-gui", "Hiển thị GUI để dễ dàng chỉnh sửa hiệu ứng hơn");
this.put("command-description-help", "Đang hiển thị Help Menu...");
this.put("command-description-info", "Nhận mô tả về hiệu ứng đang hoạt động của bạn");
this.put("command-description-list", "Danh sách IDs các hiệu ứng đang hoạt động của bạn");
this.put("command-description-reload", "Tải lại config và lang file");
this.put("command-description-remove", "Xóa một vài hiệu ứng");
this.put("command-description-reset", "Xóa tất cả hiệu ứng đang hoạt động của bạn");
this.put("command-description-styles", "Hiển thị danh sách Style bạn có thể sử dụng");
this.put("command-description-toggle", "Bật/Tắt tàng hình hiệu ứng");
this.put("command-description-version", "Hiển thị phiên bản và tác giả của plugins");
this.put("command-description-worlds", "Hiển thị danh sách thế giới bị cấm hiệu ứng");
this.put("#2", "Fixed Particle Command Description Messages");
this.put("command-description-fixed-create", "&e/pp fixed create <<x> <y> <z>|<looking>> <effect> <style> [data] - Tạo mới một hiệu ứng cố định");
this.put("command-description-fixed-edit", "&e/pp fixed edit <id> <effect|style|data> <args> - Chỉnh sửa hiệu ứng cố định bằng IDs của nó");
this.put("command-description-fixed-remove", "&e/pp fixed remove <ID> - Xóa hiệu ứng cố định");
this.put("command-description-fixed-list", "&e/pp fixed list - Danh sách các hiệu ứng cố định dưới dạng IDs");
this.put("command-description-fixed-info", "&e/pp fixed info <ID> - Hiển thị thông tin về hiệu ứng cố định");
this.put("command-description-fixed-clear", "&e/pp fixed clear <radius> - Xóa toàn bộ hiệu ứng trong khu vực bán kính");
this.put("command-description-group-save", "&e/pp group save <name> - Lưu toàn bộ hiêu ứng hoạt động vào Group mới");
this.put("command-description-group-load", "&e/pp group load <name> - Load toàn bộ hiệu ứng hoạt động trong group");
this.put("command-description-group-remove", "&e/pp group remove <name> - Xóa một group bạn đã lưu");
this.put("command-description-group-list", "&e/pp group list <name> - Hiển thị danh sách Group hiệu ứng bạn đã lưu");
this.put("command-description-group-info", "&e/pp group info <name> - Hiển thị danh sách hiệu ứng bạn đang lưu trong group");
this.put("#3", "ID Messages");
this.put("id-invalid", "&cID bạn nhập không tồn tại, nó phải là một số nguyên dương!");
this.put("id-unknown", "&cBạn không có hiệu ứng nào được áp dụng với ID &b%id%&c!");
this.put("#4", "Other Messages");
this.put("other-no-permission", "&cbạn không có quyền để thi hành lệnh của plugins cho người chơi khác!");
this.put("other-missing-args", "&cBạn đã quên một vài đối số. &b/ppo <player> <command>");
this.put("other-unknown-player", "&cKhông thể tìm thấy người chơi &b%player% &c. Người chơi được chỉ định phải Online.");
this.put("other-unknown-command", "&cLệnh &b/pp %cmd% &ckhông tồn tại.");
this.put("other-success", "&eThi hành lệnh /pp command cho &b%player%&e. Output:");
this.put("#5", "Add Messages");
this.put("add-reached-max", "&Không thể áp dụng hiệu ứng, Bạn đã đạt tới số lượng giới hạn của&b%amount% &cđược cho phép!");
this.put("add-particle-applied", "&aHạt (Particle) mới đã được áp dụng với effect &b%effect%&a, style &b%style%&a, và data &b%data%&a!");
this.put("data-no-args", "&cĐã quên một đối số cho effect! Lệnh đúng: &b/pp data <effect>");
this.put("#6", "Edit Messages");
this.put("edit-invalid-property", "&cMột property không hợp lệ &b%prop% &cwđã được cung cấp. properties hợp lệ: &beffect&c, &bstyle&c, &bdata");
this.put("edit-success-effect", "&aHạt hiệu ứng của bạn với ID &b%id% &ađã thanh đổi Hiệu ứng thành &b%effect%&a!");
this.put("edit-success-style", "&aHạt hiệu ứng của bạn với ID &b%id% &ađã thanh đổi Kiểu hiệu ứng thành &b%style%&a!");
this.put("edit-success-data", "&aHạt hiệu ứng của bạn với ID &b%id% &ađã thanh đổi Dữ liệu thành &b%data%&a!");
this.put("#7", "Group Messages");
this.put("group-invalid", "&cMột Group đã lưu hoặc Preset Group không được tìm thấy với tên &b%name%&c!");
this.put("group-no-permission", "&cBạn không có quyền for 1 effect, style để sử dụng nhóm sẵn &b%group%&c!");
this.put("group-preset-no-permission", "&cBạn không có quyền for 1 effect, style để sử dụng nhóm cài sẵn &b%group%&c!");
this.put("group-reserved", "&cGroup tên &bactive &ckhông thể được sử dụng!");
this.put("group-no-name", "&cBạn đã không cung cấp tên group! &b/pp %cmd% <groupName>");
this.put("group-save-reached-max", "&cKhông thể lưu Group , bạn đã đạt giới hạn số lượng group có thể tạo!");
this.put("group-save-no-particles", "&cKhông thể lưu group, bạn không có bất kì *hạt được được áp dụng nào!");
this.put("group-save-success", "&aHạt hiệu ứng của bạn đã được lưu dưới tên của group &b%name%&a!");
this.put("group-save-success-overwrite", "&aGroup tên&b%name% &ađã được cập nhật với hạt hiệu ứng hiện tại của bạn!");
this.put("group-load-success", "&aĐã áp dụng &b%amount% &ahạt hiệu ứng từ group được lưu với tên &b%name%&a!");
this.put("group-load-preset-success", "&aĐã áp dụng &b%amount% &ahạt hiệu ứng tự presen group với tên &b%name%&a!");
this.put("group-remove-preset", "&cBạn không thể xóa một preset group!");
this.put("group-remove-success", "&aĐã xóa một Nhóm hạt hiệu ứng với tên &b%name%&a!");
this.put("group-info-header", "&eGroup &b%group% &eđang có những hạt hiệu ứng sau:");
this.put("group-list-none", "&eBạn không có bất kì nhóm hạt hiệuứng nào được lưu!");
this.put("group-list-output", "&eBạn đã lưu các Group sau: &b%info%");
this.put("group-list-presets", "&eCác preset group có sẵn: &b%info%");
this.put("#8", "Reload Messages");
this.put("reload-success", "&aĐã tải lại plugins!");
this.put("reload-no-permission", "&cBạn không có quyền để tải lại plugins!");
this.put("#9", "Remove Messages");
this.put("remove-no-args", "&cBạn không chỉ định IDs để xóa! &b/pp remove <ID>");
this.put("remove-id-success", "&aHạt hiệu ứng của bạ với IDs &b%id% &ađã bị xóa!");
this.put("remove-effect-success", "&aĐã xóa &b%amount% &ahạt hiệu ứng của bạn với hiệu ứng &b%effect%&a!");
this.put("remove-effect-none", "&cBạn không có bất kì Hạt hiệu ứng nào để áp dụng hiệu ứng &b%effect%&c!");
this.put("remove-style-success", "&aĐã xóa &b%amount% &aHạt hiệu ứng của bạn với style &b%style%&a!");
this.put("remove-style-none", "&cBạn không có bất kì Hạt hiệu ứng nào để áp dụng style &b%style%&c!");
this.put("remove-unknown", "&cEffect hoặc Style với tên &b%name% &ckhông tồn tại!");
this.put("#10", "List Messages");
this.put("list-none", "&eBạn không có bất kì Hạt hiệu ứng hoạt động nào!");
this.put("list-you-have", "&eCác hạt hiệu ứng bạn đã áp dụng:");
this.put("list-output", "&eID: &b%id% &eEffect: &b%effect% &eStyle: &b%style% &eData: &b%data%");
this.put("#11", "Toggle Messages");
this.put("toggle-on", "&eHạt hiệu ứng : &aON&e!");
this.put("toggle-off", "&eHạt hiệu ứng : &cOFF&e!");
this.put("#12", "Color Messages");
this.put("rainbow", "&cR&6a&ei&an&bb&9o&dw");
this.put("random", "Ngẫu nhiên");
this.put("#13", "Effect Messages");
this.put("effect-no-permission", "&cBạn không có quyền để sử dụng Hiệu ứng &b%effect% &c!");
this.put("effect-invalid", "&cHiệu ứng &b%effect% &ckhông tồn tại! Sử dụng &b/pp effects &cđể hiển thị danh sách hiệu ứng bạn có thể dùng.");
this.put("effect-list", "&eBạn có thể sử dụng các hiệu ứng sau: &b%effects%");
this.put("effect-list-empty", "&cBạn không có quyền để sử dụng bất kì hiệu ứng nào!");
this.put("#14", "Style Messages");
this.put("style-no-permission", "&cbạn không có quyền để sử dụng Kiểu hiệu ứng &b%style% &c!");
this.put("style-event-spawning-info", "&eNhắc nhở: Kiểu hiệu ứng &b%style% &esinh ra dựa trên sự kiện nhất định được xảy ra.");
this.put("style-invalid", "&cKiểu hiệu ứng &b%style% &ckhông tồn tại! Use &b/pp styles &cđể hiển thị danh sách Kiểu hiệu ứng bạn có thể dùng.");
this.put("style-list", "&eBạn có thể sử dụng các Kiểu hiệu ứng sau: &b%styles%");
this.put("#15", "Data Messages");
this.put("data-usage-none", "&eHiệu ứng &b%effect% &ekhông sử dụng bất kì Dữ liệu nào!");
this.put("data-usage-block", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bblock ! &bĐịnh dạng: <blockName>");
this.put("data-usage-item", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bitem! &bĐịnh dạng: <itemName>");
this.put("data-usage-color", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bcolor! &bĐịnh dạng: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-usage-note", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bnote! &bĐịnh dạng: <0-24>|<rainbow>|<random>");
this.put("data-invalid-block", "&cDữ liệu &bblock &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <blockName>");
this.put("data-invalid-item", "&cDữ liệu &bitem &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <itemName>");
this.put("data-invalid-color", "&cDữ liệu &bcolor &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
this.put("data-invalid-note", "&cDữ liệu &bnote &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <0-24>|<rainbow>|<random>");
this.put("data-invalid-material-not-item", "&cDữ liệu &bitem &c: Vật phẩm &b%material% &cbạn đã nhập không phải là một vật phẩm!");
this.put("data-invalid-material-not-block", "&cDữ liệu &bblock &c: Vật phẩm &b%material% &cbạn đã nhập không phải là một khối!");
this.put("data-invalid-material-item", "&cDữ liệu &bitem &c: Vật phẩm &b%material% bạn đã nhập không tồn tại!");
this.put("data-invalid-material-block", "&cDữ liệu &bblock &c: Vật phẩm &b%material% bạn đã nhập không tồn tại!");
this.put("#16", "World Messages");
this.put("disabled-worlds", "&eCác Hạt hiệu ứng bị cấm tại thế giới này: &b%worlds%");
this.put("disabled-worlds-none", "&eKhông có thể giới nào cấm Hạt hiệu ứng.");
this.put("#17", "Reset Message");
this.put("reset-success", "&aĐã xóa &b%amount% &aHạt hiệu ứng hoạt động!");
this.put("#18", "Fixed Create Messages");
this.put("fixed-create-missing-args", "&cKhông thể tạo Hiệu ứng cố định, bạn đã quên &b%amount% &cđối số yêu cầu!");
this.put("fixed-create-invalid-coords", "&cKhông thể tạo Hiệu ứng cố định, một hoặc nhiều tọa độ bạn đã nhập không hợp lệ!");
this.put("fixed-create-out-of-range", "&cKhông thể tạo Hiệu ứng cố định, bạn phải ở trong bán kính &b%range% &ckhối tại vị trí mong muốn của bạn!");
this.put("fixed-create-looking-too-far", "&cKhông thể tạo Hiệu ứng cố định, bạn đang đứng quá xa khối bạn nhìn!");
this.put("fixed-create-effect-invalid", "&cKhông thể tạo Hiệu ứng cố định, Hiệu ứng với tên &b%effect% &ckhông tồn tại!");
this.put("fixed-create-effect-no-permission", "&cKhông thể tạo Hiệu ứng cố định, bạn không có quyền để sử dụng Hiệu ứng &b%effect%&c!");
this.put("fixed-create-style-invalid", "&cKhông thể tạo Hiệu ứng cố định, Kiểu hiệu ứng với tên &b%style% &ckhông tồn tại!");
this.put("fixed-create-style-no-permission", "&cKhông thể tạo Hiệu ứng cố định, bạn không có quyền để sử dụng Kiểu hiệu ứng &b%style%&c!");
this.put("fixed-create-style-non-fixable", "&cKhông thể tạo Hiệu ứng cố định, Kiểu hiệu ứng &b%style% &ckhông thể được sử dụng trong Hiệu ứng cố định!");
this.put("fixed-create-data-error", "&cKhông thể tạo Hiệu ứng cố định, Dữ liệu bạn đã cung cấp không đúng! Sử dụng &b/pp data <effect> &cđể xem định dạng dữ liệu đúng!");
this.put("fixed-create-success", "&aHiệu ứng cố định của bạn đã được tạo!");
this.put("#19", "Fixed Edit Messages");
this.put("fixed-edit-missing-args", "&cKhông thể điều chỉnh Hiệu ứng cố định, bạn chưa nhập một vài đối số!");
this.put("fixed-edit-invalid-id", "&cKhông thể điều chỉnh Hiệu ứng cố định, IDs bạn chỉ định không hợp lệ hoặc không tồn tại!");
this.put("fixed-edit-invalid-property", "&cKhông thể điều chỉnh Hiệu ứng cố định, một property không hợp lệ đã được chỉ định! Chỉ có &blocation&c, &beffect&c, &bstyle&c, và &bdata &là hợp lệ.");
this.put("fixed-edit-invalid-coords", "&cKhông thể điều chỉnh Hiệu ứng cố định, một hoặc nhiều tọa độ bạn đã nhập không hợp lệ!");
this.put("fixed-edit-out-of-range", "&cKhông thể điều chỉnh Hiệu ứng cố định, Bạn phải ở trong bán kính &b%range% &ckhối tại vị trí mong muốn của bạn!");
this.put("fixed-edit-looking-too-far", "&cKhông thể điều chỉnh Hiệu ứng cố định, Bạn đang đứng quá xa so với khối bạn nhìn!");
this.put("fixed-edit-effect-invalid", "&cKhông thể điều chỉnh Hiệu ứng cố định, một Hiệu ứng với tên &b%effect% &ckhông tồn tại!");
this.put("fixed-edit-effect-no-permission", "&cKhông thể điều chỉnh Hiệu ứng cố định, bạn không có quyền để sử dụng hiệu ứng &b%effect%&c!");
this.put("fixed-edit-style-invalid", "&cKhông thể điều chỉnh Hiệu ứng cố định, Kiểu hiệu ứng &b%style% &ckhông tồn tại!");
this.put("fixed-edit-style-no-permission", "&cKhông thể điều chỉnh Hiệu ứng cố định, bạn không có quyền để sử dụng kiểu hiệu ứng &b%style%&c!");
this.put("fixed-edit-style-non-fixable", "&cKhông thể điều chỉnh Hiệu ứng cố định, Kiểu hiệu ứng &b%style% &ckhông thể được sử dụng trong Hiệu ứng cố định!");
this.put("fixed-edit-data-error", "&cKhông thể điều chỉnh Hiệu ứng cố định, Dữ liệu bạn đã cung cấp không đúng! Sử dụng &b/pp data <effect> &cđể xem định dạng dữ liệu đúng!");
this.put("fixed-edit-data-none", "&cKhông thể điều chỉnh Hiệu ứng cố định, Hiệu ứng không yêu cầu bất cứ Dữ liệu nào!");
this.put("fixed-edit-success", "&aĐã cập nhật &b%prop% &acủa Hiệu ứng cố định với một ID của &b%id%&a!");
this.put("#20", "Fixed Remove Messages");
this.put("fixed-remove-invalid", "&cKhông thể xóa Hiệu ứng cố định, bạn không có hiệu ứng cố định nào với ID &b%id%&c!");
this.put("fixed-remove-no-args", "&cbạn không chỉ định ID để xóa!");
this.put("fixed-remove-args-invalid", "&cKhông thể xóa, ID được chỉ định phải là số");
this.put("fixed-remove-success", "&aHiệu ứng cố định của bạn với ID &b%id% &ađã bị xóa!");
this.put("#21", "Fixed List Messages");
this.put("fixed-list-none", "&eBạn không có bất kì Hiệu ứng cố định nào!");
this.put("fixed-list-success", "&eBạn có các Hiệu ứng cố định với IDs: &b%ids%");
this.put("#22", "Fixed Info Messages");
this.put("fixed-info-invalid", "&cKhông thể lấy thông tin, bạn không có bất kì Hiệu ứng cố định nào với ID &b%id%&c!");
this.put("fixed-info-no-args", "&cBạn không chỉ định ID để hiển thị thông tin Hiệu ứng có định!");
this.put("fixed-info-invalid-args", "&cKhông thể hiển thị Hiệu ứng cố định, ID được chỉ định phải là một con số!");
this.put("fixed-info-success", "&eID: &b%id% &eWorld: &b%world% &eX: &b%x% &eY: &b%y% &eZ: &b%z% &eEffect: &b%effect% &eStyle: &b%style% &eData: &b%data%");
this.put("#23", "Fixed Clear Messages");
this.put("fixed-clear-no-permission", "&cBạn không có quyền để làm điều này!");
this.put("fixed-clear-no-args", "&cBạn không cung cấp bán kính để xóa các Hiệu ứng cố định!");
this.put("fixed-clear-invalid-args", "&cbán kính được cung cấp không hợp lệ, nó phải là một số nguyên dương!");
this.put("fixed-clear-success", "&aĐã xóa &b%amount% &aHiệu ứng cố định trong bán kính &b%range% &akhối từ vị trí của bạn!");
this.put("#24", "Fixed Other Messages");
this.put("fixed-no-permission", "&cBạn không có quyền để làm điều này!");
this.put("fixed-max-reached", "&cBạn đã đạt tới giới hạn số Hiệu ứng cố định có thể sử dụng!");
this.put("fixed-invalid-command", "&cLệnh phụ không hợp lệ, &b/pp fixed&c!");
this.put("#25", "Plugin Update Message");
this.put("update-available", "&eĐã có bản cập nhật (&b%new%&e)! bạn đang sử dụng &bv%current%&e. https://www.spigotmc.org/resources/playerparticles.40261/");
this.put("#26", "GUI Messages");
this.put("gui-disabled", "&cAmdinistrator đã cấm GUI!");
this.put("#27", "GUI Color Messages");
this.put("gui-color-icon-name", "&a");
this.put("gui-color-info", "&e");
this.put("gui-color-subtext", "&b");
this.put("gui-color-unavailable", "&c");
this.put("#28", "GUI Info Messages");
this.put("gui-commands-info", "Hiển thị thêm các lệnh bằng cách gõ &b/pp help");
this.put("gui-back-button", "Quay trở về");
this.put("gui-next-page-button", "Trang tiếp theo (%start%/%end%)");
this.put("gui-previous-page-button", "Trang trước (%start%/%end%)");
this.put("gui-click-to-load", "Nhấn để tải %amount% Hạt hiệu ứng sau:");
this.put("gui-shift-click-to-delete", "Shift Click để xóa");
this.put("gui-particle-info", " - ID: &b%id% &eEffect: &b%effect% &eStyle: &b%style% &eData: &b%data%");
this.put("gui-playerparticles", "HIỆU ỨNG");
this.put("gui-active-particles", "Hạt hiệu ứng đang hoạt động: &b%amount%");
this.put("gui-saved-groups", "Groups đã lưu: &b%amount%");
this.put("gui-fixed-effects", "Hiệu ứng cố định: &b%amount%");
this.put("#29", "GUI Edit Primary Messages");
this.put("gui-edit-primary-effect", "Chỉnh sửa hiệu ứng chính (primary effect)");
this.put("gui-edit-primary-effect-description", "Chỉnh sửa Hiệu ứng Hạt hiệu ứng chính của bạn");
this.put("gui-edit-primary-style", "Chỉnh sửa Kiểu hiệu ứng chính");
this.put("gui-edit-primary-style-missing-effect", "Bạn cần chọn Hiệu ứng trước");
this.put("gui-edit-primary-style-description", "Chỉnh sửa Kiểu hiệu ứng trong Hạt hiệu ứng chính của bạn");
this.put("gui-edit-primary-data", "Chỉnh sửa Dữ liệu chính");
this.put("gui-edit-primary-data-missing-effect", "Bạn cần chọn Hiệu ứng trước");
this.put("gui-edit-primary-data-unavailable", "Hiệu ứng chính của bạn không cần sử dụng bất kì Dữ liệu nào");
this.put("gui-edit-primary-data-description", "Chỉnh sửa Dữ liệu trong Hạt hiệu ứng chính của bạn");
this.put("#30", "GUI Manage Particles Messages");
this.put("gui-manage-your-particles", "Quản lí Hạt hiệu ứng của bạn");
this.put("gui-manage-your-particles-description", "Tạo, chỉnh sửa, và xóa Hạt hiệu ứng của bạn");
this.put("gui-manage-your-groups", "Quản lí Group của bạn");
this.put("gui-manage-your-groups-description", "Tạo, xóa, và tải Group Hạt hiệu ứng của bạn");
this.put("#31", "GUI Load Messages");
this.put("gui-load-a-preset-group", "Tải một Preset Group");
this.put("gui-load-a-preset-group-description", "Tải Group Hạt hiệu ứng có sẵn");
this.put("#32", "GUI Save Messages");
this.put("gui-save-group", "Lưu group mới");
this.put("gui-save-group-description", "Nhấn để lưu Group mới. Bạn sẽ nhận được lời nhắc nhập tên Group ở chat.");
this.put("gui-save-group-full", "Bạn đã đạt đến giới hạn số lượng group có thể tạo");
this.put("gui-save-group-no-particles", "Bạn không có bất kì Hhạt hiệu ứng nào được áp dụng");
this.put("gui-save-group-hotbar-message", "&eNhập &b1 &etên group trong chat. Nhập &ccancel&e để hủy. (&b%seconds%&es left)");
this.put("#33", "GUI Reset Messages");
this.put("gui-reset-particles", "Làm mới Hạt hiệu ứng của bạn");
this.put("gui-reset-particles-description", "Xóa tất cả Hạt hiệu ứng đang hoạt động của bạn");
this.put("#34", "GUI Misc Messages");
this.put("gui-particle-name", "Hạt hiệu ứng #%id%");
this.put("gui-click-to-edit-particle", "Nhấn để chỉnh sửa Hiệu ứng, Kiểu hiệu ứng, hoặc Dữ liệu của Hạt hiệu ứng này");
this.put("gui-editing-particle", "Đang chỉnh sửa Hạt hiệu ứng #%id%");
this.put("#35", "GUI Edit Messages");
this.put("gui-edit-effect", "Chỉnh sửa Hiệu ứng");
this.put("gui-edit-effect-description", "Nhấn để chỉnh sửa Hiệu ứng của Hạt hiệu ứng này");
this.put("gui-edit-style", "Chỉnh sửa Kiểu hiệu ứng");
this.put("gui-edit-style-description", "Nhấn để chỉnh sửa Kiểu hiệu ứng của Kiểu hiệu ứng này");
this.put("gui-edit-data", "Chỉnh sửa Dữ liệu");
this.put("gui-edit-data-description", "Nhấn để chỉnh sửa Dữ liệu của Kiểu hiệu ứng này");
this.put("gui-edit-data-unavailable", "Hiệu ứng của Hạt hiệu ứng này không cần sử dụng bất kì Dữ liệu nào");
this.put("gui-data-none", "không ai");
this.put("#36", "GUI Create Messages");
this.put("gui-create-particle", "Tạo mới một Hạt hiệu ứng");
this.put("gui-create-particle-description", "Tạo mới một Hạt hiệu ứng với Hiệu ứng, Kiểu hiệu ứng, và Dữ liệu");
this.put("gui-create-particle-unavailable", "bạn đã đạt giới hạn số lượng Hạt hiệu ứng có thể tạo");
this.put("#37", "GUI Select Messages");
this.put("gui-select-effect", "Chọn Hạt hiệu ứng");
this.put("gui-select-effect-description", "Thiết lập hiệu ứng của Hạt thành &b%effect%");
this.put("gui-select-style", "Chọn Kiểu hiệu ứng của Hạt");
this.put("gui-select-style-description", "Thiết lập Kiểu hiệu ứng của Hạt thành &b%style%");
this.put("gui-select-data", "Chọn Dữ liệu của Hạt");
this.put("gui-select-data-description", "Thiết lập DỮ liệu của Hạt thành &b%data%");
this.put("gui-select-data-note", "note #%note%");
this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&cĐỏ mạnh mẽ");
this.put("gui-edit-data-color-orange", "&6Cam dịu dàng");
this.put("gui-edit-data-color-yellow", "&eVàng yêu thương");
this.put("gui-edit-data-color-lime-green", "&aXanh nhẹ nhàng");
this.put("gui-edit-data-color-green", "&2Xanh đen tối");
this.put("gui-edit-data-color-blue", "&1Xanh lam");
this.put("gui-edit-data-color-cyan", "&3Lục lam");
this.put("gui-edit-data-color-light-blue", "&bXanh Da trời");
this.put("gui-edit-data-color-purple", "&5Tím cá tính");
this.put("gui-edit-data-color-magenta", "&dĐỏ tươi");
this.put("gui-edit-data-color-pink", "&dHồng nam tính");
this.put("gui-edit-data-color-brown", "&6Nâu thâm thâm");
this.put("gui-edit-data-color-black", "&8Đen như tâm hồn");
this.put("gui-edit-data-color-gray", "&8Xám");
this.put("gui-edit-data-color-light-gray", "&7Xám nhạt");
this.put("gui-edit-data-color-white", "&fTrắng tinh khiết");
}};
}
}

View file

@ -0,0 +1,208 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.command.AddCommandModule;
import dev.esophose.playerparticles.command.CommandModule;
import dev.esophose.playerparticles.command.CommandModuleSecondary;
import dev.esophose.playerparticles.command.DataCommandModule;
import dev.esophose.playerparticles.command.DefaultCommandModule;
import dev.esophose.playerparticles.command.EditCommandModule;
import dev.esophose.playerparticles.command.EffectsCommandModule;
import dev.esophose.playerparticles.command.FixedCommandModule;
import dev.esophose.playerparticles.command.GUICommandModule;
import dev.esophose.playerparticles.command.GroupCommandModule;
import dev.esophose.playerparticles.command.HelpCommandModule;
import dev.esophose.playerparticles.command.ListCommandModule;
import dev.esophose.playerparticles.command.OtherCommandModule;
import dev.esophose.playerparticles.command.ReloadCommandModule;
import dev.esophose.playerparticles.command.RemoveCommandModule;
import dev.esophose.playerparticles.command.ResetCommandModule;
import dev.esophose.playerparticles.command.StylesCommandModule;
import dev.esophose.playerparticles.command.ToggleCommandModule;
import dev.esophose.playerparticles.command.VersionCommandModule;
import dev.esophose.playerparticles.command.WorldsCommandModule;
import dev.esophose.playerparticles.particles.OtherPPlayer;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
public class CommandManager extends Manager implements CommandExecutor, TabCompleter {
/**
* A list of all commands
*/
private List<CommandModule> commands;
private CommandModuleSecondary ppoCommand;
public CommandManager(PlayerParticles playerParticles) {
super(playerParticles);
PluginCommand pp = this.playerParticles.getCommand("pp");
PluginCommand ppo = this.playerParticles.getCommand("ppo");
if (pp == null || ppo == null) {
Bukkit.getPluginManager().disablePlugin(this.playerParticles);
return;
}
pp.setTabCompleter(this);
pp.setExecutor(this);
ppo.setTabCompleter(this);
ppo.setExecutor(this);
}
@Override
public void reload() {
this.commands = new ArrayList<CommandModule>() {{
this.add(new AddCommandModule());
this.add(new DataCommandModule());
this.add(new DefaultCommandModule());
this.add(new EditCommandModule());
this.add(new EffectsCommandModule());
this.add(new FixedCommandModule());
this.add(new GroupCommandModule());
this.add(new GUICommandModule());
this.add(new HelpCommandModule());
this.add(new ListCommandModule());
this.add(new ReloadCommandModule());
this.add(new RemoveCommandModule());
this.add(new ResetCommandModule());
this.add(new StylesCommandModule());
this.add(new ToggleCommandModule());
this.add(new VersionCommandModule());
this.add(new WorldsCommandModule());
}};
this.ppoCommand = new OtherCommandModule();
}
@Override
public void disable() {
}
/**
* Finds a matching CommandModule by its name
*
* @param commandName The command name
* @return The found CommandModule, otherwise null
*/
public CommandModule findMatchingCommand(String commandName) {
for (CommandModule commandModule : this.commands)
if (commandModule.getName().equalsIgnoreCase(commandName))
return commandModule;
return null;
}
/**
* Get a list of all available commands
*
* @return A List of all CommandModules registered
*/
public List<CommandModule> getCommands() {
return this.commands;
}
/**
* Get all available command names
*
* @return All available command names
*/
public List<String> getCommandNames() {
List<String> commandNames = new ArrayList<>();
for (CommandModule cmd : this.commands)
commandNames.add(cmd.getName());
return commandNames;
}
/**
* Called when a player executes a PlayerParticles command
* Checks what PlayerParticles command it is and calls the corresponding module
*
* @param sender Who executed the command
* @param cmd The command
* @param label The command label
* @param args The arguments following the command
* @return true
*/
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (cmd.getName().equalsIgnoreCase("pp")) {
String commandName = args.length > 0 ? args[0] : "";
CommandModule commandModule = this.findMatchingCommand(commandName);
if (commandModule == null) {
sender.sendMessage(localeManager.getLocaleMessage("command-error-unknown"));
return true;
}
String[] cmdArgs = args.length > 1 ? Arrays.copyOfRange(args, 1, args.length) : new String[0];
if (!commandModule.canConsoleExecute()) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Error: This command can only be executed by a player.");
return true;
}
} else {
commandModule.onCommandExecute(new OtherPPlayer(sender), cmdArgs);
return true;
}
Player p = (Player) sender;
this.playerParticles.getManager(DataManager.class).getPPlayer(p.getUniqueId(), (pplayer) -> {
if (commandModule.requiresEffects() && PlayerParticles.getInstance().getManager(PermissionManager.class).getEffectNamesUserHasPermissionFor(p).isEmpty()) {
localeManager.sendMessage(pplayer, "command-error-no-effects");
} else {
commandModule.onCommandExecute(pplayer, cmdArgs);
}
});
} else if (cmd.getName().equalsIgnoreCase("ppo")) {
this.ppoCommand.onCommandExecute(sender, args);
}
return true;
}
/**
* Activated when a user pushes tab in chat prefixed with /pp
*
* @param sender The sender that hit tab, should always be a player
* @param cmd The command the player is executing
* @param alias The possible alias for the command
* @param args All arguments following the command
* @return A list of commands available to the sender
*/
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
if (cmd.getName().equalsIgnoreCase("pp")) {
if (!(sender instanceof Player)) return new ArrayList<>();
PPlayer pplayer = this.playerParticles.getManager(DataManager.class).getPPlayer(((Player) sender).getUniqueId());
if (pplayer == null) return new ArrayList<>();
if (args.length <= 1) {
CommandModule commandModule = this.findMatchingCommand(""); // Get the default command module
return commandModule.onTabComplete(pplayer, args);
} else {
CommandModule commandModule = this.findMatchingCommand(args[0]);
if (commandModule != null) {
String[] cmdArgs = Arrays.copyOfRange(args, 1, args.length);
return commandModule.onTabComplete(pplayer, cmdArgs);
}
}
} else if (cmd.getName().equalsIgnoreCase("ppo")) {
return this.ppoCommand.onTabComplete(sender, args);
}
return new ArrayList<>();
}
}

View file

@ -0,0 +1,428 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.util.ParticleUtils;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.bukkit.Material;
public class ConfigurationManager extends Manager {
private static final String[] HEADER = new String[] {
" _________ __ __________ __ __ __ _________",
" \\______ \\ | _____ ___ __ __________\\______ \\_____ ________/ |_|__| ____ | | ____ ______ \\______ \\",
" | ___/ | \\__ \\< | |/ __ \\_ __ \\ ___/\\__ \\\\_ __ \\ __\\ |/ ___\\| | _/ __ \\ / ___/ / /",
" | | | |__/ __ \\\\___ \\ ___/| | \\/ | / __ \\| | \\/| | | \\ \\___| |_\\ ___/ \\___ \\ / /",
" |____| |____(____ / ____|\\___ >__| |____| (____ /__| |__| |__|\\___ >____/\\___ >____ > /____/",
" \\/\\/ \\/ \\/ \\/ \\/ \\/"
};
public enum Setting {
CHECK_UPDATES("check-updates", true, "Check for new versions of the plugin"),
SEND_METRICS("send-metrics", true, "If metrics should be sent to bStats", "I would appreciate it if you left this enabled, it helps me get statistics on how the plugin is used"),
LOCALE("locale", "en_US", "The locale to use in the /locale folder"),
MESSAGES_ENABLED("message-enabled", true, "If you're using other plugins to execute commands you may wish to turn off messages"),
USE_MESSAGE_PREFIX("use-message-prefix", true, "Whether or not to use the message-prefix field when displaying messages"),
GUI_ENABLED("gui-enabled", true, "If the command /pp gui is enabled", "Disable this if you have your own custom GUI through another plugin"),
GUI_PRESETS_ONLY("gui-presets-only", false, "If true, only the preset groups will be available in the GUI", "Permissions to open the GUI will change to only open if the user has any preset groups available"),
GUI_CLOSE_AFTER_GROUP_SELECTED("gui-close-after-group-selected", true, "If true, the GUI will close after selecting a group (either saved or preset)"),
GUI_BUTTON_SOUND("gui-button-sound", true, "If clicking a GUI button should make a noise"),
TOGGLE_ON_MOVE("toggle-on-move", false, "If true, styles will not display while the player is moving", "They will instead have the effect displayed at their feet", "Note: Not all styles abide by this rule, but most will"),
TOGGLE_ON_MOVE_DELAY("toggle-on-move-delay", 9, "The time (in ticks) a player has to be standing still before they are considered to be stopped", "This setting has no effect if toggle-on-move is set to false", "The value must be a positive whole number"),
DISABLED_WORLDS("disabled-worlds", Collections.singletonList("disabled_world_name"), "A list of worlds that the plugin is disabled in"),
MAX_PARTICLES("max-particles", 3, "The maximum number of particles a player can apply at once", "The GUI will only display up to 21, don't set this any higher than that"),
MAX_GROUPS("max-groups", 10, "The maximum number of groups a player can have saved", "The GUI will only display up to 21, don't set this any higher than that"),
MAX_FIXED_EFFECTS("max-fixed-effects", 5, "Max fixed effects per player"),
MAX_FIXED_EFFECT_CREATION_DISTANCE("max-fixed-effect-creation-distance", 32, "Max fixed effect creation distance", "Determines how far away a player may create a fixed effect from themselves", "This measurement is in blocks", "Set to 0 for infinite distance"),
TICKS_PER_PARTICLE("ticks-per-particle", 1, "How many ticks to wait before spawning more particles", "Increasing this value may cause less lag (if there was any), but will decrease prettiness", "Only use whole numbers greater than or equal to 1", "Going over 3 will likely look terrible"),
PARTICLE_RENDER_RANGE_PLAYER("particle-render-range-player", 48, "From how many blocks away should a player be able to see the particles from another player?"),
PARTICLE_RENDER_RANGE_FIXED_EFFECT("particle-render-range-fixed-effect", 32, "From how many blocks away should a player be able to see the particles from a fixed effect?"),
RAINBOW_CYCLE_SPEED("rainbow-cycle-speed", 2, "How many out of 360 hue ticks to move per game tick", "Higher values make the rainbow cycle faster", "Note: Must be a positive whole number"),
MYSQL_SETTINGS("mysql-settings", null, "Settings for if you want to use MySQL for data management"),
MYSQL_ENABLED("mysql-settings.enabled", false, "Enable MySQL", "If false, SQLite will be used instead"),
MYSQL_HOSTNAME("mysql-settings.hostname", "", "MySQL Database Hostname"),
MYSQL_PORT("mysql-settings.port", 3306, "MySQL Database Port"),
MYSQL_DATABASE_NAME("mysql-settings.database-name", "", "MySQL Database Name"),
MYSQL_USER_NAME("mysql-settings.user-name", "", "MySQL Database User Name"),
MYSQL_USER_PASSWORD("mysql-settings.user-password", "", "MySQL Database User Password"),
MYSQL_USE_SSL("mysql-settings.use-ssl", false, "If the database connection should use SSL", "You should enable this if your database supports SSL"),
GUI_ICON("gui-icon", null, "=================================================================== #",
" GUI ICON SETTINGS #",
"This configuration option allows you to change any of the GUI #",
"icons to whatever block/item you want. #",
" #",
"Important Notes: #",
"* If any of the block/item names are invalid the icon in the GUI #",
" will be the barrier icon to show that it failed to load. #",
"* Do NOT change the particle/style name #",
"* You MUST use the Spigot-given name for it to work. You can see #",
" all the Spigot-given names at the link below: #",
" https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html #",
"* If two icons are listed, the second one is used for below MC 1.13 #",
"=================================================================== #"),
GUI_ICON_MISC("gui-icon.misc", null),
GUI_ICON_MISC_PARTICLES("gui-icon.misc.particles", Collections.singletonList("BLAZE_POWDER")),
GUI_ICON_MISC_GROUPS("gui-icon.misc.groups", Collections.singletonList("CHEST")),
GUI_ICON_MISC_PRESET_GROUPS("gui-icon.misc.preset_groups", Collections.singletonList("ENDER_CHEST")),
GUI_ICON_MISC_BACK("gui-icon.misc.back", Collections.singletonList("ARROW")),
GUI_ICON_MISC_NEXT_PAGE("gui-icon.misc.next_page", Collections.singletonList("PAPER")),
GUI_ICON_MISC_PREVIOUS_PAGE("gui-icon.misc.previous_page", Collections.singletonList("PAPER")),
GUI_ICON_MISC_CREATE("gui-icon.misc.create", Arrays.asList("WRITABLE_BOOK", "BOOK_AND_QUILL")),
GUI_ICON_MISC_EDIT_EFFECT("gui-icon.misc.edit_effect", Arrays.asList("FIREWORK_ROCKET", "FIREWORK")),
GUI_ICON_MISC_EDIT_STYLE("gui-icon.misc.edit_style", Collections.singletonList("NETHER_STAR")),
GUI_ICON_MISC_EDIT_DATA("gui-icon.misc.edit_data", Collections.singletonList("BOOK")),
GUI_ICON_MISC_RESET("gui-icon.misc.reset", Collections.singletonList("BARRIER")),
GUI_ICON_EFFECT("gui-icon.effect", null),
GUI_ICON_EFFECT_AMBIENT_ENTITY_EFFECT("gui-icon.effect.ambient_entity_effect", Collections.singletonList("BEACON")),
GUI_ICON_EFFECT_ANGRY_VILLAGER("gui-icon.effect.angry_villager", Collections.singletonList("IRON_DOOR")),
GUI_ICON_EFFECT_BARRIER("gui-icon.effect.barrier", Collections.singletonList("BARRIER")),
GUI_ICON_EFFECT_BLOCK("gui-icon.effect.block", Collections.singletonList("STONE")),
GUI_ICON_EFFECT_BUBBLE("gui-icon.effect.bubble", Arrays.asList("BUBBLE_CORAL", "GLASS")),
GUI_ICON_EFFECT_BUBBLE_COLUMN_UP("gui-icon.effect.bubble_column_up", Collections.singletonList("MAGMA_BLOCK")),
GUI_ICON_EFFECT_BUBBLE_POP("gui-icon.effect.bubble_pop", Collections.singletonList("BUBBLE_CORAL_FAN")),
GUI_ICON_EFFECT_CAMPFIRE_COSY_SMOKE("gui-icon.effect.campfire_cosy_smoke", Collections.singletonList("CAMPFIRE")),
GUI_ICON_EFFECT_CAMPFIRE_SIGNAL_SMOKE("gui-icon.effect.campfire_signal_smoke", Collections.singletonList("REDSTONE_TORCH")),
GUI_ICON_EFFECT_CLOUD("gui-icon.effect.cloud", Arrays.asList("WHITE_WOOL", "WOOL")),
GUI_ICON_EFFECT_COMPOSTER("gui-icon.effect.composter", Collections.singletonList("COMPOSTER")),
GUI_ICON_EFFECT_CRIT("gui-icon.effect.crit", Collections.singletonList("IRON_SWORD")),
GUI_ICON_EFFECT_CURRENT_DOWN("gui-icon.effect.current_down", Collections.singletonList("SOUL_SAND")),
GUI_ICON_EFFECT_DAMAGE_INDICATOR("gui-icon.effect.damage_indicator", Collections.singletonList("BOW")),
GUI_ICON_EFFECT_DOLPHIN("gui-icon.effect.dolphin", Collections.singletonList("DOLPHIN_SPAWN_EGG")),
GUI_ICON_EFFECT_DRAGON_BREATH("gui-icon.effect.dragon_breath", Arrays.asList("DRAGON_BREATH", "DRAGONS_BREATH")),
GUI_ICON_EFFECT_DRIPPING_HONEY("gui-icon.effect.dripping_honey", Collections.singletonList("BEE_NEST")),
GUI_ICON_EFFECT_DRIPPING_LAVA("gui-icon.effect.dripping_lava", Collections.singletonList("LAVA_BUCKET")),
GUI_ICON_EFFECT_DRIPPING_WATER("gui-icon.effect.dripping_water", Collections.singletonList("WATER_BUCKET")),
GUI_ICON_EFFECT_DUST("gui-icon.effect.dust", Collections.singletonList("REDSTONE")),
GUI_ICON_EFFECT_ENCHANT("gui-icon.effect.enchant", Arrays.asList("ENCHANTING_TABLE", "ENCHANTMENT_TABLE")),
GUI_ICON_EFFECT_ENCHANTED_HIT("gui-icon.effect.enchanted_hit", Collections.singletonList("DIAMOND_SWORD")),
GUI_ICON_EFFECT_END_ROD("gui-icon.effect.end_rod", Collections.singletonList("END_ROD")),
GUI_ICON_EFFECT_ENTITY_EFFECT("gui-icon.effect.entity_effect", Collections.singletonList("GLOWSTONE_DUST")),
GUI_ICON_EFFECT_EXPLOSION("gui-icon.effect.explosion", Arrays.asList("FIRE_CHARGE", "FIREBALL")),
GUI_ICON_EFFECT_EXPLOSION_EMITTER("gui-icon.effect.explosion_emitter", Collections.singletonList("TNT")),
GUI_ICON_EFFECT_FALLING_DUST("gui-icon.effect.falling_dust", Collections.singletonList("SAND")),
GUI_ICON_EFFECT_FALLING_HONEY("gui-icon.effect.falling_honey", Collections.singletonList("HONEY_BOTTLE")),
GUI_ICON_EFFECT_FALLING_LAVA("gui-icon.effect.falling_lava", Collections.singletonList("RED_DYE")),
GUI_ICON_EFFECT_FALLING_NECTAR("gui-icon.effect.falling_nectar", Collections.singletonList("HONEYCOMB")),
GUI_ICON_EFFECT_FALLING_WATER("gui-icon.effect.falling_water", Collections.singletonList("BLUE_DYE")),
GUI_ICON_EFFECT_FIREWORK("gui-icon.effect.firework", Arrays.asList("FIREWORK_ROCKET", "FIREWORK")),
GUI_ICON_EFFECT_FISHING("gui-icon.effect.fishing", Collections.singletonList("FISHING_ROD")),
GUI_ICON_EFFECT_FLAME("gui-icon.effect.flame", Collections.singletonList("BLAZE_POWDER")),
GUI_ICON_EFFECT_FOOTSTEP("gui-icon.effect.footstep", Collections.singletonList("GRASS")),
GUI_ICON_EFFECT_HAPPY_VILLAGER("gui-icon.effect.happy_villager", Arrays.asList("DARK_OAK_DOOR", "WOOD_DOOR")),
GUI_ICON_EFFECT_HEART("gui-icon.effect.heart", Arrays.asList("POPPY", "RED_ROSE")),
GUI_ICON_EFFECT_INSTANT_EFFECT("gui-icon.effect.instant_effect", Arrays.asList("SPLASH_POTION", "POTION")),
GUI_ICON_EFFECT_ITEM("gui-icon.effect.item", Collections.singletonList("ITEM_FRAME")),
GUI_ICON_EFFECT_ITEM_SLIME("gui-icon.effect.item_slime", Collections.singletonList("SLIME_BALL")),
GUI_ICON_EFFECT_ITEM_SNOWBALL("gui-icon.effect.item_snowball", Collections.singletonList("SNOWBALL")),
GUI_ICON_EFFECT_LARGE_SMOKE("gui-icon.effect.large_smoke", Arrays.asList("COBWEB", "WEB")),
GUI_ICON_EFFECT_LANDING_HONEY("gui-icon.effect.landing_honey", Collections.singletonList("HONEY_BLOCK")),
GUI_ICON_EFFECT_LANDING_LAVA("gui-icon.effect.landing_lava", Collections.singletonList("ORANGE_DYE")),
GUI_ICON_EFFECT_LAVA("gui-icon.effect.lava", Collections.singletonList("MAGMA_CREAM")),
GUI_ICON_EFFECT_MYCELIUM("gui-icon.effect.mycelium", Arrays.asList("MYCELIUM", "MYCEL")),
GUI_ICON_EFFECT_NAUTILUS("gui-icon.effect.nautilus", Collections.singletonList("HEART_OF_THE_SEA")),
GUI_ICON_EFFECT_NOTE("gui-icon.effect.note", Collections.singletonList("NOTE_BLOCK")),
GUI_ICON_EFFECT_POOF("gui-icon.effect.poof", Arrays.asList("FIREWORK_STAR", "FIREWORK_CHARGE")),
GUI_ICON_EFFECT_PORTAL("gui-icon.effect.portal", Collections.singletonList("OBSIDIAN")),
GUI_ICON_EFFECT_RAIN("gui-icon.effect.rain", Arrays.asList("PUFFERFISH_BUCKET", "LAPIS_BLOCK")),
GUI_ICON_EFFECT_SMOKE("gui-icon.effect.smoke", Collections.singletonList("TORCH")),
GUI_ICON_EFFECT_SNEEZE("gui-icon.effect.sneeze", Collections.singletonList("BAMBOO")),
GUI_ICON_EFFECT_SPELL("gui-icon.effect.spell", Arrays.asList("POTION", "GLASS_BOTTLE")),
GUI_ICON_EFFECT_SPIT("gui-icon.effect.spit", Arrays.asList("LLAMA_SPAWN_EGG", "PUMPKIN_SEEDS")),
GUI_ICON_EFFECT_SPLASH("gui-icon.effect.splash", Arrays.asList("SALMON", "FISH")),
GUI_ICON_EFFECT_SQUID_INK("gui-icon.effect.squid_ink", Collections.singletonList("INK_SAC")),
GUI_ICON_EFFECT_SWEEP_ATTACK("gui-icon.effect.sweep_attack", Arrays.asList("GOLDEN_SWORD", "GOLD_SWORD")),
GUI_ICON_EFFECT_TOTEM_OF_UNDYING("gui-icon.effect.totem_of_undying", Collections.singletonList("TOTEM")),
GUI_ICON_EFFECT_UNDERWATER("gui-icon.effect.underwater", Collections.singletonList("TURTLE_HELMET")),
GUI_ICON_EFFECT_WITCH("gui-icon.effect.witch", Collections.singletonList("CAULDRON")),
GUI_ICON_STYLE("gui-icon.style", null),
GUI_ICON_STYLE_ARROWS("gui-icon.style.arrows", Collections.singletonList("BOW")),
GUI_ICON_STYLE_BATMAN("gui-icon.style.batman", Arrays.asList("BAT_SPAWN_EGG", "COAL")),
GUI_ICON_STYLE_BEAM("gui-icon.style.beam", Collections.singletonList("POWERED_RAIL")),
GUI_ICON_STYLE_BLOCKBREAK("gui-icon.style.blockbreak", Collections.singletonList("IRON_PICKAXE")),
GUI_ICON_STYLE_BLOCKPLACE("gui-icon.style.blockplace", Arrays.asList("OAK_PLANKS", "WOOD")),
GUI_ICON_STYLE_CELEBRATION("gui-icon.style.celebration", Arrays.asList("FIREWORK_ROCKET", "FIREWORK")),
GUI_ICON_STYLE_CHAINS("gui-icon.style.chains", Collections.singletonList("TRIPWIRE_HOOK")),
GUI_ICON_STYLE_COMPANION("gui-icon.style.companion", Collections.singletonList("NAME_TAG")),
GUI_ICON_STYLE_CUBE("gui-icon.style.cube", Collections.singletonList("STONE")),
GUI_ICON_STYLE_FEET("gui-icon.style.feet", Collections.singletonList("GRASS")),
GUI_ICON_STYLE_HALO("gui-icon.style.halo", Arrays.asList("END_PORTAL_FRAME", "ENDER_PORTAL_FRAME")),
GUI_ICON_STYLE_HURT("gui-icon.style.hurt", Collections.singletonList("CACTUS")),
GUI_ICON_STYLE_INVOCATION("gui-icon.style.invocation", Arrays.asList("ENDER_EYE", "EYE_OF_ENDER")),
GUI_ICON_STYLE_MOVE("gui-icon.style.move", Arrays.asList("PISTON", "PISTON_BASE")),
GUI_ICON_STYLE_NORMAL("gui-icon.style.normal", Collections.singletonList("DIRT")),
GUI_ICON_STYLE_ORBIT("gui-icon.style.orbit", Arrays.asList("ENCHANTING_TABLE", "ENCHANTMENT_TABLE")),
GUI_ICON_STYLE_OVERHEAD("gui-icon.style.overhead", Collections.singletonList("GLOWSTONE")),
GUI_ICON_STYLE_POINT("gui-icon.style.point", Collections.singletonList("STONE_BUTTON")),
GUI_ICON_STYLE_POPPER("gui-icon.style.popper", Arrays.asList("POPPED_CHORUS_FRUIT", "CHORUS_FRUIT_POPPED")),
GUI_ICON_STYLE_PULSE("gui-icon.style.pulse", Arrays.asList("REDSTONE_TORCH", "REDSTONE_TORCH_ON")),
GUI_ICON_STYLE_QUADHELIX("gui-icon.style.quadhelix", Arrays.asList("NAUTILUS_SHELL", "ACTIVATOR_RAIL")),
GUI_ICON_STYLE_RINGS("gui-icon.style.rings", Collections.singletonList("LEAD")),
GUI_ICON_STYLE_SPHERE("gui-icon.style.sphere", Arrays.asList("HEART_OF_THE_SEA", "SNOWBALL")),
GUI_ICON_STYLE_SPIN("gui-icon.style.spin", Collections.singletonList("BEACON")),
GUI_ICON_STYLE_SPIRAL("gui-icon.style.spiral", Collections.singletonList("HOPPER")),
GUI_ICON_STYLE_SWORDS("gui-icon.style.swords", Collections.singletonList("IRON_SWORD")),
GUI_ICON_STYLE_THICK("gui-icon.style.thick", Arrays.asList("COBWEB", "WEB")),
GUI_ICON_STYLE_TWINS("gui-icon.style.twins", Arrays.asList("OAK_FENCE", "FENCE")),
GUI_ICON_STYLE_VORTEX("gui-icon.style.vortex", Collections.singletonList("GLOWSTONE_DUST")),
GUI_ICON_STYLE_WHIRL("gui-icon.style.whirl", Collections.singletonList("FEATHER")),
GUI_ICON_STYLE_WHIRLWIND("gui-icon.style.whirlwind", Collections.singletonList("STRING")),
GUI_ICON_STYLE_WINGS("gui-icon.style.wings", Collections.singletonList("ELYTRA"));
private final String key;
private final Object defaultValue;
private final String[] comments;
private Object value = null;
Setting(String key, Object defaultValue, String... comments) {
this.key = key;
this.defaultValue = defaultValue;
this.comments = comments != null ? comments : new String[0];
}
/**
* Gets the setting as a boolean
*
* @return The setting as a boolean
*/
public boolean getBoolean() {
this.loadValue();
return (boolean) this.value;
}
/**
* @return the setting as an int
*/
public int getInt() {
this.loadValue();
return (int) this.getNumber();
}
/**
* @return the setting as a long
*/
public long getLong() {
this.loadValue();
return (long) this.getNumber();
}
/**
* @return the setting as a double
*/
public double getDouble() {
this.loadValue();
return this.getNumber();
}
/**
* @return the setting as a String
*/
public String getString() {
this.loadValue();
return (String) this.value;
}
private double getNumber() {
if (this.value instanceof Integer) {
return (int) this.value;
} else if (this.value instanceof Short) {
return (short) this.value;
} else if (this.value instanceof Byte) {
return (byte) this.value;
} else if (this.value instanceof Float) {
return (float) this.value;
}
return (double) this.value;
}
/**
* @return the setting as a string list
*/
@SuppressWarnings("unchecked")
public List<String> getStringList() {
this.loadValue();
return (List<String>) this.value;
}
public void setIfNotExists(CommentedFileConfiguration fileConfiguration) {
this.loadValue();
if (fileConfiguration.get(this.key) == null) {
List<String> comments = Stream.of(this.comments).collect(Collectors.toList());
if (!(this.defaultValue instanceof List) && this.defaultValue != null) {
String defaultComment = "Default: ";
if (this.defaultValue instanceof String) {
defaultComment += "'" + this.defaultValue + "'";
} else {
defaultComment += this.defaultValue;
}
comments.add(defaultComment);
}
if (this.defaultValue != null) {
fileConfiguration.set(this.key, this.defaultValue, comments.toArray(new String[0]));
} else {
fileConfiguration.addComments(comments.toArray(new String[0]));
}
}
}
/**
* Resets the cached value
*/
public void reset() {
this.value = null;
}
/**
* @return true if this setting is only a section and doesn't contain an actual value
*/
public boolean isSection() {
return this.defaultValue == null;
}
/**
* Loads the value from the config and caches it if it isn't set yet
*/
private void loadValue() {
if (this.value != null)
return;
this.value = PlayerParticles.getInstance().getManager(ConfigurationManager.class).getConfig().get(this.key);
}
}
private CommentedFileConfiguration configuration;
public ConfigurationManager(PlayerParticles playerParticles) {
super(playerParticles);
}
@Override
public void reload() {
File configFile = new File(this.playerParticles.getDataFolder(), "config.yml");
boolean setHeader = !configFile.exists();
this.configuration = CommentedFileConfiguration.loadConfiguration(this.playerParticles, configFile);
if (setHeader)
this.configuration.addComments(HEADER);
for (Setting setting : Setting.values()) {
setting.reset();
setting.setIfNotExists(this.configuration);
}
for (GuiIcon icon : GuiIcon.values())
icon.resetDefault();
this.configuration.save();
}
@Override
public void disable() {
for (Setting setting : Setting.values())
setting.reset();
}
/**
* @return the config.yml as a CommentedFileConfiguration
*/
public CommentedFileConfiguration getConfig() {
return this.configuration;
}
/**
* Used for grabbing/caching configurable GUI Icons from the config.yml
*/
public enum GuiIcon {
PARTICLES,
GROUPS,
PRESET_GROUPS,
BACK,
NEXT_PAGE,
PREVIOUS_PAGE,
CREATE,
EDIT_EFFECT,
EDIT_STYLE,
EDIT_DATA,
RESET,
EFFECT,
STYLE;
private Map<String, Material> materials;
GuiIcon() {
this.materials = new HashMap<>();
}
/**
* Gets the Material for this icon from the 'gui-icon.misc' section in the config.yml
* Tries to get from cache first, otherwise loads it
*
* @return The Material for this Icon
*/
public Material get() {
return this.getInternal("gui-icon.misc." + this.name().toLowerCase());
}
/**
* Gets the Material for a subsection of this icon in the config.yml
* Tries to get from cache first, otherwise loads it
*
* @param subsection The name of the icon in the section
* @return The Material for this Icon
*/
public Material get(String subsection) {
return this.getInternal("gui-icon." + this.name().toLowerCase() + "." + subsection);
}
/**
* Gets the Material for this icon
* Tries to get from cache first, otherwise loads it
*
* @param configPath Where to look in the config.yml for the Material name
* @return The path in the config.yml to lookup
*/
private Material getInternal(String configPath) {
Material material = this.materials.get(configPath);
if (material != null)
return material;
ConfigurationManager configurationManager = PlayerParticles.getInstance().getManager(ConfigurationManager.class);
List<String> materials = configurationManager.getConfig().getStringList(configPath);
for (String name : materials) {
material = ParticleUtils.closestMatch(name);
if (material != null)
break;
}
if (material == null)
material = Material.BARRIER;
this.materials.put(configPath, material);
return material;
}
/**
* Resets the setting's value so it will be fetched from the config the next time it's needed
*/
private void resetDefault() {
this.materials = new HashMap<>();
}
}
}

View file

@ -1,6 +1,10 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.database.DatabaseConnector;
import dev.esophose.playerparticles.database.MySQLConnector;
import dev.esophose.playerparticles.database.SQLiteConnector;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.FixedParticleEffect;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
@ -8,25 +12,58 @@ import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
/**
* All data changes to PPlayers such as group or fixed effect changes must be done through here,
* rather than directly on the PPlayer object
*/
public class DataManager {
public class DataManager extends Manager {
private DataManager() {
private DatabaseConnector databaseConnector;
public DataManager(PlayerParticles playerParticles) {
super(playerParticles);
}
@Override
public void reload() {
if (this.databaseConnector != null)
this.databaseConnector.closeConnection();
try {
if (Setting.MYSQL_ENABLED.getBoolean()) {
String hostname = Setting.MYSQL_HOSTNAME.getString();
int port = Setting.MYSQL_PORT.getInt();
String database = Setting.MYSQL_DATABASE_NAME.getString();
String username = Setting.MYSQL_USER_NAME.getString();
String password = Setting.MYSQL_USER_PASSWORD.getString();
boolean useSSL = Setting.MYSQL_USE_SSL.getBoolean();
this.databaseConnector = new MySQLConnector(this.playerParticles, hostname, port, database, username, password, useSSL);
this.playerParticles.getLogger().info("Data handler connected using MySQL.");
} else {
this.databaseConnector = new SQLiteConnector(this.playerParticles);
this.playerParticles.getLogger().info("Data handler connected using SQLite.");
}
} catch (Exception ex) {
this.playerParticles.getLogger().severe("Fatal error trying to connect to database. Please make sure all your connection settings are correct and try again. Plugin has been disabled.");
Bukkit.getPluginManager().disablePlugin(this.playerParticles);
}
}
@Override
public void disable() {
this.databaseConnector.closeConnection();
}
/**
@ -37,9 +74,9 @@ public class DataManager {
* @param playerUUID The PPlayer to get
* @return The PPlayer from cache
*/
public static PPlayer getPPlayer(UUID playerUUID) {
public PPlayer getPPlayer(UUID playerUUID) {
List<PPlayer> pplayers;
synchronized (pplayers = ParticleManager.getPPlayers()) { // Under rare circumstances, the PPlayers list can be changed while it's looping
synchronized (pplayers = this.playerParticles.getManager(ParticleManager.class).getPPlayers()) { // Under rare circumstances, the PPlayers list can be changed while it's looping
for (PPlayer pp : pplayers)
if (pp.getUniqueId().equals(playerUUID))
return pp;
@ -53,23 +90,23 @@ public class DataManager {
* @param playerUUID The pplayer to get
* @param callback The callback to execute with the found pplayer, or a newly generated one
*/
public static void getPPlayer(UUID playerUUID, ConfigurationCallback<PPlayer> callback) {
public void getPPlayer(UUID playerUUID, Consumer<PPlayer> callback) {
// Try to get them from cache first
PPlayer fromCache = getPPlayer(playerUUID);
PPlayer fromCache = this.getPPlayer(playerUUID);
if (fromCache != null) {
callback.execute(fromCache);
callback.accept(fromCache);
return;
}
async(() -> {
this.async(() -> {
List<ParticleGroup> groups = new ArrayList<>();
List<FixedParticleEffect> fixedParticles = new ArrayList<>();
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
this.databaseConnector.connect((connection) -> {
// Load settings
boolean particlesHidden = false;
String settingsQuery = "SELECT particles_hidden FROM pp_settings WHERE player_uuid = ?";
String settingsQuery = "SELECT particles_hidden FROM " + this.getTablePrefix() + "settings WHERE player_uuid = ?";
try (PreparedStatement statement = connection.prepareStatement(settingsQuery)) {
statement.setString(1, playerUUID.toString());
@ -79,7 +116,7 @@ public class DataManager {
} else {
statement.close();
String updateQuery = "INSERT INTO pp_settings (player_uuid, particles_hidden) VALUES (?, ?)";
String updateQuery = "INSERT INTO " + this.getTablePrefix() + "settings (player_uuid, particles_hidden) VALUES (?, ?)";
try (PreparedStatement updateStatement = connection.prepareStatement(updateQuery)) {
updateStatement.setString(1, playerUUID.toString());
updateStatement.setBoolean(2, false);
@ -90,8 +127,8 @@ public class DataManager {
}
// Load particle groups
String groupQuery = "SELECT * FROM pp_group g " + // @formatter:off
"JOIN pp_particle p ON g.uuid = p.group_uuid " +
String groupQuery = "SELECT * FROM " + this.getTablePrefix() + "group g " + // @formatter:off
"JOIN " + this.getTablePrefix() + "particle p ON g.uuid = p.group_uuid " +
"WHERE g.owner_uuid = ?"; // @formatter:on
try (PreparedStatement statement = connection.prepareStatement(groupQuery)) {
statement.setString(1, playerUUID.toString());
@ -132,8 +169,8 @@ public class DataManager {
}
// Load fixed effects
String fixedQuery = "SELECT f.id AS f_id, f.world, f.xPos, f.yPos, f.zPos, p.id AS p_id, p.effect, p.style, p.item_material, p.block_material, p.note, p.r, p.g, p.b FROM pp_fixed f " + // @formatter:off
"JOIN pp_particle p ON f.particle_uuid = p.uuid " +
String fixedQuery = "SELECT f.id AS f_id, f.world, f.xPos, f.yPos, f.zPos, p.id AS p_id, p.effect, p.style, p.item_material, p.block_material, p.note, p.r, p.g, p.b FROM " + this.getTablePrefix() + "fixed f " + // @formatter:off
"JOIN " + this.getTablePrefix() + "particle p ON f.particle_uuid = p.uuid " +
"WHERE f.owner_uuid = ?"; // @formatter:on
try (PreparedStatement statement = connection.prepareStatement(fixedQuery)) {
statement.setString(1, playerUUID.toString());
@ -172,17 +209,17 @@ public class DataManager {
if (!activeGroupExists) {
ParticleGroup activeGroup = new ParticleGroup(ParticleGroup.DEFAULT_NAME, new ArrayList<>());
saveParticleGroup(playerUUID, activeGroup);
this.saveParticleGroup(playerUUID, activeGroup);
groups.add(activeGroup);
}
PPlayer loadedPPlayer = new PPlayer(playerUUID, groups, fixedParticles, particlesHidden);
sync(() -> {
this.sync(() -> {
synchronized (loadedPPlayer) {
if (getPPlayer(playerUUID) == null) { // Make sure the PPlayer still isn't added, since this is async it's possible it got ran twice
ParticleManager.getPPlayers().add(loadedPPlayer); // This will be fine now since loadedPPlayer is synchronized
callback.execute(loadedPPlayer);
if (this.getPPlayer(playerUUID) == null) { // Make sure the PPlayer still isn't added, since this is async it's possible it got ran twice
this.playerParticles.getManager(ParticleManager.class).getPPlayers().add(loadedPPlayer); // This will be fine now since loadedPPlayer is synchronized
callback.accept(loadedPPlayer);
}
}
});
@ -193,14 +230,14 @@ public class DataManager {
/**
* Loads all PPlayers from the database that own FixedParticleEffects
*/
public static void loadFixedEffects() {
async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
String query = "SELECT DISTINCT owner_uuid FROM pp_fixed";
public void loadFixedEffects() {
this.async(() -> this.databaseConnector.connect((connection) -> {
String query = "SELECT DISTINCT owner_uuid FROM " + this.getTablePrefix() + "fixed";
try (PreparedStatement statement = connection.prepareStatement(query)) {
ResultSet result = statement.executeQuery();
while (result.next()) {
UUID playerUUID = UUID.fromString(result.getString("owner_uuid"));
sync(() -> getPPlayer(playerUUID, (pplayer) -> { }));
this.sync(() -> this.getPPlayer(playerUUID, (pplayer) -> { }));
}
}
}));
@ -212,9 +249,9 @@ public class DataManager {
* @param playerUUID The player to hide PlayerParticles from
* @param particlesHidden True if the particles should be hidden, otherwise False
*/
public static void updateSettingParticlesHidden(UUID playerUUID, boolean particlesHidden) {
async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
String updateQuery = "UPDATE pp_settings SET particles_hidden = ? WHERE player_uuid = ?";
public void updateSettingParticlesHidden(UUID playerUUID, boolean particlesHidden) {
this.async(() -> this.databaseConnector.connect((connection) -> {
String updateQuery = "UPDATE " + this.getTablePrefix() + "settings SET particles_hidden = ? WHERE player_uuid = ?";
try (PreparedStatement updateStatement = connection.prepareStatement(updateQuery)) {
updateStatement.setBoolean(1, particlesHidden);
updateStatement.setString(2, playerUUID.toString());
@ -223,7 +260,7 @@ public class DataManager {
}
}));
getPPlayer(playerUUID, (pplayer) -> pplayer.setParticlesHidden(particlesHidden));
this.getPPlayer(playerUUID, (pplayer) -> pplayer.setParticlesHidden(particlesHidden));
}
/**
@ -232,11 +269,11 @@ public class DataManager {
* @param playerUUID The owner of the group
* @param group The group to create/update
*/
public static void saveParticleGroup(UUID playerUUID, ParticleGroup group) {
async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
public void saveParticleGroup(UUID playerUUID, ParticleGroup group) {
this.async(() -> this.databaseConnector.connect((connection) -> {
String groupUUID;
String groupUUIDQuery = "SELECT uuid FROM pp_group WHERE owner_uuid = ? AND name = ?";
String groupUUIDQuery = "SELECT uuid FROM " + this.getTablePrefix() + "group WHERE owner_uuid = ? AND name = ?";
try (PreparedStatement statement = connection.prepareStatement(groupUUIDQuery)) {
statement.setString(1, playerUUID.toString());
statement.setString(2, group.getName());
@ -245,7 +282,7 @@ public class DataManager {
if (result.next()) { // Clear out particles from existing group
groupUUID = result.getString("uuid");
String particlesDeleteQuery = "DELETE FROM pp_particle WHERE group_uuid = ?";
String particlesDeleteQuery = "DELETE FROM " + this.getTablePrefix() + "particle WHERE group_uuid = ?";
PreparedStatement particlesDeleteStatement = connection.prepareStatement(particlesDeleteQuery);
particlesDeleteStatement.setString(1, result.getString("uuid"));
@ -253,7 +290,7 @@ public class DataManager {
} else { // Create new group
groupUUID = UUID.randomUUID().toString();
String groupCreateQuery = "INSERT INTO pp_group (uuid, owner_uuid, name) VALUES (?, ?, ?)";
String groupCreateQuery = "INSERT INTO " + this.getTablePrefix() + "group (uuid, owner_uuid, name) VALUES (?, ?, ?)";
PreparedStatement groupCreateStatement = connection.prepareStatement(groupCreateQuery);
groupCreateStatement.setString(1, groupUUID);
groupCreateStatement.setString(2, playerUUID.toString());
@ -264,7 +301,7 @@ public class DataManager {
}
// Fill group with new particles
String createParticlesQuery = "INSERT INTO pp_particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
String createParticlesQuery = "INSERT INTO " + this.getTablePrefix() + "particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (PreparedStatement particlesStatement = connection.prepareStatement(createParticlesQuery)) {
for (ParticlePair particle : group.getParticles()) {
particlesStatement.setString(1, UUID.randomUUID().toString());
@ -285,7 +322,7 @@ public class DataManager {
}
}));
getPPlayer(playerUUID, (pplayer) -> {
this.getPPlayer(playerUUID, (pplayer) -> {
for (ParticleGroup existing : pplayer.getParticleGroups()) {
if (group.getName().equalsIgnoreCase(existing.getName())) {
pplayer.getParticleGroups().remove(existing);
@ -302,11 +339,11 @@ public class DataManager {
* @param playerUUID The owner of the group
* @param group The group to remove
*/
public static void removeParticleGroup(UUID playerUUID, ParticleGroup group) {
async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
String groupQuery = "SELECT * FROM pp_group WHERE owner_uuid = ? AND name = ?";
String particleDeleteQuery = "DELETE FROM pp_particle WHERE group_uuid = ?";
String groupDeleteQuery = "DELETE FROM pp_group WHERE uuid = ?";
public void removeParticleGroup(UUID playerUUID, ParticleGroup group) {
this.async(() -> this.databaseConnector.connect((connection) -> {
String groupQuery = "SELECT * FROM " + this.getTablePrefix() + "group WHERE owner_uuid = ? AND name = ?";
String particleDeleteQuery = "DELETE FROM " + this.getTablePrefix() + "particle WHERE group_uuid = ?";
String groupDeleteQuery = "DELETE FROM " + this.getTablePrefix() + "group WHERE uuid = ?";
// Execute group uuid query
String groupUUID = null;
@ -335,7 +372,7 @@ public class DataManager {
}
}));
getPPlayer(playerUUID, (pplayer) -> pplayer.getParticleGroups().remove(group));
this.getPPlayer(playerUUID, (pplayer) -> pplayer.getParticleGroups().remove(group));
}
/**
@ -344,11 +381,11 @@ public class DataManager {
*
* @param fixedEffect The fixed effect to save
*/
public static void saveFixedEffect(FixedParticleEffect fixedEffect) {
async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
public void saveFixedEffect(FixedParticleEffect fixedEffect) {
this.async(() -> this.databaseConnector.connect((connection) -> {
String particleUUID = UUID.randomUUID().toString();
String particleQuery = "INSERT INTO pp_particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
String particleQuery = "INSERT INTO " + this.getTablePrefix() + "particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (PreparedStatement statement = connection.prepareStatement(particleQuery)) {
ParticlePair particle = fixedEffect.getParticlePair();
statement.setString(1, particleUUID);
@ -365,7 +402,7 @@ public class DataManager {
statement.executeUpdate();
}
String fixedEffectQuery = "INSERT INTO pp_fixed (owner_uuid, id, particle_uuid, world, xPos, yPos, zPos) VALUES (?, ?, ?, ?, ?, ?, ?)";
String fixedEffectQuery = "INSERT INTO " + this.getTablePrefix() + "fixed (owner_uuid, id, particle_uuid, world, xPos, yPos, zPos) VALUES (?, ?, ?, ?, ?, ?, ?)";
try (PreparedStatement statement = connection.prepareStatement(fixedEffectQuery)) {
statement.setString(1, fixedEffect.getOwnerUniqueId().toString());
statement.setInt(2, fixedEffect.getId());
@ -378,7 +415,7 @@ public class DataManager {
}
}));
getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> pplayer.addFixedEffect(fixedEffect));
this.getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> pplayer.addFixedEffect(fixedEffect));
}
/**
@ -386,10 +423,10 @@ public class DataManager {
*
* @param fixedEffect The fixed effect to update
*/
public static void updateFixedEffect(FixedParticleEffect fixedEffect) {
async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
public void updateFixedEffect(FixedParticleEffect fixedEffect) {
this.async(() -> this.databaseConnector.connect((connection) -> {
// Update fixed effect
String fixedEffectQuery = "UPDATE pp_fixed SET xPos = ?, yPos = ?, zPos = ? WHERE owner_uuid = ? AND id = ?";
String fixedEffectQuery = "UPDATE " + this.getTablePrefix() + "fixed SET xPos = ?, yPos = ?, zPos = ? WHERE owner_uuid = ? AND id = ?";
try (PreparedStatement statement = connection.prepareStatement(fixedEffectQuery)) {
statement.setDouble(1, fixedEffect.getLocation().getX());
statement.setDouble(2, fixedEffect.getLocation().getY());
@ -400,9 +437,9 @@ public class DataManager {
}
// Update particle
String particleUpdateQuery = "UPDATE pp_particle " +
String particleUpdateQuery = "UPDATE " + this.getTablePrefix() + "particle " +
"SET effect = ?, style = ?, item_material = ?, block_material = ?, note = ?, r = ?, g = ?, b = ? " +
"WHERE uuid = (SELECT particle_uuid FROM pp_fixed WHERE owner_uuid = ? AND id = ?)";
"WHERE uuid = (SELECT particle_uuid FROM " + this.getTablePrefix() + "fixed WHERE owner_uuid = ? AND id = ?)";
try (PreparedStatement statement = connection.prepareStatement(particleUpdateQuery)) {
ParticlePair particle = fixedEffect.getParticlePair();
statement.setString(1, particle.getEffect().getName());
@ -419,7 +456,7 @@ public class DataManager {
}
}));
getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> {
this.getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> {
pplayer.removeFixedEffect(fixedEffect.getId());
pplayer.addFixedEffect(fixedEffect);
});
@ -432,11 +469,11 @@ public class DataManager {
* @param playerUUID The player who owns the effect
* @param id The id of the effect to remove
*/
public static void removeFixedEffect(UUID playerUUID, int id) {
async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
public void removeFixedEffect(UUID playerUUID, int id) {
this.async(() -> this.databaseConnector.connect((connection) -> {
String particleUUID = null;
String particleUUIDQuery = "SELECT particle_uuid FROM pp_fixed WHERE owner_uuid = ? AND id = ?";
String particleUUIDQuery = "SELECT particle_uuid FROM " + this.getTablePrefix() + "fixed WHERE owner_uuid = ? AND id = ?";
try (PreparedStatement statement = connection.prepareStatement(particleUUIDQuery)) {
statement.setString(1, playerUUID.toString());
statement.setInt(2, id);
@ -447,14 +484,14 @@ public class DataManager {
}
}
String particleDeleteQuery = "DELETE FROM pp_particle WHERE uuid = ?";
String particleDeleteQuery = "DELETE FROM " + this.getTablePrefix() + "particle WHERE uuid = ?";
try (PreparedStatement statement = connection.prepareStatement(particleDeleteQuery)) {
statement.setString(1, particleUUID);
statement.executeUpdate();
}
String fixedEffectDeleteQuery = "DELETE FROM pp_fixed WHERE owner_uuid = ? AND id = ?";
String fixedEffectDeleteQuery = "DELETE FROM " + this.getTablePrefix() + "fixed WHERE owner_uuid = ? AND id = ?";
try (PreparedStatement statement = connection.prepareStatement(fixedEffectDeleteQuery)) {
statement.setString(1, playerUUID.toString());
statement.setInt(2, id);
@ -463,7 +500,7 @@ public class DataManager {
}
}));
getPPlayer(playerUUID, (pplayer) -> pplayer.removeFixedEffect(id));
this.getPPlayer(playerUUID, (pplayer) -> pplayer.removeFixedEffect(id));
}
/**
@ -471,8 +508,8 @@ public class DataManager {
*
* @param asyncCallback The callback to run on a separate thread
*/
private static void async(Runnable asyncCallback) {
Bukkit.getScheduler().runTaskAsynchronously(PlayerParticles.getPlugin(), asyncCallback);
private void async(Runnable asyncCallback) {
Bukkit.getScheduler().runTaskAsynchronously(this.playerParticles, asyncCallback);
}
/**
@ -480,16 +517,22 @@ public class DataManager {
*
* @param syncCallback The callback to run on the main thread
*/
private static void sync(Runnable syncCallback) {
Bukkit.getScheduler().runTask(PlayerParticles.getPlugin(), syncCallback);
private void sync(Runnable syncCallback) {
Bukkit.getScheduler().runTask(this.playerParticles, syncCallback);
}
/**
* Allows callbacks to be passed between configuration methods and executed for returning objects after database queries
* @return The connector to the database
*/
@FunctionalInterface
public interface ConfigurationCallback<T> {
void execute(T obj);
public DatabaseConnector getDatabaseConnector() {
return this.databaseConnector;
}
/**
* @return the prefix to be used by all table names
*/
public String getTablePrefix() {
return this.playerParticles.getDescription().getName().toLowerCase() + '_';
}
}

View file

@ -0,0 +1,114 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.database.DataMigration;
import dev.esophose.playerparticles.database.DatabaseConnector;
import dev.esophose.playerparticles.database.SQLiteConnector;
import dev.esophose.playerparticles.database.migrations._1_InitialMigration;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class DataMigrationManager extends Manager {
private List<DataMigration> migrations;
public DataMigrationManager(PlayerParticles playerParticles) {
super(playerParticles);
this.migrations = Arrays.asList(
new _1_InitialMigration()
);
}
@Override
public void reload() {
DataManager dataManager = this.playerParticles.getManager(DataManager.class);
DatabaseConnector databaseConnector = dataManager.getDatabaseConnector();
databaseConnector.connect((connection -> {
int currentMigration = -1;
boolean migrationsExist;
String query;
if (databaseConnector instanceof SQLiteConnector) {
query = "SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?";
} else {
query = "SHOW TABLES LIKE ?";
}
try (PreparedStatement statement = connection.prepareStatement(query)) {
statement.setString(1, this.getMigrationsTableName());
migrationsExist = statement.executeQuery().next();
}
if (!migrationsExist) {
// No migration table exists, create one
String createTable = "CREATE TABLE " + this.getMigrationsTableName() + " (migration_version INT NOT NULL)";
try (PreparedStatement statement = connection.prepareStatement(createTable)) {
statement.execute();
}
// Insert primary row into migration table
String insertRow = "INSERT INTO " + this.getMigrationsTableName() + " VALUES (?)";
try (PreparedStatement statement = connection.prepareStatement(insertRow)) {
statement.setInt(1, -1);
statement.execute();
}
} else {
// Grab the current migration version
String selectVersion = "SELECT migration_version FROM " + this.getMigrationsTableName();
try (PreparedStatement statement = connection.prepareStatement(selectVersion)) {
ResultSet result = statement.executeQuery();
result.next();
currentMigration = result.getInt("migration_version");
}
}
// Grab required migrations
int finalCurrentMigration = currentMigration;
List<DataMigration> requiredMigrations = this.migrations
.stream()
.filter(x -> x.getRevision() > finalCurrentMigration)
.sorted(Comparator.comparingInt(DataMigration::getRevision))
.collect(Collectors.toList());
// Nothing to migrate, abort
if (requiredMigrations.isEmpty())
return;
// Migrate the data
for (DataMigration dataMigration : requiredMigrations)
dataMigration.migrate(databaseConnector, connection, dataManager.getTablePrefix());
// Set the new current migration to be the highest migrated to
currentMigration = requiredMigrations
.stream()
.map(DataMigration::getRevision)
.max(Integer::compareTo)
.orElse(-1);
String updateVersion = "UPDATE " + this.getMigrationsTableName() + " SET migration_version = ?";
try (PreparedStatement statement = connection.prepareStatement(updateVersion)) {
statement.setInt(1, currentMigration);
statement.execute();
}
}));
}
@Override
public void disable() {
}
/**
* @return the name of the migrations table
*/
private String getMigrationsTableName() {
return this.playerParticles.getManager(DataManager.class).getTablePrefix() + "migrations";
}
}

View file

@ -1,38 +1,42 @@
package dev.esophose.playerparticles.gui;
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.gui.GuiInventory;
import dev.esophose.playerparticles.gui.GuiInventoryDefault;
import dev.esophose.playerparticles.gui.GuiInventoryLoadPresetGroups;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import dev.esophose.playerparticles.particles.PPlayer;
public class GuiManager extends Manager implements Listener, Runnable {
/**
* This class provides a collection of static methods for modifying your
* particle/style/data through the use of a GUI
*/
public class GuiHandler extends BukkitRunnable implements Listener {
private List<GuiInventory> guiInventories = new ArrayList<>();
private BukkitTask guiTask = null;
private static List<GuiInventory> guiInventories = new ArrayList<>();
private static BukkitTask guiTask = null;
public GuiManager(PlayerParticles playerParticles) {
super(playerParticles);
/**
* Initializes all the static values for this class
*/
public static void setup() {
if (guiTask != null)
guiTask.cancel();
guiTask = new GuiHandler().runTaskTimer(PlayerParticles.getPlugin(), 0, 10);
Bukkit.getPluginManager().registerEvents(this, this.playerParticles);
}
@Override
public void reload() {
if (this.guiTask != null)
this.guiTask.cancel();
this.guiTask = Bukkit.getScheduler().runTaskTimer(this.playerParticles, this, 0, 10);
}
@Override
public void disable() {
this.forceCloseAllOpenGUIs();
}
/**
@ -42,8 +46,8 @@ public class GuiHandler extends BukkitRunnable implements Listener {
public void run() {
List<GuiInventory> toRemoveList = new ArrayList<>();
for (GuiInventory inventory : guiInventories) {
PPlayer pplayer = DataManager.getPPlayer(inventory.getPPlayer().getUniqueId());
for (GuiInventory inventory : this.guiInventories) {
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(inventory.getPPlayer().getUniqueId());
if (pplayer == null) {
toRemoveList.add(inventory);
continue;
@ -64,7 +68,7 @@ public class GuiHandler extends BukkitRunnable implements Listener {
}
for (GuiInventory inventory : toRemoveList)
guiInventories.remove(inventory);
this.guiInventories.remove(inventory);
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -72,7 +76,7 @@ public class GuiHandler extends BukkitRunnable implements Listener {
if (!(event.getWhoClicked() instanceof Player)) return;
Player player = (Player)event.getWhoClicked();
GuiInventory inventory = getGuiInventory(player);
GuiInventory inventory = this.getGuiInventory(player);
if (inventory == null) return;
event.setCancelled(true);
@ -84,24 +88,24 @@ public class GuiHandler extends BukkitRunnable implements Listener {
*
* @return True if the GUI is disabled
*/
public static boolean isGuiDisabled() {
return !PSetting.GUI_ENABLED.getBoolean();
public boolean isGuiDisabled() {
return !Setting.GUI_ENABLED.getBoolean();
}
/**
* Forcefully closes all open PlayerParticles GUIs
* Used for when the plugin unloads so players can't take items from the GUI
*/
public static void forceCloseAllOpenGUIs() {
public void forceCloseAllOpenGUIs() {
for (Player player : Bukkit.getOnlinePlayers()) {
for (GuiInventory inventory : guiInventories) {
for (GuiInventory inventory : this.guiInventories) {
if (inventory.getPPlayer().getUniqueId().equals(player.getUniqueId()) && inventory.getInventory().equals(player.getOpenInventory().getTopInventory())) {
player.closeInventory();
break;
}
}
}
guiInventories.clear();
this.guiInventories.clear();
}
/**
@ -109,17 +113,17 @@ public class GuiHandler extends BukkitRunnable implements Listener {
*
* @param pplayer The PPlayer to open the GUI screen for
*/
public static void openDefault(PPlayer pplayer) {
removeGuiInventory(pplayer);
public void openDefault(PPlayer pplayer) {
this.removeGuiInventory(pplayer);
GuiInventory inventoryToOpen;
if (!PSetting.GUI_PRESETS_ONLY.getBoolean()) {
if (!Setting.GUI_PRESETS_ONLY.getBoolean()) {
inventoryToOpen = new GuiInventoryDefault(pplayer);
} else {
inventoryToOpen = new GuiInventoryLoadPresetGroups(pplayer, true);
}
guiInventories.add(inventoryToOpen);
this.guiInventories.add(inventoryToOpen);
pplayer.getPlayer().openInventory(inventoryToOpen.getInventory());
}
@ -128,9 +132,9 @@ public class GuiHandler extends BukkitRunnable implements Listener {
*
* @param nextInventory The GuiInventory to transition to
*/
protected static void transition(GuiInventory nextInventory) {
removeGuiInventory(nextInventory.getPPlayer());
guiInventories.add(nextInventory);
public void transition(GuiInventory nextInventory) {
this.removeGuiInventory(nextInventory.getPPlayer());
this.guiInventories.add(nextInventory);
nextInventory.getPPlayer().getPlayer().openInventory(nextInventory.getInventory());
}
@ -140,8 +144,8 @@ public class GuiHandler extends BukkitRunnable implements Listener {
* @param player The Player
* @return The GuiInventory belonging to the Player, if any
*/
private static GuiInventory getGuiInventory(Player player) {
for (GuiInventory inventory : guiInventories)
private GuiInventory getGuiInventory(Player player) {
for (GuiInventory inventory : this.guiInventories)
if (inventory.getPPlayer().getUniqueId().equals(player.getUniqueId()))
return inventory;
return null;
@ -152,10 +156,10 @@ public class GuiHandler extends BukkitRunnable implements Listener {
*
* @param pplayer The PPlayer who owns the GuiInventory
*/
private static void removeGuiInventory(PPlayer pplayer) {
for (GuiInventory inventory : guiInventories) {
private void removeGuiInventory(PPlayer pplayer) {
for (GuiInventory inventory : this.guiInventories) {
if (inventory.getPPlayer().getUniqueId().equals(pplayer.getUniqueId())) {
guiInventories.remove(inventory);
this.guiInventories.remove(inventory);
break;
}
}

View file

@ -1,542 +0,0 @@
package dev.esophose.playerparticles.manager;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.HashSet;
import java.util.Set;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.particles.PPlayer;
public class LangManager {
/**
* Contains the location in the .lang file of every chat message
*/
public enum Lang { // @formatter:off
// Command Errors
COMMAND_ERROR_NO_EFFECTS,
COMMAND_ERROR_UNKNOWN,
// Command Descriptions
COMMAND_DESCRIPTIONS,
COMMAND_DESCRIPTIONS_USAGE,
COMMAND_DESCRIPTIONS_HELP_1,
COMMAND_DESCRIPTIONS_HELP_2,
COMMAND_DESCRIPTIONS_HELP_OTHER,
COMMAND_DESCRIPTION_ADD,
COMMAND_DESCRIPTION_DATA,
COMMAND_DESCRIPTION_DEFAULT,
COMMAND_DESCRIPTION_EDIT,
COMMAND_DESCRIPTION_EFFECTS,
COMMAND_DESCRIPTION_FIXED,
COMMAND_DESCRIPTION_GROUP,
COMMAND_DESCRIPTION_GUI,
COMMAND_DESCRIPTION_HELP,
COMMAND_DESCRIPTION_INFO,
COMMAND_DESCRIPTION_LIST,
COMMAND_DESCRIPTION_RELOAD,
COMMAND_DESCRIPTION_REMOVE,
COMMAND_DESCRIPTION_RESET,
COMMAND_DESCRIPTION_STYLES,
COMMAND_DESCRIPTION_TOGGLE,
COMMAND_DESCRIPTION_VERSION,
COMMAND_DESCRIPTION_WORLDS,
// Sub-Command Usage
COMMAND_DESCRIPTION_FIXED_CREATE,
COMMAND_DESCRIPTION_FIXED_EDIT,
COMMAND_DESCRIPTION_FIXED_REMOVE,
COMMAND_DESCRIPTION_FIXED_LIST,
COMMAND_DESCRIPTION_FIXED_INFO,
COMMAND_DESCRIPTION_FIXED_CLEAR,
COMMAND_DESCRIPTION_GROUP_SAVE,
COMMAND_DESCRIPTION_GROUP_LOAD,
COMMAND_DESCRIPTION_GROUP_REMOVE,
COMMAND_DESCRIPTION_GROUP_LIST,
COMMAND_DESCRIPTION_GROUP_INFO,
// ID Lookup
ID_INVALID,
ID_UNKNOWN,
// Other Command
OTHER_NO_PERMISSION,
OTHER_MISSING_ARGS,
OTHER_UNKNOWN_PLAYER,
OTHER_UNKNOWN_COMMAND,
OTHER_SUCCESS,
// Add Command
ADD_REACHED_MAX,
ADD_PARTICLE_APPLIED,
// Data Command
DATA_NO_ARGS,
// Edit Command
EDIT_INVALID_PROPERTY,
EDIT_SUCCESS_EFFECT,
EDIT_SUCCESS_STYLE,
EDIT_SUCCESS_DATA,
// Group Command
GROUP_INVALID,
GROUP_NO_PERMISSION,
GROUP_PRESET_NO_PERMISSION,
GROUP_RESERVED,
GROUP_NO_NAME,
GROUP_SAVE_REACHED_MAX,
GROUP_SAVE_NO_PARTICLES,
GROUP_SAVE_SUCCESS,
GROUP_SAVE_SUCCESS_OVERWRITE,
GROUP_LOAD_SUCCESS,
GROUP_LOAD_PRESET_SUCCESS,
GROUP_REMOVE_PRESET,
GROUP_REMOVE_SUCCESS,
GROUP_INFO_HEADER,
GROUP_LIST_NONE,
GROUP_LIST_OUTPUT,
GROUP_LIST_PRESETS,
// Reload Command
RELOAD_SUCCESS,
RELOAD_NO_PERMISSION,
// Remove Command
REMOVE_NO_ARGS,
REMOVE_ID_SUCCESS,
REMOVE_EFFECT_SUCCESS,
REMOVE_EFFECT_NONE,
REMOVE_STYLE_SUCCESS,
REMOVE_STYLE_NONE,
REMOVE_UNKNOWN,
// List Command
LIST_NONE,
LIST_YOU_HAVE,
LIST_OUTPUT,
// Toggle Command
TOGGLE_ON,
TOGGLE_OFF,
// Rainbow
RAINBOW,
// Random
RANDOM,
// Effects
EFFECT_NO_PERMISSION,
EFFECT_INVALID,
EFFECT_LIST,
EFFECT_LIST_EMPTY,
// Styles
STYLE_NO_PERMISSION,
STYLE_EVENT_SPAWNING_INFO,
STYLE_INVALID,
STYLE_LIST,
// Data
DATA_USAGE_NONE,
DATA_USAGE_BLOCK,
DATA_USAGE_ITEM,
DATA_USAGE_COLOR,
DATA_USAGE_NOTE,
DATA_INVALID_BLOCK,
DATA_INVALID_ITEM,
DATA_INVALID_COLOR,
DATA_INVALID_NOTE,
DATA_INVALID_MATERIAL_NOT_ITEM,
DATA_INVALID_MATERIAL_NOT_BLOCK,
DATA_INVALID_MATERIAL_ITEM,
DATA_INVALID_MATERIAL_BLOCK,
// Worlds
DISABLED_WORLDS,
DISABLED_WORLDS_NONE,
// Reset
RESET_SUCCESS,
// Fixed Effects
FIXED_CREATE_MISSING_ARGS,
FIXED_CREATE_INVALID_COORDS,
FIXED_CREATE_OUT_OF_RANGE,
FIXED_CREATE_LOOKING_TOO_FAR,
FIXED_CREATE_EFFECT_INVALID,
FIXED_CREATE_EFFECT_NO_PERMISSION,
FIXED_CREATE_STYLE_INVALID,
FIXED_CREATE_STYLE_NO_PERMISSION,
FIXED_CREATE_STYLE_NON_FIXABLE,
FIXED_CREATE_DATA_ERROR,
FIXED_CREATE_SUCCESS,
FIXED_EDIT_MISSING_ARGS,
FIXED_EDIT_INVALID_ID,
FIXED_EDIT_INVALID_PROPERTY,
FIXED_EDIT_INVALID_COORDS,
FIXED_EDIT_OUT_OF_RANGE,
FIXED_EDIT_LOOKING_TOO_FAR,
FIXED_EDIT_EFFECT_INVALID,
FIXED_EDIT_EFFECT_NO_PERMISSION,
FIXED_EDIT_STYLE_INVALID,
FIXED_EDIT_STYLE_NO_PERMISSION,
FIXED_EDIT_STYLE_NON_FIXABLE,
FIXED_EDIT_DATA_ERROR,
FIXED_EDIT_DATA_NONE,
FIXED_EDIT_SUCCESS,
FIXED_REMOVE_INVALID,
FIXED_REMOVE_NO_ARGS,
FIXED_REMOVE_ARGS_INVALID,
FIXED_REMOVE_SUCCESS,
FIXED_LIST_NONE,
FIXED_LIST_SUCCESS,
FIXED_INFO_INVALID,
FIXED_INFO_NO_ARGS,
FIXED_INFO_INVALID_ARGS,
FIXED_INFO_SUCCESS,
FIXED_CLEAR_NO_PERMISSION,
FIXED_CLEAR_NO_ARGS,
FIXED_CLEAR_INVALID_ARGS,
FIXED_CLEAR_SUCCESS,
FIXED_NO_PERMISSION,
FIXED_MAX_REACHED,
FIXED_INVALID_COMMAND,
// Update Available
UPDATE_AVAILABLE,
// GUI
GUI_DISABLED,
GUI_COLOR_ICON_NAME,
GUI_COLOR_INFO,
GUI_COLOR_SUBTEXT,
GUI_COLOR_UNAVAILABLE,
GUI_COMMANDS_INFO,
GUI_BACK_BUTTON,
GUI_NEXT_PAGE_BUTTON,
GUI_PREVIOUS_PAGE_BUTTON,
GUI_CLICK_TO_LOAD,
GUI_SHIFT_CLICK_TO_DELETE,
GUI_PARTICLE_INFO,
GUI_PLAYERPARTICLES,
GUI_ACTIVE_PARTICLES,
GUI_SAVED_GROUPS,
GUI_FIXED_EFFECTS,
GUI_EDIT_PRIMARY_EFFECT,
GUI_EDIT_PRIMARY_EFFECT_DESCRIPTION,
GUI_EDIT_PRIMARY_STYLE,
GUI_EDIT_PRIMARY_STYLE_MISSING_EFFECT,
GUI_EDIT_PRIMARY_STYLE_DESCRIPTION,
GUI_EDIT_PRIMARY_DATA,
GUI_EDIT_PRIMARY_DATA_MISSING_EFFECT,
GUI_EDIT_PRIMARY_DATA_UNAVAILABLE,
GUI_EDIT_PRIMARY_DATA_DESCRIPTION,
GUI_MANAGE_YOUR_PARTICLES,
GUI_MANAGE_YOUR_PARTICLES_DESCRIPTION,
GUI_MANAGE_YOUR_GROUPS,
GUI_MANAGE_YOUR_GROUPS_DESCRIPTION,
GUI_LOAD_A_PRESET_GROUP,
GUI_LOAD_A_PRESET_GROUP_DESCRIPTION,
GUI_SAVE_GROUP,
GUI_SAVE_GROUP_DESCRIPTION,
GUI_SAVE_GROUP_FULL,
GUI_SAVE_GROUP_NO_PARTICLES,
GUI_SAVE_GROUP_HOTBAR_MESSAGE,
GUI_RESET_PARTICLES,
GUI_RESET_PARTICLES_DESCRIPTION,
GUI_PARTICLE_NAME,
GUI_CLICK_TO_EDIT_PARTICLE,
GUI_EDITING_PARTICLE,
GUI_EDIT_EFFECT,
GUI_EDIT_EFFECT_DESCRIPTION,
GUI_EDIT_STYLE,
GUI_EDIT_STYLE_DESCRIPTION,
GUI_EDIT_DATA,
GUI_EDIT_DATA_DESCRIPTION,
GUI_EDIT_DATA_UNAVAILABLE,
GUI_DATA_NONE,
GUI_CREATE_PARTICLE,
GUI_CREATE_PARTICLE_DESCRIPTION,
GUI_CREATE_PARTICLE_UNAVAILABLE,
GUI_SELECT_EFFECT,
GUI_SELECT_EFFECT_DESCRIPTION,
GUI_SELECT_STYLE,
GUI_SELECT_STYLE_DESCRIPTION,
GUI_SELECT_DATA,
GUI_SELECT_DATA_DESCRIPTION,
GUI_SELECT_DATA_NOTE,
GUI_EDIT_DATA_COLOR_RED,
GUI_EDIT_DATA_COLOR_ORANGE,
GUI_EDIT_DATA_COLOR_YELLOW,
GUI_EDIT_DATA_COLOR_LIME_GREEN,
GUI_EDIT_DATA_COLOR_GREEN,
GUI_EDIT_DATA_COLOR_BLUE,
GUI_EDIT_DATA_COLOR_CYAN,
GUI_EDIT_DATA_COLOR_LIGHT_BLUE,
GUI_EDIT_DATA_COLOR_PURPLE,
GUI_EDIT_DATA_COLOR_MAGENTA,
GUI_EDIT_DATA_COLOR_PINK,
GUI_EDIT_DATA_COLOR_BROWN,
GUI_EDIT_DATA_COLOR_BLACK,
GUI_EDIT_DATA_COLOR_GRAY,
GUI_EDIT_DATA_COLOR_LIGHT_GRAY,
GUI_EDIT_DATA_COLOR_WHITE; // @formatter:on
private String message;
/**
* Gets the name of the message in the config
*
* @return The location in the config that this message is located
*/
private String getConfigName() {
return this.name().toLowerCase().replaceAll("_", "-");
}
/**
* Sets the message from the lang file
*
* @param langFile The lang file to pull the message from
*/
private void setMessage(YamlConfiguration langFile) {
String fileLocation = this.getConfigName();
String langMessage = langFile.getString(fileLocation);
if (langMessage == null) {
langMessage = "&cMissing message in " + langFileName + ": " + fileLocation + ". Contact a server administrator.";
PlayerParticles.getPlugin().getLogger().warning("Missing message in " + langFileName + ": " + fileLocation);
}
this.message = parseColors(langMessage);
}
/**
* Gets the message this enum represents
*
* @param replacements The replacements for the message
* @return The message with the replacements applied
*/
private String get(Object... replacements) {
return new MessageFormat(this.message).format(replacements);
}
}
/**
* The current lang file name
*/
private static String langFileName;
private LangManager() {
}
/**
* Used to set up the LangManager
* This should only get called once by the PlayerParticles class, however
* calling it multiple times wont affect anything negatively
*
* @param resetLangFile If the default lang files should be updated to the latest version
*/
public static void reload(boolean resetLangFile) {
YamlConfiguration lang = configureLangFile(resetLangFile);
for (Lang messageType : Lang.values())
messageType.setMessage(lang);
}
/**
* Loads the target .lang file as defined in the config and grabs its YamlConfiguration
* If it doesn't exist, default to en_US.lang
* If the default lang files don't exist, copy the files from this .jar to the target directory
*
* @param resetLangFiles If the default lang files should be updated to the latest version
* @return The YamlConfiguration of the target .lang file
*/
private static YamlConfiguration configureLangFile(boolean resetLangFiles) {
File pluginDataFolder = PlayerParticles.getPlugin().getDataFolder();
langFileName = PSetting.LANG_FILE.getString();
File targetLangFile = new File(pluginDataFolder.getAbsolutePath() + "/lang/" + langFileName);
// TODO: Move this somewhere else
Set<String> defaultLangFileNames = new HashSet<>();
defaultLangFileNames.add("en_US.lang");
defaultLangFileNames.add("fr_FR.lang");
defaultLangFileNames.add("vi_VN.lang");
defaultLangFileNames.add("ru_RU.lang");
targetLangFile.getParentFile().mkdir(); // Make sure the directory always exists
if (resetLangFiles) {
for (String fileName : defaultLangFileNames) {
File file = new File(pluginDataFolder.getAbsolutePath() + "/lang/" + fileName);
// Delete the file if it already exists
if (file.exists()) {
file.delete();
}
// Generate the new file
try (InputStream stream = PlayerParticles.getPlugin().getResource("lang/" + fileName)) {
Files.copy(stream, Paths.get(file.getAbsolutePath()));
} catch (IOException ex) {
ex.printStackTrace();
PlayerParticles.getPlugin().getLogger().severe("Unable to write " + fileName + " to disk! This wasn't supposed to happen!");
}
}
PlayerParticles.getPlugin().getLogger().warning("The default lang files have been reset!");
} else {
// Make sure the default lang files still exist, if not, create them
boolean foundMissingFile = false;
for (String fileName : defaultLangFileNames) {
File file = new File(pluginDataFolder.getAbsolutePath() + "/lang/" + fileName);
// Generate the new file if it doesn't exist
if (!file.exists()) {
foundMissingFile = true;
try (InputStream stream = PlayerParticles.getPlugin().getResource("lang/" + fileName)) {
Files.copy(stream, Paths.get(file.getAbsolutePath()));
} catch (IOException ex) {
ex.printStackTrace();
PlayerParticles.getPlugin().getLogger().severe("Unable to write " + fileName + " to disk! This wasn't supposed to happen!");
}
}
}
if (foundMissingFile)
PlayerParticles.getPlugin().getLogger().warning("One or more default lang files were missing, recreated them!");
}
if (!targetLangFile.exists()) { // Target .lang file didn't exist, default to en_US.lang
if (!langFileName.equals("en_US.lang")) {
PlayerParticles.getPlugin().getLogger().warning("Couldn't find lang file '" + langFileName + "', defaulting to en_US.lang");
}
langFileName = "en_US.lang";
targetLangFile = new File(pluginDataFolder.getAbsolutePath() + "/lang/" + langFileName);
}
return YamlConfiguration.loadConfiguration(targetLangFile);
}
/**
* Gets a formatted and replaced message
*
* @param messageType The message type to get
* @param replacements The replacements fot the message
* @return The Lang in text form with its replacements applied
*/
public static String getText(Lang messageType, Object... replacements) {
return messageType.get(replacements);
}
/**
* Sends a message to the given PPlayer
*
* @param pplayer The player to send the message to
* @param messageType The message to send to the player
* @param replacements The replacements for the message
*/
public static void sendMessage(PPlayer pplayer, Lang messageType, Object... replacements) {
if (!PSetting.MESSAGES_ENABLED.getBoolean()) return;
String message = messageType.get(replacements);
if (message.length() == 0) return;
if (PSetting.USE_MESSAGE_PREFIX.getBoolean()) {
message = parseColors(PSetting.MESSAGE_PREFIX.getString()) + " " + message;
}
if (message.trim().equals("")) return;
pplayer.getMessageDestination().sendMessage(message);
}
/**
* Sends a custom message to a PPlayer
* Used in cases of string building
*
* @param pplayer The player to send the message to
* @param message The message to send to the player
*/
public static void sendCustomMessage(PPlayer pplayer, String message) {
if (!PSetting.MESSAGES_ENABLED.getBoolean()) return;
if (message.trim().length() == 0) return;
if (PSetting.USE_MESSAGE_PREFIX.getBoolean()) {
message = parseColors(PSetting.MESSAGE_PREFIX.getString()) + " " + message;
}
pplayer.getMessageDestination().sendMessage(message);
}
/**
* Sends a message to a PPlayer without the prefix
*
* @param pplayer The player to send the message to
* @param messageType The message type to send the player
* @param replacements The replacements for the message
*/
public static void sendSimpleMessage(PPlayer pplayer, Lang messageType, Object... replacements) {
if (!PSetting.MESSAGES_ENABLED.getBoolean()) return;
String message = messageType.get(replacements);
if (message.length() == 0) return;
if (message.trim().equals("")) return;
pplayer.getMessageDestination().sendMessage(message);
}
/**
* Sends a message to a CommandSender
*
* @param sender The CommandSender to send the message to
* @param messageType The message type to send the player
* @param replacements The replacements for the message
*/
public static void sendCommandSenderMessage(CommandSender sender, Lang messageType, Object... replacements) {
if (!PSetting.MESSAGES_ENABLED.getBoolean()) return;
String message = messageType.get(replacements);
if (message.length() == 0) return;
if (PSetting.USE_MESSAGE_PREFIX.getBoolean()) {
message = parseColors(PSetting.MESSAGE_PREFIX.getString()) + " " + message;
}
if (message.trim().equals("")) return;
sender.sendMessage(message);
}
/**
* Translates all ampersand symbols into the Minecraft chat color symbol
*
* @param message The input string
* @return The output string, parsed
*/
public static String parseColors(String message) {
return ChatColor.translateAlternateColorCodes('&', message);
}
}

View file

@ -0,0 +1,229 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.hook.PlaceholderAPIHook;
import dev.esophose.playerparticles.locale.EnglishLocale;
import dev.esophose.playerparticles.locale.FrenchLocale;
import dev.esophose.playerparticles.locale.GermanLocale;
import dev.esophose.playerparticles.locale.Locale;
import dev.esophose.playerparticles.locale.RussianLocale;
import dev.esophose.playerparticles.locale.SimplifiedChineseLocale;
import dev.esophose.playerparticles.locale.VietnameseLocale;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class LocaleManager extends Manager {
private CommentedFileConfiguration locale;
public LocaleManager(PlayerParticles playerParticles) {
super(playerParticles);
}
/**
* Creates a .lang file if one doesn't exist
* Cross merges values between files into the .lang file, the .lang values take priority
*
* @param locale The Locale to register
*/
private void registerLocale(Locale locale) {
File file = new File(this.playerParticles.getDataFolder() + "/locale", locale.getLocaleName() + ".lang");
boolean newFile = false;
if (!file.exists()) {
try {
file.createNewFile();
newFile = true;
} catch (IOException e) {
e.printStackTrace();
}
}
CommentedFileConfiguration configuration = CommentedFileConfiguration.loadConfiguration(this.playerParticles, file);
if (newFile) {
configuration.addComments(locale.getLocaleName() + " translation by " + locale.getTranslatorName());
Map<String, String> defaultLocaleStrings = locale.getDefaultLocaleStrings();
for (String key : defaultLocaleStrings.keySet()) {
String value = defaultLocaleStrings.get(key);
if (key.startsWith("#")) {
configuration.addComments(value);
} else {
configuration.set(key, value);
}
}
} else {
Map<String, String> defaultLocaleStrings = locale.getDefaultLocaleStrings();
for (String key : defaultLocaleStrings.keySet()) {
if (key.startsWith("#"))
continue;
String value = defaultLocaleStrings.get(key);
if (!configuration.contains(key))
configuration.set(key, value);
}
}
configuration.save();
}
@Override
public void reload() {
File localeDirectory = new File(this.playerParticles.getDataFolder(), "locale");
if (!localeDirectory.exists())
localeDirectory.mkdirs();
this.registerLocale(new EnglishLocale());
this.registerLocale(new FrenchLocale());
this.registerLocale(new GermanLocale());
this.registerLocale(new RussianLocale());
this.registerLocale(new SimplifiedChineseLocale());
this.registerLocale(new VietnameseLocale());
File targetLocaleFile = new File(this.playerParticles.getDataFolder() + "/locale", Setting.LOCALE.getString() + ".lang");
if (!targetLocaleFile.exists()) {
targetLocaleFile = new File(this.playerParticles.getDataFolder() + "/locale", "en_US.lang");
this.playerParticles.getLogger().severe("File " + targetLocaleFile.getName() + " does not exist. Defaulting to en_US.lang");
}
this.locale = CommentedFileConfiguration.loadConfiguration(this.playerParticles, targetLocaleFile);
}
@Override
public void disable() {
}
public String getLocaleMessage(String messageKey) {
return this.getLocaleMessage(messageKey, StringPlaceholders.empty());
}
public String getLocaleMessage(String messageKey, StringPlaceholders stringPlaceholders) {
String message = this.locale.getString(messageKey);
if (message == null)
return "null";
return ChatColor.translateAlternateColorCodes('&', stringPlaceholders.apply(message));
}
/**
* Sends a message to a CommandSender with the prefix with placeholders applied
*
* @param sender The CommandSender to send to
* @param messageKey The message key of the Locale to send
* @param stringPlaceholders The placeholders to apply
*/
public void sendMessage(CommandSender sender, String messageKey, StringPlaceholders stringPlaceholders) {
sender.sendMessage(this.getLocaleMessage("prefix") + this.getLocaleMessage(messageKey, stringPlaceholders));
}
/**
* Sends a message to a PPlayer with the prefix with placeholders applied
*
* @param pplayer The PPlayer to send to
* @param messageKey The message key of the Locale to send
* @param stringPlaceholders The placeholders to apply
*/
public void sendMessage(PPlayer pplayer, String messageKey, StringPlaceholders stringPlaceholders) {
pplayer.getMessageDestination().sendMessage(this.parsePlaceholders(pplayer.getPlayer(), this.getLocaleMessage("prefix") + this.getLocaleMessage(messageKey, stringPlaceholders)));
}
/**
* Sends a message to a CommandSender with the prefix
*
* @param sender The CommandSender to send to
* @param messageKey The message key of the Locale to send
*/
public void sendMessage(CommandSender sender, String messageKey) {
this.sendMessage(sender, messageKey, StringPlaceholders.empty());
}
/**
* Sends a message to a PPlayer with the prefix
*
* @param pplayer The PPlayer to send to
* @param messageKey The message key of the Locale to send
*/
public void sendMessage(PPlayer pplayer, String messageKey) {
this.sendMessage(pplayer, messageKey, StringPlaceholders.empty());
}
/**
* Sends a message to a CommandSender with placeholders applied
*
* @param sender The CommandSender to send to
* @param messageKey The message key of the Locale to send
* @param stringPlaceholders The placeholders to apply
*/
public void sendSimpleMessage(CommandSender sender, String messageKey, StringPlaceholders stringPlaceholders) {
sender.sendMessage(this.getLocaleMessage(messageKey, stringPlaceholders));
}
/**
* Sends a message to a PPlayer with placeholders applied
*
* @param pplayer The PPlayer to send to
* @param messageKey The message key of the Locale to send
* @param stringPlaceholders The placeholders to apply
*/
public void sendSimpleMessage(PPlayer pplayer, String messageKey, StringPlaceholders stringPlaceholders) {
pplayer.getMessageDestination().sendMessage(this.parsePlaceholders(pplayer.getPlayer(), this.getLocaleMessage(messageKey, stringPlaceholders)));
}
/**
* Sends a message to a CommandSender
*
* @param sender The CommandSender to send to
* @param messageKey The message key of the Locale to send
*/
public void sendSimpleMessage(CommandSender sender, String messageKey) {
this.sendMessage(sender, messageKey, StringPlaceholders.empty());
}
/**
* Sends a message to a PPlayer
*
* @param pplayer The PPlayer to send to
* @param messageKey The message key of the Locale to send
*/
public void sendSimpleMessage(PPlayer pplayer, String messageKey) {
this.sendMessage(pplayer, messageKey, StringPlaceholders.empty());
}
/**
* Sends a custom message to a CommandSender
*
* @param sender The CommandSender to send to
* @param message The message to send
*/
public void sendCustomMessage(CommandSender sender, String message) {
sender.sendMessage(message);
}
/**
* Sends a custom message to a PPlayer
*
* @param pplayer The PPlayer to send to
* @param message The message to send
*/
public void sendCustomMessage(PPlayer pplayer, String message) {
this.sendCustomMessage(pplayer.getMessageDestination(), this.parsePlaceholders(pplayer.getPlayer(), message));
}
/**
* Replaces PlaceholderAPI placeholders if PlaceholderAPI is enabled
*
* @param player The Player to replace with
* @param message The message
* @return A placeholder-replaced message
*/
private String parsePlaceholders(Player player, String message) {
return PlaceholderAPIHook.applyPlaceholders(player, message);
}
}

View file

@ -0,0 +1,23 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
public abstract class Manager {
protected PlayerParticles playerParticles;
public Manager(PlayerParticles playerParticles) {
this.playerParticles = playerParticles;
}
/**
* Reloads the Manager's settings
*/
public abstract void reload();
/**
* Cleans up the Manager's resources
*/
public abstract void disable();
}

View file

@ -1,5 +1,15 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticleGroupPreset;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@ -10,46 +20,37 @@ import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticleGroupPreset;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
public class ParticleGroupPresetManager {
public class ParticleGroupPresetManager extends Manager {
private static final String FILE_NAME = "preset_groups.yml";
private static List<ParticleGroupPreset> presetGroups;
/** Not instantiable */
private ParticleGroupPresetManager() {
private List<ParticleGroupPreset> presetGroups;
public ParticleGroupPresetManager(PlayerParticles playerParticles) {
super(playerParticles);
}
/**
* Loads the preset groups from the preset_groups.yml file
*/
public static void reload() {
presetGroups = new ArrayList<>();
@Override
public void reload() {
this.presetGroups = new ArrayList<>();
File pluginDataFolder = PlayerParticles.getPlugin().getDataFolder();
File groupsFile = new File(pluginDataFolder.getAbsolutePath() + File.separator + FILE_NAME);
File pluginDataFolder = PlayerParticles.getInstance().getDataFolder();
if (!pluginDataFolder.exists())
pluginDataFolder.mkdir();
File groupsFile = new File(pluginDataFolder, FILE_NAME);
// Create the file if it doesn't exist
if (!groupsFile.exists()) {
try (InputStream inStream = PlayerParticles.getPlugin().getResource(FILE_NAME)) {
try (InputStream inStream = PlayerParticles.getInstance().getResource(FILE_NAME)) {
Files.copy(inStream, Paths.get(groupsFile.getAbsolutePath()));
} catch (IOException e) {
e.printStackTrace();
@ -97,12 +98,12 @@ public class ParticleGroupPresetManager {
ParticleStyle style = ParticleStyle.fromName(particleSection.getString("style"));
if (effect == null) {
PlayerParticles.getPlugin().getLogger().severe("Invalid effect name: '" + particleSection.getString("effect") + "'!");
PlayerParticles.getInstance().getLogger().severe("Invalid effect name: '" + particleSection.getString("effect") + "'!");
throw new Exception();
}
if (style == null) {
PlayerParticles.getPlugin().getLogger().severe("Invalid style name: '" + particleSection.getString("style") + "'!");
PlayerParticles.getInstance().getLogger().severe("Invalid style name: '" + particleSection.getString("style") + "'!");
throw new Exception();
}
@ -112,7 +113,7 @@ public class ParticleGroupPresetManager {
NoteColor noteColorData = null;
String dataString = particleSection.getString("data");
if (!dataString.isEmpty()) {
if (dataString != null && !dataString.isEmpty()) {
String[] args = dataString.split(" ");
if (effect.hasProperty(ParticleProperty.COLORABLE)) {
@ -124,12 +125,12 @@ public class ParticleGroupPresetManager {
try {
note = Integer.parseInt(args[0]);
} catch (Exception e) {
PlayerParticles.getPlugin().getLogger().severe("Invalid note: '" + args[0] + "'!");
PlayerParticles.getInstance().getLogger().severe("Invalid note: '" + args[0] + "'!");
throw new Exception();
}
if (note < 0 || note > 23) {
PlayerParticles.getPlugin().getLogger().severe("Invalid note: '" + args[0] + "'!");
PlayerParticles.getInstance().getLogger().severe("Invalid note: '" + args[0] + "'!");
throw new Exception();
}
@ -146,12 +147,12 @@ public class ParticleGroupPresetManager {
g = Integer.parseInt(args[1]);
b = Integer.parseInt(args[2]);
} catch (Exception e) {
PlayerParticles.getPlugin().getLogger().severe("Invalid color: '" + args[0] + " " + args[1] + " " + args[2] + "'!");
PlayerParticles.getInstance().getLogger().severe("Invalid color: '" + args[0] + " " + args[1] + " " + args[2] + "'!");
throw new Exception();
}
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
PlayerParticles.getPlugin().getLogger().severe("Invalid color: '" + args[0] + " " + args[1] + " " + args[2] + "'!");
PlayerParticles.getInstance().getLogger().severe("Invalid color: '" + args[0] + " " + args[1] + " " + args[2] + "'!");
throw new Exception();
}
@ -164,7 +165,7 @@ public class ParticleGroupPresetManager {
blockData = ParticleUtils.closestMatch(args[0]);
if (blockData == null || !blockData.isBlock()) throw new Exception();
} catch (Exception e) {
PlayerParticles.getPlugin().getLogger().severe("Invalid block: '" + args[0] + "'!");
PlayerParticles.getInstance().getLogger().severe("Invalid block: '" + args[0] + "'!");
throw new Exception();
}
} else if (effect == ParticleEffect.ITEM) {
@ -172,7 +173,7 @@ public class ParticleGroupPresetManager {
itemData = ParticleUtils.closestMatch(args[0]);
if (itemData == null || itemData.isBlock()) throw new Exception();
} catch (Exception e) {
PlayerParticles.getPlugin().getLogger().severe("Invalid item: '" + args[0] + "'!");
PlayerParticles.getInstance().getLogger().severe("Invalid item: '" + args[0] + "'!");
throw new Exception();
}
}
@ -181,13 +182,18 @@ public class ParticleGroupPresetManager {
particles.add(new ParticlePair(null, id, effect, style, itemData, blockData, colorData, noteColorData));
}
presetGroups.add(new ParticleGroupPreset(displayName, guiIcon, permission, allowPermissionOverride, new ParticleGroup(groupName, particles)));
this.presetGroups.add(new ParticleGroupPreset(displayName, guiIcon, permission, allowPermissionOverride, new ParticleGroup(groupName, particles)));
} catch (Exception ex) {
PlayerParticles.getPlugin().getLogger().severe("An error occurred while parsing the groups.yml file!");
PlayerParticles.getInstance().getLogger().severe("An error occurred while parsing the groups.yml file!");
}
}
}
@Override
public void disable() {
}
/**
* Gets all the preset ParticleGroups that a player can use
@ -195,8 +201,8 @@ public class ParticleGroupPresetManager {
* @param player The player
* @return a List of preset ParticleGroups the player can use
*/
public static List<ParticleGroupPreset> getPresetGroupsForPlayer(Player player) {
return presetGroups.stream().filter(x -> x.canPlayerUse(player)).sorted(Comparator.comparing(ParticleGroupPreset::getDisplayName)).collect(Collectors.toList());
public List<ParticleGroupPreset> getPresetGroupsForPlayer(Player player) {
return this.presetGroups.stream().filter(x -> x.canPlayerUse(player)).sorted(Comparator.comparing(ParticleGroupPreset::getDisplayName)).collect(Collectors.toList());
}
/**
@ -205,8 +211,8 @@ public class ParticleGroupPresetManager {
* @param groupName The ParticleGroup name
* @return The preset ParticleGroup if it exists, otherwise null
*/
public static ParticleGroupPreset getPresetGroup(String groupName) {
for (ParticleGroupPreset group : presetGroups)
public ParticleGroupPreset getPresetGroup(String groupName) {
for (ParticleGroupPreset group : this.presetGroups)
if (group.getGroup().getName().equalsIgnoreCase(groupName))
return group;
return null;

View file

@ -1,14 +1,19 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.FixedParticleEffect;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.particles.PParticle;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyleManager;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -18,29 +23,55 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import dev.esophose.playerparticles.particles.FixedParticleEffect;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticlePair;
public class ParticleManager extends BukkitRunnable implements Listener {
public class ParticleManager extends Manager implements Listener, Runnable {
/**
* The list containing all the loaded PPlayer info
*/
private static List<PPlayer> particlePlayers = new ArrayList<>();
private List<PPlayer> particlePlayers = new ArrayList<>();
/**
* The task that spawns the particles
*/
private BukkitTask particleTask = null;
/**
* Rainbow particle effect hue and note color used for rainbow colorable effects
* These should be moved to a more appropriate place later
*/
private static int hue = 0;
private static int note = 0;
private static final Random RANDOM = new Random();
private int hue = 0;
private int note = 0;
private final Random RANDOM = new Random();
public ParticleManager(PlayerParticles playerParticles) {
super(playerParticles);
Bukkit.getPluginManager().registerEvents(this, this.playerParticles);
}
@Override
public void reload() {
if (this.particleTask != null)
this.particleTask.cancel();
Bukkit.getScheduler().runTaskLater(this.playerParticles, () -> {
long ticks = Setting.TICKS_PER_PARTICLE.getLong();
this.particleTask = Bukkit.getScheduler().runTaskTimer(this.playerParticles, this, 5, ticks);
}, 1);
this.particlePlayers.clear();
DataManager dataManager = this.playerParticles.getManager(DataManager.class);
dataManager.loadFixedEffects();
for (Player player : Bukkit.getOnlinePlayers())
dataManager.getPPlayer(player.getUniqueId(), (pplayer) -> { }); // Loads the PPlayer from the database
}
@Override
public void disable() {
if (this.particleTask != null)
this.particleTask.cancel();
}
/**
* Adds the player to the array when they join
@ -49,7 +80,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent e) {
DataManager.getPPlayer(e.getPlayer().getUniqueId(), (pplayer) -> { }); // Loads the PPlayer from the database
this.playerParticles.getManager(DataManager.class).getPPlayer(e.getPlayer().getUniqueId(), (pplayer) -> { }); // Loads the PPlayer from the database
}
/**
@ -59,8 +90,9 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent e) {
PPlayer pplayer = DataManager.getPPlayer(e.getPlayer().getUniqueId());
if (pplayer != null && pplayer.getFixedEffectIds().isEmpty()) particlePlayers.remove(pplayer); // Unload the PPlayer if they don't have any fixed effects
PPlayer pplayer = this.playerParticles.getManager(DataManager.class).getPPlayer(e.getPlayer().getUniqueId());
if (pplayer != null && pplayer.getFixedEffectIds().isEmpty())
this.particlePlayers.remove(pplayer); // Unload the PPlayer if they don't have any fixed effects
}
/**
@ -68,20 +100,8 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*
* @return The loaded PPlayers
*/
public static List<PPlayer> getPPlayers() {
return particlePlayers;
}
/**
* Loads all FixedParticleEffects from the database
* Loads all online PPlayers from the database
*/
public static void refreshData() {
particlePlayers.clear();
DataManager.loadFixedEffects();
for (Player player : Bukkit.getOnlinePlayers()) {
DataManager.getPPlayer(player.getUniqueId(), (pplayer) -> { }); // Loads the PPlayer from the database
}
public List<PPlayer> getPPlayers() {
return this.particlePlayers;
}
/**
@ -89,31 +109,33 @@ public class ParticleManager extends BukkitRunnable implements Listener {
* Does not display particles if the world is disabled or if the player is in spectator mode
*/
public void run() {
ParticleStyleManager.updateTimers();
this.playerParticles.getManager(ParticleStyleManager.class).updateTimers();
hue += PSetting.RAINBOW_CYCLE_SPEED.getInt();
hue %= 360;
this.hue += Setting.RAINBOW_CYCLE_SPEED.getInt();
this.hue %= 360;
if (hue % 4 == 0) { // Only increment note by 5 notes per second
note++;
note %= 25;
if (this.hue % 4 == 0) { // Only increment note by 5 notes per second
this.note++;
this.note %= 25;
}
PermissionManager permissionManager = this.playerParticles.getManager(PermissionManager.class);
// Loop over backwards so we can remove pplayers if need be
for (int i = particlePlayers.size() - 1; i >= 0; i--) {
PPlayer pplayer = particlePlayers.get(i);
for (int i = this.particlePlayers.size() - 1; i >= 0; i--) {
PPlayer pplayer = this.particlePlayers.get(i);
Player player = pplayer.getPlayer();
// Don't show their particles if they are in spectator mode
// Don't spawn particles if the world doesn't allow it
if (player != null && player.getGameMode() != GameMode.SPECTATOR && PermissionManager.isWorldEnabled(player.getWorld().getName()))
if (player != null && player.getGameMode() != GameMode.SPECTATOR && permissionManager.isWorldEnabled(player.getWorld().getName()))
for (ParticlePair particles : pplayer.getActiveParticles())
this.displayParticles(pplayer, particles, player.getLocation().clone().add(0, 1, 0));
// Loop for FixedParticleEffects
// Don't spawn particles if the world doesn't allow it
for (FixedParticleEffect effect : pplayer.getFixedParticles())
if (PermissionManager.isWorldEnabled(effect.getLocation().getWorld().getName()))
if (effect.getLocation().getWorld() != null && permissionManager.isWorldEnabled(effect.getLocation().getWorld().getName()))
this.displayFixedParticleEffect(effect);
}
}
@ -126,8 +148,8 @@ public class ParticleManager extends BukkitRunnable implements Listener {
* @param location The location to display at
*/
private void displayParticles(PPlayer pplayer, ParticlePair particle, Location location) {
if (!ParticleStyleManager.isCustomHandled(particle.getStyle())) {
if (PSetting.TOGGLE_ON_MOVE.getBoolean() && particle.getStyle().canToggleWithMovement() && pplayer.isMoving()) {
if (!this.playerParticles.getManager(ParticleStyleManager.class).isCustomHandled(particle.getStyle())) {
if (Setting.TOGGLE_ON_MOVE.getBoolean() && particle.getStyle().canToggleWithMovement() && pplayer.isMoving()) {
for (PParticle pparticle : DefaultStyles.FEET.getParticles(particle, location))
ParticleEffect.display(particle, pparticle, false, pplayer.getPlayer());
} else {
@ -143,7 +165,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
* @param particle The ParticlePair to use for getting particle settings
* @param particles The particles to display
*/
public static void displayParticles(ParticlePair particle, List<PParticle> particles) {
public void displayParticles(ParticlePair particle, List<PParticle> particles) {
for (PParticle pparticle : particles)
ParticleEffect.display(particle, pparticle, false, Bukkit.getPlayer(particle.getOwnerUniqueId()));
}
@ -164,8 +186,8 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*
* @return The rainbow OrdinaryColor for particle spawning with data 'rainbow'
*/
public static OrdinaryColor getRainbowParticleColor() {
Color rgb = Color.getHSBColor(hue / 360F, 1.0F, 1.0F);
public OrdinaryColor getRainbowParticleColor() {
Color rgb = Color.getHSBColor(this.hue / 360F, 1.0F, 1.0F);
return new OrdinaryColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue());
}
@ -174,8 +196,8 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*
* @return The rainbow NoteColor for particle spawning with data 'rainbow'
*/
public static NoteColor getRainbowNoteParticleColor() {
return new NoteColor(note);
public NoteColor getRainbowNoteParticleColor() {
return new NoteColor(this.note);
}
/**
@ -183,8 +205,8 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*
* @return A randomized OrdinaryColor for particle spawning with data 'random'
*/
public static OrdinaryColor getRandomParticleColor() {
Color rgb = new Color(RANDOM.nextInt(256), RANDOM.nextInt(256), RANDOM.nextInt(256));
public OrdinaryColor getRandomParticleColor() {
Color rgb = new Color(this.RANDOM.nextInt(256), this.RANDOM.nextInt(256), this.RANDOM.nextInt(256));
return new OrdinaryColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue());
}
@ -193,8 +215,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*
* @return A randomized NoteColor for particle spawning with data 'random'
*/
public static NoteColor getRandomNoteParticleColor() {
return new NoteColor(RANDOM.nextInt(25));
public NoteColor getRandomNoteParticleColor() {
return new NoteColor(this.RANDOM.nextInt(25));
}
}

View file

@ -0,0 +1,101 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.ParticleStyle;
import java.util.ArrayList;
import java.util.List;
public class ParticleStyleManager extends Manager {
/**
* Arrays that contain all registered styles
*/
private List<ParticleStyle> styles = new ArrayList<>();
private List<ParticleStyle> customHandledStyles = new ArrayList<>();
public ParticleStyleManager(PlayerParticles playerParticles) {
super(playerParticles);
DefaultStyles.registerStyles(this);
}
@Override
public void reload() {
// Styles List is never reset so you don't need to re-register styles each time the plugin reloads
}
@Override
public void disable() {
}
/**
* Registers a style that is put into the plugin's update loop
*
* @param style The style to add
*/
public void registerStyle(ParticleStyle style) {
if (style == null) {
PlayerParticles.getInstance().getLogger().severe("Tried to register a null style");
return;
}
if (style.getName() == null || style.getName().trim().equals("")) {
PlayerParticles.getInstance().getLogger().severe("Tried to register a style with a null or empty name: '" + style.getName() + "'");
return;
}
for (ParticleStyle testAgainst : this.styles) {
if (testAgainst.getName().equalsIgnoreCase(style.getName())) {
PlayerParticles.getInstance().getLogger().severe("Tried to register two styles with the same name spelling: '" + style.getName() + "'");
return;
} else if (testAgainst.equals(style)) {
PlayerParticles.getInstance().getLogger().severe("Tried to register the same style twice: '" + style.getName() + "'");
return;
}
}
this.styles.add(style);
}
/**
* Registers a style that isn't updated on the normal update loop
*
* @param style The style to register
*/
public void registerCustomHandledStyle(ParticleStyle style) {
this.registerStyle(style);
this.customHandledStyles.add(style);
}
/**
* Returns if a given style is customly handled
*
* @param style The style to check
* @return If the style is handled in a custom manner
*/
public boolean isCustomHandled(ParticleStyle style) {
return this.customHandledStyles.contains(style);
}
/**
* Gets all registered styles
*
* @return A List of ParticleStyles that are registered
*/
public List<ParticleStyle> getStyles() {
return this.styles;
}
/**
* Updates all the timers for the particle styles to make the animations
*
* Do not call this in your plugin, it will mess with other styles
*/
public void updateTimers() {
for (ParticleStyle style : this.styles)
style.updateTimers();
}
}

View file

@ -1,20 +1,18 @@
package dev.esophose.playerparticles.manager;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.styles.api.ParticleStyleManager;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.ParticleStyle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
public class PermissionManager {
public class PermissionManager extends Manager {
private static final String PERMISSION_PREFIX = "playerparticles.";
@ -66,18 +64,30 @@ public class PermissionManager {
}
}
private PermissionManager() {
public PermissionManager(PlayerParticles playerParticles) {
super(playerParticles);
}
@Override
public void reload() {
}
@Override
public void disable() {
}
/**
* Checks if a player can use /ppo
*
* @param sender The CommandSender to check
* @return If the player can use /ppo
*/
public static boolean canOverride(CommandSender sender) {
if (!(sender instanceof Player)) return true;
public boolean canOverride(CommandSender sender) {
if (!(sender instanceof Player))
return true;
return PPermission.ALL.check(sender);
}
@ -87,10 +97,14 @@ public class PermissionManager {
* @param pplayer The player to check
* @return If the player has reached the max number of particles in their active group
*/
public static boolean hasPlayerReachedMaxParticles(PPlayer pplayer) {
if (PPermission.ALL.check(pplayer.getPlayer())) return false;
if (PPermission.PARTICLES_UNLIMITED.check(pplayer.getPlayer())) return false;
return pplayer.getActiveParticles().size() >= PSetting.MAX_PARTICLES.getInt();
public boolean hasPlayerReachedMaxParticles(PPlayer pplayer) {
if (PPermission.ALL.check(pplayer.getPlayer()))
return false;
if (PPermission.PARTICLES_UNLIMITED.check(pplayer.getPlayer()))
return false;
return pplayer.getActiveParticles().size() >= Setting.MAX_PARTICLES.getInt();
}
/**
@ -99,10 +113,14 @@ public class PermissionManager {
* @param pplayer The player to check
* @return If the player has reached the max number of saved particle groups
*/
public static boolean hasPlayerReachedMaxGroups(PPlayer pplayer) {
if (PPermission.ALL.check(pplayer.getPlayer())) return false;
if (PPermission.GROUPS_UNLIMITED.check(pplayer.getPlayer())) return false;
return pplayer.getParticleGroups().size() - 1 >= PSetting.MAX_GROUPS.getInt();
public boolean hasPlayerReachedMaxGroups(PPlayer pplayer) {
if (PPermission.ALL.check(pplayer.getPlayer()))
return false;
if (PPermission.GROUPS_UNLIMITED.check(pplayer.getPlayer()))
return false;
return pplayer.getParticleGroups().size() - 1 >= Setting.MAX_GROUPS.getInt();
}
/**
@ -111,10 +129,14 @@ public class PermissionManager {
* @param pplayer The player to check
* @return If the player has permission to save groups
*/
public static boolean canPlayerSaveGroups(PPlayer pplayer) {
if (PPermission.ALL.check(pplayer.getPlayer())) return true;
if (PPermission.GROUPS_UNLIMITED.check(pplayer.getPlayer())) return true;
return PSetting.MAX_GROUPS.getInt() != 0;
public boolean canPlayerSaveGroups(PPlayer pplayer) {
if (PPermission.ALL.check(pplayer.getPlayer()))
return true;
if (PPermission.GROUPS_UNLIMITED.check(pplayer.getPlayer()))
return true;
return Setting.MAX_GROUPS.getInt() != 0;
}
/**
@ -123,10 +145,14 @@ public class PermissionManager {
* @param pplayer The player to check
* @return If the player has reached the max number of fixed effects
*/
public static boolean hasPlayerReachedMaxFixedEffects(PPlayer pplayer) {
if (PPermission.ALL.check(pplayer.getPlayer())) return false;
if (PPermission.FIXED_UNLIMITED.check(pplayer.getPlayer())) return false;
return pplayer.getFixedEffectIds().size() >= PSetting.MAX_FIXED_EFFECTS.getInt();
public boolean hasPlayerReachedMaxFixedEffects(PPlayer pplayer) {
if (PPermission.ALL.check(pplayer.getPlayer()))
return false;
if (PPermission.FIXED_UNLIMITED.check(pplayer.getPlayer()))
return false;
return pplayer.getFixedEffectIds().size() >= Setting.MAX_FIXED_EFFECTS.getInt();
}
/**
@ -134,8 +160,8 @@ public class PermissionManager {
*
* @return The max distance a fixed effect can be created from the player
*/
public static int getMaxFixedEffectCreationDistance() {
return PSetting.MAX_FIXED_EFFECT_CREATION_DISTANCE.getInt();
public int getMaxFixedEffectCreationDistance() {
return Setting.MAX_FIXED_EFFECT_CREATION_DISTANCE.getInt();
}
/**
@ -144,9 +170,11 @@ public class PermissionManager {
* @param player The player to check
* @return The maximum number of particles based on the config.yml value, or unlimited
*/
public static int getMaxParticlesAllowed(Player player) {
if (PPermission.ALL.check(player) || PPermission.PARTICLES_UNLIMITED.check(player)) return Integer.MAX_VALUE;
return PSetting.MAX_PARTICLES.getInt();
public int getMaxParticlesAllowed(Player player) {
if (PPermission.ALL.check(player) || PPermission.PARTICLES_UNLIMITED.check(player))
return Integer.MAX_VALUE;
return Setting.MAX_PARTICLES.getInt();
}
/**
@ -155,8 +183,8 @@ public class PermissionManager {
* @param world The world name to check
* @return True if the world is disabled
*/
public static boolean isWorldEnabled(String world) {
return !getDisabledWorlds().contains(world);
public boolean isWorldEnabled(String world) {
return !this.getDisabledWorlds().contains(world);
}
/**
@ -164,8 +192,8 @@ public class PermissionManager {
*
* @return All world names that are disabled
*/
public static List<String> getDisabledWorlds() {
return PSetting.DISABLED_WORLDS.getStringList();
public List<String> getDisabledWorlds() {
return Setting.DISABLED_WORLDS.getStringList();
}
/**
@ -175,7 +203,7 @@ public class PermissionManager {
* @param effect The effect to check
* @return True if the player has permission to use the effect
*/
public static boolean hasEffectPermission(Player player, ParticleEffect effect) {
public boolean hasEffectPermission(Player player, ParticleEffect effect) {
if (PPermission.ALL.check(player) || PPermission.EFFECT_ALL.check(player)) return true;
return PPermission.EFFECT.check(player, effect.getName());
}
@ -188,7 +216,7 @@ public class PermissionManager {
* @param style The style to check
* @return If the player has permission to use the style
*/
public static boolean hasStylePermission(Player player, ParticleStyle style) {
public boolean hasStylePermission(Player player, ParticleStyle style) {
if (style == DefaultStyles.NORMAL) return true;
if (PPermission.ALL.check(player) || PPermission.STYLE_ALL.check(player)) return true;
return PPermission.STYLE.check(player, style.getName());
@ -200,10 +228,10 @@ public class PermissionManager {
* @param p The player to get effect names for
* @return A String List of all effect names the given player has permission for
*/
public static List<String> getEffectNamesUserHasPermissionFor(Player p) {
public List<String> getEffectNamesUserHasPermissionFor(Player p) {
List<String> list = new ArrayList<>();
for (ParticleEffect pe : ParticleEffect.getSupportedEffects())
if (hasEffectPermission(p, pe))
if (this.hasEffectPermission(p, pe))
list.add(pe.getName());
return list;
}
@ -214,10 +242,10 @@ public class PermissionManager {
* @param p The player to get style names for
* @return A String List of all style names the given player has permission for
*/
public static List<String> getStyleNamesUserHasPermissionFor(Player p) {
public List<String> getStyleNamesUserHasPermissionFor(Player p) {
List<String> list = new ArrayList<>();
for (ParticleStyle ps : ParticleStyleManager.getStyles())
if (hasStylePermission(p, ps))
for (ParticleStyle ps : this.playerParticles.getManager(ParticleStyleManager.class).getStyles())
if (this.hasStylePermission(p, ps))
list.add(ps.getName());
return list;
}
@ -228,10 +256,10 @@ public class PermissionManager {
* @param p The player to get style names for
* @return A String List of all fixable style names the given player has permission for
*/
public static List<String> getFixableStyleNamesUserHasPermissionFor(Player p) {
public List<String> getFixableStyleNamesUserHasPermissionFor(Player p) {
List<String> list = new ArrayList<>();
for (ParticleStyle ps : ParticleStyleManager.getStyles())
if (ps.canBeFixed() && hasStylePermission(p, ps))
for (ParticleStyle ps : this.playerParticles.getManager(ParticleStyleManager.class).getStyles())
if (ps.canBeFixed() && this.hasStylePermission(p, ps))
list.add(ps.getName());
return list;
}
@ -242,10 +270,10 @@ public class PermissionManager {
* @param p The player to get effects for
* @return A List of all effects the given player has permission for
*/
public static List<ParticleEffect> getEffectsUserHasPermissionFor(Player p) {
public List<ParticleEffect> getEffectsUserHasPermissionFor(Player p) {
List<ParticleEffect> list = new ArrayList<>();
for (ParticleEffect pe : ParticleEffect.getSupportedEffects())
if (hasEffectPermission(p, pe))
if (this.hasEffectPermission(p, pe))
list.add(pe);
return list;
}
@ -256,10 +284,10 @@ public class PermissionManager {
* @param p The player to get styles for
* @return A List of all styles the given player has permission for
*/
public static List<ParticleStyle> getStylesUserHasPermissionFor(Player p) {
public List<ParticleStyle> getStylesUserHasPermissionFor(Player p) {
List<ParticleStyle> list = new ArrayList<>();
for (ParticleStyle ps : ParticleStyleManager.getStyles())
if (hasStylePermission(p, ps))
for (ParticleStyle ps : this.playerParticles.getManager(ParticleStyleManager.class).getStyles())
if (this.hasStylePermission(p, ps))
list.add(ps);
return list;
}
@ -270,7 +298,7 @@ public class PermissionManager {
* @param player The player to check the permission for
* @return True if the player has permission
*/
public static boolean canUseFixedEffects(Player player) {
public boolean canUseFixedEffects(Player player) {
return PPermission.ALL.check(player) || PPermission.FIXED.check(player);
}
@ -280,7 +308,7 @@ public class PermissionManager {
* @param player The player to check the permission for
* @return True if the player has permission to use /pp fixed clear
*/
public static boolean canClearFixedEffects(Player player) {
public boolean canClearFixedEffects(Player player) {
return PPermission.ALL.check(player) || PPermission.FIXED_CLEAR.check(player);
}
@ -290,7 +318,7 @@ public class PermissionManager {
* @param sender The sender to check the permission for
* @return True if the sender has permission to reload the plugin's settings
*/
public static boolean canReloadPlugin(CommandSender sender) {
public boolean canReloadPlugin(CommandSender sender) {
return PPermission.ALL.check(sender) || PPermission.RELOAD.check(sender);
}

View file

@ -0,0 +1,59 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.util.StringPlaceholders;
import dev.esophose.playerparticles.util.Updater;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class PluginUpdateManager extends Manager implements Listener {
private String updateVersion;
public PluginUpdateManager(PlayerParticles playerParticles) {
super(playerParticles);
Bukkit.getPluginManager().registerEvents(this, this.playerParticles);
}
@Override
public void reload() {
if (Setting.CHECK_UPDATES.getBoolean()) {
Bukkit.getScheduler().runTaskAsynchronously(this.playerParticles, () -> {
try { // This can throw an exception if the server has no internet connection or if the Curse API is down
Updater updater = new Updater(this.playerParticles, 82823, this.playerParticles.getJarFile(), Updater.UpdateType.NO_DOWNLOAD, false);
if (Double.parseDouble(updater.getLatestName().replaceAll("PlayerParticles v", "")) > Double.parseDouble(this.playerParticles.getDescription().getVersion())) {
this.updateVersion = updater.getLatestName().replaceAll("PlayerParticles v", "");
this.playerParticles.getLogger().info("An update (v" + this.updateVersion + ") is available! You are running v" + this.playerParticles.getDescription().getVersion());
}
} catch (Exception e) {
this.playerParticles.getLogger().warning("An error occurred checking for an update. There is either no established internet connection or the Curse API is down.");
}
});
}
}
@Override
public void disable() {
}
/**
* Called when a player joins and notifies ops if an update is available
*
* @param e The join event
*/
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
if (e.getPlayer().isOp() && this.updateVersion != null) {
PlayerParticles.getInstance().getManager(LocaleManager.class).sendMessage(
e.getPlayer(),
"update-available",
StringPlaceholders.builder("new", this.updateVersion).addPlaceholder("current", this.playerParticles.getDescription().getVersion()).build());
}
}
}

View file

@ -1,288 +0,0 @@
package dev.esophose.playerparticles.manager;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Material;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.particles.ParticleEffect;
public class SettingManager {
/**
* The types of settings that can be loaded
*/
private enum PSettingType {
BOOLEAN,
INTEGER,
LONG,
DOUBLE,
STRING,
STRING_LIST
}
/**
* An enum containing all settings in the config.yml for the plugin
*/
public enum PSetting {
VERSION(PSettingType.DOUBLE),
TICKS_PER_PARTICLE(PSettingType.LONG),
CHECK_UPDATES(PSettingType.BOOLEAN),
SEND_METRICS(PSettingType.BOOLEAN),
GUI_ENABLED(PSettingType.BOOLEAN),
GUI_PRESETS_ONLY(PSettingType.BOOLEAN),
GUI_CLOSE_AFTER_GROUP_SELECTED(PSettingType.BOOLEAN),
GUI_BUTTON_SOUND(PSettingType.BOOLEAN),
TOGGLE_ON_MOVE(PSettingType.BOOLEAN),
TOGGLE_ON_MOVE_DELAY(PSettingType.INTEGER),
PARTICLE_RENDER_RANGE_PLAYER(PSettingType.INTEGER),
PARTICLE_RENDER_RANGE_FIXED_EFFECT(PSettingType.INTEGER),
MESSAGES_ENABLED(PSettingType.BOOLEAN),
USE_MESSAGE_PREFIX(PSettingType.BOOLEAN),
MESSAGE_PREFIX(PSettingType.STRING),
DATABASE_ENABLE(PSettingType.BOOLEAN),
DATABASE_HOSTNAME(PSettingType.STRING),
DATABASE_PORT(PSettingType.STRING),
DATABASE_NAME(PSettingType.STRING),
DATABASE_USER_NAME(PSettingType.STRING),
DATABASE_USER_PASSWORD(PSettingType.STRING),
DATABASE_USE_SSL(PSettingType.BOOLEAN),
MAX_FIXED_EFFECTS(PSettingType.INTEGER),
MAX_FIXED_EFFECT_CREATION_DISTANCE(PSettingType.INTEGER),
MAX_PARTICLES(PSettingType.INTEGER),
MAX_GROUPS(PSettingType.INTEGER),
RAINBOW_CYCLE_SPEED(PSettingType.INTEGER),
DISABLED_WORLDS(PSettingType.STRING_LIST),
LANG_FILE(PSettingType.STRING);
private final PSettingType settingType;
private Object value = null;
PSetting(PSettingType settingType) {
this.settingType = settingType;
}
/**
* Resets the setting's value so it will be fetched from the config the next time it's needed
*/
private void resetDefault() {
this.value = null;
}
/**
* Gets the value from cache, or the config.yml if it isn't loaded yet
*
* @return The value of this setting
*/
private Object getValue() {
if (this.value == null) {
String configPath = this.name().toLowerCase().replaceAll("_", "-");
switch (this.settingType) {
case BOOLEAN:
this.value = PlayerParticles.getPlugin().getConfig().getBoolean(configPath);
break;
case INTEGER:
this.value = PlayerParticles.getPlugin().getConfig().getInt(configPath);
break;
case LONG:
this.value = PlayerParticles.getPlugin().getConfig().getLong(configPath);
break;
case DOUBLE:
this.value = PlayerParticles.getPlugin().getConfig().getDouble(configPath);
break;
case STRING:
this.value = PlayerParticles.getPlugin().getConfig().getString(configPath);
break;
case STRING_LIST:
this.value = PlayerParticles.getPlugin().getConfig().getStringList(configPath);
break;
}
}
return this.value;
}
/**
* Gets the setting's value as a boolean
*
* @return The setting's value as a boolean
*/
public boolean getBoolean() {
return (boolean) this.getValue();
}
/**
* Gets the setting's value as an int
*
* @return The setting's value as an int
*/
public int getInt() {
return (int) this.getValue();
}
/**
* Gets the setting's value as a long
*
* @return The setting's value as a long
*/
public long getLong() {
return (long) this.getValue();
}
/**
* Gets the setting's value as a double
*
* @return The setting's value as a double
*/
public double getDouble() {
return (double) this.getValue();
}
/**
* Gets the setting's value as a String
*
* @return The setting's value as a String
*/
public String getString() {
return (String) this.getValue();
}
/**
* Gets the setting's value as a List of Strings
*
* @return The setting's value as a List of Strings
*/
@SuppressWarnings("unchecked")
public List<String> getStringList() {
return (List<String>) this.getValue();
}
/**
* Gets the setting's value as a Material
*
* @return The setting's value as a Material
*/
public Material getMaterial() {
return (Material) this.getValue();
}
}
/**
* Used for grabbing/caching configurable GUI Icons from the config.yml
*/
public enum GuiIcon {
PARTICLES,
GROUPS,
PRESET_GROUPS,
BACK,
NEXT_PAGE,
PREVIOUS_PAGE,
CREATE,
EDIT_EFFECT,
EDIT_STYLE,
EDIT_DATA,
RESET,
EFFECT,
STYLE;
private Map<String, Material> materials;
GuiIcon() {
this.materials = new HashMap<>();
}
/**
* Gets the Material for this icon from the 'gui-icon.misc' section in the config.yml
* Tries to get from cache first, otherwise loads it
*
* @return The Material for this Icon
*/
public Material get() {
return this.getInternal("gui-icon.misc." + this.name().toLowerCase());
}
/**
* Gets the Material for a subsection of this icon in the config.yml
* Tries to get from cache first, otherwise loads it
*
* @param subsection The name of the icon in the section
* @return The Material for this Icon
*/
public Material get(String subsection) {
return this.getInternal("gui-icon." + this.name().toLowerCase() + "." + subsection);
}
/**
* Gets the Material for this icon
* Tries to get from cache first, otherwise loads it
*
* @param configPath Where to look in the config.yml for the Material name
* @return The path in the config.yml to lookup
*/
private Material getInternal(String configPath) {
Material material = this.materials.get(configPath);
if (material != null)
return material;
List<String> materials = PlayerParticles.getPlugin().getConfig().getStringList(configPath);
try {
if (materials.size() == 1) {
material = ParticleUtils.closestMatch(materials.get(0));
} else {
if (ParticleEffect.VERSION_13) {
material = ParticleUtils.closestMatch(materials.get(0));
} else {
material = ParticleUtils.closestMatch(materials.get(1));
}
}
} catch (Exception e) {
PlayerParticles.getPlugin().getLogger().severe("Missing GUI icon for '" + this.name().toLowerCase() + "'");
}
if (material == null)
material = Material.BARRIER;
this.materials.put(configPath, material);
return material;
}
/**
* Resets the setting's value so it will be fetched from the config the next time it's needed
*/
private void resetDefault() {
this.materials = new HashMap<>();
}
}
private SettingManager() {
}
/**
* Resets the settings to their default values
*/
public static void reload() {
for (PSetting setting : PSetting.values())
setting.resetDefault();
for (GuiIcon icon : GuiIcon.values())
icon.resetDefault();
}
}

View file

@ -1,7 +1,6 @@
package dev.esophose.playerparticles.particles;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;

View file

@ -1,9 +1,8 @@
package dev.esophose.playerparticles.particles;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.command.CommandSender;
public class OtherPPlayer extends PPlayer {

View file

@ -1,4 +1,4 @@
package dev.esophose.playerparticles.styles.api;
package dev.esophose.playerparticles.particles;
import org.bukkit.Location;

View file

@ -1,11 +1,10 @@
package dev.esophose.playerparticles.particles;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View file

@ -1,40 +1,40 @@
package dev.esophose.playerparticles.particles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.DataManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import dev.esophose.playerparticles.PlayerParticles;
public class PPlayerMovementListener implements Listener {
private static final int CHECK_INTERVAL = 3;
private Map<UUID, Integer> timeSinceLastMovement = new HashMap<>();
public PPlayerMovementListener() {
Bukkit.getScheduler().runTaskTimer(PlayerParticles.getPlugin(), () -> {
if (!PSetting.TOGGLE_ON_MOVE.getBoolean()) return;
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
Bukkit.getScheduler().runTaskTimer(PlayerParticles.getInstance(), () -> {
if (!Setting.TOGGLE_ON_MOVE.getBoolean()) return;
List<UUID> toRemove = new ArrayList<>();
for (UUID uuid : this.timeSinceLastMovement.keySet()) {
PPlayer pplayer = DataManager.getPPlayer(uuid);
PPlayer pplayer = dataManager.getPPlayer(uuid);
if (pplayer == null) {
toRemove.add(uuid);
} else {
int standingTime = this.timeSinceLastMovement.get(uuid);
pplayer.setMoving(standingTime < PSetting.TOGGLE_ON_MOVE_DELAY.getInt());
if (standingTime < PSetting.TOGGLE_ON_MOVE_DELAY.getInt())
pplayer.setMoving(standingTime < Setting.TOGGLE_ON_MOVE_DELAY.getInt());
if (standingTime < Setting.TOGGLE_ON_MOVE_DELAY.getInt())
this.timeSinceLastMovement.replace(uuid, standingTime + CHECK_INTERVAL);
}
}
@ -51,8 +51,8 @@ public class PPlayerMovementListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) {
if (!PSetting.TOGGLE_ON_MOVE.getBoolean()) return;
if (event.getTo().getBlockX() == event.getFrom().getBlockX() && event.getTo().getBlockY() == event.getFrom().getBlockY() && event.getTo().getBlockZ() == event.getFrom().getBlockZ()) return;
if (!Setting.TOGGLE_ON_MOVE.getBoolean()) return;
if (event.getTo() != null && event.getTo().getBlock() == event.getFrom().getBlock()) return;
UUID playerUUID = event.getPlayer().getUniqueId();
if (!this.timeSinceLastMovement.containsKey(playerUUID)) {

View file

@ -1,5 +1,9 @@
package dev.esophose.playerparticles.particles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.util.NMSUtil;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -8,11 +12,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import dev.esophose.playerparticles.util.NMSUtil;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
import dev.esophose.playerparticles.styles.api.PParticle;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
@ -20,7 +19,6 @@ import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.metadata.MetadataValue;
@SuppressWarnings("deprecation")
@ -43,6 +41,7 @@ public enum ParticleEffect {
DAMAGE_INDICATOR("DAMAGE_INDICATOR", "DAMAGE_INDICATOR"),
DOLPHIN("DOLPHIN", null),
DRAGON_BREATH("DRAGON_BREATH", "DRAGON_BREATH"),
DRIPPING_HONEY("DRIPPING_HONEY", null),
DRIPPING_LAVA("DRIP_LAVA", "DRIP_LAVA"),
DRIPPING_WATER("DRIP_WATER", "DRIP_WATER"),
DUST("REDSTONE", "REDSTONE", ParticleProperty.COLORABLE),
@ -329,9 +328,9 @@ public enum ParticleEffect {
*/
private List<Player> getPlayersInRange(Location center, boolean isFixedEffect, Player owner) {
List<Player> players = new ArrayList<>();
int range = !isFixedEffect ? PSetting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : PSetting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt();
int range = !isFixedEffect ? Setting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : Setting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt();
for (PPlayer pplayer : ParticleManager.getPPlayers()) {
for (PPlayer pplayer : PlayerParticles.getInstance().getManager(ParticleManager.class).getPPlayers()) {
Player p = pplayer.getPlayer();
if (!isFixedEffect && !this.canSee(p, owner))
continue;

View file

@ -1,10 +1,10 @@
package dev.esophose.playerparticles.particles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.PermissionManager;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
public class ParticleGroup {
@ -53,16 +53,18 @@ public class ParticleGroup {
* @return True if the player has permission
*/
public boolean canPlayerUse(Player player) {
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
// Make sure the player has permission for the number of particles in this group
if (PermissionManager.getMaxParticlesAllowed(player) < this.particles.size())
if (permissionManager.getMaxParticlesAllowed(player) < this.particles.size())
return false;
// Make sure the player has permission for all effects/styles in the group
for (ParticlePair particle : this.particles) {
if (!PermissionManager.hasEffectPermission(player, particle.getEffect()))
if (!permissionManager.hasEffectPermission(player, particle.getEffect()))
return false;
if (!PermissionManager.hasStylePermission(player, particle.getStyle()))
if (!permissionManager.hasStylePermission(player, particle.getStyle()))
return false;
}

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.particles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.PermissionManager;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -45,6 +46,8 @@ public class ParticleGroupPreset {
* @return True if the player has permission
*/
public boolean canPlayerUse(Player player) {
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
// If this particle group has a permission, does the player have it?
if (!this.permission.isEmpty())
if (!player.hasPermission(this.permission))
@ -55,15 +58,15 @@ public class ParticleGroupPreset {
return true;
// Make sure the player has permission for the number of particles in this group
if (PermissionManager.getMaxParticlesAllowed(player) < this.group.getParticles().size())
if (permissionManager.getMaxParticlesAllowed(player) < this.group.getParticles().size())
return false;
// Make sure the player has permission for all effects/styles in the group
for (ParticlePair particle : this.group.getParticles()) {
if (!PermissionManager.hasEffectPermission(player, particle.getEffect()))
if (!permissionManager.hasEffectPermission(player, particle.getEffect()))
return false;
if (!PermissionManager.hasStylePermission(player, particle.getStyle()))
if (!permissionManager.hasStylePermission(player, particle.getStyle()))
return false;
}

View file

@ -1,20 +1,19 @@
package dev.esophose.playerparticles.particles;
import java.util.UUID;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Material;
public class ParticlePair {
@ -44,6 +43,16 @@ public class ParticlePair {
this.setNoteColor(noteColor);
}
/**
* Updates the particle's owner if it hasn't been set yet
*
* @param pplayer The new owner
*/
public void setOwner(PPlayer pplayer) {
if (this.ownerUUID == null)
this.ownerUUID = pplayer.getUniqueId();
}
/**
* Sets the player's particle effect
*
@ -194,19 +203,21 @@ public class ParticlePair {
* @return Gets the ParticleColor the current particle effect will spawn with
*/
public ParticleColor getSpawnColor() {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
if (this.effect.hasProperty(ParticleProperty.COLORABLE)) {
if (this.effect == ParticleEffect.NOTE) {
if (this.noteColor.getNote() == 99) {
return ParticleManager.getRainbowNoteParticleColor();
return particleManager.getRainbowNoteParticleColor();
} else if (this.noteColor.getNote() == 98) {
return ParticleManager.getRandomNoteParticleColor();
return particleManager.getRandomNoteParticleColor();
}
return this.noteColor;
} else {
if (this.color.getRed() == 999 && this.color.getGreen() == 999 && this.color.getBlue() == 999) {
return ParticleManager.getRainbowParticleColor();
return particleManager.getRainbowParticleColor();
} else if (this.color.getRed() == 998 && this.color.getGreen() == 998 && this.color.getBlue() == 998) {
return ParticleManager.getRandomParticleColor();
return particleManager.getRandomParticleColor();
} else {
return this.color;
}
@ -237,6 +248,7 @@ public class ParticlePair {
* @return The particle data in a human-readable string
*/
public String getDataString() {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (this.effect == ParticleEffect.BLOCK || this.effect == ParticleEffect.FALLING_DUST) {
return this.blockMaterial.toString().toLowerCase();
} else if (this.effect == ParticleEffect.ITEM) {
@ -244,22 +256,22 @@ public class ParticlePair {
} else if (this.effect.hasProperty(ParticleProperty.COLORABLE)) {
if (this.effect == ParticleEffect.NOTE) {
if (this.noteColor.getNote() == 99) {
return LangManager.getText(Lang.RAINBOW);
return localeManager.getLocaleMessage("rainbow");
} else if (this.noteColor.getNote() == 98) {
return LangManager.getText(Lang.RANDOM);
return localeManager.getLocaleMessage("random");
}
return LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, this.noteColor.getNote());
return localeManager.getLocaleMessage("gui-select-data-note", StringPlaceholders.single("note", this.noteColor.getNote()));
} else {
if (this.color.getRed() == 999 && this.color.getGreen() == 999 && this.color.getBlue() == 999) {
return LangManager.getText(Lang.RAINBOW);
return localeManager.getLocaleMessage("rainbow");
} else if (this.color.getRed() == 998 && this.color.getGreen() == 998 && this.color.getBlue() == 998) {
return LangManager.getText(Lang.RANDOM);
return localeManager.getLocaleMessage("random");
} else {
return ChatColor.RED + "" + this.color.getRed() + " " + ChatColor.GREEN + this.color.getGreen() + " " + ChatColor.AQUA + this.color.getBlue();
}
}
}
return LangManager.getText(Lang.GUI_DATA_NONE);
return localeManager.getLocaleMessage("gui-data-none");
}
/**

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.styles.api.ParticleStyleManager;
public class DefaultStyles {
/**
@ -51,49 +48,49 @@ public class DefaultStyles {
* Registers all the default styles to the ParticleStyleManager
* Registered in alphabetical order
*/
public static void registerStyles() {
ParticleStyleManager.registerStyle(ARROWS);
ParticleStyleManager.registerStyle(BATMAN);
ParticleStyleManager.registerStyle(BEAM);
ParticleStyleManager.registerCustomHandledStyle(BLOCKBREAK);
ParticleStyleManager.registerCustomHandledStyle(BLOCKPLACE);
ParticleStyleManager.registerStyle(CELEBRATION);
ParticleStyleManager.registerStyle(CHAINS);
ParticleStyleManager.registerStyle(COMPANION);
ParticleStyleManager.registerStyle(CUBE);
ParticleStyleManager.registerStyle(FEET);
ParticleStyleManager.registerStyle(HALO);
ParticleStyleManager.registerCustomHandledStyle(HURT);
ParticleStyleManager.registerStyle(INVOCATION);
ParticleStyleManager.registerCustomHandledStyle(MOVE);
ParticleStyleManager.registerStyle(NORMAL);
ParticleStyleManager.registerStyle(ORBIT);
ParticleStyleManager.registerStyle(OVERHEAD);
ParticleStyleManager.registerStyle(POINT);
ParticleStyleManager.registerStyle(POPPER);
ParticleStyleManager.registerStyle(PULSE);
ParticleStyleManager.registerStyle(QUADHELIX);
ParticleStyleManager.registerStyle(RINGS);
ParticleStyleManager.registerStyle(SPHERE);
ParticleStyleManager.registerStyle(SPIN);
ParticleStyleManager.registerStyle(SPIRAL);
ParticleStyleManager.registerCustomHandledStyle(SWORDS);
ParticleStyleManager.registerStyle(THICK);
ParticleStyleManager.registerStyle(TWINS);
ParticleStyleManager.registerStyle(VORTEX);
ParticleStyleManager.registerStyle(WHIRL);
ParticleStyleManager.registerStyle(WHIRLWIND);
ParticleStyleManager.registerStyle(WINGS);
public static void registerStyles(ParticleStyleManager particleStyleManager) {
particleStyleManager.registerStyle(ARROWS);
particleStyleManager.registerStyle(BATMAN);
particleStyleManager.registerStyle(BEAM);
particleStyleManager.registerCustomHandledStyle(BLOCKBREAK);
particleStyleManager.registerCustomHandledStyle(BLOCKPLACE);
particleStyleManager.registerStyle(CELEBRATION);
particleStyleManager.registerStyle(CHAINS);
particleStyleManager.registerStyle(COMPANION);
particleStyleManager.registerStyle(CUBE);
particleStyleManager.registerStyle(FEET);
particleStyleManager.registerStyle(HALO);
particleStyleManager.registerCustomHandledStyle(HURT);
particleStyleManager.registerStyle(INVOCATION);
particleStyleManager.registerCustomHandledStyle(MOVE);
particleStyleManager.registerStyle(NORMAL);
particleStyleManager.registerStyle(ORBIT);
particleStyleManager.registerStyle(OVERHEAD);
particleStyleManager.registerStyle(POINT);
particleStyleManager.registerStyle(POPPER);
particleStyleManager.registerStyle(PULSE);
particleStyleManager.registerStyle(QUADHELIX);
particleStyleManager.registerStyle(RINGS);
particleStyleManager.registerStyle(SPHERE);
particleStyleManager.registerStyle(SPIN);
particleStyleManager.registerStyle(SPIRAL);
particleStyleManager.registerCustomHandledStyle(SWORDS);
particleStyleManager.registerStyle(THICK);
particleStyleManager.registerStyle(TWINS);
particleStyleManager.registerStyle(VORTEX);
particleStyleManager.registerStyle(WHIRL);
particleStyleManager.registerStyle(WHIRLWIND);
particleStyleManager.registerStyle(WINGS);
// Register their events
PluginManager manager = Bukkit.getPluginManager();
Plugin playerParticles = PlayerParticles.getPlugin();
manager.registerEvents((Listener) ARROWS, playerParticles);
manager.registerEvents((Listener) BLOCKBREAK, playerParticles);
manager.registerEvents((Listener) BLOCKPLACE, playerParticles);
manager.registerEvents((Listener) HURT, playerParticles);
manager.registerEvents((Listener) MOVE, playerParticles);
manager.registerEvents((Listener) SWORDS, playerParticles);
PluginManager pluginManager = Bukkit.getPluginManager();
PlayerParticles playerParticles = PlayerParticles.getInstance();
pluginManager.registerEvents((Listener) ARROWS, playerParticles);
pluginManager.registerEvents((Listener) BLOCKBREAK, playerParticles);
pluginManager.registerEvents((Listener) BLOCKPLACE, playerParticles);
pluginManager.registerEvents((Listener) HURT, playerParticles);
pluginManager.registerEvents((Listener) MOVE, playerParticles);
pluginManager.registerEvents((Listener) SWORDS, playerParticles);
}
}

View file

@ -1,10 +1,11 @@
package dev.esophose.playerparticles.styles.api;
import java.util.List;
import org.bukkit.Location;
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.List;
import org.bukkit.Location;
public interface ParticleStyle {
@ -57,7 +58,7 @@ public interface ParticleStyle {
* @return The ParticleStyle with a matching name
*/
static ParticleStyle fromName(String styleName) {
for (ParticleStyle style : ParticleStyleManager.getStyles())
for (ParticleStyle style : PlayerParticles.getInstance().getManager(ParticleStyleManager.class).getStyles())
if (style.getName().equalsIgnoreCase(styleName))
return style;
return null;

View file

@ -1,8 +1,10 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -11,10 +13,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityShootBowEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ParticleStyleArrows implements ParticleStyle, Listener {
private static final String[] arrowEntityNames = new String[] { "ARROW", "SPECTRAL_ARROW", "TIPPED_ARROW" };
@ -27,7 +25,7 @@ public class ParticleStyleArrows implements ParticleStyle, Listener {
int count = 0;
for (int i = this.arrows.size() - 1; i >= 0; i--) { // Loop backwards so the last-fired arrows are the ones that have particles if they go over the max
Projectile arrow = this.arrows.get(i);
if (((Player) arrow.getShooter()).getUniqueId().equals(particle.getOwnerUniqueId())) {
if (arrow.getShooter() != null && ((Player) arrow.getShooter()).getUniqueId().equals(particle.getOwnerUniqueId())) {
particles.add(new PParticle(arrow.getLocation(), 0.05F, 0.05F, 0.05F, 0.0F));
count++;
}
@ -45,7 +43,7 @@ public class ParticleStyleArrows implements ParticleStyle, Listener {
public void updateTimers() {
for (int i = this.arrows.size() - 1; i >= 0; i--) {
Projectile arrow = this.arrows.get(i);
if (arrow.getTicksLived() >= 1200 || arrow.isDead() || !arrow.isValid())
if (arrow.getTicksLived() >= 1200 || arrow.isDead() || !arrow.isValid() || arrow.getShooter() == null)
this.arrows.remove(i);
}
}

View file

@ -1,22 +1,19 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.util.VectorUtils;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.util.VectorUtils;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleBatman implements ParticleStyle {
private int step = 0;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
if (step != 0) return particles;

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleBeam implements ParticleStyle {
private static double[] cos, sin;
@ -30,7 +27,7 @@ public class ParticleStyleBeam implements ParticleStyle {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
double radius = 1;
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < points; i++) {
double newX = location.getX() + radius * cos[i];
double newY = location.getY() + (step / 10D) - 1;

View file

@ -1,8 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -10,17 +15,10 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
location.add(0.5, 0.5, 0.5); // Center around the block
@ -52,12 +50,14 @@ public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
Player player = event.getPlayer();
PPlayer pplayer = DataManager.getPPlayer(player.getUniqueId());
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(player.getUniqueId());
if (pplayer != null) {
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.BLOCKBREAK)) {
Location loc = event.getBlock().getLocation().clone();
ParticleManager.displayParticles(particle, DefaultStyles.BLOCKBREAK.getParticles(particle, loc));
particleManager.displayParticles(particle, DefaultStyles.BLOCKBREAK.getParticles(particle, loc));
}
}
}

View file

@ -1,8 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -10,17 +15,10 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleBlockPlace implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
location.add(0.5, 0.5, 0.5); // Center around the block
@ -52,12 +50,14 @@ public class ParticleStyleBlockPlace implements ParticleStyle, Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
Player player = event.getPlayer();
PPlayer pplayer = DataManager.getPPlayer(player.getUniqueId());
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(player.getUniqueId());
if (pplayer != null) {
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.BLOCKPLACE)) {
Location loc = event.getBlock().getLocation().clone();
ParticleManager.displayParticles(particle, DefaultStyles.BLOCKPLACE.getParticles(particle, loc));
particleManager.displayParticles(particle, DefaultStyles.BLOCKPLACE.getParticles(particle, loc));
}
}
}

View file

@ -1,15 +1,5 @@
package dev.esophose.playerparticles.styles;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
@ -17,8 +7,15 @@ import dev.esophose.playerparticles.particles.FixedParticleEffect;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class ParticleStyleCelebration implements ParticleStyle {
@ -26,7 +23,7 @@ public class ParticleStyleCelebration implements ParticleStyle {
private final int spawnTime = 15;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
return new ArrayList<PParticle>();
return new ArrayList<>();
}
/**
@ -34,21 +31,24 @@ public class ParticleStyleCelebration implements ParticleStyle {
* This style uses two different effects, one is always 'firework'
*/
public void updateTimers() {
step++;
if (step == spawnTime) {
step = 0;
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
this.step++;
if (this.step == this.spawnTime) {
this.step = 0;
Random random = new Random();
for (PPlayer pplayer : ParticleManager.getPPlayers()) {
for (PPlayer pplayer : particleManager.getPPlayers()) {
Player player = pplayer.getPlayer();
if (player != null && player.getGameMode() != GameMode.SPECTATOR && PermissionManager.isWorldEnabled(player.getWorld().getName()))
if (player != null && player.getGameMode() != GameMode.SPECTATOR && permissionManager.isWorldEnabled(player.getWorld().getName()))
for (ParticlePair particle : pplayer.getActiveParticles())
if (particle.getStyle() == this)
spawnFirework(player.getLocation(), pplayer, particle, random);
if (particle.getStyle() == this)
this.spawnFirework(player.getLocation(), pplayer, particle, random);
for (FixedParticleEffect fixedEffect : pplayer.getFixedParticles())
if (fixedEffect.getParticlePair().getStyle() == this && PermissionManager.isWorldEnabled(fixedEffect.getLocation().getWorld().getName()))
spawnFirework(fixedEffect.getLocation(), pplayer, fixedEffect.getParticlePair(), random);
if (fixedEffect.getParticlePair().getStyle() == this && permissionManager.isWorldEnabled(fixedEffect.getLocation().getWorld().getName()))
this.spawnFirework(fixedEffect.getLocation(), pplayer, fixedEffect.getParticlePair(), random);
}
}
}
@ -60,6 +60,7 @@ public class ParticleStyleCelebration implements ParticleStyle {
double dz = Math.cos(angle) * distanceFrom;
final Location loc = location.clone().add(dx, 1, dz);
final int fuse = 3 + random.nextInt(3);
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
new BukkitRunnable() {
private Location location = loc;
@ -71,12 +72,12 @@ public class ParticleStyleCelebration implements ParticleStyle {
ParticlePair trail = ParticlePair.getNextDefault(pplayer);
trail.setEffect(ParticleEffect.FIREWORK);
trail.setStyle(DefaultStyles.CELEBRATION);
ParticleManager.displayParticles(trail, Collections.singletonList(new PParticle(this.location)));
particleManager.displayParticles(trail, Collections.singletonList(new PParticle(this.location)));
this.location.add(0, 0.25, 0);
} else {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < 40; i++) {
double radius = 0.6 + random.nextDouble() * 0.2;
double u = random.nextDouble();
@ -89,13 +90,13 @@ public class ParticleStyleCelebration implements ParticleStyle {
particles.add(new PParticle(this.location.clone().add(dx, dy, dz)));
}
ParticleManager.displayParticles(particle, particles);
particleManager.displayParticles(particle, particles);
this.cancel();
}
this.fuseTimer++;
}
}.runTaskTimer(PlayerParticles.getPlugin(), 0, 1);
}.runTaskTimer(PlayerParticles.getInstance(), 0, 1);
}
public String getName() {

View file

@ -1,18 +1,15 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleChains implements ParticleStyle {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
for (double n = -0.2; n < 0.6; n += 0.1) {
particles.add(new PParticle(location.clone().add(1 - n, n - 1.1, 1 - n)));

View file

@ -23,16 +23,13 @@
*/
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleCompanion implements ParticleStyle {
private int numParticles = 150;
@ -43,7 +40,7 @@ public class ParticleStyleCompanion implements ParticleStyle {
private int step = 0;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
Vector vector = new Vector();

View file

@ -23,17 +23,14 @@
*/
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.util.VectorUtils;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.util.VectorUtils;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
/**
* Credit goes to Slikey who made all this logic for drawing a cube out of particles
* The project this is from is called EffectLib and can be found here:
@ -50,7 +47,7 @@ public class ParticleStyleCube implements ParticleStyle {
private boolean skipNextStep = false; // Only spawn every 2 ticks
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> pparticles = new ArrayList<PParticle>();
List<PParticle> pparticles = new ArrayList<>();
if (!skipNextStep) {
double xRotation = 0, yRotation = 0, zRotation = 0;

View file

@ -1,18 +1,15 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleFeet implements ParticleStyle {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
particles.add(new PParticle(location.clone().subtract(0, 0.95, 0), 0.4F, 0.0F, 0.4F, 0.0F));
return particles;
}

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleHalo implements ParticleStyle {
private static double[] cos, sin;
@ -28,11 +25,11 @@ public class ParticleStyleHalo implements ParticleStyle {
}
public List<PParticle> getParticles(ParticlePair particle, Location location) {
if (step % 2 == 0) return new ArrayList<PParticle>();
if (step % 2 == 0) return new ArrayList<>();
int points = 16;
double radius = .65;
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < points; i++) {
double dx = radius * cos[i];
double dy = 1.5;

View file

@ -1,8 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -10,20 +15,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleHurt implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> baseParticles = DefaultStyles.THICK.getParticles(particle, location);
int multiplyingFactor = 3; // Uses the same logic as ParticleStyleThick except multiplies the resulting particles by 3x
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < baseParticles.size() * multiplyingFactor; i++) {
particles.add(baseParticles.get(i % baseParticles.size()));
}
@ -53,13 +51,15 @@ public class ParticleStyleHurt implements ParticleStyle, Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDamage(EntityDamageEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
PPlayer pplayer = DataManager.getPPlayer(player.getUniqueId());
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(player.getUniqueId());
if (pplayer != null) {
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.HURT)) {
Location loc = player.getLocation().clone().add(0, 1, 0);
ParticleManager.displayParticles(particle, DefaultStyles.HURT.getParticles(particle, loc));
particleManager.displayParticles(particle, DefaultStyles.HURT.getParticles(particle, loc));
}
}
}

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleInvocation implements ParticleStyle {
@ -19,7 +16,7 @@ public class ParticleStyleInvocation implements ParticleStyle {
private int numSteps = 120;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
double speed = getSpeedByEffect(particle.getEffect());
// Circle around everything, spawn less often

View file

@ -1,20 +1,18 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleMove implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
@ -43,12 +41,14 @@ public class ParticleStyleMove implements ParticleStyle, Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent e) {
PPlayer pplayer = DataManager.getPPlayer(e.getPlayer().getUniqueId());
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(e.getPlayer().getUniqueId());
if (pplayer != null) {
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.MOVE)) {
Location loc = e.getPlayer().getLocation().clone();
loc.setY(loc.getY() + 0.05);
ParticleManager.displayParticles(particle, DefaultStyles.MOVE.getParticles(particle, loc));
particleManager.displayParticles(particle, DefaultStyles.MOVE.getParticles(particle, loc));
}
}
}

View file

@ -1,21 +1,18 @@
package dev.esophose.playerparticles.styles;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleNormal implements ParticleStyle {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
ParticleEffect particleEffect = particle.getEffect();
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
switch (particleEffect) {
case AMBIENT_ENTITY_EFFECT:

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleOrbit implements ParticleStyle {
private static double[] cos, sin;
@ -29,7 +26,7 @@ public class ParticleStyleOrbit implements ParticleStyle {
}
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < orbs; i++) {
double dx = cos[(step + (numSteps / orbs * i)) % numSteps];
double dz = sin[(step + (numSteps / orbs * i)) % numSteps];

Some files were not shown because too many files have changed in this diff Show more