Update to 1.5

Added new Staff message utility to be used going forward
New demote action in MCM listener
Added tag option to move [MCM] into hover event
Fixes #3
Fixes #5
master
Etzelia 2018-10-20 23:01:00 -05:00
parent 9f0a0bfad5
commit 33f893907d
5 changed files with 72 additions and 44 deletions

View File

@ -3,7 +3,7 @@
<groupId>xyz.etztech</groupId>
<artifactId>MinecraftManager</artifactId>
<!-- Version is used in plugin.yml -->
<version>1.4</version>
<version>1.5</version>
<packaging>jar</packaging>
<!-- Plugin Information -->
@ -38,13 +38,11 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>xyz.etztech</groupId>
<artifactId>EtzCore</artifactId>
<version>1.0.4</version>
<scope>compile</scope>
<version>1.0.5</version>
</dependency>

View File

@ -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 {

View File

@ -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() {
}

View File

@ -37,7 +37,6 @@ public class MinecraftManagerThread extends Thread {
public void run() {
List<String> 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,7 +53,6 @@ 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));
@ -74,13 +72,15 @@ public class MinecraftManagerThread extends Thread {
case "staff":
staffChat(args);
break;
case "demote":
demote(args.get(0));
break;
default:
Bukkit.getConsoleSender().sendMessage("Input not recognized, ignoring.");
break;
}
}
}
}
Bukkit.getConsoleSender().sendMessage("Closing MinecraftManager on Port " + this.plugin.getConfig().get("port"));
cmdSock.close();
} catch (Exception ex) {
@ -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<String> 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<String> 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 <player> group set " + promote, username);
} else if ("luckperms".equalsIgnoreCase(engine)) {
runTask("lp user <player> 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);
}
}

View File

@ -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: