Skip to content

Commit

Permalink
[2.1.8] Fixes for /history and /warns
Browse files Browse the repository at this point in the history
History had displayed wrong usage
/warns for own warnings didn't work
  • Loading branch information
DevLeoko committed Apr 9, 2020
1 parent e103257 commit 83cdd3e
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<version>2.1.8</version>
<packaging>jar</packaging>
<properties>
<build>SNAPSHOT</build>
<build>RELEASE</build>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>false</skipTests>
<trimStackTrace>true</trimStackTrace>
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/me/leoko/advancedban/manager/UpdateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ public void setup() {

if(mi.isUnitTesting()) return;

if (!mi.contains(mi.getMessages(), "WarnsOwn")) {
addMessage("ChangeReason:", "", 0);
addMessage("ChangeReason:", "WarnsOwn:", -1);
addMessage("ChangeReason:", " OutOfIndex: \"&cThere is no page %PAGE%!\"", -1);
addMessage("ChangeReason:", " NoEntries: \"&c&oYou have no warnings yet\"", -1);
addMessage("ChangeReason:", " Header:", -1);
addMessage("ChangeReason:", " - \"%PREFIX% &7Your warnings:\"", -1);
addMessage("ChangeReason:", " - \"&e&oDuration &8| &7&oWarned by\"", -1);
addMessage("ChangeReason:", " - \"&c&o#ID &8> &7&oReason\"", -1);
addMessage("ChangeReason:", " - \"&7\"", -1);
addMessage("ChangeReason:", " Entry:", -1);
addMessage("ChangeReason:", " - \"&8[&e%DATE%&8]\"", -1);
addMessage("ChangeReason:", " - \"&e%DURATION% &8| &7%OPERATOR%\"", -1);
addMessage("ChangeReason:", " - \"&c&l#%ID% &8> &7&o%REASON%\"", -1);
addMessage("ChangeReason:", " - \"&7\"", -1);
addMessage("ChangeReason:", " Footer: \"&7Page &e&o%CURRENT_PAGE% &7of &e&o%TOTAL_PAGES% &8| &7Active warnings: &e&o%COUNT%\"", -1);
addMessage("ChangeReason:", " PageFooter: \"&7Use &e&o/warns %NEXT_PAGE% &7to see the next page\"", -1);
}

if (!mi.contains(mi.getMessages(), "UnBan.Notification")) {
addMessage("UnBan:", " Notification: \"&e&o%OPERATOR% &7unbanned &c&o%NAME%\"", 1);
addMessage("UnMute:", " Notification: \"&e&o%OPERATOR% &7unmuted &c&o%NAME%\"", 1);
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/me/leoko/advancedban/utils/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ public enum Command {
new ListProcessor(
target -> PunishmentManager.get().getPunishments(target, null, false),
"History", true, true),
"Banlist.Usage",
"History.Usage",
"history"),

WARNS(null,
"\\S+( [1-9][0-9]*)?|\\S+",
"\\S+( [1-9][0-9]*)?|\\S+|",
input -> {
if (input.getPrimary().matches("\\S+")) {
if (input.hasNext() && !input.getPrimary().matches("[1-9][0-9]*")) {
if (!Universal.get().hasPerms(input.getSender(), "ab.warns.other")) {
MessageManager.sendMessage(input.getSender(), "General.NoPerms", true);
return;
Expand All @@ -217,9 +217,10 @@ public enum Command {
}

String name = Universal.get().getMethods().getName(input.getSender());
String identifier = processName(new Command.CommandInput(input.getSender(), new String[]{name}));
new ListProcessor(
target -> PunishmentManager.get().getPunishments(name, null, true),
"Warns", false, false).accept(input);
target -> PunishmentManager.get().getPunishments(identifier, null, true),
"WarnsOwn", false, false).accept(input);
}
},
"Warns.Usage",
Expand Down Expand Up @@ -366,6 +367,7 @@ public enum Command {
null,
"advancedban");

//language=RegExp
private final String permission;
private final Predicate<String[]> syntaxValidator;
private final Consumer<CommandInput> commandHandler;
Expand Down Expand Up @@ -413,7 +415,7 @@ public static Command getByName(String name) {
return null;
}

public class CommandInput {
public static class CommandInput {
private Object sender;
private String[] args;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public ListProcessor(Function<String, List<Punishment>> listSupplier, String con

@Override
public void accept(Command.CommandInput input) {
String target = "";
String name = input.getPrimary();
String target = null;
String name = "invalid";
if (hasTarget) {
target = input.getPrimary();
name = target;
if (!target.matches("^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$")) {
target = processName(input);
if (target == null)
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/Layouts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Message:
- '&7'
- "&cIt seems like you are using a"
- "&chacked client please disable it!"
- "&cUnban in &8\xbb &7%DURATION%"
- "&cUnban in &8» &7%DURATION%"
- '&7'
- '&8Unban application in TS or forum'
- "&eTS-Ip &8\xbb &c&ncoming soon"
- "&eForum &8\xbb &c&ncoming soon"
- "&eTS-Ip &8» &c&ncoming soon"
- "&eForum &8» &c&ncoming soon"
ExampleLayout2:
- '%PREFIX% &7Banned for offensive language'
- '&7'
Expand Down
110 changes: 63 additions & 47 deletions src/main/resources/Messages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
General:
Prefix: "&c&lAdvancedBan &8&l\xbb"
Prefix: "&c&lAdvancedBan &8&l»"
NoPerms: "&cYou don't have perms for that!"
LayoutNotFound: "&cThere is no layout called %NAME%"
# This will be the replacement for the %DURATION% variable
Expand All @@ -11,154 +11,154 @@ General:


Ban:
Usage: "&cUsage &8\xbb &7&o/ban [Name] [Reason/@Layout]"
Usage: "&cUsage &8» &7&o/ban [Name] [Reason/@Layout]"
Done: "&c&o%NAME% &7was successfully banned!"
AlreadyDone: "&c&o%NAME% &7has already been banned!"
Exempt: "&7You are not able to ban &c&o%NAME%"
Layout:
- '%PREFIX% &7Permanently banned'
- '&7'
- '&7'
- "&cReason &8\xbb &7%REASON%"
- "&cReason &8» &7%REASON%"
- '&7'
- '&8Unban application in TS or forum'
- "&eTS-Ip &8\xbb &c&ncoming soon"
- "&eForum &8\xbb &c&ncoming soon"
- "&eTS-Ip &8» &c&ncoming soon"
- "&eForum &8» &c&ncoming soon"
Notification:
- "&c&o%NAME% &7got banned by &e&o%OPERATOR%"
- "&7For the reason &o%REASON%"
UndoNotification: "&e&o%OPERATOR% &7unbanned &c&o%NAME%"

Ipban:
Usage: "&cUsage &8\xbb &7&o/banip [Name/IP] [Reason/@Layout]"
Usage: "&cUsage &8» &7&o/banip [Name/IP] [Reason/@Layout]"
Layout:
- '%PREFIX% &7Permanently banned'
- '&7'
- '&7'
- "&cReason &8\xbb &7%REASON%"
- "&cReason &8» &7%REASON%"
- '&7'
- '&8Unban application in TS or forum'
- "&eTS-Ip &8\xbb &c&ncoming soon"
- "&eForum &8\xbb &c&ncoming soon"
- "&eTS-Ip &8» &c&ncoming soon"
- "&eForum &8» &c&ncoming soon"
Notification:
- "&c&o%NAME% &7got banned by &e&o%OPERATOR%"
- "&7For the reason &o%REASON%"
IpNotCashed: "&cThere is no saved IP for %NAME%!"

Tempban:
Usage: "&cUsage &8\xbb &7&o/tempban [Name] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
Usage: "&cUsage &8» &7&o/tempban [Name] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
MaxDuration: "&cYou are not able to ban more than %MAX%sec"
Layout:
- '%PREFIX% &7Temporarily banned'
- '&7'
- '&7'
- "&cReason &8\xbb &7%REASON%"
- "&cDuration &8\xbb &7%DURATION%"
- "&cReason &8» &7%REASON%"
- "&cDuration &8» &7%DURATION%"
- '&7'
- '&8Unban application in TS or forum'
- "&eTS-Ip &8\xbb &c&ncoming soon"
- "&eForum &8\xbb &c&ncoming soon"
- "&eTS-Ip &8» &c&ncoming soon"
- "&eForum &8» &c&ncoming soon"
Notification:
- "&c&o%NAME% &7got banned by &e&o%OPERATOR%"
- "&7For the reason &o%REASON%"
- "&7&oThis player got banned for &e&o%DURATION%"

Tempipban:
Usage: "&cUsage &8\xbb &7&o/tempipban [Name/IP] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
Usage: "&cUsage &8» &7&o/tempipban [Name/IP] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
MaxDuration: "&cYou are not able to ban more than %MAX%sec"
Layout:
- '%PREFIX% &7Temporarily banned'
- '&7'
- '&7'
- "&cReason &8\xbb &7%REASON%"
- "&cDuration &8\xbb &7%DURATION%"
- "&cReason &8» &7%REASON%"
- "&cDuration &8» &7%DURATION%"
- '&7'
- '&8Unban application in TS or forum'
- "&eTS-Ip &8\xbb &c&ncoming soon"
- "&eForum &8\xbb &c&ncoming soon"
- "&eTS-Ip &8» &c&ncoming soon"
- "&eForum &8» &c&ncoming soon"
Notification:
- "&c&o%NAME% &7got banned by &e&o%OPERATOR%"
- "&7For the reason &o%REASON%"
- "&7&oThis player got banned for &e&o%DURATION%"

Mute:
Usage: "&cUsage &8\xbb &7&o/mute [Name] [Reason/@Layout]"
Usage: "&cUsage &8» &7&o/mute [Name] [Reason/@Layout]"
Done: "&c&o%NAME% &7was successfully muted!"
AlreadyDone: "&c&o%NAME% &7has already been muted!"
Exempt: "&7You are not able to mute &c&o%NAME%"
Layout:
- '%PREFIX% &7You are permanently muted'
- "&cReason &8\xbb &7%REASON%"
- "&cReason &8» &7%REASON%"
Notification:
- "&c&o%NAME% &7got muted by &e&o%OPERATOR%"
- "&7For the reason &o%REASON%"
UndoNotification: "&e&o%OPERATOR% &7unmuted &c&o%NAME%"

Tempmute:
Usage: "&cUsage &8\xbb &7&o/tempmute [Name] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
Usage: "&cUsage &8» &7&o/tempmute [Name] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
MaxDuration: "&cYou are not able to mute more than %MAX%sec"
Layout:
- '%PREFIX% &7You are muted for %DURATION%'
- "&cReason &8\xbb &7%REASON%"
- "&cReason &8» &7%REASON%"
Notification:
- "&c&o%NAME% &7got muted by &e&o%OPERATOR%"
- "&7For the reason &o%REASON%"
- "&7&oThis player got muted for &e&o%DURATION%"

Warn:
Usage: "&cUsage &8\xbb &7&o/warn [Name] [Reason/@Layout]"
Usage: "&cUsage &8» &7&o/warn [Name] [Reason/@Layout]"
Done: "&c&o%NAME% &7was successfully warned!"
Exempt: "&7You are not able to warn &c&o%NAME%"
Layout:
- '%PREFIX% &cYou received a warning'
- "&cReason &8\xbb &7%REASON%"
- "&cReason &8» &7%REASON%"
- '&7You have now &c&o%COUNT% &7warning(s) in total!'
Notification:
- "&c&o%NAME% &7got warned by &e&o%OPERATOR%"
- "&7For the reason &o%REASON%"

Tempwarn:
Usage: "&cUsage &8\xbb &7&o/tempwarn [Name] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
Usage: "&cUsage &8» &7&o/tempwarn [Name] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
MaxDuration: "&cYou are not able to warn more than %MAX%sec"
Layout:
- '%PREFIX% &cYou received a temp-warning'
- "&cReason &8\xbb &7%REASON%"
- "&cIt will pass in &8\xbb &7%DURATION%"
- "&cReason &8» &7%REASON%"
- "&cIt will pass in &8» &7%DURATION%"
- '&7You have now &c&o%COUNT% &7warning(s) in total!'
Notification:
- "&c&o%NAME% &7got temp-warned by &e&o%OPERATOR%"
- "&7For the reason &o%REASON%"
- "&7This warning will pass in &o%DURATION%"

Kick:
Usage: "&cUsage &8\xbb &7&o/kick [Name] [Reason/@Layout]"
Usage: "&cUsage &8» &7&o/kick [Name] [Reason/@Layout]"
Done: "&c&o%NAME% &7was successfully kicked!"
NotOnline: "&c&o%NAME% &7is not online!"
Exempt: "&7You are not able to kick &c&o%NAME%"
Layout:
- '%PREFIX% &7You got kicked'
- '&7'
- "&cReason &8\xbb &7%REASON%"
- "&cReason &8» &7%REASON%"
- '&7'
Notification:
- "&c&o%NAME% &7got kicked by &e&o%OPERATOR%"
- "&7For the reason &o%REASON%"


UnBan:
Usage: "&cUsage &8\xbb &7&o/unban [Name/IP]"
Usage: "&cUsage &8» &7&o/unban [Name/IP]"
NotPunished: "&c&o%NAME% is not banned!"
Done: "&a&o%NAME% &7was successfully unbanned!"
Notification: "&e&o%OPERATOR% &7unbanned &c&o%NAME%"

UnMute:
Usage: "&cUsage &8\xbb &7&o/unmute [Name]"
Usage: "&cUsage &8» &7&o/unmute [Name]"
NotPunished: "&c&o%NAME% is not muted!"
Done: "&a&o%NAME% &7was successfully unmuted!"
Notification: "&e&o%OPERATOR% &7unmuted &c&o%NAME%"

UnWarn:
Usage: "&cUsage &8\xbb &7&o/unwarn [ID] or /unwarn clear [Name]"
Usage: "&cUsage &8» &7&o/unwarn [ID] or /unwarn clear [Name]"
NotFound: "&cCould not find warning #%ID%"
Done: "&7Warn &a&o#%ID% &7was successfully deleted!"
Notification: "&e&o%OPERATOR% &7unwarned &c&o%NAME%"
Expand All @@ -167,13 +167,13 @@ UnWarn:
Done: "&7Cleared &a&o%COUNT% &7warnings"

UnPunish:
Usage: "&cUsage &8\xbb &7&o/unpunish [ID]"
Usage: "&cUsage &8» &7&o/unpunish [ID]"
NotFound: "&cCould not find punishment #%ID%"
Done: "&7Punishment &a&o#%ID% &7was successfully deleted!"


Banlist:
Usage: "&cUsage &8\xbb &7&o/banlist <Page>"
Usage: "&cUsage &8» &7&o/banlist <Page>"
OutOfIndex: "&cThere is no page %PAGE%!"
NoEntries: "&c&oThere are no entries"
Header:
Expand All @@ -190,7 +190,7 @@ Banlist:
PageFooter: "&7Use &e&o/banlist %NEXT_PAGE% &7to see the next page"

History:
Usage: "&cUsage &8\xbb &7&o/history [Name/IP] <Page>"
Usage: "&cUsage &8» &7&o/history [Name/IP] <Page>"
OutOfIndex: "&cThere is no page %PAGE%!"
NoEntries: "&c&oCould not find the history of %NAME% :("
Header:
Expand All @@ -207,7 +207,7 @@ History:
PageFooter: "&7Use &e&o/history %NAME% %NEXT_PAGE% &7to see the next page"

Warns:
Usage: "&cUsage &8\xbb &7&o/warns [Name] <Page>"
Usage: "&cUsage &8» &7&o/warns [Name] <Page> &cor &7&o/warns <Page>"
OutOfIndex: "&cThere is no page %PAGE%!"
NoEntries: "&c&o%NAME% has no warnings yet"
Header:
Expand All @@ -223,22 +223,38 @@ Warns:
Footer: "&7Page &e&o%CURRENT_PAGE% &7of &e&o%TOTAL_PAGES% &8| &7Active warnings: &e&o%COUNT%"
PageFooter: "&7Use &e&o/warns %NAME% %NEXT_PAGE% &7to see the next page"

WarnsOwn:
OutOfIndex: "&cThere is no page %PAGE%!"
NoEntries: "&c&oYou have no warnings yet"
Header:
- "%PREFIX% &7Your warnings:"
- "&e&oDuration &8| &7&oWarned by"
- "&c&o#ID &8> &7&oReason"
- "&7"
Entry:
- "&8[&e%DATE%&8]"
- "&e%DURATION% &8| &7%OPERATOR%"
- "&c&l#%ID% &8> &7&o%REASON%"
- "&7"
Footer: "&7Page &e&o%CURRENT_PAGE% &7of &e&o%TOTAL_PAGES% &8| &7Active warnings: &e&o%COUNT%"
PageFooter: "&7Use &e&o/warns %NEXT_PAGE% &7to see the next page"

ChangeReason:
Usage: "&cUsage &8\xbb &7&o/change-reason [ID or ban/mute USER] [New reason]"
Usage: "&cUsage &8» &7&o/change-reason [ID or ban/mute USER] [New reason]"
Done: "&7Punishment &a&o#%ID% &7has successfully been updated!"
NotFound: "&cSorry we have not been able to find this punishment"

Check:
Usage: "&cUsage &8\xbb &7&o/check [Name]"
Usage: "&cUsage &8» &7&o/check [Name]"
Header: "&7Checking &e&o%NAME% &8(%CACHED%&8)"
UUID: "&cUUID &8\xbb &7%UUID% &8(%CACHED%&8)"
IP: "&cIP &8\xbb &7%IP% &8(%CACHED%&8)"
Geo: "&cCountry &8\xbb &7%LOCATION%"
Mute: "&cMuted &8\xbb &7%DURATION%"
MuteReason: " &cReason &8\xbb &7%REASON%"
Ban: "&cBanned &8\xbb &7%DURATION%"
BanReason: " &cReason &8\xbb &7%REASON%"
Warn: "&cWarns &8\xbb &7%COUNT%"
UUID: "&cUUID &8» &7%UUID% &8(%CACHED%&8)"
IP: "&cIP &8» &7%IP% &8(%CACHED%&8)"
Geo: "&cCountry &8» &7%LOCATION%"
Mute: "&cMuted &8» &7%DURATION%"
MuteReason: " &cReason &8» &7%REASON%"
Ban: "&cBanned &8» &7%DURATION%"
BanReason: " &cReason &8» &7%REASON%"
Warn: "&cWarns &8» &7%COUNT%"
NotFound: "&cSorry we have not been able to find %NAME%"
Cached: "&a&ocached"
NotCached: "&c&onot cached"

0 comments on commit 83cdd3e

Please sign in to comment.