This commit is contained in:
extendedclip
2018-03-20 19:04:14 -04:00
commit fbe0a03a8f
32 changed files with 4030 additions and 0 deletions

View File

@@ -0,0 +1,215 @@
package me.clip.placeholderapi.commands.bukkit;
import java.util.Map;
import java.util.Map.Entry;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ExpansionCloudCommands implements CommandExecutor {
private PlaceholderAPIPlugin plugin;
public ExpansionCloudCommands(PlaceholderAPIPlugin instance) {
plugin = instance;
}
@Override
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 1) {
Msg.msg(s, "&bExpansion cloud commands");
Msg.msg(s, " ");
Msg.msg(s, "&b/papi ecloud status");
Msg.msg(s, "&fView status of the cloud");
Msg.msg(s, "&b/papi ecloud list <all/author> (page)");
Msg.msg(s, "&fList all/author specific available expansions");
Msg.msg(s, "&b/papi ecloud info <expansion name>");
Msg.msg(s, "&fView information about a specific expansion available on the cloud");
Msg.msg(s, "&b/papi ecloud download <expansion name>");
Msg.msg(s, "&fDownload a specific expansion from the cloud");
Msg.msg(s, "&b/papi ecloud refresh");
Msg.msg(s, "&fFetch the most up to date list of expansions available.");
Msg.msg(s, "&b/papi ecloud clear");
Msg.msg(s, "&fClear the expansion cloud cache.");
return true;
}
if (args[1].equalsIgnoreCase("refresh")) {
Msg.msg(s, "&aRefresh task started. Use &7/papi ecloud list all &fin a few!!");
plugin.getExpansionCloud().clean();
plugin.getExpansionCloud().fetch();
return true;
}
if (plugin.getExpansionCloud().getCloudExpansions().isEmpty()) {
Msg.msg(s, "&7No cloud expansions are available at this time.");
return true;
}
if (args[1].equalsIgnoreCase("clear")) {
plugin.getExpansionCloud().clean();
Msg.msg(s, "&aThe cloud cache has been cleared!!");
return true;
}
if (args[1].equalsIgnoreCase("download")) {
if (args.length < 3) {
Msg.msg(s, "&cAn expansion name must be specified!");
return true;
}
CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]);
if (expansion == null) {
Msg.msg(s, "&cNo expansion found with the name: &f" + args[2]);
return true;
}
PlaceholderExpansion loaded = plugin.getExpansionManager().getRegisteredExpansion(args[2]);
if (loaded != null && loaded.isRegistered()) {
PlaceholderAPI.unregisterPlaceholderHook(loaded.getIdentifier());
}
Msg.msg(s, "&aAttempting download of expansion &f" + expansion.getName());
String player = ((s instanceof Player) ? s.getName() : null);
plugin.getExpansionCloud().downloadExpansion(player, expansion);
return true;
}
if (args[1].equalsIgnoreCase("status")) {
Msg.msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size()
+ " &bcloud expansions available to download on demand.");
Msg.msg(s, "&bA total of &f" + plugin.getExpansionCloud().getCloudAuthorCount()
+ " &bauthors have contributed to the expansion cloud.");
return true;
} else if (args[1].equalsIgnoreCase("info")) {
if (args.length < 3) {
Msg.msg(s, "&cAn expansion name must be specified!");
return true;
}
CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]);
if (expansion == null) {
Msg.msg(s, "&cNo expansion found with the name: &f" + args[2]);
return true;
}
PlaceholderExpansion exp = plugin.getExpansionManager().getRegisteredExpansion(args[2]);
boolean enabled = false;
String version = null;
if (exp != null) {
enabled = exp.isRegistered();
version = exp.getVersion();
}
Msg.msg(s, "&aExpansion: &f" + expansion.getName());
if (enabled) {
Msg.msg(s, "&aThis expansion is currently enabled!");
Msg.msg(s, "&bYour version&7: &f" + version);
}
Msg.msg(s, "&bCloud version&7: &f" + expansion.getVersion());
Msg.msg(s, "&bAuthor&7: &f" + expansion.getAuthor());
String desc = expansion.getVersion();
if (desc.indexOf("\n") > 0) {
for (String line : desc.split("\n")) {
Msg.msg(s, line);
}
} else {
Msg.msg(s, desc);
}
Msg.msg(s, "&bDownload with &7/papi ecloud download " + expansion.getName());
return true;
} else if (args[1].equalsIgnoreCase("list")) {
int page = 1;
String author;
if (args.length < 3) {
Msg.msg(s, "&cIncorrect usage! &7/papi ecloud list <all/author> (page)");
return true;
}
author = args[2];
if (author.equalsIgnoreCase("all")) {
author = null;
}
if (args.length >= 4) {
try {
page = Integer.parseInt(args[3]);
} catch (NumberFormatException ex) {
Msg.msg(s, "&cPage number must be an integer!");
return true;
}
}
if (page < 1) {
Msg.msg(s, "&cPage must be greater than or equal to 1!");
return true;
}
int avail;
Map<Integer, CloudExpansion> ex;
if (author == null) {
ex = plugin.getExpansionCloud().getCloudExpansions();
} else {
ex = plugin.getExpansionCloud().getAllByAuthor(author);
}
if (ex == null) {
Msg.msg(s, "&cNo expansions available" + (author != null ? " for author &f" + author : ""));
return true;
}
avail = plugin.getExpansionCloud().getPagesAvailable(ex, 10);
if (page > avail) {
Msg.msg(s, "&cThere " + ((avail == 1) ? " is only &f" + avail + " &cpage available!" : "are only &f" + avail + " &cpages available!"));
return true;
}
Msg.msg(s, "&bExpansion cloud for &f" + (author != null ? author : "all available")+ " &8&m-- &r&bamount&7: &f" + ex.size() + " &bpage&7: &f" + page + "&7/&f" + avail);
ex = plugin.getExpansionCloud().getPage(ex, page);
for (Entry<Integer, CloudExpansion> expansion : ex.entrySet()) {
Msg.msg(s, "&b" + (expansion.getKey()+1) + "&7: &f" + expansion.getValue().getName() + " &8&m-- &r" + expansion.getValue().getLink());
}
Msg.msg(s, "&bDownload an expansion with &7/papi ecloud download <name>");
Msg.msg(s, "&bView more info on an expansion with &7/papi ecloud info <expansion>");
return true;
}
return true;
}
}

