Locale refactoring

This commit is contained in:
Esophose 2019-12-12 19:32:53 -07:00
parent ea4c8e293c
commit ad4b8a9def
109 changed files with 1266 additions and 3384 deletions

View file

@ -1,27 +1,33 @@
/*
* TODO: v6.4
* TODO: v7.0
* * Refactored and cleaned up code to remove static abuse
* * Changed the plugin's package name
* * Added an API, accessible through the dev.esophose.playerparticles.api.PlayerParticlesAPI class
* + Add ability to create/manage fixed effects from the GUI
* * Convert fixed effect ids into names
* + Add command '/pp fixed teleport <id>' that requires the permission playerparticles.fixed.teleport
* + Add named colors to the color data
* + Add named colors to the color data autocomplete
* * Clean up duplicated command parsing
*/
/*
* TODO: v6.5
* + Add effect/style name customization through config files
* + Add effect/style settings folder that lets you disable effects/style and edit style properties
* + Added PlaceholderAPI support for message strings
* + Added setting to disable particles while in combat
*/
package dev.esophose.playerparticles;
import dev.esophose.playerparticles.gui.hook.PlayerChatHook;
import dev.esophose.playerparticles.manager.CommandManager;
import dev.esophose.playerparticles.manager.ConfigurationManager;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.DataMigrationManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.Manager;
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.PluginUpdateManager;
import dev.esophose.playerparticles.manager.SettingManager.Setting;
import dev.esophose.playerparticles.particles.PPlayerMovementListener;
import dev.esophose.playerparticles.util.Metrics;
import java.io.File;
@ -53,16 +59,16 @@ public class PlayerParticles extends JavaPlugin {
public void onEnable() {
INSTANCE = this;
this.managers = new HashMap<>();
this.reload();
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PPlayerMovementListener(), this);
pm.registerEvents(new PlayerChatHook(), this);
this.managers = new HashMap<>();
if (Setting.SEND_METRICS.getBoolean())
new Metrics(this);
this.reload();
}
@Override
@ -111,10 +117,17 @@ public class PlayerParticles extends JavaPlugin {
this.managers.values().forEach(Manager::disable);
this.managers.clear();
this.getManager(CommandManager.class);
this.getManager(ParticleStyleManager.class);
this.getManager(ParticleGroupPresetManager.class);
this.getManager(ConfigurationManager.class);
this.getManager(DataMigrationManager.class);
this.getManager(PluginUpdateManager.class);
this.getManager(ParticleManager.class);
this.getManager(LocaleManager.class);
this.getManager(ConfigurationManager.class);
this.getManager(PermissionManager.class);
this.getManager(PluginUpdateManager.class);
PlayerChatHook.setup();
}

View file

@ -1,19 +1,9 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
@ -22,6 +12,14 @@ import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
public class AddCommandModule implements CommandModule {
@ -32,28 +30,29 @@ public class AddCommandModule implements CommandModule {
}
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
int maxParticlesAllowed = permissionManager.getMaxParticlesAllowed(pplayer.getPlayer());
if (pplayer.getActiveParticles().size() >= maxParticlesAllowed) {
LangManager.sendMessage(pplayer, Lang.ADD_REACHED_MAX, maxParticlesAllowed);
localeManager.sendMessage(pplayer, "add-reached-max", StringPlaceholders.single("amount", maxParticlesAllowed));
return;
}
ParticleEffect effect = ParticleEffect.fromName(args[0]);
if (effect == null) {
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
localeManager.sendMessage(pplayer, "effect-invalid", StringPlaceholders.single("effect", args[0]));
return;
} else if (!permissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
LangManager.sendMessage(pplayer, Lang.EFFECT_NO_PERMISSION, effect.getName());
localeManager.sendMessage(pplayer, "effect-no-permission", StringPlaceholders.single("effect", effect.getName()));
return;
}
ParticleStyle style = ParticleStyle.fromName(args[1]);
if (style == null) {
LangManager.sendMessage(pplayer, Lang.STYLE_INVALID, args[1]);
localeManager.sendMessage(pplayer, "style-invalid", StringPlaceholders.single("style", args[1]));
return;
} else if (!permissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
LangManager.sendMessage(pplayer, Lang.STYLE_NO_PERMISSION, args[1]);
localeManager.sendMessage(pplayer, "style-no-permission", StringPlaceholders.single("style", args[1]));
return;
}
@ -74,12 +73,12 @@ public class AddCommandModule implements CommandModule {
try {
note = Integer.parseInt(args[2]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
localeManager.sendMessage(pplayer, "data-invalid-note");
return;
}
if (note < 0 || note > 24) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
localeManager.sendMessage(pplayer, "data-invalid-note");
return;
}
@ -98,12 +97,12 @@ public class AddCommandModule implements CommandModule {
g = Integer.parseInt(args[3]);
b = Integer.parseInt(args[4]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_COLOR);
localeManager.sendMessage(pplayer, "data-invalid-color");
return;
}
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_COLOR);
localeManager.sendMessage(pplayer, "data-invalid-color");
return;
}
@ -116,7 +115,7 @@ public class AddCommandModule implements CommandModule {
blockData = ParticleUtils.closestMatch(args[2]);
if (blockData == null || !blockData.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_BLOCK);
localeManager.sendMessage(pplayer, "data-invalid-block");
return;
}
} else if (effect == ParticleEffect.ITEM) {
@ -124,7 +123,7 @@ public class AddCommandModule implements CommandModule {
itemData = ParticleUtils.closestMatch(args[2]);
if (itemData == null || itemData.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_ITEM);
localeManager.sendMessage(pplayer, "data-invalid-item");
return;
}
}
@ -135,11 +134,14 @@ public class AddCommandModule implements CommandModule {
ParticlePair newParticle = new ParticlePair(pplayer.getUniqueId(), pplayer.getNextActiveParticleId(), effect, style, itemData, blockData, colorData, noteColorData);
group.getParticles().add(newParticle);
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
LangManager.sendMessage(pplayer, Lang.ADD_PARTICLE_APPLIED, newParticle.getEffect().getName(), newParticle.getStyle().getName(), newParticle.getDataString());
StringPlaceholders addParticlePlaceholders = StringPlaceholders.builder("effect", newParticle.getEffect().getName())
.addPlaceholder("style", newParticle.getStyle().getName())
.addPlaceholder("data", newParticle.getDataString()).build();
localeManager.sendMessage(pplayer, "add-particle-applied", addParticlePlaceholders);
if (PlayerParticles.getInstance().getManager(ParticleStyleManager.class).isCustomHandled(newParticle.getStyle())) {
LangManager.sendMessage(pplayer, Lang.STYLE_EVENT_SPAWNING_INFO, newParticle.getStyle().getName());
localeManager.sendMessage(pplayer, "style-event-spawning-info", StringPlaceholders.single("style", newParticle.getStyle().getName()));
}
}

View file

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

View file

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

