-
Notifications
You must be signed in to change notification settings - Fork 126
Allow players to view their full /history #626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,10 +18,7 @@ | |
| import me.leoko.advancedban.utils.tabcompletion.TabCompleter; | ||
| import org.apache.commons.lang3.ArrayUtils; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Calendar; | ||
| import java.util.GregorianCalendar; | ||
| import java.util.List; | ||
| import java.util.*; | ||
| import java.util.function.Consumer; | ||
| import java.util.function.Predicate; | ||
|
|
||
|
|
@@ -281,24 +278,22 @@ public enum Command { | |
| "Banlist.Usage", | ||
| "banlist"), | ||
|
|
||
| HISTORY("ab.history", | ||
| "\\S+( [1-9][0-9]*)?", | ||
| HISTORY(null, | ||
| "\\S+( [1-9][0-9]*)?|\\S+|", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you clarify this change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why I did it this way, I have no idea, as it has been like two years. |
||
| new CleanTabCompleter((user, args) -> { | ||
| if(args.length == 1) | ||
| return list(CleanTabCompleter.PLAYER_PLACEHOLDER, "[Name]"); | ||
| else if(args.length == 2) | ||
| if(Universal.get().getMethods().hasPerms(user, "ab.history.other")) | ||
| return list(CleanTabCompleter.PLAYER_PLACEHOLDER, "<Name>", "<Page>"); | ||
| else | ||
| return list("<Page>"); | ||
| else if(args.length == 2 && !args[0].matches("\\d+")) | ||
| return list("<Page>"); | ||
| else | ||
| return list(); | ||
| }), | ||
| input -> { | ||
| MethodInterface mi = Universal.get().getMethods(); | ||
| List<PunishmentType> putList = new ArrayList<>(); | ||
| mi.getStringList(mi.getConfig(),"FullHistory").forEach((typeString -> putList.add(PunishmentType.valueOf(typeString)))); | ||
|
|
||
| new ListProcessor( | ||
| target -> PunishmentManager.get().getPunishmentsOfTypes(target, putList, false), | ||
| "History", true, true).accept(input); | ||
| PunishmentType[] puts={}; | ||
| hasPerm(input, "History", false, puts); | ||
| }, | ||
| "History.Usage", | ||
| "history"), | ||
|
|
@@ -316,29 +311,7 @@ else if(args.length == 2 && !args[0].matches("\\d+")) | |
| else | ||
| return list(); | ||
| }), | ||
| input -> { | ||
| 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; | ||
| } | ||
|
|
||
| new ListProcessor( | ||
| target -> PunishmentManager.get().getPunishments(target, PunishmentType.WARNING, true), | ||
| "Warns", false, true).accept(input); | ||
| } else { | ||
| if (!Universal.get().hasPerms(input.getSender(), "ab.warns.own")) { | ||
| MessageManager.sendMessage(input.getSender(), "General.NoPerms", true); | ||
| return; | ||
| } | ||
|
|
||
| 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(identifier, PunishmentType.WARNING, true), | ||
| "WarnsOwn", false, false).accept(input); | ||
| } | ||
| }, | ||
| input -> hasPerm(input, "Warns", true, PunishmentType.WARNING), | ||
| "Warns.Usage", | ||
| "warns"), | ||
| NOTES(null, | ||
|
|
@@ -354,29 +327,7 @@ else if(args.length == 2 && !args[0].matches("\\d+")) | |
| else | ||
| return list(); | ||
| }), | ||
| input -> { | ||
| if (input.hasNext() && !input.getPrimary().matches("[1-9][0-9]*")) { | ||
| if (!Universal.get().hasPerms(input.getSender(), "ab.notes.other")) { | ||
| MessageManager.sendMessage(input.getSender(), "General.NoPerms", true); | ||
| return; | ||
| } | ||
|
|
||
| new ListProcessor( | ||
| target -> PunishmentManager.get().getPunishments(target, PunishmentType.NOTE, true), | ||
| "Notes", false, true).accept(input); | ||
| } else { | ||
| if (!Universal.get().hasPerms(input.getSender(), "ab.notes.own")) { | ||
| MessageManager.sendMessage(input.getSender(), "General.NoPerms", true); | ||
| return; | ||
| } | ||
|
|
||
| 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(identifier, PunishmentType.NOTE, true), | ||
| "NotesOwn", false, false).accept(input); | ||
| } | ||
| }, | ||
| input -> hasPerm(input, "Notes", true, PunishmentType.NOTE), | ||
| "Notes.Usage", | ||
| "notes"), | ||
|
|
||
|
|
@@ -531,6 +482,37 @@ else if(args.length == 2 && !args[0].matches("\\d+")) | |
| null, | ||
| "advancedban"); | ||
|
|
||
| private static void hasPerm(Command.CommandInput input, String FriendlyName, boolean current, PunishmentType ... puts){ | ||
| MethodInterface mi = Universal.get().getMethods(); | ||
| List<PunishmentType> Types; | ||
| if(puts.length == 0){ | ||
| Types = new ArrayList<>(); | ||
| mi.getStringList(mi.getConfig(),"FullHistory").forEach((typeString -> Types.add(PunishmentType.valueOf(typeString)))); | ||
| }else | ||
| Types = Arrays.asList(puts); | ||
|
|
||
|
|
||
| if (input.hasNext() && !input.getPrimary().matches("[1-9][0-9]*")) { | ||
| if (!Universal.get().hasPerms(input.getSender(), "ab." + FriendlyName.toLowerCase() + ".other")) { | ||
| MessageManager.sendMessage(input.getSender(), "General.NoPerms", true); | ||
| return; | ||
| } | ||
| new ListProcessor( | ||
| target -> PunishmentManager.get().getPunishmentsOfTypes(target, Types, current), | ||
| FriendlyName, false, true).accept(input); | ||
| } else { | ||
| if (!Universal.get().hasPerms(input.getSender(), "ab." + FriendlyName.toLowerCase() + ".own")) { | ||
| MessageManager.sendMessage(input.getSender(), "General.NoPerms", true); | ||
| return; | ||
| } | ||
|
|
||
| String name = Universal.get().getMethods().getName(input.getSender()); | ||
| String identifier = processName(new Command.CommandInput(input.getSender(), new String[]{name})); | ||
| new ListProcessor( | ||
| target -> PunishmentManager.get().getPunishmentsOfTypes(identifier, Types, current), | ||
| FriendlyName + "Own", false, false).accept(input); | ||
| } | ||
| } | ||
| private final String permission; | ||
| private final Predicate<String[]> syntaxValidator; | ||
| private final TabCompleter tabCompleter; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define the imports required that are relevant for the changes rather than using a wildcard.