Skip to content

Commit

Permalink
bug fixs
Browse files Browse the repository at this point in the history
**changes in:**
/rtv
/kill
change bans command arguments
increase vote time for rtv
change minimun required name lenght to 3 characters
bans -> ban
change chat formatting to not to interfere with other plugins

**fix:**
/godmode
ban ip with no reason don't work
vpnapi.io api change
TempData.inGodmode exception if player timed out
Auto pause, pause the game if game over
plugin don't work in v7
plugin don't load for new installation

**add:**
color formating for chat in console
can find in other teams, 250 others hidden teams
cooldown for vnw and rtv
auto blacklist name of admin player for non-admin, to prevent name spoofing 
*Note:* just test if an admin name is in name of player skipping case, colors, and emojis
option to give an vpnapi.io token to get more test in a day (default is 100 requests per day)
remove limit argument to anti-vpn because is unless
  • Loading branch information
ZetaMap authored Jan 30, 2023
1 parent 56717ae commit 2b00d9a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Visitor Badge](https://visitor-badge.laobi.icu/badge?page_id=ZetaMap.moreCommands) ![Download](https://shields.io/github/downloads/ZetaMap/moreCommands/total) ![GitHub Clones](https://img.shields.io/badge/dynamic/json?color=success&label=Clones&query=count&url=https://gist.githubusercontent.com/ZetaMap/e8cbd0ed420987f8c25b6945fd80e3b0/raw/clone.json&logo=github)
# moreCommands Plugin
**/!\\This plugin need java 12 or greater./!\\** To download java 12, follow steps [here](https://www.oracle.com/fr/java/technologies/javase/jdk12-archive-downloads.html) or greater version [here](https://www.oracle.com/java/technologies/downloads/).

### Player Commands
* `/ut [filter|username...]` The name of the unit.
* `/vnw [number]` Vote for sending a New Wave.
Expand Down Expand Up @@ -51,10 +51,10 @@
* `tag <help|arg0> [ID|] [tagName...]` Configure the tag system.
* `ban <list|add|remove|reset> [type-id|ip] [ID|IP] [reason...]` List all banned IP/ID or ban/unban an ID/IP.
* `alogs [on|off|reset] [y|n]` Configure admins logs.
* `reset [ID]` Reset all data of the player (ips, names, ban, ...).
* `fillitems [team|all] [items...]` Fill the core with the selected item.
- [ ] `warn [ID] [message...]` Display a pop-up message to warn the player.
- [ ] `reports <list|ok|clear> [id]` Control the reports list
- [ ] `reset [ID]` Reset all data of the player (ips, names, ban, ...).

### Feedback
Open an issue if you have a suggestion.
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@echo off
powershell .\gradlew :build
powershell ./gradlew :build
move /y .\build\libs\!moreCommands.jar .\
rd /s /q .\build
4 changes: 4 additions & 0 deletions src/main/java/data/Switcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public ConnectReponse connect(mindustry.gen.Player player) {
else {
Host ping = ping();

if (ping != null) {
arc.util.Log.info("@ @ @ @ @ @", ping.address, ping.description, ping.mapname, ping.modeName, ping.versionType, ping.ping);
}

if (ping == null) reponse.failed("The server not responding. (Connexion timed out!)");
else if (ping.playerLimit > 0 && ping.players >= ping.playerLimit) reponse.failed("Server full. (" + ping.players + "/" + ping.playerLimit + ")");
else if (ping.version != mindustry.core.Version.build) reponse.failed("Incompatible version. Required: " + ping.version);
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/manager/BansManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public static void bansCommand(String[] arg) {
+ "[scarlet] has been banned of the server.\nReason: [white]" + PVars.bansReason.get(arg[2])
+ "\n[gold]--------------------\n");
ALog.write("Ban", "[Server] banned @ [@] for the reason: @", d.stripedName, d.player.uuid(), PVars.bansReason.get(arg[2]));
if (arg[3].isBlank()) d.player.kick(KickReason.banned);
else d.player.kick("You are banned on this server!\n[scarlet]Reason: []" + arg[3]);
if (arg.length == 3 || arg[3].isBlank()) d.player.kick(KickReason.banned);
else d.player.kick("You are banned on this server!\n[scarlet]Reason: []" + PVars.bansReason.get(arg[2]));
}
});

Expand Down Expand Up @@ -161,7 +161,7 @@ public static void blacklistCommand(String[] arg) {
Log.info(Strings.lJust("| Custom list: Total: " + bannedNames.size, max) + " Default list: Total: " + list.size);
for (int i = 0; i < Math.max(bannedNames.size, list.size); i++) {
try { builder.append(Strings.lJust("| | " + bannedNames.get(i), max + 1)); }
catch (IndexOutOfBoundsException e) { builder.append("|" + Strings.createSpaces(max)); }
catch (IndexOutOfBoundsException e) { builder.append("|" + Strings.repeat(" ", max)); }
try { builder.append(" | " + list.get(i)); }
catch (IndexOutOfBoundsException e) {}

Expand All @@ -178,7 +178,7 @@ public static void blacklistCommand(String[] arg) {
for (int i = 0; i < Math.max(bannedIps.size, AntiVpn.vpnServersList.size()); i++) {
try { builder.append(Strings.lJust("| | " + bannedIps.get(i), max + 1)); }
catch (IndexOutOfBoundsException e) {
builder.append("|" + Strings.createSpaces(max));
builder.append("|" + Strings.repeat(" ", max));
if (i > 20) break;
}
try {
Expand Down Expand Up @@ -273,8 +273,11 @@ else if (bannedNames.contains(name) ||
name.toLowerCase().equals("server"))
message = "[scarlet]This nickname is banned!";
else if (!player.admin &&
netServer.admins.getAdmins().contains(p -> Strings.stripGlyphs(Strings.stripColors(p.lastName)).strip().equals(name)))
message = "[scarlet]Spoofing an admin name is prohibited!";
netServer.admins.getAdmins().contains(p -> {
String adminName = Strings.stripGlyphs(Strings.stripColors(p.lastName)).strip().toLowerCase();
return adminName.contains(name.toLowerCase()) || name.toLowerCase().contains(adminName);
}))
message = "[scarlet]Spoofing an admin name is prohibited! [lightgray](even if not entirely)";
else if (bannedClients.contains(name)) message = "Ingenuine copy of Mindustry.\n\nMindustry is free on: [royal]https://anuke.itch.io/mindustry[]\n";
else if (bannedIps.contains(player.con.address)) message = "[scarlet]Your IP is blacklisted. [lightgray](ip: " + player.ip() + ")";
else kicked = false;
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/moreCommandsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,19 @@ public void registerServerCommands(CommandHandler handler) {
Log.info("Items of all teams:");
teams.each(t -> {
mindustry.world.modules.ItemModule coreItems = t.cores().first().items;
int count = items.count(i -> coreItems.has(i));
Seq<String> teamItems = items.select(i -> coreItems.has(i)).map(i -> i.name + "=" + coreItems.get(i) + ", ");
String builder = "| | ";
int best = Strings.bestLength(teamItems);

Log.info("| Team @: Total: @ items ", t.name, coreItems.total());
Log.info("| | ");
for (int i=0; i<teamItems.size; i++) {
builder += teamItems.get(i);
if (i%3 == 0 && i != 0) {
Log.info(builder);
builder = "| | ";
}else builder += Strings.repeat("\t", (int)(teamItems.get(i).length()/10));
}
Log.info(builder);
});
return;
}
Expand Down Expand Up @@ -231,7 +240,7 @@ public void registerServerCommands(CommandHandler handler) {
Log.info(Strings.lJust("| Server commands: Total:" + server.size, 28 + best2) + "Client commands: Total:" + client.size);
for (int i=0; i<Math.max(client.size, server.size); i++) {
try { builder.append(Strings.mJust("| | Name: " + server.get(i).name," - Enabled: " + (server.get(i).isActivate ? "true " : "false"), 27 + best2)); }
catch (IndexOutOfBoundsException e) { builder.append("|" + Strings.createSpaces(best1 + 20)); }
catch (IndexOutOfBoundsException e) { builder.append("|" + Strings.repeat(" ", best1 + 20)); }
try { builder.append(Strings.lJust(" | Name: " + client.get(i).name, 9 + best1) + " - Enabled: " + client.get(i).isActivate);}
catch (IndexOutOfBoundsException e) {}

Expand Down Expand Up @@ -679,7 +688,7 @@ else if (arg.length > 1) {
} else {
Log.info("Admin Logs Help:");
Log.info("| Admin logs is @ ...", ALog.isEnabled ? "enabled" : "disabled");
Log.info("| @ files created since the last reset.", ALog.files);
Log.info("| @ files created since the last reset.", ALog.files+1);
Log.info("| Logs path: @", PVars.ALogPath);
Log.info("");
Log.info("Logs files:");
Expand All @@ -692,21 +701,23 @@ else if (arg.length > 1) {
} else Log.err("| Files directory not found.");
}
});

/*
commands.add("reset", "<ID>", "Reset all player's data (names, ips, ...)", arg -> {
PlayerInfo target = netServer.admins.getInfoOptional(arg[0]);
if (target == null) Log.err("no player found with id '@'", arg[0]);
else {
Players player = Players.findByID(arg[0]);
if (player.found) player.player.kick("Player data reset.");
if (player.found) player.player.kick("Player data reseted.");
target = new PlayerInfo();
target.id = arg[0];
Log.info("player data reseted");
}
});
*/
}

// register commands that player can invoke in-game
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/util/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public static String mJust(String left, String right, int newLenght, String fill
return left + right;
}

public static String createSpaces(int length) {
String spaces = "";
for (int i=0; i<length; i++) spaces+=" ";
return spaces;
public static String repeat(String str, int count) {
String result = "";
for (int i=0; i<count; i++) result+=str;
return result;
}

public static int bestLength(Iterable<? extends String> list) {
Expand Down

0 comments on commit 2b00d9a

Please sign in to comment.