View file

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

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.CommandManager;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.util.StringUtil;
public class DefaultCommandModule implements CommandModule {

View file

@ -1,30 +1,30 @@
package dev.esophose.playerparticles.command;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
public class EditCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (args.length < 3) {
CommandModule.printUsage(pplayer, this);
return;
@ -34,17 +34,17 @@ public class EditCommandModule implements CommandModule {
try {
id = Integer.parseInt(args[0]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.ID_INVALID);
localeManager.sendMessage(pplayer, "id-invalid");
return;
}
if (id <= 0) {
LangManager.sendMessage(pplayer, Lang.ID_INVALID);
localeManager.sendMessage(pplayer, "id-invalid");
return;
}
if (pplayer.getActiveParticle(id) == null) {
LangManager.sendMessage(pplayer, Lang.ID_UNKNOWN, id);
localeManager.sendMessage(pplayer, "id-unknown", StringPlaceholders.single("id", id));
return;
}
@ -62,7 +62,7 @@ public class EditCommandModule implements CommandModule {
this.editData(pplayer, id, cmdArgs);
break;
default:
LangManager.sendMessage(pplayer, Lang.EDIT_INVALID_PROPERTY, args[1]);
localeManager.sendMessage(pplayer, "edit-invalid-property", StringPlaceholders.single("prop", args[1]));
break;
}
}
@ -75,12 +75,14 @@ public class EditCommandModule implements CommandModule {
* @param args The rest of the args
*/
private void editEffect(PPlayer pplayer, int id, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
ParticleEffect effect = ParticleEffect.fromName(args[0]);
if (effect == null) {
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
localeManager.sendMessage(pplayer, "effect-invalid", StringPlaceholders.single("effect", args[0]));
return;
} else if (!PlayerParticles.getInstance().getManager(PermissionManager.class).hasEffectPermission(pplayer.getPlayer(), effect)) {
LangManager.sendMessage(pplayer, Lang.EFFECT_NO_PERMISSION, effect.getName());
localeManager.sendMessage(pplayer, "effect-no-permission", StringPlaceholders.single("effect", effect.getName()));
return;
}
@ -93,7 +95,7 @@ public class EditCommandModule implements CommandModule {
}
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
LangManager.sendMessage(pplayer, Lang.EDIT_SUCCESS_EFFECT, id, effect.getName());
localeManager.sendMessage(pplayer, "edit-success-effect", StringPlaceholders.builder("id", id).addPlaceholder("effect", effect.getName()).build());
}
/**
@ -104,12 +106,14 @@ public class EditCommandModule implements CommandModule {
* @param args The rest of the args
*/
private void editStyle(PPlayer pplayer, int id, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
ParticleStyle style = ParticleStyle.fromName(args[0]);
if (style == null) {
LangManager.sendMessage(pplayer, Lang.STYLE_INVALID, args[0]);
localeManager.sendMessage(pplayer, "style-invalid", StringPlaceholders.single("style", args[0]));
return;
} else if (!PlayerParticles.getInstance().getManager(PermissionManager.class).hasStylePermission(pplayer.getPlayer(), style)) {
LangManager.sendMessage(pplayer, Lang.STYLE_NO_PERMISSION, style.getName());
localeManager.sendMessage(pplayer, "style-no-permission", StringPlaceholders.single("style", style.getName()));
return;
}
@ -122,7 +126,7 @@ public class EditCommandModule implements CommandModule {
}
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
LangManager.sendMessage(pplayer, Lang.EDIT_SUCCESS_STYLE, id, style.getName());
localeManager.sendMessage(pplayer, "edit-success-style", StringPlaceholders.builder("id", id).addPlaceholder("style", style.getName()).build());
}
/**
@ -133,6 +137,8 @@ public class EditCommandModule implements CommandModule {
* @param args The rest of the args
*/
private void editData(PPlayer pplayer, int id, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
Material itemData = null;
Material blockData = null;
OrdinaryColor colorData = null;
@ -151,12 +157,12 @@ public class EditCommandModule implements CommandModule {
try {
note = Integer.parseInt(args[0]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
localeManager.sendMessage(pplayer, "data-invalid-note");
return;
}
if (note < 0 || note > 24) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
localeManager.sendMessage(pplayer, "data-invalid-note");
return;
}
@ -175,12 +181,12 @@ public class EditCommandModule implements CommandModule {
g = Integer.parseInt(args[1]);
b = Integer.parseInt(args[2]);
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_COLOR);
localeManager.sendMessage(pplayer, "data-invalid-color");
return;
}
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_COLOR);
localeManager.sendMessage(pplayer, "data-invalid-color");
return;
}
@ -193,7 +199,7 @@ public class EditCommandModule implements CommandModule {
blockData = ParticleUtils.closestMatch(args[0]);
if (blockData == null || !blockData.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_BLOCK);
localeManager.sendMessage(pplayer, "data-invalid-block");
return;
}
} else if (effect == ParticleEffect.ITEM) {
@ -201,7 +207,7 @@ public class EditCommandModule implements CommandModule {
itemData = ParticleUtils.closestMatch(args[0]);
if (itemData == null || itemData.isBlock()) throw new Exception();
} catch (Exception e) {
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_ITEM);
localeManager.sendMessage(pplayer, "data-invalid-item");
return;
}
}
@ -221,7 +227,7 @@ public class EditCommandModule implements CommandModule {
}
PlayerParticles.getInstance().getManager(DataManager.class).saveParticleGroup(pplayer.getUniqueId(), group);
LangManager.sendMessage(pplayer, Lang.EDIT_SUCCESS_DATA, id, updatedDataString);
localeManager.sendMessage(pplayer, "edit-success-data", StringPlaceholders.builder("id", id).addPlaceholder("data", updatedDataString).build());
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,30 +1,29 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import org.apache.commons.lang.StringUtils;
import org.bukkit.util.StringUtil;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.bukkit.util.StringUtil;
public class RemoveCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
if (args.length == 0) {
LangManager.sendMessage(pplayer, Lang.REMOVE_NO_ARGS);
localeManager.sendMessage(pplayer, "remove-no-args");
return;
}
@ -33,12 +32,12 @@ public class RemoveCommandModule implements CommandModule {
try {
id = Integer.parseInt(args[0]);
} catch (Exception ex) {
LangManager.sendMessage(pplayer, Lang.ID_INVALID);
localeManager.sendMessage(pplayer, "id-invalid");
return;
}
if (id <= 0) {
LangManager.sendMessage(pplayer, Lang.ID_INVALID);
localeManager.sendMessage(pplayer, "id-invalid");
return;
}
@ -53,12 +52,12 @@ public class RemoveCommandModule implements CommandModule {
}
if (!removed) {
LangManager.sendMessage(pplayer, Lang.ID_UNKNOWN, id);
localeManager.sendMessage(pplayer, "id-unknown", StringPlaceholders.single("id", id));
return;
}
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
LangManager.sendMessage(pplayer, Lang.REMOVE_ID_SUCCESS, id);
localeManager.sendMessage(pplayer, "remove-id-success", StringPlaceholders.single("id", id));
} else { // Removing by effect/style name
ParticleEffect effect = ParticleEffect.fromName(args[0]);
ParticleStyle style = ParticleStyle.fromName(args[0]);
@ -75,9 +74,9 @@ public class RemoveCommandModule implements CommandModule {
if (removedCount > 0) {
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
LangManager.sendMessage(pplayer, Lang.REMOVE_EFFECT_SUCCESS, removedCount, effect.getName());
localeManager.sendMessage(pplayer, "remove-effect-success", StringPlaceholders.builder("amount", removedCount).addPlaceholder("effect", effect.getName()).build());
} else {
LangManager.sendMessage(pplayer, Lang.REMOVE_EFFECT_NONE, effect.getName());
localeManager.sendMessage(pplayer, "remove-effect-none", StringPlaceholders.single("effect", effect.getName()));
}
} else if (style != null) {
int removedCount = 0;
@ -91,12 +90,12 @@ public class RemoveCommandModule implements CommandModule {
if (removedCount > 0) {
dataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
LangManager.sendMessage(pplayer, Lang.REMOVE_STYLE_SUCCESS, removedCount, style.getName());
localeManager.sendMessage(pplayer, "remove-style-success", StringPlaceholders.builder("amount", removedCount).addPlaceholder("style", style.getName()).build());
} else {
LangManager.sendMessage(pplayer, Lang.REMOVE_STYLE_NONE, style.getName());
localeManager.sendMessage(pplayer, "remove-style-none", StringPlaceholders.single("style", style.getName()));
}
} else {
LangManager.sendMessage(pplayer, Lang.REMOVE_UNKNOWN, args[0]);
localeManager.sendMessage(pplayer, "remove-unknown", StringPlaceholders.single("name", args[0]));
}
}
}

View file

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

View file

@ -1,15 +1,13 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import org.bukkit.entity.Player;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
public class StylesCommandModule implements CommandModule {
@ -26,7 +24,7 @@ public class StylesCommandModule implements CommandModule {
toSend = new StringBuilder(toSend.substring(0, toSend.length() - 2));
}
LangManager.sendMessage(pplayer, Lang.STYLE_LIST, toSend.toString());
PlayerParticles.getInstance().getManager(LocaleManager.class).sendMessage(pplayer, "style-list", StringPlaceholders.single("styles", toSend.toString()));
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {

View file

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

View file

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

View file

@ -1,20 +1,19 @@
package dev.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
public class WorldsCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
if (permissionManager.getDisabledWorlds() == null || permissionManager.getDisabledWorlds().isEmpty()) {
LangManager.sendMessage(pplayer, Lang.DISABLED_WORLDS_NONE);
localeManager.sendMessage(pplayer, "disabled-worlds-none");
return;
}
@ -24,7 +23,7 @@ public class WorldsCommandModule implements CommandModule {
}
if (worlds.length() > 2) worlds = new StringBuilder(worlds.substring(0, worlds.length() - 2));
LangManager.sendCustomMessage(pplayer, LangManager.getText(Lang.DISABLED_WORLDS) + " " + worlds);
localeManager.sendCustomMessage(pplayer, localeManager.getLocaleMessage("disabled-worlds") + " " + worlds);
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {

View file

@ -1,6 +1,10 @@
package dev.esophose.playerparticles.config;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
@ -8,10 +12,6 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class CommentedConfigurationSection implements ConfigurationSection {
protected ConfigurationSection config;
@ -351,6 +351,21 @@ public class CommentedConfigurationSection implements ConfigurationSection {
return this.config.isColor(s);
}
@Override
public Location getLocation(String path) {
return this.getSerializable(path, Location.class);
}
@Override
public Location getLocation(String path, Location def) {
return this.getSerializable(path, Location.class, def);
}
@Override
public boolean isLocation(String path) {
return this.getSerializable(path, Location.class) != null;
}
@Override
public CommentedConfigurationSection getConfigurationSection(String s) {
ConfigurationSection section = this.config.getConfigurationSection(s);

View file

@ -1,12 +1,11 @@
package dev.esophose.playerparticles.config;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import org.yaml.snakeyaml.DumperOptions;
import java.io.File;
import java.io.Reader;
import java.lang.reflect.Field;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import org.yaml.snakeyaml.DumperOptions;
public class CommentedFileConfiguration extends CommentedConfigurationSection {

View file

@ -1,7 +1,5 @@
package dev.esophose.playerparticles.config;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
@ -11,10 +9,14 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.plugin.java.JavaPlugin;
public class CommentedFileConfigurationHelper {
@ -206,11 +208,9 @@ public class CommentedFileConfigurationHelper {
}
}
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(file.getAbsolutePath()))) {
writer.write(stringBuilder.toString());
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}

View file

@ -2,10 +2,9 @@ package dev.esophose.playerparticles.database;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.bukkit.plugin.Plugin;
import java.sql.Connection;
import java.sql.SQLException;
import org.bukkit.plugin.Plugin;
public class MySQLConnector implements DatabaseConnector {

View file

@ -1,11 +1,10 @@
package dev.esophose.playerparticles.database;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.bukkit.plugin.Plugin;
public class SQLiteConnector implements DatabaseConnector {

View file

@ -3,7 +3,6 @@ package dev.esophose.playerparticles.database.migrations;
import dev.esophose.playerparticles.database.DataMigration;
import dev.esophose.playerparticles.database.DatabaseConnector;
import dev.esophose.playerparticles.database.SQLiteConnector;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@ -62,25 +61,25 @@ public class _1_InitialMigration extends DataMigration {
if (hasTables) {
try (Statement statement = connection.createStatement()) {
if (connector instanceof SQLiteConnector) {
statement.addBatch("ALTER TABLE pp_settings RENAME TO " + tablePrefix + "_settings");
statement.addBatch("ALTER TABLE pp_particle RENAME TO " + tablePrefix + "_particle");
statement.addBatch("ALTER TABLE pp_group RENAME TO " + tablePrefix + "_group");
statement.addBatch("ALTER TABLE pp_fixed RENAME TO " + tablePrefix + "_fixed");
statement.addBatch("ALTER TABLE pp_settings RENAME TO " + tablePrefix + "settings");
statement.addBatch("ALTER TABLE pp_particle RENAME TO " + tablePrefix + "particle");
statement.addBatch("ALTER TABLE pp_group RENAME TO " + tablePrefix + "group");
statement.addBatch("ALTER TABLE pp_fixed RENAME TO " + tablePrefix + "fixed");
} else {
statement.addBatch("RENAME TABLE pp_settings TO " + tablePrefix + "_settings");
statement.addBatch("RENAME TABLE pp_particle TO " + tablePrefix + "_particle");
statement.addBatch("RENAME TABLE pp_group TO " + tablePrefix + "_group");
statement.addBatch("RENAME TABLE pp_fixed TO " + tablePrefix + "_fixed");
statement.addBatch("RENAME TABLE pp_settings TO " + tablePrefix + "settings");
statement.addBatch("RENAME TABLE pp_particle TO " + tablePrefix + "particle");
statement.addBatch("RENAME TABLE pp_group TO " + tablePrefix + "group");
statement.addBatch("RENAME TABLE pp_fixed TO " + tablePrefix + "fixed");
}
statement.executeBatch();
}
} else { // Otherwise create them
try (Statement createStatement = connection.createStatement()) {
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "_settings (player_uuid VARCHAR(36), particles_hidden TINYINT)");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "_particle (uuid VARCHAR(36), group_uuid VARCHAR(36), id SMALLINT, effect VARCHAR(100), style VARCHAR(100), item_material VARCHAR(100), block_material VARCHAR(100), note SMALLINT, r SMALLINT, g SMALLINT, b SMALLINT, PRIMARY KEY(uuid))");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "_group (uuid VARCHAR(36), owner_uuid VARCHAR(36), name VARCHAR(100), PRIMARY KEY(uuid))");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "_fixed (owner_uuid VARCHAR(36), id SMALLINT, particle_uuid VARCHAR(36), world VARCHAR(100), xPos DOUBLE, yPos DOUBLE, zPos DOUBLE, PRIMARY KEY(owner_uuid, id), FOREIGN KEY(particle_uuid) REFERENCES pp_particle(uuid) ON DELETE CASCADE)");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "settings (player_uuid VARCHAR(36), particles_hidden TINYINT)");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "particle (uuid VARCHAR(36), group_uuid VARCHAR(36), id SMALLINT, effect VARCHAR(100), style VARCHAR(100), item_material VARCHAR(100), block_material VARCHAR(100), note SMALLINT, r SMALLINT, g SMALLINT, b SMALLINT, PRIMARY KEY(uuid))");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "group (uuid VARCHAR(36), owner_uuid VARCHAR(36), name VARCHAR(100), PRIMARY KEY(uuid))");
createStatement.addBatch("CREATE TABLE IF NOT EXISTS " + tablePrefix + "fixed (owner_uuid VARCHAR(36), id SMALLINT, particle_uuid VARCHAR(36), world VARCHAR(100), xPos DOUBLE, yPos DOUBLE, zPos DOUBLE, PRIMARY KEY(owner_uuid, id), FOREIGN KEY(particle_uuid) REFERENCES pp_particle(uuid) ON DELETE CASCADE)");
createStatement.executeBatch();
}
}

