Skip to content

Commit 83cdd3e

Browse files
committed
[2.1.8] Fixes for /history and /warns
History had displayed wrong usage /warns for own warnings didn't work
1 parent e103257 commit 83cdd3e

File tree

6 files changed

+97
-59
lines changed

6 files changed

+97
-59
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<version>2.1.8</version>
99
<packaging>jar</packaging>
1010
<properties>
11-
<build>SNAPSHOT</build>
11+
<build>RELEASE</build>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<skipTests>false</skipTests>
1414
<trimStackTrace>true</trimStackTrace>

src/main/java/me/leoko/advancedban/manager/UpdateManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ public void setup() {
3636

3737
if(mi.isUnitTesting()) return;
3838

39+
if (!mi.contains(mi.getMessages(), "WarnsOwn")) {
40+
addMessage("ChangeReason:", "", 0);
41+
addMessage("ChangeReason:", "WarnsOwn:", -1);
42+
addMessage("ChangeReason:", " OutOfIndex: \"&cThere is no page %PAGE%!\"", -1);
43+
addMessage("ChangeReason:", " NoEntries: \"&c&oYou have no warnings yet\"", -1);
44+
addMessage("ChangeReason:", " Header:", -1);
45+
addMessage("ChangeReason:", " - \"%PREFIX% &7Your warnings:\"", -1);
46+
addMessage("ChangeReason:", " - \"&e&oDuration &8| &7&oWarned by\"", -1);
47+
addMessage("ChangeReason:", " - \"&c&o#ID &8> &7&oReason\"", -1);
48+
addMessage("ChangeReason:", " - \"&7\"", -1);
49+
addMessage("ChangeReason:", " Entry:", -1);
50+
addMessage("ChangeReason:", " - \"&8[&e%DATE%&8]\"", -1);
51+
addMessage("ChangeReason:", " - \"&e%DURATION% &8| &7%OPERATOR%\"", -1);
52+
addMessage("ChangeReason:", " - \"&c&l#%ID% &8> &7&o%REASON%\"", -1);
53+
addMessage("ChangeReason:", " - \"&7\"", -1);
54+
addMessage("ChangeReason:", " Footer: \"&7Page &e&o%CURRENT_PAGE% &7of &e&o%TOTAL_PAGES% &8| &7Active warnings: &e&o%COUNT%\"", -1);
55+
addMessage("ChangeReason:", " PageFooter: \"&7Use &e&o/warns %NEXT_PAGE% &7to see the next page\"", -1);
56+
}
57+
3958
if (!mi.contains(mi.getMessages(), "UnBan.Notification")) {
4059
addMessage("UnBan:", " Notification: \"&e&o%OPERATOR% &7unbanned &c&o%NAME%\"", 1);
4160
addMessage("UnMute:", " Notification: \"&e&o%OPERATOR% &7unmuted &c&o%NAME%\"", 1);

src/main/java/me/leoko/advancedban/utils/Command.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ public enum Command {
195195
new ListProcessor(
196196
target -> PunishmentManager.get().getPunishments(target, null, false),
197197
"History", true, true),
198-
"Banlist.Usage",
198+
"History.Usage",
199199
"history"),
200200

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

219219
String name = Universal.get().getMethods().getName(input.getSender());
220+
String identifier = processName(new Command.CommandInput(input.getSender(), new String[]{name}));
220221
new ListProcessor(
221-
target -> PunishmentManager.get().getPunishments(name, null, true),
222-
"Warns", false, false).accept(input);
222+
target -> PunishmentManager.get().getPunishments(identifier, null, true),
223+
"WarnsOwn", false, false).accept(input);
223224
}
224225
},
225226
"Warns.Usage",
@@ -366,6 +367,7 @@ public enum Command {
366367
null,
367368
"advancedban");
368369

370+
//language=RegExp
369371
private final String permission;
370372
private final Predicate<String[]> syntaxValidator;
371373
private final Consumer<CommandInput> commandHandler;
@@ -413,7 +415,7 @@ public static Command getByName(String name) {
413415
return null;
414416
}
415417

416-
public class CommandInput {
418+
public static class CommandInput {
417419
private Object sender;
418420
private String[] args;
419421

src/main/java/me/leoko/advancedban/utils/commands/ListProcessor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ public ListProcessor(Function<String, List<Punishment>> listSupplier, String con
2929

3030
@Override
3131
public void accept(Command.CommandInput input) {
32-
String target = "";
33-
String name = input.getPrimary();
32+
String target = null;
33+
String name = "invalid";
3434
if (hasTarget) {
3535
target = input.getPrimary();
36+
name = target;
3637
if (!target.matches("^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$")) {
3738
target = processName(input);
3839
if (target == null)

src/main/resources/Layouts.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ Message:
1919
- '&7'
2020
- "&cIt seems like you are using a"
2121
- "&chacked client please disable it!"
22-
- "&cUnban in &8\xbb &7%DURATION%"
22+
- "&cUnban in &8» &7%DURATION%"
2323
- '&7'
2424
- '&8Unban application in TS or forum'
25-
- "&eTS-Ip &8\xbb &c&ncoming soon"
26-
- "&eForum &8\xbb &c&ncoming soon"
25+
- "&eTS-Ip &8» &c&ncoming soon"
26+
- "&eForum &8» &c&ncoming soon"
2727
ExampleLayout2:
2828
- '%PREFIX% &7Banned for offensive language'
2929
- '&7'

src/main/resources/Messages.yml

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
General:
2-
Prefix: "&c&lAdvancedBan &8&l\xbb"
2+
Prefix: "&c&lAdvancedBan &8&l»"
33
NoPerms: "&cYou don't have perms for that!"
44
LayoutNotFound: "&cThere is no layout called %NAME%"
55
# This will be the replacement for the %DURATION% variable
@@ -11,154 +11,154 @@ General:
1111

1212

1313
Ban:
14-
Usage: "&cUsage &8\xbb &7&o/ban [Name] [Reason/@Layout]"
14+
Usage: "&cUsage &8» &7&o/ban [Name] [Reason/@Layout]"
1515
Done: "&c&o%NAME% &7was successfully banned!"
1616
AlreadyDone: "&c&o%NAME% &7has already been banned!"
1717
Exempt: "&7You are not able to ban &c&o%NAME%"
1818
Layout:
1919
- '%PREFIX% &7Permanently banned'
2020
- '&7'
2121
- '&7'
22-
- "&cReason &8\xbb &7%REASON%"
22+
- "&cReason &8» &7%REASON%"
2323
- '&7'
2424
- '&8Unban application in TS or forum'
25-
- "&eTS-Ip &8\xbb &c&ncoming soon"
26-
- "&eForum &8\xbb &c&ncoming soon"
25+
- "&eTS-Ip &8» &c&ncoming soon"
26+
- "&eForum &8» &c&ncoming soon"
2727
Notification:
2828
- "&c&o%NAME% &7got banned by &e&o%OPERATOR%"
2929
- "&7For the reason &o%REASON%"
3030
UndoNotification: "&e&o%OPERATOR% &7unbanned &c&o%NAME%"
3131

3232
Ipban:
33-
Usage: "&cUsage &8\xbb &7&o/banip [Name/IP] [Reason/@Layout]"
33+
Usage: "&cUsage &8» &7&o/banip [Name/IP] [Reason/@Layout]"
3434
Layout:
3535
- '%PREFIX% &7Permanently banned'
3636
- '&7'
3737
- '&7'
38-
- "&cReason &8\xbb &7%REASON%"
38+
- "&cReason &8» &7%REASON%"
3939
- '&7'
4040
- '&8Unban application in TS or forum'
41-
- "&eTS-Ip &8\xbb &c&ncoming soon"
42-
- "&eForum &8\xbb &c&ncoming soon"
41+
- "&eTS-Ip &8» &c&ncoming soon"
42+
- "&eForum &8» &c&ncoming soon"
4343
Notification:
4444
- "&c&o%NAME% &7got banned by &e&o%OPERATOR%"
4545
- "&7For the reason &o%REASON%"
4646
IpNotCashed: "&cThere is no saved IP for %NAME%!"
4747

4848
Tempban:
49-
Usage: "&cUsage &8\xbb &7&o/tempban [Name] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
49+
Usage: "&cUsage &8» &7&o/tempban [Name] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
5050
MaxDuration: "&cYou are not able to ban more than %MAX%sec"
5151
Layout:
5252
- '%PREFIX% &7Temporarily banned'
5353
- '&7'
5454
- '&7'
55-
- "&cReason &8\xbb &7%REASON%"
56-
- "&cDuration &8\xbb &7%DURATION%"
55+
- "&cReason &8» &7%REASON%"
56+
- "&cDuration &8» &7%DURATION%"
5757
- '&7'
5858
- '&8Unban application in TS or forum'
59-
- "&eTS-Ip &8\xbb &c&ncoming soon"
60-
- "&eForum &8\xbb &c&ncoming soon"
59+
- "&eTS-Ip &8» &c&ncoming soon"
60+
- "&eForum &8» &c&ncoming soon"
6161
Notification:
6262
- "&c&o%NAME% &7got banned by &e&o%OPERATOR%"
6363
- "&7For the reason &o%REASON%"
6464
- "&7&oThis player got banned for &e&o%DURATION%"
6565

6666
Tempipban:
67-
Usage: "&cUsage &8\xbb &7&o/tempipban [Name/IP] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
67+
Usage: "&cUsage &8» &7&o/tempipban [Name/IP] [Xmo/Xd/Xh/Xm/Xs/#TimeLayout] [Reason/@Layout]"
6868
MaxDuration: "&cYou are not able to ban more than %MAX%sec"
6969
Layout:
7070
- '%PREFIX% &7Temporarily banned'
7171
- '&7'
7272
- '&7'
73-
- "&cReason &8\xbb &7%REASON%"
74-
- "&cDuration &8\xbb &7%DURATION%"
73+
- "&cReason &8» &7%REASON%"
74+
- "&cDuration &8» &7%DURATION%"
7575
- '&7'
7676
- '&8Unban application in TS or forum'
77-
- "&eTS-Ip &8\xbb &c&ncoming soon"
78-
- "&eForum &8\xbb &c&ncoming soon"
77+
- "&eTS-Ip &8» &c&ncoming soon"
78+
- "&eForum &8» &c&ncoming soon"
7979
Notification:
8080
- "&c&o%NAME% &7got banned by &e&o%OPERATOR%"
8181
- "&7For the reason &o%REASON%"
8282
- "&7&oThis player got banned for &e&o%DURATION%"
8383

8484
Mute:
85-
Usage: "&cUsage &8\xbb &7&o/mute [Name] [Reason/@Layout]"
85+
Usage: "&cUsage &8» &7&o/mute [Name] [Reason/@Layout]"
8686
Done: "&c&o%NAME% &7was successfully muted!"
8787
AlreadyDone: "&c&o%NAME% &7has already been muted!"
8888
Exempt: "&7You are not able to mute &c&o%NAME%"
8989
Layout:
9090
- '%PREFIX% &7You are permanently muted'
91-
- "&cReason &8\xbb &7%REASON%"
91+
- "&cReason &8» &7%REASON%"
9292
Notification:
9393
- "&c&o%NAME% &7got muted by &e&o%OPERATOR%"
9494
- "&7For the reason &o%REASON%"
9595
UndoNotification: "&e&o%OPERATOR% &7unmuted &c&o%NAME%"
9696

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

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

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

133133
Kick:
134-
Usage: "&cUsage &8\xbb &7&o/kick [Name] [Reason/@Layout]"
134+
Usage: "&cUsage &8» &7&o/kick [Name] [Reason/@Layout]"
135135
Done: "&c&o%NAME% &7was successfully kicked!"
136136
NotOnline: "&c&o%NAME% &7is not online!"
137137
Exempt: "&7You are not able to kick &c&o%NAME%"
138138
Layout:
139139
- '%PREFIX% &7You got kicked'
140140
- '&7'
141-
- "&cReason &8\xbb &7%REASON%"
141+
- "&cReason &8» &7%REASON%"
142142
- '&7'
143143
Notification:
144144
- "&c&o%NAME% &7got kicked by &e&o%OPERATOR%"
145145
- "&7For the reason &o%REASON%"
146146

147147

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

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

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

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

174174

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

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

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

226+
WarnsOwn:
227+
OutOfIndex: "&cThere is no page %PAGE%!"
228+
NoEntries: "&c&oYou have no warnings yet"
229+
Header:
230+
- "%PREFIX% &7Your warnings:"
231+
- "&e&oDuration &8| &7&oWarned by"
232+
- "&c&o#ID &8> &7&oReason"
233+
- "&7"
234+
Entry:
235+
- "&8[&e%DATE%&8]"
236+
- "&e%DURATION% &8| &7%OPERATOR%"
237+
- "&c&l#%ID% &8> &7&o%REASON%"
238+
- "&7"
239+
Footer: "&7Page &e&o%CURRENT_PAGE% &7of &e&o%TOTAL_PAGES% &8| &7Active warnings: &e&o%COUNT%"
240+
PageFooter: "&7Use &e&o/warns %NEXT_PAGE% &7to see the next page"
241+
226242
ChangeReason:
227-
Usage: "&cUsage &8\xbb &7&o/change-reason [ID or ban/mute USER] [New reason]"
243+
Usage: "&cUsage &8» &7&o/change-reason [ID or ban/mute USER] [New reason]"
228244
Done: "&7Punishment &a&o#%ID% &7has successfully been updated!"
229245
NotFound: "&cSorry we have not been able to find this punishment"
230246

231247
Check:
232-
Usage: "&cUsage &8\xbb &7&o/check [Name]"
248+
Usage: "&cUsage &8» &7&o/check [Name]"
233249
Header: "&7Checking &e&o%NAME% &8(%CACHED%&8)"
234-
UUID: "&cUUID &8\xbb &7%UUID% &8(%CACHED%&8)"
235-
IP: "&cIP &8\xbb &7%IP% &8(%CACHED%&8)"
236-
Geo: "&cCountry &8\xbb &7%LOCATION%"
237-
Mute: "&cMuted &8\xbb &7%DURATION%"
238-
MuteReason: " &cReason &8\xbb &7%REASON%"
239-
Ban: "&cBanned &8\xbb &7%DURATION%"
240-
BanReason: " &cReason &8\xbb &7%REASON%"
241-
Warn: "&cWarns &8\xbb &7%COUNT%"
250+
UUID: "&cUUID &8» &7%UUID% &8(%CACHED%&8)"
251+
IP: "&cIP &8» &7%IP% &8(%CACHED%&8)"
252+
Geo: "&cCountry &8» &7%LOCATION%"
253+
Mute: "&cMuted &8» &7%DURATION%"
254+
MuteReason: " &cReason &8» &7%REASON%"
255+
Ban: "&cBanned &8» &7%DURATION%"
256+
BanReason: " &cReason &8» &7%REASON%"
257+
Warn: "&cWarns &8» &7%COUNT%"
242258
NotFound: "&cSorry we have not been able to find %NAME%"
243259
Cached: "&a&ocached"
244260
NotCached: "&c&onot cached"

0 commit comments

Comments
 (0)