mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-02-11 03:29:53 +00:00
Added command '/ppo', changed version to v6.2
This commit is contained in:
parent
cdc4d1d7ad
commit
a2d173d932
17 changed files with 311 additions and 181 deletions
2
pom.xml
2
pom.xml
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.esophose.playerparticles</groupId>
|
||||
<artifactId>PlayerParticles</artifactId>
|
||||
<version>6.1</version>
|
||||
<version>6.2</version>
|
||||
<name>PlayerParticles</name>
|
||||
<url>https://github.com/Esophose/PlayerParticles</url>
|
||||
<description>Display particles around your player using customized styles and data!</description>
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
/*
|
||||
* TODO: v6.2
|
||||
* TODO: v6.3
|
||||
* + Add new style 'tornado'
|
||||
* + Add new style 'doubleorbit'
|
||||
* + Add new style 'wings_<type>', multiple new wing types: fairy, demon
|
||||
* * Create lore line parser
|
||||
* * Make it so lore lines of the GUI are removed if the string is empty in the config
|
||||
* * Add ability to add line breaks to the lore with \n
|
||||
* + Add new style(s) 'wings_<type>', multiple new wing types: fairy, demon
|
||||
*/
|
||||
|
||||
package com.esophose.playerparticles;
|
||||
|
@ -13,6 +10,7 @@ package com.esophose.playerparticles;
|
|||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
@ -59,9 +57,8 @@ public class PlayerParticles extends JavaPlugin {
|
|||
public void onEnable() {
|
||||
pluginInstance = Bukkit.getServer().getPluginManager().getPlugin("PlayerParticles");
|
||||
|
||||
getCommand("pp").setTabCompleter(new ParticleCommandHandler());
|
||||
getCommand("pp").setExecutor(new ParticleCommandHandler());
|
||||
|
||||
this.registerCommands();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new ParticleManager(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new PluginUpdateListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new GuiHandler(), this);
|
||||
|
@ -114,6 +111,20 @@ public class PlayerParticles extends JavaPlugin {
|
|||
GuiHandler.forceCloseAllOpenGUIs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the commands for the plugin
|
||||
*/
|
||||
private void registerCommands() {
|
||||
ParticleCommandHandler pch = new ParticleCommandHandler();
|
||||
PluginCommand pp = this.getCommand("pp");
|
||||
PluginCommand ppo = this.getCommand("ppo");
|
||||
|
||||
pp.setTabCompleter(pch);
|
||||
pp.setExecutor(pch);
|
||||
ppo.setTabCompleter(pch);
|
||||
ppo.setExecutor(pch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the settings of the plugin
|
||||
*
|
||||
|
|
|
@ -17,7 +17,7 @@ public class EffectsCommandModule implements CommandModule {
|
|||
|
||||
List<String> effectList = PermissionManager.getEffectNamesUserHasPermissionFor(p);
|
||||
if (effectList.isEmpty()) {
|
||||
LangManager.sendMessage(p, Lang.EFFECT_LIST_EMPTY);
|
||||
LangManager.sendMessage(pplayer, Lang.EFFECT_LIST_EMPTY);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class EffectsCommandModule implements CommandModule {
|
|||
toSend = toSend.substring(0, toSend.length() - 2);
|
||||
}
|
||||
|
||||
LangManager.sendMessage(p, Lang.EFFECT_LIST, toSend);
|
||||
LangManager.sendMessage(pplayer, Lang.EFFECT_LIST, toSend);
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
||||
|
|
|
@ -35,17 +35,17 @@ public class FixedCommandModule implements CommandModule {
|
|||
Player p = pplayer.getPlayer();
|
||||
|
||||
if (!PermissionManager.canUseFixedEffects(p)) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_NO_PERMISSION);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_NO_PERMISSION);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 0) { // General information on command
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_CREATE);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_EDIT);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_REMOVE);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_LIST);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_INFO);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_CLEAR);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -76,13 +76,13 @@ public class FixedCommandModule implements CommandModule {
|
|||
handleClear(pplayer, p, cmdArgs);
|
||||
return;
|
||||
default:
|
||||
LangManager.sendMessage(p, Lang.FIXED_INVALID_COMMAND);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_CREATE);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_EDIT);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_REMOVE);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_LIST);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_INFO);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_CLEAR);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,12 +96,12 @@ public class FixedCommandModule implements CommandModule {
|
|||
private void handleCreate(PPlayer pplayer, Player p, String[] args) {
|
||||
boolean reachedMax = PermissionManager.hasPlayerReachedMaxFixedEffects(pplayer);
|
||||
if (reachedMax) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_MAX_REACHED);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_MAX_REACHED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 5 && !(args.length > 0 && args[0].equalsIgnoreCase("looking") && args.length >= 3)) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_MISSING_ARGS, 5 - args.length);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_MISSING_ARGS, 5 - args.length);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
Block targetBlock = p.getTargetBlock((Set<Material>)null, 8);
|
||||
int maxDistanceSqrd = 6 * 6;
|
||||
if (targetBlock.getLocation().distanceSquared(p.getLocation()) > maxDistanceSqrd) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_LOOKING_TOO_FAR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_LOOKING_TOO_FAR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
zPos = Double.parseDouble(args[2]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_INVALID_COORDS);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_INVALID_COORDS);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -160,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(p, Lang.FIXED_CREATE_OUT_OF_RANGE, maxCreationDistance);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_OUT_OF_RANGE, maxCreationDistance);
|
||||
return;
|
||||
}
|
||||
|
||||
ParticleEffect effect = ParticleEffect.fromName(args[3]);
|
||||
if (effect == null) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_EFFECT_INVALID, args[3]);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_EFFECT_INVALID, args[3]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasEffectPermission(p, effect)) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_EFFECT_NO_PERMISSION, effect.getName());
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_EFFECT_NO_PERMISSION, effect.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
ParticleStyle style = ParticleStyle.fromName(args[4]);
|
||||
if (style == null) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_STYLE_INVALID, args[4]);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_STYLE_INVALID, args[4]);
|
||||
return;
|
||||
} else if (!PermissionManager.hasStylePermission(p, style)) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_STYLE_NO_PERMISSION, args[4]);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_STYLE_NO_PERMISSION, args[4]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!style.canBeFixed()) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_STYLE_NON_FIXABLE, style.getName());
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_STYLE_NON_FIXABLE, style.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -204,12 +204,12 @@ public class FixedCommandModule implements CommandModule {
|
|||
try {
|
||||
note = Integer.parseInt(args[5]);
|
||||
} catch (Exception e) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (note < 0 || note > 24) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -230,12 +230,12 @@ public class FixedCommandModule implements CommandModule {
|
|||
g = Integer.parseInt(args[6]);
|
||||
b = Integer.parseInt(args[7]);
|
||||
} catch (Exception e) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,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(p, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,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(p, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,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(p, Lang.FIXED_CREATE_SUCCESS);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CREATE_SUCCESS);
|
||||
DataManager.saveFixedEffect(fixedEffect);
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
*/
|
||||
private void handleEdit(PPlayer pplayer, Player p, String[] args) {
|
||||
if (args.length < 3) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_MISSING_ARGS);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_MISSING_ARGS);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -296,13 +296,13 @@ public class FixedCommandModule implements CommandModule {
|
|||
try {
|
||||
id = Integer.parseInt(args[0]);
|
||||
} catch (Exception ex) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_INVALID_ID);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_ID);
|
||||
return;
|
||||
}
|
||||
|
||||
FixedParticleEffect fixedEffect = pplayer.getFixedEffectById(id);
|
||||
if (fixedEffect == null) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_INVALID_ID);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_ID);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
Block targetBlock = p.getTargetBlock((Set<Material>)null, 8);
|
||||
int maxDistanceSqrd = 6 * 6;
|
||||
if (targetBlock.getLocation().distanceSquared(p.getLocation()) > maxDistanceSqrd) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_LOOKING_TOO_FAR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_LOOKING_TOO_FAR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
zPos = Double.parseDouble(args[4]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_INVALID_COORDS);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_COORDS);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -354,7 +354,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(p, Lang.FIXED_EDIT_OUT_OF_RANGE, maxCreationDistance);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_OUT_OF_RANGE, maxCreationDistance);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_STYLE_NO_PERMISSION, style.getName());
|
||||
return;
|
||||
} else if (!style.canBeFixed()) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_STYLE_NON_FIXABLE, style.getName());
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_STYLE_NON_FIXABLE, style.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -402,12 +402,12 @@ public class FixedCommandModule implements CommandModule {
|
|||
try {
|
||||
note = Integer.parseInt(args[2]);
|
||||
} catch (Exception e) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (note < 0 || note > 24) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -428,12 +428,12 @@ public class FixedCommandModule implements CommandModule {
|
|||
g = Integer.parseInt(args[3]);
|
||||
b = Integer.parseInt(args[4]);
|
||||
} catch (Exception e) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -448,7 +448,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(p, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,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(p, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_DATA_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -476,7 +476,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
fixedEffect.getParticlePair().setItemMaterial(itemData);
|
||||
fixedEffect.getParticlePair().setBlockMaterial(blockData);
|
||||
} else {
|
||||
LangManager.sendMessage(p, Lang.FIXED_EDIT_INVALID_PROPERTY);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_EDIT_INVALID_PROPERTY);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -493,7 +493,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
*/
|
||||
private void handleRemove(PPlayer pplayer, Player p, String[] args) {
|
||||
if (args.length < 1) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_REMOVE_NO_ARGS);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_NO_ARGS);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -501,15 +501,15 @@ public class FixedCommandModule implements CommandModule {
|
|||
try {
|
||||
id = Integer.parseInt(args[0]);
|
||||
} catch (Exception e) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_REMOVE_ARGS_INVALID);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_ARGS_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pplayer.getFixedEffectById(id) != null) {
|
||||
DataManager.removeFixedEffect(pplayer.getUniqueId(), id);
|
||||
LangManager.sendMessage(p, Lang.FIXED_REMOVE_SUCCESS, id);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_SUCCESS, id);
|
||||
} else {
|
||||
LangManager.sendMessage(p, Lang.FIXED_REMOVE_INVALID, id);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_REMOVE_INVALID, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -525,7 +525,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
Collections.sort(ids);
|
||||
|
||||
if (ids.isEmpty()) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_LIST_NONE);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_LIST_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
msg += id;
|
||||
}
|
||||
|
||||
LangManager.sendMessage(p, Lang.FIXED_LIST_SUCCESS, msg);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_LIST_SUCCESS, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -549,7 +549,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
*/
|
||||
private void handleInfo(PPlayer pplayer, Player p, String[] args) {
|
||||
if (args.length < 1) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_INFO_NO_ARGS);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_INFO_NO_ARGS);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -557,20 +557,20 @@ public class FixedCommandModule implements CommandModule {
|
|||
try {
|
||||
id = Integer.parseInt(args[0]);
|
||||
} catch (Exception e) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_INFO_INVALID_ARGS);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_INFO_INVALID_ARGS);
|
||||
return;
|
||||
}
|
||||
|
||||
FixedParticleEffect fixedEffect = pplayer.getFixedEffectById(id);
|
||||
if (fixedEffect == null) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_INFO_INVALID, id);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_INFO_INVALID, id);
|
||||
return;
|
||||
}
|
||||
|
||||
ParticlePair particle = fixedEffect.getParticlePair();
|
||||
|
||||
DecimalFormat df = new DecimalFormat("0.##"); // Decimal formatter so the coords aren't super long
|
||||
LangManager.sendMessage(p, // @formatter:off
|
||||
LangManager.sendMessage(pplayer, // @formatter:off
|
||||
Lang.FIXED_INFO_SUCCESS,
|
||||
fixedEffect.getId(),
|
||||
fixedEffect.getLocation().getWorld().getName(),
|
||||
|
@ -592,12 +592,12 @@ public class FixedCommandModule implements CommandModule {
|
|||
*/
|
||||
private void handleClear(PPlayer pplayer, Player p, String[] args) {
|
||||
if (!PermissionManager.canClearFixedEffects(p)) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CLEAR_NO_PERMISSION);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CLEAR_NO_PERMISSION);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CLEAR_NO_ARGS);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CLEAR_NO_ARGS);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -605,7 +605,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
try {
|
||||
radius = Math.abs(Integer.parseInt(args[0]));
|
||||
} catch (Exception e) {
|
||||
LangManager.sendMessage(p, Lang.FIXED_CLEAR_INVALID_ARGS);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CLEAR_INVALID_ARGS);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -619,7 +619,7 @@ public class FixedCommandModule implements CommandModule {
|
|||
for (FixedParticleEffect fixedEffect : fixedEffectsToRemove)
|
||||
DataManager.removeFixedEffect(fixedEffect.getOwnerUniqueId(), fixedEffect.getId());
|
||||
|
||||
LangManager.sendMessage(p, Lang.FIXED_CLEAR_SUCCESS, fixedEffectsToRemove.size(), radius);
|
||||
LangManager.sendMessage(pplayer, Lang.FIXED_CLEAR_SUCCESS, fixedEffectsToRemove.size(), radius);
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.Arrays;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.esophose.playerparticles.manager.DataManager;
|
||||
|
@ -19,20 +18,18 @@ import com.esophose.playerparticles.particles.ParticlePair;
|
|||
public class GroupCommandModule implements CommandModule {
|
||||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
Player p = pplayer.getPlayer();
|
||||
|
||||
List<String> validCommands = Arrays.asList(new String[] { "save", "load", "remove", "info", "list" });
|
||||
if (args.length == 0 || !validCommands.contains(args[0])) {
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_SAVE);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_LOAD);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_REMOVE);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_INFO);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_LIST);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 1 && !args[0].equalsIgnoreCase("list")) {
|
||||
LangManager.sendMessage(p, Lang.GROUP_NO_NAME, args[0].toLowerCase());
|
||||
LangManager.sendMessage(pplayer, Lang.GROUP_NO_NAME, args[0].toLowerCase());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -53,11 +50,11 @@ public class GroupCommandModule implements CommandModule {
|
|||
onList(pplayer);
|
||||
break;
|
||||
default:
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_SAVE);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_LOAD);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_REMOVE);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_INFO);
|
||||
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_GROUP_LIST);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,19 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.esophose.playerparticles.manager.DataManager;
|
||||
import com.esophose.playerparticles.manager.LangManager;
|
||||
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||
import com.esophose.playerparticles.manager.PermissionManager;
|
||||
import com.esophose.playerparticles.particles.OtherPPlayer;
|
||||
import com.esophose.playerparticles.particles.PPlayer;
|
||||
|
||||
public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
|
||||
|
@ -80,8 +83,8 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Called when a player executes a /pp command
|
||||
* Checks what /pp command it is and calls the corresponding module
|
||||
* Called when a player executes a PlayerParticles command
|
||||
* Checks what PlayerParticles command it is and calls the corresponding module
|
||||
*
|
||||
* @param sender Who executed the command
|
||||
* @param cmd The command
|
||||
|
@ -90,30 +93,68 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
|
|||
* @return true
|
||||
*/
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Error: PlayerParticles only supports players executing commands.");
|
||||
return true;
|
||||
if (cmd.getName().equalsIgnoreCase("pp")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Error: PlayerParticles only supports players executing commands.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = (Player) sender;
|
||||
|
||||
DataManager.getPPlayer(p.getUniqueId(), (pplayer) -> {
|
||||
String commandName = args.length > 0 ? args[0] : "";
|
||||
CommandModule commandModule = findMatchingCommand(commandName);
|
||||
|
||||
if (commandModule != null) {
|
||||
if (commandModule.requiresEffects() && PermissionManager.getEffectNamesUserHasPermissionFor(p).isEmpty()) {
|
||||
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_NO_EFFECTS);
|
||||
} else {
|
||||
String[] cmdArgs = new String[0];
|
||||
if (args.length > 1) cmdArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
commandModule.onCommandExecute(pplayer, cmdArgs);
|
||||
}
|
||||
} else {
|
||||
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN);
|
||||
}
|
||||
});
|
||||
} else if (cmd.getName().equalsIgnoreCase("ppo")) {
|
||||
if (!PermissionManager.canOverride(sender)) {
|
||||
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_MISSING_ARGS);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player other = Bukkit.getPlayer(args[0]);
|
||||
if (other == null) {
|
||||
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_UNKNOWN_PLAYER, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandModule commandModule = findMatchingCommand(args[1]);
|
||||
if (commandModule == null) {
|
||||
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_UNKNOWN_COMMAND, args[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (commandModule.requiresEffects() && PermissionManager.getEffectNamesUserHasPermissionFor(other).isEmpty()) {
|
||||
LangManager.sendCommandSenderMessage(sender, Lang.COMMAND_ERROR_NO_EFFECTS);
|
||||
return true;
|
||||
}
|
||||
|
||||
DataManager.getPPlayer(other.getUniqueId(), (pplayer) -> {
|
||||
OtherPPlayer otherPPlayer = new OtherPPlayer(sender, pplayer);
|
||||
|
||||
LangManager.sendCommandSenderMessage(sender, Lang.OTHER_SUCCESS, other.getName());
|
||||
|
||||
String[] cmdArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
commandModule.onCommandExecute(otherPPlayer, cmdArgs);
|
||||
});
|
||||
}
|
||||
|
||||
Player p = (Player) sender;
|
||||
|
||||
DataManager.getPPlayer(p.getUniqueId(), (pplayer) -> {
|
||||
String commandName = args.length > 0 ? args[0] : "";
|
||||
CommandModule commandModule = findMatchingCommand(commandName);
|
||||
|
||||
if (commandModule != null) {
|
||||
if (commandModule.requiresEffects() && PermissionManager.getEffectNamesUserHasPermissionFor(p).isEmpty()) {
|
||||
LangManager.sendMessage(p, Lang.COMMAND_ERROR_NO_EFFECTS);
|
||||
} else {
|
||||
String[] cmdArgs = new String[0];
|
||||
if (args.length > 1) cmdArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
commandModule.onCommandExecute(pplayer, cmdArgs);
|
||||
}
|
||||
} else {
|
||||
LangManager.sendMessage(p, Lang.COMMAND_ERROR_UNKNOWN);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -127,9 +168,9 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
|
|||
* @return A list of commands available to the sender
|
||||
*/
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
if (!(sender instanceof Player)) return new ArrayList<String>();
|
||||
|
||||
if (cmd.getName().equalsIgnoreCase("pp")) {
|
||||
if (!(sender instanceof Player)) return new ArrayList<String>();
|
||||
|
||||
PPlayer pplayer = DataManager.getPPlayer(((Player) sender).getUniqueId());
|
||||
if (pplayer == null) return new ArrayList<String>();
|
||||
|
||||
|
@ -138,12 +179,41 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
|
|||
return commandModule.onTabComplete(pplayer, args);
|
||||
} else if (args.length >= 2) {
|
||||
CommandModule commandModule = findMatchingCommand(args[0]);
|
||||
String[] cmdArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
if (commandModule != null) {
|
||||
String[] cmdArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
return commandModule.onTabComplete(pplayer, cmdArgs);
|
||||
}
|
||||
}
|
||||
} else if (cmd.getName().equalsIgnoreCase("ppo")) {
|
||||
List<String> completions = new ArrayList<String>();
|
||||
|
||||
if (args.length < 2) {
|
||||
List<String> playerNames = new ArrayList<String>();
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
playerNames.add(player.getName());
|
||||
|
||||
if (args.length == 0) completions = playerNames;
|
||||
else StringUtil.copyPartialMatches(args[0], playerNames, completions);
|
||||
} else if (args.length == 2) {
|
||||
List<String> commandNames = ParticleCommandHandler.getCommandNames();
|
||||
StringUtil.copyPartialMatches(args[1], commandNames, completions);
|
||||
} else {
|
||||
Player otherPlayer = Bukkit.getPlayer(args[0]);
|
||||
if (otherPlayer != null) {
|
||||
PPlayer other = DataManager.getPPlayer(otherPlayer.getUniqueId());
|
||||
if (other != null) {
|
||||
CommandModule commandModule = findMatchingCommand(args[1]);
|
||||
if (commandModule != null) {
|
||||
String[] cmdArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
completions = commandModule.onTabComplete(other, cmdArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return completions;
|
||||
}
|
||||
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class StylesCommandModule implements CommandModule {
|
|||
toSend = toSend.substring(0, toSend.length() - 2);
|
||||
}
|
||||
|
||||
LangManager.sendMessage(p, Lang.STYLE_LIST, toSend);
|
||||
LangManager.sendMessage(pplayer, Lang.STYLE_LIST, toSend);
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
||||
|
|
|
@ -157,7 +157,7 @@ public class GuiActionButton {
|
|||
* @param lore The lines of lore
|
||||
* @return A parsed list of lore text
|
||||
*/
|
||||
private List<String> parseLore(String... lore) {
|
||||
public static List<String> parseLore(String... lore) {
|
||||
List<String> parsedLore = new ArrayList<String>();
|
||||
for (String line : lore) {
|
||||
// Try to maintain the color going to the next line if it's split
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.esophose.playerparticles.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -42,12 +41,12 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
currentIconMeta.setDisplayName(LangManager.getText(Lang.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()),
|
||||
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()),
|
||||
"",
|
||||
" ",
|
||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_COMMANDS_INFO)
|
||||
};
|
||||
currentIconMeta.setLore(Arrays.asList(currentIconLore));
|
||||
currentIconMeta.setLore(GuiActionButton.parseLore(currentIconLore));
|
||||
currentIconMeta.setOwner(pplayer.getPlayer().getName());
|
||||
headIcon.setItemMeta(currentIconMeta);
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ import java.nio.file.Paths;
|
|||
import java.text.MessageFormat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.esophose.playerparticles.PlayerParticles;
|
||||
import com.esophose.playerparticles.manager.SettingManager.PSetting;
|
||||
|
@ -49,6 +49,7 @@ public class LangManager {
|
|||
COMMAND_DESCRIPTION_TOGGLE,
|
||||
COMMAND_DESCRIPTION_VERSION,
|
||||
COMMAND_DESCRIPTION_WORLDS,
|
||||
COMMAND_DESCRIPTION_OTHER,
|
||||
|
||||
// Sub-Command Usage
|
||||
COMMAND_DESCRIPTION_FIXED_CREATE,
|
||||
|
@ -67,6 +68,13 @@ public class LangManager {
|
|||
ID_INVALID,
|
||||
ID_UNKNOWN,
|
||||
|
||||
// Other Command
|
||||
OTHER_NO_PERMISSION,
|
||||
OTHER_MISSING_ARGS,
|
||||
OTHER_UNKNOWN_PLAYER,
|
||||
OTHER_UNKNOWN_COMMAND,
|
||||
OTHER_SUCCESS,
|
||||
|
||||
// Add Command
|
||||
ADD_REACHED_MAX,
|
||||
ADD_PARTICLE_APPLIED,
|
||||
|
@ -280,7 +288,11 @@ public class LangManager {
|
|||
GUI_EDIT_DATA_COLOR_BLACK,
|
||||
GUI_EDIT_DATA_COLOR_GRAY,
|
||||
GUI_EDIT_DATA_COLOR_LIGHT_GRAY,
|
||||
GUI_EDIT_DATA_COLOR_WHITE;
|
||||
GUI_EDIT_DATA_COLOR_WHITE,
|
||||
|
||||
// Update Available
|
||||
UPDATE_AVAILABLE;
|
||||
|
||||
// @formatter:on
|
||||
|
||||
private String message;
|
||||
|
@ -398,13 +410,13 @@ public class LangManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the given player
|
||||
* Sends a message to the given PPlayer
|
||||
*
|
||||
* @param player The player to send the message to
|
||||
* @param pplayer The player to send the message to
|
||||
* @param messageType The message to send to the player
|
||||
* @param replacements The replacements for the message
|
||||
*/
|
||||
public static void sendMessage(Player player, Lang messageType, Object... replacements) {
|
||||
public static void sendMessage(PPlayer pplayer, Lang messageType, Object... replacements) {
|
||||
if (!PSetting.MESSAGES_ENABLED.getBoolean()) return;
|
||||
|
||||
String message = messageType.get(replacements);
|
||||
|
@ -417,37 +429,7 @@ public class LangManager {
|
|||
|
||||
if (message.trim().equals("")) return;
|
||||
|
||||
player.sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the given PPlayer
|
||||
*
|
||||
* @param pplayer The player to send the message to
|
||||
* @param messageType The message to send to the player
|
||||
* @param replacements The replacements for the message
|
||||
*/
|
||||
public static void sendMessage(PPlayer pplayer, Lang messageType, Object... replacements) {
|
||||
sendMessage(pplayer.getPlayer(), messageType, replacements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a custom message to a player
|
||||
* Used in cases of string building
|
||||
*
|
||||
* @param player The player to send the message to
|
||||
* @param message The message to send to the player
|
||||
*/
|
||||
public static void sendCustomMessage(Player player, String message) {
|
||||
if (!PSetting.MESSAGES_ENABLED.getBoolean()) return;
|
||||
|
||||
if (message.trim().length() == 0) return;
|
||||
|
||||
if (PSetting.USE_MESSAGE_PREFIX.getBoolean()) {
|
||||
message = parseColors(PSetting.MESSAGE_PREFIX.getString()) + " " + message;
|
||||
}
|
||||
|
||||
player.sendMessage(message);
|
||||
pplayer.getMessageDestination().sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -458,26 +440,15 @@ public class LangManager {
|
|||
* @param message The message to send to the player
|
||||
*/
|
||||
public static void sendCustomMessage(PPlayer pplayer, String message) {
|
||||
sendCustomMessage(pplayer.getPlayer(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to a Player without the prefix
|
||||
*
|
||||
* @param player The player to send the message to
|
||||
* @param messageType The message type to send the player
|
||||
* @param replacements The replacements for the message
|
||||
*/
|
||||
public static void sendSimpleMessage(Player player, Lang messageType, Object... replacements) {
|
||||
if (!PSetting.MESSAGES_ENABLED.getBoolean()) return;
|
||||
|
||||
String message = messageType.get(replacements);
|
||||
if (message.trim().length() == 0) return;
|
||||
|
||||
if (message.length() == 0) return;
|
||||
if (PSetting.USE_MESSAGE_PREFIX.getBoolean()) {
|
||||
message = parseColors(PSetting.MESSAGE_PREFIX.getString()) + " " + message;
|
||||
}
|
||||
|
||||
if (message.trim().equals("")) return;
|
||||
|
||||
player.sendMessage(message);
|
||||
pplayer.getMessageDestination().sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -488,7 +459,38 @@ public class LangManager {
|
|||
* @param replacements The replacements for the message
|
||||
*/
|
||||
public static void sendSimpleMessage(PPlayer pplayer, Lang messageType, Object... replacements) {
|
||||
sendSimpleMessage(pplayer.getPlayer(), messageType, replacements);
|
||||
if (!PSetting.MESSAGES_ENABLED.getBoolean()) return;
|
||||
|
||||
String message = messageType.get(replacements);
|
||||
|
||||
if (message.length() == 0) return;
|
||||
|
||||
if (message.trim().equals("")) return;
|
||||
|
||||
pplayer.getMessageDestination().sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to a CommandSender
|
||||
*
|
||||
* @param sender The CommandSender to send the message to
|
||||
* @param messageType The message type to send the player
|
||||
* @param replacements The replacements for the message
|
||||
*/
|
||||
public static void sendCommandSenderMessage(CommandSender sender, Lang messageType, Object... replacements) {
|
||||
if (!PSetting.MESSAGES_ENABLED.getBoolean()) return;
|
||||
|
||||
String message = messageType.get(replacements);
|
||||
|
||||
if (message.length() == 0) return;
|
||||
|
||||
if (PSetting.USE_MESSAGE_PREFIX.getBoolean()) {
|
||||
message = parseColors(PSetting.MESSAGE_PREFIX.getString()) + " " + message;
|
||||
}
|
||||
|
||||
if (message.trim().equals("")) return;
|
||||
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.esophose.playerparticles.manager;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.esophose.playerparticles.manager.SettingManager.PSetting;
|
||||
|
@ -68,6 +69,17 @@ public class PermissionManager {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player can use /ppo
|
||||
*
|
||||
* @param sender The CommandSender to check
|
||||
* @return If the player can use /ppo
|
||||
*/
|
||||
public static boolean canOverride(CommandSender sender) {
|
||||
if (!(sender instanceof Player)) return true;
|
||||
return PPermission.ALL.check((Player)sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given player has reached the max number of particles in their active group
|
||||
*
|
||||
|
|
19
src/com/esophose/playerparticles/particles/OtherPPlayer.java
Normal file
19
src/com/esophose/playerparticles/particles/OtherPPlayer.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package com.esophose.playerparticles.particles;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class OtherPPlayer extends PPlayer {
|
||||
|
||||
private CommandSender sender;
|
||||
|
||||
public OtherPPlayer(CommandSender sender, PPlayer other) {
|
||||
super(other.getUniqueId(), other.getParticleGroups(), other.getFixedParticles(), !other.canSeeParticles());
|
||||
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public CommandSender getMessageDestination() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.esophose.playerparticles.styles.api.ParticleStyle;
|
||||
|
@ -72,6 +73,15 @@ public class PPlayer {
|
|||
return Bukkit.getPlayer(this.playerUUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the destination for messages
|
||||
*
|
||||
* @return The destination for messages
|
||||
*/
|
||||
public CommandSender getMessageDestination() {
|
||||
return this.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the Player can see particles spawned by the plugin or not
|
||||
*
|
||||
|
@ -258,7 +268,8 @@ public class PPlayer {
|
|||
|
||||
/**
|
||||
* Gets the primary particle (ID 1) for the PPlayer
|
||||
* @return
|
||||
*
|
||||
* @return The particle with an ID of 1 for the PPlayer or a new one if one doesn't exist
|
||||
*/
|
||||
public ParticlePair getPrimaryParticle() {
|
||||
ParticlePair primaryParticle = this.getActiveParticle(1);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.esophose.playerparticles.updater;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import com.esophose.playerparticles.PlayerParticles;
|
||||
import com.esophose.playerparticles.manager.LangManager;
|
||||
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||
|
||||
public class PluginUpdateListener implements Listener {
|
||||
|
||||
|
@ -17,12 +17,8 @@ public class PluginUpdateListener implements Listener {
|
|||
*/
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
if (e.getPlayer().isOp()) {
|
||||
if (PlayerParticles.updateVersion != null) { // @formatter:off
|
||||
LangManager.sendCustomMessage(e.getPlayer(), ChatColor.YELLOW + "An update (" + ChatColor.AQUA + "v" + PlayerParticles.updateVersion + ChatColor.YELLOW + ") is available! " +
|
||||
"You are running " + ChatColor.AQUA + "v" + PlayerParticles.getPlugin().getDescription().getVersion() + ChatColor.YELLOW +
|
||||
". https://www.spigotmc.org/resources/playerparticles.40261/");
|
||||
} // @formatter:on
|
||||
if (e.getPlayer().isOp() && PlayerParticles.updateVersion != null) {
|
||||
LangManager.sendCommandSenderMessage(e.getPlayer(), Lang.UPDATE_AVAILABLE, PlayerParticles.updateVersion, PlayerParticles.getPlugin().getDescription().getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# This value is the version of the plugin that last modified the config file
|
||||
# Changing this value manually will likely result in data loss and errors!
|
||||
# Do not change this manually unless specifically told to by the plugin author
|
||||
version: 6.1
|
||||
version: 6.2
|
||||
|
||||
# Check for new versions of the plugin
|
||||
# Default: true
|
||||
|
|
|
@ -36,6 +36,7 @@ command-description-styles: 'Display a list of styles you can use'
|
|||
command-description-toggle: 'Toggles particle visibility on/off'
|
||||
command-description-version: 'Display the plugin version and author'
|
||||
command-description-worlds: 'Find out what worlds particles are disabled in'
|
||||
command-description-other: 'Execute a /pp command for another player'
|
||||
|
||||
# Sub-Command Usage
|
||||
command-description-fixed-create: '&e/pp fixed create <<x> <y> <z>|<looking>> <effect> <style> [data] - Creates a new fixed effect'
|
||||
|
@ -54,6 +55,13 @@ command-description-group-info: '&e/pp group info <name> - List the particles sa
|
|||
id-invalid: '&cThe ID you entered is invalid, it must be a positive whole number!'
|
||||
id-unknown: '&cYou do not have a particle applied with the ID &b{0}&c!'
|
||||
|
||||
# Other Command
|
||||
other-no-permission: '&cYou do not have permission to execute PlayerParticles commands for other players!'
|
||||
other-missing-args: '&cYou are missing some arguments. &b/ppo <player> <command>'
|
||||
other-unknown-player: '&cThe player &b{0} &cwas not found. They must be online.'
|
||||
other-unknown-command: '&cThe command &b/pp {0} &cdoes not exist.'
|
||||
other-success: '&eExecuted /pp command for &b{0}&e. Output:'
|
||||
|
||||
# Add Command
|
||||
add-reached-max: '&cUnable to apply particle, you have reached the maximum amount of &b{0} &callowed!'
|
||||
add-particle-applied: '&aA new particle has been applied with the effect &b{0}&a, style &b{1}&a, and data &b{2}&a!'
|
||||
|
@ -168,7 +176,7 @@ fixed-edit-style-no-permission: '&cUnable to edit fixed effect, you do not have
|
|||
fixed-edit-style-non-fixable: '&cUnable to edit fixed effect, the style &b{0} &ccan not be used in fixed effects!'
|
||||
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!'
|
||||
fixed-edit-data-none: '&cUnable to edit fixed effect, the effect does not require any data!'
|
||||
fixed-edit-success: '&aUpdated the &b{0} &aof the fixed effect with an ID of &b{1}!'
|
||||
fixed-edit-success: '&aUpdated the &b{0} &aof the fixed effect with an ID of &b{1}&a!'
|
||||
|
||||
fixed-remove-invalid: '&cUnable to remove fixed effect, you do not have a fixed effect with the ID of &b{0}&c!'
|
||||
fixed-remove-no-args: '&cYou did not specify an ID to remove!'
|
||||
|
@ -268,3 +276,6 @@ gui-edit-data-color-black: '&8black'
|
|||
gui-edit-data-color-gray: '&8gray'
|
||||
gui-edit-data-color-light-gray: '&7light gray'
|
||||
gui-edit-data-color-white: '&fwhite'
|
||||
|
||||
# Update Available
|
||||
update-available: '&eAn update (&b{0}&e) is available! You are running &bv{1}&e. https://www.spigotmc.org/resources/playerparticles.40261/'
|
|
@ -1,6 +1,6 @@
|
|||
name: PlayerParticles
|
||||
main: com.esophose.playerparticles.PlayerParticles
|
||||
version: 6.1
|
||||
version: 6.2
|
||||
api-version: 1.13
|
||||
description: Display particles around your player using customized styles and data!
|
||||
author: Esophose
|
||||
|
@ -8,3 +8,5 @@ website: https://www.spigotmc.org/resources/playerparticles.40261/
|
|||
commands:
|
||||
pp:
|
||||
description: The main PlayerParticles command. By default, opens the GUI.
|
||||
ppo:
|
||||
description: The secondary PlayerParticles command. Used for modifying the particles of other players.
|
||||
|
|
Loading…
Reference in a new issue