diff --git a/pom.xml b/pom.xml
index 7a48c4c..8d10296 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.esophose.playerparticles
PlayerParticles
- 6.4
+ 6.5
PlayerParticles
https://github.com/Esophose/PlayerParticles
Display particles around your player and blocks using customized styles and data!
@@ -11,10 +11,19 @@
src
+ false
**/*.java
+ **/*.yml
+
+ src
+ true
+
+ **/*.yml
+
+
@@ -101,7 +110,7 @@
org.spigotmc
spigot-api
- 1.14-R0.1-SNAPSHOT
+ 1.14.3-R0.1-SNAPSHOT
diff --git a/src/com/esophose/playerparticles/command/AddCommandModule.java b/src/com/esophose/playerparticles/command/AddCommandModule.java
index 7426411..96de0e6 100644
--- a/src/com/esophose/playerparticles/command/AddCommandModule.java
+++ b/src/com/esophose/playerparticles/command/AddCommandModule.java
@@ -203,4 +203,8 @@ public class AddCommandModule implements CommandModule {
return true;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/CommandModule.java b/src/com/esophose/playerparticles/command/CommandModule.java
index 44be4b2..0b699c9 100644
--- a/src/com/esophose/playerparticles/command/CommandModule.java
+++ b/src/com/esophose/playerparticles/command/CommandModule.java
@@ -52,6 +52,11 @@ public interface CommandModule {
* @return If the player must have effects to use this command
*/
boolean requiresEffects();
+
+ /**
+ * @return true if this command can be executed from console, otherwise false
+ */
+ boolean canConsoleExecute();
/**
* Displays a command's usage to the player
diff --git a/src/com/esophose/playerparticles/command/DataCommandModule.java b/src/com/esophose/playerparticles/command/DataCommandModule.java
index ef64757..94c1cfc 100644
--- a/src/com/esophose/playerparticles/command/DataCommandModule.java
+++ b/src/com/esophose/playerparticles/command/DataCommandModule.java
@@ -67,4 +67,8 @@ public class DataCommandModule implements CommandModule {
return true;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/DefaultCommandModule.java b/src/com/esophose/playerparticles/command/DefaultCommandModule.java
index 9eefee8..ea25d56 100644
--- a/src/com/esophose/playerparticles/command/DefaultCommandModule.java
+++ b/src/com/esophose/playerparticles/command/DefaultCommandModule.java
@@ -16,7 +16,7 @@ public class DefaultCommandModule implements CommandModule {
}
public List onTabComplete(PPlayer pplayer, String[] args) {
- List matches = new ArrayList();
+ List matches = new ArrayList<>();
List commandNames = ParticleCommandHandler.getCommandNames();
if (args.length == 0) return commandNames;
@@ -42,4 +42,8 @@ public class DefaultCommandModule implements CommandModule {
return true;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/EditCommandModule.java b/src/com/esophose/playerparticles/command/EditCommandModule.java
index 17197c9..bf5f6f5 100644
--- a/src/com/esophose/playerparticles/command/EditCommandModule.java
+++ b/src/com/esophose/playerparticles/command/EditCommandModule.java
@@ -314,4 +314,8 @@ public class EditCommandModule implements CommandModule {
return true;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/EffectsCommandModule.java b/src/com/esophose/playerparticles/command/EffectsCommandModule.java
index 9f72d0d..97424c3 100644
--- a/src/com/esophose/playerparticles/command/EffectsCommandModule.java
+++ b/src/com/esophose/playerparticles/command/EffectsCommandModule.java
@@ -53,4 +53,8 @@ public class EffectsCommandModule implements CommandModule {
return false;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/FixedCommandModule.java b/src/com/esophose/playerparticles/command/FixedCommandModule.java
index 2c649a0..b678bd2 100644
--- a/src/com/esophose/playerparticles/command/FixedCommandModule.java
+++ b/src/com/esophose/playerparticles/command/FixedCommandModule.java
@@ -793,4 +793,8 @@ public class FixedCommandModule implements CommandModule {
return true;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/GUICommandModule.java b/src/com/esophose/playerparticles/command/GUICommandModule.java
index 0997672..a00c3b4 100644
--- a/src/com/esophose/playerparticles/command/GUICommandModule.java
+++ b/src/com/esophose/playerparticles/command/GUICommandModule.java
@@ -62,4 +62,8 @@ public class GUICommandModule implements CommandModule {
return true;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/GroupCommandModule.java b/src/com/esophose/playerparticles/command/GroupCommandModule.java
index 284b836..56aaecb 100644
--- a/src/com/esophose/playerparticles/command/GroupCommandModule.java
+++ b/src/com/esophose/playerparticles/command/GroupCommandModule.java
@@ -315,4 +315,8 @@ public class GroupCommandModule implements CommandModule {
return false;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/HelpCommandModule.java b/src/com/esophose/playerparticles/command/HelpCommandModule.java
index 001ea9f..ab1fd8c 100644
--- a/src/com/esophose/playerparticles/command/HelpCommandModule.java
+++ b/src/com/esophose/playerparticles/command/HelpCommandModule.java
@@ -38,4 +38,8 @@ public class HelpCommandModule implements CommandModule {
return false;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/ListCommandModule.java b/src/com/esophose/playerparticles/command/ListCommandModule.java
index c202c11..13110ee 100644
--- a/src/com/esophose/playerparticles/command/ListCommandModule.java
+++ b/src/com/esophose/playerparticles/command/ListCommandModule.java
@@ -50,4 +50,8 @@ public class ListCommandModule implements CommandModule {
return true;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/ParticleCommandHandler.java b/src/com/esophose/playerparticles/command/ParticleCommandHandler.java
index bae2528..7451e5d 100644
--- a/src/com/esophose/playerparticles/command/ParticleCommandHandler.java
+++ b/src/com/esophose/playerparticles/command/ParticleCommandHandler.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import com.esophose.playerparticles.particles.OtherPPlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -96,27 +97,32 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
*/
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("pp")) {
- if (!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "Error: This command can only be executed by a player.");
+ String commandName = args.length > 0 ? args[0] : "";
+ CommandModule commandModule = findMatchingCommand(commandName);
+ if (commandModule == null) {
+ sender.sendMessage(LangManager.getText(Lang.COMMAND_ERROR_UNKNOWN));
+ return true;
+ }
+
+ String[] cmdArgs = args.length > 1 ? Arrays.copyOfRange(args, 1, args.length) : new String[0];
+
+ if (!commandModule.canConsoleExecute()) {
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.RED + "Error: This command can only be executed by a player.");
+ return true;
+ }
+ } else {
+ commandModule.onCommandExecute(new OtherPPlayer(sender), cmdArgs);
return true;
}
Player p = (Player) sender;
DataManager.getPPlayer(p.getUniqueId(), (pplayer) -> {
- 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);
- }
+ if (commandModule.requiresEffects() && PermissionManager.getEffectNamesUserHasPermissionFor(p).isEmpty()) {
+ LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_NO_EFFECTS);
} else {
- LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN);
+ commandModule.onCommandExecute(pplayer, cmdArgs);
}
});
} else if (cmd.getName().equalsIgnoreCase("ppo")) {
diff --git a/src/com/esophose/playerparticles/command/ReloadCommandModule.java b/src/com/esophose/playerparticles/command/ReloadCommandModule.java
index 3e50859..84bb72b 100644
--- a/src/com/esophose/playerparticles/command/ReloadCommandModule.java
+++ b/src/com/esophose/playerparticles/command/ReloadCommandModule.java
@@ -12,7 +12,7 @@ import com.esophose.playerparticles.particles.PPlayer;
public class ReloadCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
- if (PermissionManager.canReloadPlugin(pplayer.getPlayer())) {
+ if (PermissionManager.canReloadPlugin(pplayer.getMessageDestination())) {
PlayerParticles.getPlugin().reload(false);
LangManager.sendMessage(pplayer, Lang.RELOAD_SUCCESS);
PlayerParticles.getPlugin().getLogger().info("Reloaded configuration.");
@@ -41,4 +41,8 @@ public class ReloadCommandModule implements CommandModule {
return false;
}
+ public boolean canConsoleExecute() {
+ return true;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/RemoveCommandModule.java b/src/com/esophose/playerparticles/command/RemoveCommandModule.java
index 37711cb..bac2b17 100644
--- a/src/com/esophose/playerparticles/command/RemoveCommandModule.java
+++ b/src/com/esophose/playerparticles/command/RemoveCommandModule.java
@@ -130,4 +130,8 @@ public class RemoveCommandModule implements CommandModule {
return true;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/ResetCommandModule.java b/src/com/esophose/playerparticles/command/ResetCommandModule.java
index bc9137c..21dcfb8 100644
--- a/src/com/esophose/playerparticles/command/ResetCommandModule.java
+++ b/src/com/esophose/playerparticles/command/ResetCommandModule.java
@@ -37,4 +37,8 @@ public class ResetCommandModule implements CommandModule {
return false;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/StylesCommandModule.java b/src/com/esophose/playerparticles/command/StylesCommandModule.java
index 8c23803..c9e7c78 100644
--- a/src/com/esophose/playerparticles/command/StylesCommandModule.java
+++ b/src/com/esophose/playerparticles/command/StylesCommandModule.java
@@ -48,4 +48,8 @@ public class StylesCommandModule implements CommandModule {
return false;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/ToggleCommandModule.java b/src/com/esophose/playerparticles/command/ToggleCommandModule.java
index 8693ded..0932804 100644
--- a/src/com/esophose/playerparticles/command/ToggleCommandModule.java
+++ b/src/com/esophose/playerparticles/command/ToggleCommandModule.java
@@ -41,4 +41,8 @@ public class ToggleCommandModule implements CommandModule {
return false;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/VersionCommandModule.java b/src/com/esophose/playerparticles/command/VersionCommandModule.java
index a2851c2..df5ae83 100644
--- a/src/com/esophose/playerparticles/command/VersionCommandModule.java
+++ b/src/com/esophose/playerparticles/command/VersionCommandModule.java
@@ -37,4 +37,8 @@ public class VersionCommandModule implements CommandModule {
return false;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/command/WorldsCommandModule.java b/src/com/esophose/playerparticles/command/WorldsCommandModule.java
index d225cde..9fbc37f 100644
--- a/src/com/esophose/playerparticles/command/WorldsCommandModule.java
+++ b/src/com/esophose/playerparticles/command/WorldsCommandModule.java
@@ -45,4 +45,8 @@ public class WorldsCommandModule implements CommandModule {
return false;
}
+ public boolean canConsoleExecute() {
+ return false;
+ }
+
}
diff --git a/src/com/esophose/playerparticles/manager/DataManager.java b/src/com/esophose/playerparticles/manager/DataManager.java
index 2d0bcd5..31aae35 100644
--- a/src/com/esophose/playerparticles/manager/DataManager.java
+++ b/src/com/esophose/playerparticles/manager/DataManager.java
@@ -1,14 +1,5 @@
package com.esophose.playerparticles.manager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.bukkit.Material;
-import org.bukkit.scheduler.BukkitRunnable;
-
import com.esophose.playerparticles.PlayerParticles;
import com.esophose.playerparticles.particles.FixedParticleEffect;
import com.esophose.playerparticles.particles.PPlayer;
@@ -19,6 +10,14 @@ import com.esophose.playerparticles.particles.ParticleGroup;
import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.styles.api.ParticleStyle;
import com.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;
/**
* All data changes to PPlayers such as group or fixed effect changes must be done through here,
@@ -55,6 +54,7 @@ public class DataManager {
* @param callback The callback to execute with the found pplayer, or a newly generated one
*/
public static void getPPlayer(UUID playerUUID, ConfigurationCallback callback) {
+
// Try to get them from cache first
PPlayer fromCache = getPPlayer(playerUUID);
if (fromCache != null) {
@@ -471,12 +471,8 @@ public class DataManager {
*
* @param asyncCallback The callback to run on a separate thread
*/
- private static void async(SyncInterface asyncCallback) {
- new BukkitRunnable() {
- public void run() {
- asyncCallback.execute();
- }
- }.runTaskAsynchronously(PlayerParticles.getPlugin());
+ private static void async(Runnable asyncCallback) {
+ Bukkit.getScheduler().runTaskAsynchronously(PlayerParticles.getPlugin(), asyncCallback);
}
/**
@@ -484,20 +480,8 @@ public class DataManager {
*
* @param syncCallback The callback to run on the main thread
*/
- private static void sync(SyncInterface syncCallback) {
- new BukkitRunnable() {
- public void run() {
- syncCallback.execute();
- }
- }.runTask(PlayerParticles.getPlugin());
- }
-
- /**
- * Provides an easy way to run a section of code either synchronously or asynchronously using a callback
- */
- @FunctionalInterface
- private interface SyncInterface {
- void execute();
+ private static void sync(Runnable syncCallback) {
+ Bukkit.getScheduler().runTask(PlayerParticles.getPlugin(), syncCallback);
}
/**
diff --git a/src/com/esophose/playerparticles/manager/PermissionManager.java b/src/com/esophose/playerparticles/manager/PermissionManager.java
index e9f89e6..5fb810d 100644
--- a/src/com/esophose/playerparticles/manager/PermissionManager.java
+++ b/src/com/esophose/playerparticles/manager/PermissionManager.java
@@ -12,6 +12,7 @@ import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.styles.DefaultStyles;
import com.esophose.playerparticles.styles.api.ParticleStyle;
import com.esophose.playerparticles.styles.api.ParticleStyleManager;
+import org.bukkit.permissions.Permissible;
public class PermissionManager {
@@ -42,24 +43,24 @@ public class PermissionManager {
}
/**
- * Checks if a Player has a PlayerParticles permission
+ * Checks if a Permissible has a PlayerParticles permission
*
- * @param p The Player
+ * @param p The Permissible
* @return True if the Player has permission
*/
- public boolean check(Player p) {
+ public boolean check(Permissible p) {
String permission = PERMISSION_PREFIX + this.permissionString;
return p.hasPermission(permission);
}
/**
- * Checks if a Player has a PlayerParticles permission with a sub-permission
+ * Checks if a Permissible has a PlayerParticles permission with a sub-permission
*
- * @param p The Player
+ * @param p The Permissibhle
* @param subPermission The sub-permission
* @return True if the Player has permission
*/
- public boolean check(Player p, String subPermission) {
+ public boolean check(Permissible p, String subPermission) {
String permission = PERMISSION_PREFIX + this.permissionString + '.' + subPermission;
return p.hasPermission(permission);
}
@@ -77,7 +78,7 @@ public class PermissionManager {
*/
public static boolean canOverride(CommandSender sender) {
if (!(sender instanceof Player)) return true;
- return PPermission.ALL.check((Player)sender);
+ return PPermission.ALL.check(sender);
}
/**
@@ -286,11 +287,11 @@ public class PermissionManager {
/**
* Checks if a player has permission to use /pp reload
*
- * @param player The player to check the permission for
- * @return True if the player has permission to reload the plugin's settings
+ * @param sender The sender to check the permission for
+ * @return True if the sender has permission to reload the plugin's settings
*/
- public static boolean canReloadPlugin(Player player) {
- return PPermission.ALL.check(player) || PPermission.RELOAD.check(player);
+ public static boolean canReloadPlugin(CommandSender sender) {
+ return PPermission.ALL.check(sender) || PPermission.RELOAD.check(sender);
}
}
diff --git a/src/com/esophose/playerparticles/particles/OtherPPlayer.java b/src/com/esophose/playerparticles/particles/OtherPPlayer.java
index dad1036..13550e7 100644
--- a/src/com/esophose/playerparticles/particles/OtherPPlayer.java
+++ b/src/com/esophose/playerparticles/particles/OtherPPlayer.java
@@ -2,9 +2,18 @@ package com.esophose.playerparticles.particles;
import org.bukkit.command.CommandSender;
+import java.util.ArrayList;
+import java.util.UUID;
+
public class OtherPPlayer extends PPlayer {
private CommandSender sender;
+
+ public OtherPPlayer(CommandSender sender) {
+ super(UUID.randomUUID(), new ArrayList<>(), new ArrayList<>(), false);
+
+ this.sender = sender;
+ }
public OtherPPlayer(CommandSender sender, PPlayer other) {
super(other.getUniqueId(), other.getParticleGroups(), other.getFixedParticles(), !other.canSeeParticles());
diff --git a/src/com/esophose/playerparticles/particles/ParticleEffect.java b/src/com/esophose/playerparticles/particles/ParticleEffect.java
index 7b334d6..18c48e5 100644
--- a/src/com/esophose/playerparticles/particles/ParticleEffect.java
+++ b/src/com/esophose/playerparticles/particles/ParticleEffect.java
@@ -88,7 +88,7 @@ public enum ParticleEffect {
UNDERWATER("SUSPENDED_DEPTH", "SUSPENDED_DEPTH"),
WITCH("SPELL_WITCH", "SPELL_WTICH");
- public static boolean VERSION_13; // This is a particle unique to Minecraft 1.13, this is a reliable way of telling what server version is running
+ public static boolean VERSION_13;
private static final Map NAME_MAP = new HashMap<>();
private static Constructor> DustOptions_CONSTRUCTOR;
private static Method createBlockData_METHOD;
diff --git a/src/config.yml b/src/config.yml
index 16bbd5b..71c0694 100644
--- a/src/config.yml
+++ b/src/config.yml
@@ -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.4
+version: ${project.version}
# Check for new versions of the plugin
# Default: true
diff --git a/src/plugin.yml b/src/plugin.yml
index e9caf96..4aae68d 100644
--- a/src/plugin.yml
+++ b/src/plugin.yml
@@ -1,6 +1,6 @@
name: PlayerParticles
main: com.esophose.playerparticles.PlayerParticles
-version: 6.4
+version: ${project.version}
api-version: 1.13
description: Display particles around your player and blocks using customized styles and data!
author: Esophose