View file

@ -1,8 +1,8 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.gui.GuiInventoryEditData.ColorData;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemFlag;
@ -10,8 +10,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Dye;
import dev.esophose.playerparticles.gui.GuiInventoryEditData.ColorData;
public class GuiActionButton {
private int slot;

View file

@ -1,8 +1,10 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.ParticleUtils;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -13,12 +15,8 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import dev.esophose.playerparticles.manager.SettingManager.Setting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.ParticleUtils;
public abstract class GuiInventory implements InventoryHolder {
protected enum BorderColor {
WHITE(0, "WHITE_STAINED_GLASS_PANE"),
ORANGE(1, "ORANGE_STAINED_GLASS_PANE"),

View file

@ -1,34 +1,35 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("deprecation")
public class GuiInventoryDefault extends GuiInventory {
public GuiInventoryDefault(PPlayer pplayer) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_PLAYERPARTICLES)));
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-playerparticles")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.WHITE);
@ -43,13 +44,13 @@ public class GuiInventoryDefault extends GuiInventory {
SkullMeta currentIconMeta = (SkullMeta) headIcon.getItemMeta();
if (currentIconMeta != null) {
currentIconMeta.setDisplayName(LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + pplayer.getPlayer().getName());
currentIconMeta.setDisplayName(localeManager.getLocaleMessage("gui-color-icon-name") + pplayer.getPlayer().getName());
String[] currentIconLore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_ACTIVE_PARTICLES, pplayer.getActiveParticles().size()),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SAVED_GROUPS, pplayer.getParticleGroups().size() - 1),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_FIXED_EFFECTS, pplayer.getFixedEffectIds().size()),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-active-particles", StringPlaceholders.single("amount", pplayer.getActiveParticles().size())),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-saved-groups", StringPlaceholders.single("amount", pplayer.getParticleGroups().size() - 1)),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-fixed-effects", StringPlaceholders.single("amount", pplayer.getFixedEffectIds().size())),
" ",
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_COMMANDS_INFO)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-commands-info")
};
currentIconMeta.setLore(GuiActionButton.parseLore(currentIconLore));
currentIconMeta.setOwner(pplayer.getPlayer().getName());
@ -81,9 +82,9 @@ public class GuiInventoryDefault extends GuiInventory {
GuiActionButton manageYourParticlesButton = new GuiActionButton(
manageParticlesSlot,
GuiIcon.PARTICLES.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES_DESCRIPTION)},
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryManageParticles(pplayer)));
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-manage-your-particles"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-manage-your-particles-description")},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryManageParticles(pplayer)));
this.actionButtons.add(manageYourParticlesButton);
// Manage Your Groups button
@ -91,9 +92,9 @@ public class GuiInventoryDefault extends GuiInventory {
GuiActionButton manageYourGroupsButton = new GuiActionButton(
manageGroupsSlot,
GuiIcon.GROUPS.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS_DESCRIPTION)},
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryManageGroups(pplayer)));
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-manage-your-groups"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-manage-your-groups-description")},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryManageGroups(pplayer)));
this.actionButtons.add(manageYourGroupsButton);
}
@ -102,9 +103,9 @@ public class GuiInventoryDefault extends GuiInventory {
GuiActionButton loadPresetGroups = new GuiActionButton(
loadPresetGroupSlot,
GuiIcon.PRESET_GROUPS.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP_DESCRIPTION)},
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryLoadPresetGroups(pplayer, false)));
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-load-a-preset-group"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-load-a-preset-group-description")},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryLoadPresetGroups(pplayer, false)));
this.actionButtons.add(loadPresetGroups);
}
@ -116,12 +117,12 @@ public class GuiInventoryDefault extends GuiInventory {
GuiActionButton editPrimaryEffect = new GuiActionButton(
38,
GuiIcon.EDIT_EFFECT.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_EFFECT),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_EFFECT_DESCRIPTION)},
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-primary-effect"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-effect-description")},
(button, isShiftClick) -> {
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> GuiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup();
if (canEditPrimaryStyleAndData) {
@ -136,7 +137,7 @@ public class GuiInventoryDefault extends GuiInventory {
}
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
GuiManager.transition(new GuiInventoryDefault(pplayer));
guiManager.transition(new GuiInventoryDefault(pplayer));
});
callbacks.get(1).execute();
@ -146,24 +147,24 @@ public class GuiInventoryDefault extends GuiInventory {
// Edit Primary Style
String[] editPrimaryStyleLore;
if (canEditPrimaryStyleAndData) {
editPrimaryStyleLore = new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE_DESCRIPTION)};
editPrimaryStyleLore = new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-style-description")};
} else {
editPrimaryStyleLore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE_DESCRIPTION),
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE_MISSING_EFFECT)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-style-description"),
localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-edit-primary-style-missing-effect")
};
}
GuiActionButton editPrimaryStyle = new GuiActionButton(
40,
GuiIcon.EDIT_STYLE.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_STYLE),
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-primary-style"),
editPrimaryStyleLore,
(button, isShiftClick) -> {
if (!canEditPrimaryStyleAndData) return;
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> GuiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) {
@ -174,7 +175,7 @@ public class GuiInventoryDefault extends GuiInventory {
}
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
GuiManager.transition(new GuiInventoryDefault(pplayer));
guiManager.transition(new GuiInventoryDefault(pplayer));
});
callbacks.get(1).execute();
@ -184,29 +185,29 @@ public class GuiInventoryDefault extends GuiInventory {
// Edit Primary Data
String[] editPrimaryDataLore;
if (canEditPrimaryStyleAndData && doesEffectUseData) {
editPrimaryDataLore = new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_DESCRIPTION)};
editPrimaryDataLore = new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-data-description")};
} else if (canEditPrimaryStyleAndData) {
editPrimaryDataLore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_DESCRIPTION),
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_UNAVAILABLE)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-data-description"),
localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-edit-primary-data-unavailable")
};
} else {
editPrimaryDataLore = new String[]{
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_DESCRIPTION),
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA_MISSING_EFFECT)
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-data-description"),
localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-edit-primary-data-missing-effect")
};
}
GuiActionButton editPrimaryData = new GuiActionButton(
42,
GuiIcon.EDIT_DATA.get(),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_PRIMARY_DATA),
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-primary-data"),
editPrimaryDataLore,
(button, isShiftClick) -> {
if (!canEditPrimaryStyleAndData || !doesEffectUseData) return;
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
callbacks.add(() -> GuiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> GuiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles()) {
@ -220,7 +221,7 @@ public class GuiInventoryDefault extends GuiInventory {
}
dataManager.saveParticleGroup(pplayer.getUniqueId(), group);
GuiManager.transition(new GuiInventoryDefault(pplayer));
guiManager.transition(new GuiInventoryDefault(pplayer));
});
callbacks.get(1).execute();

View file

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

View file

@ -1,23 +1,25 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.List;
import org.bukkit.Bukkit;
public class GuiInventoryEditEffect extends GuiInventory {
public GuiInventoryEditEffect(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_EFFECT)));
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-effect")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.LIGHT_BLUE);
@ -35,8 +37,8 @@ public class GuiInventoryEditEffect extends GuiInventory {
GuiActionButton selectButton = new GuiActionButton(
slot,
GuiIcon.EFFECT.get(effect.getName()),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ParticleUtils.formatName(effect.getName()),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, ParticleUtils.formatName(effect.getName()))},
localeManager.getLocaleMessage("gui-color-icon-name") + ParticleUtils.formatName(effect.getName()),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-effect-description", StringPlaceholders.single("effect", ParticleUtils.formatName(effect.getName())))},
(button, isShiftClick) -> {
editingParticle.setEffect(effect);
callbackList.get(callbackListPosition + 1).execute();
@ -55,7 +57,7 @@ public class GuiInventoryEditEffect extends GuiInventory {
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1,
GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
new String[]{},
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
this.actionButtons.add(backButton);
@ -65,9 +67,9 @@ public class GuiInventoryEditEffect extends GuiInventory {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
@ -76,9 +78,9 @@ public class GuiInventoryEditEffect extends GuiInventory {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}

View file

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

View file

@ -1,23 +1,25 @@
package dev.esophose.playerparticles.gui;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.manager.SettingManager.GuiIcon;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.List;
import org.bukkit.Bukkit;
public class GuiInventoryEditStyle extends GuiInventory {
public GuiInventoryEditStyle(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_STYLE)));
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-style")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
this.fillBorder(BorderColor.BLUE);
@ -35,8 +37,8 @@ public class GuiInventoryEditStyle extends GuiInventory {
GuiActionButton selectButton = new GuiActionButton(
slot,
GuiIcon.STYLE.get(style.getName()),
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ParticleUtils.formatName(style.getName()),
new String[]{LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, ParticleUtils.formatName(style.getName()))},
localeManager.getLocaleMessage("gui-color-icon-name") + ParticleUtils.formatName(style.getName()),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-style-description", StringPlaceholders.single("style", ParticleUtils.formatName(style.getName())))},
(button, isShiftClick) -> {
editingParticle.setStyle(style);
callbackList.get(callbackListPosition + 1).execute();
@ -55,7 +57,7 @@ public class GuiInventoryEditStyle extends GuiInventory {
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1,
GuiIcon.BACK.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
new String[]{},
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
this.actionButtons.add(backButton);
@ -65,9 +67,9 @@ public class GuiInventoryEditStyle extends GuiInventory {
GuiActionButton previousPageButton = new GuiActionButton(
INVENTORY_SIZE - 6,
GuiIcon.PREVIOUS_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PREVIOUS_PAGE_BUTTON, pageNumber - 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition)));
this.actionButtons.add(previousPageButton);
}
@ -76,9 +78,9 @@ public class GuiInventoryEditStyle extends GuiInventory {
GuiActionButton nextPageButton = new GuiActionButton(
INVENTORY_SIZE - 4,
GuiIcon.NEXT_PAGE.get(),
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_NEXT_PAGE_BUTTON, pageNumber + 1, maxPages),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{},
(button, isShiftClick) -> GuiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition)));
this.actionButtons.add(nextPageButton);
}