View File

@@ -0,0 +1,226 @@
package me.clip.placeholderapi.commands.bukkit;
import java.util.Set;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PlaceholderAPICommands implements CommandExecutor {
private PlaceholderAPIPlugin plugin;
private ExpansionCloudCommands eCloud;
public PlaceholderAPICommands(PlaceholderAPIPlugin i) {
plugin = i;
eCloud = new ExpansionCloudCommands(i);
}
@Override
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 0) {
Msg.msg(s, "PlaceholderAPI &7version &b&o"+plugin.getDescription().getVersion());
Msg.msg(s, "&fCreated by&7: &bextended_clip");
return true;
} else {
if (args[0].equalsIgnoreCase("help")) {
Msg.msg(s, "PlaceholderAPI &aHelp &e(&f" + plugin.getDescription().getVersion() + "&e)");
Msg.msg(s, "&b/papi");
Msg.msg(s, "&fView plugin info/version info");
Msg.msg(s, "&b/papi list");
Msg.msg(s, "&fList all placeholder expansions that are currently active");
Msg.msg(s, "&b/papi info <placeholder name>");
Msg.msg(s, "&fView information for a specific expansion");
Msg.msg(s, "&b/papi parse <...args>");
Msg.msg(s, "&fParse a String with placeholders");
Msg.msg(s, "&b/papi reload");
Msg.msg(s, "&fReload the config settings");
boolean enabled = plugin.getExpansionCloud() != null;
if (s.isOp()) {
if (!enabled) {
Msg.msg(s, "&b/papi enablecloud");
Msg.msg(s, "&fEnable the expansion cloud");
} else {
Msg.msg(s, "&b/papi disablecloud");
Msg.msg(s, "&fDisable the expansion cloud");
Msg.msg(s, "&b/papi ecloud");
Msg.msg(s, "&fView information about the PlaceholderAPI expansion cloud");
Msg.msg(s, "&b/papi ecloud status");
Msg.msg(s, "&fView status of the PlaceholderAPI expansion cloud");
Msg.msg(s, "&b/papi ecloud list <all/author> <page>");
Msg.msg(s, "&fList all available expansions");
Msg.msg(s, "&b/papi ecloud info <expansion name>");
Msg.msg(s, "&fView information about a specific expansion on the cloud");
Msg.msg(s, "&b/papi ecloud download <expansion name>");
Msg.msg(s, "&fDownload a specific expansion from the cloud");
}
}
return true;
} else if (args[0].equalsIgnoreCase("ecloud")) {
if (!s.isOp()) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
if (plugin.getExpansionCloud() == null) {
Msg.msg(s, "&7The expansion cloud is not enabled!");
return true;
}
return eCloud.onCommand(s, c, label, args);
} else if (args[0].equalsIgnoreCase("enablecloud")) {
if (!s.isOp()) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
if (plugin.getExpansionCloud() != null) {
Msg.msg(s, "&7The cloud is already enabled!");
return true;
}
plugin.enableCloud();
plugin.getPlaceholderAPIConfig().setCloudEnabled(true);
Msg.msg(s, "&aThe cloud has been enabled!");
return true;
} else if (args[0].equalsIgnoreCase("disablecloud")) {
if (!s.isOp()) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
if (plugin.getExpansionCloud() == null) {
Msg.msg(s, "&7The cloud is already disabled!");
return true;
}
plugin.disableCloud();
plugin.getPlaceholderAPIConfig().setCloudEnabled(false);
Msg.msg(s, "&aThe cloud has been disabled!");
return true;
} else if (args[0].equalsIgnoreCase("info")) {
if (!s.hasPermission("placeholderapi.info")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
PlaceholderExpansion ex = plugin.getExpansionManager().getRegisteredExpansion(args[1]);
if (ex == null) {
Msg.msg(s, "&cThere is no expansion loaded with the identifier: &f" + args[1]);
return true;
}
Msg.msg(s, "&7Placeholder expansion info for: &f%" + ex.getIdentifier() + "_<identifier>%");
Msg.msg(s, "&7Status: " + (ex.isRegistered() ? "&aRegistered" : "&cNot registered"));
if (ex.getAuthor() != null) {
Msg.msg(s, "&7Created by: &f" + ex.getAuthor());
}
if (ex.getVersion() != null) {
Msg.msg(s, "&7Version: &f" + ex.getVersion());
}
if (ex.getDescription() != null) {
Msg.msg(s, ex.getDescription());
}
if (ex.getLink() != null) {
Msg.msg(s, "&7Link: &f" + ex.getLink());
}
if (ex.getPlugin() != null) {
Msg.msg(s, "&7Requires plugin: &f" + ex.getPlugin());
}
if (ex.getPlaceholders() != null) {
Msg.msg(s, "&8&m-- &r&7Placeholders &8&m--");
for (String placeholder : ex.getPlaceholders()) {
Msg.msg(s, placeholder);
}
}
return true;
} else if (args[0].equalsIgnoreCase("parse")) {
if (!(s instanceof Player)) {
Msg.msg(s, "&cThis command can only be used in game!");
return true;
} else {
if (!s.hasPermission("placeholderapi.parse")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Player p = (Player) s;
String parse = StringUtils.join(args, " ", 1, args.length);
Msg.msg(s, "&r" + PlaceholderAPI.setPlaceholders(p, parse));
return true;
} else if (args[0].equalsIgnoreCase("reload")) {
if (s instanceof Player) {
if (!s.hasPermission("placeholderapi.reload")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Msg.msg(s, "&cClips &fPlaceholder&7API &bconfiguration reloaded!");
plugin.reloadConf(s);
} else if (args[0].equalsIgnoreCase("list")) {
if (s instanceof Player) {
if (!s.hasPermission("placeholderapi.list")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Set<String> registered = PlaceholderAPI.getRegisteredIdentifiers();
if (registered.isEmpty()) {
Msg.msg(s, "&7There are no placeholder hooks currently registered!");
return true;
}
Msg.msg(s, registered.size()+" &7Placeholder hooks registered:");
Msg.msg(s, registered.toString());
} else {
Msg.msg(s, "&cIncorrect usage! &7/papi help");
}
}
return true;
}
}

View File

@@ -0,0 +1,301 @@
package me.clip.placeholderapi.commands.spigot;
import java.util.Map;
import java.util.Map.Entry;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.Msg;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ExpansionCloudCommands implements CommandExecutor {
private PlaceholderAPIPlugin plugin;
public ExpansionCloudCommands(PlaceholderAPIPlugin instance) {
plugin = instance;
}
@Override
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 1) {
Msg.msg(s, "&bExpansion cloud commands");
Msg.msg(s, " ");
Msg.msg(s, "&b/papi ecloud status");
Msg.msg(s, "&fView status of the cloud");
Msg.msg(s, "&b/papi ecloud list <all/author> (page)");
Msg.msg(s, "&fList all/author specific available expansions");
Msg.msg(s, "&b/papi ecloud info <expansion name>");
Msg.msg(s, "&fView information about a specific expansion available on the cloud");
Msg.msg(s, "&b/papi ecloud download <expansion name>");
Msg.msg(s, "&fDownload a specific expansion from the cloud");
Msg.msg(s, "&b/papi ecloud refresh");
Msg.msg(s, "&fFetch the most up to date list of expansions available.");
Msg.msg(s, "&b/papi ecloud clear");
Msg.msg(s, "&fClear the expansion cloud cache.");
return true;
}
if (args[1].equalsIgnoreCase("refresh") || args[1].equalsIgnoreCase("update") || args[1].equalsIgnoreCase("fetch")) {
Msg.msg(s, "&aRefresh task started. Use &f/papi ecloud list all &ain a few!!");
plugin.getExpansionCloud().clean();
plugin.getExpansionCloud().fetch();
return true;
}
if (plugin.getExpansionCloud().getCloudExpansions().isEmpty()) {
Msg.msg(s, "&7No cloud expansions are available at this time.");
return true;
}
if (args[1].equalsIgnoreCase("clear")) {
plugin.getExpansionCloud().clean();
Msg.msg(s, "&aThe cloud cache has been cleared!!");
return true;
}
if (args[1].equalsIgnoreCase("status")) {
Msg.msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size() + " &bexpansions available on the cloud.");
Msg.msg(s, "&7A total of &f" + plugin.getExpansionCloud().getCloudAuthorCount()
+ " &7authors have contributed to the expansion cloud.");
if (plugin.getExpansionCloud().getToUpdateCount() > 0) {
Msg.msg(s, "&eYou have &f" + plugin.getExpansionCloud().getToUpdateCount()
+ " &eexpansions installed that have updates available.");
}
return true;
}
if (args[1].equalsIgnoreCase("info")) {
if (args.length < 3) {
Msg.msg(s, "&cAn expansion name must be specified!");
return true;
}
CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]);
if (expansion == null) {
Msg.msg(s, "&cNo expansion found with the name: &f" + args[2]);
return true;
}
if (!(s instanceof Player)) {
Msg.msg(s, (expansion.shouldUpdate() ? "&e" : "") + expansion.getName() + " &8&m-- &r" + expansion.getLink());
return true;
}
Player p = (Player) s;
Msg.msg(s, "&bCloud expansion info for&7:" + (expansion.shouldUpdate() ? "&6" : (expansion.hasExpansion() ? "&e" : "")) + expansion.getName());
StringBuilder sb = new StringBuilder();
sb.append(expansion.getDescription());
if (expansion.getReleaseNotes() != null) {
sb.append("\n\n" + expansion.getReleaseNotes());
}
String hover = ChatColor.translateAlternateColorCodes('&', sb.toString());
if (expansion.hasExpansion()) {
if (expansion.shouldUpdate()) {
Msg.msg(s, "&6You have this expansion but there is a newer version available.");
} else {
Msg.msg(s, "&aYou have the latest version of this expansion!");
}
} else {
Msg.msg(s, "&7You do not have this expansion installed");
}
sms(p, "&bAuthor&7: &f" + expansion.getAuthor(), hover, null);
sms(p, "&bVersion&7: &f" + expansion.getVersion(), hover, null);
if (expansion.getLastUpdate() > 1) {
sb.append("&bLast updated&7: &f" + expansion.getTimeSinceLastUpdate() + " ago");
}
sms(p, "&aClick here to download!", hover, expansion.getName());
return true;
}
if (args[1].equalsIgnoreCase("list")) {
int page = 1;
String author;
boolean installed = false;
if (args.length < 3) {
Msg.msg(s, "&cIncorrect usage! &7/papi ecloud list <all/author/installed> (page)");
return true;
}
author = args[2];
if (author.equalsIgnoreCase("all")) {
author = null;
} else if (author.equalsIgnoreCase("installed")) {
author = null;
installed = true;
}
if (args.length >= 4) {
try {
page = Integer.parseInt(args[3]);
} catch (NumberFormatException ex) {
Msg.msg(s, "&cPage number must be an integer!");
return true;
}
}
if (page < 1) {
Msg.msg(s, "&cPage must be greater than or equal to 1!");
return true;
}
int avail;
Map<Integer, CloudExpansion> ex;
if (installed) {
ex = plugin.getExpansionCloud().getAllInstalled();
} else if (author == null) {
ex = plugin.getExpansionCloud().getCloudExpansions();
} else {
ex = plugin.getExpansionCloud().getAllByAuthor(author);
}
if (ex == null || ex.isEmpty()) {
Msg.msg(s, "&cNo expansions available" + (author != null ? " for author &f" + author : ""));
return true;
}
avail = plugin.getExpansionCloud().getPagesAvailable(ex, 10);
if (page > avail) {
Msg.msg(s, "&cThere " + ((avail == 1) ? " is only &f" + avail + " &cpage available!" : "are only &f" + avail + " &cpages available!"));
return true;
}
Msg.msg(s, "&bShowing expansions for&7: &f" + (author != null ? author : (installed ? "all installed" : "all available"))+ " &8&m--&r &bamount&7: &f" + ex.size() + " &bpage&7: &f" + page + "&7/&f" + avail);
ex = plugin.getExpansionCloud().getPage(ex, page);
if (ex == null) {
Msg.msg(s, "&cThere was a problem getting the requested page...");
return true;
}
Msg.msg(s, "&aGreen = Expansions you have");
Msg.msg(s, "&6Gold = Expansions which need updated");
if (!(s instanceof Player)) {
for (Entry<Integer, CloudExpansion> expansion : ex.entrySet()) {
if (expansion == null || expansion.getKey() == null || expansion.getValue() == null) continue;
Msg.msg(s, "&b" + (expansion.getKey()+1) + "&7: " + (expansion.getValue().shouldUpdate() ? "&6" : (expansion.getValue().hasExpansion() ? "&a" : "&7")) + expansion.getValue().getName() + " &8&m-- &r" + expansion.getValue().getLink());
}
return true;
}
Player p = (Player) s;
for (Entry<Integer, CloudExpansion> expansion : ex.entrySet()) {
if (expansion == null || expansion.getValue() == null) {
continue;
}
StringBuilder sb = new StringBuilder();
if (expansion.getValue().shouldUpdate()) {
sb.append("&6Click to update to the latest version of this expansion\n\n");
} else if (!expansion.getValue().hasExpansion()) {
sb.append("&bClick to download this expansion\n\n");
} else {
sb.append("&aYou have the latest version of this expansion\n\n");
}
sb.append("&bAuthor&7: &f" + expansion.getValue().getAuthor() + "\n");
sb.append("&bVersion&7: &f" + expansion.getValue().getVersion() + "\n");
if (expansion.getValue().getLastUpdate() > 1) {
sb.append("&bLast updated&7: &f" + expansion.getValue().getTimeSinceLastUpdate() + " ago\n");
}
if (expansion.getValue().getReleaseNotes() != null) {
sb.append("&bRelease Notes&7: &f" + expansion.getValue().getReleaseNotes() + "\n");
}
sb.append("\n" + expansion.getValue().getDescription());
String msg = ChatColor.translateAlternateColorCodes('&', "&b" + (expansion.getKey()+1) + "&7: " + (expansion.getValue().shouldUpdate() ? "&6" : (expansion.getValue().hasExpansion() ? "&a" : "")) + expansion.getValue().getName());
String hover = ChatColor.translateAlternateColorCodes('&', sb.toString());
sms(p, msg, hover, expansion.getValue().getName());
}
return true;
}
if (args[1].equalsIgnoreCase("download")) {
if (args.length < 3) {
Msg.msg(s, "&cAn expansion name must be specified!");
return true;
}
CloudExpansion expansion = plugin.getExpansionCloud().getCloudExpansion(args[2]);
if (expansion == null) {
Msg.msg(s, "&cNo expansion found with the name: &f" + args[2]);
return true;
}
if (expansion.hasExpansion() && !expansion.shouldUpdate()) {
Msg.msg(s, "&aYou already have this expansion installed and your version is up to date!");
return true;
}
PlaceholderExpansion loaded = plugin.getExpansionManager().getRegisteredExpansion(args[2]);
if (loaded != null && loaded.isRegistered()) {
PlaceholderAPI.unregisterPlaceholderHook(loaded.getIdentifier());
}
Msg.msg(s, "&aAttempting download of expansion &f" + expansion.getName());
String player = ((s instanceof Player) ? s.getName() : null);
plugin.getExpansionCloud().downloadExpansion(player, expansion);
return true;
}
Msg.msg(s, "&cIncorrect usage! &b/papi ecloud");
return true;
}
private void sms(Player p, String text, String hover, String link) {
TextComponent message = new TextComponent( ChatColor.translateAlternateColorCodes('&', text) );
if (hover != null) {
message.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', hover)).create() ) );
}
if (link != null) {
message.setClickEvent( new ClickEvent( ClickEvent.Action.SUGGEST_COMMAND, "/papi ecloud download " + link) );
}
p.spigot().sendMessage( message );
}
}

