Skip to content

Commit

Permalink
update to 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
myunco committed Jul 12, 2023
1 parent b0b50a2 commit ad2304f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
37 changes: 34 additions & 3 deletions src/ml/mcos/servermonitor/listener/PluginEventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

public class PluginEventListener implements Listener {
private final int mcVersion;
String opGivePermission;
String opTakePermission;
private final String opGivePermission;
private final String opTakePermission;

public PluginEventListener(int mcVersion) {
this.mcVersion = mcVersion;
Expand Down Expand Up @@ -56,7 +56,12 @@ public void playerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
if (!Config.playerCommand.get("enable")) {
return;
}
String cmd = event.getMessage();
String cmd;
if (isLoginCommand(event.getMessage())) {
cmd = hidePassword(event.getMessage());
} else {
cmd = event.getMessage();
}
String playerName = event.getPlayer().getName();
boolean isOp = event.getPlayer().isOp();
String str = Util.getTime() + Language.logPlayerCommand
Expand Down Expand Up @@ -132,6 +137,32 @@ public void playerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
}
}

private final String[] loginCommand = {"/login", "/log", "/l", "/register", "/reg"};

private boolean isLoginCommand(String cmd) {
for (String s : loginCommand) {
if (cmd.startsWith(s)) {
return true;
}
}
return false;
}

private String hidePassword(String cmd) {
StringBuilder builder = new StringBuilder();
int index = cmd.indexOf(' ');
for (int i = 0; i < cmd.length(); i++) {
if (i <= index) {
builder.append(cmd.charAt(i));
} else if (cmd.charAt(i) != ' '){
builder.append('*');
} else {
builder.append(' ');
}
}
return builder.toString();
}

@EventHandler(priority = EventPriority.MONITOR)
public void serverCommandEvent(ServerCommandEvent event) {
if (!Config.playerCommand.get("consoleCommand")) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ServerMonitor
main: ml.mcos.servermonitor.ServerMonitor
version: 1.3.2-SNAPSHOT
version: 1.3.2
api-version: 1.13
author: unco_
website: https://www.mcbbs.net/thread-995756-1-1.html
Expand Down

0 comments on commit ad2304f

Please sign in to comment.