diff --git a/pom.xml b/pom.xml index 9dd2399..721dfc4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ xyz.etztech MinecraftManager - 1.4 + 1.5 jar @@ -38,13 +38,11 @@ commons-lang commons-lang 2.6 - provided xyz.etztech EtzCore - 1.0.4 - compile + 1.0.5 diff --git a/src/main/java/xyz/etztech/minecraftmanager/MCMUtil.java b/src/main/java/xyz/etztech/minecraftmanager/MCMUtil.java index bf193c7..eb56a30 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/MCMUtil.java +++ b/src/main/java/xyz/etztech/minecraftmanager/MCMUtil.java @@ -46,8 +46,12 @@ public class MCMUtil { } public static void staffMessage(String message) { + staffMessage(message, false); + } + public static void staffMessage(String message, boolean mcm) { log(staffLog, message); - HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create()); + String tag = mcm ? "MCM " : ""; + HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(tag + "Staff Chat").create()); TextComponent text = new TextComponent(message); text.setHoverEvent(hover); for (Player player : Bukkit.getServer().getOnlinePlayers()) { @@ -92,6 +96,13 @@ public class MCMUtil { } } + public static void globalMessage(TextComponent message) { + log(globalLog, message.toPlainText()); + for (Player player : Bukkit.getServer().getOnlinePlayers()) { + player.spigot().sendMessage(message); + } + } + public static String getUUID(String playerName) { String uuid = null; try { diff --git a/src/main/java/xyz/etztech/minecraftmanager/MinecraftManager.java b/src/main/java/xyz/etztech/minecraftmanager/MinecraftManager.java index ba1fb5f..695df12 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/MinecraftManager.java +++ b/src/main/java/xyz/etztech/minecraftmanager/MinecraftManager.java @@ -5,8 +5,6 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import xyz.etztech.core.api.IMinecraftManager; -import xyz.etztech.core.maven.MavenLibrary; -import xyz.etztech.core.maven.MavenPlugin; import xyz.etztech.minecraftmanager.command.*; import xyz.etztech.minecraftmanager.listeners.AsyncPlayerChatListener; import xyz.etztech.minecraftmanager.listeners.BlockBreakListener; @@ -23,8 +21,7 @@ import java.util.List; import java.util.Map; import java.util.logging.Logger; -@MavenLibrary(group = "commons-lang", artifact = "commons-lang", version = "2.6") -public class MinecraftManager extends MavenPlugin implements IMinecraftManager { +public class MinecraftManager extends JavaPlugin implements IMinecraftManager { public static MinecraftManager instance; @@ -50,8 +47,7 @@ public class MinecraftManager extends MavenPlugin implements IMinecraftManager { - @Override - public void enable() { + public void onEnable() { instance = this; saveDefaultConfig(); @@ -95,8 +91,7 @@ public class MinecraftManager extends MavenPlugin implements IMinecraftManager { } } - @Override - public void disable() { + public void onDisable() { } diff --git a/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java b/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java index af97fc6..3bcfd78 100644 --- a/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java +++ b/src/main/java/xyz/etztech/minecraftmanager/objects/MinecraftManagerThread.java @@ -37,7 +37,6 @@ public class MinecraftManagerThread extends Thread { public void run() { - List commands = Arrays.asList("application", "ticket", "accept", "deny", "global", "staff"); try { ServerSocket cmdSock = new ServerSocket(this.plugin.getConfig().getInt("port"), 0, InetAddress.getByName(null)); while (getRunning()) { @@ -54,30 +53,31 @@ public class MinecraftManagerThread extends Thread { args = new ArrayList<>(Arrays.asList(buf.split(" "))); args.remove(0); } - if (commands.contains(base)) { - switch (base) { - case "application": - application(args.get(0), args.get(1)); - break; - case "ticket": - ticket(args.get(0), args.get(1), args.get(2)); - break; - case "accept": - action(args.get(0), true); - break; - case "deny": - action(args.get(0), false); - break; - case "global": - globalChat(args); - break; - case "staff": - staffChat(args); - break; - default: - Bukkit.getConsoleSender().sendMessage("Input not recognized, ignoring."); - break; - } + switch (base) { + case "application": + application(args.get(0), args.get(1)); + break; + case "ticket": + ticket(args.get(0), args.get(1), args.get(2)); + break; + case "accept": + action(args.get(0), true); + break; + case "deny": + action(args.get(0), false); + break; + case "global": + globalChat(args); + break; + case "staff": + staffChat(args); + break; + case "demote": + demote(args.get(0)); + break; + default: + Bukkit.getConsoleSender().sendMessage("Input not recognized, ignoring."); + break; } } } @@ -93,7 +93,7 @@ public class MinecraftManagerThread extends Thread { .color(ChatColor.GREEN) .event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/app info " + id)); TextComponent message = new TextComponent(builder.create()); - message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create())); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("MCM Staff Chat").create())); MCMUtil.staffMessage(message); } @@ -102,7 +102,7 @@ public class MinecraftManagerThread extends Thread { .color(ChatColor.GREEN) .event(new ClickEvent(ClickEvent.Action.OPEN_URL, link)); TextComponent message = new TextComponent(builder.create()); - message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create())); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("MCM Staff Chat").create())); MCMUtil.staffMessage(message); } @@ -142,7 +142,7 @@ public class MinecraftManagerThread extends Thread { ComponentBuilder builder = new ComponentBuilder(username + " was " + (accepted ? "accepted" : "denied") + ".") .color(ChatColor.GREEN); TextComponent staffMessage = new TextComponent(builder.create()); - staffMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create())); + staffMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("MCM Staff Chat").create())); MCMUtil.staffMessage(staffMessage); } @@ -159,19 +159,40 @@ public class MinecraftManagerThread extends Thread { private void globalChat(ArrayList args) { String name = args.get(0); args.remove(0); - MCMUtil.globalMessage("[MCM] " + name + " > " + StringUtils.join(args, " ")); + String tag = plugin.getConfig().getBoolean("tag", true) ? "[MCM] " : ""; + ComponentBuilder builder = new ComponentBuilder(tag + name + " > ") + .append(StringUtils.join(args, " ")); + TextComponent message = new TextComponent(builder.create()); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("MCM Global Chat").create())); + MCMUtil.globalMessage(message); } private void staffChat(ArrayList args) { String name = args.get(0); args.remove(0); - ComponentBuilder builder = new ComponentBuilder("[MCM] " + name + " > ") + String tag = plugin.getConfig().getBoolean("tag", true) ? "[MCM] " : ""; + ComponentBuilder builder = new ComponentBuilder(tag + name + " > ") .color(ChatColor.GOLD) .append(StringUtils.join(args, " "), ComponentBuilder.FormatRetention.NONE) .color(ChatColor.GREEN); TextComponent message = new TextComponent(builder.create()); - message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Staff Chat").create())); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("MCM Staff Chat").create())); MCMUtil.staffMessage(message); } + private void demote(String username) { + String engine = MinecraftManager.config.getString("permissions.engine"); + String promote = MinecraftManager.config.getString("permissions.promote"); + if ("permissionsex".equalsIgnoreCase(engine)) { + runTask("pex user group set " + promote, username); + } else if ("luckperms".equalsIgnoreCase(engine)) { + runTask("lp user group set " + promote, username); + } + ComponentBuilder builder = new ComponentBuilder(username + " has been demoted.") + .color(ChatColor.GREEN); + TextComponent staffMessage = new TextComponent(builder.create()); + staffMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("MCM Staff Chat").create())); + MCMUtil.staffMessage(staffMessage); + } + } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c04561d..652e83d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -8,6 +8,9 @@ staff-chat: prefix: - "#" +# If true, chat is prefixed with an [MCM] tag. When false, the tag is moved to a hover event. +tag: true + # Override rules # A '*' before a rule will show as a sub-rule rules: