mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-07-05 13:31:24 +00:00
WIP: Refactoring by removing statics and moving all managers
This commit is contained in:
parent
2059b902a2
commit
0ede905fef
86 changed files with 4210 additions and 1777 deletions
|
@ -7,6 +7,7 @@ plugins {
|
|||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
group = 'dev.esophose.playerparticles'
|
||||
version = '7.0'
|
||||
|
||||
|
|
|
@ -15,170 +15,108 @@
|
|||
|
||||
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.ParticleGroupPresetManager;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager;
|
||||
import dev.esophose.playerparticles.manager.DataMigrationManager;
|
||||
import dev.esophose.playerparticles.manager.Manager;
|
||||
import dev.esophose.playerparticles.manager.ParticleManager;
|
||||
import dev.esophose.playerparticles.manager.SettingManager;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
|
||||
import dev.esophose.playerparticles.manager.PluginUpdateManager;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.Setting;
|
||||
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;
|
||||
|
||||
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;
|
||||
this.managers = new HashMap<>();
|
||||
|
||||
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);
|
||||
this.reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
pp.setTabCompleter(pch);
|
||||
pp.setExecutor(pch);
|
||||
ppo.setTabCompleter(pch);
|
||||
ppo.setExecutor(pch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the settings of the plugin
|
||||
* Gets a manager instance
|
||||
*
|
||||
* @param updatePluginSettings True if the settings should be updated to the latest version of the plugin
|
||||
* @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
|
||||
*/
|
||||
public void reload(boolean updatePluginSettings) {
|
||||
this.reloadConfig();
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Manager> T getManager(Class<T> managerClass) {
|
||||
if (this.managers.containsKey(managerClass))
|
||||
return (T) this.managers.get(managerClass);
|
||||
|
||||
// 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
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
/**
|
||||
* Returns the file which contains this plugin
|
||||
* Exposes the JavaPlugin.getFile() method
|
||||
*
|
||||
* @return File containing this plugin
|
||||
*/
|
||||
public File getJarFile() {
|
||||
return this.getFile();
|
||||
}
|
||||
|
||||
SettingManager.reload();
|
||||
LangManager.reload(updatePluginSettings);
|
||||
ParticleGroupPresetManager.reload();
|
||||
/**
|
||||
* Reloads the plugin
|
||||
*/
|
||||
public void reload() {
|
||||
this.managers.values().forEach(Manager::disable);
|
||||
this.managers.clear();
|
||||
|
||||
this.getManager(ConfigurationManager.class);
|
||||
this.getManager(DataMigrationManager.class);
|
||||
this.getManager(PluginUpdateManager.class);
|
||||
this.getManager(ParticleManager.class);
|
||||
|
||||
GuiHandler.setup();
|
||||
PlayerChatHook.setup();
|
||||
|
||||
ParticleManager.refreshData();
|
||||
this.startParticleTask();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,61 +124,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package dev.esophose.playerparticles.api;
|
||||
|
||||
public final class PlayerParticlesAPI {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -3,8 +3,9 @@ package dev.esophose.playerparticles.command;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.styles.api.ParticleStyle;
|
||||
import dev.esophose.playerparticles.styles.api.ParticleStyleManager;
|
||||
import dev.esophose.playerparticles.manager.ParticleStyleManager;
|
||||
import dev.esophose.playerparticles.util.ParticleUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -30,7 +31,9 @@ public class AddCommandModule implements CommandModule {
|
|||
return;
|
||||
}
|
||||
|
||||
int maxParticlesAllowed = PermissionManager.getMaxParticlesAllowed(pplayer.getPlayer());
|
||||
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
|
||||
|
||||
int maxParticlesAllowed = permissionManager.getMaxParticlesAllowed(pplayer.getPlayer());
|
||||
if (pplayer.getActiveParticles().size() >= maxParticlesAllowed) {
|
||||
LangManager.sendMessage(pplayer, Lang.ADD_REACHED_MAX, maxParticlesAllowed);
|
||||
return;
|
||||
|
@ -40,7 +43,7 @@ public class AddCommandModule implements CommandModule {
|
|||
if (effect == null) {
|
||||
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
|
||||
} else if (!permissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
|
||||
LangManager.sendMessage(pplayer, Lang.EFFECT_NO_PERMISSION, effect.getName());
|
||||
return;
|
||||
}
|
||||
|
@ -49,7 +52,7 @@ public class AddCommandModule implements CommandModule {
|
|||
if (style == null) {
|
||||
LangManager.sendMessage(pplayer, Lang.STYLE_INVALID, args[1]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
|
||||
} else if (!permissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
|
||||
LangManager.sendMessage(pplayer, Lang.STYLE_NO_PERMISSION, args[1]);
|
||||
return;
|
||||
}
|
||||
|
@ -131,11 +134,11 @@ 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);
|
||||
|
||||
LangManager.sendMessage(pplayer, Lang.ADD_PARTICLE_APPLIED, newParticle.getEffect().getName(), newParticle.getStyle().getName(), newParticle.getDataString());
|
||||
|
||||
if (ParticleStyleManager.isCustomHandled(newParticle.getStyle())) {
|
||||
if (PlayerParticles.getInstance().getManager(ParticleStyleManager.class).isCustomHandled(newParticle.getStyle())) {
|
||||
LangManager.sendMessage(pplayer, Lang.STYLE_EVENT_SPAWNING_INFO, newParticle.getStyle().getName());
|
||||
}
|
||||
}
|
||||
|
@ -143,12 +146,13 @@ public class AddCommandModule implements CommandModule {
|
|||
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 +195,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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.esophose.playerparticles.command;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
|
@ -43,10 +44,14 @@ public class DataCommandModule implements CommandModule {
|
|||
}
|
||||
|
||||
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() {
|
||||
|
|
|
@ -3,6 +3,8 @@ package dev.esophose.playerparticles.command;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.CommandManager;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
|
@ -12,12 +14,12 @@ 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 +32,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() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.esophose.playerparticles.command;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.styles.api.ParticleStyle;
|
||||
import dev.esophose.playerparticles.util.ParticleUtils;
|
||||
import org.bukkit.Material;
|
||||
|
@ -78,7 +79,7 @@ public class EditCommandModule implements CommandModule {
|
|||
if (effect == null) {
|
||||
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
|
||||
} else if (!PlayerParticles.getInstance().getManager(PermissionManager.class).hasEffectPermission(pplayer.getPlayer(), effect)) {
|
||||
LangManager.sendMessage(pplayer, Lang.EFFECT_NO_PERMISSION, effect.getName());
|
||||
return;
|
||||
}
|
||||
|
@ -91,7 +92,7 @@ public class EditCommandModule implements CommandModule {
|
|||
}
|
||||
}
|
||||
|
||||
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
|
||||
LangManager.sendMessage(pplayer, Lang.EDIT_SUCCESS_EFFECT, id, effect.getName());
|
||||
}
|
||||
|
||||
|
@ -107,7 +108,7 @@ public class EditCommandModule implements CommandModule {
|
|||
if (style == null) {
|
||||
LangManager.sendMessage(pplayer, Lang.STYLE_INVALID, args[0]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
|
||||
} else if (!PlayerParticles.getInstance().getManager(PermissionManager.class).hasStylePermission(pplayer.getPlayer(), style)) {
|
||||
LangManager.sendMessage(pplayer, Lang.STYLE_NO_PERMISSION, style.getName());
|
||||
return;
|
||||
}
|
||||
|
@ -120,7 +121,7 @@ public class EditCommandModule implements CommandModule {
|
|||
}
|
||||
}
|
||||
|
||||
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
|
||||
LangManager.sendMessage(pplayer, Lang.EDIT_SUCCESS_STYLE, id, style.getName());
|
||||
}
|
||||
|
||||
|
@ -219,11 +220,12 @@ public class EditCommandModule implements CommandModule {
|
|||
}
|
||||
}
|
||||
|
||||
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
|
||||
LangManager.sendMessage(pplayer, Lang.EDIT_SUCCESS_DATA, id, updatedDataString);
|
||||
}
|
||||
|
||||
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 +255,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 +304,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() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.esophose.playerparticles.command;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
|
@ -15,7 +16,7 @@ public class EffectsCommandModule implements CommandModule {
|
|||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
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);
|
||||
return;
|
||||
|
@ -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() {
|
||||
|
|
|
@ -1,21 +1,6 @@
|
|||
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;
|
||||
|
@ -28,13 +13,28 @@ 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.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 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;
|
||||
|
||||
public class FixedCommandModule implements CommandModule {
|
||||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
Player p = pplayer.getPlayer();
|
||||
|
||||
if (!PermissionManager.canUseFixedEffects(p)) {
|
||||
if (!PlayerParticles.getInstance().getManager(PermissionManager.class).canUseFixedEffects(p)) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_NO_PERMISSION);
|
||||
return;
|
||||
}
|
||||
|
@ -92,7 +92,8 @@ public class FixedCommandModule implements CommandModule {
|
|||
* @param args The command arguments
|
||||
*/
|
||||
private void handleCreate(PPlayer pplayer, Player p, String[] args) {
|
||||
boolean reachedMax = PermissionManager.hasPlayerReachedMaxFixedEffects(pplayer);
|
||||
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
|
||||
boolean reachedMax = permissionManager.hasPlayerReachedMaxFixedEffects(pplayer);
|
||||
if (reachedMax) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_MAX_REACHED);
|
||||
return;
|
||||
|
@ -155,7 +156,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
}
|
||||
|
||||
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);
|
||||
return;
|
||||
|
@ -165,7 +166,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
if (effect == null) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_EFFECT_INVALID, args[3]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasEffectPermission(p, effect)) {
|
||||
} else if (!permissionManager.hasEffectPermission(p, effect)) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_EFFECT_NO_PERMISSION, effect.getName());
|
||||
return;
|
||||
}
|
||||
|
@ -174,7 +175,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
if (style == null) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_STYLE_INVALID, args[4]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasStylePermission(p, style)) {
|
||||
} else if (!permissionManager.hasStylePermission(p, style)) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_STYLE_NO_PERMISSION, args[4]);
|
||||
return;
|
||||
}
|
||||
|
@ -271,7 +272,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
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);
|
||||
PlayerParticles.getInstance().getManager(DataManager.class).saveFixedEffect(fixedEffect);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,6 +283,8 @@ public class FixedCommandModule implements CommandModule {
|
|||
* @param args The command arguments
|
||||
*/
|
||||
private void handleEdit(PPlayer pplayer, Player p, String[] args) {
|
||||
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
|
||||
|
||||
if (args.length < 3) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_MISSING_ARGS);
|
||||
return;
|
||||
|
@ -348,7 +351,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
}
|
||||
|
||||
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);
|
||||
return;
|
||||
|
@ -361,7 +364,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
if (effect == null) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_EFFECT_INVALID, args[2]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
|
||||
} else if (!permissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_EFFECT_NO_PERMISSION, effect.getName());
|
||||
return;
|
||||
}
|
||||
|
@ -374,7 +377,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
if (style == null) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_STYLE_INVALID, args[2]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
|
||||
} else if (!permissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_STYLE_NO_PERMISSION, style.getName());
|
||||
return;
|
||||
} else if (!style.canBeFixed()) {
|
||||
|
@ -480,7 +483,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
return;
|
||||
}
|
||||
|
||||
DataManager.updateFixedEffect(fixedEffect);
|
||||
PlayerParticles.getInstance().getManager(DataManager.class).updateFixedEffect(fixedEffect);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_SUCCESS, editType, id);
|
||||
}
|
||||
|
||||
|
@ -506,7 +509,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
}
|
||||
|
||||
if (pplayer.getFixedEffectById(id) != null) {
|
||||
DataManager.removeFixedEffect(pplayer.getUniqueId(), id);
|
||||
PlayerParticles.getInstance().getManager(DataManager.class).removeFixedEffect(pplayer.getUniqueId(), id);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_SUCCESS, id);
|
||||
} else {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_INVALID, id);
|
||||
|
@ -591,7 +594,11 @@ public class FixedCommandModule implements CommandModule {
|
|||
* @param args The command arguments
|
||||
*/
|
||||
private void handleClear(PPlayer pplayer, Player p, String[] args) {
|
||||
if (!PermissionManager.canClearFixedEffects(p)) {
|
||||
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)) {
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CLEAR_NO_PERMISSION);
|
||||
return;
|
||||
}
|
||||
|
@ -611,18 +618,19 @@ public class FixedCommandModule implements CommandModule {
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
||||
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
|
||||
Player p = pplayer.getPlayer();
|
||||
List<String> matches = new ArrayList<>();
|
||||
|
||||
|
@ -657,9 +665,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 +725,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 +789,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() {
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package dev.esophose.playerparticles.command;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.Setting;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
|
||||
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.manager.PermissionManager;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
|
||||
public class GUICommandModule implements CommandModule {
|
||||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
|
@ -18,7 +19,7 @@ public class GUICommandModule implements CommandModule {
|
|||
byDefault = true;
|
||||
}
|
||||
|
||||
if (GuiHandler.isGuiDisabled()) {
|
||||
if (GuiManager.isGuiDisabled()) {
|
||||
if (byDefault) {
|
||||
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN);
|
||||
} else {
|
||||
|
@ -27,7 +28,7 @@ public class GUICommandModule implements CommandModule {
|
|||
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);
|
||||
} else {
|
||||
|
@ -36,7 +37,7 @@ public class GUICommandModule implements CommandModule {
|
|||
return;
|
||||
}
|
||||
|
||||
GuiHandler.openDefault(pplayer);
|
||||
GuiManager.openDefault(pplayer);
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
||||
|
@ -47,8 +48,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() {
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
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.ParticleGroupPresetManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
|
||||
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 org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupCommandModule implements CommandModule {
|
||||
|
||||
|
@ -87,7 +87,7 @@ 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)) {
|
||||
if (pplayer.getParticleGroupByName(groupName) == null && PlayerParticles.getInstance().getManager(PermissionManager.class).hasPlayerReachedMaxGroups(pplayer)) {
|
||||
LangManager.sendMessage(pplayer, Lang.GROUP_SAVE_REACHED_MAX);
|
||||
return;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ 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);
|
||||
} else {
|
||||
|
@ -131,7 +131,7 @@ 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);
|
||||
return;
|
||||
|
@ -158,7 +158,7 @@ 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);
|
||||
|
@ -182,7 +182,7 @@ 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);
|
||||
|
@ -193,7 +193,7 @@ public class GroupCommandModule implements CommandModule {
|
|||
}
|
||||
|
||||
// Delete the group and notify player
|
||||
DataManager.removeParticleGroup(pplayer.getUniqueId(), group);
|
||||
PlayerParticles.getInstance().getManager(DataManager.class).removeParticleGroup(pplayer.getUniqueId(), group);
|
||||
LangManager.sendMessage(pplayer, Lang.GROUP_REMOVE_SUCCESS, groupName);
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ 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);
|
||||
return;
|
||||
|
@ -254,7 +254,7 @@ 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(", "))
|
||||
|
@ -290,7 +290,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 +303,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() {
|
||||
|
|
|
@ -3,15 +3,18 @@ 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.CommandManager;
|
||||
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
|
||||
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();
|
||||
List<CommandModule> cmds = PlayerParticles.getInstance().getManager(CommandManager.class).getCommands();
|
||||
for (CommandModule cmd : cmds)
|
||||
if (!(cmd instanceof DefaultCommandModule))
|
||||
CommandModule.printUsageWithDescription(pplayer, cmd);
|
||||
|
@ -26,8 +29,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() {
|
||||
|
|
|
@ -38,8 +38,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() {
|
||||
|
|
|
@ -1,25 +1,28 @@
|
|||
package dev.esophose.playerparticles.command;
|
||||
|
||||
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.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.CommandManager;
|
||||
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;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OtherCommandModule implements CommandModuleSecondary {
|
||||
|
||||
public void onCommandExecute(CommandSender sender, String[] args) {
|
||||
if (!PermissionManager.canOverride(sender)) {
|
||||
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
|
||||
|
||||
if (!permissionManager.canOverride(sender)) {
|
||||
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_NO_PERMISSION);
|
||||
return;
|
||||
}
|
||||
|
@ -35,19 +38,19 @@ public class OtherCommandModule implements CommandModuleSecondary {
|
|||
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]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (commandModule.requiresEffects() && PermissionManager.getEffectNamesUserHasPermissionFor(other).isEmpty()) {
|
||||
if (commandModule.requiresEffects() && permissionManager.getEffectNamesUserHasPermissionFor(other).isEmpty()) {
|
||||
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_SUCCESS, other.getName());
|
||||
LangManager.sendCommandSenderMessage(sender, Lang.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());
|
||||
|
@ -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);
|
||||
|
|
|
@ -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<>();
|
||||
}
|
||||
|
||||
}
|
|
@ -12,10 +12,10 @@ import dev.esophose.playerparticles.particles.PPlayer;
|
|||
public class ReloadCommandModule implements CommandModule {
|
||||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
if (PermissionManager.canReloadPlugin(pplayer.getMessageDestination())) {
|
||||
PlayerParticles.getPlugin().reload(false);
|
||||
if (PlayerParticles.getInstance().getManager(PermissionManager.class).canReloadPlugin(pplayer.getMessageDestination())) {
|
||||
PlayerParticles.getInstance().reload();
|
||||
LangManager.sendMessage(pplayer, Lang.RELOAD_SUCCESS);
|
||||
PlayerParticles.getPlugin().getLogger().info("Reloaded configuration.");
|
||||
PlayerParticles.getInstance().getLogger().info("Reloaded configuration.");
|
||||
} else {
|
||||
LangManager.sendMessage(pplayer, Lang.RELOAD_NO_PERMISSION);
|
||||
}
|
||||
|
@ -29,8 +29,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() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.styles.api.ParticleStyle;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
@ -20,6 +21,8 @@ import dev.esophose.playerparticles.particles.ParticlePair;
|
|||
public class RemoveCommandModule implements CommandModule {
|
||||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
|
||||
if (args.length == 0) {
|
||||
LangManager.sendMessage(pplayer, Lang.REMOVE_NO_ARGS);
|
||||
return;
|
||||
|
@ -54,7 +57,7 @@ public class RemoveCommandModule implements CommandModule {
|
|||
return;
|
||||
}
|
||||
|
||||
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
|
||||
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
|
||||
LangManager.sendMessage(pplayer, Lang.REMOVE_ID_SUCCESS, id);
|
||||
} else { // Removing by effect/style name
|
||||
ParticleEffect effect = ParticleEffect.fromName(args[0]);
|
||||
|
@ -71,7 +74,7 @@ public class RemoveCommandModule implements CommandModule {
|
|||
}
|
||||
|
||||
if (removedCount > 0) {
|
||||
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
|
||||
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
|
||||
LangManager.sendMessage(pplayer, Lang.REMOVE_EFFECT_SUCCESS, removedCount, effect.getName());
|
||||
} else {
|
||||
LangManager.sendMessage(pplayer, Lang.REMOVE_EFFECT_NONE, effect.getName());
|
||||
|
@ -87,7 +90,7 @@ public class RemoveCommandModule implements CommandModule {
|
|||
}
|
||||
|
||||
if (removedCount > 0) {
|
||||
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
|
||||
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
|
||||
LangManager.sendMessage(pplayer, Lang.REMOVE_STYLE_SUCCESS, removedCount, style.getName());
|
||||
} else {
|
||||
LangManager.sendMessage(pplayer, Lang.REMOVE_STYLE_NONE, style.getName());
|
||||
|
@ -118,8 +121,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() {
|
||||
|
|
|
@ -3,6 +3,7 @@ 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;
|
||||
|
@ -13,7 +14,7 @@ public class ResetCommandModule implements CommandModule {
|
|||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
int particleCount = pplayer.getActiveParticles().size();
|
||||
DataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
|
||||
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
|
||||
LangManager.sendMessage(pplayer, Lang.RESET_SUCCESS, particleCount);
|
||||
}
|
||||
|
||||
|
@ -25,8 +26,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() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.esophose.playerparticles.command;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
|
@ -15,7 +16,7 @@ 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(", ");
|
||||
|
@ -36,8 +37,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() {
|
||||
|
|
|
@ -3,6 +3,7 @@ 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;
|
||||
|
@ -12,7 +13,7 @@ public class ToggleCommandModule implements CommandModule {
|
|||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
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);
|
||||
|
@ -29,8 +30,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() {
|
||||
|
|
|
@ -13,7 +13,7 @@ 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 + "Running PlayerParticles " + ChatColor.AQUA + "v" + PlayerParticles.getInstance().getDescription().getVersion());
|
||||
LangManager.sendCustomMessage(pplayer, ChatColor.YELLOW + "Plugin created by: " + ChatColor.AQUA + "Esophose");
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,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() {
|
||||
|
|
|
@ -3,6 +3,7 @@ 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.PermissionManager;
|
||||
|
@ -11,13 +12,14 @@ import dev.esophose.playerparticles.particles.PPlayer;
|
|||
public class WorldsCommandModule implements CommandModule {
|
||||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
if (PermissionManager.getDisabledWorlds() == null || PermissionManager.getDisabledWorlds().isEmpty()) {
|
||||
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
|
||||
if (permissionManager.getDisabledWorlds() == null || permissionManager.getDisabledWorlds().isEmpty()) {
|
||||
LangManager.sendMessage(pplayer, Lang.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));
|
||||
|
@ -33,8 +35,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() {
|
||||
|
|
|
@ -0,0 +1,378 @@
|
|||
package dev.esophose.playerparticles.config;
|
||||
|
||||
import org.bukkit.Color;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package dev.esophose.playerparticles.config;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,223 @@
|
|||
package dev.esophose.playerparticles.config;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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 = new BufferedReader(new FileReader(file));
|
||||
|
||||
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 InputStreamReader(new ByteArrayInputStream(config.getBytes(StandardCharsets.UTF_8)));
|
||||
|
||||
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 = new BufferedReader(new FileReader(file));
|
||||
|
||||
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))) {
|
||||
stringBuilder.append('\n');
|
||||
}
|
||||
|
||||
stringBuilder.append(line).append('\n');
|
||||
|
||||
lastLineHadContent = lineHadContent;
|
||||
lastCommentSpacing = commentSpacing;
|
||||
lastLineSpacing = lineSpacing;
|
||||
forceCompact = false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
|
||||
writer.write(stringBuilder.toString());
|
||||
writer.flush();
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getPluginName() {
|
||||
return this.plugin.getDescription().getName();
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@ 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();
|
||||
|
||||
|
@ -25,10 +25,10 @@ public interface DatabaseConnector {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,31 +1,26 @@
|
|||
package dev.esophose.playerparticles.database;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
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;
|
||||
|
||||
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 +40,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();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package dev.esophose.playerparticles.database;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ 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.manager.SettingManager.Setting;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import dev.esophose.playerparticles.util.ParticleUtils;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package dev.esophose.playerparticles.gui;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
|
||||
|
@ -26,6 +28,8 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
public GuiInventoryDefault(PPlayer pplayer) {
|
||||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_PLAYERPARTICLES)));
|
||||
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.WHITE);
|
||||
|
||||
// PPlayer information icon
|
||||
|
@ -55,8 +59,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) {
|
||||
|
@ -79,7 +83,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
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)));
|
||||
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryManageParticles(pplayer)));
|
||||
this.actionButtons.add(manageYourParticlesButton);
|
||||
|
||||
// Manage Your Groups button
|
||||
|
@ -89,7 +93,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
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)));
|
||||
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryManageGroups(pplayer)));
|
||||
this.actionButtons.add(manageYourGroupsButton);
|
||||
}
|
||||
|
||||
|
@ -100,7 +104,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
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)));
|
||||
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryLoadPresetGroups(pplayer, false)));
|
||||
this.actionButtons.add(loadPresetGroups);
|
||||
}
|
||||
|
||||
|
@ -116,8 +120,8 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.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)));
|
||||
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,9 +134,9 @@ 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();
|
||||
|
@ -158,8 +162,8 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
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)));
|
||||
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,9 +172,9 @@ 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();
|
||||
|
@ -201,8 +205,8 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
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)));
|
||||
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,9 +218,9 @@ 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();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.esophose.playerparticles.gui;
|
||||
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||
|
@ -308,7 +309,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
GuiIcon.PREVIOUS_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -319,7 +320,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
GuiIcon.NEXT_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -369,7 +370,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
GuiIcon.PREVIOUS_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -380,7 +381,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
GuiIcon.NEXT_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +431,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
GuiIcon.PREVIOUS_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -441,7 +442,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
GuiIcon.NEXT_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package dev.esophose.playerparticles.gui;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
|
@ -20,7 +22,7 @@ public class GuiInventoryEditEffect extends GuiInventory {
|
|||
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);
|
||||
|
@ -65,7 +67,7 @@ public class GuiInventoryEditEffect extends GuiInventory {
|
|||
GuiIcon.PREVIOUS_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -76,7 +78,7 @@ public class GuiInventoryEditEffect extends GuiInventory {
|
|||
GuiIcon.NEXT_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package dev.esophose.playerparticles.gui;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||
|
@ -18,6 +20,8 @@ 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())));
|
||||
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.RED);
|
||||
|
||||
// Particle Info Icon
|
||||
|
@ -38,8 +42,8 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
new String[]{LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.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)));
|
||||
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,9 +52,9 @@ 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();
|
||||
|
@ -64,8 +68,8 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
new String[]{LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.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)));
|
||||
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,9 +78,9 @@ 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();
|
||||
|
@ -93,8 +97,8 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
(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)));
|
||||
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,9 +110,9 @@ 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();
|
||||
|
@ -122,7 +126,7 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
GuiIcon.BACK.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.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();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package dev.esophose.playerparticles.gui;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
|
@ -20,7 +22,7 @@ public class GuiInventoryEditStyle extends GuiInventory {
|
|||
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);
|
||||
|
@ -65,7 +67,7 @@ public class GuiInventoryEditStyle extends GuiInventory {
|
|||
GuiIcon.PREVIOUS_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -76,7 +78,7 @@ public class GuiInventoryEditStyle extends GuiInventory {
|
|||
GuiIcon.NEXT_PAGE.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package dev.esophose.playerparticles.gui;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.Setting;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import dev.esophose.playerparticles.particles.ParticleGroup;
|
||||
import dev.esophose.playerparticles.particles.ParticleGroupPreset;
|
||||
|
@ -22,6 +24,8 @@ 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)));
|
||||
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.GREEN);
|
||||
|
||||
Player player = pplayer.getPlayer();
|
||||
|
@ -29,7 +33,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;
|
||||
|
@ -51,9 +55,9 @@ public class GuiInventoryLoadPresetGroups 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();
|
||||
}
|
||||
});
|
||||
|
@ -73,7 +77,7 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
|
|||
INVENTORY_SIZE - 1, GuiIcon.BACK.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.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
|
||||
|
@ -84,7 +88,7 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
|
|||
new String[]{LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_RESET_PARTICLES_DESCRIPTION)},
|
||||
(button, isShiftClick) -> {
|
||||
// Reset particles
|
||||
DataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
|
||||
dataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
|
||||
});
|
||||
this.actionButtons.add(resetParticles);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
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.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.Setting;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import dev.esophose.playerparticles.particles.ParticleGroup;
|
||||
import dev.esophose.playerparticles.particles.ParticlePair;
|
||||
|
@ -23,6 +25,8 @@ public class GuiInventoryManageGroups extends GuiInventory {
|
|||
public GuiInventoryManageGroups(PPlayer pplayer) {
|
||||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS)));
|
||||
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.BROWN);
|
||||
|
||||
int index = 10;
|
||||
|
@ -54,7 +58,7 @@ public class GuiInventoryManageGroups extends GuiInventory {
|
|||
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 +67,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,7 +84,7 @@ 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) {
|
||||
|
@ -108,7 +112,7 @@ public class GuiInventoryManageGroups extends GuiInventory {
|
|||
|
||||
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];
|
||||
|
||||
|
@ -136,14 +140,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);
|
||||
} else {
|
||||
LangManager.sendMessage(pplayer, Lang.GROUP_SAVE_SUCCESS, groupName);
|
||||
}
|
||||
|
||||
GuiHandler.transition(new GuiInventoryManageGroups(pplayer));
|
||||
GuiManager.transition(new GuiInventoryManageGroups(pplayer));
|
||||
}
|
||||
}));
|
||||
pplayer.getPlayer().closeInventory();
|
||||
|
@ -156,7 +160,7 @@ public class GuiInventoryManageGroups extends GuiInventory {
|
|||
GuiIcon.BACK.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.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();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package dev.esophose.playerparticles.gui;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
|
@ -21,6 +23,8 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
public GuiInventoryManageParticles(PPlayer pplayer) {
|
||||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES)));
|
||||
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.ORANGE);
|
||||
|
||||
// Manage/Delete Particle Buttons
|
||||
|
@ -42,7 +46,7 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
},
|
||||
(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 +56,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,7 +74,7 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
}
|
||||
|
||||
// Create New Particle Button
|
||||
boolean canCreate = pplayer.getActiveParticles().size() < PermissionManager.getMaxParticlesAllowed(pplayer.getPlayer());
|
||||
boolean canCreate = pplayer.getActiveParticles().size() < PlayerParticles.getInstance().getManager(PermissionManager.class).getMaxParticlesAllowed(pplayer.getPlayer());
|
||||
String lore = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_CREATE_PARTICLE_DESCRIPTION);
|
||||
GuiActionButton createNewParticle = new GuiActionButton(
|
||||
38,
|
||||
|
@ -81,12 +85,12 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
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)));
|
||||
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();
|
||||
}
|
||||
|
@ -95,10 +99,10 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
// 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();
|
||||
});
|
||||
|
@ -111,10 +115,10 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
new String[]{LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.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);
|
||||
|
||||
|
@ -124,7 +128,7 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
GuiIcon.BACK.get(),
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.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();
|
||||
|
|
|
@ -31,7 +31,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 +45,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,303 @@
|
|||
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>() {{
|
||||
// Plugin Prefix
|
||||
this.put("prefix", "&7[&3PlayerParticles&7] ");
|
||||
|
||||
// Command Errors
|
||||
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.");
|
||||
|
||||
// Command Descriptions
|
||||
this.put("command-descriptions", "&eThe following commands are available:");
|
||||
this.put("command-descriptions-usage", "&e/pp {0} {1}");
|
||||
this.put("command-descriptions-help-1", "&7> &b/pp {0} &e- {1}");
|
||||
this.put("command-descriptions-help-2", "&7> &b/pp {0} {1} &e- {2}");
|
||||
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");
|
||||
|
||||
// Sub-Command Usage
|
||||
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");
|
||||
|
||||
// ID Lookup
|
||||
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{0}&c!");
|
||||
|
||||
// Other Command
|
||||
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{0} &cwas not found. They must be online.");
|
||||
this.put("other-unknown-command", "&cThe command &b/pp {0} &cdoes not exist.");
|
||||
this.put("other-success", "&eExecuted /pp command for &b{0}&e. Output:");
|
||||
|
||||
// Add Command
|
||||
this.put("add-reached-max", "&cUnable to apply particle, you have reached the maximum amount of &b{0} &callowed!");
|
||||
this.put("add-particle-applied", "&aA new particle has been applied with the effect &b{0}&a, style &b{1}&a, and data &b{2}&a!");
|
||||
|
||||
// Data Command
|
||||
this.put("data-no-args", "&cMissing argument for effect! Command usage: &b/pp data <effect>");
|
||||
|
||||
// Edit Command
|
||||
this.put("edit-invalid-property", "&cAn invalid property &b{0} &cwas provided. Valid properties: &beffect&c, &bstyle&c, &bdata");
|
||||
this.put("edit-success-effect", "&aYour particle with an ID of &b{0} &ahas had its effect changed to &b{1}&a!");
|
||||
this.put("edit-success-style", "&aYour particle with an ID of &b{0} &ahas had its style changed to &b{1}&a!");
|
||||
this.put("edit-success-data", "&aYour particle with an ID of &b{0} &ahas had its data changed to &b{1}&a!");
|
||||
|
||||
// Group Command
|
||||
this.put("group-invalid", "&cA saved group or preset group does not exist with the name &b{0}&c!");
|
||||
this.put("group-no-permission", "&cYou are missing permission for an effect or style to use the group &b{0}&c!");
|
||||
this.put("group-preset-no-permission", "&cYou are missing permission for an effect or style to use the preset group &b{0}&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 {0} <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{0}&a!");
|
||||
this.put("group-save-success-overwrite", "&aThe group named &b{0} &ahas been updated with your current particles!");
|
||||
this.put("group-load-success", "&aApplied &b{0} &aparticle(s) from your saved group named &b{1}&a!");
|
||||
this.put("group-load-preset-success", "&aApplied &b{0} &aparticle(s) from the preset group named &b{1}&a!");
|
||||
this.put("group-remove-preset", "&cYou cannot remove a preset group!");
|
||||
this.put("group-remove-success", "&aRemoved the particle group named &b{0}&a!");
|
||||
this.put("group-info-header", "&eThe group &b{0} &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{0}");
|
||||
this.put("group-list-presets", "&eThe following preset groups are available: &b{0}");
|
||||
|
||||
// Reload Command
|
||||
this.put("reload-success", "&aThe plugin has been reloaded!");
|
||||
this.put("reload-no-permission", "&cYou do not have permission to reload the plugin settings!");
|
||||
|
||||
// Remove Command
|
||||
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{0} &ahas been removed!");
|
||||
this.put("remove-effect-success", "&aRemoved &b{0} &aof your particles with the effect of &b{1}&a!");
|
||||
this.put("remove-effect-none", "&cYou do not have any particles applied with the effect &b{0}&c!");
|
||||
this.put("remove-style-success", "&aRemoved &b{0} &aof your particles with the style of &b{1}&a!");
|
||||
this.put("remove-style-none", "&cYou do not have any particles applied with the style &b{0}&c!");
|
||||
this.put("remove-unknown", "&cAn effect or style with the name of &b{0} &cdoes not exist!");
|
||||
|
||||
// List Command
|
||||
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{0} &eEffect: &b{1} &eStyle: &b{2} &eData: &b{3}");
|
||||
|
||||
// Toggle Command
|
||||
this.put("toggle-on", "&eParticles have been toggled &aON&e!");
|
||||
this.put("toggle-off", "&eParticles have been toggled &cOFF&e!");
|
||||
|
||||
// Rainbow
|
||||
this.put("rainbow", "&cR&6a&ei&an&bb&9o&dw");
|
||||
|
||||
// Random
|
||||
this.put("random", "Random");
|
||||
|
||||
// Effects
|
||||
this.put("effect-no-permission", "&cYou do not have permission to use the effect &b{0} &c!");
|
||||
this.put("effect-invalid", "&cThe effect &b{0} &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{0}");
|
||||
this.put("effect-list-empty", "&cYou do not have permission to use any effects!");
|
||||
|
||||
// Styles
|
||||
this.put("style-no-permission", "&cYou do not have permission to use the style &b{0} &c!");
|
||||
this.put("style-event-spawning-info", "&eNote: The style &b{0} &espawns particles based on an event.");
|
||||
this.put("style-invalid", "&cThe style &b{0} &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{0}");
|
||||
|
||||
// Data
|
||||
this.put("data-usage-none", "&eThe effect &b{0} &edoes not use any data!");
|
||||
this.put("data-usage-block", "&eThe effect &b{0} &erequires &bblock &edata! &bFormat: <blockName>");
|
||||
this.put("data-usage-item", "&eThe effect &b{0} &erequires &bitem &edata! &bFormat: <itemName>");
|
||||
this.put("data-usage-color", "&eThe effect &b{0} &erequires &bcolor &edata! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
|
||||
this.put("data-usage-note", "&eThe effect &b{0} &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{0} &cyou entered is not an item!");
|
||||
this.put("data-invalid-material-not-block", "&cThe &bblock &cmaterial &b{0} &cyou entered is not a block!");
|
||||
this.put("data-invalid-material-item", "&cThe &bitem &cmaterial &b{0} you entered does not exist!");
|
||||
this.put("data-invalid-material-block", "&cThe &bblock &cmaterial &b{0} you entered does not exist!");
|
||||
|
||||
// Worlds
|
||||
this.put("disabled-worlds", "&eParticles are disabled in these worlds: &b{0}");
|
||||
this.put("disabled-worlds-none", "&eParticles are not disabled in any worlds.");
|
||||
|
||||
// Reset
|
||||
this.put("reset-success", "&aRemoved &b{0} &aactive particle(s)!");
|
||||
|
||||
// Fixed Effects
|
||||
this.put("fixed-create-missing-args", "&cUnable to create fixed effect, you are missing &b{0} &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{0} &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{0} &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{0}&c!");
|
||||
this.put("fixed-create-style-invalid", "&cUnable to create fixed effect, a style with the name &b{0} &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{0}&c!");
|
||||
this.put("fixed-create-style-non-fixable", "&cUnable to create fixed effect, the style &b{0} &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("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{0} &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{0} &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{0}&c!");
|
||||
this.put("fixed-edit-style-invalid", "&cUnable to edit fixed effect, a style with the name &b{0} &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{0}&c!");
|
||||
this.put("fixed-edit-style-non-fixable", "&cUnable to edit fixed effect, the style &b{0} &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{0} &aof the fixed effect with an ID of &b{1}&a!");
|
||||
|
||||
this.put("fixed-remove-invalid", "&cUnable to remove fixed effect, you do not have a fixed effect with the ID of &b{0}&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{0} &ahas been removed!");
|
||||
|
||||
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{0}");
|
||||
|
||||
this.put("fixed-info-invalid", "&cUnable to get info, you do not have a fixed effect with the ID of &b{0}&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{0} &eWorld: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eEffect: &b{5} &eStyle: &b{6} &eData: &b{7}");
|
||||
|
||||
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{0} &afixed effects within &b{1} &ablocks of your location!");
|
||||
|
||||
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!");
|
||||
|
||||
// Update Available
|
||||
this.put("update-available", "&eAn update (&b{0}&e) is available! You are running &bv{1}&e. https://www.spigotmc.org/resources/playerparticles.40261/");
|
||||
|
||||
// GUI
|
||||
this.put("gui-disabled", "&cThe server administrator has disabled the GUI!");
|
||||
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("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 ({0}/{1})");
|
||||
this.put("gui-previous-page-button", "Previous Page ({0}/{1})");
|
||||
this.put("gui-click-to-load", "Click to load the following {0} particle(s):");
|
||||
this.put("gui-shift-click-to-delete", "Shift click to delete");
|
||||
this.put("gui-particle-info", " - ID: &b{0} &eEffect: &b{1} &eStyle: &b{2} &eData: &b{3}");
|
||||
this.put("gui-playerparticles", "PlayerParticles");
|
||||
this.put("gui-active-particles", "Active Particles: &b{0}");
|
||||
this.put("gui-saved-groups", "Saved Groups: &b{0}");
|
||||
this.put("gui-fixed-effects", "Fixed Effects: &b{0}");
|
||||
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("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("gui-load-a-preset-group", "Load A Preset Group");
|
||||
this.put("gui-load-a-preset-group-description", "Load a premade particle group");
|
||||
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{0}&es left)");
|
||||
this.put("gui-reset-particles", "Reset Your Particles");
|
||||
this.put("gui-reset-particles-description", "Deletes all your active particles");
|
||||
this.put("gui-particle-name", "Particle #{0}");
|
||||
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 #{0}");
|
||||
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("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("gui-select-effect", "Select Particle Effect");
|
||||
this.put("gui-select-effect-description", "Sets the particle effect to &b{0}");
|
||||
this.put("gui-select-style", "Select Particle Style");
|
||||
this.put("gui-select-style-description", "Sets the particle style to &b{0}");
|
||||
this.put("gui-select-data", "Select Particle Data");
|
||||
this.put("gui-select-data-description", "Sets the particle data to &b{0}");
|
||||
this.put("gui-select-data-note", "note #{0}");
|
||||
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");
|
||||
}};
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,302 @@
|
|||
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>() {{
|
||||
// Plugin Prefix
|
||||
this.put("prefix", "&7[&3PlayerParticles&7] ");
|
||||
|
||||
// Command Errors
|
||||
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.");
|
||||
|
||||
// Command Descriptions
|
||||
this.put("command-descriptions", "&eLes commandes suivantes sont disponibles :");
|
||||
this.put("command-descriptions-usage", "&e/pp {0} {1}");
|
||||
this.put("command-descriptions-help-1", "&7> &b/pp {0} &e- {1}");
|
||||
this.put("command-descriptions-help-2", "&7> &b/pp {0} {1} &e- {2}");
|
||||
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é");
|
||||
|
||||
// Sub-Command Usage
|
||||
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");
|
||||
|
||||
// Command ID Lookup
|
||||
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{0} &c!");
|
||||
|
||||
// Other Command
|
||||
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{0} &cn'a pas été trouvé. Il doit être en ligne.");
|
||||
this.put("other-unknown-command", "&cLa commande &b/pp {0} &cn existe pas.");
|
||||
this.put("other-success", "&Commande /pp exécutée. &b{0}&e. Retour de la commande :");
|
||||
|
||||
// Add Command
|
||||
this.put("add-reached-max", "Impossible d'appliquer la particule, vous avez atteint la limite de particules qui est de &b{0} &c!");
|
||||
this.put("add-particle-applied", "&aUne nouvelle particule est appliquée avec l'effet &b{0}&a, le style &b{1}&a, et les paramètres &b{2} &a!");
|
||||
|
||||
// Data Command
|
||||
this.put("data-no-args", "&cVous oubliez des arguments dans l'effet. Utilisation de la commande: &b/pp data <effect>");
|
||||
|
||||
// Edit Command
|
||||
this.put("edit-invalid-property", "cLa propriété &b{0} &cest interdite. Propriétés valides : &beffect&c, &bstyle&c, &bdata");
|
||||
this.put("edit-success-effect", "&aVotre particule avec l'ID de &b{0} &aa son effet changé à &b{1} &a!");
|
||||
this.put("edit-success-style", "&aVotre particule avec l'ID de &b{0} &aa son style changé à &b{1} &a!");
|
||||
this.put("edit-success-data", "&aVotre particule avec l'ID de &b{0} &aa ses paramètres changés à &b{1} &a!");
|
||||
|
||||
// Group Command
|
||||
this.put("group-invalid", "&cUn groupe ou un preset de groupe sauvegardé n'existe pas avec le nom &b{0} &c!");
|
||||
this.put("group-no-permission", "&cVous oubliez une permission pour un style ou un effet afin d'utiliser les groupe &b{0} &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{0} &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 {0} <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{0} &a!");
|
||||
this.put("group-save-success-overwrite", "&aLe groupe &b{0} &aa été mis à jour avec vos particules actuelle !");
|
||||
this.put("group-load-success", "&b{0} &aparticule(s) appliqués venant du groupe sauvegardé nommé &b{1} &a!");
|
||||
this.put("group-load-preset-success", "&b{0} &aparticule(s) appliqués venant du preset sauvegardé nommé &b{1} &a!");
|
||||
this.put("group-remove-preset", "&cVous ne pouvez pas supprimer un groupe de presets !");
|
||||
this.put("group-remove-success", "&aGroupe de particules &b{0} &asupprimé !");
|
||||
this.put("group-info-header", "&eLe groupe &b{0} &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{0}");
|
||||
this.put("group-list-presets", "&eCes presets de groupes suivants sont disponibles : &b{0}");
|
||||
|
||||
// Reload Command
|
||||
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 !");
|
||||
|
||||
// Remove Command
|
||||
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{0} &aa été supprimée !");
|
||||
this.put("remove-effect-success", "&aSuppression de &b{0} &ade votre particule avec l'effet &b{1} &a!");
|
||||
this.put("remove-effect-none", "&cVous n'avez pas de particules appliquées avec l'effet &b{0} &c!");
|
||||
this.put("remove-style-success", "&aSuppression &b{0} &ade votre particule avec le style &b{1} &a!");
|
||||
this.put("remove-style-none", "&cVous n'avez pas de particules appliquées avec le style &b{0} &c!");
|
||||
this.put("remove-unknown", "&cL'effect avec le nom ou le style &b{0} &cn'existe pas !");
|
||||
|
||||
// List Command
|
||||
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{0} &eEffet: &b{1} &eStyle: &b{2} &eParamètre: &b{3}");
|
||||
|
||||
// Toggle Command
|
||||
this.put("toggle-on", "&eLes particules sont maintenant en mode &aON &e!");
|
||||
this.put("toggle-off", "&eLes particules sont maintenant en mode &cOFF &e!");
|
||||
|
||||
// Rainbow
|
||||
this.put("rainbow", "&cr&6a&ei&an&bb&9o&dw");
|
||||
|
||||
// Random
|
||||
this.put("random", "aléatoire");
|
||||
|
||||
// Effects
|
||||
this.put("effect-no-permission", "&cVous n'avez pas la permission pour utiliser la particule &b{0} &c!");
|
||||
this.put("effect-invalid", "&cL'effet &b{0} &cn existe pas ! Utilisez &b/pp effects &cpour afficher les effets disponibles.");
|
||||
this.put("effect-list", "&eVous pouvez utiliser les effets suivants : &b{0}");
|
||||
this.put("effect-list-empty", "&cVous n'avez pas la permission pour utiliser des effets !");
|
||||
|
||||
// Styles
|
||||
this.put("style-no-permission", "&cVous n'avez pas la permission pour utiliser le style &b{0} &c!");
|
||||
this.put("style-event-spawning-info", "&eNote: Le style &b{0} &efait apparaitre des particules seulement lors d'évènements spécifiques.");
|
||||
this.put("style-invalid", "&cLe style &b{0} &cn'existe pas ! Utilisez &b/pp styles &cpour afficher les styles disponibles.");
|
||||
this.put("style-list", "&eVous pouvez utiliser les styles suivants : &b{0}");
|
||||
|
||||
// Data
|
||||
this.put("data-usage-none", "&eL'effet &b{0} &en'est pas paramétrable.");
|
||||
this.put("data-usage-block", "&eL'effet &b{0} &erequière l'ID du bloc ! &bFormat: <blockName>");
|
||||
this.put("data-usage-item", "&eL'effet &b{0} &erequière l'ID de l'item ! &bFormat: <itemName>");
|
||||
this.put("data-usage-color", "&eL'effet &b{0} &erequière l'ID de la couleur ! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
|
||||
this.put("data-usage-note", "&eL'effet&b{0} &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{0} &cne correspond pas à un item !");
|
||||
this.put("data-invalid-material-not-block", "&cL'ID &b{0} &cne correspond pas à un bloc !");
|
||||
this.put("data-invalid-material-item", "&cL'ID &b{0} n'existe pas !");
|
||||
this.put("data-invalid-material-block", "&cL'ID&b{0} n'existe pas !");
|
||||
|
||||
// Worlds
|
||||
this.put("disabled-worlds", "&eLes particules sont désactivées dans ces mondes : &b{0}");
|
||||
this.put("disabled-worlds-none", "&Les particules sont désactivées dans aucuns mondes.");
|
||||
|
||||
// Reset
|
||||
this.put("reset-success", "&b{0} &aparticule(s) actives supprimées !");
|
||||
|
||||
// Fixed Effects
|
||||
this.put("fixed-create-missing-args", "&cImpossible de créer un effet fixe, vous oubliez des arguments : &b{0}");
|
||||
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{0} &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{0} &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{0} &c!");
|
||||
this.put("fixed-create-style-invalid", "&cImpossible de créer un effet fixe, le style &b{0} &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{0} &c!");
|
||||
this.put("fixed-create-style-non-fixable", "&cImpossible de créer un effet fixe, le style &b{0} &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("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{0} &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{0} &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{0} &c!");
|
||||
this.put("fixed-edit-style-invalid", "&cImpossible de modifier l'effet fixe, le style &b{0} &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{0} &c!");
|
||||
this.put("fixed-edit-style-non-fixable", "&cImpossible de modifier l'effet fixe, the style &b{0} &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{0} &ade l'effet fixe avec l'ID &b{1} &a!");
|
||||
|
||||
this.put("fixed-remove-invalid", "&cImpossible de supprimer l'effet fixe, vous n'avez pas d effets fixes avec l'ID &b{0} &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{0} &aont été supprimés !");
|
||||
|
||||
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{0}");
|
||||
|
||||
this.put("fixed-info-invalid", "&cImpossible d'obtenir l'information, vous n'avez pas de particules fixes avec l'ID &b{0}& 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{0} &eWorld: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eEffect: &b{5} &eStyle: &b{6} &eData: &b{7}");
|
||||
|
||||
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{0} &aeffets ont été supprimés dans un rayon &b{1} &cblocs !");
|
||||
|
||||
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!");
|
||||
|
||||
// Update Available
|
||||
this.put("update-available", "&eLa version (&b{0}&e) est disponible ! vous utilisez la version &bv{1}&d. https://www.spigotmc.org/resources/playerparticles.40261/");
|
||||
|
||||
// GUI
|
||||
this.put("gui-disabled", "&cL'interface du plugin à été désactivée !");
|
||||
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("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 ({0}/{1})");
|
||||
this.put("gui-previous-page-button", "Page Précédente ({0}/{1})");
|
||||
this.put("gui-click-to-load", "Cliquez pour charger : {0}");
|
||||
this.put("gui-shift-click-to-delete", "Touche SHIFT + clic-gauche pour effacer un effet");
|
||||
this.put("gui-particle-info", " - ID: &b{0} &eEffet: &b{1} &eStyle: &b{2} &eParamètre: &b{3}");
|
||||
this.put("gui-playerparticles", "PlayerParticles");
|
||||
this.put("gui-active-particles", "Particules actives: &b{0}");
|
||||
this.put("gui-saved-groups", "Groupes sauvegardés: &b{0}");
|
||||
this.put("gui-fixed-effects", "Effets fixes: &b{0}");
|
||||
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("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("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("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{0}&es restants)");
|
||||
this.put("gui-reset-particles", "Réinitialisez vos particules");
|
||||
this.put("gui-reset-particles-description", "Supprimez vos particules actives");
|
||||
this.put("gui-particle-name", "Particule #{0}");
|
||||
this.put("gui-click-to-edit-particle", "Cliquez pour éditer cette particule");
|
||||
this.put("gui-editing-particle", "Edition particule #{0}");
|
||||
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("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("gui-select-effect", "Sélectionnez les effets");
|
||||
this.put("gui-select-effect-description", "Mettez les effets de la particules à &b{0}");
|
||||
this.put("gui-select-style", "Sélectionnez le style");
|
||||
this.put("gui-select-style-description", "Mets le style de la particule à &b{0}");
|
||||
this.put("gui-select-data", "Sélectionnez les paramètres");
|
||||
this.put("gui-select-data-description", "Mets les paramètres de la particule à &b{0}");
|
||||
this.put("gui-select-data-note", "note #{0}");
|
||||
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");
|
||||
}};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,302 @@
|
|||
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>() {{
|
||||
// Plugin Prefix
|
||||
this.put("prefix", "&7[&3PlayerParticles&7] ");
|
||||
|
||||
// Command Errors
|
||||
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.");
|
||||
|
||||
// Command Descriptions
|
||||
this.put("command-descriptions", "Die folgenden Befehle stehen zur Auswahl:");
|
||||
this.put("command-descriptions-usage", "&e/pp {0} {1}");
|
||||
this.put("command-descriptions-help-1", "&7> &b/pp {0} &e- {1}");
|
||||
this.put("command-descriptions-help-2", "&7> &b/pp {0} {1} &e- {2}");
|
||||
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");
|
||||
|
||||
// Sub-Command Usage
|
||||
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");
|
||||
|
||||
// Command ID Lookup
|
||||
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{0}&cangelegt!");
|
||||
|
||||
// Other Command
|
||||
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{0} &cwurde nicht gefunden. Der Spieler mussen online sein.");
|
||||
this.put("other-unknown-command", "&cDer Befehl &b/pp {0} &cexistiert nicht.");
|
||||
this.put("other-success", "&eBefehl /pp command für &b{0}&eausgeführt. Ausgabe:");
|
||||
|
||||
// Add Command
|
||||
this.put("add-reached-max", "&cPartikel kann nicht angewendet werden, Sie haben die maximal zulässige Menge von &b{0} &cerreicht!");
|
||||
this.put("add-particle-applied", "&aEs wurde ein neues Partikel mit dem Effekt &b{0}&a, dem Stil &b{1}&aund den Daten &b{2}&aangewendet!");
|
||||
|
||||
// Data Command
|
||||
this.put("data-no-args", "&cFehlendes Argument für die Wirkung! Befehlsverwendung: &b/pp data <effect>");
|
||||
|
||||
// Edit Command
|
||||
this.put("edit-invalid-property", "&cEine ungültige Eigenschaft &b{0} &cwurde angegeben. Gültige Eigenschaften: &beffect&c, &bstyle&c, &bdata");
|
||||
this.put("edit-success-effect", "&aDer Effekt Ihres Partikels mit der ID &b{0} &awurde in &b{1}&ageändert!");
|
||||
this.put("edit-success-style", "&aDer Stil Ihres Partikels mit der ID &b{0} &awurde in &b{1}&ageändert!");
|
||||
this.put("edit-success-data", "&aDie Daten Ihres Partikels mit der ID &b{0} &awurden in &b{1}&ageändert!");
|
||||
|
||||
// Group Command
|
||||
this.put("group-invalid", "&cEs existiert keine gespeicherte Gruppe oder Voreinstellungsgruppe mit dem Namen &b{0}&c!");
|
||||
this.put("group-no-permission", "&cSie haben keine Berechtigung für einen Effekt oder Stil, um die Gruppe &b{0}&czu verwenden!");
|
||||
this.put("group-preset-no-permission", "&cEs fehlt die Berechtigung für einen Effekt oder Stil, um die voreingestellte Gruppe &b{0}&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 {0} <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{0}&agespeichert!");
|
||||
this.put("group-save-success-overwrite", "&aDie Gruppe mit dem Namen &b{0} &awurde mit Ihren aktuellen Partikeln aktualisiert!");
|
||||
this.put("group-load-success", "&aAngewendete &b{0} &aPartikel aus Ihrer gespeicherten Gruppe mit dem Namen &b{1}&a!");
|
||||
this.put("group-load-preset-success", "&aAngewendete &b{0} &aPartikel aus der voreingestellten Gruppe mit dem Namen &b{1}&a!");
|
||||
this.put("group-remove-preset", "&cSie können keine voreingestellte Gruppe entfernen!");
|
||||
this.put("group-remove-success", "&aDie Partikelgruppe mit dem Namen &b{0}&awurde entfernt!");
|
||||
this.put("group-info-header", "&eDie Gruppe &b{0} &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{0}");
|
||||
this.put("group-list-presets", "&eDie folgenden voreingestellten Gruppen sind verfügbar: &b{0}");
|
||||
|
||||
// Reload Command
|
||||
this.put("reload-success", "&aDas Plugin wurde neu geladen!");
|
||||
this.put("reload-no-permission", "&cSie haben keine Berechtigung, die Plugin-Einstellungen neu zu laden!");
|
||||
|
||||
// Remove Command
|
||||
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{0} &awurde entfernt!");
|
||||
this.put("remove-effect-success", "&aEntferne &b{0} &adeiner Partikel mit dem Effekt von &b{1}&a!");
|
||||
this.put("remove-effect-none", "&cSie haben keine Partikel mit dem Effekt &b{0}&cangelegt!");
|
||||
this.put("remove-style-success", "&b{0} &adeiner Partikel im Stil von &b{1} &aentfernt!");
|
||||
this.put("remove-style-none", "&cSie haben keine Partikel mit dem Stil &b{0}&cangelegt!");
|
||||
this.put("remove-unknown", "&cEs existiert kein Effekt oder Stil mit dem Namen &b{0}&c!");
|
||||
|
||||
// List Command
|
||||
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{0} &eEffekt: &b{1} &eStil: &b{2} &eDaten: &b{3}");
|
||||
|
||||
// Toggle Command
|
||||
this.put("toggle-on", "&ePartikel wurden umgeschaltet &aAN&e!");
|
||||
this.put("toggle-off", "&ePartikel wurden umgeschaltet &cAUS&e!");
|
||||
|
||||
// Rainbow
|
||||
this.put("rainbow", "&cR&6e&eg&ae&bn&9b&do&cg&4e&2n");
|
||||
|
||||
// Random
|
||||
this.put("random", "Zufällig");
|
||||
|
||||
// Effects
|
||||
this.put("effect-no-permission", "&cSie haben keine Berechtigung, den Effekt &b{0} &czu verwenden!");
|
||||
this.put("effect-invalid", "&cDer Effekt &b{0} &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{0}");
|
||||
this.put("effect-list-empty", "&cSie haben keine Berechtigung, Effekte zu verwenden!");
|
||||
|
||||
// Styles
|
||||
this.put("style-no-permission", "&cSie haben keine Berechtigung, den Stil &b{0} &czu verwenden!");
|
||||
this.put("style-event-spawning-info", "&eHinweis: Der Stil &b{0} &eerzeugt Partikel basierend auf einem Ereignis.");
|
||||
this.put("style-invalid", "&cDer Stil &b{0} &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{0}");
|
||||
|
||||
// Data
|
||||
this.put("data-usage-none", "&eDer Effekt &b{0} &everwendet keine Daten!");
|
||||
this.put("data-usage-block", "&eFür den Effekt &b{0} &ewerden &bBlockdaten &ebenötigt! &bFormat: <blockName>");
|
||||
this.put("data-usage-item", "&eFür den Effekt &b{0} &esind &bItem &eDaten erforderlich! &bFormat: <itemName>");
|
||||
this.put("data-usage-color", "&eFür den Effekt &b{0} &esind &bFarbdaten &eerforderlich! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>");
|
||||
this.put("data-usage-note", "&eFür den Effekt &b{0} &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{0} &cist kein Item!");
|
||||
this.put("data-invalid-material-not-block", "&cDas von Ihnen eingegebene &bBlock &cMaterial &b{0} &cist kein Block!");
|
||||
this.put("data-invalid-material-item", "&cDas von Ihnen eingegebene &bItem &cMaterial &b{0} &cexistiert nicht!");
|
||||
this.put("data-invalid-material-block", "&cDas von Ihnen eingegebene &bBlock &cMaterial &b{0} &cexistiert nicht!");
|
||||
|
||||
// Worlds
|
||||
this.put("disabled-worlds", "&ePartikel sind in diesen Welten deaktiviert: &b{0}");
|
||||
this.put("disabled-worlds-none", "&ePartikel sind in keiner Welt deaktiviert.");
|
||||
|
||||
// Reset
|
||||
this.put("reset-success", "&b{0} &aaktive Partikel entfernt!");
|
||||
|
||||
// Fixed Effects
|
||||
this.put("fixed-create-missing-args", "&cFixer Effekt kann nicht erstellt werden, es fehlen &b{0} &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{0} &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{0} &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{0}&c!");
|
||||
this.put("fixed-create-style-invalid", "&cEs kann kein fester Effekt erstellt werden. Ein Stil mit dem Namen &b{0} &cist nicht vorhanden.");
|
||||
this.put("fixed-create-style-no-permission", "&cEs kann kein fester Effekt erstellt werden. Sie haben keine Berechtigung, den Stil &b{0}&czu verwenden.");
|
||||
this.put("fixed-create-style-non-fixable", "&cFeste Effekte können nicht erstellt werden. Der Stil &b{0} &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("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{0} &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{0} &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{0}&c!");
|
||||
this.put("fixed-edit-style-invalid", "&cEin fester Effekt kann nicht bearbeitet werden, ein Stil mit dem Namen &b{0} &cist nicht vorhanden!");
|
||||
this.put("fixed-edit-style-no-permission", "&cFixierter Effekt kann nicht bearbeitet werden. Sie haben keine Berechtigung, den Stil &b{0}&czu verwenden.");
|
||||
this.put("fixed-edit-style-non-fixable", "&cFixer Effekt kann nicht bearbeitet werden. Der Stil &b{0} &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{0} &ades festen Effekts mit einer ID von &b{1}&a!");
|
||||
|
||||
this.put("fixed-remove-invalid", "&cFixierter Effekt kann nicht entfernt werden, Sie haben keinen Fixierten Effekt mit der ID &b{0}&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{0} &awurde entfernt!");
|
||||
|
||||
this.put("fixed-list-none", "&eDu hast keine festen Effekte!");
|
||||
this.put("fixed-list-success", "&eSie haben feste Effekte mit der ID: &b{0}");
|
||||
|
||||
this.put("fixed-info-invalid", "&cInformationen können nicht abgerufen werden. Sie haben keinen festen Effekt mit der ID &b{0}&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{0} &eWelt: &b{1} &eX: &b{2} &eY: &b{3} &eZ: {4} &b &eEffekt: &b{5} &eStil: &b{6} &eDaten: &b{7}");
|
||||
|
||||
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{0} &aEffekte in &b{1} &aBlöcken von Ihrem Standort entfernt!");
|
||||
|
||||
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!");
|
||||
|
||||
// Update Available
|
||||
this.put("update-available", "&eEin Update (&b{0}&e) ist verfügbar! Aktuelle Version: &bv{1}&e. https://www.spigotmc.org/resources/playerparticles.40261/");
|
||||
|
||||
// GUI
|
||||
this.put("gui-disabled", "&cDer Serveradministrator hat die GUI deaktiviert!");
|
||||
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("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 ({0}/{1})");
|
||||
this.put("gui-previous-page-button", "Vorherige Seite ({0}/{1})");
|
||||
this.put("gui-click-to-load", "Klicken Sie, um die folgenden {0} Partikel zu laden:");
|
||||
this.put("gui-shift-click-to-delete", "Umschaltklick zum Löschen");
|
||||
this.put("gui-particle-info", "- ID: &b{0} &eEffekt: &b{1} &eStil: &b{2} &eDaten: &b{3}");
|
||||
this.put("gui-playerparticles", "PlayerParticles");
|
||||
this.put("gui-active-particles", "Aktive Partikel: &b{0}");
|
||||
this.put("gui-saved-groups", "Gespeicherte Gruppen: &b{0}");
|
||||
this.put("gui-fixed-effects", "feste Effekte: &b{0}");
|
||||
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("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("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("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{0}&e)");
|
||||
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("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 #{0} bearbeiten");
|
||||
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("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("gui-select-effect", "Wählen Sie Partikeleffekt");
|
||||
this.put("gui-select-effect-description", "Setzt den Partikeleffekt auf &b{0}");
|
||||
this.put("gui-select-style", "Wählen Sie Partikelstil");
|
||||
this.put("gui-select-style-description", "Legt den Partikelstil auf &b{0} fest");
|
||||
this.put("gui-select-data", "Wählen Sie Partikeldaten");
|
||||
this.put("gui-select-data-description", "Setzt die Partikeldaten auf &b{0}");
|
||||
this.put("gui-select-data-note", "Hinweis #{0}");
|
||||
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");
|
||||
}};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package dev.esophose.playerparticles.locale;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface Locale {
|
||||
|
||||
String getLocaleName();
|
||||
|
||||
String getTranslatorName();
|
||||
|
||||
Map<String, String> getDefaultLocaleStrings();
|
||||
|
||||
}
|
|
@ -0,0 +1,287 @@
|
|||
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>() {{
|
||||
// Plugin Prefix
|
||||
this.put("prefix", "&7[&3PlayerParticles&7] ");
|
||||
|
||||
// Command Errors
|
||||
this.put("command-error-no-effects", "&cВы должны иметь доступ к эффектам чтобы использовать эту команду!");
|
||||
this.put("command-error-unknown", "&cНеизвестная команда, напишите &b/pp help &c, чтобы узнать команды.");
|
||||
|
||||
// Command Descriptions
|
||||
this.put("command-descriptions", "&eВам доступны команды ниже:");
|
||||
this.put("command-descriptions-usage", "&e/pp {0} {1}");
|
||||
this.put("command-descriptions-help-1", "&7> &b/pp {0} &e- {1}");
|
||||
this.put("command-descriptions-help-2", "&7> &b/pp {0} {1} &e- {2}");
|
||||
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", "Узнать, в каком мире Ваши частицы отключены.");
|
||||
|
||||
// Sub-Command Usage
|
||||
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> - Показывает частицы, сохранённые в группе.");
|
||||
|
||||
|
||||
// Command ID Lookup
|
||||
this.put("id-invalid", "&cID, который Вы ввели, недействительный, это должно быть целое число!");
|
||||
this.put("id-unknown", "&cВы не имеете частиц с ID &b{0}&c!");
|
||||
|
||||
// Other Command
|
||||
this.put("other-no-permission", "&cВы не имеете права, чтобы выполнять команды от других игроков!");
|
||||
this.put("other-missing-args", "&cВы не ввели некоторые аргументы. &b/ppo <Игрок> <Команда>");
|
||||
this.put("other-unknown-player", "&cИгрок &b{0} &cwas не найден. Скорее всего игрок оффлайн.");
|
||||
this.put("other-unknown-command", "&cКоманды &b/pp {0} &cне существует.");
|
||||
this.put("other-success", "&eВыполнена команда /pp от лица &b{0}&e. Результат:");
|
||||
|
||||
// Add Command
|
||||
this.put("add-reached-max", "&cНевозможно применить частицу, Вы использовали &b{0} &c, максимум допустимых!");
|
||||
this.put("add-particle-applied", "&aНовая частица была приложена к эффекту &b{0}&a, стилю &b{1}&a и данным &b{2}&a!");
|
||||
|
||||
// Data Command
|
||||
this.put("data-no-args", "&cВы не ввели аргумент для эффекта! Используйте &b/pp data <Эффект>");
|
||||
|
||||
// Edit Command
|
||||
this.put("edit-invalid-property", "&cНедействительное свойство &b{0} &cпредусмотрено. Действительные свойства: &bЭффект&c, &bСтиль&c, &bДанные.");
|
||||
this.put("edit-success-effect", "&aЭффект Ваших частиц под ID &b{0} &aбыл изменён на &b{1}&a!");
|
||||
this.put("edit-success-style", "&aСтиль Ваших частиц под ID &b{0} &aбыл изменён на &b{1}&a!");
|
||||
this.put("edit-success-data", "&aДанные Ваших частиц под ID &b{0} &aбыли изменены на &b{1}&a!");
|
||||
|
||||
// Group Command
|
||||
this.put("group-invalid", "&cСохранённая или заданная группа под названием &b{0}&cне существует!");
|
||||
this.put("group-no-permission", "&cВы потеряли право использовать эффект или стиль в группе &b{0}&c!");
|
||||
this.put("group-preset-no-permission", "&cВы потеряли право использовать эффект или стиль в заданной группе &b{0}&c!");
|
||||
this.put("group-reserved", "&cНазвание группы &bактивно &cи не может быть использованно!");
|
||||
this.put("group-no-name", "&cВы не ввели название группы! &b/pp {0} <названиеГруппы>");
|
||||
this.put("group-save-reached-max", "&cНевозможно сохранить группу, Вы превысили максимальное количество групп!");
|
||||
this.put("group-save-no-particles", "&cНевозможно сохранить группу, у Вас нет никаких приложенных частиц!");
|
||||
this.put("group-save-success", "&aВаши эффекты были сохранены в группе под названием &b{0}&a!");
|
||||
this.put("group-save-success-overwrite", "&aГруппа &b{0} &aбыла обновлена с Вашими частицами!");
|
||||
this.put("group-load-success", "&aИз группы &b{1}&a прикреплено частиц - &b{0}!");
|
||||
this.put("group-load-preset-success", "&aИз группы &b{1}&a прикреплено частиц - &b{0}");
|
||||
this.put("group-remove-preset", "&cВы не можете удалить заданную группу!");
|
||||
this.put("group-remove-success", "&aУдалена группа под названием &b{0}&a!");
|
||||
this.put("group-info-header", "&eГруппа &b{0} &eимеет следующие частицы:");
|
||||
this.put("group-list-none", "&eУ Вас нет никаких сохранённых групп с частицами!");
|
||||
this.put("group-list-output", "&eУ Вас есть следующие сохранённые группы: &b{0}");
|
||||
this.put("group-list-presets", "&eДоступны следующие заданные группы: &b{0}");
|
||||
|
||||
// Reload Command
|
||||
this.put("reload-success", "&aКонфигурация перезагружена!");
|
||||
this.put("reload-no-permission", "&cВы не имеете права, чтобы перезагружать параметры плагина!");
|
||||
|
||||
// Remove Command
|
||||
this.put("remove-no-args", "&cВы не ввели ID для удаления! &b/pp remove <ID>");
|
||||
this.put("remove-id-success", "&aВаши частицы под ID &b{0} &aбыли успешно удалены!");
|
||||
this.put("remove-effect-success", "&aКоличество удалённых частиц - &b{0} &a, эффектов - &b{1}&a!");
|
||||
this.put("remove-effect-none", "&cУ Вас нет каких-либо частиц с эффектом &b{0}&c!");
|
||||
this.put("remove-style-success", "&aКоличество удалённых частиц - &b{0} &a, стилей - &b{1}&a!");
|
||||
this.put("remove-style-none", "&cУ Вас нет каких-либо частиц со стилем &b{0}&c!");
|
||||
this.put("remove-unknown", "&cЭффект или стиль под названием &b{0} &cне существует!");
|
||||
|
||||
// List Command
|
||||
this.put("list-none", "&eУ вас нет каких-либо активных частиц!");
|
||||
this.put("list-you-have", "&eУ Вас есть следующие частицы:");
|
||||
this.put("list-output", "&eID: &b{0} &eЭффект: &b{1} &eСтиль: &b{2} &eДанные: &b{3}");
|
||||
|
||||
// Toggle Command
|
||||
this.put("toggle-on", "&eЧастицы были &aВКЛЮЧЕНЫ&e!");
|
||||
this.put("toggle-off", "&eЧастицы были &cВЫКЛЮЧЕНЫ&e!");
|
||||
|
||||
// Rainbow
|
||||
this.put("rainbow", "&cР&6а&eд&aу&bг&9а&d!");
|
||||
|
||||
// Random
|
||||
this.put("random", "Random");
|
||||
|
||||
// Effects
|
||||
this.put("effect-no-permission", "&cУ Вас нет прав использовать эффект &b{0} &c!");
|
||||
this.put("effect-invalid", "&cЭффект &b{0} &cне существует! Введите &b/pp effects, &cчтобы узнать доступные Вам эффекты.");
|
||||
this.put("effect-list", "&eВы можете использовать следующие эффекты: &b{0}");
|
||||
this.put("effect-list-empty", "&cУ Вас нет права использовать какие-либо эффекты!");
|
||||
|
||||
// Styles
|
||||
this.put("style-no-permission", "&cУ Вас нет прав использовать стиль &b{0} &c!");
|
||||
this.put("style-event-spawning-info", "&eЗаписка: стиль &b{0} &eспавнит частицы во время Ивента.");
|
||||
this.put("style-invalid", "&cСтиль &b{0} &cне существует! Введите &b/pp styles &cчтобы узнать доступные Вам стили.");
|
||||
this.put("style-list", "&eВы можете использовать следующие стили: &b{0}");
|
||||
|
||||
// Data
|
||||
this.put("data-usage-none", "&eЭффект &b{0} &eне использует какие-либо данные!");
|
||||
this.put("data-usage-block", "&eЭффект &b{0} &eзапрашивает &bблок &eданных! &bФормат: <названиеБлока>");
|
||||
this.put("data-usage-item", "&eЭффект &b{0} &eзапрашивает &bпредмет &eданных! &bФормат: <названиеПредмета>");
|
||||
this.put("data-usage-color", "&eЭффект &b{0} &eзапрашивает &bцвет &eданных! &bФормат: «0-255> <0-255> <0-255»|<rainbow>|<random>");
|
||||
this.put("data-usage-note", "&eЭффект &b{0} &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{0}&c, который Вы ввели, не является предметом!");
|
||||
this.put("data-invalid-material-not-block", "&bМатериал &cблока&b{0}&c, который Вы ввели, не является блоком!");
|
||||
this.put("data-invalid-material-item", "&bМатериал &cпредмета&b{0}, который Вы ввели, не существует!");
|
||||
this.put("ata-invalid-material-block", "&bМатериал &cблока&b{0}, который Вы ввели, не существует!");
|
||||
|
||||
// Worlds
|
||||
this.put("disabled-worlds", "&b{0} &eне поддерживает данные частицы.");
|
||||
this.put("disabled-worlds-none", "&eЧастицы не поддерживаются ни в каком мире.");
|
||||
|
||||
// Reset
|
||||
this.put("reset-success", "&aУдалено &aактивных частиц - &b{0}!");
|
||||
|
||||
// Fixed Effects
|
||||
this.put("fixed-create-missing-args", "&cНевозможно создать эффект, не введено запрашиваемых аргументов - &b{0}!");
|
||||
this.put("fixed-create-invalid-coords", "&cНевозможно создать эффект, одни или несколько координат, которые Вы ввели, неверны!");
|
||||
this.put("fixed-create-out-of-range", "&cНевозможно создать эффект, Вы должны быть в &b{0} &cблоках от желаемой локации!");
|
||||
this.put("fixed-create-looking-too-far", "&cНевозможно создать эффект, Вы стоите слишком далеко от блока, на который смотрите!");
|
||||
this.put("fixed-create-effect-invalid", "&cНевозможно создать эффект, эффект под названием &b{0} &cне существует!");
|
||||
this.put("fixed-create-effect-no-permission", "&cНевозможно создать эффект, у Вас нет права использовать эффект &b{0}&c!");
|
||||
this.put("fixed-create-style-invalid", "&cНевозможно создать эффект, стиль под названием &b{0} &cне существует!");
|
||||
this.put("fixed-create-style-no-permission", "&cНевозможно создать эффект, у Вас нет права использовать стиль &b{0}&c!");
|
||||
this.put("fixed-create-style-non-fixable", "&cНевозможно создать эффект, стиль &b{0} &cне может быть использован!");
|
||||
this.put("fixed-create-data-error", "&cНевозможно создать эффект, введённые данные неверны! Введите &b/pp data <Эффект>&c, чтобы найти правильный формат данных!");
|
||||
this.put("fixed-create-success", "&aВаш эффект был создан!");
|
||||
|
||||
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{0} &cблоках от желаемой локации!");
|
||||
this.put("fixed-edit-looking-too-far", "&cНевозможно изменить эффект, Вы стоите слишком далеко от блока, на который смотрите!");
|
||||
this.put("fixed-edit-effect-invalid", "&cНевозможно изменить эффект, эффект под названием &b{0} &cне существует!");
|
||||
this.put("fixed-edit-effect-no-permission", "&cНевозможно создать эффект, у Вас нет права использовать эффект &b{0}&c!");
|
||||
this.put("fixed-edit-style-invalid", "&cНевозможно изменить эффект, стиль под названием &b{0} &cне существует!");
|
||||
this.put("fixed-edit-style-no-permission", "&cНевозможно изменить эффект, у Вас нет права использовать стиль &b{0}&c!");
|
||||
this.put("fixed-edit-style-non-fixable", "&cНевозможно изменить эффект, стиль &b{0} &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{1}&a - &b{0}&a!");
|
||||
|
||||
this.put("fixed-remove-invalid", "&cНевозможно удалить эффект, у Вас нет эффекта под ID &b{0}&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{0} &aбыл удалён!");
|
||||
|
||||
this.put("fixed-list-none", "&eУ Вас нет каких-либо эффектов!");
|
||||
this.put("fixed-list-success", "&eУ Вас есть эффекты с этими ID: &b{0}");
|
||||
|
||||
this.put("fixed-info-invalid", "&cНевозможно получить информацию, у Вас нет эффекта под ID &b{0}&c!");
|
||||
this.put("fixed-info-no-args", "&cВы не ввели ID, по которому нужно узнать информацию!");
|
||||
this.put("fixed-info-invalid-args", "&cНевозможно получить информацию, введённый ID должен состоять из чисел!");
|
||||
this.put("fixed-info-success", "&eID: &b{0} &eМир: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eЭффект: &b{5} &eСтиль: &b{6} &eДанные: &b{7}");
|
||||
|
||||
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{0}&a!");
|
||||
|
||||
this.put("fixed-no-permission", "&cУ Вас нет права, чтобы использовать этот эффект!");
|
||||
this.put("fixed-max-reached", "&cВы достигли максимального количества эффектов!");
|
||||
this.put("fixed-invalid-command", "&cНедействительная команда для &b/pp fixed&c!");
|
||||
|
||||
// Update Available
|
||||
this.put("update-available", "&eОбновление (&b{0}&e) доступно! Ваша версия - &bv{1}&e. https://www.spigotmc.org/resources/playerparticles.40261/");
|
||||
|
||||
// GUI
|
||||
this.put("gui-disabled", "&cАдминистратор отключил интерфейс!");
|
||||
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("gui-commands-info", "Узнать подробнее о командах - &b/pp help");
|
||||
this.put("gui-back-button", "Назад");
|
||||
this.put("gui-next-page-button", "Следующая страница ({0}/{1})");
|
||||
this.put("gui-previous-page-button", "Предыдущая страница ({0}/{1})");
|
||||
this.put("gui-click-to-load", "Доступны {0} частицы для загрузки:");
|
||||
this.put("gui-shift-click-to-delete", "Shift+ЛКМ для удаления");
|
||||
this.put("gui-particle-info", " - ID: &b{0} &eЭффект: &b{1} &eСтиль: &b{2} &eДанные: &b{3}");
|
||||
this.put("gui-playerparticles", "Выбор частиц");
|
||||
this.put("gui-active-particles", "Активные частицы - &b{0}");
|
||||
this.put("gui-saved-groups", "Сохранённые группы - &b{0}");
|
||||
this.put("gui-fixed-effects", "Эффекты - &b{0}");
|
||||
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("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("gui-load-a-preset-group", "Установить группу");
|
||||
this.put("gui-load-a-preset-group-description", "Установка готовой группы частиц");
|
||||
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("gui-reset-particles", "Удалить ваши частицы");
|
||||
this.put("gui-reset-particles-description", "Убирает все Ваши активные частицы");
|
||||
this.put("gui-particle-name", "Частицы #{0}");
|
||||
this.put("gui-click-to-edit-particle", "Нажмите, чтобы изменить эффект, стиль или данные частиц");
|
||||
this.put("gui-editing-particle", "Изменение частиц #{0}");
|
||||
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("gui-create-particle", "Создать новые частицы");
|
||||
this.put("gui-create-particle-description", "Создать новые частицы с эффектом, стилем и данными");
|
||||
this.put("gui-create-particle-unavailable", "Вы достигли максимального числа частиц, которые можно создать");
|
||||
this.put("gui-select-effect", "Выбор эффекта частиц");
|
||||
this.put("gui-select-effect-description", "Выбрать эффект для частиц &b{0}");
|
||||
this.put("gui-select-style", "Выбор стиля частиц");
|
||||
this.put("gui-select-style-description", "Выбрать стиль для частиц &b{0}");
|
||||
this.put("gui-select-data", "Выбор данных частиц");
|
||||
this.put("gui-select-data-description", "Выбрать данные для частиц &b{0}");
|
||||
this.put("gui-select-data-note", "записка #{0}");
|
||||
}};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,302 @@
|
|||
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>() {{
|
||||
// Plugin Prefix
|
||||
this.put("prefix", "&7[&3PlayerParticles&7] ");
|
||||
|
||||
// Command Errors
|
||||
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.");
|
||||
|
||||
// Command Descriptions
|
||||
this.put("command-descriptions", "&eCác lệnh có sẵn:");
|
||||
this.put("command-descriptions-usage", "&e/pp {0} {1}");
|
||||
this.put("command-descriptions-help-1", "&7> &b/pp {0} &e- {1}");
|
||||
this.put("command-descriptions-help-2", "&7> &b/pp {0} {1} &e- {2}");
|
||||
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");
|
||||
|
||||
// Sub-Command Usage
|
||||
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");
|
||||
|
||||
// Command ID Lookup
|
||||
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{0}&c!");
|
||||
|
||||
// Other Command
|
||||
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{0} &c. Người chơi được chỉ định phải Online.");
|
||||
this.put("other-unknown-command", "&cLệnh &b/pp {0} &ckhông tồn tại.");
|
||||
this.put("other-success", "&eThi hành lệnh /pp command cho &b{0}&e. Output:");
|
||||
|
||||
// Add Command
|
||||
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{0} &cđược cho phép!");
|
||||
this.put("add-particle-applied", "&aHạt (Particle) mới đã được áp dụng với effect &b{0}&a, style &b{1}&a, và data &b{2}&a!");
|
||||
|
||||
// Data Command
|
||||
this.put("data-no-args", "&cĐã quên một đối số cho effect! Lệnh đúng: &b/pp data <effect>");
|
||||
|
||||
// Edit Command
|
||||
this.put("edit-invalid-property", "&cMột property không hợp lệ &b{0} &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{0} &ađã thanh đổi Hiệu ứng thành &b{1}&a!");
|
||||
this.put("edit-success-style", "&aHạt hiệu ứng của bạn với ID &b{0} &ađã thanh đổi Kiểu hiệu ứng thành &b{1}&a!");
|
||||
this.put("edit-success-data", "&aHạt hiệu ứng của bạn với ID &b{0} &ađã thanh đổi Dữ liệu thành &b{1}&a!");
|
||||
|
||||
// Group Command
|
||||
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{0}&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{0}&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{0}&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 {0} <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{0}&a!");
|
||||
this.put("group-save-success-overwrite", "&aGroup tên&b{0} &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{0} &ahạt hiệu ứng từ group được lưu với tên &b{1}&a!");
|
||||
this.put("group-load-preset-success", "&aĐã áp dụng &b{0} &ahạt hiệu ứng tự presen group với tên &b{1}&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{0}&a!");
|
||||
this.put("group-info-header", "&eGroup &b{0} &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{0}");
|
||||
this.put("group-list-presets", "&eCác preset group có sẵn: &b{0}");
|
||||
|
||||
// Reload Command
|
||||
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!");
|
||||
|
||||
// Remove Command
|
||||
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{0} &ađã bị xóa!");
|
||||
this.put("remove-effect-success", "&aĐã xóa &b{0} &ahạt hiệu ứng của bạn với hiệu ứng &b{1}&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{0}&c!");
|
||||
this.put("remove-style-success", "&aĐã xóa &b{0} &aHạt hiệu ứng của bạn với style &b{1}&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{0}&c!");
|
||||
this.put("remove-unknown", "&cEffect hoặc Style với tên &b{0} &ckhông tồn tại!");
|
||||
|
||||
// List Command
|
||||
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{0} &eEffect: &b{1} &eStyle: &b{2} &eData: &b{3}");
|
||||
|
||||
// Toggle Command
|
||||
this.put("toggle-on", "&eHạt hiệu ứng : &aON&e!");
|
||||
this.put("toggle-off", "&eHạt hiệu ứng : &cOFF&e!");
|
||||
|
||||
// Rainbow
|
||||
this.put("rainbow", "&cR&6a&ei&an&bb&9o&dw");
|
||||
|
||||
// Random
|
||||
this.put("random", "Ngẫu nhiên");
|
||||
|
||||
// Effects
|
||||
this.put("effect-no-permission", "&cBạn không có quyền để sử dụng Hiệu ứng &b{0} &c!");
|
||||
this.put("effect-invalid", "&cHiệu ứng &b{0} &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{0}");
|
||||
this.put("effect-list-empty", "&cBạn không có quyền để sử dụng bất kì hiệu ứng nào!");
|
||||
|
||||
// Styles
|
||||
this.put("style-no-permission", "&cbạn không có quyền để sử dụng Kiểu hiệu ứng &b{0} &c!");
|
||||
this.put("style-event-spawning-info", "&eNhắc nhở: Kiểu hiệu ứng &b{0} &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{0} &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{0}");
|
||||
|
||||
// Data
|
||||
this.put("data-usage-none", "&eHiệu ứng &b{0} &ekhông sử dụng bất kì Dữ liệu nào!");
|
||||
this.put("data-usage-block", "&eHiệu ứng &b{0} &eyêu cầu dữ liệu &bblock ! &bĐịnh dạng: <blockName>");
|
||||
this.put("data-usage-item", "&eHiệu ứng &b{0} &eyêu cầu dữ liệu &bitem! &bĐịnh dạng: <itemName>");
|
||||
this.put("data-usage-color", "&eHiệu ứng &b{0} &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{0} &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{0} &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{0} &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{0} 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{0} bạn đã nhập không tồn tại!");
|
||||
|
||||
// Worlds
|
||||
this.put("disabled-worlds", "&eCác Hạt hiệu ứng bị cấm tại thế giới này: &b{0}");
|
||||
this.put("disabled-worlds-none", "&eKhông có thể giới nào cấm Hạt hiệu ứng.");
|
||||
|
||||
// Reset
|
||||
this.put("reset-success", "&aĐã xóa &b{0} &aHạt hiệu ứng hoạt động!");
|
||||
|
||||
// Fixed Effects
|
||||
this.put("fixed-create-missing-args", "&cKhông thể tạo Hiệu ứng cố định, bạn đã quên &b{0} &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{0} &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{0} &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{0}&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{0} &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{0}&c!");
|
||||
this.put("fixed-create-style-non-fixable", "&cKhông thể tạo Hiệu ứng cố định, Kiểu hiệu ứng &b{0} &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("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{0} &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{0} &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{0}&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{0} &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{0}&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{0} &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{0} &acủa Hiệu ứng cố định với một ID của &b{1}&a!");
|
||||
|
||||
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{0}&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{0} &ađã bị xóa!");
|
||||
|
||||
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{0}");
|
||||
|
||||
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{0}&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{0} &eWorld: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eEffect: &b{5} &eStyle: &b{6} &eData: &b{7}");
|
||||
|
||||
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{0} &aHiệu ứng cố định trong bán kính &b{1} &akhối từ vị trí của bạn!");
|
||||
|
||||
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!");
|
||||
|
||||
// Update Available
|
||||
this.put("update-available", "&eĐã có bản cập nhật (&b{0}&e)! bạn đang sử dụng &bv{1}&e. https://www.spigotmc.org/resources/playerparticles.40261/");
|
||||
|
||||
// GUI
|
||||
this.put("gui-disabled", "&cAmdinistrator đã cấm GUI!");
|
||||
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("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 ({0}/{1})");
|
||||
this.put("gui-previous-page-button", "Trang trước ({0}/{1})");
|
||||
this.put("gui-click-to-load", "Nhấn để tải {0} Hạt hiệu ứng sau:");
|
||||
this.put("gui-shift-click-to-delete", "Shift Click để xóa");
|
||||
this.put("gui-particle-info", " - ID: &b{0} &eEffect: &b{1} &eStyle: &b{2} &eData: &b{3}");
|
||||
this.put("gui-playerparticles", "HIỆU ỨNG");
|
||||
this.put("gui-active-particles", "Hạt hiệu ứng đang hoạt động: &b{0}");
|
||||
this.put("gui-saved-groups", "Groups đã lưu: &b{0}");
|
||||
this.put("gui-fixed-effects", "Hiệu ứng cố định: &b{0}");
|
||||
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("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("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("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{0}&es left)");
|
||||
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("gui-particle-name", "Hạt hiệu ứng #{0}");
|
||||
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 #{0}");
|
||||
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("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("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{0}");
|
||||
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{0}");
|
||||
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{0}");
|
||||
this.put("gui-select-data-note", "note #{0}");
|
||||
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");
|
||||
}};
|
||||
}
|
||||
}
|
|
@ -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.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.particles.OtherPPlayer;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
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) {
|
||||
if (cmd.getName().equalsIgnoreCase("pp")) {
|
||||
String commandName = args.length > 0 ? args[0] : "";
|
||||
CommandModule commandModule = this.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;
|
||||
|
||||
this.playerParticles.getManager(DataManager.class).getPPlayer(p.getUniqueId(), (pplayer) -> {
|
||||
if (commandModule.requiresEffects() && PlayerParticles.getInstance().getManager(PermissionManager.class).getEffectNamesUserHasPermissionFor(p).isEmpty()) {
|
||||
LangManager.sendMessage(pplayer, Lang.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<>();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
package dev.esophose.playerparticles.manager;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
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"),
|
||||
MESSAGE_PREFIX("message-prefix", "&7[&3PlayerParticles&7]", "The prefix to use for all PlayerParticles messages", "This is useless if use-message-prefix is set to false"),
|
||||
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");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
@ -18,15 +22,49 @@ import java.sql.ResultSet;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 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 +75,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 +91,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 +117,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 +128,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 +170,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 +210,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 +231,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 +250,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 +261,7 @@ public class DataManager {
|
|||
}
|
||||
}));
|
||||
|
||||
getPPlayer(playerUUID, (pplayer) -> pplayer.setParticlesHidden(particlesHidden));
|
||||
this.getPPlayer(playerUUID, (pplayer) -> pplayer.setParticlesHidden(particlesHidden));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,11 +270,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 +283,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 +291,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 +302,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 +323,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 +340,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 +373,7 @@ public class DataManager {
|
|||
}
|
||||
}));
|
||||
|
||||
getPPlayer(playerUUID, (pplayer) -> pplayer.getParticleGroups().remove(group));
|
||||
this.getPPlayer(playerUUID, (pplayer) -> pplayer.getParticleGroups().remove(group));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -344,11 +382,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 +403,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 +416,7 @@ public class DataManager {
|
|||
}
|
||||
}));
|
||||
|
||||
getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> pplayer.addFixedEffect(fixedEffect));
|
||||
this.getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> pplayer.addFixedEffect(fixedEffect));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -386,10 +424,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 +438,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 +457,7 @@ public class DataManager {
|
|||
}
|
||||
}));
|
||||
|
||||
getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> {
|
||||
this.getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> {
|
||||
pplayer.removeFixedEffect(fixedEffect.getId());
|
||||
pplayer.addFixedEffect(fixedEffect);
|
||||
});
|
||||
|
@ -432,11 +470,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 +485,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 +501,7 @@ public class DataManager {
|
|||
}
|
||||
}));
|
||||
|
||||
getPPlayer(playerUUID, (pplayer) -> pplayer.removeFixedEffect(id));
|
||||
this.getPPlayer(playerUUID, (pplayer) -> pplayer.removeFixedEffect(id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -471,8 +509,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 +518,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() + '_';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
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";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +1,44 @@
|
|||
package dev.esophose.playerparticles.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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.SettingManager.Setting;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
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;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
// TODO: Remove static guiInventories and subsequent methods
|
||||
public class GuiManager extends Manager implements Listener, Runnable {
|
||||
|
||||
private static List<GuiInventory> guiInventories = new ArrayList<>();
|
||||
private static BukkitTask guiTask = null;
|
||||
private BukkitTask guiTask = null;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
public GuiManager(PlayerParticles playerParticles) {
|
||||
super(playerParticles);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,7 +49,7 @@ public class GuiHandler extends BukkitRunnable implements Listener {
|
|||
List<GuiInventory> toRemoveList = new ArrayList<>();
|
||||
|
||||
for (GuiInventory inventory : guiInventories) {
|
||||
PPlayer pplayer = DataManager.getPPlayer(inventory.getPPlayer().getUniqueId());
|
||||
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(inventory.getPPlayer().getUniqueId());
|
||||
if (pplayer == null) {
|
||||
toRemoveList.add(inventory);
|
||||
continue;
|
||||
|
@ -85,14 +91,14 @@ public class GuiHandler extends BukkitRunnable implements Listener {
|
|||
* @return True if the GUI is disabled
|
||||
*/
|
||||
public static boolean isGuiDisabled() {
|
||||
return !PSetting.GUI_ENABLED.getBoolean();
|
||||
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) {
|
||||
if (inventory.getPPlayer().getUniqueId().equals(player.getUniqueId()) && inventory.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
||||
|
@ -113,7 +119,7 @@ public class GuiHandler extends BukkitRunnable implements Listener {
|
|||
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);
|
||||
|
@ -128,7 +134,7 @@ public class GuiHandler extends BukkitRunnable implements Listener {
|
|||
*
|
||||
* @param nextInventory The GuiInventory to transition to
|
||||
*/
|
||||
protected static void transition(GuiInventory nextInventory) {
|
||||
public static void transition(GuiInventory nextInventory) {
|
||||
removeGuiInventory(nextInventory.getPPlayer());
|
||||
guiInventories.add(nextInventory);
|
||||
nextInventory.getPPlayer().getPlayer().openInventory(nextInventory.getInventory());
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package dev.esophose.playerparticles.manager;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
|
||||
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.VietnameseLocale;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
|
||||
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;
|
||||
|
||||
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 (!configuration.contains(key))
|
||||
configuration.set(key, value);
|
||||
}
|
||||
|
||||
configuration.save(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
if (!this.playerParticles.getDataFolder().exists())
|
||||
this.playerParticles.getDataFolder().mkdirs();
|
||||
|
||||
this.registerLocale(new EnglishLocale());
|
||||
this.registerLocale(new FrenchLocale());
|
||||
this.registerLocale(new GermanLocale());
|
||||
this.registerLocale(new RussianLocale());
|
||||
this.registerLocale(new VietnameseLocale());
|
||||
|
||||
File targetLocaleFile = new File(Setting.LOCALE.getString() + ".lang");
|
||||
if (!targetLocaleFile.exists()) {
|
||||
targetLocaleFile = new File("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 sendPrefixedMessage(CommandSender sender, String messageKey, StringPlaceholders stringPlaceholders) {
|
||||
sender.sendMessage(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 sendPrefixedMessage(CommandSender sender, String messageKey) {
|
||||
this.sendPrefixedMessage(sender, messageKey, new StringPlaceholders());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 sendMessage(CommandSender sender, String messageKey, StringPlaceholders stringPlaceholders) {
|
||||
sender.sendMessage(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 sendMessage(CommandSender sender, String messageKey) {
|
||||
this.sendMessage(sender, messageKey, StringPlaceholders.empty());
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
||||
}
|
|
@ -27,29 +27,29 @@ 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 pluginDataFolder = PlayerParticles.getInstance().getDataFolder();
|
||||
File groupsFile = new File(pluginDataFolder.getAbsolutePath() + File.separator + 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 +97,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 +112,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 +124,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 +146,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 +164,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 +172,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();
|
||||
}
|
||||
}
|
||||
|
@ -182,21 +182,26 @@ 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
|
||||
*
|
||||
* @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 +210,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;
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
package dev.esophose.playerparticles.manager;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.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.styles.api.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,54 @@ 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() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the player to the array when they join
|
||||
|
@ -49,7 +79,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 +89,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 +99,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 +108,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 +147,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 +164,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 +185,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 +195,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 +204,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 +214,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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
package dev.esophose.playerparticles.manager;
|
||||
|
||||
import dev.esophose.playerparticles.styles.DefaultStyles;
|
||||
import dev.esophose.playerparticles.styles.api.ParticleStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -3,18 +3,18 @@ package dev.esophose.playerparticles.manager;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
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.manager.SettingManager.Setting;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import dev.esophose.playerparticles.particles.ParticleEffect;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
public class PermissionManager {
|
||||
public class PermissionManager extends Manager {
|
||||
|
||||
private static final String PERMISSION_PREFIX = "playerparticles.";
|
||||
|
||||
|
@ -66,7 +66,17 @@ public class PermissionManager {
|
|||
}
|
||||
}
|
||||
|
||||
private PermissionManager() {
|
||||
public PermissionManager(PlayerParticles playerParticles) {
|
||||
super(playerParticles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
|
||||
|
@ -76,8 +86,10 @@ public class PermissionManager {
|
|||
* @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 +99,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 +115,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 +131,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 +147,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 +162,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 +172,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 +185,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 +194,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 +205,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 +218,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 +230,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 +244,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 +258,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 +272,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 +286,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 +300,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 +310,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 +320,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package dev.esophose.playerparticles.manager;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.Setting;
|
||||
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) {
|
||||
LangManager.sendCommandSenderMessage(
|
||||
e.getPlayer(),
|
||||
Lang.UPDATE_AVAILABLE,
|
||||
this.updateVersion,
|
||||
this.playerParticles.getDescription().getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -27,7 +27,7 @@ public class SettingManager {
|
|||
/**
|
||||
* An enum containing all settings in the config.yml for the plugin
|
||||
*/
|
||||
public enum PSetting {
|
||||
public enum Setting {
|
||||
VERSION(PSettingType.DOUBLE),
|
||||
TICKS_PER_PARTICLE(PSettingType.LONG),
|
||||
CHECK_UPDATES(PSettingType.BOOLEAN),
|
||||
|
@ -72,7 +72,7 @@ public class SettingManager {
|
|||
private final PSettingType settingType;
|
||||
private Object value = null;
|
||||
|
||||
PSetting(PSettingType settingType) {
|
||||
Setting(PSettingType settingType) {
|
||||
this.settingType = settingType;
|
||||
}
|
||||
|
||||
|
@ -93,22 +93,22 @@ public class SettingManager {
|
|||
String configPath = this.name().toLowerCase().replaceAll("_", "-");
|
||||
switch (this.settingType) {
|
||||
case BOOLEAN:
|
||||
this.value = PlayerParticles.getPlugin().getConfig().getBoolean(configPath);
|
||||
this.value = PlayerParticles.getInstance().getConfig().getBoolean(configPath);
|
||||
break;
|
||||
case INTEGER:
|
||||
this.value = PlayerParticles.getPlugin().getConfig().getInt(configPath);
|
||||
this.value = PlayerParticles.getInstance().getConfig().getInt(configPath);
|
||||
break;
|
||||
case LONG:
|
||||
this.value = PlayerParticles.getPlugin().getConfig().getLong(configPath);
|
||||
this.value = PlayerParticles.getInstance().getConfig().getLong(configPath);
|
||||
break;
|
||||
case DOUBLE:
|
||||
this.value = PlayerParticles.getPlugin().getConfig().getDouble(configPath);
|
||||
this.value = PlayerParticles.getInstance().getConfig().getDouble(configPath);
|
||||
break;
|
||||
case STRING:
|
||||
this.value = PlayerParticles.getPlugin().getConfig().getString(configPath);
|
||||
this.value = PlayerParticles.getInstance().getConfig().getString(configPath);
|
||||
break;
|
||||
case STRING_LIST:
|
||||
this.value = PlayerParticles.getPlugin().getConfig().getStringList(configPath);
|
||||
this.value = PlayerParticles.getInstance().getConfig().getStringList(configPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ public class SettingManager {
|
|||
if (material != null)
|
||||
return material;
|
||||
|
||||
List<String> materials = PlayerParticles.getPlugin().getConfig().getStringList(configPath);
|
||||
List<String> materials = PlayerParticles.getInstance().getConfig().getStringList(configPath);
|
||||
|
||||
try {
|
||||
if (materials.size() == 1) {
|
||||
|
@ -251,7 +251,7 @@ public class SettingManager {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
PlayerParticles.getPlugin().getLogger().severe("Missing GUI icon for '" + this.name().toLowerCase() + "'");
|
||||
PlayerParticles.getInstance().getLogger().severe("Missing GUI icon for '" + this.name().toLowerCase() + "'");
|
||||
}
|
||||
|
||||
if (material == null)
|
||||
|
@ -278,7 +278,7 @@ public class SettingManager {
|
|||
* Resets the settings to their default values
|
||||
*/
|
||||
public static void reload() {
|
||||
for (PSetting setting : PSetting.values())
|
||||
for (Setting setting : Setting.values())
|
||||
setting.resetDefault();
|
||||
|
||||
for (GuiIcon icon : GuiIcon.values())
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.Setting;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -22,19 +22,21 @@ public class PPlayerMovementListener implements Listener {
|
|||
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 +53,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)) {
|
||||
|
|
|
@ -9,9 +9,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.util.NMSUtil;
|
||||
import dev.esophose.playerparticles.manager.ParticleManager;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.PSetting;
|
||||
import dev.esophose.playerparticles.manager.SettingManager.Setting;
|
||||
import dev.esophose.playerparticles.styles.api.PParticle;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
|
@ -326,9 +327,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;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dev.esophose.playerparticles.particles;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -53,16 +54,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package dev.esophose.playerparticles.particles;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import dev.esophose.playerparticles.manager.ParticleManager;
|
||||
|
@ -194,19 +195,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;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package dev.esophose.playerparticles.styles;
|
||||
|
||||
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;
|
||||
import dev.esophose.playerparticles.manager.ParticleStyleManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
public class DefaultStyles {
|
||||
|
||||
|
@ -51,49 +49,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package dev.esophose.playerparticles.styles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.styles.api.PParticle;
|
||||
import dev.esophose.playerparticles.styles.api.ParticleStyle;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -10,12 +14,8 @@ 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;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
|
||||
|
||||
|
@ -52,12 +52,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.esophose.playerparticles.styles;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -52,12 +53,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -19,6 +9,15 @@ 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 org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ParticleStyleCelebration implements ParticleStyle {
|
||||
|
||||
|
@ -26,7 +25,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 +33,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);
|
||||
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 +62,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;
|
||||
|
@ -72,11 +75,11 @@ public class ParticleStyleCelebration implements ParticleStyle {
|
|||
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 +92,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() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package dev.esophose.playerparticles.styles;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -23,7 +24,7 @@ public class ParticleStyleHurt implements ParticleStyle, Listener {
|
|||
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 +54,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package dev.esophose.playerparticles.styles;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -43,12 +44,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -24,7 +25,7 @@ public class ParticleStyleSwords implements ParticleStyle, Listener {
|
|||
private static final List<String> SWORD_NAMES;
|
||||
|
||||
static {
|
||||
SWORD_NAMES = new ArrayList<String>();
|
||||
SWORD_NAMES = new ArrayList<>();
|
||||
SWORD_NAMES.addAll(Arrays.asList("WOOD_SWORD", "STONE_SWORD", "IRON_SWORD", "GOLD_SWORD", "GOLDEN_SWORD", "DIAMOND_SWORD", "TRIDENT"));
|
||||
}
|
||||
|
||||
|
@ -32,7 +33,7 @@ public class ParticleStyleSwords implements ParticleStyle, Listener {
|
|||
List<PParticle> baseParticles = DefaultStyles.NORMAL.getParticles(particle, location);
|
||||
|
||||
int multiplyingFactor = 15; // Uses the same logic as ParticleStyleNormal 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()));
|
||||
}
|
||||
|
@ -62,14 +63,16 @@ public class ParticleStyleSwords implements ParticleStyle, Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityDamageEntity(EntityDamageByEntityEvent event) {
|
||||
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
|
||||
|
||||
if (event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity) {
|
||||
Player player = (Player) event.getDamager();
|
||||
LivingEntity entity = (LivingEntity) 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.SWORDS)) {
|
||||
Location loc = entity.getLocation().clone().add(0, 1, 0);
|
||||
ParticleManager.displayParticles(particle, DefaultStyles.SWORDS.getParticles(particle, loc));
|
||||
particleManager.displayParticles(particle, DefaultStyles.SWORDS.getParticles(particle, loc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package dev.esophose.playerparticles.styles.api;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.ParticleStyleManager;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
@ -57,7 +59,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;
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
package dev.esophose.playerparticles.styles.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
|
||||
public class ParticleStyleManager {
|
||||
|
||||
/**
|
||||
* Arrays that contain all registered styles
|
||||
*/
|
||||
private static List<ParticleStyle> styles = new ArrayList<>();
|
||||
private static List<ParticleStyle> customHandledStyles = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Registers a style that is put into the plugin's update loop
|
||||
*
|
||||
* @param style The style to add
|
||||
*/
|
||||
public static void registerStyle(ParticleStyle style) {
|
||||
if (style == null) {
|
||||
PlayerParticles.getPlugin().getLogger().severe("Tried to register a null style");
|
||||
return;
|
||||
}
|
||||
|
||||
if (style.getName() == null || style.getName().trim().equals("")) {
|
||||
PlayerParticles.getPlugin().getLogger().severe("Tried to register a style with a null or empty name: '" + style.getName() + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
for (ParticleStyle testAgainst : styles) {
|
||||
if (testAgainst.getName().equalsIgnoreCase(style.getName())) {
|
||||
PlayerParticles.getPlugin().getLogger().severe("Tried to register two styles with the same name spelling: '" + style.getName() + "'");
|
||||
return;
|
||||
} else if (testAgainst.equals(style)) {
|
||||
PlayerParticles.getPlugin().getLogger().severe("Tried to register the same style twice: '" + style.getName() + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
styles.add(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a style that isn't updated on the normal update loop
|
||||
*
|
||||
* @param style The style to register
|
||||
*/
|
||||
public static void registerCustomHandledStyle(ParticleStyle style) {
|
||||
registerStyle(style);
|
||||
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 static boolean isCustomHandled(ParticleStyle style) {
|
||||
return customHandledStyles.contains(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all registered styles
|
||||
*
|
||||
* @return A List of ParticleStyles that are registered
|
||||
*/
|
||||
public static List<ParticleStyle> getStyles() {
|
||||
return styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all styles from the registry
|
||||
*
|
||||
* It is not recommended to call this
|
||||
*/
|
||||
public static void reset() {
|
||||
styles.clear();
|
||||
customHandledStyles.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 static void updateTimers() {
|
||||
for (ParticleStyle style : styles)
|
||||
style.updateTimers();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package dev.esophose.playerparticles.updater;
|
||||
|
||||
import java.sql.Statement;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
|
||||
/**
|
||||
* This class handles updating the SQLite or MySQL data from older versions to the current version
|
||||
* Everything is purposely done on the main thread to prevent the plugin from starting before all the data is updated
|
||||
*/
|
||||
public class DataUpdater {
|
||||
|
||||
/**
|
||||
* Checks to make sure all the correct database tables exist
|
||||
* If they don't, create them
|
||||
*/
|
||||
public static void tryCreateTables() {
|
||||
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
|
||||
try (Statement createStatement = connection.createStatement()) {
|
||||
createStatement.addBatch("CREATE TABLE IF NOT EXISTS pp_settings (player_uuid VARCHAR(36), particles_hidden TINYINT)");
|
||||
createStatement.addBatch("CREATE TABLE IF NOT EXISTS pp_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 pp_group (uuid VARCHAR(36), owner_uuid VARCHAR(36), name VARCHAR(100), PRIMARY KEY(uuid))");
|
||||
createStatement.addBatch("CREATE TABLE IF NOT EXISTS pp_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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the plugin data from one version of the plugin to the current version
|
||||
*
|
||||
* @param configVersion The old version of the plugin
|
||||
* @param currentVersion The current version of the plugin
|
||||
*/
|
||||
public static void updateData(double configVersion, double currentVersion) {
|
||||
if (configVersion == currentVersion) return;
|
||||
|
||||
PlayerParticles.getPlugin().getLogger().warning("Starting to update SQLite/MySQL data from " + (configVersion < 5.3 ? "a legacy version" : "v" + configVersion) + " to v" + PlayerParticles.getPlugin().getDescription().getVersion() + ", this may take a while...");
|
||||
|
||||
if (configVersion < 5.3) {
|
||||
updateFrom_legacy_to_current();
|
||||
} else if (configVersion == 5.3) {
|
||||
updateFrom_5_3_to_current();
|
||||
} else {
|
||||
PlayerParticles.getPlugin().getLogger().warning("Found nothing to update.");
|
||||
}
|
||||
|
||||
PlayerParticles.getPlugin().getLogger().warning("Finished updating SQLite/MySQL data from " + (configVersion < 5.3 ? "a legacy version" : "v" + configVersion) + " to v" + PlayerParticles.getPlugin().getDescription().getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the data from versions older than v5.2
|
||||
*/
|
||||
private static void updateFrom_legacy_to_current() {
|
||||
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the data from v5.3 to current
|
||||
* Note: v5.3 was never officially released
|
||||
*/
|
||||
private static void updateFrom_5_3_to_current() {
|
||||
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
|
||||
// Create player settings table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String updateQuery = "CREATE TABLE IF NOT EXISTS pp_settings (player_uuid VARCHAR(36), particles_hidden TINYINT)";
|
||||
statement.executeUpdate(updateQuery);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package dev.esophose.playerparticles.updater;
|
||||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.manager.LangManager;
|
||||
import dev.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PluginUpdateListener implements Listener {
|
||||
|
||||
/**
|
||||
* 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() && PlayerParticles.getPlugin().getUpdateVersion() != null) {
|
||||
LangManager.sendCommandSenderMessage(
|
||||
e.getPlayer(),
|
||||
Lang.UPDATE_AVAILABLE,
|
||||
PlayerParticles.getPlugin().getUpdateVersion(),
|
||||
PlayerParticles.getPlugin().getDescription().getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ import java.util.zip.GZIPOutputStream;
|
|||
* Check out https://bStats.org/ to learn more about bStats!
|
||||
*/
|
||||
@SuppressWarnings({"WeakerAccess", "unused", "unchecked"})
|
||||
public class Metrics {
|
||||
public final class Metrics {
|
||||
|
||||
static {
|
||||
// You can use the property to disable the check in your test environment
|
||||
|
|
|
@ -2,7 +2,7 @@ package dev.esophose.playerparticles.util;
|
|||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class NMSUtil {
|
||||
public final class NMSUtil {
|
||||
|
||||
private static String cachedVersion = null;
|
||||
private static int cachedVersionNumber = -1;
|
||||
|
@ -28,7 +28,7 @@ public class NMSUtil {
|
|||
public static int getVersionNumber() {
|
||||
if (cachedVersionNumber == -1) {
|
||||
String name = getVersion().substring(3);
|
||||
cachedVersionNumber = Integer.valueOf(name.substring(0, name.length() - 4));
|
||||
cachedVersionNumber = Integer.parseInt(name.substring(0, name.length() - 4));
|
||||
}
|
||||
return cachedVersionNumber;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import java.util.List;
|
|||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class ParticleUtils {
|
||||
public final class ParticleUtils {
|
||||
|
||||
private static List<String> blockMaterials, itemMaterials;
|
||||
|
||||
static {
|
||||
blockMaterials = new ArrayList<String>();
|
||||
itemMaterials = new ArrayList<String>();
|
||||
blockMaterials = new ArrayList<>();
|
||||
itemMaterials = new ArrayList<>();
|
||||
|
||||
for (Material mat : Material.values()) {
|
||||
if (mat.isBlock()) {
|
||||
|
@ -92,10 +92,10 @@ public class ParticleUtils {
|
|||
*/
|
||||
public static String formatName(String string) {
|
||||
String[] words = string.split("_");
|
||||
String result = "";
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String word : words)
|
||||
result += Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase() + " ";
|
||||
return result;
|
||||
result.append(Character.toUpperCase(word.charAt(0))).append(word.substring(1).toLowerCase()).append(" ");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package dev.esophose.playerparticles.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class StringPlaceholders {
|
||||
|
||||
private Map<String, String> placeholders;
|
||||
|
||||
public StringPlaceholders() {
|
||||
this.placeholders = new HashMap<>();
|
||||
}
|
||||
|
||||
public void addPlaceholder(String placeholder, Object value) {
|
||||
this.placeholders.put(placeholder, objectToString(value));
|
||||
}
|
||||
|
||||
public String apply(String string) {
|
||||
for (String key : this.placeholders.keySet())
|
||||
string = string.replaceAll(Pattern.quote('%' + key + '%'), Matcher.quoteReplacement(this.placeholders.get(key)));
|
||||
return string;
|
||||
}
|
||||
|
||||
public Map<String, String> getPlaceholders() {
|
||||
return Collections.unmodifiableMap(this.placeholders);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static Builder builder(String placeholder, Object value) {
|
||||
return new Builder(placeholder, objectToString(value));
|
||||
}
|
||||
|
||||
public static StringPlaceholders empty() {
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
public static StringPlaceholders single(String placeholder, Object value) {
|
||||
return builder(placeholder, value).build();
|
||||
}
|
||||
|
||||
private static String objectToString(Object object) {
|
||||
return object != null ? object.toString() : "null";
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private StringPlaceholders stringPlaceholders;
|
||||
|
||||
private Builder() {
|
||||
this.stringPlaceholders = new StringPlaceholders();
|
||||
}
|
||||
|
||||
private Builder(String placeholder, Object value) {
|
||||
this();
|
||||
this.stringPlaceholders.addPlaceholder(placeholder, objectToString(value));
|
||||
}
|
||||
|
||||
public Builder addPlaceholder(String placeholder, Object value) {
|
||||
this.stringPlaceholders.addPlaceholder(placeholder, objectToString(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public String apply(String string) {
|
||||
return this.stringPlaceholders.apply(string);
|
||||
}
|
||||
|
||||
public StringPlaceholders build() {
|
||||
return this.stringPlaceholders;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package dev.esophose.playerparticles.updater;
|
||||
package dev.esophose.playerparticles.util;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
|
@ -1,5 +1,5 @@
|
|||
# __________ __ __________ __ __ __ _________
|
||||
# \______ \ | _____ ___ __ __________\______ \_____ ________/ |_|__| ____ | | ____ ______ \______ \
|
||||
# _________ __ __________ __ __ __ _________
|
||||
# \______ \ | _____ ___ __ __________\______ \_____ ________/ |_|__| ____ | | ____ ______ \______ \
|
||||
# | ___/ | \__ \< | |/ __ \_ __ \ ___/\__ \\_ __ \ __\ |/ ___\| | _/ __ \ / ___/ / /
|
||||
# | | | |__/ __ \\___ \ ___/| | \/ | / __ \| | \/| | | \ \___| |_\ ___/ \___ \ / /
|
||||
# |____| |____(____ / ____|\___ >__| |____| (____ /__| |__| |__|\___ >____/\___ >____ > /____/
|
||||
|
@ -22,15 +22,10 @@ lang-file: 'en_US.lang'
|
|||
# Default: true
|
||||
messages-enabled: true
|
||||
|
||||
# Whether or not to use the message-prefix field when displaying messages
|
||||
# Whether or not to display the plugin message prefix when displaying messages
|
||||
# Default: true
|
||||
use-message-prefix: true
|
||||
|
||||
# The prefix to use for all PlayerParticles messages
|
||||
# This is useless if use-message-prefix is set to false
|
||||
# Default: '&7[&3PlayerParticles&7]'
|
||||
message-prefix: '&7[&3PlayerParticles&7]'
|
||||
|
||||
# If the command /pp gui is enabled
|
||||
# Disable this if you have your own custom GUI through another plugin
|
||||
# Default: true
|
||||
|
|
|
@ -259,7 +259,7 @@ gui-edit-style-description: "Nhấn để chỉnh sửa Kiểu hiệu ứng củ
|
|||
gui-edit-data: "Chỉnh sửa Dữ liệu"
|
||||
gui-edit-data-description: "Nhấn để chỉnh sửa Dữ liệu của Kiểu hiệu ứng này"
|
||||
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"
|
||||
gui-data-none: "none"
|
||||
gui-data-none: "không ai"
|
||||
gui-create-particle: "Tạo mới một Hạt hiệu ứng"
|
||||
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"
|
||||
gui-create-particle-unavailable: "bạn đã đạt giới hạn số lượng Hạt hiệu ứng có thể tạo"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue