Merge pull request #17 from Esophose/v6.4

v6.4
This commit is contained in:
Esophose 2019-04-28 15:00:31 -06:00 committed by GitHub
commit 2a474faa88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
63 changed files with 2143 additions and 2224 deletions

4
.gitignore vendored
View file

@ -28,6 +28,7 @@ $RECYCLE.BIN/
# Icon must end with two \r # Icon must end with two \r
Icon Icon
# Thumbnails # Thumbnails
._* ._*
@ -39,6 +40,8 @@ Icon
/doc /doc
/target /target
/images /images
/build
/.idea
# Files that might appear on external disk # Files that might appear on external disk
.Spotlight-V100 .Spotlight-V100
@ -51,3 +54,4 @@ Network Trash Folder
Temporary Items Temporary Items
.apdisk .apdisk
images/ images/
*.iml

View file

@ -1,5 +1,18 @@
== UPDATING WILL DELETE YOUR CONFIG.YML == == UPDATING WILL DELETE YOUR CONFIG.YML ==
* Create a backup of your config.yml if you wish to import all your old settings! * Create a backup of your config.yml if you wish to import all your old settings!
=== v6.4 ===
+ Added support for Minecraft 1.14
+ Added 1.14 effects: 'campfire_cosy_smoke', 'campfire_signal_smoke', 'composter', 'falling_lava', 'falling_water', 'landing_lava', 'sneeze'
+ Added pages for effects, styles, and data in the GUI
+ Added setting 'gui-close-after-group-selected' to the config.yml
+ Added setting 'gui-presets-only' to the config.yml
+ Added Vietnamese translation file (vi_VN.lang)
+ Added support for vanish plugins as long as they use the Spigot hidden player API properly
* Fixed a whole bunch of errors in the fr_FR.lang file
* Fixed '/pp add' item data parameter being ignored
* Fixed an error with the GUI chat hook for creating a new group in 1.9
* Fixed players being able to load saved groups they no longer have permission for
* Fixed support for newline characters in GUI messages in some cases
=== v6.3 === === v6.3 ===
+ Added the ability to remove particles by id/effect/style using '/pp remove <id>|<effect>|<style>' + Added the ability to remove particles by id/effect/style using '/pp remove <id>|<effect>|<style>'
+ Added new styles 'popper', 'pulse', 'twins', 'whirl', and 'whirlwind' + Added new styles 'popper', 'pulse', 'twins', 'whirl', and 'whirlwind'

124
pom.xml
View file

@ -2,10 +2,10 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.esophose.playerparticles</groupId> <groupId>com.esophose.playerparticles</groupId>
<artifactId>PlayerParticles</artifactId> <artifactId>PlayerParticles</artifactId>
<version>6.3</version> <version>6.4</version>
<name>PlayerParticles</name> <name>PlayerParticles</name>
<url>https://github.com/Esophose/PlayerParticles</url> <url>https://github.com/Esophose/PlayerParticles</url>
<description>Display particles around your player using customized styles and data!</description> <description>Display particles around your player and blocks using customized styles and data!</description>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<resources> <resources>
@ -31,7 +31,7 @@
<version>3.1.0</version> <version>3.1.0</version>
<executions> <executions>
<execution> <execution>
<id>1.13</id> <id>shaded</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>shade</goal> <goal>shade</goal>
@ -42,6 +42,7 @@
<include>com.zaxxer:HikariCP</include> <include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include> <include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include> <include>org.slf4j:slf4j-nop</include>
<include>com.googlecode.json-simple:json-simple</include>
</includes> </includes>
</artifactSet> </artifactSet>
<filters> <filters>
@ -54,115 +55,7 @@
</excludes> </excludes>
</filter> </filter>
</filters> </filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.13\plugins\update\PlayerParticles v${project.version}.jar</outputFile> <outputFile>./target/PlayerParticles_v${project.version}.jar</outputFile>
</configuration>
</execution>
<execution>
<id>1.12</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.12\plugins\update\PlayerParticles v${project.version}.jar</outputFile>
</configuration>
</execution>
<execution>
<id>1.11</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.11\plugins\update\PlayerParticles v${project.version}.jar</outputFile>
</configuration>
</execution>
<execution>
<id>1.10</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.10\plugins\update\PlayerParticles v${project.version}.jar</outputFile>
</configuration>
</execution>
<execution>
<id>1.9</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.9\plugins\update\PlayerParticles v${project.version}.jar</outputFile>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
@ -200,10 +93,15 @@
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.23.1</version> <version>3.23.1</version>
</dependency> </dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version> <version>1.14-R0.1-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View file

@ -1,10 +1,14 @@
/* /*
* TODO: v6.4+ * TODO: v6.4
* + Add new style(s) 'wings_<type>', multiple new wing types: fairy, demon
* + Add ability to create/manage fixed effects from the GUI * + Add ability to create/manage fixed effects from the GUI
* * Convert fixed effect ids into names * * Convert fixed effect ids into names
* + Add command '/pp fixed teleport <id>' that requires the permission playerparticles.fixed.teleport * + Add command '/pp fixed teleport <id>' that requires the permission playerparticles.fixed.teleport
* + Add named colors to the color data * + Add named colors to the color data
* * Clean up duplicated command parsing
*/
/*
* TODO: v6.5
* + Add effect/style name customization through config files * + Add effect/style name customization through config files
* + Add effect/style settings folder that lets you disable effects/style and edit style properties * + Add effect/style settings folder that lets you disable effects/style and edit style properties
*/ */
@ -34,6 +38,7 @@ import com.esophose.playerparticles.manager.SettingManager;
import com.esophose.playerparticles.manager.SettingManager.PSetting; import com.esophose.playerparticles.manager.SettingManager.PSetting;
import com.esophose.playerparticles.particles.PPlayerMovementListener; import com.esophose.playerparticles.particles.PPlayerMovementListener;
import com.esophose.playerparticles.styles.DefaultStyles; import com.esophose.playerparticles.styles.DefaultStyles;
import com.esophose.playerparticles.updater.DataUpdater;
import com.esophose.playerparticles.updater.PluginUpdateListener; import com.esophose.playerparticles.updater.PluginUpdateListener;
import com.esophose.playerparticles.updater.Updater; import com.esophose.playerparticles.updater.Updater;
import com.esophose.playerparticles.util.Metrics; import com.esophose.playerparticles.util.Metrics;
@ -76,23 +81,23 @@ public class PlayerParticles extends JavaPlugin {
pm.registerEvents(new PPlayerMovementListener(), this); pm.registerEvents(new PPlayerMovementListener(), this);
pm.registerEvents(new PlayerChatHook(), this); pm.registerEvents(new PlayerChatHook(), this);
saveDefaultConfig(); this.saveDefaultConfig();
double configVersion = PSetting.VERSION.getDouble(); double configVersion = PSetting.VERSION.getDouble();
double currentVersion = Double.parseDouble(getDescription().getVersion()); double currentVersion = Double.parseDouble(this.getDescription().getVersion());
boolean updatePluginSettings = configVersion < currentVersion; boolean updatePluginSettings = configVersion < currentVersion;
if (updatePluginSettings) { if (updatePluginSettings) {
configureDatabase(PSetting.DATABASE_ENABLE.getBoolean()); this.configureDatabase(PSetting.DATABASE_ENABLE.getBoolean());
DataUpdater.updateData(configVersion, currentVersion); DataUpdater.updateData(configVersion, currentVersion);
databaseConnector.closeConnection(); this.databaseConnector.closeConnection();
databaseConnector = null; this.databaseConnector = null;
File configFile = new File(getDataFolder(), "config.yml"); File configFile = new File(this.getDataFolder(), "config.yml");
if (configFile.exists()) { if (configFile.exists()) {
configFile.delete(); configFile.delete();
} }
saveDefaultConfig(); this.saveDefaultConfig();
reloadConfig(); this.reloadConfig();
getLogger().warning("The config.yml has been updated to v" + getDescription().getVersion() + "!"); this.getLogger().warning("The config.yml has been updated to v" + this.getDescription().getVersion() + "!");
} }
if (PSetting.CHECK_UPDATES.getBoolean()) { if (PSetting.CHECK_UPDATES.getBoolean()) {
@ -123,7 +128,7 @@ public class PlayerParticles extends JavaPlugin {
* Close all users with an open PlayerParticles GUI * Close all users with an open PlayerParticles GUI
*/ */
public void onDisable() { public void onDisable() {
databaseConnector.closeConnection(); this.databaseConnector.closeConnection();
GuiHandler.forceCloseAllOpenGUIs(); GuiHandler.forceCloseAllOpenGUIs();
} }
@ -150,18 +155,18 @@ public class PlayerParticles extends JavaPlugin {
this.reloadConfig(); this.reloadConfig();
// If not null, plugin is already loaded // If not null, plugin is already loaded
if (particleTask != null) { if (this.particleTask != null) {
particleTask.cancel(); this.particleTask.cancel();
particleTask = null; this.particleTask = null;
databaseConnector.closeConnection(); this.databaseConnector.closeConnection();
databaseConnector = null; this.databaseConnector = null;
GuiHandler.forceCloseAllOpenGUIs(); GuiHandler.forceCloseAllOpenGUIs();
} else { } else {
DefaultStyles.registerStyles(); // Only ever load styles once DefaultStyles.registerStyles(); // Only ever load styles once
} }
// This runs before the SettingManager is reloaded, the credentials will not be stored in memory for more than a few milliseconds // This runs before the SettingManager is reloaded, the credentials will not be stored in memory for more than a few milliseconds
configureDatabase(PSetting.DATABASE_ENABLE.getBoolean()); this.configureDatabase(PSetting.DATABASE_ENABLE.getBoolean());
DataUpdater.tryCreateTables(); DataUpdater.tryCreateTables();
SettingManager.reload(); SettingManager.reload();
@ -172,7 +177,7 @@ public class PlayerParticles extends JavaPlugin {
PlayerChatHook.setup(); PlayerChatHook.setup();
ParticleManager.refreshData(); ParticleManager.refreshData();
startParticleTask(); this.startParticleTask();
} }
/** /**
@ -190,7 +195,7 @@ public class PlayerParticles extends JavaPlugin {
* @return The DatabaseConnector * @return The DatabaseConnector
*/ */
public DatabaseConnector getDBConnector() { public DatabaseConnector getDBConnector() {
return databaseConnector; return this.databaseConnector;
} }
/** /**
@ -210,20 +215,19 @@ public class PlayerParticles extends JavaPlugin {
*/ */
private void configureDatabase(boolean useMySql) { private void configureDatabase(boolean useMySql) {
if (useMySql) { if (useMySql) {
databaseConnector = new MySqlDatabaseConnector(); this.databaseConnector = new MySqlDatabaseConnector();
} else { } else {
try { try {
Class.forName("org.sqlite.JDBC"); // This is required to put here for Spigot 1.9 and 1.10 for some reason Class.forName("org.sqlite.JDBC"); // This is required to put here for Spigot 1.9 and 1.10 for some reason
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
databaseConnector = new SqliteDatabaseConnector(this.getDataFolder().getAbsolutePath()); this.databaseConnector = new SqliteDatabaseConnector(this.getDataFolder().getAbsolutePath());
} }
if (!databaseConnector.isInitialized()) { if (!this.databaseConnector.isInitialized()) {
getLogger().severe("Unable to connect to the MySQL database! Is your login information correct? Falling back to SQLite database instead."); this.getLogger().severe("Unable to connect to the MySQL database! Is your login information correct? Falling back to SQLite database instead.");
configureDatabase(false); this.configureDatabase(false);
return;
} }
} }
@ -232,13 +236,10 @@ public class PlayerParticles extends JavaPlugin {
* Run in the synchronous task so it starts after all plugins have loaded, including extensions * Run in the synchronous task so it starts after all plugins have loaded, including extensions
*/ */
private void startParticleTask() { private void startParticleTask() {
final Plugin playerParticles = this; Bukkit.getScheduler().runTaskLater(pluginInstance, () -> {
new BukkitRunnable() {
public void run() {
long ticks = PSetting.TICKS_PER_PARTICLE.getLong(); long ticks = PSetting.TICKS_PER_PARTICLE.getLong();
particleTask = new ParticleManager().runTaskTimer(playerParticles, 5, ticks); this.particleTask = new ParticleManager().runTaskTimer(pluginInstance, 5, ticks);
} }, 1);
}.runTaskLater(playerParticles, 1);
} }
} }

View file

@ -67,7 +67,7 @@ public class AddCommandModule implements CommandModule {
} else if (args[2].equalsIgnoreCase("random")) { } else if (args[2].equalsIgnoreCase("random")) {
noteColorData = new NoteColor(98); noteColorData = new NoteColor(98);
} else { } else {
int note = -1; int note;
try { try {
note = Integer.parseInt(args[2]); note = Integer.parseInt(args[2]);
} catch (Exception e) { } catch (Exception e) {
@ -88,9 +88,7 @@ public class AddCommandModule implements CommandModule {
} else if (args[2].equalsIgnoreCase("random")) { } else if (args[2].equalsIgnoreCase("random")) {
colorData = new OrdinaryColor(998, 998, 998); colorData = new OrdinaryColor(998, 998, 998);
} else { } else {
int r = -1; int r, g, b;
int g = -1;
int b = -1;
try { try {
r = Integer.parseInt(args[2]); r = Integer.parseInt(args[2]);
@ -131,7 +129,7 @@ public class AddCommandModule implements CommandModule {
} }
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
ParticlePair newParticle = new ParticlePair(pplayer.getUniqueId(), pplayer.getNextActiveParticleId(), effect, style, blockData, blockData, colorData, noteColorData); ParticlePair newParticle = new ParticlePair(pplayer.getUniqueId(), pplayer.getNextActiveParticleId(), effect, style, itemData, blockData, colorData, noteColorData);
group.getParticles().add(newParticle); group.getParticles().add(newParticle);
DataManager.saveParticleGroup(pplayer.getUniqueId(), group); DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
@ -144,18 +142,18 @@ public class AddCommandModule implements CommandModule {
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
Player p = pplayer.getPlayer(); Player p = pplayer.getPlayer();
List<String> matches = new ArrayList<String>(); List<String> matches = new ArrayList<>();
if (args.length <= 1) { // Effect name if (args.length <= 1) { // Effect name
if (args.length == 0) matches = PermissionManager.getEffectNamesUserHasPermissionFor(p); if (args.length == 0) matches = PermissionManager.getEffectNamesUserHasPermissionFor(p);
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectNamesUserHasPermissionFor(p), matches); else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectNamesUserHasPermissionFor(p), matches);
} else if (args.length == 2) { // Style name } else if (args.length == 2) { // Style name
StringUtil.copyPartialMatches(args[1], PermissionManager.getStyleNamesUserHasPermissionFor(p), matches); StringUtil.copyPartialMatches(args[1], PermissionManager.getStyleNamesUserHasPermissionFor(p), matches);
} else if (args.length >= 3) { // Data } else { // Data
ParticleEffect effect = ParticleEffect.fromName(args[0]); ParticleEffect effect = ParticleEffect.fromName(args[0]);
if (effect != null) { if (effect != null) {
if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect.hasProperty(ParticleProperty.COLORABLE)) {
List<String> possibleValues = new ArrayList<String>(); List<String> possibleValues = new ArrayList<>();
if (effect == ParticleEffect.NOTE) { // Note data if (effect == ParticleEffect.NOTE) { // Note data
if (args.length == 3) { if (args.length == 3) {
possibleValues.add("<0-24>"); possibleValues.add("<0-24>");
@ -178,9 +176,9 @@ public class AddCommandModule implements CommandModule {
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches); StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
} else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { } else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material
matches = StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllBlockMaterials(), matches); StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllBlockMaterials(), matches);
} else if (effect == ParticleEffect.ITEM) { // Item material } else if (effect == ParticleEffect.ITEM) { // Item material
matches = StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllItemMaterials(), matches); StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllItemMaterials(), matches);
} }
} }
} }

View file

@ -14,7 +14,7 @@ public interface CommandModule {
* @param pplayer The PPlayer who executed this command * @param pplayer The PPlayer who executed this command
* @param args The arguments to this command * @param args The arguments to this command
*/ */
public void onCommandExecute(PPlayer pplayer, String[] args); void onCommandExecute(PPlayer pplayer, String[] args);
/** /**
* Called when a player tries to tab complete this command * Called when a player tries to tab complete this command
@ -23,35 +23,35 @@ public interface CommandModule {
* @param args Arguments typed so far * @param args Arguments typed so far
* @return A list of possible argument values * @return A list of possible argument values
*/ */
public List<String> onTabComplete(PPlayer pplayer, String[] args); List<String> onTabComplete(PPlayer pplayer, String[] args);
/** /**
* Gets the name of this command * Gets the name of this command
* *
* @return The name of this command * @return The name of this command
*/ */
public String getName(); String getName();
/** /**
* Gets the Lang description of this command * Gets the Lang description of this command
* *
* @return The description of this command * @return The description of this command
*/ */
public Lang getDescription(); Lang getDescription();
/** /**
* Gets any arguments this command has * Gets any arguments this command has
* *
* @return The arguments this command has * @return The arguments this command has
*/ */
public String getArguments(); String getArguments();
/** /**
* True if this command requires the player to have any effects * True if this command requires the player to have any effects
* *
* @return If the player must have effects to use this command * @return If the player must have effects to use this command
*/ */
public boolean requiresEffects(); boolean requiresEffects();
/** /**
* Displays a command's usage to the player * Displays a command's usage to the player
@ -59,7 +59,7 @@ public interface CommandModule {
* @param pplayer The PPlayer to display the command usage to * @param pplayer The PPlayer to display the command usage to
* @param command The command to display usage for * @param command The command to display usage for
*/ */
public static void printUsage(PPlayer pplayer, CommandModule command) { static void printUsage(PPlayer pplayer, CommandModule command) {
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_USAGE, command.getName(), command.getArguments()); LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_USAGE, command.getName(), command.getArguments());
} }
@ -69,7 +69,7 @@ public interface CommandModule {
* @param pplayer The PPlayer to display the command usage to * @param pplayer The PPlayer to display the command usage to
* @param command The command to display usage for * @param command The command to display usage for
*/ */
public static void printUsageWithDescription(PPlayer pplayer, CommandModule command) { static void printUsageWithDescription(PPlayer pplayer, CommandModule command) {
if (command.getArguments().length() == 0) { if (command.getArguments().length() == 0) {
LangManager.sendSimpleMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_HELP_1, command.getName(), LangManager.getText(command.getDescription())); LangManager.sendSimpleMessage(pplayer, Lang.COMMAND_DESCRIPTIONS_HELP_1, command.getName(), LangManager.getText(command.getDescription()));
} else { } else {

View file

@ -12,7 +12,7 @@ public interface CommandModuleSecondary {
* @param sender The CommandSender who executed this command * @param sender The CommandSender who executed this command
* @param args The arguments to this command * @param args The arguments to this command
*/ */
public void onCommandExecute(CommandSender sender, String[] args); void onCommandExecute(CommandSender sender, String[] args);
/** /**
* Called when a player tries to tab complete this command * Called when a player tries to tab complete this command
@ -21,6 +21,6 @@ public interface CommandModuleSecondary {
* @param args Arguments typed so far * @param args Arguments typed so far
* @return A list of possible argument values * @return A list of possible argument values
*/ */
public List<String> onTabComplete(CommandSender sender, String[] args); List<String> onTabComplete(CommandSender sender, String[] args);
} }

View file

@ -43,7 +43,7 @@ public class DataCommandModule implements CommandModule {
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
List<String> matches = new ArrayList<String>(); List<String> matches = new ArrayList<>();
if (args.length <= 1) { if (args.length <= 1) {
if (args.length == 0) matches = PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()); if (args.length == 0) matches = PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer());
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()), matches); else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()), matches);

View file

@ -29,7 +29,7 @@ public class EditCommandModule implements CommandModule {
return; return;
} }
int id = -1; int id;
try { try {
id = Integer.parseInt(args[0]); id = Integer.parseInt(args[0]);
} catch (Exception e) { } catch (Exception e) {
@ -48,19 +48,17 @@ public class EditCommandModule implements CommandModule {
} }
String[] cmdArgs = new String[args.length - 2]; String[] cmdArgs = new String[args.length - 2];
for (int i = 2; i < args.length; i++) { System.arraycopy(args, 2, cmdArgs, 0, args.length - 2);
cmdArgs[i - 2] = args[i];
}
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "effect": case "effect":
editEffect(pplayer, id, cmdArgs); this.editEffect(pplayer, id, cmdArgs);
break; break;
case "style": case "style":
editStyle(pplayer, id, cmdArgs); this.editStyle(pplayer, id, cmdArgs);
break; break;
case "data": case "data":
editData(pplayer, id, cmdArgs); this.editData(pplayer, id, cmdArgs);
break; break;
default: default:
LangManager.sendMessage(pplayer, Lang.EDIT_INVALID_PROPERTY, args[1]); LangManager.sendMessage(pplayer, Lang.EDIT_INVALID_PROPERTY, args[1]);
@ -148,7 +146,7 @@ public class EditCommandModule implements CommandModule {
} else if (args[0].equalsIgnoreCase("random")) { } else if (args[0].equalsIgnoreCase("random")) {
noteColorData = new NoteColor(98); noteColorData = new NoteColor(98);
} else { } else {
int note = -1; int note;
try { try {
note = Integer.parseInt(args[0]); note = Integer.parseInt(args[0]);
} catch (Exception e) { } catch (Exception e) {
@ -169,9 +167,7 @@ public class EditCommandModule implements CommandModule {
} else if (args[0].equalsIgnoreCase("random")) { } else if (args[0].equalsIgnoreCase("random")) {
colorData = new OrdinaryColor(998, 998, 998); colorData = new OrdinaryColor(998, 998, 998);
} else { } else {
int r = -1; int r, g, b;
int g = -1;
int b = -1;
try { try {
r = Integer.parseInt(args[0]); r = Integer.parseInt(args[0]);
@ -229,8 +225,8 @@ public class EditCommandModule implements CommandModule {
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
Player p = pplayer.getPlayer(); Player p = pplayer.getPlayer();
List<String> matches = new ArrayList<String>(); List<String> matches = new ArrayList<>();
List<String> ids = new ArrayList<String>(); List<String> ids = new ArrayList<>();
for (ParticlePair particles : pplayer.getActiveParticles()) for (ParticlePair particles : pplayer.getActiveParticles())
ids.add(String.valueOf(particles.getId())); ids.add(String.valueOf(particles.getId()));
@ -244,11 +240,11 @@ public class EditCommandModule implements CommandModule {
int id = -1; int id = -1;
try { try {
id = Integer.parseInt(args[0]); id = Integer.parseInt(args[0]);
} catch (Exception e) { } } catch (Exception ignored) { }
if (pplayer.getActiveParticle(id) != null) { if (pplayer.getActiveParticle(id) != null) {
if (args.length == 2) { if (args.length == 2) {
List<String> possibleValues = new ArrayList<String>(); List<String> possibleValues = new ArrayList<>();
possibleValues.add("effect"); possibleValues.add("effect");
possibleValues.add("style"); possibleValues.add("style");
possibleValues.add("data"); possibleValues.add("data");
@ -266,7 +262,7 @@ public class EditCommandModule implements CommandModule {
case "data": case "data":
ParticleEffect effect = pplayer.getActiveParticle(id).getEffect(); ParticleEffect effect = pplayer.getActiveParticle(id).getEffect();
if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect.hasProperty(ParticleProperty.COLORABLE)) {
List<String> possibleValues = new ArrayList<String>(); List<String> possibleValues = new ArrayList<>();
if (effect == ParticleEffect.NOTE) { // Note data if (effect == ParticleEffect.NOTE) { // Note data
if (args.length == 3) { if (args.length == 3) {
possibleValues.add("<0-24>"); possibleValues.add("<0-24>");
@ -289,9 +285,9 @@ public class EditCommandModule implements CommandModule {
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches); StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
} else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { } else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material
matches = StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllBlockMaterials(), matches); StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllBlockMaterials(), matches);
} else if (effect == ParticleEffect.ITEM) { // Item material } else if (effect == ParticleEffect.ITEM) { // Item material
matches = StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllItemMaterials(), matches); StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllItemMaterials(), matches);
} }
} }
break; break;

View file

@ -21,20 +21,20 @@ public class EffectsCommandModule implements CommandModule {
return; return;
} }
String toSend = ""; StringBuilder toSend = new StringBuilder();
for (String name : effectList) { for (String name : effectList) {
toSend += name + ", "; toSend.append(name).append(", ");
} }
if (toSend.endsWith(", ")) { if (toSend.toString().endsWith(", ")) {
toSend = toSend.substring(0, toSend.length() - 2); toSend = new StringBuilder(toSend.substring(0, toSend.length() - 2));
} }
LangManager.sendMessage(pplayer, Lang.EFFECT_LIST, toSend); LangManager.sendMessage(pplayer, Lang.EFFECT_LIST, toSend.toString());
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -52,28 +52,26 @@ public class FixedCommandModule implements CommandModule {
String cmd = args[0]; String cmd = args[0];
String[] cmdArgs = new String[args.length - 1]; String[] cmdArgs = new String[args.length - 1];
for (int i = 1; i < args.length; i++) { System.arraycopy(args, 1, cmdArgs, 0, args.length - 1);
cmdArgs[i - 1] = args[i];
}
switch (cmd.toLowerCase()) { switch (cmd.toLowerCase()) {
case "create": case "create":
handleCreate(pplayer, p, cmdArgs); this.handleCreate(pplayer, p, cmdArgs);
return; return;
case "edit": case "edit":
handleEdit(pplayer, p, cmdArgs); this.handleEdit(pplayer, p, cmdArgs);
return; return;
case "remove": case "remove":
handleRemove(pplayer, p, cmdArgs); this.handleRemove(pplayer, p, cmdArgs);
return; return;
case "list": case "list":
handleList(pplayer, p, cmdArgs); this.handleList(pplayer, p, cmdArgs);
return; return;
case "info": case "info":
handleInfo(pplayer, p, cmdArgs); this.handleInfo(pplayer, p, cmdArgs);
return; return;
case "clear": case "clear":
handleClear(pplayer, p, cmdArgs); this.handleClear(pplayer, p, cmdArgs);
return; return;
default: default:
LangManager.sendMessage(pplayer, Lang.FIXED_INVALID_COMMAND); LangManager.sendMessage(pplayer, Lang.FIXED_INVALID_COMMAND);
@ -105,7 +103,7 @@ public class FixedCommandModule implements CommandModule {
return; return;
} }
double xPos = -1, yPos = -1, zPos = -1; double xPos, yPos, zPos;
if (args[0].equalsIgnoreCase("looking")) { if (args[0].equalsIgnoreCase("looking")) {
Block targetBlock = p.getTargetBlock((Set<Material>) null, 8); Block targetBlock = p.getTargetBlock((Set<Material>) null, 8);
@ -126,8 +124,7 @@ public class FixedCommandModule implements CommandModule {
paddedArgs[0] = String.valueOf(xPos); paddedArgs[0] = String.valueOf(xPos);
paddedArgs[1] = String.valueOf(yPos); paddedArgs[1] = String.valueOf(yPos);
paddedArgs[2] = String.valueOf(zPos); paddedArgs[2] = String.valueOf(zPos);
for (int i = 1; i < args.length; i++) System.arraycopy(args, 1, paddedArgs, 3, args.length - 1);
paddedArgs[i + 2] = args[i];
args = paddedArgs; args = paddedArgs;
} else { } else {
try { try {
@ -200,7 +197,7 @@ public class FixedCommandModule implements CommandModule {
} else if (args[5].equalsIgnoreCase("random")) { } else if (args[5].equalsIgnoreCase("random")) {
noteColorData = new NoteColor(98); noteColorData = new NoteColor(98);
} else { } else {
int note = -1; int note;
try { try {
note = Integer.parseInt(args[5]); note = Integer.parseInt(args[5]);
} catch (Exception e) { } catch (Exception e) {
@ -221,9 +218,7 @@ public class FixedCommandModule implements CommandModule {
} else if (args[5].equalsIgnoreCase("random")) { } else if (args[5].equalsIgnoreCase("random")) {
colorData = new OrdinaryColor(998, 998, 998); colorData = new OrdinaryColor(998, 998, 998);
} else { } else {
int r = -1; int r, g, b;
int g = -1;
int b = -1;
try { try {
r = Integer.parseInt(args[5]); r = Integer.parseInt(args[5]);
@ -244,7 +239,7 @@ public class FixedCommandModule implements CommandModule {
} }
} else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) {
Material material = null; Material material;
try { try {
material = ParticleUtils.closestMatch(args[5]); material = ParticleUtils.closestMatch(args[5]);
if (material == null) material = Material.matchMaterial(args[5]); if (material == null) material = Material.matchMaterial(args[5]);
@ -256,7 +251,7 @@ public class FixedCommandModule implements CommandModule {
blockData = material; blockData = material;
} else if (effect == ParticleEffect.ITEM) { } else if (effect == ParticleEffect.ITEM) {
Material material = null; Material material;
try { try {
material = ParticleUtils.closestMatch(args[5]); material = ParticleUtils.closestMatch(args[5]);
if (material == null) material = Material.matchMaterial(args[5]); if (material == null) material = Material.matchMaterial(args[5]);
@ -292,7 +287,7 @@ public class FixedCommandModule implements CommandModule {
return; return;
} }
int id = -1; int id;
try { try {
id = Integer.parseInt(args[0]); id = Integer.parseInt(args[0]);
} catch (Exception ex) { } catch (Exception ex) {
@ -307,8 +302,9 @@ public class FixedCommandModule implements CommandModule {
} }
String editType = args[1].toLowerCase(); String editType = args[1].toLowerCase();
if (editType.equals("location")) { switch (editType) {
double xPos = -1, yPos = -1, zPos = -1; case "location":
double xPos, yPos, zPos;
if (args[2].equalsIgnoreCase("looking")) { if (args[2].equalsIgnoreCase("looking")) {
Block targetBlock = p.getTargetBlock((Set<Material>) null, 8); Block targetBlock = p.getTargetBlock((Set<Material>) null, 8);
@ -359,7 +355,8 @@ public class FixedCommandModule implements CommandModule {
} }
fixedEffect.setCoordinates(xPos, yPos, zPos); fixedEffect.setCoordinates(xPos, yPos, zPos);
} else if (editType.equals("effect")) { break;
case "effect": {
ParticleEffect effect = ParticleEffect.fromName(args[2]); ParticleEffect effect = ParticleEffect.fromName(args[2]);
if (effect == null) { if (effect == null) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_EFFECT_INVALID, args[2]); LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_EFFECT_INVALID, args[2]);
@ -370,7 +367,9 @@ public class FixedCommandModule implements CommandModule {
} }
fixedEffect.getParticlePair().setEffect(effect); fixedEffect.getParticlePair().setEffect(effect);
} else if (editType.equals("style")) { break;
}
case "style":
ParticleStyle style = ParticleStyle.fromName(args[2]); ParticleStyle style = ParticleStyle.fromName(args[2]);
if (style == null) { if (style == null) {
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_STYLE_INVALID, args[2]); LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_STYLE_INVALID, args[2]);
@ -384,7 +383,8 @@ public class FixedCommandModule implements CommandModule {
} }
fixedEffect.getParticlePair().setStyle(style); fixedEffect.getParticlePair().setStyle(style);
} else if (editType.equals("data")) { break;
case "data": {
Material itemData = null; Material itemData = null;
Material blockData = null; Material blockData = null;
OrdinaryColor colorData = null; OrdinaryColor colorData = null;
@ -398,7 +398,7 @@ public class FixedCommandModule implements CommandModule {
} else if (args[2].equalsIgnoreCase("random")) { } else if (args[2].equalsIgnoreCase("random")) {
noteColorData = new NoteColor(98); noteColorData = new NoteColor(98);
} else { } else {
int note = -1; int note;
try { try {
note = Integer.parseInt(args[2]); note = Integer.parseInt(args[2]);
} catch (Exception e) { } catch (Exception e) {
@ -419,9 +419,7 @@ public class FixedCommandModule implements CommandModule {
} else if (args[2].equalsIgnoreCase("random")) { } else if (args[2].equalsIgnoreCase("random")) {
colorData = new OrdinaryColor(998, 998, 998); colorData = new OrdinaryColor(998, 998, 998);
} else { } else {
int r = -1; int r, g, b;
int g = -1;
int b = -1;
try { try {
r = Integer.parseInt(args[2]); r = Integer.parseInt(args[2]);
@ -442,7 +440,7 @@ public class FixedCommandModule implements CommandModule {
} }
} else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) {
Material material = null; Material material;
try { try {
material = ParticleUtils.closestMatch(args[2]); material = ParticleUtils.closestMatch(args[2]);
if (material == null) material = Material.matchMaterial(args[2]); if (material == null) material = Material.matchMaterial(args[2]);
@ -454,7 +452,7 @@ public class FixedCommandModule implements CommandModule {
blockData = material; blockData = material;
} else if (effect == ParticleEffect.ITEM) { } else if (effect == ParticleEffect.ITEM) {
Material material = null; Material material;
try { try {
material = ParticleUtils.closestMatch(args[2]); material = ParticleUtils.closestMatch(args[2]);
if (material == null) material = Material.matchMaterial(args[2]); if (material == null) material = Material.matchMaterial(args[2]);
@ -475,7 +473,9 @@ public class FixedCommandModule implements CommandModule {
fixedEffect.getParticlePair().setNoteColor(noteColorData); fixedEffect.getParticlePair().setNoteColor(noteColorData);
fixedEffect.getParticlePair().setItemMaterial(itemData); fixedEffect.getParticlePair().setItemMaterial(itemData);
fixedEffect.getParticlePair().setBlockMaterial(blockData); fixedEffect.getParticlePair().setBlockMaterial(blockData);
} else { break;
}
default:
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_PROPERTY); LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_PROPERTY);
return; return;
} }
@ -497,7 +497,7 @@ public class FixedCommandModule implements CommandModule {
return; return;
} }
int id = -1; int id;
try { try {
id = Integer.parseInt(args[0]); id = Integer.parseInt(args[0]);
} catch (Exception e) { } catch (Exception e) {
@ -529,15 +529,15 @@ public class FixedCommandModule implements CommandModule {
return; return;
} }
String msg = ""; StringBuilder msg = new StringBuilder();
boolean first = true; boolean first = true;
for (int id : ids) { for (int id : ids) {
if (!first) msg += ", "; if (!first) msg.append(", ");
else first = false; else first = false;
msg += id; msg.append(id);
} }
LangManager.sendMessage(pplayer, Lang.FIXED_LIST_SUCCESS, msg); LangManager.sendMessage(pplayer, Lang.FIXED_LIST_SUCCESS, msg.toString());
} }
/** /**
@ -553,7 +553,7 @@ public class FixedCommandModule implements CommandModule {
return; return;
} }
int id = -1; int id;
try { try {
id = Integer.parseInt(args[0]); id = Integer.parseInt(args[0]);
} catch (Exception e) { } catch (Exception e) {
@ -570,7 +570,7 @@ public class FixedCommandModule implements CommandModule {
ParticlePair particle = fixedEffect.getParticlePair(); ParticlePair particle = fixedEffect.getParticlePair();
DecimalFormat df = new DecimalFormat("0.##"); // Decimal formatter so the coords aren't super long DecimalFormat df = new DecimalFormat("0.##"); // Decimal formatter so the coords aren't super long
LangManager.sendMessage(pplayer, // @formatter:off LangManager.sendMessage(pplayer,
Lang.FIXED_INFO_SUCCESS, Lang.FIXED_INFO_SUCCESS,
fixedEffect.getId(), fixedEffect.getId(),
fixedEffect.getLocation().getWorld().getName(), fixedEffect.getLocation().getWorld().getName(),
@ -580,7 +580,7 @@ public class FixedCommandModule implements CommandModule {
particle.getEffect().getName(), particle.getEffect().getName(),
particle.getStyle().getName(), particle.getStyle().getName(),
particle.getDataString() particle.getDataString()
); // @formatter:on );
} }
/** /**
@ -601,7 +601,7 @@ public class FixedCommandModule implements CommandModule {
return; return;
} }
int radius = -1; int radius;
try { try {
radius = Math.abs(Integer.parseInt(args[0])); radius = Math.abs(Integer.parseInt(args[0]));
} catch (Exception e) { } catch (Exception e) {
@ -609,7 +609,7 @@ public class FixedCommandModule implements CommandModule {
return; return;
} }
ArrayList<FixedParticleEffect> fixedEffectsToRemove = new ArrayList<FixedParticleEffect>(); ArrayList<FixedParticleEffect> fixedEffectsToRemove = new ArrayList<>();
for (PPlayer ppl : ParticleManager.getPPlayers()) for (PPlayer ppl : ParticleManager.getPPlayers())
for (FixedParticleEffect fixedEffect : ppl.getFixedParticles()) for (FixedParticleEffect fixedEffect : ppl.getFixedParticles())
@ -624,18 +624,17 @@ public class FixedCommandModule implements CommandModule {
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
Player p = pplayer.getPlayer(); Player p = pplayer.getPlayer();
List<String> matches = new ArrayList<String>(); List<String> matches = new ArrayList<>();
String[] subCommands = new String[] { "create", "edit", "remove", "list", "info", "clear" };
if (args.length <= 1) { if (args.length <= 1) {
List<String> possibleCmds = new ArrayList<String>(Arrays.asList(subCommands)); List<String> possibleCmds = new ArrayList<>(Arrays.asList("create", "edit", "remove", "list", "info", "clear"));
if (args.length == 0) matches = possibleCmds; if (args.length == 0) matches = possibleCmds;
else StringUtil.copyPartialMatches(args[0], possibleCmds, matches); else StringUtil.copyPartialMatches(args[0], possibleCmds, matches);
} else { } else {
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "create": case "create":
if (args.length >= 2 && args.length <= 4) { if (args.length <= 4) {
List<String> possibleValues = new ArrayList<String>(); List<String> possibleValues = new ArrayList<>();
if (args.length == 4) { if (args.length == 4) {
possibleValues.add("~"); possibleValues.add("~");
} }
@ -650,11 +649,10 @@ public class FixedCommandModule implements CommandModule {
} }
// Pad arguments if the first coordinate is "looking" // Pad arguments if the first coordinate is "looking"
if (args.length > 1 && args[1].equalsIgnoreCase("looking")) { if (args[1].equalsIgnoreCase("looking")) {
String[] paddedArgs = new String[args.length + 2]; String[] paddedArgs = new String[args.length + 2];
paddedArgs[0] = paddedArgs[1] = paddedArgs[2] = paddedArgs[3] = ""; paddedArgs[0] = paddedArgs[1] = paddedArgs[2] = paddedArgs[3] = "";
for (int i = 2; i < args.length; i++) System.arraycopy(args, 2, paddedArgs, 4, args.length - 2);
paddedArgs[i + 2] = args[i];
args = paddedArgs; args = paddedArgs;
} }
@ -666,7 +664,7 @@ public class FixedCommandModule implements CommandModule {
ParticleEffect effect = ParticleEffect.fromName(args[4]); ParticleEffect effect = ParticleEffect.fromName(args[4]);
if (effect != null) { if (effect != null) {
if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect.hasProperty(ParticleProperty.COLORABLE)) {
List<String> possibleValues = new ArrayList<String>(); List<String> possibleValues = new ArrayList<>();
if (effect == ParticleEffect.NOTE) { // Note data if (effect == ParticleEffect.NOTE) { // Note data
if (args.length == 7) { if (args.length == 7) {
possibleValues.add("<0-24>"); possibleValues.add("<0-24>");
@ -689,9 +687,9 @@ public class FixedCommandModule implements CommandModule {
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches); StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
} else if (args.length == 7 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { } else if (args.length == 7 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material
matches = StringUtil.copyPartialMatches(args[6], ParticleUtils.getAllBlockMaterials(), matches); StringUtil.copyPartialMatches(args[6], ParticleUtils.getAllBlockMaterials(), matches);
} else if (effect == ParticleEffect.ITEM) { // Item material } else if (effect == ParticleEffect.ITEM) { // Item material
matches = StringUtil.copyPartialMatches(args[6], ParticleUtils.getAllItemMaterials(), matches); StringUtil.copyPartialMatches(args[6], ParticleUtils.getAllItemMaterials(), matches);
} }
} }
} }
@ -699,11 +697,11 @@ public class FixedCommandModule implements CommandModule {
break; break;
case "edit": case "edit":
if (args.length == 2) { if (args.length == 2) {
StringUtil.copyPartialMatches(args[1], pplayer.getFixedEffectIds().stream().map((x) -> String.valueOf(x)).collect(Collectors.toList()), matches); StringUtil.copyPartialMatches(args[1], pplayer.getFixedEffectIds().stream().map(String::valueOf).collect(Collectors.toList()), matches);
} else if (args.length == 3) { } else if (args.length == 3) {
String[] validProperties = new String[] { "location", "effect", "style", "data" }; String[] validProperties = new String[] { "location", "effect", "style", "data" };
StringUtil.copyPartialMatches(args[2], Arrays.asList(validProperties), matches); StringUtil.copyPartialMatches(args[2], Arrays.asList(validProperties), matches);
} else if (args.length > 3) { } else {
String property = args[2].toLowerCase(); String property = args[2].toLowerCase();
if (property.equals("location")) { if (property.equals("location")) {
List<String> possibleValues = new ArrayList<String>(); List<String> possibleValues = new ArrayList<String>();
@ -732,7 +730,7 @@ public class FixedCommandModule implements CommandModule {
if (fixedEffect != null) { if (fixedEffect != null) {
ParticleEffect effect = fixedEffect.getParticlePair().getEffect(); ParticleEffect effect = fixedEffect.getParticlePair().getEffect();
if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect.hasProperty(ParticleProperty.COLORABLE)) {
List<String> possibleValues = new ArrayList<String>(); List<String> possibleValues = new ArrayList<>();
if (effect == ParticleEffect.NOTE) { // Note data if (effect == ParticleEffect.NOTE) { // Note data
if (args.length == 4) { if (args.length == 4) {
possibleValues.add("<0-24>"); possibleValues.add("<0-24>");
@ -755,9 +753,9 @@ public class FixedCommandModule implements CommandModule {
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches); StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
} else if (args.length == 4 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { } else if (args.length == 4 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material
matches = StringUtil.copyPartialMatches(args[3], ParticleUtils.getAllBlockMaterials(), matches); StringUtil.copyPartialMatches(args[3], ParticleUtils.getAllBlockMaterials(), matches);
} else if (effect == ParticleEffect.ITEM) { // Item material } else if (effect == ParticleEffect.ITEM) { // Item material
matches = StringUtil.copyPartialMatches(args[3], ParticleUtils.getAllItemMaterials(), matches); StringUtil.copyPartialMatches(args[3], ParticleUtils.getAllItemMaterials(), matches);
} }
} }
} }
@ -765,16 +763,14 @@ public class FixedCommandModule implements CommandModule {
} }
break; break;
case "remove": case "remove":
StringUtil.copyPartialMatches(args[1], pplayer.getFixedEffectIds().stream().map((x) -> String.valueOf(x)).collect(Collectors.toList()), matches);
break;
case "list":
break;
case "info": case "info":
StringUtil.copyPartialMatches(args[1], pplayer.getFixedEffectIds().stream().map((x) -> String.valueOf(x)).collect(Collectors.toList()), matches); StringUtil.copyPartialMatches(args[1], pplayer.getFixedEffectIds().stream().map(String::valueOf).collect(Collectors.toList()), matches);
break; break;
case "clear": case "clear":
matches.add("<radius>"); matches.add("<radius>");
break; break;
case "list":
break;
} }
} }

View file

@ -6,6 +6,8 @@ import java.util.List;
import com.esophose.playerparticles.gui.GuiHandler; import com.esophose.playerparticles.gui.GuiHandler;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.ParticleGroupPresetManager;
import com.esophose.playerparticles.manager.SettingManager.PSetting;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.particles.PPlayer; import com.esophose.playerparticles.particles.PPlayer;
@ -26,7 +28,9 @@ public class GUICommandModule implements CommandModule {
return; return;
} }
if (PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()).isEmpty()) { if (PSetting.GUI_PRESETS_ONLY.getBoolean() && ParticleGroupPresetManager.getPresetGroupsForPlayer(pplayer.getPlayer()).isEmpty()) {
return;
} else if (PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()).isEmpty()) {
if (byDefault) { if (byDefault) {
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN); LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN);
} else { } else {
@ -39,7 +43,7 @@ public class GUICommandModule implements CommandModule {
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.esophose.playerparticles.manager.DataManager; import com.esophose.playerparticles.manager.DataManager;
@ -20,7 +21,7 @@ import com.esophose.playerparticles.particles.ParticlePair;
public class GroupCommandModule implements CommandModule { public class GroupCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) { public void onCommandExecute(PPlayer pplayer, String[] args) {
List<String> validCommands = Arrays.asList(new String[] { "save", "load", "remove", "info", "list" }); List<String> validCommands = Arrays.asList("save", "load", "remove", "info", "list");
if (args.length == 0 || !validCommands.contains(args[0])) { if (args.length == 0 || !validCommands.contains(args[0])) {
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_SAVE); LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_SAVE);
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_LOAD); LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_LOAD);
@ -37,19 +38,19 @@ public class GroupCommandModule implements CommandModule {
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "save": case "save":
onSave(pplayer, args[1].toLowerCase()); this.onSave(pplayer, args[1].toLowerCase());
break; break;
case "load": case "load":
onLoad(pplayer, args[1].toLowerCase()); this.onLoad(pplayer, args[1].toLowerCase());
break; break;
case "remove": case "remove":
onRemove(pplayer, args[1].toLowerCase()); this.onRemove(pplayer, args[1].toLowerCase());
break; break;
case "info": case "info":
onInfo(pplayer, args[1].toLowerCase()); this.onInfo(pplayer, args[1].toLowerCase());
break; break;
case "list": case "list":
onList(pplayer); this.onList(pplayer);
break; break;
default: default:
LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_SAVE); LangManager.sendMessage(pplayer, Lang.COMMAND_DESCRIPTION_GROUP_SAVE);
@ -95,7 +96,7 @@ public class GroupCommandModule implements CommandModule {
ParticleGroup group = pplayer.getParticleGroupByName(groupName); ParticleGroup group = pplayer.getParticleGroupByName(groupName);
boolean groupUpdated = false; boolean groupUpdated = false;
if (group == null) { if (group == null) {
List<ParticlePair> particles = new ArrayList<ParticlePair>(); List<ParticlePair> particles = new ArrayList<>();
for (ParticlePair particle : pplayer.getActiveParticles()) for (ParticlePair particle : pplayer.getActiveParticles())
particles.add(particle.clone()); // Make sure the ParticlePairs aren't the same references in both the active and saved group particles.add(particle.clone()); // Make sure the ParticlePairs aren't the same references in both the active and saved group
group = new ParticleGroup(groupName, particles); group = new ParticleGroup(groupName, particles);
@ -145,6 +146,11 @@ public class GroupCommandModule implements CommandModule {
isPreset = true; isPreset = true;
} }
if (!group.canPlayerUse(pplayer.getPlayer())) {
LangManager.sendMessage(pplayer, Lang.GROUP_NO_PERMISSION, groupName);
return;
}
// Empty out the active group and fill it with clones from the target group // Empty out the active group and fill it with clones from the target group
ParticleGroup activeGroup = pplayer.getActiveParticleGroup(); ParticleGroup activeGroup = pplayer.getActiveParticleGroup();
activeGroup.getParticles().clear(); activeGroup.getParticles().clear();
@ -238,38 +244,39 @@ public class GroupCommandModule implements CommandModule {
List<ParticleGroup> groups = pplayer.getParticleGroups(); List<ParticleGroup> groups = pplayer.getParticleGroups();
groups.sort(Comparator.comparing(ParticleGroup::getName)); groups.sort(Comparator.comparing(ParticleGroup::getName));
String groupsList = ""; Player player = pplayer.getPlayer();
StringBuilder groupsList = new StringBuilder();
for (ParticleGroup group : groups) for (ParticleGroup group : groups)
if (!group.getName().equals(ParticleGroup.DEFAULT_NAME)) if (!group.getName().equals(ParticleGroup.DEFAULT_NAME))
groupsList += group.getName() + ", "; groupsList.append(group.getName()).append(", ");
if (groupsList.endsWith(", ")) if (groupsList.toString().endsWith(", "))
groupsList = groupsList.substring(0, groupsList.length() - 2); groupsList = new StringBuilder(groupsList.substring(0, groupsList.length() - 2));
String presetsList = ""; StringBuilder presetsList = new StringBuilder();
for (ParticleGroupPreset group : ParticleGroupPresetManager.getPresetGroupsForPlayer(pplayer.getPlayer())) for (ParticleGroupPreset group : ParticleGroupPresetManager.getPresetGroupsForPlayer(pplayer.getPlayer()))
presetsList += group.getGroup().getName() + ", "; presetsList.append(group.getGroup().getName()).append(", ");
if (presetsList.endsWith(", ")) if (presetsList.toString().endsWith(", "))
presetsList = presetsList.substring(0, presetsList.length() - 2); presetsList = new StringBuilder(presetsList.substring(0, presetsList.length() - 2));
if (groupsList.isEmpty() && presetsList.isEmpty()) { if ((groupsList.length() == 0) && (presetsList.length() == 0)) {
LangManager.sendMessage(pplayer, Lang.GROUP_LIST_NONE); LangManager.sendMessage(pplayer, Lang.GROUP_LIST_NONE);
return; return;
} }
if (!groupsList.isEmpty()) { if (groupsList.length() > 0) {
LangManager.sendMessage(pplayer, Lang.GROUP_LIST_OUTPUT, groupsList); LangManager.sendMessage(pplayer, Lang.GROUP_LIST_OUTPUT, groupsList.toString());
} }
if (!presetsList.isEmpty()) { if (presetsList.length() > 0) {
LangManager.sendMessage(pplayer, Lang.GROUP_LIST_PRESETS, presetsList); LangManager.sendMessage(pplayer, Lang.GROUP_LIST_PRESETS, presetsList.toString());
} }
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
List<String> matches = new ArrayList<String>(); List<String> matches = new ArrayList<>();
List<String> subCommands = Arrays.asList(new String[] { "save", "load", "remove", "info", "list" }); List<String> subCommands = Arrays.asList("save", "load", "remove", "info", "list");
if (args.length <= 1) { if (args.length <= 1) {
if (args.length == 0) matches = subCommands; if (args.length == 0) matches = subCommands;
@ -278,7 +285,7 @@ public class GroupCommandModule implements CommandModule {
if (args[0].equalsIgnoreCase("save")) { if (args[0].equalsIgnoreCase("save")) {
matches.add("<groupName>"); matches.add("<groupName>");
} else { } else {
List<String> groupNames = new ArrayList<String>(); List<String> groupNames = new ArrayList<>();
for (ParticleGroup group : pplayer.getParticleGroups()) for (ParticleGroup group : pplayer.getParticleGroups())
if (!group.getName().equals(ParticleGroup.DEFAULT_NAME)) if (!group.getName().equals(ParticleGroup.DEFAULT_NAME))
groupNames.add(group.getName()); groupNames.add(group.getName());
@ -305,7 +312,7 @@ public class GroupCommandModule implements CommandModule {
} }
public boolean requiresEffects() { public boolean requiresEffects() {
return true; return false;
} }
} }

View file

@ -19,7 +19,7 @@ public class HelpCommandModule implements CommandModule {
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -31,7 +31,7 @@ public class ListCommandModule implements CommandModule {
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -58,10 +58,10 @@ public class OtherCommandModule implements CommandModuleSecondary {
} }
public List<String> onTabComplete(CommandSender sender, String[] args) { public List<String> onTabComplete(CommandSender sender, String[] args) {
List<String> completions = new ArrayList<String>(); List<String> completions = new ArrayList<>();
if (args.length < 2) { if (args.length < 2) {
List<String> playerNames = new ArrayList<String>(); List<String> playerNames = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
playerNames.add(player.getName()); playerNames.add(player.getName());

View file

@ -27,7 +27,7 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
private static CommandModuleSecondary ppoCommand; private static CommandModuleSecondary ppoCommand;
static { static {
commands = new ArrayList<CommandModule>(); commands = new ArrayList<>();
commands.add(new AddCommandModule()); commands.add(new AddCommandModule());
commands.add(new DataCommandModule()); commands.add(new DataCommandModule());
@ -78,7 +78,7 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
* @return All available command names * @return All available command names
*/ */
public static List<String> getCommandNames() { public static List<String> getCommandNames() {
List<String> commandNames = new ArrayList<String>(); List<String> commandNames = new ArrayList<>();
for (CommandModule cmd : commands) for (CommandModule cmd : commands)
commandNames.add(cmd.getName()); commandNames.add(cmd.getName());
return commandNames; return commandNames;
@ -137,15 +137,15 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
*/ */
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
if (cmd.getName().equalsIgnoreCase("pp")) { if (cmd.getName().equalsIgnoreCase("pp")) {
if (!(sender instanceof Player)) return new ArrayList<String>(); if (!(sender instanceof Player)) return new ArrayList<>();
PPlayer pplayer = DataManager.getPPlayer(((Player) sender).getUniqueId()); PPlayer pplayer = DataManager.getPPlayer(((Player) sender).getUniqueId());
if (pplayer == null) return new ArrayList<String>(); if (pplayer == null) return new ArrayList<>();
if (args.length <= 1) { if (args.length <= 1) {
CommandModule commandModule = findMatchingCommand(""); // Get the default command module CommandModule commandModule = findMatchingCommand(""); // Get the default command module
return commandModule.onTabComplete(pplayer, args); return commandModule.onTabComplete(pplayer, args);
} else if (args.length >= 2) { } else {
CommandModule commandModule = findMatchingCommand(args[0]); CommandModule commandModule = findMatchingCommand(args[0]);
if (commandModule != null) { if (commandModule != null) {
String[] cmdArgs = Arrays.copyOfRange(args, 1, args.length); String[] cmdArgs = Arrays.copyOfRange(args, 1, args.length);
@ -156,7 +156,7 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
return ppoCommand.onTabComplete(sender, args); return ppoCommand.onTabComplete(sender, args);
} }
return new ArrayList<String>(); return new ArrayList<>();
} }
} }

View file

@ -22,7 +22,7 @@ public class ReloadCommandModule implements CommandModule {
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -26,7 +26,7 @@ public class RemoveCommandModule implements CommandModule {
} }
if (StringUtils.isNumeric(args[0])) { // Removing by ID if (StringUtils.isNumeric(args[0])) { // Removing by ID
int id = -1; int id;
try { try {
id = Integer.parseInt(args[0]); id = Integer.parseInt(args[0]);
} catch (Exception ex) { } catch (Exception ex) {
@ -99,8 +99,8 @@ public class RemoveCommandModule implements CommandModule {
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
List<String> matches = new ArrayList<String>(); List<String> matches = new ArrayList<>();
Set<String> removeBy = new HashSet<String>(); Set<String> removeBy = new HashSet<>();
for (ParticlePair particle : pplayer.getActiveParticles()) { for (ParticlePair particle : pplayer.getActiveParticles()) {
removeBy.add(String.valueOf(particle.getId())); removeBy.add(String.valueOf(particle.getId()));
@ -108,7 +108,7 @@ public class RemoveCommandModule implements CommandModule {
removeBy.add(particle.getStyle().getName()); removeBy.add(particle.getStyle().getName());
} }
if (args.length == 0) return new ArrayList<String>(removeBy); if (args.length == 0) return new ArrayList<>(removeBy);
StringUtil.copyPartialMatches(args[0], removeBy, matches); StringUtil.copyPartialMatches(args[0], removeBy, matches);
return matches; return matches;

View file

@ -18,7 +18,7 @@ public class ResetCommandModule implements CommandModule {
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -16,20 +16,20 @@ public class StylesCommandModule implements CommandModule {
Player p = pplayer.getPlayer(); Player p = pplayer.getPlayer();
List<String> styleNames = PermissionManager.getStyleNamesUserHasPermissionFor(p); List<String> styleNames = PermissionManager.getStyleNamesUserHasPermissionFor(p);
String toSend = ""; StringBuilder toSend = new StringBuilder();
for (String name : styleNames) { for (String name : styleNames) {
toSend += name + ", "; toSend.append(name).append(", ");
} }
if (toSend.endsWith(", ")) { if (toSend.toString().endsWith(", ")) {
toSend = toSend.substring(0, toSend.length() - 2); toSend = new StringBuilder(toSend.substring(0, toSend.length() - 2));
} }
LangManager.sendMessage(pplayer, Lang.STYLE_LIST, toSend); LangManager.sendMessage(pplayer, Lang.STYLE_LIST, toSend.toString());
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -22,7 +22,7 @@ public class ToggleCommandModule implements CommandModule {
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -18,7 +18,7 @@ public class VersionCommandModule implements CommandModule {
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -16,17 +16,17 @@ public class WorldsCommandModule implements CommandModule {
return; return;
} }
String worlds = ""; StringBuilder worlds = new StringBuilder();
for (String s : PermissionManager.getDisabledWorlds()) { for (String s : PermissionManager.getDisabledWorlds()) {
worlds += s + ", "; worlds.append(s).append(", ");
} }
if (worlds.length() > 2) worlds = worlds.substring(0, worlds.length() - 2); if (worlds.length() > 2) worlds = new StringBuilder(worlds.substring(0, worlds.length() - 2));
LangManager.sendCustomMessage(pplayer, LangManager.getText(Lang.DISABLED_WORLDS) + " " + worlds); LangManager.sendCustomMessage(pplayer, LangManager.getText(Lang.DISABLED_WORLDS) + " " + worlds);
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return new ArrayList<String>(); return new ArrayList<>();
} }
public String getName() { public String getName() {

View file

@ -10,25 +10,25 @@ public interface DatabaseConnector {
* *
* @return If the connection is created or not * @return If the connection is created or not
*/ */
public boolean isInitialized(); boolean isInitialized();
/** /**
* Closes all open connections to the database * Closes all open connections to the database
*/ */
public void closeConnection(); void closeConnection();
/** /**
* Executes a callback with a Connection passed and automatically closes it when finished * Executes a callback with a Connection passed and automatically closes it when finished
* *
* @param callback The callback to execute once the connection is retrieved * @param callback The callback to execute once the connection is retrieved
*/ */
public void connect(ConnectionCallback callback); void connect(ConnectionCallback callback);
/** /**
* Allows Lambda expressions to be used to reduce duplicated code for getting connections * Allows Lambda expressions to be used to reduce duplicated code for getting connections
*/ */
public static interface ConnectionCallback { interface ConnectionCallback {
public void execute(Connection connection) throws SQLException; void execute(Connection connection) throws SQLException;
} }
} }

View file

@ -11,7 +11,7 @@ import com.zaxxer.hikari.HikariDataSource;
public class MySqlDatabaseConnector implements DatabaseConnector { public class MySqlDatabaseConnector implements DatabaseConnector {
private HikariDataSource hikari; private HikariDataSource hikari;
private boolean initializedSuccessfully = false; private boolean initializedSuccessfully;
public MySqlDatabaseConnector() { public MySqlDatabaseConnector() {
String hostname = PSetting.DATABASE_HOSTNAME.getString(); String hostname = PSetting.DATABASE_HOSTNAME.getString();
@ -19,12 +19,13 @@ public class MySqlDatabaseConnector implements DatabaseConnector {
String database = PSetting.DATABASE_NAME.getString(); String database = PSetting.DATABASE_NAME.getString();
String user = PSetting.DATABASE_USER_NAME.getString(); String user = PSetting.DATABASE_USER_NAME.getString();
String pass = PSetting.DATABASE_USER_PASSWORD.getString(); String pass = PSetting.DATABASE_USER_PASSWORD.getString();
boolean useSSL = PSetting.DATABASE_USE_SSL.getBoolean();
HikariConfig config = new HikariConfig(); HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database); config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database + "?useSSL=" + useSSL);
config.setUsername(user); config.setUsername(user);
config.setPassword(pass); config.setPassword(pass);
config.setMaximumPoolSize(5); config.setMaximumPoolSize(3);
try { try {
this.hikari = new HikariDataSource(config); this.hikari = new HikariDataSource(config);

View file

@ -3,6 +3,7 @@ package com.esophose.playerparticles.gui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.esophose.playerparticles.util.NMSUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
@ -98,7 +99,6 @@ public class GuiActionButton {
* *
* @return The icon ItemStack for the GUI * @return The icon ItemStack for the GUI
*/ */
@SuppressWarnings("deprecation")
public ItemStack getIcon() { public ItemStack getIcon() {
ItemStack itemStack; ItemStack itemStack;
if (this.icons != null) { if (this.icons != null) {
@ -112,12 +112,12 @@ public class GuiActionButton {
} }
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta != null) {
itemMeta.setDisplayName(this.name); itemMeta.setDisplayName(this.name);
itemMeta.setLore(parseLore(this.lore)); itemMeta.setLore(parseLore(this.lore));
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS); itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS);
itemStack.setItemMeta(itemMeta); itemStack.setItemMeta(itemMeta);
}
return itemStack; return itemStack;
} }
@ -125,10 +125,9 @@ public class GuiActionButton {
/** /**
* Executes the onClick callback passed in the constructor * Executes the onClick callback passed in the constructor
* *
* @param button The button that was clicked
* @param isShiftClick If the player was holding shift when they clicked * @param isShiftClick If the player was holding shift when they clicked
*/ */
public void handleClick(GuiActionButton button, boolean isShiftClick) { public void handleClick(boolean isShiftClick) {
if (this.onClick != null) if (this.onClick != null)
this.onClick.execute(this, isShiftClick); this.onClick.execute(this, isShiftClick);
} }
@ -158,7 +157,7 @@ public class GuiActionButton {
* @return A parsed list of lore text * @return A parsed list of lore text
*/ */
public static List<String> parseLore(String... lore) { public static List<String> parseLore(String... lore) {
List<String> parsedLore = new ArrayList<String>(); List<String> parsedLore = new ArrayList<>();
for (String line : lore) { for (String line : lore) {
// Try to maintain the color going to the next line if it's split // Try to maintain the color going to the next line if it's split
// If there is no color, just ignore it // If there is no color, just ignore it
@ -168,7 +167,7 @@ public class GuiActionButton {
} }
// Split the lore along \n onto a new line if any exist // Split the lore along \n onto a new line if any exist
String[] splitLines = line.split("\\\\n"); String[] splitLines = line.split("\n");
for (String parsedLine : splitLines) { for (String parsedLine : splitLines) {
if (ChatColor.stripColor(parsedLine).isEmpty()) continue; if (ChatColor.stripColor(parsedLine).isEmpty()) continue;
parsedLore.add(lineColor + parsedLine); parsedLore.add(lineColor + parsedLine);
@ -181,8 +180,8 @@ public class GuiActionButton {
* Allows button click callbacks as parameters * Allows button click callbacks as parameters
*/ */
@FunctionalInterface @FunctionalInterface
public static interface GuiActionButtonClickCallback { public interface GuiActionButtonClickCallback {
public void execute(GuiActionButton button, boolean isShiftClick); void execute(GuiActionButton button, boolean isShiftClick);
} }
} }

View file

@ -23,7 +23,7 @@ import com.esophose.playerparticles.particles.PPlayer;
*/ */
public class GuiHandler extends BukkitRunnable implements Listener { public class GuiHandler extends BukkitRunnable implements Listener {
private static List<GuiInventory> guiInventories = new ArrayList<GuiInventory>(); private static List<GuiInventory> guiInventories = new ArrayList<>();
private static BukkitTask guiTask = null; private static BukkitTask guiTask = null;
/** /**
@ -40,7 +40,7 @@ public class GuiHandler extends BukkitRunnable implements Listener {
* Removes entries from playerGuiInventories if the player no longer has the inventory open or is offline * Removes entries from playerGuiInventories if the player no longer has the inventory open or is offline
*/ */
public void run() { public void run() {
List<GuiInventory> toRemoveList = new ArrayList<GuiInventory>(); List<GuiInventory> toRemoveList = new ArrayList<>();
for (GuiInventory inventory : guiInventories) { for (GuiInventory inventory : guiInventories) {
PPlayer pplayer = DataManager.getPPlayer(inventory.getPPlayer().getUniqueId()); PPlayer pplayer = DataManager.getPPlayer(inventory.getPPlayer().getUniqueId());
@ -112,10 +112,15 @@ public class GuiHandler extends BukkitRunnable implements Listener {
public static void openDefault(PPlayer pplayer) { public static void openDefault(PPlayer pplayer) {
removeGuiInventory(pplayer); removeGuiInventory(pplayer);
GuiInventoryDefault defaultInventory = new GuiInventoryDefault(pplayer); GuiInventory inventoryToOpen;
guiInventories.add(defaultInventory); if (!PSetting.GUI_PRESETS_ONLY.getBoolean()) {
inventoryToOpen = new GuiInventoryDefault(pplayer);
} else {
inventoryToOpen = new GuiInventoryLoadPresetGroups(pplayer, true);
}
pplayer.getPlayer().openInventory(defaultInventory.getInventory()); guiInventories.add(inventoryToOpen);
pplayer.getPlayer().openInventory(inventoryToOpen.getInventory());
} }
/** /**

View file

@ -22,14 +22,25 @@ public abstract class GuiInventory implements InventoryHolder {
protected enum BorderColor { protected enum BorderColor {
WHITE(0, "WHITE_STAINED_GLASS_PANE"), WHITE(0, "WHITE_STAINED_GLASS_PANE"),
ORANGE(1, "ORANGE_STAINED_GLASS_PANE"), ORANGE(1, "ORANGE_STAINED_GLASS_PANE"),
RED(14, "RED_STAINED_GLASS_PANE"), MAGENTA(2, "MAGENTA_STAINED_GLASS_PANE"),
LIGHT_BLUE(3, "LIGHT_BLUE_STAINED_GLASS_PANE"),
YELLOW(4, "YELLOW_STAINED_GLASS_PANE"),
LIME(5, "LIME_STAINED_GLASS_PANE"),
PINK(6, "PINK_STAINED_GLASS_PANE"),
GRAY(7, "GRAY_STAINED_GLASS_PANE"),
LIGHT_GRAY(8, "LIGHT_GRAY_STAINED_GLASS_PANE"),
CYAN(9, "CYAN_STAINED_GLASS_PANE"),
PURPLE(10, "PURPLE_STAINED_GLASS_PANE"),
BLUE(11, "BLUE_STAINED_GLASS_PANE"),
BROWN(12, "BROWN_STAINED_GLASS_PANE"), BROWN(12, "BROWN_STAINED_GLASS_PANE"),
GREEN(13, "GREEN_STAINED_GLASS_PANE"); GREEN(13, "GREEN_STAINED_GLASS_PANE"),
RED(14, "RED_STAINED_GLASS_PANE"),
BLACK(15, "BLACK_STAINED_GLASS_PANE");
private short data; private short data;
private Material material; private Material material;
private BorderColor(int data, String materialName) { BorderColor(int data, String materialName) {
this.data = (short)data; this.data = (short)data;
this.material = ParticleUtils.closestMatch(materialName); this.material = ParticleUtils.closestMatch(materialName);
} }
@ -44,9 +55,11 @@ public abstract class GuiInventory implements InventoryHolder {
} }
ItemMeta meta = borderIcon.getItemMeta(); ItemMeta meta = borderIcon.getItemMeta();
if (meta != null) {
meta.setDisplayName(" "); meta.setDisplayName(" ");
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ENCHANTS); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ENCHANTS);
borderIcon.setItemMeta(meta); borderIcon.setItemMeta(meta);
}
return borderIcon; return borderIcon;
} }
@ -60,7 +73,7 @@ public abstract class GuiInventory implements InventoryHolder {
public GuiInventory(PPlayer pplayer, Inventory inventory) { public GuiInventory(PPlayer pplayer, Inventory inventory) {
this.pplayer = pplayer; this.pplayer = pplayer;
this.inventory = inventory; this.inventory = inventory;
this.actionButtons = new ArrayList<GuiActionButton>(); this.actionButtons = new ArrayList<>();
} }
/** /**
@ -110,7 +123,7 @@ public abstract class GuiInventory implements InventoryHolder {
* Populates the Inventory with the contents of actionButtons * Populates the Inventory with the contents of actionButtons
*/ */
protected void populate() { protected void populate() {
for (GuiActionButton button : actionButtons) { for (GuiActionButton button : this.actionButtons) {
this.inventory.setItem(button.getSlot(), button.getIcon()); this.inventory.setItem(button.getSlot(), button.getIcon());
} }
} }
@ -140,21 +153,19 @@ public abstract class GuiInventory implements InventoryHolder {
for (GuiActionButton button : this.actionButtons) { for (GuiActionButton button : this.actionButtons) {
if (button.getSlot() == slot) { if (button.getSlot() == slot) {
button.handleClick(button, isShiftClick); button.handleClick(isShiftClick);
if (PSetting.GUI_BUTTON_SOUND.getBoolean()) { if (PSetting.GUI_BUTTON_SOUND.getBoolean() && event.getWhoClicked() instanceof Player) {
if (event.getWhoClicked() instanceof Player) {
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 0.5f, 1); player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 0.5f, 1);
} }
}
break; break;
} }
} }
} }
@FunctionalInterface @FunctionalInterface
public static interface GuiInventoryEditFinishedCallback { public interface GuiInventoryEditFinishedCallback {
public void execute(); void execute();
} }
} }

View file

@ -1,14 +1,5 @@
package com.esophose.playerparticles.gui; package com.esophose.playerparticles.gui;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import com.esophose.playerparticles.manager.DataManager; import com.esophose.playerparticles.manager.DataManager;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
@ -20,6 +11,14 @@ import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import com.esophose.playerparticles.particles.ParticleGroup; import com.esophose.playerparticles.particles.ParticleGroup;
import com.esophose.playerparticles.particles.ParticlePair; import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.util.ParticleUtils; import com.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class GuiInventoryDefault extends GuiInventory { public class GuiInventoryDefault extends GuiInventory {
@ -39,6 +38,7 @@ public class GuiInventoryDefault extends GuiInventory {
} }
SkullMeta currentIconMeta = (SkullMeta) headIcon.getItemMeta(); SkullMeta currentIconMeta = (SkullMeta) headIcon.getItemMeta();
if (currentIconMeta != null) {
currentIconMeta.setDisplayName(LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + pplayer.getPlayer().getName()); currentIconMeta.setDisplayName(LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + pplayer.getPlayer().getName());
String[] currentIconLore = new String[]{ String[] currentIconLore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_ACTIVE_PARTICLES, pplayer.getActiveParticles().size()), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_ACTIVE_PARTICLES, pplayer.getActiveParticles().size()),
@ -50,6 +50,7 @@ public class GuiInventoryDefault extends GuiInventory {
currentIconMeta.setLore(GuiActionButton.parseLore(currentIconLore)); currentIconMeta.setLore(GuiActionButton.parseLore(currentIconLore));
currentIconMeta.setOwner(pplayer.getPlayer().getName()); currentIconMeta.setOwner(pplayer.getPlayer().getName());
headIcon.setItemMeta(currentIconMeta); headIcon.setItemMeta(currentIconMeta);
}
this.inventory.setItem(13, headIcon); this.inventory.setItem(13, headIcon);
@ -73,36 +74,33 @@ public class GuiInventoryDefault extends GuiInventory {
} }
// Manage Your Particles button // Manage Your Particles button
GuiActionButton manageYourParticlesButton = new GuiActionButton(manageParticlesSlot, GuiActionButton manageYourParticlesButton = new GuiActionButton(
manageParticlesSlot,
GuiIcon.PARTICLES.get(), GuiIcon.PARTICLES.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES), 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)}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES_DESCRIPTION)},
(button, isShiftClick) -> { (button, isShiftClick) -> GuiHandler.transition(new GuiInventoryManageParticles(pplayer)));
GuiHandler.transition(new GuiInventoryManageParticles(pplayer));
});
this.actionButtons.add(manageYourParticlesButton); this.actionButtons.add(manageYourParticlesButton);
// Manage Your Groups button // Manage Your Groups button
if (manageGroupsVisible) { if (manageGroupsVisible) {
GuiActionButton manageYourGroupsButton = new GuiActionButton(manageGroupsSlot, GuiActionButton manageYourGroupsButton = new GuiActionButton(
manageGroupsSlot,
GuiIcon.GROUPS.get(), GuiIcon.GROUPS.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS), 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)}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS_DESCRIPTION)},
(button, isShiftClick) -> { (button, isShiftClick) -> GuiHandler.transition(new GuiInventoryManageGroups(pplayer)));
GuiHandler.transition(new GuiInventoryManageGroups(pplayer));
});
this.actionButtons.add(manageYourGroupsButton); this.actionButtons.add(manageYourGroupsButton);
} }
// Load Preset Groups // Load Preset Groups
if (loadPresetGroupVisible) { if (loadPresetGroupVisible) {
GuiActionButton loadPresetGroups = new GuiActionButton(loadPresetGroupSlot, GuiActionButton loadPresetGroups = new GuiActionButton(
loadPresetGroupSlot,
GuiIcon.PRESET_GROUPS.get(), GuiIcon.PRESET_GROUPS.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP), 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)}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP_DESCRIPTION)},
(button, isShiftClick) -> { (button, isShiftClick) -> GuiHandler.transition(new GuiInventoryLoadPresetGroups(pplayer, false)));
GuiHandler.transition(new GuiInventoryLoadPresetGroups(pplayer));
});
this.actionButtons.add(loadPresetGroups); this.actionButtons.add(loadPresetGroups);
} }
@ -111,14 +109,15 @@ public class GuiInventoryDefault extends GuiInventory {
boolean doesEffectUseData = editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA); boolean doesEffectUseData = editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA);
// Edit Primary Effect // Edit Primary Effect
GuiActionButton editPrimaryEffect = new GuiActionButton(38, GuiActionButton editPrimaryEffect = new GuiActionButton(
38,
GuiIcon.EDIT_EFFECT.get(), GuiIcon.EDIT_EFFECT.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_EFFECT), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_EFFECT),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_EFFECT_DESCRIPTION)}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_EFFECT_DESCRIPTION)},
(button, isShiftClick) -> { (button, isShiftClick) -> {
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>(); List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryDefault(pplayer))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, callbacks, 1))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> { callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
if (canEditPrimaryStyleAndData) { if (canEditPrimaryStyleAndData) {
@ -150,16 +149,17 @@ public class GuiInventoryDefault extends GuiInventory {
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE_MISSING_EFFECT) LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE_MISSING_EFFECT)
}; };
} }
GuiActionButton editPrimaryStyle = new GuiActionButton(40, GuiActionButton editPrimaryStyle = new GuiActionButton(
40,
GuiIcon.EDIT_STYLE.get(), GuiIcon.EDIT_STYLE.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE),
editPrimaryStyleLore, editPrimaryStyleLore,
(button, isShiftClick) -> { (button, isShiftClick) -> {
if (!canEditPrimaryStyleAndData) return; if (!canEditPrimaryStyleAndData) return;
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>(); List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryDefault(pplayer))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, callbacks, 1))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> { callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) { for (ParticlePair particle : group.getParticles()) {
@ -192,16 +192,17 @@ public class GuiInventoryDefault extends GuiInventory {
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_MISSING_EFFECT) LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_MISSING_EFFECT)
}; };
} }
GuiActionButton editPrimaryData = new GuiActionButton(42, GuiActionButton editPrimaryData = new GuiActionButton(
42,
GuiIcon.EDIT_DATA.get(), GuiIcon.EDIT_DATA.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA),
editPrimaryDataLore, editPrimaryDataLore,
(button, isShiftClick) -> { (button, isShiftClick) -> {
if (!canEditPrimaryStyleAndData || !doesEffectUseData) return; if (!canEditPrimaryStyleAndData || !doesEffectUseData) return;
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>(); List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryDefault(pplayer))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, callbacks, 1))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> { callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) { for (ParticlePair particle : group.getParticles()) {

View file

@ -1,18 +1,5 @@
package com.esophose.playerparticles.gui; package com.esophose.playerparticles.gui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.SettingManager.GuiIcon; import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
@ -22,35 +9,47 @@ import com.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import com.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; import com.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import com.esophose.playerparticles.particles.ParticlePair; import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.util.NMSUtil;
import com.esophose.playerparticles.util.ParticleUtils; import com.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class GuiInventoryEditData extends GuiInventory { public class GuiInventoryEditData extends GuiInventory {
private static Random RANDOM = new Random();
private static List<Material> BLOCK_MATERIALS, ITEM_MATERIALS; private static List<Material> BLOCK_MATERIALS, ITEM_MATERIALS;
private static ColorData[] colorMapping; private static ColorData[] colorMapping;
private static ColorData[] rainbowColorMapping; private static ColorData[] rainbowColorMapping;
private static ColorData[] noteColorMapping; private static ColorData[] noteColorMapping, noteColorMappingOld;
static { static {
colorMapping = new ColorData[]{ colorMapping = new ColorData[]{
new ColorData(DyeColor.RED, ParticleUtils.closestMatch("ROSE_RED"), new OrdinaryColor(255, 0, 0), Lang.GUI_EDIT_DATA_COLOR_RED), new ColorData(DyeColor.RED, ParticleUtils.closestMatchWithFallback(false, "RED_DYE", "ROSE_RED"), new OrdinaryColor(255, 0, 0), Lang.GUI_EDIT_DATA_COLOR_RED),
new ColorData(DyeColor.ORANGE, ParticleUtils.closestMatch("ORANGE_DYE"), new OrdinaryColor(255, 140, 0), Lang.GUI_EDIT_DATA_COLOR_ORANGE), new ColorData(DyeColor.ORANGE, ParticleUtils.closestMatchWithFallback(false, "ORANGE_DYE"), new OrdinaryColor(255, 140, 0), Lang.GUI_EDIT_DATA_COLOR_ORANGE),
new ColorData(DyeColor.YELLOW, ParticleUtils.closestMatch("DANDELION_YELLOW"), new OrdinaryColor(255, 255, 0), Lang.GUI_EDIT_DATA_COLOR_YELLOW), new ColorData(DyeColor.YELLOW, ParticleUtils.closestMatchWithFallback(false, "YELLOW_DYE", "DANDELION_YELLOW"), new OrdinaryColor(255, 255, 0), Lang.GUI_EDIT_DATA_COLOR_YELLOW),
new ColorData(DyeColor.LIME, ParticleUtils.closestMatch("LIME_DYE"), new OrdinaryColor(50, 205, 50), Lang.GUI_EDIT_DATA_COLOR_LIME_GREEN), new ColorData(DyeColor.LIME, ParticleUtils.closestMatchWithFallback(false, "LIME_DYE"), new OrdinaryColor(50, 205, 50), Lang.GUI_EDIT_DATA_COLOR_LIME_GREEN),
new ColorData(DyeColor.GREEN, ParticleUtils.closestMatch("CACTUS_GREEN"), new OrdinaryColor(0, 128, 0), Lang.GUI_EDIT_DATA_COLOR_GREEN), new ColorData(DyeColor.GREEN, ParticleUtils.closestMatchWithFallback(false, "GREEN_DYE", "CACTUS_GREEN"), new OrdinaryColor(0, 128, 0), Lang.GUI_EDIT_DATA_COLOR_GREEN),
new ColorData(DyeColor.BLUE, ParticleUtils.closestMatch("LAPIS_LAZULI"), new OrdinaryColor(0, 0, 255), Lang.GUI_EDIT_DATA_COLOR_BLUE), new ColorData(DyeColor.BLUE, ParticleUtils.closestMatchWithFallback(false, "BLUE_DYE", "LAPIS_LAZULI"), new OrdinaryColor(0, 0, 255), Lang.GUI_EDIT_DATA_COLOR_BLUE),
new ColorData(DyeColor.CYAN, ParticleUtils.closestMatch("CYAN_DYE"), new OrdinaryColor(0, 139, 139), Lang.GUI_EDIT_DATA_COLOR_CYAN), new ColorData(DyeColor.CYAN, ParticleUtils.closestMatchWithFallback(false, "CYAN_DYE"), new OrdinaryColor(0, 139, 139), Lang.GUI_EDIT_DATA_COLOR_CYAN),
new ColorData(DyeColor.LIGHT_BLUE, ParticleUtils.closestMatch("LIGHT_BLUE_DYE"), new OrdinaryColor(173, 216, 230), Lang.GUI_EDIT_DATA_COLOR_LIGHT_BLUE), new ColorData(DyeColor.LIGHT_BLUE, ParticleUtils.closestMatchWithFallback(false, "LIGHT_BLUE_DYE"), new OrdinaryColor(173, 216, 230), Lang.GUI_EDIT_DATA_COLOR_LIGHT_BLUE),
new ColorData(DyeColor.PURPLE, ParticleUtils.closestMatch("PURPLE_DYE"), new OrdinaryColor(138, 43, 226), Lang.GUI_EDIT_DATA_COLOR_PURPLE), new ColorData(DyeColor.PURPLE, ParticleUtils.closestMatchWithFallback(false, "PURPLE_DYE"), new OrdinaryColor(138, 43, 226), Lang.GUI_EDIT_DATA_COLOR_PURPLE),
new ColorData(DyeColor.MAGENTA, ParticleUtils.closestMatch("MAGENTA_DYE"), new OrdinaryColor(202, 31, 123), Lang.GUI_EDIT_DATA_COLOR_MAGENTA), new ColorData(DyeColor.MAGENTA, ParticleUtils.closestMatchWithFallback(false, "MAGENTA_DYE"), new OrdinaryColor(202, 31, 123), Lang.GUI_EDIT_DATA_COLOR_MAGENTA),
new ColorData(DyeColor.PINK, ParticleUtils.closestMatch("PINK_DYE"), new OrdinaryColor(255, 182, 193), Lang.GUI_EDIT_DATA_COLOR_PINK), new ColorData(DyeColor.PINK, ParticleUtils.closestMatchWithFallback(false, "PINK_DYE"), new OrdinaryColor(255, 182, 193), Lang.GUI_EDIT_DATA_COLOR_PINK),
new ColorData(DyeColor.BROWN, ParticleUtils.closestMatch("COCOA_BEANS"), new OrdinaryColor(139, 69, 19), Lang.GUI_EDIT_DATA_COLOR_BROWN), new ColorData(DyeColor.BROWN, ParticleUtils.closestMatchWithFallback(false, "BROWN_DYE", "COCOA_BEANS"), new OrdinaryColor(139, 69, 19), Lang.GUI_EDIT_DATA_COLOR_BROWN),
new ColorData(DyeColor.BLACK, ParticleUtils.closestMatch("INK_SAC"), new OrdinaryColor(0, 0, 0), Lang.GUI_EDIT_DATA_COLOR_BLACK), new ColorData(DyeColor.BLACK, ParticleUtils.closestMatchWithFallback(false, "BLACK_DYE", "INK_SAC"), new OrdinaryColor(0, 0, 0), Lang.GUI_EDIT_DATA_COLOR_BLACK),
new ColorData(DyeColor.GRAY, ParticleUtils.closestMatch("GRAY_DYE"), new OrdinaryColor(128, 128, 128), Lang.GUI_EDIT_DATA_COLOR_GRAY), new ColorData(DyeColor.GRAY, ParticleUtils.closestMatchWithFallback(false, "GRAY_DYE"), new OrdinaryColor(128, 128, 128), Lang.GUI_EDIT_DATA_COLOR_GRAY),
new ColorData(DyeColor.getByDyeData((byte)7), ParticleUtils.closestMatch("LIGHT_GRAY_DYE"), new OrdinaryColor(192, 192, 192), Lang.GUI_EDIT_DATA_COLOR_LIGHT_GRAY), new ColorData(DyeColor.getByDyeData((byte) 7), ParticleUtils.closestMatchWithFallback(false, "LIGHT_GRAY_DYE"), new OrdinaryColor(192, 192, 192), Lang.GUI_EDIT_DATA_COLOR_LIGHT_GRAY),
new ColorData(DyeColor.WHITE, ParticleUtils.closestMatch("BONE_MEAL"), new OrdinaryColor(255, 255, 255), Lang.GUI_EDIT_DATA_COLOR_WHITE), new ColorData(DyeColor.WHITE, ParticleUtils.closestMatchWithFallback(false, "WHITE_DYE", "BONE_MEAL"), new OrdinaryColor(255, 255, 255), Lang.GUI_EDIT_DATA_COLOR_WHITE),
}; };
rainbowColorMapping = new ColorData[]{ rainbowColorMapping = new ColorData[]{
@ -59,41 +58,70 @@ public class GuiInventoryEditData extends GuiInventory {
colorMapping[2], // Yellow colorMapping[2], // Yellow
colorMapping[3], // Lime colorMapping[3], // Lime
colorMapping[7], // Light Blue colorMapping[7], // Light Blue
colorMapping[6], // Cyan
colorMapping[5], // Blue colorMapping[5], // Blue
colorMapping[8] // Purple colorMapping[8], // Purple
colorMapping[9] // Magenta
}; };
// Note: This is supposed to be a rainbow but there's actually a bug in Minecraft since 1.8 that makes a bunch of them gray
noteColorMapping = new ColorData[]{ noteColorMapping = new ColorData[]{
colorMapping[7], // Light Blue rainbowColorMapping[3], // 0 Lime
colorMapping[7], // Light Blue rainbowColorMapping[3], // 1 Lime
colorMapping[13], // Gray rainbowColorMapping[2], // 2 Yellow
colorMapping[10], // Pink rainbowColorMapping[1], // 3 Orange
colorMapping[9], // Magenta rainbowColorMapping[1], // 4 Orange
colorMapping[9], // Magenta rainbowColorMapping[0], // 5 Red
colorMapping[0], // Red rainbowColorMapping[0], // 6 Red
colorMapping[2], // Yellow rainbowColorMapping[0], // 7 Red
colorMapping[2], // Yellow rainbowColorMapping[8], // 8 Magenta
colorMapping[14], // Light Gray rainbowColorMapping[8], // 9 Magenta
colorMapping[13], // Gray rainbowColorMapping[7], // 10 Purple
colorMapping[6], // Cyan rainbowColorMapping[7], // 11 Purple
colorMapping[6], // Cyan rainbowColorMapping[7], // 12 Purple
colorMapping[6], // Cyan rainbowColorMapping[6], // 13 Blue
colorMapping[5], // Blue rainbowColorMapping[6], // 14 Blue
colorMapping[8], // Purple rainbowColorMapping[6], // 15 Blue
colorMapping[8], // Purple rainbowColorMapping[6], // 16 Blue
colorMapping[8], // Purple rainbowColorMapping[5], // 17 Cyan
colorMapping[13], // Gray rainbowColorMapping[5], // 18 Cyan
colorMapping[4], // Green rainbowColorMapping[5], // 20 Lime
colorMapping[3], // Lime rainbowColorMapping[5], // 21 Lime
colorMapping[2], // Yellow rainbowColorMapping[5], // 22 Lime
colorMapping[4], // Green rainbowColorMapping[5], // 23 Lime
colorMapping[7], // Light Blue rainbowColorMapping[5] // 24 Lime
colorMapping[7] // Light Blue
}; };
BLOCK_MATERIALS = new ArrayList<Material>(); // Note: Minecraft 1.8 through 1.13 had screwed up note color values, they were thankfully fixed in 1.14
ITEM_MATERIALS = new ArrayList<Material>(); noteColorMappingOld = new ColorData[]{
colorMapping[7], // 0 Light Blue
colorMapping[7], // 1 Light Blue
colorMapping[13], // 2 Gray
colorMapping[10], // 3 Pink
colorMapping[9], // 4 Magenta
colorMapping[9], // 5 Magenta
colorMapping[0], // 6 Red
colorMapping[2], // 7 Yellow
colorMapping[2], // 8 Yellow
colorMapping[14], // 9 Light Gray
colorMapping[13], // 10 Gray
colorMapping[6], // 11 Cyan
colorMapping[6], // 12 Cyan
colorMapping[6], // 13 Cyan
colorMapping[5], // 14 Blue
colorMapping[8], // 15 Purple
colorMapping[8], // 16 Purple
colorMapping[8], // 17 Purple
colorMapping[13], // 18 Gray
colorMapping[4], // 19 Green
colorMapping[3], // 20 Lime
colorMapping[2], // 21 Yellow
colorMapping[4], // 22 Green
colorMapping[7], // 23 Light Blue
colorMapping[7] // 24 Light Blue
};
BLOCK_MATERIALS = new ArrayList<>();
ITEM_MATERIALS = new ArrayList<>();
Inventory tempInventory = Bukkit.createInventory(null, 9); Inventory tempInventory = Bukkit.createInventory(null, 9);
for (Material mat : Material.values()) { for (Material mat : Material.values()) {
@ -111,28 +139,33 @@ public class GuiInventoryEditData extends GuiInventory {
} }
} }
public GuiInventoryEditData(PPlayer pplayer, ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) { public GuiInventoryEditData(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_DATA))); super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_DATA)));
this.fillBorder(BorderColor.MAGENTA);
ParticleEffect pe = editingParticle.getEffect(); ParticleEffect pe = editingParticle.getEffect();
if (pe.hasProperty(ParticleProperty.COLORABLE)) { if (pe.hasProperty(ParticleProperty.COLORABLE)) {
if (pe == ParticleEffect.NOTE) { // Note data if (pe == ParticleEffect.NOTE) { // Note data
this.populateNoteData(editingParticle, callbackList, callbackListPosition); this.populateNoteData(editingParticle, pageNumber, callbackList, callbackListPosition);
} else { // Color data } else { // Color data
this.populateColorData(editingParticle, callbackList, callbackListPosition); this.populateColorData(editingParticle, pageNumber, callbackList, callbackListPosition);
} }
} else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { } else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (pe == ParticleEffect.ITEM) { // Item data if (pe == ParticleEffect.ITEM) { // Item data
this.populateItemData(editingParticle, callbackList, callbackListPosition); this.populateItemData(editingParticle, pageNumber, callbackList, callbackListPosition);
} else { // Block data } else { // Block data
this.populateBlockData(editingParticle, callbackList, callbackListPosition); this.populateBlockData(editingParticle, pageNumber, callbackList, callbackListPosition);
} }
} }
// Back Button // Back Button
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> { GuiActionButton backButton = new GuiActionButton(
callbackList.get(callbackListPosition - 1).execute(); INVENTORY_SIZE - 1,
}); GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
new String[]{},
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
this.actionButtons.add(backButton); this.actionButtons.add(backButton);
this.populate(); this.populate();
@ -142,18 +175,19 @@ public class GuiInventoryEditData extends GuiInventory {
* Populates the Inventory with available color data options * Populates the Inventory with available color data options
* *
* @param editingParticle The ParticlePair that's being edited * @param editingParticle The ParticlePair that's being edited
* @param pageNumber The current page number
* @param callbackList The List of GuiInventoryEditFinishedCallbacks * @param callbackList The List of GuiInventoryEditFinishedCallbacks
* @param callbackListPosition The index of the callbackList we're currently at * @param callbackListPosition The index of the callbackList we're currently at
*/ */
private void populateColorData(ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) { private void populateColorData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
int index = 10; int index = 10;
int nextWrap = 17; int nextWrap = 17;
for (int i = 0; i < colorMapping.length; i++) { for (ColorData colorData : colorMapping) {
ColorData colorData = colorMapping[i];
String formattedDisplayColor = ChatColor.RED.toString() + colorData.getOrdinaryColor().getRed() + " " + ChatColor.GREEN + colorData.getOrdinaryColor().getGreen() + " " + ChatColor.AQUA + colorData.getOrdinaryColor().getBlue(); String formattedDisplayColor = ChatColor.RED.toString() + colorData.getOrdinaryColor().getRed() + " " + ChatColor.GREEN + colorData.getOrdinaryColor().getGreen() + " " + ChatColor.AQUA + colorData.getOrdinaryColor().getBlue();
// Color Data Buttons // Color Data Buttons
GuiActionButton setColorButton = new GuiActionButton(index, GuiActionButton setColorButton = new GuiActionButton(
index,
colorData, colorData,
colorData.getName(), colorData.getName(),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, formattedDisplayColor)}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, formattedDisplayColor)},
@ -171,7 +205,8 @@ public class GuiInventoryEditData extends GuiInventory {
} }
// Rainbow Color Data Button // Rainbow Color Data Button
GuiActionButton setRainbowColorButton = new GuiActionButton(39, GuiActionButton setRainbowColorButton = new GuiActionButton(
39,
rainbowColorMapping, rainbowColorMapping,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RAINBOW), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RAINBOW),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RAINBOW))}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RAINBOW))},
@ -202,17 +237,26 @@ public class GuiInventoryEditData extends GuiInventory {
* *
* @param editingParticle The ParticlePair that's being edited * @param editingParticle The ParticlePair that's being edited
* @param callbackList The List of GuiInventoryEditFinishedCallbacks * @param callbackList The List of GuiInventoryEditFinishedCallbacks
* @param pageNumber The current page number
* @param callbackListPosition The index of the callbackList we're currently at * @param callbackListPosition The index of the callbackList we're currently at
*/ */
private void populateNoteData(ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) { private void populateNoteData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
for (int i = 0; i < noteColorMapping.length; i++) { int numberOfItems = noteColorMapping.length;
ColorData colorData = noteColorMapping[i]; int itemsPerPage = 14;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
int slot = 10;
int nextWrap = 17;
int maxSlot = 25;
for (int i = (pageNumber - 1) * itemsPerPage; i < numberOfItems; i++) {
ColorData colorData = NMSUtil.getVersionNumber() > 13 ? noteColorMapping[i] : noteColorMappingOld[i];
String formattedDisplayName = LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, i) + " (" + colorData.getName() + LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ")"; String formattedDisplayName = LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, i) + " (" + colorData.getName() + LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ")";
String formattedDescription = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, i)); String formattedDescription = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, i));
// Note Color Buttons // Note Color Buttons
int noteIndex = i; int noteIndex = i;
GuiActionButton setColorButton = new GuiActionButton(i, GuiActionButton setColorButton = new GuiActionButton(
slot,
colorData, colorData,
formattedDisplayName, formattedDisplayName,
new String[]{formattedDescription}, new String[]{formattedDescription},
@ -221,10 +265,18 @@ public class GuiInventoryEditData extends GuiInventory {
callbackList.get(callbackListPosition + 1).execute(); callbackList.get(callbackListPosition + 1).execute();
}); });
this.actionButtons.add(setColorButton); this.actionButtons.add(setColorButton);
slot++;
if (slot == nextWrap) { // Loop around border
nextWrap += 9;
slot += 2;
}
if (slot > maxSlot) break; // Overflowed the available space
} }
// Rainbow Note Data Button // Rainbow Note Data Button
GuiActionButton setRainbowColorButton = new GuiActionButton(39, GuiActionButton setRainbowColorButton = new GuiActionButton(
39,
rainbowColorMapping, rainbowColorMapping,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RAINBOW), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RAINBOW),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RAINBOW))}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RAINBOW))},
@ -239,7 +291,8 @@ public class GuiInventoryEditData extends GuiInventory {
Collections.shuffle(randomizedColorsList); Collections.shuffle(randomizedColorsList);
ColorData[] randomizedColors = new ColorData[randomizedColorsList.size()]; ColorData[] randomizedColors = new ColorData[randomizedColorsList.size()];
randomizedColors = randomizedColorsList.toArray(randomizedColors); randomizedColors = randomizedColorsList.toArray(randomizedColors);
GuiActionButton setRandomColorButton = new GuiActionButton(41, GuiActionButton setRandomColorButton = new GuiActionButton(
41,
randomizedColors, randomizedColors,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RANDOM), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.RANDOM),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RANDOM))}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RANDOM))},
@ -248,6 +301,28 @@ public class GuiInventoryEditData extends GuiInventory {
callbackList.get(callbackListPosition + 1).execute(); callbackList.get(callbackListPosition + 1).execute();
}); });
this.actionButtons.add(setRandomColorButton); this.actionButtons.add(setRandomColorButton);
// Previous page button
if (pageNumber != 1) {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
// Next page button
if (pageNumber != maxPages) {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}
} }
/** /**
@ -255,19 +330,22 @@ public class GuiInventoryEditData extends GuiInventory {
* *
* @param editingParticle The ParticlePair that's being edited * @param editingParticle The ParticlePair that's being edited
* @param callbackList The List of GuiInventoryEditFinishedCallbacks * @param callbackList The List of GuiInventoryEditFinishedCallbacks
* @param pageNumber The current page number
* @param callbackListPosition The index of the callbackList we're currently at * @param callbackListPosition The index of the callbackList we're currently at
*/ */
private void populateItemData(ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) { private void populateItemData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
List<Material> materialBag = new ArrayList<Material>(); int numberOfItems = ITEM_MATERIALS.size();
while (materialBag.size() < 36) { // Grab 36 random materials that are an item int itemsPerPage = 28;
Material randomMaterial = ITEM_MATERIALS.get(RANDOM.nextInt(ITEM_MATERIALS.size())); int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
if (!materialBag.contains(randomMaterial)) materialBag.add(randomMaterial); int slot = 10;
} int nextWrap = 17;
int maxSlot = 43;
for (int i = 0; i < materialBag.size(); i++) { for (int i = (pageNumber - 1) * itemsPerPage; i < numberOfItems; i++) {
// Item Data Button // Item Data Button
Material material = materialBag.get(i); Material material = ITEM_MATERIALS.get(i);
GuiActionButton setRainbowColorButton = new GuiActionButton(i, GuiActionButton setRainbowColorButton = new GuiActionButton(
slot,
material, material,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + material.name().toLowerCase(), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + material.name().toLowerCase(),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, material.name().toLowerCase())}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, material.name().toLowerCase())},
@ -276,17 +354,36 @@ public class GuiInventoryEditData extends GuiInventory {
callbackList.get(callbackListPosition + 1).execute(); callbackList.get(callbackListPosition + 1).execute();
}); });
this.actionButtons.add(setRainbowColorButton); this.actionButtons.add(setRainbowColorButton);
slot++;
if (slot == nextWrap) { // Loop around border
nextWrap += 9;
slot += 2;
}
if (slot > maxSlot) break; // Overflowed the available space
} }
// Randomize Button, re-randomizes the icons // Previous page button
GuiActionButton randomizeButton = new GuiActionButton(45, if (pageNumber != 1) {
GuiIcon.RANDOMIZE.get(), GuiActionButton previousPageButton = new GuiActionButton(
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SELECT_DATA_RANDOMIZE_ITEMS), INVENTORY_SIZE - 6,
new String[] { LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_SELECT_DATA_RANDOMIZE_ITEMS_DESCRIPTION) }, GuiIcon.PREVIOUS_PAGE.get(),
(block, isShiftClick) -> { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
callbackList.get(callbackListPosition).execute(); // Just reopen the same inventory new String[]{},
}); (button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(randomizeButton); this.actionButtons.add(previousPageButton);
}
// Next page button
if (pageNumber != maxPages) {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}
} }
/** /**
@ -294,19 +391,22 @@ public class GuiInventoryEditData extends GuiInventory {
* *
* @param editingParticle The ParticlePair that's being edited * @param editingParticle The ParticlePair that's being edited
* @param callbackList The List of GuiInventoryEditFinishedCallbacks * @param callbackList The List of GuiInventoryEditFinishedCallbacks
* @param pageNumber The current page number
* @param callbackListPosition The index of the callbackList we're currently at * @param callbackListPosition The index of the callbackList we're currently at
*/ */
private void populateBlockData(ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) { private void populateBlockData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
List<Material> materialBag = new ArrayList<Material>(); int numberOfItems = BLOCK_MATERIALS.size();
while (materialBag.size() < 36) { // Grab 36 random materials that are an item int itemsPerPage = 28;
Material randomMaterial = BLOCK_MATERIALS.get(RANDOM.nextInt(BLOCK_MATERIALS.size())); int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
if (!materialBag.contains(randomMaterial)) materialBag.add(randomMaterial); int slot = 10;
} int nextWrap = 17;
int maxSlot = 43;
for (int i = 0; i < materialBag.size(); i++) { for (int i = (pageNumber - 1) * itemsPerPage; i < numberOfItems; i++) {
// Item Data Button // Item Data Button
Material material = materialBag.get(i); Material material = BLOCK_MATERIALS.get(i);
GuiActionButton setRainbowColorButton = new GuiActionButton(i, GuiActionButton setRainbowColorButton = new GuiActionButton(
slot,
material, material,
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + material.name().toLowerCase(), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + material.name().toLowerCase(),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, material.name().toLowerCase())}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, material.name().toLowerCase())},
@ -315,17 +415,36 @@ public class GuiInventoryEditData extends GuiInventory {
callbackList.get(callbackListPosition + 1).execute(); callbackList.get(callbackListPosition + 1).execute();
}); });
this.actionButtons.add(setRainbowColorButton); this.actionButtons.add(setRainbowColorButton);
slot++;
if (slot == nextWrap) { // Loop around border
nextWrap += 9;
slot += 2;
}
if (slot > maxSlot) break; // Overflowed the available space
} }
// Randomize Button, re-randomizes the icons // Previous page button
GuiActionButton randomizeButton = new GuiActionButton(45, if (pageNumber != 1) {
GuiIcon.RANDOMIZE.get(), GuiActionButton previousPageButton = new GuiActionButton(
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SELECT_DATA_RANDOMIZE_BLOCKS), INVENTORY_SIZE - 6,
new String[] { LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_SELECT_DATA_RANDOMIZE_BLOCKS_DESCRIPTION) }, GuiIcon.PREVIOUS_PAGE.get(),
(block, isShiftClick) -> { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
callbackList.get(callbackListPosition).execute(); // Just reopen the same inventory new String[]{},
}); (button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(randomizeButton); this.actionButtons.add(previousPageButton);
}
// Next page button
if (pageNumber != maxPages) {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}
} }
/** /**

View file

@ -1,9 +1,5 @@
package com.esophose.playerparticles.gui; package com.esophose.playerparticles.gui;
import java.util.List;
import org.bukkit.Bukkit;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
@ -12,17 +8,30 @@ import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleEffect; import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.particles.ParticlePair; import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.util.ParticleUtils; import com.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import java.util.List;
public class GuiInventoryEditEffect extends GuiInventory { public class GuiInventoryEditEffect extends GuiInventory {
public GuiInventoryEditEffect(PPlayer pplayer, ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) { public GuiInventoryEditEffect(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_EFFECT))); super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_EFFECT)));
this.fillBorder(BorderColor.LIGHT_BLUE);
// Select Effect Buttons // Select Effect Buttons
List<ParticleEffect> effectsUserHasPermissionFor = PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer()); List<ParticleEffect> effectsUserHasPermissionFor = PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer());
for (int i = 0; i < effectsUserHasPermissionFor.size(); i++) { int numberOfItems = effectsUserHasPermissionFor.size();
int itemsPerPage = 28;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
int slot = 10;
int nextWrap = 17;
int maxSlot = 43;
for (int i = (pageNumber - 1) * itemsPerPage; i < numberOfItems; i++) {
ParticleEffect effect = effectsUserHasPermissionFor.get(i); ParticleEffect effect = effectsUserHasPermissionFor.get(i);
GuiActionButton selectButton = new GuiActionButton(i, GuiActionButton selectButton = new GuiActionButton(
slot,
GuiIcon.EFFECT.get(effect.getName()), GuiIcon.EFFECT.get(effect.getName()),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ParticleUtils.formatName(effect.getName()), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ParticleUtils.formatName(effect.getName()),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, ParticleUtils.formatName(effect.getName()))}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, ParticleUtils.formatName(effect.getName()))},
@ -31,14 +40,46 @@ public class GuiInventoryEditEffect extends GuiInventory {
callbackList.get(callbackListPosition + 1).execute(); callbackList.get(callbackListPosition + 1).execute();
}); });
this.actionButtons.add(selectButton); this.actionButtons.add(selectButton);
slot++;
if (slot == nextWrap) { // Loop around border
nextWrap += 9;
slot += 2;
}
if (slot > maxSlot) break; // Overflowed the available space
} }
// Back Button // Back Button
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> { GuiActionButton backButton = new GuiActionButton(
callbackList.get(callbackListPosition - 1).execute(); INVENTORY_SIZE - 1,
}); GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
new String[]{},
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
this.actionButtons.add(backButton); this.actionButtons.add(backButton);
// Previous page button
if (pageNumber != 1) {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
// Next page button
if (pageNumber != maxPages) {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}
this.populate(); this.populate();
} }

View file

@ -1,10 +1,5 @@
package com.esophose.playerparticles.gui; package com.esophose.playerparticles.gui;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import com.esophose.playerparticles.manager.DataManager; import com.esophose.playerparticles.manager.DataManager;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
@ -13,6 +8,10 @@ import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import com.esophose.playerparticles.particles.ParticleGroup; import com.esophose.playerparticles.particles.ParticleGroup;
import com.esophose.playerparticles.particles.ParticlePair; import com.esophose.playerparticles.particles.ParticlePair;
import org.bukkit.Bukkit;
import java.util.ArrayList;
import java.util.List;
public class GuiInventoryEditParticle extends GuiInventory { public class GuiInventoryEditParticle extends GuiInventory {
@ -23,7 +22,8 @@ public class GuiInventoryEditParticle extends GuiInventory {
// Particle Info Icon // Particle Info Icon
String particleInfo = LangManager.getText(Lang.GUI_PARTICLE_INFO, editingParticle.getId(), editingParticle.getEffect().getName(), editingParticle.getStyle().getName(), editingParticle.getDataString()); String particleInfo = LangManager.getText(Lang.GUI_PARTICLE_INFO, editingParticle.getId(), editingParticle.getEffect().getName(), editingParticle.getStyle().getName(), editingParticle.getDataString());
GuiActionButton particleInfoIcon = new GuiActionButton(13, GuiActionButton particleInfoIcon = new GuiActionButton(
13,
GuiIcon.PARTICLES.get(), GuiIcon.PARTICLES.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_PARTICLE_NAME, editingParticle.getId()), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_PARTICLE_NAME, editingParticle.getId()),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + particleInfo}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + particleInfo},
@ -31,14 +31,15 @@ public class GuiInventoryEditParticle extends GuiInventory {
this.actionButtons.add(particleInfoIcon); this.actionButtons.add(particleInfoIcon);
// Edit Effect Button // Edit Effect Button
GuiActionButton editEffectButton = new GuiActionButton(38, GuiActionButton editEffectButton = new GuiActionButton(
38,
GuiIcon.EDIT_EFFECT.get(), GuiIcon.EDIT_EFFECT.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_EFFECT), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_EFFECT),
new String[]{LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_EFFECT_DESCRIPTION)}, new String[]{LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_EFFECT_DESCRIPTION)},
(button, isShiftClick) -> { (button, isShiftClick) -> {
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>(); List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, callbacks, 1))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> { callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) { for (ParticlePair particle : group.getParticles()) {
@ -62,9 +63,9 @@ public class GuiInventoryEditParticle extends GuiInventory {
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_STYLE), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_STYLE),
new String[]{LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_STYLE_DESCRIPTION)}, new String[]{LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_STYLE_DESCRIPTION)},
(button, isShiftClick) -> { (button, isShiftClick) -> {
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>(); List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, callbacks, 1))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> { callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) { for (ParticlePair particle : group.getParticles()) {
@ -91,9 +92,9 @@ public class GuiInventoryEditParticle extends GuiInventory {
new String[]{LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_DATA_UNAVAILABLE)}, new String[]{LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_DATA_UNAVAILABLE)},
(button, isShiftClick) -> { (button, isShiftClick) -> {
if (usesData) { if (usesData) {
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>(); List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, callbacks, 1))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> { callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) { for (ParticlePair particle : group.getParticles()) {
@ -116,9 +117,12 @@ public class GuiInventoryEditParticle extends GuiInventory {
this.actionButtons.add(editDataButton); this.actionButtons.add(editDataButton);
// Back Button // Back Button
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> { GuiActionButton backButton = new GuiActionButton(
GuiHandler.transition(new GuiInventoryManageParticles(pplayer)); 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 GuiInventoryManageParticles(pplayer)));
this.actionButtons.add(backButton); this.actionButtons.add(backButton);
this.populate(); this.populate();

View file

@ -1,9 +1,5 @@
package com.esophose.playerparticles.gui; package com.esophose.playerparticles.gui;
import java.util.List;
import org.bukkit.Bukkit;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
@ -12,17 +8,30 @@ import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticlePair; import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.styles.api.ParticleStyle; import com.esophose.playerparticles.styles.api.ParticleStyle;
import com.esophose.playerparticles.util.ParticleUtils; import com.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import java.util.List;
public class GuiInventoryEditStyle extends GuiInventory { public class GuiInventoryEditStyle extends GuiInventory {
public GuiInventoryEditStyle(PPlayer pplayer, ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) { public GuiInventoryEditStyle(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_STYLE))); super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_STYLE)));
this.fillBorder(BorderColor.BLUE);
// Select Style Buttons // Select Style Buttons
List<ParticleStyle> stylesUserHasPermissionFor = PermissionManager.getStylesUserHasPermissionFor(pplayer.getPlayer()); List<ParticleStyle> stylesUserHasPermissionFor = PermissionManager.getStylesUserHasPermissionFor(pplayer.getPlayer());
for (int i = 0; i < stylesUserHasPermissionFor.size(); i++) { int numberOfItems = stylesUserHasPermissionFor.size();
int itemsPerPage = 28;
int maxPages = (int) Math.ceil((double) numberOfItems / itemsPerPage);
int slot = 10;
int nextWrap = 17;
int maxSlot = 43;
for (int i = (pageNumber - 1) * itemsPerPage; i < numberOfItems; i++) {
ParticleStyle style = stylesUserHasPermissionFor.get(i); ParticleStyle style = stylesUserHasPermissionFor.get(i);
GuiActionButton selectButton = new GuiActionButton(i, GuiActionButton selectButton = new GuiActionButton(
slot,
GuiIcon.STYLE.get(style.getName()), GuiIcon.STYLE.get(style.getName()),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ParticleUtils.formatName(style.getName()), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ParticleUtils.formatName(style.getName()),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, ParticleUtils.formatName(style.getName()))}, new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, ParticleUtils.formatName(style.getName()))},
@ -31,14 +40,46 @@ public class GuiInventoryEditStyle extends GuiInventory {
callbackList.get(callbackListPosition + 1).execute(); callbackList.get(callbackListPosition + 1).execute();
}); });
this.actionButtons.add(selectButton); this.actionButtons.add(selectButton);
slot++;
if (slot == nextWrap) { // Loop around border
nextWrap += 9;
slot += 2;
}
if (slot > maxSlot) break; // Overflowed the available space
} }
// Back Button // Back Button
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> { GuiActionButton backButton = new GuiActionButton(
callbackList.get(callbackListPosition - 1).execute(); INVENTORY_SIZE - 1,
}); GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
new String[]{},
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
this.actionButtons.add(backButton); this.actionButtons.add(backButton);
// Previous page button
if (pageNumber != 1) {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
// Next page button
if (pageNumber != maxPages) {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
new String[]{},
(button, isShiftClick) -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}
this.populate(); this.populate();
} }

View file

@ -1,33 +1,39 @@
package com.esophose.playerparticles.gui; package com.esophose.playerparticles.gui;
import java.util.Comparator;
import java.util.List;
import org.bukkit.Bukkit;
import com.esophose.playerparticles.manager.DataManager; import com.esophose.playerparticles.manager.DataManager;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.ParticleGroupPresetManager; import com.esophose.playerparticles.manager.ParticleGroupPresetManager;
import com.esophose.playerparticles.manager.SettingManager.GuiIcon; import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
import com.esophose.playerparticles.manager.SettingManager.PSetting;
import com.esophose.playerparticles.particles.PPlayer; import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleGroup; import com.esophose.playerparticles.particles.ParticleGroup;
import com.esophose.playerparticles.particles.ParticleGroupPreset; import com.esophose.playerparticles.particles.ParticleGroupPreset;
import com.esophose.playerparticles.particles.ParticlePair; import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.util.ParticleUtils; import com.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.Comparator;
import java.util.List;
public class GuiInventoryLoadPresetGroups extends GuiInventory { public class GuiInventoryLoadPresetGroups extends GuiInventory {
public GuiInventoryLoadPresetGroups(PPlayer pplayer) { public GuiInventoryLoadPresetGroups(PPlayer pplayer, boolean isEndPoint) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP))); super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP)));
this.fillBorder(BorderColor.GREEN); this.fillBorder(BorderColor.GREEN);
Player player = pplayer.getPlayer();
int index = 10; int index = 10;
int nextWrap = 17; int nextWrap = 17;
int maxIndex = 43; int maxIndex = 43;
List<ParticleGroupPreset> groups = ParticleGroupPresetManager.getPresetGroupsForPlayer(pplayer.getPlayer()); List<ParticleGroupPreset> groups = ParticleGroupPresetManager.getPresetGroupsForPlayer(pplayer.getPlayer());
for (ParticleGroupPreset group : groups) { for (ParticleGroupPreset group : groups) {
if (!group.getGroup().canPlayerUse(player))
continue;
List<ParticlePair> particles = group.getGroup().getParticles(); List<ParticlePair> particles = group.getGroup().getParticles();
particles.sort(Comparator.comparingInt(ParticlePair::getId)); particles.sort(Comparator.comparingInt(ParticlePair::getId));
@ -47,7 +53,9 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
activeGroup.getParticles().add(particle.clone()); activeGroup.getParticles().add(particle.clone());
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup); DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
if (PSetting.GUI_CLOSE_AFTER_GROUP_SELECTED.getBoolean()) {
pplayer.getPlayer().closeInventory(); pplayer.getPlayer().closeInventory();
}
}); });
this.actionButtons.add(groupButton); this.actionButtons.add(groupButton);
@ -59,11 +67,27 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
if (index > maxIndex) break; // Overflowed the available space if (index > maxIndex) break; // Overflowed the available space
} }
if (!isEndPoint) {
// Back Button // Back Button
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> { GuiActionButton backButton = new GuiActionButton(
GuiHandler.transition(new GuiInventoryDefault(pplayer)); 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)));
this.actionButtons.add(backButton); this.actionButtons.add(backButton);
} else {
// Reset Particles Button
GuiActionButton resetParticles = new GuiActionButton(
49,
GuiIcon.RESET.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_RESET_PARTICLES),
new String[]{LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_RESET_PARTICLES_DESCRIPTION)},
(button, isShiftClick) -> {
// Reset particles
DataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
});
this.actionButtons.add(resetParticles);
}
this.populate(); this.populate();
} }

View file

@ -1,22 +1,22 @@
package com.esophose.playerparticles.gui; package com.esophose.playerparticles.gui;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.bukkit.Bukkit;
import com.esophose.playerparticles.gui.hook.PlayerChatHook; import com.esophose.playerparticles.gui.hook.PlayerChatHook;
import com.esophose.playerparticles.gui.hook.PlayerChatHookData; import com.esophose.playerparticles.gui.hook.PlayerChatHookData;
import com.esophose.playerparticles.manager.DataManager; import com.esophose.playerparticles.manager.DataManager;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.manager.SettingManager.GuiIcon; import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
import com.esophose.playerparticles.manager.SettingManager.PSetting;
import com.esophose.playerparticles.particles.PPlayer; import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleGroup; import com.esophose.playerparticles.particles.ParticleGroup;
import com.esophose.playerparticles.particles.ParticlePair; import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.util.ParticleUtils; import com.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class GuiInventoryManageGroups extends GuiInventory { public class GuiInventoryManageGroups extends GuiInventory {
@ -47,7 +47,12 @@ public class GuiInventoryManageGroups extends GuiInventory {
lore[i] = LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_SHIFT_CLICK_TO_DELETE); lore[i] = LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_SHIFT_CLICK_TO_DELETE);
// Load Group Buttons // Load Group Buttons
GuiActionButton groupButton = new GuiActionButton(index, GuiIcon.GROUPS.get(), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + group.getName(), lore, (button, isShiftClick) -> { GuiActionButton groupButton = new GuiActionButton(
index,
GuiIcon.GROUPS.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + group.getName(),
lore,
(button, isShiftClick) -> {
if (isShiftClick) { if (isShiftClick) {
DataManager.removeParticleGroup(pplayer.getUniqueId(), group); DataManager.removeParticleGroup(pplayer.getUniqueId(), group);
@ -60,8 +65,10 @@ public class GuiInventoryManageGroups extends GuiInventory {
activeGroup.getParticles().add(particle.clone()); activeGroup.getParticles().add(particle.clone());
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup); DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
if (PSetting.GUI_CLOSE_AFTER_GROUP_SELECTED.getBoolean()) {
pplayer.getPlayer().closeInventory(); pplayer.getPlayer().closeInventory();
} }
}
}); });
this.actionButtons.add(groupButton); this.actionButtons.add(groupButton);
@ -91,7 +98,8 @@ public class GuiInventoryManageGroups extends GuiInventory {
} }
// Save Group Button // Save Group Button
GuiActionButton saveGroupButton = new GuiActionButton(40, GuiActionButton saveGroupButton = new GuiActionButton(
40,
GuiIcon.CREATE.get(), GuiIcon.CREATE.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SAVE_GROUP), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SAVE_GROUP),
lore, lore,
@ -143,9 +151,12 @@ public class GuiInventoryManageGroups extends GuiInventory {
this.actionButtons.add(saveGroupButton); this.actionButtons.add(saveGroupButton);
// Back Button // Back Button
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> { GuiActionButton backButton = new GuiActionButton(
GuiHandler.transition(new GuiInventoryDefault(pplayer)); 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)));
this.actionButtons.add(backButton); this.actionButtons.add(backButton);
this.populate(); this.populate();

View file

@ -1,22 +1,21 @@
package com.esophose.playerparticles.gui; package com.esophose.playerparticles.gui;
import com.esophose.playerparticles.manager.DataManager;
import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import com.esophose.playerparticles.particles.ParticleGroup;
import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import com.esophose.playerparticles.manager.DataManager;
import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleGroup;
import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import com.esophose.playerparticles.util.ParticleUtils;
public class GuiInventoryManageParticles extends GuiInventory { public class GuiInventoryManageParticles extends GuiInventory {
public GuiInventoryManageParticles(PPlayer pplayer) { public GuiInventoryManageParticles(PPlayer pplayer) {
@ -32,7 +31,8 @@ public class GuiInventoryManageParticles extends GuiInventory {
int nextWrap = 17; int nextWrap = 17;
int maxIndex = 35; int maxIndex = 35;
for (ParticlePair particle : particles) { for (ParticlePair particle : particles) {
GuiActionButton selectButton = new GuiActionButton(index, GuiActionButton selectButton = new GuiActionButton(
index,
GuiIcon.PARTICLES.get(), GuiIcon.PARTICLES.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_PARTICLE_NAME, particle.getId()), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_PARTICLE_NAME, particle.getId()),
new String[]{ new String[]{
@ -72,20 +72,21 @@ public class GuiInventoryManageParticles extends GuiInventory {
// Create New Particle Button // Create New Particle Button
boolean canCreate = pplayer.getActiveParticles().size() < PermissionManager.getMaxParticlesAllowed(pplayer.getPlayer()); boolean canCreate = pplayer.getActiveParticles().size() < PermissionManager.getMaxParticlesAllowed(pplayer.getPlayer());
String lore = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_CREATE_PARTICLE_DESCRIPTION); String lore = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_CREATE_PARTICLE_DESCRIPTION);
GuiActionButton createNewParticle = new GuiActionButton(38, GuiActionButton createNewParticle = new GuiActionButton(
38,
GuiIcon.CREATE.get(), GuiIcon.CREATE.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_CREATE_PARTICLE), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_CREATE_PARTICLE),
canCreate ? new String[]{lore} : new String[]{lore, LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_CREATE_PARTICLE_UNAVAILABLE)}, canCreate ? new String[]{lore} : new String[]{lore, LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_CREATE_PARTICLE_UNAVAILABLE)},
(button, isShiftClick) -> { (button, isShiftClick) -> {
if (!canCreate) return; if (!canCreate) return;
ParticlePair editingParticle = ParticlePair.getNextDefault(pplayer); ParticlePair editingParticle = ParticlePair.getNextDefault(pplayer);
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>(); List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiHandler.transition(new GuiInventoryManageParticles(pplayer))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryManageParticles(pplayer)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, callbacks, 1))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, callbacks, 2))); callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 2)));
callbacks.add(() -> { callbacks.add(() -> {
if (editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { if (editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, callbacks, 3)); GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 3));
} else { } else {
callbacks.get(4).execute(); callbacks.get(4).execute();
} }
@ -118,9 +119,12 @@ public class GuiInventoryManageParticles extends GuiInventory {
this.actionButtons.add(resetParticles); this.actionButtons.add(resetParticles);
// Back Button // Back Button
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> { GuiActionButton backButton = new GuiActionButton(
GuiHandler.transition(new GuiInventoryDefault(pplayer)); 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)));
this.actionButtons.add(backButton); this.actionButtons.add(backButton);
this.populate(); this.populate();

View file

@ -3,6 +3,7 @@ package com.esophose.playerparticles.gui.hook;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import com.esophose.playerparticles.util.NMSUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -27,13 +28,12 @@ public class PlayerChatHook extends BukkitRunnable implements Listener {
* Initializes all the static values for this class * Initializes all the static values for this class
*/ */
public static void setup() { public static void setup() {
hooks = new HashSet<PlayerChatHookData>(); hooks = new HashSet<>();
if (hookTask != null) if (hookTask != null)
hookTask.cancel(); hookTask.cancel();
hookTask = new PlayerChatHook().runTaskTimer(PlayerParticles.getPlugin(), 0, 20); hookTask = new PlayerChatHook().runTaskTimer(PlayerParticles.getPlugin(), 0, 20);
} }
/** /**
* Called when a player sends a message in chat * Called when a player sends a message in chat
* *
@ -44,8 +44,8 @@ public class PlayerChatHook extends BukkitRunnable implements Listener {
for (PlayerChatHookData hook : hooks) { for (PlayerChatHookData hook : hooks) {
if (hook.getPlayerUUID().equals(event.getPlayer().getUniqueId())) { if (hook.getPlayerUUID().equals(event.getPlayer().getUniqueId())) {
event.setCancelled(true); event.setCancelled(true);
hook.triggerCallback(event.getMessage());
hooks.remove(hook); hooks.remove(hook);
Bukkit.getScheduler().scheduleSyncDelayedTask(PlayerParticles.getPlugin(), () -> hook.triggerCallback(event.getMessage()));
return; return;
} }
} }
@ -55,7 +55,7 @@ public class PlayerChatHook extends BukkitRunnable implements Listener {
* Ticked every second to decrease the seconds remaining on each hook * Ticked every second to decrease the seconds remaining on each hook
*/ */
public void run() { public void run() {
Set<PlayerChatHookData> hooksToRemove = new HashSet<PlayerChatHookData>(); Set<PlayerChatHookData> hooksToRemove = new HashSet<>();
for (PlayerChatHookData hook : hooks) { for (PlayerChatHookData hook : hooks) {
hook.decrementHookLength(); hook.decrementHookLength();
@ -68,10 +68,15 @@ public class PlayerChatHook extends BukkitRunnable implements Listener {
Player player = Bukkit.getPlayer(hook.getPlayerUUID()); Player player = Bukkit.getPlayer(hook.getPlayerUUID());
if (player == null) { if (player == null) {
hooksToRemove.remove(hook); hooksToRemove.remove(hook);
} else {
if (NMSUtil.getVersionNumber() == 9) {
if (hook.getMaxHookLength() == hook.getTimeRemaining())
player.sendMessage(LangManager.getText(Lang.GUI_SAVE_GROUP_HOTBAR_MESSAGE, hook.getTimeRemaining()));
} else { } else {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(LangManager.getText(Lang.GUI_SAVE_GROUP_HOTBAR_MESSAGE, hook.getTimeRemaining()))); player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(LangManager.getText(Lang.GUI_SAVE_GROUP_HOTBAR_MESSAGE, hook.getTimeRemaining())));
} }
} }
}
for (PlayerChatHookData hookToRemove : hooksToRemove) for (PlayerChatHookData hookToRemove : hooksToRemove)
hooks.remove(hookToRemove); hooks.remove(hookToRemove);
@ -84,7 +89,7 @@ public class PlayerChatHook extends BukkitRunnable implements Listener {
*/ */
public static void addHook(PlayerChatHookData newHook) { public static void addHook(PlayerChatHookData newHook) {
for (PlayerChatHookData hook : hooks) { for (PlayerChatHookData hook : hooks) {
if (hook.getPlayerUUID().equals(hook.getPlayerUUID())) { if (hook.getPlayerUUID().equals(newHook.getPlayerUUID())) {
hooks.remove(hook); hooks.remove(hook);
break; break;
} }

View file

@ -5,11 +5,13 @@ import java.util.UUID;
public class PlayerChatHookData { public class PlayerChatHookData {
private UUID playerUUID; private UUID playerUUID;
private int maxHookLength;
private int hookLength; private int hookLength;
private PlayerChatHookCallback hookCallback; private PlayerChatHookCallback hookCallback;
public PlayerChatHookData(UUID playerUUID, int hookLength, PlayerChatHookCallback hookCallback) { public PlayerChatHookData(UUID playerUUID, int hookLength, PlayerChatHookCallback hookCallback) {
this.playerUUID = playerUUID; this.playerUUID = playerUUID;
this.maxHookLength = hookLength;
this.hookLength = hookLength; this.hookLength = hookLength;
this.hookCallback = hookCallback; this.hookCallback = hookCallback;
} }
@ -39,6 +41,15 @@ public class PlayerChatHookData {
return this.hookLength <= 0; return this.hookLength <= 0;
} }
/**
* Gets the max length of the hook
*
* @return The max length of the hook
*/
public int getMaxHookLength() {
return this.maxHookLength;
}
/** /**
* Gets how much time is remaining on the hook * Gets how much time is remaining on the hook
* *
@ -61,8 +72,8 @@ public class PlayerChatHookData {
* Allows simple hooking into the player chat for a specific time interval * Allows simple hooking into the player chat for a specific time interval
*/ */
@FunctionalInterface @FunctionalInterface
public static interface PlayerChatHookCallback { public interface PlayerChatHookCallback {
public void onPlayerChat(String textEntered); void onPlayerChat(String textEntered);
} }
} }

View file

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -105,8 +106,8 @@ public class DataManager {
int id = result.getInt("id"); int id = result.getInt("id");
ParticleEffect effect = ParticleEffect.fromName(result.getString("effect")); ParticleEffect effect = ParticleEffect.fromName(result.getString("effect"));
ParticleStyle style = ParticleStyle.fromName(result.getString("style")); ParticleStyle style = ParticleStyle.fromName(result.getString("style"));
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("item_material")); Material itemMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("item_material"));
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("block_material")); Material blockMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("block_material"));
NoteColor noteColor = new NoteColor(result.getInt("note")); NoteColor noteColor = new NoteColor(result.getInt("note"));
OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b")); OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b"));
ParticlePair particle = new ParticlePair(playerUUID, id, effect, style, itemMaterial, blockMaterial, color, noteColor); ParticlePair particle = new ParticlePair(playerUUID, id, effect, style, itemMaterial, blockMaterial, color, noteColor);
@ -123,7 +124,7 @@ public class DataManager {
// Add the particle to a new group if one didn't already exist // Add the particle to a new group if one didn't already exist
if (!groupAlreadyExists) { if (!groupAlreadyExists) {
List<ParticlePair> particles = new ArrayList<ParticlePair>(); List<ParticlePair> particles = new ArrayList<>();
particles.add(particle); particles.add(particle);
ParticleGroup newGroup = new ParticleGroup(groupName, particles); ParticleGroup newGroup = new ParticleGroup(groupName, particles);
groups.add(newGroup); groups.add(newGroup);
@ -151,8 +152,8 @@ public class DataManager {
int particleId = result.getInt("p_id"); int particleId = result.getInt("p_id");
ParticleEffect effect = ParticleEffect.fromName(result.getString("effect")); ParticleEffect effect = ParticleEffect.fromName(result.getString("effect"));
ParticleStyle style = ParticleStyle.fromName(result.getString("style")); ParticleStyle style = ParticleStyle.fromName(result.getString("style"));
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("item_material")); Material itemMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("item_material"));
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("block_material")); Material blockMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("block_material"));
NoteColor noteColor = new NoteColor(result.getInt("note")); NoteColor noteColor = new NoteColor(result.getInt("note"));
OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b")); OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b"));
ParticlePair particle = new ParticlePair(playerUUID, particleId, effect, style, itemMaterial, blockMaterial, color, noteColor); ParticlePair particle = new ParticlePair(playerUUID, particleId, effect, style, itemMaterial, blockMaterial, color, noteColor);
@ -171,7 +172,7 @@ public class DataManager {
} }
if (!activeGroupExists) { if (!activeGroupExists) {
ParticleGroup activeGroup = new ParticleGroup(ParticleGroup.DEFAULT_NAME, new ArrayList<ParticlePair>()); ParticleGroup activeGroup = new ParticleGroup(ParticleGroup.DEFAULT_NAME, new ArrayList<>());
saveParticleGroup(playerUUID, activeGroup); saveParticleGroup(playerUUID, activeGroup);
groups.add(activeGroup); groups.add(activeGroup);
} }
@ -194,20 +195,16 @@ public class DataManager {
* Loads all PPlayers from the database that own FixedParticleEffects * Loads all PPlayers from the database that own FixedParticleEffects
*/ */
public static void loadFixedEffects() { public static void loadFixedEffects() {
async(() -> { async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
String query = "SELECT DISTINCT owner_uuid FROM pp_fixed"; String query = "SELECT DISTINCT owner_uuid FROM pp_fixed";
try (PreparedStatement statement = connection.prepareStatement(query)) { try (PreparedStatement statement = connection.prepareStatement(query)) {
ResultSet result = statement.executeQuery(); ResultSet result = statement.executeQuery();
while (result.next()) { while (result.next()) {
UUID playerUUID = UUID.fromString(result.getString("owner_uuid")); UUID playerUUID = UUID.fromString(result.getString("owner_uuid"));
sync(() -> { sync(() -> getPPlayer(playerUUID, (pplayer) -> { }));
getPPlayer(playerUUID, (pplayer) -> { });
});
} }
} }
}); }));
});
} }
/** /**
@ -217,8 +214,7 @@ public class DataManager {
* @param particlesHidden True if the particles should be hidden, otherwise False * @param particlesHidden True if the particles should be hidden, otherwise False
*/ */
public static void updateSettingParticlesHidden(UUID playerUUID, boolean particlesHidden) { public static void updateSettingParticlesHidden(UUID playerUUID, boolean particlesHidden) {
async(() -> { async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
String updateQuery = "UPDATE pp_settings SET particles_hidden = ? WHERE player_uuid = ?"; String updateQuery = "UPDATE pp_settings SET particles_hidden = ? WHERE player_uuid = ?";
try (PreparedStatement updateStatement = connection.prepareStatement(updateQuery)) { try (PreparedStatement updateStatement = connection.prepareStatement(updateQuery)) {
updateStatement.setBoolean(1, particlesHidden); updateStatement.setBoolean(1, particlesHidden);
@ -226,12 +222,9 @@ public class DataManager {
updateStatement.executeUpdate(); updateStatement.executeUpdate();
} }
}); }));
});
getPPlayer(playerUUID, (pplayer) -> { getPPlayer(playerUUID, (pplayer) -> pplayer.setParticlesHidden(particlesHidden));
pplayer.setParticlesHidden(particlesHidden);
});
} }
/** /**
@ -241,9 +234,8 @@ public class DataManager {
* @param group The group to create/update * @param group The group to create/update
*/ */
public static void saveParticleGroup(UUID playerUUID, ParticleGroup group) { public static void saveParticleGroup(UUID playerUUID, ParticleGroup group) {
async(() -> { async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> { String groupUUID;
String groupUUID = null;
String groupUUIDQuery = "SELECT uuid FROM pp_group WHERE owner_uuid = ? AND name = ?"; String groupUUIDQuery = "SELECT uuid FROM pp_group WHERE owner_uuid = ? AND name = ?";
try (PreparedStatement statement = connection.prepareStatement(groupUUIDQuery)) { try (PreparedStatement statement = connection.prepareStatement(groupUUIDQuery)) {
@ -292,8 +284,7 @@ public class DataManager {
particlesStatement.executeBatch(); particlesStatement.executeBatch();
} }
}); }));
});
getPPlayer(playerUUID, (pplayer) -> { getPPlayer(playerUUID, (pplayer) -> {
for (ParticleGroup existing : pplayer.getParticleGroups()) { for (ParticleGroup existing : pplayer.getParticleGroups()) {
@ -313,8 +304,7 @@ public class DataManager {
* @param group The group to remove * @param group The group to remove
*/ */
public static void removeParticleGroup(UUID playerUUID, ParticleGroup group) { public static void removeParticleGroup(UUID playerUUID, ParticleGroup group) {
async(() -> { async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
String groupQuery = "SELECT * FROM pp_group WHERE owner_uuid = ? AND name = ?"; String groupQuery = "SELECT * FROM pp_group WHERE owner_uuid = ? AND name = ?";
String particleDeleteQuery = "DELETE FROM pp_particle WHERE group_uuid = ?"; String particleDeleteQuery = "DELETE FROM pp_particle WHERE group_uuid = ?";
String groupDeleteQuery = "DELETE FROM pp_group WHERE uuid = ?"; String groupDeleteQuery = "DELETE FROM pp_group WHERE uuid = ?";
@ -344,12 +334,9 @@ public class DataManager {
statement.executeUpdate(); statement.executeUpdate();
} }
}); }));
});
getPPlayer(playerUUID, (pplayer) -> { getPPlayer(playerUUID, (pplayer) -> pplayer.getParticleGroups().remove(group));
pplayer.getParticleGroups().remove(group);
});
} }
/** /**
@ -359,8 +346,7 @@ public class DataManager {
* @param fixedEffect The fixed effect to save * @param fixedEffect The fixed effect to save
*/ */
public static void saveFixedEffect(FixedParticleEffect fixedEffect) { public static void saveFixedEffect(FixedParticleEffect fixedEffect) {
async(() -> { async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
String particleUUID = UUID.randomUUID().toString(); 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 pp_particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
@ -391,12 +377,9 @@ public class DataManager {
statement.setDouble(7, fixedEffect.getLocation().getZ()); statement.setDouble(7, fixedEffect.getLocation().getZ());
statement.executeUpdate(); statement.executeUpdate();
} }
}); }));
});
getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> { getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> pplayer.addFixedEffect(fixedEffect));
pplayer.addFixedEffect(fixedEffect);
});
} }
/** /**
@ -405,8 +388,7 @@ public class DataManager {
* @param fixedEffect The fixed effect to update * @param fixedEffect The fixed effect to update
*/ */
public static void updateFixedEffect(FixedParticleEffect fixedEffect) { public static void updateFixedEffect(FixedParticleEffect fixedEffect) {
async(() -> { async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
// Update fixed effect // Update fixed effect
String fixedEffectQuery = "UPDATE pp_fixed SET xPos = ?, yPos = ?, zPos = ? WHERE owner_uuid = ? AND id = ?"; String fixedEffectQuery = "UPDATE pp_fixed SET xPos = ?, yPos = ?, zPos = ? WHERE owner_uuid = ? AND id = ?";
try (PreparedStatement statement = connection.prepareStatement(fixedEffectQuery)) { try (PreparedStatement statement = connection.prepareStatement(fixedEffectQuery)) {
@ -436,8 +418,7 @@ public class DataManager {
statement.setInt(10, fixedEffect.getId()); statement.setInt(10, fixedEffect.getId());
statement.executeUpdate(); statement.executeUpdate();
} }
}); }));
});
getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> { getPPlayer(fixedEffect.getOwnerUniqueId(), (pplayer) -> {
pplayer.removeFixedEffect(fixedEffect.getId()); pplayer.removeFixedEffect(fixedEffect.getId());
@ -453,8 +434,7 @@ public class DataManager {
* @param id The id of the effect to remove * @param id The id of the effect to remove
*/ */
public static void removeFixedEffect(UUID playerUUID, int id) { public static void removeFixedEffect(UUID playerUUID, int id) {
async(() -> { async(() -> PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
String particleUUID = null; String particleUUID = null;
String particleUUIDQuery = "SELECT particle_uuid FROM pp_fixed WHERE owner_uuid = ? AND id = ?"; String particleUUIDQuery = "SELECT particle_uuid FROM pp_fixed WHERE owner_uuid = ? AND id = ?";
@ -482,12 +462,9 @@ public class DataManager {
statement.executeUpdate(); statement.executeUpdate();
} }
}); }));
});
getPPlayer(playerUUID, (pplayer) -> { getPPlayer(playerUUID, (pplayer) -> pplayer.removeFixedEffect(id));
pplayer.removeFixedEffect(id);
});
} }
/** /**
@ -520,16 +497,16 @@ public class DataManager {
* Provides an easy way to run a section of code either synchronously or asynchronously using a callback * Provides an easy way to run a section of code either synchronously or asynchronously using a callback
*/ */
@FunctionalInterface @FunctionalInterface
private static interface SyncInterface { private interface SyncInterface {
public void execute(); void execute();
} }
/** /**
* Allows callbacks to be passed between configuration methods and executed for returning objects after database queries * Allows callbacks to be passed between configuration methods and executed for returning objects after database queries
*/ */
@FunctionalInterface @FunctionalInterface
public static interface ConfigurationCallback<T> { public interface ConfigurationCallback<T> {
public void execute(T obj); void execute(T obj);
} }
} }

View file

@ -22,7 +22,7 @@ public class LangManager {
/** /**
* Contains the location in the .lang file of every chat message * Contains the location in the .lang file of every chat message
*/ */
public static enum Lang { // @formatter:off public enum Lang { // @formatter:off
// Command Errors // Command Errors
COMMAND_ERROR_NO_EFFECTS, COMMAND_ERROR_NO_EFFECTS,
@ -92,6 +92,7 @@ public class LangManager {
// Group Command // Group Command
GROUP_INVALID, GROUP_INVALID,
GROUP_NO_PERMISSION,
GROUP_PRESET_NO_PERMISSION, GROUP_PRESET_NO_PERMISSION,
GROUP_RESERVED, GROUP_RESERVED,
GROUP_NO_NAME, GROUP_NO_NAME,
@ -231,6 +232,8 @@ public class LangManager {
GUI_COLOR_UNAVAILABLE, GUI_COLOR_UNAVAILABLE,
GUI_COMMANDS_INFO, GUI_COMMANDS_INFO,
GUI_BACK_BUTTON, GUI_BACK_BUTTON,
GUI_NEXT_PAGE_BUTTON,
GUI_PREVIOUS_PAGE_BUTTON,
GUI_CLICK_TO_LOAD, GUI_CLICK_TO_LOAD,
GUI_SHIFT_CLICK_TO_DELETE, GUI_SHIFT_CLICK_TO_DELETE,
GUI_PARTICLE_INFO, GUI_PARTICLE_INFO,
@ -281,10 +284,6 @@ public class LangManager {
GUI_SELECT_DATA, GUI_SELECT_DATA,
GUI_SELECT_DATA_DESCRIPTION, GUI_SELECT_DATA_DESCRIPTION,
GUI_SELECT_DATA_NOTE, GUI_SELECT_DATA_NOTE,
GUI_SELECT_DATA_RANDOMIZE_ITEMS,
GUI_SELECT_DATA_RANDOMIZE_ITEMS_DESCRIPTION,
GUI_SELECT_DATA_RANDOMIZE_BLOCKS,
GUI_SELECT_DATA_RANDOMIZE_BLOCKS_DESCRIPTION,
GUI_EDIT_DATA_COLOR_RED, GUI_EDIT_DATA_COLOR_RED,
GUI_EDIT_DATA_COLOR_ORANGE, GUI_EDIT_DATA_COLOR_ORANGE,
GUI_EDIT_DATA_COLOR_YELLOW, GUI_EDIT_DATA_COLOR_YELLOW,
@ -375,7 +374,7 @@ public class LangManager {
File targetLangFile = new File(pluginDataFolder.getAbsolutePath() + "/lang/" + langFileName); File targetLangFile = new File(pluginDataFolder.getAbsolutePath() + "/lang/" + langFileName);
// TODO: Move this somewhere else // TODO: Move this somewhere else
Set<String> defaultLangFileNames = new HashSet<String>(); Set<String> defaultLangFileNames = new HashSet<>();
defaultLangFileNames.add("en_US.lang"); defaultLangFileNames.add("en_US.lang");
defaultLangFileNames.add("fr_FR.lang"); defaultLangFileNames.add("fr_FR.lang");
defaultLangFileNames.add("vi_VN.lang"); defaultLangFileNames.add("vi_VN.lang");

View file

@ -42,7 +42,7 @@ public class ParticleGroupPresetManager {
* Loads the preset groups from the preset_groups.yml file * Loads the preset groups from the preset_groups.yml file
*/ */
public static void reload() { public static void reload() {
presetGroups = new ArrayList<ParticleGroupPreset>(); presetGroups = new ArrayList<>();
File pluginDataFolder = PlayerParticles.getPlugin().getDataFolder(); File pluginDataFolder = PlayerParticles.getPlugin().getDataFolder();
File groupsFile = new File(pluginDataFolder.getAbsolutePath() + File.separator + FILE_NAME); File groupsFile = new File(pluginDataFolder.getAbsolutePath() + File.separator + FILE_NAME);
@ -61,7 +61,7 @@ public class ParticleGroupPresetManager {
Set<String> groupNames = groupsYaml.getKeys(false); Set<String> groupNames = groupsYaml.getKeys(false);
for (String groupName : groupNames) { for (String groupName : groupNames) {
try { try {
List<ParticlePair> particles = new ArrayList<ParticlePair>(); List<ParticlePair> particles = new ArrayList<>();
String displayName = ""; String displayName = "";
Material guiIcon = Material.ENDER_CHEST; Material guiIcon = Material.ENDER_CHEST;
String permission = ""; String permission = "";
@ -120,7 +120,7 @@ public class ParticleGroupPresetManager {
if (args[0].equalsIgnoreCase("rainbow")) { if (args[0].equalsIgnoreCase("rainbow")) {
noteColorData = new NoteColor(99); noteColorData = new NoteColor(99);
} else { } else {
int note = -1; int note;
try { try {
note = Integer.parseInt(args[0]); note = Integer.parseInt(args[0]);
} catch (Exception e) { } catch (Exception e) {
@ -139,9 +139,7 @@ public class ParticleGroupPresetManager {
if (args[0].equalsIgnoreCase("rainbow")) { if (args[0].equalsIgnoreCase("rainbow")) {
colorData = new OrdinaryColor(999, 999, 999); colorData = new OrdinaryColor(999, 999, 999);
} else { } else {
int r = -1; int r, g, b;
int g = -1;
int b = -1;
try { try {
r = Integer.parseInt(args[0]); r = Integer.parseInt(args[0]);
@ -181,7 +179,7 @@ public class ParticleGroupPresetManager {
} }
} }
particles.add(new ParticlePair(null, id, effect, style, blockData, blockData, colorData, noteColorData)); particles.add(new ParticlePair(null, id, effect, style, itemData, blockData, colorData, noteColorData));
} }
presetGroups.add(new ParticleGroupPreset(displayName, guiIcon, permission, allowPermissionOverride, new ParticleGroup(groupName, particles))); presetGroups.add(new ParticleGroupPreset(displayName, guiIcon, permission, allowPermissionOverride, new ParticleGroup(groupName, particles)));

View file

@ -32,7 +32,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
/** /**
* The list containing all the loaded PPlayer info * The list containing all the loaded PPlayer info
*/ */
private static List<PPlayer> particlePlayers = new ArrayList<PPlayer>(); private static List<PPlayer> particlePlayers = new ArrayList<>();
/** /**
* Rainbow particle effect hue and note color used for rainbow colorable effects * Rainbow particle effect hue and note color used for rainbow colorable effects
@ -106,15 +106,15 @@ public class ParticleManager extends BukkitRunnable implements Listener {
// Don't show their particles if they are in spectator mode // Don't show their particles if they are in spectator mode
// Don't spawn particles if the world doesn't allow it // Don't spawn particles if the world doesn't allow it
if (player != null && player.getGameMode() != GameMode.SPECTATOR && !PermissionManager.isWorldDisabled(player.getWorld().getName())) if (player != null && player.getGameMode() != GameMode.SPECTATOR && PermissionManager.isWorldEnabled(player.getWorld().getName()))
for (ParticlePair particles : pplayer.getActiveParticles()) for (ParticlePair particles : pplayer.getActiveParticles())
displayParticles(pplayer, particles, player.getLocation().clone().add(0, 1, 0)); this.displayParticles(pplayer, particles, player.getLocation().clone().add(0, 1, 0));
// Loop for FixedParticleEffects // Loop for FixedParticleEffects
// Don't spawn particles if the world doesn't allow it // Don't spawn particles if the world doesn't allow it
for (FixedParticleEffect effect : pplayer.getFixedParticles()) for (FixedParticleEffect effect : pplayer.getFixedParticles())
if (!PermissionManager.isWorldDisabled(effect.getLocation().getWorld().getName())) if (PermissionManager.isWorldEnabled(effect.getLocation().getWorld().getName()))
displayFixedParticleEffect(effect); this.displayFixedParticleEffect(effect);
} }
} }
@ -129,10 +129,10 @@ public class ParticleManager extends BukkitRunnable implements Listener {
if (!ParticleStyleManager.isCustomHandled(particle.getStyle())) { if (!ParticleStyleManager.isCustomHandled(particle.getStyle())) {
if (PSetting.TOGGLE_ON_MOVE.getBoolean() && particle.getStyle().canToggleWithMovement() && pplayer.isMoving()) { if (PSetting.TOGGLE_ON_MOVE.getBoolean() && particle.getStyle().canToggleWithMovement() && pplayer.isMoving()) {
for (PParticle pparticle : DefaultStyles.FEET.getParticles(particle, location)) for (PParticle pparticle : DefaultStyles.FEET.getParticles(particle, location))
ParticleEffect.display(particle, pparticle, false); ParticleEffect.display(particle, pparticle, false, pplayer.getPlayer());
} else { } else {
for (PParticle pparticle : particle.getStyle().getParticles(particle, location)) for (PParticle pparticle : particle.getStyle().getParticles(particle, location))
ParticleEffect.display(particle, pparticle, false); ParticleEffect.display(particle, pparticle, false, pplayer.getPlayer());
} }
} }
} }
@ -145,7 +145,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*/ */
public static void displayParticles(ParticlePair particle, List<PParticle> particles) { public static void displayParticles(ParticlePair particle, List<PParticle> particles) {
for (PParticle pparticle : particles) for (PParticle pparticle : particles)
ParticleEffect.display(particle, pparticle, false); ParticleEffect.display(particle, pparticle, false, Bukkit.getPlayer(particle.getOwnerUniqueId()));
} }
/** /**
@ -156,7 +156,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
private void displayFixedParticleEffect(FixedParticleEffect fixedEffect) { private void displayFixedParticleEffect(FixedParticleEffect fixedEffect) {
ParticlePair particle = fixedEffect.getParticlePair(); ParticlePair particle = fixedEffect.getParticlePair();
for (PParticle pparticle : particle.getStyle().getParticles(particle, fixedEffect.getLocation().clone().add(0, particle.getStyle().getFixedEffectOffset(), 0))) for (PParticle pparticle : particle.getStyle().getParticles(particle, fixedEffect.getLocation().clone().add(0, particle.getStyle().getFixedEffectOffset(), 0)))
ParticleEffect.display(particle, pparticle, true); ParticleEffect.display(particle, pparticle, true, null);
} }
/** /**

View file

@ -37,7 +37,7 @@ public class PermissionManager {
private final String permissionString; private final String permissionString;
private PPermission(String permissionString) { PPermission(String permissionString) {
this.permissionString = permissionString; this.permissionString = permissionString;
} }
@ -149,13 +149,13 @@ public class PermissionManager {
} }
/** /**
* Checks if a world is disabled for particles to spawn in * Checks if a world is enabled for particles to spawn in
* *
* @param world The world name to check * @param world The world name to check
* @return True if the world is disabled * @return True if the world is disabled
*/ */
public static boolean isWorldDisabled(String world) { public static boolean isWorldEnabled(String world) {
return getDisabledWorlds().contains(world); return !getDisabledWorlds().contains(world);
} }
/** /**
@ -200,7 +200,7 @@ public class PermissionManager {
* @return A String List of all effect names the given player has permission for * @return A String List of all effect names the given player has permission for
*/ */
public static List<String> getEffectNamesUserHasPermissionFor(Player p) { public static List<String> getEffectNamesUserHasPermissionFor(Player p) {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<>();
for (ParticleEffect pe : ParticleEffect.getSupportedEffects()) for (ParticleEffect pe : ParticleEffect.getSupportedEffects())
if (hasEffectPermission(p, pe)) if (hasEffectPermission(p, pe))
list.add(pe.getName()); list.add(pe.getName());
@ -214,7 +214,7 @@ public class PermissionManager {
* @return A String List of all style names the given player has permission for * @return A String List of all style names the given player has permission for
*/ */
public static List<String> getStyleNamesUserHasPermissionFor(Player p) { public static List<String> getStyleNamesUserHasPermissionFor(Player p) {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<>();
for (ParticleStyle ps : ParticleStyleManager.getStyles()) for (ParticleStyle ps : ParticleStyleManager.getStyles())
if (hasStylePermission(p, ps)) if (hasStylePermission(p, ps))
list.add(ps.getName()); list.add(ps.getName());
@ -228,7 +228,7 @@ public class PermissionManager {
* @return A String List of all fixable style names the given player has permission for * @return A String List of all fixable style names the given player has permission for
*/ */
public static List<String> getFixableStyleNamesUserHasPermissionFor(Player p) { public static List<String> getFixableStyleNamesUserHasPermissionFor(Player p) {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<>();
for (ParticleStyle ps : ParticleStyleManager.getStyles()) for (ParticleStyle ps : ParticleStyleManager.getStyles())
if (ps.canBeFixed() && hasStylePermission(p, ps)) if (ps.canBeFixed() && hasStylePermission(p, ps))
list.add(ps.getName()); list.add(ps.getName());
@ -242,7 +242,7 @@ public class PermissionManager {
* @return A List of all effects the given player has permission for * @return A List of all effects the given player has permission for
*/ */
public static List<ParticleEffect> getEffectsUserHasPermissionFor(Player p) { public static List<ParticleEffect> getEffectsUserHasPermissionFor(Player p) {
List<ParticleEffect> list = new ArrayList<ParticleEffect>(); List<ParticleEffect> list = new ArrayList<>();
for (ParticleEffect pe : ParticleEffect.getSupportedEffects()) for (ParticleEffect pe : ParticleEffect.getSupportedEffects())
if (hasEffectPermission(p, pe)) if (hasEffectPermission(p, pe))
list.add(pe); list.add(pe);
@ -256,7 +256,7 @@ public class PermissionManager {
* @return A List of all styles the given player has permission for * @return A List of all styles the given player has permission for
*/ */
public static List<ParticleStyle> getStylesUserHasPermissionFor(Player p) { public static List<ParticleStyle> getStylesUserHasPermissionFor(Player p) {
List<ParticleStyle> list = new ArrayList<ParticleStyle>(); List<ParticleStyle> list = new ArrayList<>();
for (ParticleStyle ps : ParticleStyleManager.getStyles()) for (ParticleStyle ps : ParticleStyleManager.getStyles())
if (hasStylePermission(p, ps)) if (hasStylePermission(p, ps))
list.add(ps); list.add(ps);

View file

@ -32,7 +32,10 @@ public class SettingManager {
TICKS_PER_PARTICLE(PSettingType.LONG), TICKS_PER_PARTICLE(PSettingType.LONG),
CHECK_UPDATES(PSettingType.BOOLEAN), CHECK_UPDATES(PSettingType.BOOLEAN),
SEND_METRICS(PSettingType.BOOLEAN), SEND_METRICS(PSettingType.BOOLEAN),
GUI_ENABLED(PSettingType.BOOLEAN), GUI_ENABLED(PSettingType.BOOLEAN),
GUI_PRESETS_ONLY(PSettingType.BOOLEAN),
GUI_CLOSE_AFTER_GROUP_SELECTED(PSettingType.BOOLEAN),
GUI_BUTTON_SOUND(PSettingType.BOOLEAN), GUI_BUTTON_SOUND(PSettingType.BOOLEAN),
TOGGLE_ON_MOVE(PSettingType.BOOLEAN), TOGGLE_ON_MOVE(PSettingType.BOOLEAN),
@ -51,6 +54,7 @@ public class SettingManager {
DATABASE_NAME(PSettingType.STRING), DATABASE_NAME(PSettingType.STRING),
DATABASE_USER_NAME(PSettingType.STRING), DATABASE_USER_NAME(PSettingType.STRING),
DATABASE_USER_PASSWORD(PSettingType.STRING), DATABASE_USER_PASSWORD(PSettingType.STRING),
DATABASE_USE_SSL(PSettingType.BOOLEAN),
MAX_FIXED_EFFECTS(PSettingType.INTEGER), MAX_FIXED_EFFECTS(PSettingType.INTEGER),
MAX_FIXED_EFFECT_CREATION_DISTANCE(PSettingType.INTEGER), MAX_FIXED_EFFECT_CREATION_DISTANCE(PSettingType.INTEGER),
@ -68,7 +72,7 @@ public class SettingManager {
private final PSettingType settingType; private final PSettingType settingType;
private Object value = null; private Object value = null;
private PSetting(PSettingType settingType) { PSetting(PSettingType settingType) {
this.settingType = settingType; this.settingType = settingType;
} }
@ -184,11 +188,12 @@ public class SettingManager {
GROUPS, GROUPS,
PRESET_GROUPS, PRESET_GROUPS,
BACK, BACK,
NEXT_PAGE,
PREVIOUS_PAGE,
CREATE, CREATE,
EDIT_EFFECT, EDIT_EFFECT,
EDIT_STYLE, EDIT_STYLE,
EDIT_DATA, EDIT_DATA,
RANDOMIZE,
RESET, RESET,
EFFECT, EFFECT,
@ -196,8 +201,8 @@ public class SettingManager {
private Map<String, Material> materials; private Map<String, Material> materials;
private GuiIcon() { GuiIcon() {
this.materials = new HashMap<String, Material>(); this.materials = new HashMap<>();
} }
/** /**
@ -261,7 +266,7 @@ public class SettingManager {
* Resets the setting's value so it will be fetched from the config the next time it's needed * Resets the setting's value so it will be fetched from the config the next time it's needed
*/ */
private void resetDefault() { private void resetDefault() {
this.materials = new HashMap<String, Material>(); this.materials = new HashMap<>();
} }
} }

View file

@ -168,7 +168,7 @@ public class PPlayer {
* @return A List of ParticlePairs with a matching style * @return A List of ParticlePairs with a matching style
*/ */
public List<ParticlePair> getActiveParticlesForStyle(ParticleStyle style) { public List<ParticlePair> getActiveParticlesForStyle(ParticleStyle style) {
List<ParticlePair> matches = new ArrayList<ParticlePair>(); List<ParticlePair> matches = new ArrayList<>();
for (ParticlePair pair : this.getActiveParticles()) for (ParticlePair pair : this.getActiveParticles())
if (pair.getStyle().equals(style)) if (pair.getStyle().equals(style))
matches.add(pair); matches.add(pair);
@ -216,7 +216,7 @@ public class PPlayer {
* @return A List of Integer ids this player's fixed effects have * @return A List of Integer ids this player's fixed effects have
*/ */
public List<Integer> getFixedEffectIds() { public List<Integer> getFixedEffectIds() {
List<Integer> ids = new ArrayList<Integer>(); List<Integer> ids = new ArrayList<>();
for (FixedParticleEffect fixedEffect : this.fixedParticles) for (FixedParticleEffect fixedEffect : this.fixedParticles)
ids.add(fixedEffect.getId()); ids.add(fixedEffect.getId());
return ids; return ids;

View file

@ -6,11 +6,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scheduler.BukkitRunnable;
import com.esophose.playerparticles.PlayerParticles; import com.esophose.playerparticles.PlayerParticles;
import com.esophose.playerparticles.manager.DataManager; import com.esophose.playerparticles.manager.DataManager;
@ -19,31 +19,29 @@ import com.esophose.playerparticles.manager.SettingManager.PSetting;
public class PPlayerMovementListener implements Listener { public class PPlayerMovementListener implements Listener {
private static final int CHECK_INTERVAL = 3; private static final int CHECK_INTERVAL = 3;
private Map<UUID, Integer> timeSinceLastMovement = new HashMap<UUID, Integer>(); private Map<UUID, Integer> timeSinceLastMovement = new HashMap<>();
public PPlayerMovementListener() { public PPlayerMovementListener() {
new BukkitRunnable() { Bukkit.getScheduler().runTaskTimer(PlayerParticles.getPlugin(), () -> {
public void run() {
if (!PSetting.TOGGLE_ON_MOVE.getBoolean()) return; if (!PSetting.TOGGLE_ON_MOVE.getBoolean()) return;
List<UUID> toRemove = new ArrayList<UUID>(); List<UUID> toRemove = new ArrayList<>();
for (UUID uuid : timeSinceLastMovement.keySet()) { for (UUID uuid : this.timeSinceLastMovement.keySet()) {
PPlayer pplayer = DataManager.getPPlayer(uuid); PPlayer pplayer = DataManager.getPPlayer(uuid);
if (pplayer == null) { if (pplayer == null) {
toRemove.add(uuid); toRemove.add(uuid);
} else { } else {
int standingTime = timeSinceLastMovement.get(uuid); int standingTime = this.timeSinceLastMovement.get(uuid);
pplayer.setMoving(standingTime < PSetting.TOGGLE_ON_MOVE_DELAY.getInt()); pplayer.setMoving(standingTime < PSetting.TOGGLE_ON_MOVE_DELAY.getInt());
if (standingTime < PSetting.TOGGLE_ON_MOVE_DELAY.getInt()) if (standingTime < PSetting.TOGGLE_ON_MOVE_DELAY.getInt())
timeSinceLastMovement.replace(uuid, standingTime + CHECK_INTERVAL); this.timeSinceLastMovement.replace(uuid, standingTime + CHECK_INTERVAL);
} }
} }
for (UUID uuid : toRemove) for (UUID uuid : toRemove)
timeSinceLastMovement.remove(uuid); this.timeSinceLastMovement.remove(uuid);
} }, 0, CHECK_INTERVAL);
}.runTaskTimer(PlayerParticles.getPlugin(), 0, CHECK_INTERVAL);
} }
/** /**
@ -57,10 +55,10 @@ public class PPlayerMovementListener implements Listener {
if (event.getTo().getBlockX() == event.getFrom().getBlockX() && event.getTo().getBlockY() == event.getFrom().getBlockY() && event.getTo().getBlockZ() == event.getFrom().getBlockZ()) return; if (event.getTo().getBlockX() == event.getFrom().getBlockX() && event.getTo().getBlockY() == event.getFrom().getBlockY() && event.getTo().getBlockZ() == event.getFrom().getBlockZ()) return;
UUID playerUUID = event.getPlayer().getUniqueId(); UUID playerUUID = event.getPlayer().getUniqueId();
if (!timeSinceLastMovement.containsKey(playerUUID)) { if (!this.timeSinceLastMovement.containsKey(playerUUID)) {
timeSinceLastMovement.put(playerUUID, 0); this.timeSinceLastMovement.put(playerUUID, 0);
} else { } else {
timeSinceLastMovement.replace(playerUUID, 0); this.timeSinceLastMovement.replace(playerUUID, 0);
} }
} }

View file

@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.esophose.playerparticles.util.NMSUtil;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -32,7 +33,10 @@ public enum ParticleEffect {
BUBBLE("WATER_BUBBLE", "WATER_BUBBLE"), BUBBLE("WATER_BUBBLE", "WATER_BUBBLE"),
BUBBLE_COLUMN_UP("BUBBLE_COLUMN_UP", null), BUBBLE_COLUMN_UP("BUBBLE_COLUMN_UP", null),
BUBBLE_POP("BUBBLE_POP", null), BUBBLE_POP("BUBBLE_POP", null),
CAMPFIRE_COSY_SMOKE("CAMPFIRE_COSY_SMOKE", null),
CAMPFIRE_SIGNAL_SMOKE("CAMPFIRE_SIGNAL_SMOKE", null),
CLOUD("CLOUD", "CLOUD"), CLOUD("CLOUD", "CLOUD"),
COMPOSTER("COMPOSTER", null),
CRIT("CRIT", "CRIT"), CRIT("CRIT", "CRIT"),
CURRENT_DOWN("CURRENT_DOWN", null), CURRENT_DOWN("CURRENT_DOWN", null),
DAMAGE_INDICATOR("DAMAGE_INDICATOR", "DAMAGE_INDICATOR"), DAMAGE_INDICATOR("DAMAGE_INDICATOR", "DAMAGE_INDICATOR"),
@ -49,9 +53,12 @@ public enum ParticleEffect {
EXPLOSION("EXPLOSION_LARGE", "EXPLOSION_LARGE"), EXPLOSION("EXPLOSION_LARGE", "EXPLOSION_LARGE"),
EXPLOSION_EMITTER("EXPLOSION_HUGE", "EXPLOSION_HUGE"), EXPLOSION_EMITTER("EXPLOSION_HUGE", "EXPLOSION_HUGE"),
FALLING_DUST("FALLING_DUST", "FALLING_DUST", ParticleProperty.REQUIRES_MATERIAL_DATA), FALLING_DUST("FALLING_DUST", "FALLING_DUST", ParticleProperty.REQUIRES_MATERIAL_DATA),
FALLING_LAVA("FALLING_LAVA", null),
FALLING_WATER("FALLING_WATER", null),
FIREWORK("FIREWORKS_SPARK", "FIREWORKS_SPARK"), FIREWORK("FIREWORKS_SPARK", "FIREWORKS_SPARK"),
FISHING("WATER_WAKE", "WATER_WAKE"), FISHING("WATER_WAKE", "WATER_WAKE"),
FLAME("FLAME", "FLAME"), FLAME("FLAME", "FLAME"),
// FLASH("FLASH", null), // Also no thank you
FOOTSTEP(null, "FOOTSTEP"), // Removed in Minecraft 1.13 :( FOOTSTEP(null, "FOOTSTEP"), // Removed in Minecraft 1.13 :(
HAPPY_VILLAGER("VILLAGER_HAPPY", "VILLAGER_HAPPY"), HAPPY_VILLAGER("VILLAGER_HAPPY", "VILLAGER_HAPPY"),
HEART("HEART", "HEART"), HEART("HEART", "HEART"),
@ -59,6 +66,7 @@ public enum ParticleEffect {
ITEM("ITEM_CRACK", "ITEM_CRACK", ParticleProperty.REQUIRES_MATERIAL_DATA), ITEM("ITEM_CRACK", "ITEM_CRACK", ParticleProperty.REQUIRES_MATERIAL_DATA),
ITEM_SLIME("SLIME", "SLIME"), ITEM_SLIME("SLIME", "SLIME"),
ITEM_SNOWBALL("SNOWBALL", "SNOWBALL"), ITEM_SNOWBALL("SNOWBALL", "SNOWBALL"),
LANDING_LAVA("LANDING_LAVA", null),
LARGE_SMOKE("SMOKE_LARGE", "SMOKE_LARGE"), LARGE_SMOKE("SMOKE_LARGE", "SMOKE_LARGE"),
LAVA("LAVA", "LAVA"), LAVA("LAVA", "LAVA"),
MYCELIUM("TOWN_AURA", "TOWN_AURA"), MYCELIUM("TOWN_AURA", "TOWN_AURA"),
@ -68,6 +76,7 @@ public enum ParticleEffect {
PORTAL("PORTAL", "PORTAL"), PORTAL("PORTAL", "PORTAL"),
RAIN("WATER_DROP", "WATER_DROP"), RAIN("WATER_DROP", "WATER_DROP"),
SMOKE("SMOKE_NORMAL", "SMOKE_NORMAL"), SMOKE("SMOKE_NORMAL", "SMOKE_NORMAL"),
SNEEZE("SNEEZE", null),
SPELL("SPELL", "SPELL"), // The Minecraft internal name for this is actually "effect", but that's the command name, so it's SPELL for the plugin instead SPELL("SPELL", "SPELL"), // The Minecraft internal name for this is actually "effect", but that's the command name, so it's SPELL for the plugin instead
SPIT("SPIT", "SPIT"), SPIT("SPIT", "SPIT"),
SPLASH("WATER_SPLASH", "WATER_SPLASH"), SPLASH("WATER_SPLASH", "WATER_SPLASH"),
@ -78,7 +87,7 @@ public enum ParticleEffect {
WITCH("SPELL_WITCH", "SPELL_WTICH"); WITCH("SPELL_WITCH", "SPELL_WTICH");
public static boolean VERSION_13; // This is a particle unique to Minecraft 1.13, this is a reliable way of telling what server version is running public static boolean VERSION_13; // This is a particle unique to Minecraft 1.13, this is a reliable way of telling what server version is running
private static final Map<String, ParticleEffect> NAME_MAP = new HashMap<String, ParticleEffect>(); private static final Map<String, ParticleEffect> NAME_MAP = new HashMap<>();
private static Constructor<?> DustOptions_CONSTRUCTOR; private static Constructor<?> DustOptions_CONSTRUCTOR;
private static Method createBlockData_METHOD; private static Method createBlockData_METHOD;
private final Particle internalEnum; private final Particle internalEnum;
@ -87,15 +96,19 @@ public enum ParticleEffect {
// Initialize map for quick name and id lookup // Initialize map for quick name and id lookup
// Initialize Minecraft 1.13 related variables // Initialize Minecraft 1.13 related variables
static { static {
for (ParticleEffect effect : values()) { for (ParticleEffect effect : values())
if (effect.isSupported())
NAME_MAP.put(effect.getName(), effect); NAME_MAP.put(effect.getName(), effect);
}
if (NMSUtil.getVersionNumber() > 12) {
VERSION_13 = true;
try { try {
VERSION_13 = Particle.valueOf("NAUTILUS") != null;
DustOptions_CONSTRUCTOR = Particle.REDSTONE.getDataType().getConstructor(Color.class, float.class); DustOptions_CONSTRUCTOR = Particle.REDSTONE.getDataType().getConstructor(Color.class, float.class);
createBlockData_METHOD = Material.class.getMethod("createBlockData"); createBlockData_METHOD = Material.class.getMethod("createBlockData");
} catch (Exception e) { } catch (Exception ex) {
ex.printStackTrace();
}
} else {
DustOptions_CONSTRUCTOR = null; DustOptions_CONSTRUCTOR = null;
createBlockData_METHOD = null; createBlockData_METHOD = null;
VERSION_13 = false; VERSION_13 = false;
@ -109,7 +122,7 @@ public enum ParticleEffect {
* @param enumNameLegacy Name of the Particle Enum when the server version is less than 1.13 * @param enumNameLegacy Name of the Particle Enum when the server version is less than 1.13
* @param properties Properties of this particle effect * @param properties Properties of this particle effect
*/ */
private ParticleEffect(String enumName, String enumNameLegacy, ParticleProperty... properties) { ParticleEffect(String enumName, String enumNameLegacy, ParticleProperty... properties) {
this.properties = Arrays.asList(properties); this.properties = Arrays.asList(properties);
Particle matchingEnum = null; Particle matchingEnum = null;
@ -167,9 +180,10 @@ public enum ParticleEffect {
* @return Supported effects * @return Supported effects
*/ */
public static List<ParticleEffect> getSupportedEffects() { public static List<ParticleEffect> getSupportedEffects() {
List<ParticleEffect> effects = new ArrayList<ParticleEffect>(); List<ParticleEffect> effects = new ArrayList<>();
for (ParticleEffect pe : values()) for (ParticleEffect pe : values())
if (pe.isSupported()) effects.add(pe); if (pe.isSupported())
effects.add(pe);
return effects; return effects;
} }
@ -195,17 +209,18 @@ public enum ParticleEffect {
* @param particle The ParticlePair, given the effect/style/data * @param particle The ParticlePair, given the effect/style/data
* @param pparticle The particle spawn information * @param pparticle The particle spawn information
* @param isFixedEffect If the particle is spawned from a fixed effect * @param isFixedEffect If the particle is spawned from a fixed effect
* @param owner The player that owns the particles
*/ */
public static void display(ParticlePair particle, PParticle pparticle, boolean isFixedEffect) { public static void display(ParticlePair particle, PParticle pparticle, boolean isFixedEffect, Player owner) {
ParticleEffect effect = particle.getEffect(); ParticleEffect effect = particle.getEffect();
int count = pparticle.isDirectional() ? 0 : 1; int count = pparticle.isDirectional() ? 0 : 1;
if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
effect.display(particle.getSpawnMaterial(), pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), pparticle.getSpeed(), 1, pparticle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)), isFixedEffect); effect.display(particle.getSpawnMaterial(), pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), pparticle.getSpeed(), 1, pparticle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)), isFixedEffect, owner);
} else if (effect.hasProperty(ParticleProperty.COLORABLE)) { } else if (effect.hasProperty(ParticleProperty.COLORABLE)) {
effect.display(particle.getSpawnColor(), pparticle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)), isFixedEffect); effect.display(particle.getSpawnColor(), pparticle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)), isFixedEffect, owner);
} else { } else {
effect.display(pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), pparticle.getSpeed(), count, pparticle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)), isFixedEffect); effect.display(pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), pparticle.getSpeed(), count, pparticle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)), isFixedEffect, owner);
} }
} }
@ -219,15 +234,16 @@ public enum ParticleEffect {
* @param amount Amount of particles * @param amount Amount of particles
* @param center Center location of the effect * @param center Center location of the effect
* @param isFixedEffect If the particle is spawned from a fixed effect * @param isFixedEffect If the particle is spawned from a fixed effect
* @param owner The player that owns the particles
* @throws ParticleDataException If the particle effect requires additional data * @throws ParticleDataException If the particle effect requires additional data
*/ */
public void display(double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center, boolean isFixedEffect) throws ParticleDataException { public void display(double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center, boolean isFixedEffect, Player owner) throws ParticleDataException {
if (hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { if (this.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
throw new ParticleDataException("This particle effect requires additional data"); throw new ParticleDataException("This particle effect requires additional data");
} }
for (Player player : getPlayersInRange(center, isFixedEffect)) { for (Player player : this.getPlayersInRange(center, isFixedEffect, owner)) {
player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed); player.spawnParticle(this.internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed);
} }
} }
@ -237,10 +253,11 @@ public enum ParticleEffect {
* @param color Color of the particle * @param color Color of the particle
* @param center Center location of the effect * @param center Center location of the effect
* @param isFixedEffect If the particle is spawned from a fixed effect * @param isFixedEffect If the particle is spawned from a fixed effect
* @param owner The player that owns the particles
* @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect * @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect
*/ */
public void display(ParticleColor color, Location center, boolean isFixedEffect) throws ParticleColorException { public void display(ParticleColor color, Location center, boolean isFixedEffect, Player owner) throws ParticleColorException {
if (!hasProperty(ParticleProperty.COLORABLE)) { if (!this.hasProperty(ParticleProperty.COLORABLE)) {
throw new ParticleColorException("This particle effect is not colorable"); throw new ParticleColorException("This particle effect is not colorable");
} }
@ -249,17 +266,15 @@ public enum ParticleEffect {
Object dustData = null; Object dustData = null;
try { // The DustData class doesn't exist in Minecraft versions less than 1.13... so this is disgusting... but it works great try { // The DustData class doesn't exist in Minecraft versions less than 1.13... so this is disgusting... but it works great
dustData = DustOptions_CONSTRUCTOR.newInstance(Color.fromRGB(dustColor.getRed(), dustColor.getGreen(), dustColor.getBlue()), 1); // Wait, you can change the size of these now??? AWESOME! I might implement this in the future! dustData = DustOptions_CONSTRUCTOR.newInstance(Color.fromRGB(dustColor.getRed(), dustColor.getGreen(), dustColor.getBlue()), 1); // Wait, you can change the size of these now??? AWESOME! I might implement this in the future!
} catch (Exception e) { } catch (Exception ignored) { }
} for (Player player : this.getPlayersInRange(center, isFixedEffect, owner)) {
player.spawnParticle(this.internalEnum, center.getX(), center.getY(), center.getZ(), 1, 0, 0, 0, 0, dustData);
for (Player player : getPlayersInRange(center, isFixedEffect)) {
player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), 1, 0, 0, 0, 0, dustData);
} }
} else { } else {
for (Player player : getPlayersInRange(center, isFixedEffect)) { for (Player player : this.getPlayersInRange(center, isFixedEffect, owner)) {
// Minecraft clients require that you pass a non-zero value if the Red value should be zero // Minecraft clients require that you pass a non-zero value if the Red value should be zero
player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), 0, this == ParticleEffect.DUST && color.getValueX() == 0 ? Float.MIN_VALUE : color.getValueX(), color.getValueY(), color.getValueZ(), 1); player.spawnParticle(this.internalEnum, center.getX(), center.getY(), center.getZ(), 0, this == ParticleEffect.DUST && color.getValueX() == 0 ? Float.MIN_VALUE : color.getValueX(), color.getValueY(), color.getValueZ(), 1);
} }
} }
} }
@ -277,30 +292,27 @@ public enum ParticleEffect {
* @param amount Amount of particles * @param amount Amount of particles
* @param center Center location of the effect * @param center Center location of the effect
* @param isFixedEffect If the particle is spawned from a fixed effect * @param isFixedEffect If the particle is spawned from a fixed effect
* @param owner The player that owns the particles
* @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect
*/ */
public void display(Material spawnMaterial, double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center, boolean isFixedEffect) throws ParticleDataException { public void display(Material spawnMaterial, double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center, boolean isFixedEffect, Player owner) throws ParticleDataException {
if (!hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { if (!this.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
throw new ParticleDataException("This particle effect does not require additional data"); throw new ParticleDataException("This particle effect does not require additional data");
} }
Object extraData = null; Object extraData = null;
if (internalEnum.getDataType().getTypeName().equals("org.bukkit.block.data.BlockData")) { if (this.internalEnum.getDataType().getTypeName().equals("org.bukkit.block.data.BlockData")) {
try { // The Material.createBlockData() method doesn't exist in Minecraft versions less than 1.13... so this is disgusting... but it works great try { // The Material.createBlockData() method doesn't exist in Minecraft versions less than 1.13... so this is disgusting... but it works great
extraData = createBlockData_METHOD.invoke(spawnMaterial); extraData = createBlockData_METHOD.invoke(spawnMaterial);
} catch (Exception e) { } catch (Exception ignored) { }
} else if (this.internalEnum.getDataType() == ItemStack.class) {
}
} else if (internalEnum.getDataType() == ItemStack.class) {
extraData = new ItemStack(spawnMaterial); extraData = new ItemStack(spawnMaterial);
} else if (internalEnum.getDataType() == MaterialData.class) { } else if (this.internalEnum.getDataType() == MaterialData.class) {
extraData = new MaterialData(spawnMaterial); // Deprecated, only used in versions < 1.13 extraData = new MaterialData(spawnMaterial); // Deprecated, only used in versions < 1.13
} else {
extraData = null;
} }
for (Player player : getPlayersInRange(center, isFixedEffect)) for (Player player : this.getPlayersInRange(center, isFixedEffect, owner))
player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed, extraData); player.spawnParticle(this.internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed, extraData);
} }
/** /**
@ -308,14 +320,18 @@ public enum ParticleEffect {
* *
* @param center The center of the radius to check around * @param center The center of the radius to check around
* @param isFixedEffect If the particle is spawned from a fixed effect * @param isFixedEffect If the particle is spawned from a fixed effect
* @param owner The player that owns the particles
* @return A List of Players within the particle display range * @return A List of Players within the particle display range
*/ */
private List<Player> getPlayersInRange(Location center, boolean isFixedEffect) { private List<Player> getPlayersInRange(Location center, boolean isFixedEffect, Player owner) {
List<Player> players = new ArrayList<Player>(); List<Player> players = new ArrayList<>();
int range = !isFixedEffect ? PSetting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : PSetting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt(); int range = !isFixedEffect ? PSetting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : PSetting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt();
for (PPlayer pplayer : ParticleManager.getPPlayers()) { for (PPlayer pplayer : ParticleManager.getPPlayers()) {
Player p = pplayer.getPlayer(); Player p = pplayer.getPlayer();
if (!isFixedEffect && !p.canSee(owner))
continue;
if (p != null && pplayer.canSeeParticles() && p.getWorld().equals(center.getWorld()) && center.distanceSquared(p.getLocation()) <= range * range) { if (p != null && pplayer.canSeeParticles() && p.getWorld().equals(center.getWorld()) && center.distanceSquared(p.getLocation()) <= range * range) {
players.add(p); players.add(p);
} }
@ -333,7 +349,7 @@ public enum ParticleEffect {
* @author DarkBlade12 * @author DarkBlade12
* @since 1.7 * @since 1.7
*/ */
public static enum ParticleProperty { public enum ParticleProperty {
/** /**
* The particle effect requires block or item material data to be displayed * The particle effect requires block or item material data to be displayed
*/ */
@ -341,7 +357,7 @@ public enum ParticleEffect {
/** /**
* The particle effect uses the offsets as color values * The particle effect uses the offsets as color values
*/ */
COLORABLE; COLORABLE
} }
/** /**
@ -438,7 +454,7 @@ public enum ParticleEffect {
* @return The red value * @return The red value
*/ */
public int getRed() { public int getRed() {
return red; return this.red;
} }
/** /**
@ -447,7 +463,7 @@ public enum ParticleEffect {
* @return The green value * @return The green value
*/ */
public int getGreen() { public int getGreen() {
return green; return this.green;
} }
/** /**
@ -456,7 +472,7 @@ public enum ParticleEffect {
* @return The blue value * @return The blue value
*/ */
public int getBlue() { public int getBlue() {
return blue; return this.blue;
} }
/** /**
@ -466,8 +482,8 @@ public enum ParticleEffect {
*/ */
@Override @Override
public float getValueX() { public float getValueX() {
if (red == 999 || red == 998) return 0F; if (this.red == 999 || this.red == 998) return 0F;
return (float) red / 255F; return (float) this.red / 255F;
} }
/** /**
@ -477,8 +493,8 @@ public enum ParticleEffect {
*/ */
@Override @Override
public float getValueY() { public float getValueY() {
if (green == 999 || green == 998) return 0F; if (this.green == 999 || this.green == 998) return 0F;
return (float) green / 255F; return (float) this.green / 255F;
} }
/** /**
@ -488,8 +504,8 @@ public enum ParticleEffect {
*/ */
@Override @Override
public float getValueZ() { public float getValueZ() {
if (blue == 999 || blue == 998) return 0F; if (this.blue == 999 || this.blue == 998) return 0F;
return (float) blue / 255F; return (float) this.blue / 255F;
} }
} }

View file

@ -1,5 +1,8 @@
package com.esophose.playerparticles.particles; package com.esophose.playerparticles.particles;
import com.esophose.playerparticles.manager.PermissionManager;
import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -40,7 +43,30 @@ public class ParticleGroup {
* @return The default empty active ParticleGroup * @return The default empty active ParticleGroup
*/ */
public static ParticleGroup getDefaultGroup() { public static ParticleGroup getDefaultGroup() {
return new ParticleGroup(DEFAULT_NAME, new ArrayList<ParticlePair>()); return new ParticleGroup(DEFAULT_NAME, new ArrayList<>());
}
/**
* Checks if a player has permission to use this particle group
*
* @param player The player to check
* @return True if the player has permission
*/
public boolean canPlayerUse(Player player) {
// Make sure the player has permission for the number of particles in this group
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()))
return false;
if (!PermissionManager.hasStylePermission(player, particle.getStyle()))
return false;
}
return true;
} }
} }

View file

@ -280,7 +280,7 @@ public class ParticlePair {
-1, -1,
ParticleEffect.FLAME, ParticleEffect.FLAME,
DefaultStyles.NORMAL, DefaultStyles.NORMAL,
ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"), ParticleUtils.closestMatchWithFallback(true, "IRON_SHOVEL", "IRON_SPADE"),
Material.STONE, Material.STONE,
new OrdinaryColor(0, 0, 0), new OrdinaryColor(0, 0, 0),
new NoteColor(0)); // @formatter:on new NoteColor(0)); // @formatter:on
@ -297,7 +297,7 @@ public class ParticlePair {
pplayer.getNextActiveParticleId(), pplayer.getNextActiveParticleId(),
ParticleEffect.FLAME, ParticleEffect.FLAME,
DefaultStyles.NORMAL, DefaultStyles.NORMAL,
ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"), ParticleUtils.closestMatchWithFallback(true, "IRON_SHOVEL", "IRON_SPADE"),
Material.STONE, Material.STONE,
new OrdinaryColor(0, 0, 0), new OrdinaryColor(0, 0, 0),
new NoteColor(0)); // @formatter:on new NoteColor(0)); // @formatter:on

View file

@ -41,13 +41,13 @@ public class ParticleStyleCelebration implements ParticleStyle {
Random random = new Random(); Random random = new Random();
for (PPlayer pplayer : ParticleManager.getPPlayers()) { for (PPlayer pplayer : ParticleManager.getPPlayers()) {
Player player = pplayer.getPlayer(); Player player = pplayer.getPlayer();
if (player != null && player.getGameMode() != GameMode.SPECTATOR && !PermissionManager.isWorldDisabled(player.getWorld().getName())) if (player != null && player.getGameMode() != GameMode.SPECTATOR && PermissionManager.isWorldEnabled(player.getWorld().getName()))
for (ParticlePair particle : pplayer.getActiveParticles()) for (ParticlePair particle : pplayer.getActiveParticles())
if (particle.getStyle() == this) if (particle.getStyle() == this)
spawnFirework(player.getLocation(), pplayer, particle, random); spawnFirework(player.getLocation(), pplayer, particle, random);
for (FixedParticleEffect fixedEffect : pplayer.getFixedParticles()) for (FixedParticleEffect fixedEffect : pplayer.getFixedParticles())
if (fixedEffect.getParticlePair().getStyle() == this && !PermissionManager.isWorldDisabled(fixedEffect.getLocation().getWorld().getName())) if (fixedEffect.getParticlePair().getStyle() == this && PermissionManager.isWorldEnabled(fixedEffect.getLocation().getWorld().getName()))
spawnFirework(fixedEffect.getLocation(), pplayer, fixedEffect.getParticlePair(), random); spawnFirework(fixedEffect.getLocation(), pplayer, fixedEffect.getParticlePair(), random);
} }
} }

View file

@ -15,40 +15,40 @@ public interface ParticleStyle {
* @param location The central location of the particles * @param location The central location of the particles
* @return A List of PParticles to spawn * @return A List of PParticles to spawn
*/ */
public List<PParticle> getParticles(ParticlePair particle, Location location); List<PParticle> getParticles(ParticlePair particle, Location location);
/** /**
* Used to update timers for animations, called once per particle tick * Used to update timers for animations, called once per particle tick
*/ */
public void updateTimers(); void updateTimers();
/** /**
* The name of the style * The name of the style
* *
* @return The style's name * @return The style's name
*/ */
public String getName(); String getName();
/** /**
* Gets if the style can be used in a FixedParticleEffect * Gets if the style can be used in a FixedParticleEffect
* *
* @return If the style can be used in a FixedParticleEffect * @return If the style can be used in a FixedParticleEffect
*/ */
public boolean canBeFixed(); boolean canBeFixed();
/** /**
* Gets if the style can be replaced with DefaultStyles.FEET when the player is moving * Gets if the style can be replaced with DefaultStyles.FEET when the player is moving
* *
* @return True if it can be, otherwise False * @return True if it can be, otherwise False
*/ */
public boolean canToggleWithMovement(); boolean canToggleWithMovement();
/** /**
* The Y-axis offset to be applied when using '/pp fixed create looking' * The Y-axis offset to be applied when using '/pp fixed create looking'
* *
* @return How far to move the style up or down to get it centered on the block properly * @return How far to move the style up or down to get it centered on the block properly
*/ */
public double getFixedEffectOffset(); double getFixedEffectOffset();
/** /**
* Gets the ParticleStyle with the name given, returns null if not found * Gets the ParticleStyle with the name given, returns null if not found
@ -56,7 +56,7 @@ public interface ParticleStyle {
* @param styleName The name of the style to search for * @param styleName The name of the style to search for
* @return The ParticleStyle with a matching name * @return The ParticleStyle with a matching name
*/ */
public static ParticleStyle fromName(String styleName) { static ParticleStyle fromName(String styleName) {
for (ParticleStyle style : ParticleStyleManager.getStyles()) for (ParticleStyle style : ParticleStyleManager.getStyles())
if (style.getName().equalsIgnoreCase(styleName)) if (style.getName().equalsIgnoreCase(styleName))
return style; return style;

View file

@ -10,8 +10,8 @@ public class ParticleStyleManager {
/** /**
* Arrays that contain all registered styles * Arrays that contain all registered styles
*/ */
private static List<ParticleStyle> styles = new ArrayList<ParticleStyle>(); private static List<ParticleStyle> styles = new ArrayList<>();
private static List<ParticleStyle> customHandledStyles = new ArrayList<ParticleStyle>(); private static List<ParticleStyle> customHandledStyles = new ArrayList<>();
/** /**
* Registers a style that is put into the plugin's update loop * Registers a style that is put into the plugin's update loop

View file

@ -1,7 +1,9 @@
package com.esophose.playerparticles; package com.esophose.playerparticles.updater;
import java.sql.Statement; import java.sql.Statement;
import com.esophose.playerparticles.PlayerParticles;
/** /**
* This class handles updating the SQLite or MySQL data from older versions to the current version * 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 * Everything is purposely done on the main thread to prevent the plugin from starting before all the data is updated
@ -12,7 +14,7 @@ public class DataUpdater {
* Checks to make sure all the correct database tables exist * Checks to make sure all the correct database tables exist
* If they don't, create them * If they don't, create them
*/ */
protected static void tryCreateTables() { public static void tryCreateTables() {
PlayerParticles.getPlugin().getDBConnector().connect((connection) -> { PlayerParticles.getPlugin().getDBConnector().connect((connection) -> {
try (Statement createStatement = connection.createStatement()) { 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_settings (player_uuid VARCHAR(36), particles_hidden TINYINT)");
@ -30,7 +32,7 @@ public class DataUpdater {
* @param configVersion The old version of the plugin * @param configVersion The old version of the plugin
* @param currentVersion The current version of the plugin * @param currentVersion The current version of the plugin
*/ */
protected static void updateData(double configVersion, double currentVersion) { public static void updateData(double configVersion, double currentVersion) {
if (configVersion == currentVersion) return; 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..."); 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...");
@ -39,7 +41,7 @@ public class DataUpdater {
updateFrom_legacy_to_current(); updateFrom_legacy_to_current();
} else if (configVersion == 5.3) { } else if (configVersion == 5.3) {
updateFrom_5_3_to_current(); updateFrom_5_3_to_current();
} else if (configVersion == 6.0) { } else {
PlayerParticles.getPlugin().getLogger().warning("Found nothing to update."); PlayerParticles.getPlugin().getLogger().warning("Found nothing to update.");
} }

View file

@ -1,12 +1,11 @@
package com.esophose.playerparticles.updater; package com.esophose.playerparticles.updater;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import com.esophose.playerparticles.PlayerParticles; import com.esophose.playerparticles.PlayerParticles;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.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 { public class PluginUpdateListener implements Listener {
@ -18,7 +17,11 @@ public class PluginUpdateListener implements Listener {
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent e) { public void onPlayerJoin(PlayerJoinEvent e) {
if (e.getPlayer().isOp() && PlayerParticles.getPlugin().getUpdateVersion() != null) { if (e.getPlayer().isOp() && PlayerParticles.getPlugin().getUpdateVersion() != null) {
LangManager.sendCommandSenderMessage(e.getPlayer(), Lang.UPDATE_AVAILABLE, PlayerParticles.getPlugin().getUpdateVersion(), PlayerParticles.getPlugin().getDescription().getVersion()); LangManager.sendCommandSenderMessage(
e.getPlayer(),
Lang.UPDATE_AVAILABLE,
PlayerParticles.getPlugin().getUpdateVersion(),
PlayerParticles.getPlugin().getDescription().getVersion());
} }
} }

View file

@ -1,29 +1,5 @@
package com.esophose.playerparticles.util; package com.esophose.playerparticles.util;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.HttpsURLConnection;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -33,12 +9,25 @@ import org.bukkit.plugin.ServicePriority;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
/** /**
* bStats collects some data for plugin authors. * bStats collects some data for plugin authors.
* <p> * <p>
* Check out https://bStats.org/ to learn more about bStats! * Check out https://bStats.org/ to learn more about bStats!
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings({"WeakerAccess", "unused"})
public class Metrics { public class Metrics {
static { static {
@ -79,9 +68,6 @@ public class Metrics {
// The plugin // The plugin
private final Plugin plugin; private final Plugin plugin;
// A list with all custom charts
private final List<CustomChart> charts = new ArrayList<>();
/** /**
* Class constructor. * Class constructor.
* *
@ -125,12 +111,9 @@ public class Metrics {
} }
// Load the data // Load the data
enabled = config.getBoolean("enabled", true);
serverUUID = config.getString("serverUuid"); serverUUID = config.getString("serverUuid");
logFailedRequests = config.getBoolean("logFailedRequests", false); logFailedRequests = config.getBoolean("logFailedRequests", false);
logSentData = config.getBoolean("logSentData", false); enabled = config.getBoolean("enabled", true);
logResponseStatusText = config.getBoolean("logResponseStatusText", false);
if (enabled) { if (enabled) {
boolean found = false; boolean found = false;
// Search for all other bStats Metrics classes to see if we are the first one // Search for all other bStats Metrics classes to see if we are the first one
@ -159,18 +142,6 @@ public class Metrics {
return enabled; return enabled;
} }
/**
* Adds a custom chart.
*
* @param chart The chart to add.
*/
public void addCustomChart(CustomChart chart) {
if (chart == null) {
throw new IllegalArgumentException("Chart cannot be null!");
}
charts.add(chart);
}
/** /**
* Starts the Scheduler which submits our data every 30 minutes. * Starts the Scheduler which submits our data every 30 minutes.
*/ */
@ -208,14 +179,6 @@ public class Metrics {
data.put("pluginName", pluginName); // Append the name of the plugin data.put("pluginName", pluginName); // Append the name of the plugin
data.put("pluginVersion", pluginVersion); // Append the version of the plugin data.put("pluginVersion", pluginVersion); // Append the version of the plugin
JSONArray customCharts = new JSONArray(); JSONArray customCharts = new JSONArray();
for (CustomChart customChart : charts) {
// Add the data of the custom charts
JSONObject chart = customChart.getRequestJsonObject();
if (chart == null) { // If the chart is null, we skip it
continue;
}
customCharts.add(chart);
}
data.put("customCharts", customCharts); data.put("customCharts", customCharts);
return data; return data;
@ -281,7 +244,8 @@ public class Metrics {
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) { for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try { try {
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider())); pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { } } catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
}
} }
} catch (NoSuchFieldException ignored) { } } catch (NoSuchFieldException ignored) { }
} }
@ -375,334 +339,4 @@ public class Metrics {
return outputStream.toByteArray(); return outputStream.toByteArray();
} }
/**
* Represents a custom chart.
*/
public static abstract class CustomChart {
// The id of the chart
final String chartId;
/**
* Class constructor.
*
* @param chartId The id of the chart.
*/
CustomChart(String chartId) {
if (chartId == null || chartId.isEmpty()) {
throw new IllegalArgumentException("ChartId cannot be null or empty!");
}
this.chartId = chartId;
}
private JSONObject getRequestJsonObject() {
JSONObject chart = new JSONObject();
chart.put("chartId", chartId);
try {
JSONObject data = getChartData();
if (data == null) {
// If the data is null we don't send the chart.
return null;
}
chart.put("data", data);
} catch (Throwable t) {
if (logFailedRequests) {
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
}
return null;
}
return chart;
}
protected abstract JSONObject getChartData() throws Exception;
}
/**
* Represents a custom simple pie.
*/
public static class SimplePie extends CustomChart {
private final Callable<String> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimplePie(String chartId, Callable<String> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JSONObject getChartData() throws Exception {
JSONObject data = new JSONObject();
String value = callable.call();
if (value == null || value.isEmpty()) {
// Null = skip the chart
return null;
}
data.put("value", value);
return data;
}
}
/**
* Represents a custom advanced pie.
*/
public static class AdvancedPie extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JSONObject getChartData() throws Exception {
JSONObject data = new JSONObject();
JSONObject values = new JSONObject();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
continue; // Skip this invalid
}
allSkipped = false;
values.put(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.put("values", values);
return data;
}
}
/**
* Represents a custom drilldown pie.
*/
public static class DrilldownPie extends CustomChart {
private final Callable<Map<String, Map<String, Integer>>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
super(chartId);
this.callable = callable;
}
@Override
public JSONObject getChartData() throws Exception {
JSONObject data = new JSONObject();
JSONObject values = new JSONObject();
Map<String, Map<String, Integer>> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean reallyAllSkipped = true;
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
JSONObject value = new JSONObject();
boolean allSkipped = true;
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
value.put(valueEntry.getKey(), valueEntry.getValue());
allSkipped = false;
}
if (!allSkipped) {
reallyAllSkipped = false;
values.put(entryValues.getKey(), value);
}
}
if (reallyAllSkipped) {
// Null = skip the chart
return null;
}
data.put("values", values);
return data;
}
}
/**
* Represents a custom single line chart.
*/
public static class SingleLineChart extends CustomChart {
private final Callable<Integer> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SingleLineChart(String chartId, Callable<Integer> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JSONObject getChartData() throws Exception {
JSONObject data = new JSONObject();
int value = callable.call();
if (value == 0) {
// Null = skip the chart
return null;
}
data.put("value", value);
return data;
}
}
/**
* Represents a custom multi line chart.
*/
public static class MultiLineChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JSONObject getChartData() throws Exception {
JSONObject data = new JSONObject();
JSONObject values = new JSONObject();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
continue; // Skip this invalid
}
allSkipped = false;
values.put(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.put("values", values);
return data;
}
}
/**
* Represents a custom simple bar chart.
*/
public static class SimpleBarChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JSONObject getChartData() throws Exception {
JSONObject data = new JSONObject();
JSONObject values = new JSONObject();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
for (Map.Entry<String, Integer> entry : map.entrySet()) {
JSONArray categoryValues = new JSONArray();
categoryValues.add(entry.getValue());
values.put(entry.getKey(), categoryValues);
}
data.put("values", values);
return data;
}
}
/**
* Represents a custom advanced bar chart.
*/
public static class AdvancedBarChart extends CustomChart {
private final Callable<Map<String, int[]>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JSONObject getChartData() throws Exception {
JSONObject data = new JSONObject();
JSONObject values = new JSONObject();
Map<String, int[]> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, int[]> entry : map.entrySet()) {
if (entry.getValue().length == 0) {
continue; // Skip this invalid
}
allSkipped = false;
JSONArray categoryValues = new JSONArray();
for (int categoryValue : entry.getValue()) {
categoryValues.add(categoryValue);
}
values.put(entry.getKey(), categoryValues);
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.put("values", values);
return data;
}
}
} }

View file

@ -0,0 +1,36 @@
package com.esophose.playerparticles.util;
import org.bukkit.Bukkit;
public class NMSUtil {
private static String cachedVersion = null;
private static int cachedVersionNumber = -1;
/**
* Gets the server version
*
* @return The server version
*/
public static String getVersion() {
if (cachedVersion == null) {
String name = Bukkit.getServer().getClass().getPackage().getName();
cachedVersion = name.substring(name.lastIndexOf('.') + 1) + ".";
}
return cachedVersion;
}
/**
* Gets the server version major release number
*
* @return The server version major release number
*/
public static int getVersionNumber() {
if (cachedVersionNumber == -1) {
String name = getVersion().substring(3);
cachedVersionNumber = Integer.valueOf(name.substring(0, name.length() - 4));
}
return cachedVersionNumber;
}
}

View file

@ -50,16 +50,19 @@ public class ParticleUtils {
* Finds a block/item as a material from a list of possible strings * Finds a block/item as a material from a list of possible strings
* Contains a fallback to the barrier icon just in case * Contains a fallback to the barrier icon just in case
* *
* @param barrierFallback If the material should fall back to barrier
* @param input A list of material names * @param input A list of material names
* @return The first matching material * @return The first matching material
*/ */
public static Material closestMatchWithFallback(String... input) { public static Material closestMatchWithFallback(boolean barrierFallback, String... input) {
Material mat = null; Material mat = null;
for (String name : input) { for (String name : input) {
mat = closestMatch(name); mat = closestMatch(name);
if (mat != null) return mat; if (mat != null)
return mat;
} }
if (mat == null) mat = Material.BARRIER; if (barrierFallback)
mat = Material.BARRIER;
return mat; return mat;
} }

View file

@ -13,7 +13,7 @@
# This value is the version of the plugin that last modified the config file # This value is the version of the plugin that last modified the config file
# Changing this value manually will likely result in data loss and errors! # Changing this value manually will likely result in data loss and errors!
# Do not change this manually unless specifically told to by the plugin author # Do not change this manually unless specifically told to by the plugin author
version: 6.3 version: 6.4
# Check for new versions of the plugin # Check for new versions of the plugin
# Default: true # Default: true
@ -46,6 +46,15 @@ message-prefix: '&7[&3PlayerParticles&7]'
# Default: true # Default: true
gui-enabled: true gui-enabled: true
# 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
# Default: false
gui-presets-only: false
# If true, the GUI will close after selecting a group (either saved or preset)
# Default: true
gui-close-after-group-selected: true
# If clicking a GUI button should make a noise # If clicking a GUI button should make a noise
# Default: true # Default: true
gui-button-sound: true gui-button-sound: true
@ -148,6 +157,11 @@ database-user-name: ''
# Default: '' # Default: ''
database-user-password: '' database-user-password: ''
# If the database connection should use SSL
# You should enable this if your database supports SSL
# Default: false
database-use-ssl: false
# =================================================================== # # =================================================================== #
# GUI ICON SETTINGS # # GUI ICON SETTINGS #
# This configuration option allows you to change any of the GUI # # This configuration option allows you to change any of the GUI #
@ -173,6 +187,10 @@ gui-icon:
- ENDER_CHEST - ENDER_CHEST
back: back:
- ARROW - ARROW
next_page:
- PAPER
previous_page:
- PAPER
create: create:
- WRITABLE_BOOK - WRITABLE_BOOK
- BOOK_AND_QUILL - BOOK_AND_QUILL
@ -183,8 +201,6 @@ gui-icon:
- NETHER_STAR - NETHER_STAR
edit_data: edit_data:
- BOOK - BOOK
randomize:
- HOPPER
reset: reset:
- BARRIER - BARRIER
effect: effect:
@ -203,9 +219,15 @@ gui-icon:
- MAGMA_BLOCK - MAGMA_BLOCK
bubble_pop: bubble_pop:
- BUBBLE_CORAL_FAN - BUBBLE_CORAL_FAN
campfire_cosy_smoke:
- CAMPFIRE
campfire_signal_smoke:
- REDSTONE_TORCH
cloud: cloud:
- WHITE_WOOL - WHITE_WOOL
- WOOL - WOOL
composter:
- COMPOSTER
crit: crit:
- IRON_SWORD - IRON_SWORD
current_down: current_down:
@ -239,6 +261,10 @@ gui-icon:
- TNT - TNT
falling_dust: falling_dust:
- SAND - SAND
falling_lava:
- RED_DYE
falling_water:
- BLUE_DYE
firework: firework:
- FIREWORK_ROCKET - FIREWORK_ROCKET
- FIREWORK - FIREWORK
@ -266,6 +292,8 @@ gui-icon:
large_smoke: large_smoke:
- COBWEB - COBWEB
- WEB - WEB
landing_lava:
- ORANGE_DYE
lava: lava:
- MAGMA_CREAM - MAGMA_CREAM
mycelium: mycelium:
@ -285,6 +313,8 @@ gui-icon:
- LAPIS_BLOCK - LAPIS_BLOCK
smoke: smoke:
- TORCH - TORCH
sneeze:
- BAMBOO
spell: spell:
- POTION - POTION
- GLASS_BOTTLE - GLASS_BOTTLE

View file

@ -78,6 +78,7 @@ edit-success-data: "&aYour particle with an ID of &b{0} &ahas had its data chang
# Group Command # Group Command
group-invalid: "&cA saved group or preset group does not exist with the name &b{0}&c!" group-invalid: "&cA saved group or preset group does not exist with the name &b{0}&c!"
group-no-permission: "&cYou are missing permission for an effect or style to use the group &b{0}&c!"
group-preset-no-permission: "&cYou are missing permission for an effect or style to use the preset group &b{0}&c!" group-preset-no-permission: "&cYou are missing permission for an effect or style to use the preset group &b{0}&c!"
group-reserved: "&cThe group name &bactive &cis reserved and cannot be used!" group-reserved: "&cThe group name &bactive &cis reserved and cannot be used!"
group-no-name: "&cYou did not provide a group name! &b/pp {0} <groupName>" group-no-name: "&cYou did not provide a group name! &b/pp {0} <groupName>"
@ -217,6 +218,8 @@ gui-color-subtext: "&b"
gui-color-unavailable: "&c" gui-color-unavailable: "&c"
gui-commands-info: "Find info about commands with &b/pp help" gui-commands-info: "Find info about commands with &b/pp help"
gui-back-button: "Go Back" gui-back-button: "Go Back"
gui-next-page-button: "Next Page ({0}/{1})"
gui-previous-page-button: "Previous Page ({0}/{1})"
gui-click-to-load: "Click to load the following {0} particle(s):" gui-click-to-load: "Click to load the following {0} particle(s):"
gui-shift-click-to-delete: "Shift click to delete" gui-shift-click-to-delete: "Shift click to delete"
gui-particle-info: " - ID: &b{0} &eEffect: &b{1} &eStyle: &b{2} &eData: &b{3}" gui-particle-info: " - ID: &b{0} &eEffect: &b{1} &eStyle: &b{2} &eData: &b{3}"
@ -267,10 +270,6 @@ gui-select-style-description: "Sets the particle style to &b{0}"
gui-select-data: "Select Particle Data" gui-select-data: "Select Particle Data"
gui-select-data-description: "Sets the particle data to &b{0}" gui-select-data-description: "Sets the particle data to &b{0}"
gui-select-data-note: "note #{0}" gui-select-data-note: "note #{0}"
gui-select-data-randomize-items: "Randomize Items"
gui-select-data-randomize-items-description: "Randomizes the items displayed"
gui-select-data-randomize-blocks: "Randomize Blocks"
gui-select-data-randomize-blocks-description: "Randomizes the blocks displayed"
gui-edit-data-color-red: "&cred" gui-edit-data-color-red: "&cred"
gui-edit-data-color-orange: "&6orange" gui-edit-data-color-orange: "&6orange"
gui-edit-data-color-yellow: "&eyellow" gui-edit-data-color-yellow: "&eyellow"

View file

@ -8,10 +8,10 @@
# * PLEASE MAKE YOUR OWN .lang FILE IF YOU WANT CUSTOM MESSAGES! # # * PLEASE MAKE YOUR OWN .lang FILE IF YOU WANT CUSTOM MESSAGES! #
# * This file will be overridden almost every plugin update! # # * This file will be overridden almost every plugin update! #
# ================================================================ # # ================================================================ #
# Translator: maxime_n2 # Translator: maxime_n2 & SevenX
# Command Errors # Command Errors
command-error-no-effects: "&cVous n avez pas la permission d utiliser cette commande." command-error-no-effects: "&cVous n'avez pas la permission d'utiliser cette commande."
command-error-unknown: "&cCommande inconnue, utilisez &b/pp help &cpour afficher la liste des commandes disponibles pour ce plugin." command-error-unknown: "&cCommande inconnue, utilisez &b/pp help &cpour afficher la liste des commandes disponibles pour ce plugin."
# Command Descriptions # Command Descriptions
@ -19,87 +19,88 @@ command-descriptions: "&eLes commandes suivantes sont disponibles :"
command-descriptions-usage: "&e/pp {0} {1}" command-descriptions-usage: "&e/pp {0} {1}"
command-descriptions-help-1: "&7> &b/pp {0} &e- {1}" command-descriptions-help-1: "&7> &b/pp {0} &e- {1}"
command-descriptions-help-2: "&7> &b/pp {0} {1} &e- {2}" command-descriptions-help-2: "&7> &b/pp {0} {1} &e- {2}"
command-descriptions-help-other: "&7> &b/ppo <player> <command> &e- Exécute une commande /pp en tant qu un autre joueur." command-descriptions-help-other: "&7> &b/ppo <player> <command> &e- Exécute une commande /pp en tant qu'un autre joueur."
command-description-add: "Ajoutez une nouvelle particule" command-description-add: "Ajoutez une nouvelle particule"
command-description-data: "Voir les paramètres utilisées par la particule" command-description-data: "Voir les paramètres utilisées par la particule"
command-description-default: "Commande principale. Par défaut elle ouvre l interface." command-description-default: "Commande principale. Par défaut elle ouvre l'interface."
command-description-edit: "Modifiez une particule" command-description-edit: "Modifiez une particule"
command-description-effects: "Affichez une liste des effets utilisés" command-description-effects: "Affichez une liste des effets utilisés"
command-description-fixed: "Gérez vos effets fixes" command-description-fixed: "Gérez vos effets fixes"
command-description-group: "Gérez vos groupes d effets" command-description-group: "Gérez vos groupes d'effets"
command-description-gui: "Affichez l interface pour modifier facilement les effets" command-description-gui: "Affichez l'interface pour modifier facilement les effets"
command-description-help: "Affichez le menu d aide... Vous y êtes déjà !" command-description-help: "Affichez le menu d'aide... Vous y êtes déjà !"
command-description-info: "Voir la description d une de vos particules actives" command-description-info: "Voir la description d'une de vos particules actives"
command-description-list: "Listez les IDs de vos particules actives" command-description-list: "Listez les IDs de vos particules actives"
command-description-reload: "Rechargez le fichier config.yml et de langue" command-description-reload: "Rechargez le fichier config.yml et de langue"
command-description-remove: "Supprimez vos particules actives." command-description-remove: "Supprimez vos particules actives."
command-description-reset: "Supprimez toutes vos particules actives" command-description-reset: "Supprimez toutes vos particules actives"
command-description-styles: "Affichez une liste des styles de particules que vous utilisez" command-description-styles: "Affichez une liste des styles de particules que vous utilisez"
command-description-toggle: "Activez ou déativez vos particules actives" command-description-toggle: "Activez ou désactivez vos particules actives"
command-description-version: "Affichez la version du plugin et son créateur" command-description-version: "Affichez la version du plugin et son créateur"
command-description-worlds: "Voir les mondes où ce plugin n est pas autorisé" command-description-worlds: "Voir les mondes où ce plugin n'est pas autorisé"
# Sub-Command Usage # Sub-Command Usage
command-description-fixed-create: "&e/pp fixed create <<x> <y> <z>|<looking>> <effect> <style> [data] - Créez une particule fixe" command-description-fixed-create: "&e/pp fixed create <<x> <y> <z>|<looking>> <effect> <style> [data] - Créez une particule fixe"
command-description-fixed-edit: "&e/pp fixed edit <id> <effect|style|data> <args> - Modifiez une partie d une particule fixe par son ID" command-description-fixed-edit: "&e/pp fixed edit <id> <effect|style|data> <args> - Modifiez une partie d'une particule fixe par son ID"
command-description-fixed-remove: "&e/pp fixed remove <ID> - Supprimez une particule fixe par son ID" command-description-fixed-remove: "&e/pp fixed remove <ID> - Supprimez une particule fixe par son ID"
command-description-fixed-list: "&e/pp fixed list - Affiche l ID de tous vos effets fixes" command-description-fixed-list: "&e/pp fixed list - Affiche l'ID de tous vos effets fixes"
command-description-fixed-info: "&e/pp fixed info <ID> - Voir des informations sur l une de vos particules fixe" command-description-fixed-info: "&e/pp fixed info <ID> - Voir des informations sur l'une de vos particules fixe"
command-description-fixed-clear: "&e/pp fixed clear <radius> - Supprimez tous les effets fixe de tous les joueurs d un rayon" command-description-fixed-clear: "&e/pp fixed clear <radius> - Supprimez tous les effets fixe de tous les joueurs d'un rayon"
command-description-group-save: "&e/pp group save <name> - Sauvegardez toutes les particules actives dans un nouveau groupe" command-description-group-save: "&e/pp group save <name> - Sauvegardez toutes les particules actives dans un nouveau groupe"
command-description-group-load: "&e/pp group load <name> - Chargez toutes les particules sauvegardées dans un groupe" command-description-group-load: "&e/pp group load <name> - Chargez toutes les particules sauvegardées dans un groupe"
command-description-group-remove: "&e/pp group remove <name> - Supprimez un groupe que vous avez créé" command-description-group-remove: "&e/pp group remove <name> - Supprimez un groupe que vous avez créé"
command-description-group-list: "&e/pp group list <name> - Voir toutes les particules sauvegardées d un groupe que vous avez créé" command-description-group-list: "&e/pp group list <name> - Voir toutes les particules sauvegardées d'un groupe que vous avez créé"
command-description-group-info: "&e/pp group info <name> - Voir toutes les particules sauvegardées du groupe" command-description-group-info: "&e/pp group info <name> - Voir toutes les particules sauvegardées du groupe"
# Command ID Lookup # Command ID Lookup
id-invalid: "&cL ID rentrée n est pas valide, il doit être un nombre entier positif" id-invalid: "&cL'ID rentrée n'est pas valide, il doit être un nombre entier positif"
id-unknown: "&cVous n avez pas de particules appliquées avec : &b{0} &c!" id-unknown: "&cVous n'avez pas de particules appliquées avec : &b{0} &c!"
# Other Command # Other Command
other-no-permission: "&cVous n avez pas la permission pour exécuter une commande /pp en tant qu un autre joueur." other-no-permission: "&cVous n'avez pas la permission pour exécuter une commande /pp en tant qu'un autre joueur."
other-missing-args: "&cVous oubliez des arguments dans votre commande. &b/ppo <player> <command>" other-missing-args: "&cVous oubliez des arguments dans votre commande. &b/ppo <player> <command>"
other-unknown-player: "&cLe joueur &b{0} &cn a pas été trouvé. Il doit être en ligne." other-unknown-player: "&cLe joueur &b{0} &cn'a pas été trouvé. Il doit être en ligne."
other-unknown-command: "&cLa commande &b/pp {0} &cn existe pas." other-unknown-command: "&cLa commande &b/pp {0} &cn existe pas."
other-success: "&Commande /pp exécutée. &b{0}&e. Retour de la commande :" other-success: "&Commande /pp exécutée. &b{0}&e. Retour de la commande :"
# Add Command # Add Command
add-reached-max: "Impossible d appliquer la particule, vous avez atteint la limite de particules qui est de &b{0} &c!" add-reached-max: "Impossible d'appliquer la particule, vous avez atteint la limite de particules qui est de &b{0} &c!"
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!" 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 # Data Command
data-no-args: "&cVous oubliez des arguments dans l effet. Utilisation de la commande: &b/pp data <effect>" data-no-args: "&cVous oubliez des arguments dans l'effet. Utilisation de la commande: &b/pp data <effect>"
# Edit Command # Edit Command
edit-invalid-property: "cLa propriété &b{0} &cest interdite. Propriétés valides : &beffect&c, &bstyle&c, &bdata" edit-invalid-property: "cLa propriété &b{0} &cest interdite. Propriétés valides : &beffect&c, &bstyle&c, &bdata"
edit-success-effect: "&aVotre particule avec l ID de &b{0} &aa son effet changé à &b{1} &a!" edit-success-effect: "&aVotre particule avec l'ID de &b{0} &aa son effet changé à &b{1} &a!"
edit-success-style: "&aVotre particule avec l ID de &b{0} &aa son style changé à &b{1} &a!" edit-success-style: "&aVotre particule avec l'ID de &b{0} &aa son style changé à &b{1} &a!"
edit-success-data: "&aVotre particule avec l ID de &b{0} &aa ses paramètres changés à &b{1} &a!" edit-success-data: "&aVotre particule avec l'ID de &b{0} &aa ses paramètres changés à &b{1} &a!"
# Group Command # Group Command
group-invalid: "&cUn groupe ou un preset de groupe sauvegardé n existe pas avec le nom &b{0} &c!" group-invalid: "&cUn groupe ou un preset de groupe sauvegardé n'existe pas avec le nom &b{0} &c!"
group-preset-no-permission: "&cVous oubliez une permission pour un style ou un effet afin d utiliser les persets du groupe &b{0} &c!" group-no-permission: "&cVous oubliez une permission pour un style ou un effet afin d'utiliser les groupe &b{0} &c!"
group-preset-no-permission: "&cVous oubliez une permission pour un style ou un effet afin d'utiliser les presets du groupe &b{0} &c!"
group-reserved: "&cLe nom de groupe &bactive &cest réservé et ne peut pas être utiliser !" group-reserved: "&cLe nom de groupe &bactive &cest réservé et ne peut pas être utiliser !"
group-no-name: "&cVous n avez pas rentré de nom de groupe ! &b/pp {0} <groupName>" group-no-name: "&cVous n'avez pas rentré de nom de groupe ! &b/pp {0} <groupName>"
group-save-reached-max: "&cImpossible de sauvegarder le groupe, vous avez atteint le nombre maximun de groupes !" group-save-reached-max: "&cImpossible de sauvegarder le groupe, vous avez atteint le nombre maximun de groupes !"
group-save-no-particles: "&cImpossible de sauvegarder le groupe, vous n avez pas appliqué de particules !" group-save-no-particles: "&cImpossible de sauvegarder le groupe, vous n'avez pas appliqué de particules !"
group-save-success: "&aVos particules actuelles on été sauvegardées sous le nom de groupe &b{0} &a!" group-save-success: "&aVos particules actuelles ont été sauvegardées sous le nom de groupe &b{0} &a!"
group-save-success-overwrite: "&aLe groupe &b{0} &aa été mis à jour avec vos particules actuelle !" group-save-success-overwrite: "&aLe groupe &b{0} &aa été mis à jour avec vos particules actuelle !"
group-load-success: "&b{0} &aparticule(s) appliqués venant du groupe sauvegardé nommé &b{1} &a!" group-load-success: "&b{0} &aparticule(s) appliqués venant du groupe sauvegardé nommé &b{1} &a!"
group-load-preset-success: "&b{0} &aparticule(s) appliqués venant du preset sauvegardé nommé &b{1} &a!" group-load-preset-success: "&b{0} &aparticule(s) appliqués venant du preset sauvegardé nommé &b{1} &a!"
group-remove-preset: "&cVous ne pouvez pas supprimer un groupe de presets !" group-remove-preset: "&cVous ne pouvez pas supprimer un groupe de presets !"
group-remove-success: "&aGroupe de particules &b{0} &asupprimé !" group-remove-success: "&aGroupe de particules &b{0} &asupprimé !"
group-info-header: "&eLe groupe &b{0} &eposséde les particules suivantes :" group-info-header: "&eLe groupe &b{0} &eposséde les particules suivantes :"
group-list-none: "&eVous n avez pas de groupes de particules sauvegardés !" group-list-none: "&eVous n'avez pas de groupes de particules sauvegardés !"
group-list-output: "&eVous avez ces groupes suivants sauvegardés : &b{0}" group-list-output: "&eVous avez ces groupes suivants sauvegardés : &b{0}"
group-list-presets: "&eCes presets de groupes suivants sont disponibles : &b{0}" group-list-presets: "&eCes presets de groupes suivants sont disponibles : &b{0}"
# Reload Command # Reload Command
reload-success: "&aLe plugin a été rechargé..." reload-success: "&aLe plugin a été rechargé..."
reload-no-permission: "&cVous n avez pas la permission pour recharger la configuration de ce plugin !" reload-no-permission: "&cVous n'avez pas la permission pour recharger la configuration de ce plugin !"
# Remove Command # Remove Command
remove-no-args: "&cVous n avez pas rentrer d ID à supprimer ! &b/pp remove <ID>" remove-no-args: "&cVous n'avez pas rentrer d'ID à supprimer ! &b/pp remove <ID>"
remove-id-success: "&aVotre particule avec l'ID &b{0} &aa été supprimée !" remove-id-success: "&aVotre particule avec l'ID &b{0} &aa été supprimée !"
remove-effect-success: "&aSuppression de &b{0} &ade votre particule avec l'effet &b{1} &a!" remove-effect-success: "&aSuppression de &b{0} &ade votre particule avec l'effet &b{1} &a!"
remove-effect-none: "&cVous n'avez pas de particules appliquées avec l'effet &b{0} &c!" remove-effect-none: "&cVous n'avez pas de particules appliquées avec l'effet &b{0} &c!"
@ -108,7 +109,7 @@ remove-style-none: "&cVous n'avez pas de particules appliquées avec le style &b
remove-unknown: "&cL'effect avec le nom ou le style &b{0} &cn'existe pas !" remove-unknown: "&cL'effect avec le nom ou le style &b{0} &cn'existe pas !"
# List Command # List Command
list-none: "&eVous n avez pas de particules actives." list-none: "&eVous n'avez pas de particules actives."
list-you-have: "&eVous avez les particules suivantes appliquées :" list-you-have: "&eVous avez les particules suivantes appliquées :"
list-output: "&eID: &b{0} &eEffet: &b{1} &eStyle: &b{2} &eParamètre: &b{3}" list-output: "&eID: &b{0} &eEffet: &b{1} &eStyle: &b{2} &eParamètre: &b{3}"
@ -123,31 +124,31 @@ rainbow: "&cr&6a&ei&an&bb&9o&dw"
random: "aléatoire" random: "aléatoire"
# Effects # Effects
effect-no-permission: "&cVous n avez pas la permission pour utiliser la particule &b{0} &c!" effect-no-permission: "&cVous n'avez pas la permission pour utiliser la particule &b{0} &c!"
effect-invalid: "&cL effet &b{0} &cn existe pas ! Utilisez &b/pp effects &cpour afficher les effets disponibles." effect-invalid: "&cL'effet &b{0} &cn existe pas ! Utilisez &b/pp effects &cpour afficher les effets disponibles."
effect-list: "&eVous pouvez utiliser les effets suivants : &b{0}" effect-list: "&eVous pouvez utiliser les effets suivants : &b{0}"
effect-list-empty: "&cVous n avez pas la permission pour utiliser des effets !" effect-list-empty: "&cVous n'avez pas la permission pour utiliser des effets !"
# Styles # Styles
style-no-permission: "&cVous n avez pas la permission pour utiliser le style &b{0} &c!" style-no-permission: "&cVous n'avez pas la permission pour utiliser le style &b{0} &c!"
style-event-spawning-info: "&eNote: Le style &b{0} &efait apparaitre des particules seulement lors d évènements spécifiques." style-event-spawning-info: "&eNote: Le style &b{0} &efait apparaitre des particules seulement lors d'évènements spécifiques."
style-invalid: "&cLe style &b{0} &cn existe pas ! Utilisez &b/pp styles &cpour afficher les styles disponibles." style-invalid: "&cLe style &b{0} &cn'existe pas ! Utilisez &b/pp styles &cpour afficher les styles disponibles."
style-list: "&eVous pouvez utiliser les styles suivants : &b{0}" style-list: "&eVous pouvez utiliser les styles suivants : &b{0}"
# Data # Data
data-usage-none: "&eL effet &b{0} &en est pas paramétrable." data-usage-none: "&eL'effet &b{0} &en'est pas paramétrable."
data-usage-block: "&eL effet &b{0} &erequière l ID du bloc ! &bFormat: <blockName>" data-usage-block: "&eL'effet &b{0} &erequière l'ID du bloc ! &bFormat: <blockName>"
data-usage-item: "&eL effet &b{0} &erequière l ID de l item ! &bFormat: <itemName>" data-usage-item: "&eL'effet &b{0} &erequière l'ID de l'item ! &bFormat: <itemName>"
data-usage-color: "&eL effet &b{0} &erequière l ID de la couleur ! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>" data-usage-color: "&eL'effet &b{0} &erequière l'ID de la couleur ! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"
data-usage-note: "&eL effet&b{0} &erequière l ID de la note ! &bFormat: <0-24>|<rainbow>|<random>" data-usage-note: "&eL'effet&b{0} &erequière l'ID de la note ! &bFormat: <0-24>|<rainbow>|<random>"
data-invalid-block: "&cL ID du bloc que vous avez rentré n est pas valide ! &bFormat: <blockName>" data-invalid-block: "&cL'ID du bloc que vous avez rentré n'est pas valide ! &bFormat: <blockName>"
data-invalid-item: "&cL ID de l item que vous avez rentré n est pas valide ! &bFormat: <itemName>" data-invalid-item: "&cL'ID de l'item que vous avez rentré n'est pas valide ! &bFormat: <itemName>"
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>" 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>"
data-invalid-note: "&cL ID du bloc que vous avez rentré n est pas valide ! &bFormat: <0-24>|<rainbow>|<random>" data-invalid-note: "&cL'ID du bloc que vous avez rentré n'est pas valide ! &bFormat: <0-24>|<rainbow>|<random>"
data-invalid-material-not-item: "&cL ID &b{0} &cne correspond pas à un item !" data-invalid-material-not-item: "&cL'ID &b{0} &cne correspond pas à un item !"
data-invalid-material-not-block: "&cL ID &b{0} &cne correspond pas à un bloc !" data-invalid-material-not-block: "&cL'ID &b{0} &cne correspond pas à un bloc !"
data-invalid-material-item: "&cL ID &b{0} n existe pas !" data-invalid-material-item: "&cL'ID &b{0} n'existe pas !"
data-invalid-material-block: "&cL ID&b{0} n existe pas !" data-invalid-material-block: "&cL'ID&b{0} n'existe pas !"
# Worlds # Worlds
disabled-worlds: "&eLes particules sont désactivées dans ces mondes : &b{0}" disabled-worlds: "&eLes particules sont désactivées dans ces mondes : &b{0}"
@ -161,48 +162,48 @@ fixed-create-missing-args: "&cImpossible de créer un effet fixe, vous oubliez d
fixed-create-invalid-coords: "&cImpossible de créer un effet fixe, coordonnées invalides !" fixed-create-invalid-coords: "&cImpossible de créer un effet fixe, coordonnées invalides !"
fixed-create-out-of-range: "&cImpossible de créer un effet fixe, Vous devez être à &b{0} &cblocs de la position rentrée !" fixed-create-out-of-range: "&cImpossible de créer un effet fixe, Vous devez être à &b{0} &cblocs de la position rentrée !"
fixed-create-looking-too-far: "&cImpossible de créer un effet fixe, vous êtes trop loin du bloc que vous regardez !" fixed-create-looking-too-far: "&cImpossible de créer un effet fixe, vous êtes trop loin du bloc que vous regardez !"
fixed-create-effect-invalid: "&cImpossible de créer un effet fixe, l effet &b{0} &cn existe pas !" fixed-create-effect-invalid: "&cImpossible de créer un effet fixe, l effet &b{0} &cn'existe pas !"
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!" 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!"
fixed-create-style-invalid: "&cImpossible de créer un effet fixe, le style &b{0} &cn existe pas!" fixed-create-style-invalid: "&cImpossible de créer un effet fixe, le style &b{0} &cn'existe pas!"
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!" 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!"
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 !" 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 !"
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." 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."
fixed-create-success: "&aL effet fixe à été créer." fixed-create-success: "&aL'effet fixe à été créer."
fixed-edit-missing-args: "&cImpossible de modifier l effet fixe, vous oubliez des arguments !" fixed-edit-missing-args: "&cImpossible de modifier l'effet fixe, vous oubliez des arguments !"
fixed-edit-invalid-id: "&cImpossible de modifier l effet fixe, ID incorrecte !" fixed-edit-invalid-id: "&cImpossible de modifier l'effet fixe, ID incorrecte !"
fixed-edit-invalid-property: "&cImpossible de modifier l effet fixe, argument incorrecte ! Seuls localisation, effet, style, et paramètre sont valides." fixed-edit-invalid-property: "&cImpossible de modifier l'effet fixe, argument incorrect ! Seuls localisation, effet, style, et paramètre sont valides."
fixed-edit-invalid-coords: "&cImpossible de modifier l effet fixe, coordonnée incorrecte !" fixed-edit-invalid-coords: "&cImpossible de modifier l'effet fixe, coordonnée incorrecte !"
fixed-edit-out-of-range: "&cImpossible de modifier l effet fixe, vous devez être à &b{0} &cblocs de l emplacement désiré !" fixed-edit-out-of-range: "&cImpossible de modifier l'effet fixe, vous devez être à &b{0} &cblocs de l'emplacement désiré !"
fixed-edit-looking-too-far: "&cImpossible de modifier l effet fixe, vous êtes trop loin du bloc que vous regardez !" fixed-edit-looking-too-far: "&cImpossible de modifier l'effet fixe, vous êtes trop loin du bloc que vous regardez !"
fixed-edit-effect-invalid: "&cImpossible de modifier l effet fixe, l effet &b{0} &cn existe pas !" fixed-edit-effect-invalid: "&cImpossible de modifier l'effet fixe, l'effet &b{0} &cn'existe pas !"
fixed-edit-effect-no-permission: "&cImpossible de modifier l effet fixe, vous n avez pas la permission pour utiliser l effet &b{0} &c!" fixed-edit-effect-no-permission: "&cImpossible de modifier l'effet fixe, vous n'avez pas la permission pour utiliser l'effet &b{0} &c!"
fixed-edit-style-invalid: "&cImpossible de modifier l effet fixe, le style &b{0} &cn existe pas !" fixed-edit-style-invalid: "&cImpossible de modifier l'effet fixe, le style &b{0} &cn'existe pas !"
fixed-edit-style-no-permission: "&cImpossible de modifier l effet fixe, vous n avez pas la permission pour utiliser le style &b{0} &c!" fixed-edit-style-no-permission: "&cImpossible de modifier l'effet fixe, vous n'avez pas la permission pour utiliser le style &b{0} &c!"
fixed-edit-style-non-fixable: "&cImpossible de modifier l effet fixe, the style &b{0} &cne peut pas être utilisé dans des effets fixes !" fixed-edit-style-non-fixable: "&cImpossible de modifier l'effet fixe, the style &b{0} &cne peut pas être utilisé dans des effets fixes !"
fixed-edit-data-error: "&cImpossible de modifier l effet fixe, paramètre incorrecte ! Utilisez &b/pp data <effect> pour afficher les paramètres valides." fixed-edit-data-error: "&cImpossible de modifier l'effet fixe, paramètre incorrect ! Utilisez &b/pp data <effect> pour afficher les paramètres valides."
fixed-edit-data-none: "&cImpossible de modifier l effet fixe, l effet ne requière pas de paramètres !" fixed-edit-data-none: "&cImpossible de modifier l'effet fixe, l'effet ne requière pas de paramètres !"
fixed-edit-success: "&aMise à jour de &b{0} &ade l effet fixe avec l ID &b{1} &a!" fixed-edit-success: "&aMise à jour de &b{0} &ade l'effet fixe avec l'ID &b{1} &a!"
fixed-remove-invalid: "&cImpossible de supprimer l effet fixe, vous n avez pas d effets fixes avec l ID &b{0} &c!" fixed-remove-invalid: "&cImpossible de supprimer l'effet fixe, vous n'avez pas d effets fixes avec l'ID &b{0} &c!"
fixed-remove-no-args: "&cVous n avez pas rentrer d ID à supprimer !" fixed-remove-no-args: "&cVous n'avez pas rentrer d'ID à supprimer !"
fixed-remove-args-invalid: "&cImpossible de supprimer, l ID doit être un nombre !" fixed-remove-args-invalid: "&cImpossible de supprimer, l'ID doit être un nombre !"
fixed-remove-success: "&aTous vos effets fixes avec l ID &b{0} &aont été supprimés !" fixed-remove-success: "&aTous vos effets fixes avec l'ID &b{0} &aont été supprimés !"
fixed-list-none: "&eVous n avez pas d effets fixes !" fixed-list-none: "&eVous n'avez pas d'effets fixes !"
fixed-list-success: "&eVous avez des effets fixes avec ces IDs :&b{0}" fixed-list-success: "&eVous avez des effets fixes avec ces IDs :&b{0}"
fixed-info-invalid: "&cImpossible de obtenir l information, vous n avez pas de particules fixes avec l ID &b{0}& c!" fixed-info-invalid: "&cImpossible d'obtenir l'information, vous n'avez pas de particules fixes avec l'ID &b{0}& c!"
fixed-info-no-args: "&cVous n avez pas rentrée d ID pour obtenir d infomations !" fixed-info-no-args: "&cVous n'avez pas rentrée d'ID pour obtenir d'infomations !"
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 !" 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 !"
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}" 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}"
fixed-clear-no-permission: "&cVous n avez la permission pour supprimer les effets proches !" fixed-clear-no-permission: "&cVous n'avez la permission pour supprimer les effets proches !"
fixed-clear-no-args: "&cVous n avez pas rentré de rayon !" fixed-clear-no-args: "&cVous n'avez pas rentré de rayon !"
fixed-clear-invalid-args: "&cLe rayon rentré n est pas valide, il doit être un nombre rond !" fixed-clear-invalid-args: "&cLe rayon rentré n'est pas valide, il doit être un nombre rond !"
fixed-clear-success: "&b{0} &aeffets on été supprimés dans un rayon &b{1} &cblocs !" fixed-clear-success: "&b{0} &aeffets ont été supprimés dans un rayon &b{1} &cblocs !"
fixed-no-permission: "&cVous n avez pas la permission d ajouter des effets fixes !" fixed-no-permission: "&cVous n'avez pas la permission d'ajouter des effets fixes !"
fixed-max-reached: "&cVous avez atteint le nombre maximum de particules fixes !" fixed-max-reached: "&cVous avez atteint le nombre maximum de particules fixes !"
fixed-invalid-command: "&cArguments invalides pour la commande &b/pp fixed&c!" fixed-invalid-command: "&cArguments invalides pour la commande &b/pp fixed&c!"
@ -210,13 +211,15 @@ fixed-invalid-command: "&cArguments invalides pour la commande &b/pp fixed&c!"
update-available: "&eLa version (&b{0}&e) est disponible ! vous utilisez la version &bv{1}&d. https://www.spigotmc.org/resources/playerparticles.40261/" update-available: "&eLa version (&b{0}&e) est disponible ! vous utilisez la version &bv{1}&d. https://www.spigotmc.org/resources/playerparticles.40261/"
# GUI # GUI
gui-disabled: "&cL interface du plugin à été désactivée !" gui-disabled: "&cL'interface du plugin à été désactivée !"
gui-color-icon-name: "&a" gui-color-icon-name: "&a"
gui-color-info: "&e" gui-color-info: "&e"
gui-color-subtext: "&b" gui-color-subtext: "&b"
gui-color-unavailable: "&c" gui-color-unavailable: "&c"
gui-commands-info: "Affichez des informations avec &b/pp help" gui-commands-info: "Affichez des informations avec &b/pp help"
gui-back-button: "Retour en arrière" gui-back-button: "Retour en arrière"
gui-next-page-button: "Page Suivante ({0}/{1})"
gui-previous-page-button: "Page Précédente ({0}/{1})"
gui-click-to-load: "Cliquez pour charger : {0}" gui-click-to-load: "Cliquez pour charger : {0}"
gui-shift-click-to-delete: "Touche SHIFT + clic-gauche pour effacer un effet" gui-shift-click-to-delete: "Touche SHIFT + clic-gauche pour effacer un effet"
gui-particle-info: " - ID: &b{0} &eEffet: &b{1} &eStyle: &b{2} &eParamètre: &b{3}" gui-particle-info: " - ID: &b{0} &eEffet: &b{1} &eStyle: &b{2} &eParamètre: &b{3}"
@ -224,14 +227,14 @@ gui-playerparticles: "PlayerParticles"
gui-active-particles: "Particules actives: &b{0}" gui-active-particles: "Particules actives: &b{0}"
gui-saved-groups: "Groupes sauvegardés: &b{0}" gui-saved-groups: "Groupes sauvegardés: &b{0}"
gui-fixed-effects: "Effets fixes: &b{0}" gui-fixed-effects: "Effets fixes: &b{0}"
gui-edit-primary-effect: "Editez l effet primaire" gui-edit-primary-effect: "Editez l'effet primaire"
gui-edit-primary-effect-description: "Editez l effet d une de vos particules primaire" gui-edit-primary-effect-description: "Editez l effet d une de vos particules primaire"
gui-edit-primary-style: "Editez le style primaire" gui-edit-primary-style: "Editez le style primaire"
gui-edit-primary-style-missing-effect: "Vous devez d abord sélectionner un effet !" gui-edit-primary-style-missing-effect: "Vous devez d'abord sélectionner un effet !"
gui-edit-primary-style-description: "Editez le style d une particule primaire" gui-edit-primary-style-description: "Editez le style d'une particule primaire"
gui-edit-primary-data: "Editez les paramètres d une particules primaire" gui-edit-primary-data: "Editez les paramètres d'une particules primaire"
gui-edit-primary-data-missing-effect: "Vous devez d abord sélectionner un effet" gui-edit-primary-data-missing-effect: "Vous devez d'abord sélectionner un effet"
gui-edit-primary-data-unavailable: "Votre effet primaire n est pas paramétrable" gui-edit-primary-data-unavailable: "Votre effet primaire n'est pas paramétrable"
gui-edit-primary-data-description: "Editer les paramères de votre effet primaire" gui-edit-primary-data-description: "Editer les paramères de votre effet primaire"
gui-manage-your-particles: "Gérez vos particules" gui-manage-your-particles: "Gérez vos particules"
gui-manage-your-particles-description: "Créez, éditez, et supprimez vos particules" gui-manage-your-particles-description: "Créez, éditez, et supprimez vos particules"
@ -240,7 +243,7 @@ gui-manage-your-groups-description: "Créez, éditez, et supprimez vos groupes p
gui-load-a-preset-group: "Chargez un groupe de presets" gui-load-a-preset-group: "Chargez un groupe de presets"
gui-load-a-preset-group-description: "Chargez un groupe de particules déjà fait" gui-load-a-preset-group-description: "Chargez un groupe de particules déjà fait"
gui-save-group: "Sauvegardez un nouveau groupe" gui-save-group: "Sauvegardez un nouveau groupe"
gui-save-group-description: "Cliquez pour sauvegardez un nouveau groupe. Vous allez être invité\na écrire un nouveau nom dans le tchat." gui-save-group-description: "Cliquez pour sauvegardez un nouveau groupe. Vous allez être invité\nà écrire un nouveau nom dans le tchat."
gui-save-group-full: "Vous avez atteint le nombre maximal de groupe !" gui-save-group-full: "Vous avez atteint le nombre maximal de groupe !"
gui-save-group-no-particles: "Vous avez aucunes particules appliquées" gui-save-group-no-particles: "Vous avez aucunes particules appliquées"
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)" 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)"
@ -249,8 +252,8 @@ gui-reset-particles-description: "Supprimez vos particules actives"
gui-particle-name: "Particule #{0}" gui-particle-name: "Particule #{0}"
gui-click-to-edit-particle: "Cliquez pour éditer cette particule" gui-click-to-edit-particle: "Cliquez pour éditer cette particule"
gui-editing-particle: "Edition particule #{0}" gui-editing-particle: "Edition particule #{0}"
gui-edit-effect: "Editez l effet" gui-edit-effect: "Editez l'effet"
gui-edit-effect-description: "Cliquez pour éditer l effet de cette particule" gui-edit-effect-description: "Cliquez pour éditer l'effet de cette particule"
gui-edit-style: "Editez le style" gui-edit-style: "Editez le style"
gui-edit-style-description: "Cliquez pour éditer le style de cette particule" gui-edit-style-description: "Cliquez pour éditer le style de cette particule"
gui-edit-data: "Editez les paramères" gui-edit-data: "Editez les paramères"
@ -267,10 +270,6 @@ gui-select-style-description: "Mets le style de la particule à &b{0}"
gui-select-data: "Sélectionnez les paramètres" gui-select-data: "Sélectionnez les paramètres"
gui-select-data-description: "Mets les paramètres de la particule à &b{0}" gui-select-data-description: "Mets les paramètres de la particule à &b{0}"
gui-select-data-note: "note #{0}" gui-select-data-note: "note #{0}"
gui-select-data-randomize-items: "Mélangez les items"
gui-select-data-randomize-items-description: "Mélangez les items affichés"
gui-select-data-randomize-blocks: "Mélangez les blocs"
gui-select-data-randomize-blocks-description: "Mélangez les blocs affichés"
gui-edit-data-color-red: "&crouge" gui-edit-data-color-red: "&crouge"
gui-edit-data-color-orange: "&6orange" gui-edit-data-color-orange: "&6orange"
gui-edit-data-color-yellow: "&ejaune" gui-edit-data-color-yellow: "&ejaune"

View file

@ -78,6 +78,7 @@ edit-success-data: "&aHạt hiệu ứng của bạn với ID &b{0} &ađã thanh
# Group Command # Group Command
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!" 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!"
group-no-permission: "&cBạn không có quyền for 1 effect, style để sử dụng nhóm sẵn &b{0}&c!"
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!" 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!"
group-reserved: "&cGroup tên &bactive &ckhông thể được sử dụng!" group-reserved: "&cGroup tên &bactive &ckhông thể được sử dụng!"
group-no-name: "&cBạn đã không cung cấp tên group! &b/pp {0} <groupName>" group-no-name: "&cBạn đã không cung cấp tên group! &b/pp {0} <groupName>"
@ -95,8 +96,8 @@ group-list-output: "&eBạn đã lưu các Group sau: &b{0}"
group-list-presets: "&eCác preset group có sẵn: &b{0}" group-list-presets: "&eCác preset group có sẵn: &b{0}"
# Reload Command # Reload Command
reload-success: "&aCác plugin đã được tải lại!" reload-success: "&aĐã tải lại plugins!"
reload-no-permission: "&cBạn không có quyền tải lại các cài đặt plugin!" reload-no-permission: "&cBạn không có quyền để tải lại plugins!"
# Remove Command # Remove Command
remove-no-args: "&cBạn không chỉ định IDs để xóa! &b/pp remove <ID>" remove-no-args: "&cBạn không chỉ định IDs để xóa! &b/pp remove <ID>"
@ -217,6 +218,8 @@ gui-color-subtext: "&b"
gui-color-unavailable: "&c" gui-color-unavailable: "&c"
gui-commands-info: "Hiển thị thêm các lệnh bằng cách gõ &b/pp help" gui-commands-info: "Hiển thị thêm các lệnh bằng cách gõ &b/pp help"
gui-back-button: "Quay trở về" gui-back-button: "Quay trở về"
gui-next-page-button: "Trang tiếp theo ({0}/{1})"
gui-previous-page-button: "Trang trước ({0}/{1})"
gui-click-to-load: "Nhấn để tải {0} Hạt hiệu ứng sau:" gui-click-to-load: "Nhấn để tải {0} Hạt hiệu ứng sau:"
gui-shift-click-to-delete: "Shift Click để xóa" gui-shift-click-to-delete: "Shift Click để xóa"
gui-particle-info: " - ID: &b{0} &eEffect: &b{1} &eStyle: &b{2} &eData: &b{3}" gui-particle-info: " - ID: &b{0} &eEffect: &b{1} &eStyle: &b{2} &eData: &b{3}"
@ -267,10 +270,6 @@ gui-select-style-description: "Thiết lập Kiểu hiệu ứng của Hạt th
gui-select-data: "Chọn Dữ liệu của Hạt" gui-select-data: "Chọn Dữ liệu của Hạt"
gui-select-data-description: "Thiết lập DỮ liệu của Hạt thành &b{0}" gui-select-data-description: "Thiết lập DỮ liệu của Hạt thành &b{0}"
gui-select-data-note: "note #{0}" gui-select-data-note: "note #{0}"
gui-select-data-randomize-items: "Vật phẩm ngẫu nhiên"
gui-select-data-randomize-items-description: "Đã hiển thị vật phẩm ngẫu nhiên"
gui-select-data-randomize-blocks: "Khối ngẫu nhiên"
gui-select-data-randomize-blocks-description: "Đã hiển thị khối ngẫu nhiên"
gui-edit-data-color-red: "&cĐỏ mạnh mẽ" gui-edit-data-color-red: "&cĐỏ mạnh mẽ"
gui-edit-data-color-orange: "&6Cam dịu dàng" gui-edit-data-color-orange: "&6Cam dịu dàng"
gui-edit-data-color-yellow: "&eVàng yêu thương" gui-edit-data-color-yellow: "&eVàng yêu thương"

View file

@ -1,8 +1,8 @@
name: PlayerParticles name: PlayerParticles
main: com.esophose.playerparticles.PlayerParticles main: com.esophose.playerparticles.PlayerParticles
version: 6.3 version: 6.4
api-version: 1.13 api-version: 1.13
description: Display particles around your player using customized styles and data! description: Display particles around your player and blocks using customized styles and data!
author: Esophose author: Esophose
website: https://www.spigotmc.org/resources/playerparticles.40261/ website: https://www.spigotmc.org/resources/playerparticles.40261/
commands: commands:
@ -10,3 +10,4 @@ commands:
description: The main PlayerParticles command. By default, opens the GUI. description: The main PlayerParticles command. By default, opens the GUI.
ppo: ppo:
description: Allows executing a /pp command for another player. description: Allows executing a /pp command for another player.
permission: playerparticles.other