View File

@@ -0,0 +1,258 @@
package me.clip.placeholderapi.commands.spigot;
import java.util.Set;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PlaceholderAPICommands implements CommandExecutor {
private PlaceholderAPIPlugin plugin;
private ExpansionCloudCommands eCloud;
public PlaceholderAPICommands(PlaceholderAPIPlugin i) {
plugin = i;
eCloud = new ExpansionCloudCommands(i);
}
@Override
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 0) {
Msg.msg(s, "PlaceholderAPI &7version &b&o"+plugin.getDescription().getVersion());
Msg.msg(s, "&fCreated by&7: &bextended_clip");
return true;
} else {
if (args[0].equalsIgnoreCase("help")) {
Msg.msg(s, "PlaceholderAPI &aHelp &e(&f" + plugin.getDescription().getVersion() + "&e)");
Msg.msg(s, "&b/papi");
Msg.msg(s, "&fView plugin info/version info");
Msg.msg(s, "&b/papi list");
Msg.msg(s, "&fList all placeholder expansions that are currently active");
Msg.msg(s, "&b/papi info <placeholder name>");
Msg.msg(s, "&fView information for a specific expansion");
Msg.msg(s, "&b/papi parse <...args>");
Msg.msg(s, "&fParse a String with placeholders");
Msg.msg(s, "&b/papi parserel <player one> <player two> <...args>");
Msg.msg(s, "&fParse a String with relational placeholders");
Msg.msg(s, "&b/papi reload");
Msg.msg(s, "&fReload the config settings");
boolean enabled = plugin.getExpansionCloud() != null;
if (s.isOp()) {
if (!enabled) {
Msg.msg(s, "&b/papi enablecloud");
Msg.msg(s, "&fEnable the expansion cloud");
} else {
Msg.msg(s, "&b/papi disablecloud");
Msg.msg(s, "&fDisable the expansion cloud");
Msg.msg(s, "&b/papi ecloud");
Msg.msg(s, "&fView information about the PlaceholderAPI expansion cloud");
Msg.msg(s, "&b/papi ecloud status");
Msg.msg(s, "&fView status of the PlaceholderAPI expansion cloud");
Msg.msg(s, "&b/papi ecloud list <all/author> <page>");
Msg.msg(s, "&fList all available expansions");
Msg.msg(s, "&b/papi ecloud info <expansion name>");
Msg.msg(s, "&fView information about a specific expansion on the cloud");
Msg.msg(s, "&b/papi ecloud download <expansion name>");
Msg.msg(s, "&fDownload a specific expansion from the cloud");
}
}
return true;
} else if (args[0].equalsIgnoreCase("ecloud")) {
if (!s.isOp()) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
if (plugin.getExpansionCloud() == null) {
Msg.msg(s, "&7The expansion cloud is not enabled!");
return true;
}
return eCloud.onCommand(s, c, label, args);
} else if (args[0].equalsIgnoreCase("enablecloud")) {
if (!s.isOp()) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
if (plugin.getExpansionCloud() != null) {
Msg.msg(s, "&7The cloud is already enabled!");
return true;
}
plugin.enableCloud();
plugin.getPlaceholderAPIConfig().setCloudEnabled(true);
Msg.msg(s, "&aThe cloud has been enabled!");
return true;
} else if (args[0].equalsIgnoreCase("disablecloud")) {
if (!s.isOp()) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
if (plugin.getExpansionCloud() == null) {
Msg.msg(s, "&7The cloud is already disabled!");
return true;
}
plugin.disableCloud();
plugin.getPlaceholderAPIConfig().setCloudEnabled(false);
Msg.msg(s, "&aThe cloud has been disabled!");
return true;
} else if (args.length > 1 && args[0].equalsIgnoreCase("info")) {
if (!s.hasPermission("placeholderapi.info")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
PlaceholderExpansion ex = plugin.getExpansionManager().getRegisteredExpansion(args[1]);
if (ex == null) {
Msg.msg(s, "&cThere is no expansion loaded with the identifier: &f" + args[1]);
return true;
}
Msg.msg(s, "&7Placeholder expansion info for: &f%" + ex.getIdentifier() + "_<identifier>%");
Msg.msg(s, "&7Status: " + (ex.isRegistered() ? "&aRegistered" : "&cNot registered"));
if (ex.getAuthor() != null) {
Msg.msg(s, "&7Created by: &f" + ex.getAuthor());
}
if (ex.getVersion() != null) {
Msg.msg(s, "&7Version: &f" + ex.getVersion());
}
if (ex.getDescription() != null) {
Msg.msg(s, ex.getDescription());
}
if (ex.getLink() != null) {
Msg.msg(s, "&7Link: &f" + ex.getLink());
}
if (ex.getPlugin() != null) {
Msg.msg(s, "&7Requires plugin: &f" + ex.getPlugin());
}
if (ex.getPlaceholders() != null) {
Msg.msg(s, "&8&m-- &r&7Placeholders &8&m--");
for (String placeholder : ex.getPlaceholders()) {
Msg.msg(s, placeholder);
}
}
return true;
} else if (args.length > 1 && args[0].equalsIgnoreCase("parse")) {
if (!(s instanceof Player)) {
Msg.msg(s, "&cThis command can only be used in game!");
return true;
} else {
if (!s.hasPermission("placeholderapi.parse")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Player p = (Player) s;
String parse = StringUtils.join(args, " ", 1, args.length);
Msg.msg(s, "&r" + PlaceholderAPI.setPlaceholders(p, parse));
return true;
} else if (args.length > 3 && args[0].equalsIgnoreCase("parserel")) {
if (!(s instanceof Player)) {
Msg.msg(s, "&cThis command can only be used in game!");
return true;
} else {
if (!s.hasPermission("placeholderapi.parse")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Player one = Bukkit.getPlayer(args[1]);
if (one == null) {
Msg.msg(s, args[1] + " &cis not online!");
return true;
}
Player two = Bukkit.getPlayer(args[2]);
if (two == null) {
Msg.msg(s, args[2] + " &cis not online!");
return true;
}
String parse = StringUtils.join(args, " ", 3, args.length);
Msg.msg(s, "&r" + PlaceholderAPI.setRelationalPlaceholders(one, two, parse));
return true;
} else if (args[0].equalsIgnoreCase("reload")) {
if (s instanceof Player) {
if (!s.hasPermission("placeholderapi.reload")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Msg.msg(s, "&fPlaceholder&7API &bconfiguration reloaded!");
plugin.reloadConf(s);
} else if (args[0].equalsIgnoreCase("list")) {
if (s instanceof Player) {
if (!s.hasPermission("placeholderapi.list")) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
}
}
Set<String> registered = PlaceholderAPI.getRegisteredIdentifiers();
if (registered.isEmpty()) {
Msg.msg(s, "&7There are no placeholder hooks currently registered!");
return true;
}
Msg.msg(s, registered.size()+" &7Placeholder hooks registered:");
Msg.msg(s, registered.toString());
} else {
Msg.msg(s, "&cIncorrect usage! &7/papi help");
}
}
return true;
}
}