View file

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

View file

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

View file

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

View file

@ -1,9 +1,13 @@
package dev.esophose.playerparticles.gui.hook;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.util.NMSUtil;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.HashSet;
import java.util.Set;
import dev.esophose.playerparticles.util.NMSUtil;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -12,13 +16,6 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
public class PlayerChatHook extends BukkitRunnable implements Listener {
private static Set<PlayerChatHookData> hooks;
@ -69,11 +66,12 @@ public class PlayerChatHook extends BukkitRunnable implements Listener {
if (player == null) {
hooksToRemove.remove(hook);
} else {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (NMSUtil.getVersionNumber() == 9) {
if (hook.getMaxHookLength() == hook.getTimeRemaining())
player.sendMessage(LangManager.getText(Lang.GUI_SAVE_GROUP_HOTBAR_MESSAGE, hook.getTimeRemaining()));
player.sendMessage(localeManager.getLocaleMessage("gui-save-group-hotbar-message", StringPlaceholders.single("seconds", hook.getTimeRemaining())));
} else {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(LangManager.getText(Lang.GUI_SAVE_GROUP_HOTBAR_MESSAGE, hook.getTimeRemaining())));
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(localeManager.getLocaleMessage("gui-save-group-hotbar-message", StringPlaceholders.single("seconds", hook.getTimeRemaining()))));
}
}
}

View file

@ -194,7 +194,7 @@ public class EnglishLocale implements Locale {
this.put("fixed-edit-style-non-fixable", "&cUnable to edit fixed effect, the style &b%style% &ccan not be used in fixed effects!");
this.put("fixed-edit-data-error", "&cUnable to edit fixed effect, the data provided is not correct! Use &b/pp data <effect> &cto find the correct data format!");
this.put("fixed-edit-data-none", "&cUnable to edit fixed effect, the effect does not require any data!");
this.put("fixed-edit-success", "&aUpdated the &b%property% &aof the fixed effect with an ID of &b%id%&a!");
this.put("fixed-edit-success", "&aUpdated the &b%prop% &aof the fixed effect with an ID of &b%id%&a!");
this.put("fixed-remove-invalid", "&cUnable to remove fixed effect, you do not have a fixed effect with the ID of &b%id%&c!");
this.put("fixed-remove-no-args", "&cYou did not specify an ID to remove!");

View file

@ -194,7 +194,7 @@ public class FrenchLocale implements Locale {
this.put("fixed-edit-style-non-fixable", "&cImpossible de modifier l'effet fixe, the style &b%style% &cne peut pas être utilisé dans des effets fixes !");
this.put("fixed-edit-data-error", "&cImpossible de modifier l'effet fixe, paramètre incorrect ! Utilisez &b/pp data <effect> pour afficher les paramètres valides.");
this.put("fixed-edit-data-none", "&cImpossible de modifier l'effet fixe, l'effet ne requière pas de paramètres !");
this.put("fixed-edit-success", "&aMise à jour de &b%property% &ade l'effet fixe avec l'ID &b%id% &a!");
this.put("fixed-edit-success", "&aMise à jour de &b%prop% &ade l'effet fixe avec l'ID &b%id% &a!");
this.put("fixed-remove-invalid", "&cImpossible de supprimer l'effet fixe, vous n'avez pas d effets fixes avec l'ID &b%id% &c!");
this.put("fixed-remove-no-args", "&cVous n'avez pas rentrer d'ID à supprimer !");

View file

@ -194,7 +194,7 @@ public class GermanLocale implements Locale {
this.put("fixed-edit-style-non-fixable", "&cFixer Effekt kann nicht bearbeitet werden. Der Stil &b%style% &ckann nicht für fixe Effekte verwendet werden!");
this.put("fixed-edit-data-error", "&cFixeffekt kann nicht bearbeitet werden, die angegebenen Daten sind nicht korrekt! Verwenden Sie &b/pp data <effect> &c, um das richtige Datenformat zu finden!");
this.put("fixed-edit-data-none", "&cFixierter Effekt kann nicht bearbeitet werden, für den Effekt sind keine Daten erforderlich!");
this.put("fixed-edit-success", "&aAktualisiert die &b%property% &ades festen Effekts mit einer ID von &b%id%&a!");
this.put("fixed-edit-success", "&aAktualisiert die &b%prop% &ades festen Effekts mit einer ID von &b%id%&a!");
this.put("fixed-remove-invalid", "&cFixierter Effekt kann nicht entfernt werden, Sie haben keinen Fixierten Effekt mit der ID &b%id%&c!");
this.put("fixed-remove-no-args", "&cSie haben keine ID zum Entfernen angegeben!");

View file

@ -195,7 +195,7 @@ public class RussianLocale implements Locale {
this.put("fixed-edit-style-non-fixable", "&cНевозможно изменить эффект, стиль &b%style% &cне может быть использован!");
this.put("fixed-edit-data-error", "&cНевозможно создать эффект, введённые данные неверны! Введите &b/pp data <Эффект>&c, чтобы найти правильный формат данных!");
this.put("fixed-edit-data-none", "&cНевозможно изменить эффект, эффект не запрашивает какие-либо данные!");
this.put("fixed-edit-success", "&aОбновлено эффектов под ID &b%id%&a - &b%property%&a!");
this.put("fixed-edit-success", "&aОбновлено эффектов под ID &b%id%&a - &b%prop%&a!");
this.put("fixed-remove-invalid", "&cНевозможно удалить эффект, у Вас нет эффекта под ID &b%id%&c!");
this.put("fixed-remove-no-args", "&cYou did not specify an ID to remove!");

View file

@ -194,7 +194,7 @@ public class SimplifiedChineseLocale implements Locale {
this.put("fixed-edit-style-non-fixable", "&c无法编辑定点特效 风格 &b%style% &c无法用于定点特效!");
this.put("fixed-edit-data-error", "&c无法编辑定点特效 数据有误! 请输入 &b/pp data <effect> &cto 来获取正确的数据格式!");
this.put("fixed-edit-data-none", "&c无法编辑定点特效 该特效无需数据!");
this.put("fixed-edit-success", "&a已更新&b%property%&a个ID为&b%id%&a的定点特效!");
this.put("fixed-edit-success", "&a已更新&b%prop%&a个ID为&b%id%&a的定点特效!");
this.put("fixed-remove-invalid", "&c无法删除定点特效 你没有ID为&b%id%&c的定点特效!");
this.put("fixed-remove-no-args", "&c你没有指定要删除的ID!");

View file

@ -194,7 +194,7 @@ public class VietnameseLocale implements Locale {
this.put("fixed-edit-style-non-fixable", "&cKhông thể điều chỉnh Hiệu ứng cố định, Kiểu hiệu ứng &b%style% &ckhông thể được sử dụng trong Hiệu ứng cố định!");
this.put("fixed-edit-data-error", "&cKhông thể điều chỉnh Hiệu ứng cố định, Dữ liệu bạn đã cung cấp không đúng! Sử dụng &b/pp data <effect> &cđể xem định dạng dữ liệu đúng!");
this.put("fixed-edit-data-none", "&cKhông thể điều chỉnh Hiệu ứng cố định, Hiệu ứng không yêu cầu bất cứ Dữ liệu nào!");
this.put("fixed-edit-success", "&aĐã cập nhật &b%property% &acủa Hiệu ứng cố định với một ID của &b%id%&a!");
this.put("fixed-edit-success", "&aĐã cập nhật &b%prop% &acủa Hiệu ứng cố định với một ID của &b%id%&a!");
this.put("fixed-remove-invalid", "&cKhông thể xóa Hiệu ứng cố định, bạn không có hiệu ứng cố định nào với ID &b%id%&c!");
this.put("fixed-remove-no-args", "&cbạn không chỉ định ID để xóa!");

View file

@ -21,9 +21,11 @@ import dev.esophose.playerparticles.command.StylesCommandModule;
import dev.esophose.playerparticles.command.ToggleCommandModule;
import dev.esophose.playerparticles.command.VersionCommandModule;
import dev.esophose.playerparticles.command.WorldsCommandModule;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.particles.OtherPPlayer;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@ -33,10 +35,6 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CommandManager extends Manager implements CommandExecutor, TabCompleter {
/**
@ -137,11 +135,13 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
* @return true
*/
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (cmd.getName().equalsIgnoreCase("pp")) {
String commandName = args.length > 0 ? args[0] : "";
CommandModule commandModule = this.findMatchingCommand(commandName);
if (commandModule == null) {
sender.sendMessage(LangManager.getText(Lang.COMMAND_ERROR_UNKNOWN));
sender.sendMessage(localeManager.getLocaleMessage("command-error-unknown"));
return true;
}
@ -161,7 +161,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
this.playerParticles.getManager(DataManager.class).getPPlayer(p.getUniqueId(), (pplayer) -> {
if (commandModule.requiresEffects() && PlayerParticles.getInstance().getManager(PermissionManager.class).getEffectNamesUserHasPermissionFor(p).isEmpty()) {
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_NO_EFFECTS);
localeManager.sendMessage(pplayer, "command-error-no-effects");
} else {
commandModule.onCommandExecute(pplayer, cmdArgs);
}

View file

@ -2,12 +2,17 @@ package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.util.ParticleUtils;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.bukkit.Material;
public class ConfigurationManager extends Manager {
@ -26,7 +31,6 @@ public class ConfigurationManager extends Manager {
LOCALE("locale", "en_US", "The locale to use in the /locale folder"),
MESSAGES_ENABLED("message-enabled", true, "If you're using other plugins to execute commands you may wish to turn off messages"),
USE_MESSAGE_PREFIX("use-message-prefix", true, "Whether or not to use the message-prefix field when displaying messages"),
MESSAGE_PREFIX("message-prefix", "&7[&3PlayerParticles&7]", "The prefix to use for all PlayerParticles messages", "This is useless if use-message-prefix is set to false"),
GUI_ENABLED("gui-enabled", true, "If the command /pp gui is enabled", "Disable this if you have your own custom GUI through another plugin"),
GUI_PRESETS_ONLY("gui-presets-only", false, "If true, only the preset groups will be available in the GUI", "Permissions to open the GUI will change to only open if the user has any preset groups available"),
GUI_CLOSE_AFTER_GROUP_SELECTED("gui-close-after-group-selected", true, "If true, the GUI will close after selecting a group (either saved or preset)"),
@ -50,7 +54,129 @@ public class ConfigurationManager extends Manager {
MYSQL_DATABASE_NAME("mysql-settings.database-name", "", "MySQL Database Name"),
MYSQL_USER_NAME("mysql-settings.user-name", "", "MySQL Database User Name"),
MYSQL_USER_PASSWORD("mysql-settings.user-password", "", "MySQL Database User Password"),
MYSQL_USE_SSL("mysql-settings.use-ssl", false, "If the database connection should use SSL", "You should enable this if your database supports SSL");
MYSQL_USE_SSL("mysql-settings.use-ssl", false, "If the database connection should use SSL", "You should enable this if your database supports SSL"),
GUI_ICON("gui-icon", null, "# =================================================================== #",
"# GUI ICON SETTINGS #",
"# This configuration option allows you to change any of the GUI #",
"# icons to whatever block/item you want. #",
"# #",
"# Important Notes: #",
"# * If any of the block/item names are invalid the icon in the GUI #",
"# will be the barrier icon to show that it failed to load. #",
"# * Do NOT change the particle/style name #",
"# * You MUST use the Spigot-given name for it to work. You can see #",
"# all the Spigot-given names at the link below: #",
"# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html #",
"# * If two icons are listed, the second one is used for below MC 1.13 #",
"# =================================================================== #"),
GUI_ICON_MISC("gui-icon.misc", null),
GUI_ICON_MISC_PARTICLES("gui-icon.misc.particles", Collections.singletonList("BLAZE_POWDER")),
GUI_ICON_MISC_GROUPS("gui-icon.misc.groups", Collections.singletonList("CHEST")),
GUI_ICON_MISC_PRESET_GROUPS("gui-icon.misc.preset_groups", Collections.singletonList("ENDER_CHEST")),
GUI_ICON_MISC_BACK("gui-icon.misc.back", Collections.singletonList("ARROW")),
GUI_ICON_MISC_NEXT_PAGE("gui-icon.misc.next_page", Collections.singletonList("PAPER")),
GUI_ICON_MISC_PREVIOUS_PAGE("gui-icon.misc.previous_page", Collections.singletonList("PAPER")),
GUI_ICON_MISC_CREATE("gui-icon.misc.create", Arrays.asList("WRITABLE_BOOK", "BOOK_AND_QUILL")),
GUI_ICON_MISC_EDIT_EFFECT("gui-icon.misc.edit_effect", Arrays.asList("FIREWORK_ROCKET", "FIREWORK")),
GUI_ICON_MISC_EDIT_STYLE("gui-icon.misc.edit_style", Collections.singletonList("NETHER_STAR")),
GUI_ICON_MISC_EDIT_DATA("gui-icon.misc.edit_data", Collections.singletonList("BOOK")),
GUI_ICON_MISC_RESET("gui-icon.misc.reset", Collections.singletonList("BARRIER")),
GUI_ICON_EFFECT("gui-icon.effect", null),
GUI_ICON_EFFECT_AMBIENT_ENTITY_EFFECT("gui-icon.effect.ambient_entity_effect", Collections.singletonList("BEACON")),
GUI_ICON_EFFECT_ANGRY_VILLAGER("gui-icon.effect.angry_villager", Collections.singletonList("IRON_DOOR")),
GUI_ICON_EFFECT_BARRIER("gui-icon.effect.barrier", Collections.singletonList("BARRIER")),
GUI_ICON_EFFECT_BLOCK("gui-icon.effect.block", Collections.singletonList("STONE")),
GUI_ICON_EFFECT_BUBBLE("gui-icon.effect.bubble", Arrays.asList("BUBBLE_CORAL", "GLASS")),
GUI_ICON_EFFECT_BUBBLE_COLUMN_UP("gui-icon.effect.bubble_column_up", Collections.singletonList("MAGMA_BLOCK")),
GUI_ICON_EFFECT_BUBBLE_POP("gui-icon.effect.bubble_pop", Collections.singletonList("BUBBLE_CORAL_FAN")),
GUI_ICON_EFFECT_CAMPFIRE_COSY_SMOKE("gui-icon.effect.campfire_cosy_smoke", Collections.singletonList("CAMPFIRE")),
GUI_ICON_EFFECT_CAMPFIRE_SIGNAL_SMOKE("gui-icon.effect.campfire_signal_smoke", Collections.singletonList("REDSTONE_TORCH")),
GUI_ICON_EFFECT_CLOUD("gui-icon.effect.cloud", Arrays.asList("WHITE_WOOL", "WOOL")),
GUI_ICON_EFFECT_COMPOSTER("gui-icon.effect.composter", Collections.singletonList("COMPOSTER")),
GUI_ICON_EFFECT_CRIT("gui-icon.effect.crit", Collections.singletonList("IRON_SWORD")),
GUI_ICON_EFFECT_CURRENT_DOWN("gui-icon.effect.current_down", Collections.singletonList("SOUL_SAND")),
GUI_ICON_EFFECT_DAMAGE_INDICATOR("gui-icon.effect.damage_indicator", Collections.singletonList("BOW")),
GUI_ICON_EFFECT_DOLPHIN("gui-icon.effect.dolphin", Collections.singletonList("DOLPHIN_SPAWN_EGG")),
GUI_ICON_EFFECT_DRAGON_BREATH("gui-icon.effect.dragon_breath", Arrays.asList("DRAGON_BREATH", "DRAGONS_BREATH")),
GUI_ICON_EFFECT_DRIPPING_HONEY("gui-icon.effect.dripping_honey", Collections.singletonList("BEE_NEST")),
GUI_ICON_EFFECT_DRIPPING_LAVA("gui-icon.effect.dripping_lava", Collections.singletonList("LAVA_BUCKET")),
GUI_ICON_EFFECT_DRIPPING_WATER("gui-icon.effect.dripping_water", Collections.singletonList("WATER_BUCKET")),
GUI_ICON_EFFECT_DUST("gui-icon.effect.dust", Collections.singletonList("REDSTONE")),
GUI_ICON_EFFECT_ENCHANT("gui-icon.effect.enchant", Arrays.asList("ENCHANTING_TABLE", "ENCHANTMENT_TABLE")),
GUI_ICON_EFFECT_ENCHANTED_HIT("gui-icon.effect.enchanted_hit", Collections.singletonList("DIAMOND_SWORD")),
GUI_ICON_EFFECT_END_ROD("gui-icon.effect.end_rod", Collections.singletonList("END_ROD")),
GUI_ICON_EFFECT_ENTITY_EFFECT("gui-icon.effect.entity_effect", Collections.singletonList("GLOWSTONE_DUST")),
GUI_ICON_EFFECT_EXPLOSION("gui-icon.effect.explosion", Arrays.asList("FIRE_CHARGE", "FIREBALL")),
GUI_ICON_EFFECT_EXPLOSION_EMITTER("gui-icon.effect.explosion_emitter", Collections.singletonList("TNT")),
GUI_ICON_EFFECT_FALLING_DUST("gui-icon.effect.falling_dust", Collections.singletonList("SAND")),
GUI_ICON_EFFECT_FALLING_HONEY("gui-icon.effect.falling_honey", Collections.singletonList("HONEY_BOTTLE")),
GUI_ICON_EFFECT_FALLING_LAVA("gui-icon.effect.falling_lava", Collections.singletonList("RED_DYE")),
GUI_ICON_EFFECT_FALLING_NECTAR("gui-icon.effect.falling_nectar", Collections.singletonList("HONEYCOMB")),
GUI_ICON_EFFECT_FALLING_WATER("gui-icon.effect.falling_water", Collections.singletonList("BLUE_DYE")),
GUI_ICON_EFFECT_FIREWORK("gui-icon.effect.firework", Arrays.asList("FIREWORK_ROCKET", "FIREWORK")),
GUI_ICON_EFFECT_FISHING("gui-icon.effect.fishing", Collections.singletonList("FISHING_ROD")),
GUI_ICON_EFFECT_FLAME("gui-icon.effect.flame", Collections.singletonList("BLAZE_POWDER")),
GUI_ICON_EFFECT_FOOTSTEP("gui-icon.effect.footstep", Collections.singletonList("GRASS")),
GUI_ICON_EFFECT_HAPPY_VILLAGER("gui-icon.effect.happy_villager", Arrays.asList("DARK_OAK_DOOR", "WOOD_DOOR")),
GUI_ICON_EFFECT_HEART("gui-icon.effect.heart", Arrays.asList("POPPY", "RED_ROSE")),
GUI_ICON_EFFECT_INSTANT_EFFECT("gui-icon.effect.instant_effect", Arrays.asList("SPLASH_POTION", "POTION")),
GUI_ICON_EFFECT_ITEM("gui-icon.effect.item", Collections.singletonList("ITEM_FRAME")),
GUI_ICON_EFFECT_ITEM_SLIME("gui-icon.effect.item_slime", Collections.singletonList("SLIME_BALL")),
GUI_ICON_EFFECT_ITEM_SNOWBALL("gui-icon.effect.item_snowball", Collections.singletonList("SNOWBALL")),
GUI_ICON_EFFECT_LARGE_SMOKE("gui-icon.effect.large_smoke", Arrays.asList("COBWEB", "WEB")),
GUI_ICON_EFFECT_LANDING_HONEY("gui-icon.effect.landing_honey", Collections.singletonList("HONEY_BLOCK")),
GUI_ICON_EFFECT_LANDING_LAVA("gui-icon.effect.landing_lava", Collections.singletonList("ORANGE_DYE")),
GUI_ICON_EFFECT_LAVA("gui-icon.effect.lava", Collections.singletonList("MAGMA_CREAM")),
GUI_ICON_EFFECT_MYCELIUM("gui-icon.effect.mycelium", Arrays.asList("MYCELIUM", "MYCEL")),
GUI_ICON_EFFECT_NAUTILUS("gui-icon.effect.nautilus", Collections.singletonList("HEART_OF_THE_SEA")),
GUI_ICON_EFFECT_NOTE("gui-icon.effect.note", Collections.singletonList("NOTE_BLOCK")),
GUI_ICON_EFFECT_POOF("gui-icon.effect.poof", Arrays.asList("FIREWORK_STAR", "FIREWORK_CHARGE")),
GUI_ICON_EFFECT_PORTAL("gui-icon.effect.portal", Collections.singletonList("OBSIDIAN")),
GUI_ICON_EFFECT_RAIN("gui-icon.effect.rain", Arrays.asList("PUFFERFISH_BUCKET", "LAPIS_BLOCK")),
GUI_ICON_EFFECT_SMOKE("gui-icon.effect.smoke", Collections.singletonList("TORCH")),
GUI_ICON_EFFECT_SNEEZE("gui-icon.effect.sneeze", Collections.singletonList("BAMBOO")),
GUI_ICON_EFFECT_SPELL("gui-icon.effect.spell", Arrays.asList("POTION", "GLASS_BOTTLE")),
GUI_ICON_EFFECT_SPIT("gui-icon.effect.spit", Arrays.asList("LLAMA_SPAWN_EGG", "PUMPKIN_SEEDS")),
GUI_ICON_EFFECT_SPLASH("gui-icon.effect.splash", Arrays.asList("SALMON", "FISH")),
GUI_ICON_EFFECT_SQUID_INK("gui-icon.effect.squid_ink", Collections.singletonList("INK_SAC")),
GUI_ICON_EFFECT_SWEEP_ATTACK("gui-icon.effect.sweep_attack", Arrays.asList("GOLDEN_SWORD", "GOLD_SWORD")),
GUI_ICON_EFFECT_TOTEM_OF_UNDYING("gui-icon.effect.totem_of_undying", Collections.singletonList("TOTEM")),
GUI_ICON_EFFECT_UNDERWATER("gui-icon.effect.underwater", Collections.singletonList("TURTLE_HELMET")),
GUI_ICON_EFFECT_WITCH("gui-icon.effect.witch", Collections.singletonList("CAULDRON")),
GUI_ICON_STYLE("gui-icon.style", null),
GUI_ICON_STYLE_ARROWS("gui-icon.style.arrows", Collections.singletonList("BOW")),
GUI_ICON_STYLE_BATMAN("gui-icon.style.batman", Arrays.asList("BAT_SPAWN_EGG", "COAL")),
GUI_ICON_STYLE_BEAM("gui-icon.style.beam", Collections.singletonList("POWERED_RAIL")),
GUI_ICON_STYLE_BLOCKBREAK("gui-icon.style.blockbreak", Collections.singletonList("IRON_PICKAXE")),
GUI_ICON_STYLE_BLOCKPLACE("gui-icon.style.blockplace", Arrays.asList("OAK_PLANKS", "WOOD")),
GUI_ICON_STYLE_CELEBRATION("gui-icon.style.celebration", Arrays.asList("FIREWORK_ROCKET", "FIREWORK")),
GUI_ICON_STYLE_CHAINS("gui-icon.style.chains", Collections.singletonList("TRIPWIRE_HOOK")),
GUI_ICON_STYLE_COMPANION("gui-icon.style.companion", Collections.singletonList("NAME_TAG")),
GUI_ICON_STYLE_CUBE("gui-icon.style.cube", Collections.singletonList("STONE")),
GUI_ICON_STYLE_FEET("gui-icon.style.feet", Collections.singletonList("GRASS")),
GUI_ICON_STYLE_HALO("gui-icon.style.halo", Arrays.asList("END_PORTAL_FRAME", "ENDER_PORTAL_FRAME")),
GUI_ICON_STYLE_HURT("gui-icon.style.hurt", Collections.singletonList("CACTUS")),
GUI_ICON_STYLE_INVOCATION("gui-icon.style.invocation", Arrays.asList("ENDER_EYE", "EYE_OF_ENDER")),
GUI_ICON_STYLE_MOVE("gui-icon.style.move", Arrays.asList("PISTON", "PISTON_BASE")),
GUI_ICON_STYLE_NORMAL("gui-icon.style.normal", Collections.singletonList("DIRT")),
GUI_ICON_STYLE_ORBIT("gui-icon.style.orbit", Arrays.asList("ENCHANTING_TABLE", "ENCHANTMENT_TABLE")),
GUI_ICON_STYLE_OVERHEAD("gui-icon.style.overhead", Collections.singletonList("GLOWSTONE")),
GUI_ICON_STYLE_POINT("gui-icon.style.point", Collections.singletonList("STONE_BUTTON")),
GUI_ICON_STYLE_POPPER("gui-icon.style.popper", Arrays.asList("POPPED_CHORUS_FRUIT", "CHORUS_FRUIT_POPPED")),
GUI_ICON_STYLE_PULSE("gui-icon.style.pulse", Arrays.asList("REDSTONE_TORCH", "REDSTONE_TORCH_ON")),
GUI_ICON_STYLE_QUADHELIX("gui-icon.style.quadhelix", Arrays.asList("NAUTILUS_SHELL", "ACTIVATOR_RAIL")),
GUI_ICON_STYLE_RINGS("gui-icon.style.rings", Collections.singletonList("LEAD")),
GUI_ICON_STYLE_SPHERE("gui-icon.style.sphere", Arrays.asList("HEART_OF_THE_SEA", "SNOWBALL")),
GUI_ICON_STYLE_SPIN("gui-icon.style.spin", Collections.singletonList("BEACON")),
GUI_ICON_STYLE_SPIRAL("gui-icon.style.spiral", Collections.singletonList("HOPPER")),
GUI_ICON_STYLE_SWORDS("gui-icon.style.swords", Collections.singletonList("IRON_SWORD")),
GUI_ICON_STYLE_THICK("gui-icon.style.thick", Arrays.asList("COBWEB", "WEB")),
GUI_ICON_STYLE_TWINS("gui-icon.style.twins", Arrays.asList("OAK_FENCE", "FENCE")),
GUI_ICON_STYLE_VORTEX("gui-icon.style.vortex", Collections.singletonList("GLOWSTONE_DUST")),
GUI_ICON_STYLE_WHIRL("gui-icon.style.whirl", Collections.singletonList("FEATHER")),
GUI_ICON_STYLE_WHIRLWIND("gui-icon.style.whirlwind", Collections.singletonList("STRING")),
GUI_ICON_STYLE_WINGS("gui-icon.style.wings", Collections.singletonList("ELYTRA"));
private final String key;
private final Object defaultValue;
@ -197,6 +323,9 @@ public class ConfigurationManager extends Manager {
setting.setIfNotExists(this.configuration);
}
for (GuiIcon icon : GuiIcon.values())
icon.resetDefault();
this.configuration.save();
}
@ -213,4 +342,96 @@ public class ConfigurationManager extends Manager {
return this.configuration;
}
/**
* Used for grabbing/caching configurable GUI Icons from the config.yml
*/
public enum GuiIcon {
PARTICLES,
GROUPS,
PRESET_GROUPS,
BACK,
NEXT_PAGE,
PREVIOUS_PAGE,
CREATE,
EDIT_EFFECT,
EDIT_STYLE,
EDIT_DATA,
RESET,
EFFECT,
STYLE;
private Map<String, Material> materials;
GuiIcon() {
this.materials = new HashMap<>();
}
/**
* Gets the Material for this icon from the 'gui-icon.misc' section in the config.yml
* Tries to get from cache first, otherwise loads it
*
* @return The Material for this Icon
*/
public Material get() {
return this.getInternal("gui-icon.misc." + this.name().toLowerCase());
}
/**
* Gets the Material for a subsection of this icon in the config.yml
* Tries to get from cache first, otherwise loads it
*
* @param subsection The name of the icon in the section
* @return The Material for this Icon
*/
public Material get(String subsection) {
return this.getInternal("gui-icon." + this.name().toLowerCase() + "." + subsection);
}
/**
* Gets the Material for this icon
* Tries to get from cache first, otherwise loads it
*
* @param configPath Where to look in the config.yml for the Material name
* @return The path in the config.yml to lookup
*/
private Material getInternal(String configPath) {
Material material = this.materials.get(configPath);
if (material != null)
return material;
ConfigurationManager configurationManager = PlayerParticles.getInstance().getManager(ConfigurationManager.class);
List<String> materials = configurationManager.getConfig().getStringList(configPath);
try {
if (materials.size() == 1) {
material = ParticleUtils.closestMatch(materials.get(0));
} else {
if (ParticleEffect.VERSION_13) {
material = ParticleUtils.closestMatch(materials.get(0));
} else {
material = ParticleUtils.closestMatch(materials.get(1));
}
}
} catch (Exception e) {
PlayerParticles.getInstance().getLogger().severe("Missing GUI icon for '" + this.name().toLowerCase() + "'");
}
if (material == null)
material = Material.BARRIER;
this.materials.put(configPath, material);
return material;
}
/**
* Resets the setting's value so it will be fetched from the config the next time it's needed
*/
private void resetDefault() {
this.materials = new HashMap<>();
}
}
}

View file

@ -12,17 +12,16 @@ import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
/**
* All data changes to PPlayers such as group or fixed effect changes must be done through here,

View file

@ -5,7 +5,6 @@ import dev.esophose.playerparticles.database.DataMigration;
import dev.esophose.playerparticles.database.DatabaseConnector;
import dev.esophose.playerparticles.database.SQLiteConnector;
import dev.esophose.playerparticles.database.migrations._1_InitialMigration;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Arrays;

View file

@ -4,8 +4,10 @@ import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.gui.GuiInventory;
import dev.esophose.playerparticles.gui.GuiInventoryDefault;
import dev.esophose.playerparticles.gui.GuiInventoryLoadPresetGroups;
import dev.esophose.playerparticles.manager.SettingManager.Setting;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.PPlayer;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -14,13 +16,9 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.List;
// TODO: Remove static guiInventories and subsequent methods
public class GuiManager extends Manager implements Listener, Runnable {
private static List<GuiInventory> guiInventories = new ArrayList<>();
private List<GuiInventory> guiInventories = new ArrayList<>();
private BukkitTask guiTask = null;
public GuiManager(PlayerParticles playerParticles) {
@ -48,7 +46,7 @@ public class GuiManager extends Manager implements Listener, Runnable {
public void run() {
List<GuiInventory> toRemoveList = new ArrayList<>();
for (GuiInventory inventory : guiInventories) {
for (GuiInventory inventory : this.guiInventories) {
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(inventory.getPPlayer().getUniqueId());
if (pplayer == null) {
toRemoveList.add(inventory);
@ -70,7 +68,7 @@ public class GuiManager extends Manager implements Listener, Runnable {
}
for (GuiInventory inventory : toRemoveList)
guiInventories.remove(inventory);
this.guiInventories.remove(inventory);
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -78,7 +76,7 @@ public class GuiManager extends Manager implements Listener, Runnable {
if (!(event.getWhoClicked() instanceof Player)) return;
Player player = (Player)event.getWhoClicked();
GuiInventory inventory = getGuiInventory(player);
GuiInventory inventory = this.getGuiInventory(player);
if (inventory == null) return;
event.setCancelled(true);
@ -90,7 +88,7 @@ public class GuiManager extends Manager implements Listener, Runnable {
*
* @return True if the GUI is disabled
*/
public static boolean isGuiDisabled() {
public boolean isGuiDisabled() {
return !Setting.GUI_ENABLED.getBoolean();
}
@ -100,14 +98,14 @@ public class GuiManager extends Manager implements Listener, Runnable {
*/
public void forceCloseAllOpenGUIs() {
for (Player player : Bukkit.getOnlinePlayers()) {
for (GuiInventory inventory : guiInventories) {
for (GuiInventory inventory : this.guiInventories) {
if (inventory.getPPlayer().getUniqueId().equals(player.getUniqueId()) && inventory.getInventory().equals(player.getOpenInventory().getTopInventory())) {
player.closeInventory();
break;
}
}
}
guiInventories.clear();
this.guiInventories.clear();
}
/**
@ -115,8 +113,8 @@ public class GuiManager extends Manager implements Listener, Runnable {
*
* @param pplayer The PPlayer to open the GUI screen for
*/
public static void openDefault(PPlayer pplayer) {
removeGuiInventory(pplayer);
public void openDefault(PPlayer pplayer) {
this.removeGuiInventory(pplayer);
GuiInventory inventoryToOpen;
if (!Setting.GUI_PRESETS_ONLY.getBoolean()) {
@ -124,8 +122,8 @@ public class GuiManager extends Manager implements Listener, Runnable {
} else {
inventoryToOpen = new GuiInventoryLoadPresetGroups(pplayer, true);
}
guiInventories.add(inventoryToOpen);
this.guiInventories.add(inventoryToOpen);
pplayer.getPlayer().openInventory(inventoryToOpen.getInventory());
}
@ -134,9 +132,9 @@ public class GuiManager extends Manager implements Listener, Runnable {
*
* @param nextInventory The GuiInventory to transition to
*/
public static void transition(GuiInventory nextInventory) {
removeGuiInventory(nextInventory.getPPlayer());
guiInventories.add(nextInventory);
public void transition(GuiInventory nextInventory) {
this.removeGuiInventory(nextInventory.getPPlayer());
this.guiInventories.add(nextInventory);
nextInventory.getPPlayer().getPlayer().openInventory(nextInventory.getInventory());
}
@ -146,8 +144,8 @@ public class GuiManager extends Manager implements Listener, Runnable {
* @param player The Player
* @return The GuiInventory belonging to the Player, if any
*/
private static GuiInventory getGuiInventory(Player player) {
for (GuiInventory inventory : guiInventories)
private GuiInventory getGuiInventory(Player player) {
for (GuiInventory inventory : this.guiInventories)
if (inventory.getPPlayer().getUniqueId().equals(player.getUniqueId()))
return inventory;
return null;
@ -158,10 +156,10 @@ public class GuiManager extends Manager implements Listener, Runnable {
*
* @param pplayer The PPlayer who owns the GuiInventory
*/
private static void removeGuiInventory(PPlayer pplayer) {
for (GuiInventory inventory : guiInventories) {
private void removeGuiInventory(PPlayer pplayer) {
for (GuiInventory inventory : this.guiInventories) {
if (inventory.getPPlayer().getUniqueId().equals(pplayer.getUniqueId())) {
guiInventories.remove(inventory);
this.guiInventories.remove(inventory);
break;
}
}

View file

@ -7,8 +7,10 @@ import dev.esophose.playerparticles.locale.FrenchLocale;
import dev.esophose.playerparticles.locale.GermanLocale;
import dev.esophose.playerparticles.locale.Locale;
import dev.esophose.playerparticles.locale.RussianLocale;
import dev.esophose.playerparticles.locale.SimplifiedChineseLocale;
import dev.esophose.playerparticles.locale.VietnameseLocale;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.io.File;
import java.io.IOException;
@ -58,18 +60,20 @@ public class LocaleManager extends Manager {
@Override
public void reload() {
if (!this.playerParticles.getDataFolder().exists())
this.playerParticles.getDataFolder().mkdirs();
File localeDirectory = new File(this.playerParticles.getDataFolder(), "locale");
if (!localeDirectory.exists())
localeDirectory.mkdirs();
this.registerLocale(new EnglishLocale());
this.registerLocale(new FrenchLocale());
this.registerLocale(new GermanLocale());
this.registerLocale(new RussianLocale());
this.registerLocale(new SimplifiedChineseLocale());
this.registerLocale(new VietnameseLocale());
File targetLocaleFile = new File(Setting.LOCALE.getString() + ".lang");
File targetLocaleFile = new File(this.playerParticles.getDataFolder() + "/locale", Setting.LOCALE.getString() + ".lang");
if (!targetLocaleFile.exists()) {
targetLocaleFile = new File("en_US.lang");
targetLocaleFile = new File(this.playerParticles.getDataFolder() + "/locale", "en_US.lang");
this.playerParticles.getLogger().severe("File " + targetLocaleFile.getName() + " does not exist. Defaulting to en_US.lang");
}
@ -87,6 +91,7 @@ public class LocaleManager extends Manager {
public String getLocaleMessage(String messageKey, StringPlaceholders stringPlaceholders) {
String message = this.locale.getString(messageKey);
System.out.println("Message: " + messageKey + " = " + message);
if (message == null)
return "null";
return ChatColor.translateAlternateColorCodes('&', stringPlaceholders.apply(message));
@ -99,18 +104,39 @@ public class LocaleManager extends Manager {
* @param messageKey The message key of the Locale to send
* @param stringPlaceholders The placeholders to apply
*/
public void sendPrefixedMessage(CommandSender sender, String messageKey, StringPlaceholders stringPlaceholders) {
public void sendMessage(CommandSender sender, String messageKey, StringPlaceholders stringPlaceholders) {
sender.sendMessage(this.getLocaleMessage("prefix") + this.getLocaleMessage(messageKey, stringPlaceholders));
}
/**
* Sends a message to a PPlayer with the prefix with placeholders applied
*
* @param pplayer The PPlayer to send to
* @param messageKey The message key of the Locale to send
* @param stringPlaceholders The placeholders to apply
*/
public void sendMessage(PPlayer pplayer, String messageKey, StringPlaceholders stringPlaceholders) {
this.sendMessage(pplayer.getMessageDestination(), messageKey, stringPlaceholders);
}
/**
* Sends a message to a CommandSender with the prefix
*
* @param sender The CommandSender to send to
* @param messageKey The message key of the Locale to send
*/
public void sendPrefixedMessage(CommandSender sender, String messageKey) {
this.sendPrefixedMessage(sender, messageKey, new StringPlaceholders());
public void sendMessage(CommandSender sender, String messageKey) {
this.sendMessage(sender, messageKey, new StringPlaceholders());
}
/**
* Sends a message to a PPlayer with the prefix
*
* @param pplayer The PPlayer to send to
* @param messageKey The message key of the Locale to send
*/
public void sendMessage(PPlayer pplayer, String messageKey) {
this.sendMessage(pplayer.getMessageDestination(), messageKey);
}
/**
@ -120,18 +146,59 @@ public class LocaleManager extends Manager {
* @param messageKey The message key of the Locale to send
* @param stringPlaceholders The placeholders to apply
*/
public void sendMessage(CommandSender sender, String messageKey, StringPlaceholders stringPlaceholders) {
public void sendSimpleMessage(CommandSender sender, String messageKey, StringPlaceholders stringPlaceholders) {
sender.sendMessage(this.getLocaleMessage(messageKey, stringPlaceholders));
}
/**
* Sends a message to a PPlayer with placeholders applied
*
* @param pplayer The PPlayer to send to
* @param messageKey The message key of the Locale to send
* @param stringPlaceholders The placeholders to apply
*/
public void sendSimpleMessage(PPlayer pplayer, String messageKey, StringPlaceholders stringPlaceholders) {
this.sendSimpleMessage(pplayer.getMessageDestination(), messageKey, stringPlaceholders);
}
/**
* Sends a message to a CommandSender
*
* @param sender The CommandSender to send to
* @param messageKey The message key of the Locale to send
*/
public void sendMessage(CommandSender sender, String messageKey) {
public void sendSimpleMessage(CommandSender sender, String messageKey) {
this.sendMessage(sender, messageKey, StringPlaceholders.empty());
}
/**
* Sends a message to a PPlayer
*
* @param pplayer The PPlayer to send to
* @param messageKey The message key of the Locale to send
*/
public void sendSimpleMessage(PPlayer pplayer, String messageKey) {
this.sendSimpleMessage(pplayer.getMessageDestination(), messageKey);
}
/**
* Sends a custom message to a CommandSender
*
* @param sender The CommandSender to send to
* @param message The message to send
*/
public void sendCustomMessage(CommandSender sender, String message) {
sender.sendMessage(message);
}
/**
* Sends a custom message to a PPlayer
*
* @param pplayer The PPlayer to send to
* @param message The message to send
*/
public void sendCustomMessage(PPlayer pplayer, String message) {
this.sendCustomMessage(pplayer.getMessageDestination(), message);
}
}

View file

@ -1,5 +1,15 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticleGroupPreset;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@ -10,23 +20,11 @@ import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticleGroupPreset;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
public class ParticleGroupPresetManager extends Manager {
private static final String FILE_NAME = "preset_groups.yml";
@ -45,7 +43,10 @@ public class ParticleGroupPresetManager extends Manager {
this.presetGroups = new ArrayList<>();
File pluginDataFolder = PlayerParticles.getInstance().getDataFolder();
File groupsFile = new File(pluginDataFolder.getAbsolutePath() + File.separator + FILE_NAME);
if (!pluginDataFolder.exists())
pluginDataFolder.mkdir();
File groupsFile = new File(pluginDataFolder, FILE_NAME);
// Create the file if it doesn't exist
if (!groupsFile.exists()) {

View file

@ -1,7 +1,7 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.SettingManager.Setting;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.FixedParticleEffect;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
@ -9,7 +9,7 @@ import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.particles.PParticle;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,12 +1,11 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.styles.ParticleStyle;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
public class ParticleStyleManager extends Manager {
/**

View file

@ -1,17 +1,15 @@
package dev.esophose.playerparticles.manager;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import dev.esophose.playerparticles.manager.SettingManager.Setting;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.ParticleStyle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
public class PermissionManager extends Manager {

View file

@ -1,9 +1,8 @@
package dev.esophose.playerparticles.manager;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.SettingManager.Setting;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.util.StringPlaceholders;
import dev.esophose.playerparticles.util.Updater;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
@ -50,11 +49,10 @@ public class PluginUpdateManager extends Manager implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
if (e.getPlayer().isOp() && this.updateVersion != null) {
LangManager.sendCommandSenderMessage(
PlayerParticles.getInstance().getManager(LocaleManager.class).sendMessage(
e.getPlayer(),
Lang.UPDATE_AVAILABLE,
this.updateVersion,
this.playerParticles.getDescription().getVersion());
"update-available",
StringPlaceholders.builder("new", this.updateVersion).addPlaceholder("current", this.playerParticles.getDescription().getVersion()).build());
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,21 +1,19 @@
package dev.esophose.playerparticles.particles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.DataManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.SettingManager.Setting;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import dev.esophose.playerparticles.PlayerParticles;
public class PPlayerMovementListener implements Listener {
private static final int CHECK_INTERVAL = 3;

View file

@ -1,5 +1,9 @@
package dev.esophose.playerparticles.particles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.util.NMSUtil;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -8,12 +12,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.util.NMSUtil;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.manager.SettingManager.Setting;
import dev.esophose.playerparticles.styles.api.PParticle;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
@ -21,7 +19,6 @@ import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.metadata.MetadataValue;
@SuppressWarnings("deprecation")

View file

@ -2,10 +2,9 @@ package dev.esophose.playerparticles.particles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.PermissionManager;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
public class ParticleGroup {

View file

@ -1,21 +1,19 @@
package dev.esophose.playerparticles.particles;
import java.util.UUID;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LangManager;
import dev.esophose.playerparticles.manager.LangManager.Lang;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleColor;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Material;
public class ParticlePair {
@ -250,6 +248,7 @@ public class ParticlePair {
* @return The particle data in a human-readable string
*/
public String getDataString() {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (this.effect == ParticleEffect.BLOCK || this.effect == ParticleEffect.FALLING_DUST) {
return this.blockMaterial.toString().toLowerCase();
} else if (this.effect == ParticleEffect.ITEM) {
@ -257,22 +256,22 @@ public class ParticlePair {
} else if (this.effect.hasProperty(ParticleProperty.COLORABLE)) {
if (this.effect == ParticleEffect.NOTE) {
if (this.noteColor.getNote() == 99) {
return LangManager.getText(Lang.RAINBOW);
return localeManager.getLocaleMessage("rainbow");
} else if (this.noteColor.getNote() == 98) {
return LangManager.getText(Lang.RANDOM);
return localeManager.getLocaleMessage("random");
}
return LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, this.noteColor.getNote());
return localeManager.getLocaleMessage("gui-select-data-note", StringPlaceholders.single("note", this.noteColor.getNote()));
} else {
if (this.color.getRed() == 999 && this.color.getGreen() == 999 && this.color.getBlue() == 999) {
return LangManager.getText(Lang.RAINBOW);
return localeManager.getLocaleMessage("rainbow");
} else if (this.color.getRed() == 998 && this.color.getGreen() == 998 && this.color.getBlue() == 998) {
return LangManager.getText(Lang.RANDOM);
return localeManager.getLocaleMessage("random");
} else {
return ChatColor.RED + "" + this.color.getRed() + " " + ChatColor.GREEN + this.color.getGreen() + " " + ChatColor.AQUA + this.color.getBlue();
}
}
}
return LangManager.getText(Lang.GUI_DATA_NONE);
return localeManager.getLocaleMessage("gui-data-none");
}
/**

View file

@ -1,7 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;

View file

@ -1,12 +1,11 @@
package dev.esophose.playerparticles.styles.api;
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.List;
import org.bukkit.Location;
public interface ParticleStyle {

View file

@ -1,8 +1,10 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -11,10 +13,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityShootBowEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ParticleStyleArrows implements ParticleStyle, Listener {
private static final String[] arrowEntityNames = new String[] { "ARROW", "SPECTRAL_ARROW", "TIPPED_ARROW" };

View file

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

View file

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

View file

@ -5,8 +5,9 @@ import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -14,13 +15,10 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import java.util.ArrayList;
import java.util.List;
public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
location.add(0.5, 0.5, 0.5); // Center around the block

View file

@ -1,9 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -11,17 +15,10 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleBlockPlace implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
location.add(0.5, 0.5, 0.5); // Center around the block

View file

@ -7,17 +7,15 @@ import dev.esophose.playerparticles.particles.FixedParticleEffect;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class ParticleStyleCelebration implements ParticleStyle {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -11,13 +15,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleHurt implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) {

View file

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

View file

@ -1,21 +1,18 @@
package dev.esophose.playerparticles.styles;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleMove implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) {

View file

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

View file

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

View file

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

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.Collections;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStylePoint implements ParticleStyle {
public List<PParticle> getParticles(ParticlePair particle, Location location) {

View file

@ -1,15 +1,12 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStylePopper implements ParticleStyle {
private double grow = 0.08f;
@ -19,7 +16,7 @@ public class ParticleStylePopper implements ParticleStyle {
private int maxStep = 35;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
double radius = (1 - (double)step / maxStep);
for (int i = 0; i < helices; i++) {

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStylePulse implements ParticleStyle {
@ -18,7 +15,7 @@ public class ParticleStylePulse implements ParticleStyle {
private int numSteps = 15;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
double speed = getSpeedByEffect(particle.getEffect());
if (step == 0) {

View file

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

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleRings implements ParticleStyle {
private static double[] cos, sin;
@ -27,7 +24,7 @@ public class ParticleStyleRings implements ParticleStyle {
}
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
particles.add(new PParticle(location.clone().add(cos[index], sin[index], sin[index])));
particles.add(new PParticle(location.clone().add(cos[wrap(index + 16)], sin[wrap(index + 16)], sin[wrap(index + 16)])));

View file

@ -1,20 +1,17 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleSphere implements ParticleStyle {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
int density = 15;
double radius = 1.5f;
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < density; i++) {
double u = Math.random();

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.Collections;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleSpin implements ParticleStyle {
private static double[] cos, sin;

View file

@ -1,20 +1,17 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleSpiral implements ParticleStyle {
private int stepX = 0;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
for (int stepY = -60; stepY < 60; stepY += 10) {
double dx = -(Math.cos(((stepX + stepY) / 90D) * Math.PI * 2)) * 0.8;
double dy = stepY / 45D;

View file

@ -1,10 +1,14 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import dev.esophose.playerparticles.PlayerParticles;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -13,13 +17,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleSwords implements ParticleStyle, Listener {
private static final List<String> SWORD_NAMES;

View file

@ -1,21 +1,18 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleThick implements ParticleStyle {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> baseParticles = DefaultStyles.NORMAL.getParticles(particle, location);
int multiplyingFactor = 10; // Uses the same logic as ParticleStyleNormal except multiplies the resulting particles by 10x
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < baseParticles.size() * multiplyingFactor; i++) {
particles.add(baseParticles.get(i % baseParticles.size()));
}

View file

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

View file

@ -23,16 +23,13 @@
*/
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.styles.api.PParticle;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleVortex implements ParticleStyle {
private double grow = .05f;
@ -42,7 +39,7 @@ public class ParticleStyleVortex implements ParticleStyle {
private int maxStep = 70;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
double radius = 2 * (1 - (double)step / maxStep);
for (int i = 0; i < helices; i++) {

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleWhirl implements ParticleStyle {
@ -17,7 +14,7 @@ public class ParticleStyleWhirl implements ParticleStyle {
private int numSteps = 40;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
double speed = getSpeedByEffect(particle.getEffect());
for (int i = 0; i < points; i++) {

View file

@ -1,14 +1,11 @@
package dev.esophose.playerparticles.styles;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
import dev.esophose.playerparticles.particles.PParticle;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleWhirlwind implements ParticleStyle {
@ -17,7 +14,7 @@ public class ParticleStyleWhirlwind implements ParticleStyle {
private int numSteps = 40;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
double speed = getSpeedByEffect(particle.getEffect()) * 2.5;
// Orbit going clockwise

View file

@ -1,22 +1,19 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.util.VectorUtils;
import java.util.ArrayList;
import java.util.List;
import dev.esophose.playerparticles.util.VectorUtils;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.styles.api.PParticle;
import dev.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleWings implements ParticleStyle {
private int spawnTimer = 0; // Spawn particles every 3 ticks
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
List<PParticle> particles = new ArrayList<>();
if (spawnTimer == 0) {
for (double t = 0; t < Math.PI * 2; t += Math.PI / 48) {
double x = Math.sin(t) * (Math.pow(Math.E, Math.cos(t)) - 2 * Math.cos(t * 4) - Math.pow(Math.sin(t / 12), 5)) / 2;

View file

@ -0,0 +1,22 @@
package dev.esophose.playerparticles.util;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.styles.ParticleStyle;
import org.bukkit.Location;
public final class InputParser {
public static ParticleEffect parseEffect(PPlayer pplayer, String input) {
return null;
}
public static ParticleStyle parseStyle(PPlayer pplayer, String input) {
return null;
}
public static Location parseLocation(PPlayer pplayer, String input) {
return null;
}
}

View file

@ -1,16 +1,12 @@
package dev.esophose.playerparticles.util;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
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;
@ -21,6 +17,15 @@ import java.util.TimerTask;
import java.util.UUID;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.HttpsURLConnection;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
/**
* bStats collects some data for plugin authors.

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