-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add /kitreset command #3909
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
Merged
Merged
Add /kitreset command #3909
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
99875a0
Add kitreset command
JRoy b92b714
Update Essentials/src/main/resources/plugin.yml
mdcfe 2202dc2
Allow use by console + Add tab completes
JRoy 679c5d8
Merge remote-tracking branch 'origin/feature/kit-reset' into feature/…
JRoy 87f49ca
Merge branch '2.x' into feature/kit-reset
mdcfe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
Essentials/src/main/java/com/earth2me/essentials/commands/Commandkitreset.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package com.earth2me.essentials.commands; | ||
|
|
||
| import com.earth2me.essentials.CommandSource; | ||
| import com.earth2me.essentials.User; | ||
| import org.bukkit.Server; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import static com.earth2me.essentials.I18n.tl; | ||
|
|
||
| public class Commandkitreset extends EssentialsCommand { | ||
| public Commandkitreset() { | ||
| super("kitreset"); | ||
| } | ||
|
|
||
| @Override | ||
| protected void run(Server server, User user, String commandLabel, String[] args) throws Exception { | ||
| if (args.length < 1) { | ||
| throw new NotEnoughArgumentsException(); | ||
| } | ||
|
|
||
| final String kitName = args[0]; | ||
| if (ess.getKits().getKit(kitName) == null) { | ||
| throw new Exception(tl("kitNotFound")); | ||
| } | ||
|
|
||
| User target = user; | ||
| if (args.length > 1 && user.isAuthorized("essentials.kitreset.others")) { | ||
| target = getPlayer(server, user, args, 1); | ||
| } | ||
|
|
||
| target.setKitTimestamp(kitName, 0); | ||
| if (user.equals(target)) { | ||
| user.sendMessage(tl("kitReset", kitName)); | ||
| } else { | ||
| user.sendMessage(tl("kitResetOther", kitName, target.getDisplayName())); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception { | ||
| if (args.length < 2) { | ||
| throw new NotEnoughArgumentsException(); | ||
| } | ||
|
|
||
| final String kitName = args[0]; | ||
| if (ess.getKits().getKit(kitName) == null) { | ||
| throw new Exception(tl("kitNotFound")); | ||
| } | ||
|
|
||
| final User target = getPlayer(server, sender, args, 1); | ||
| target.setKitTimestamp(kitName, 0); | ||
| sender.sendMessage(tl("kitResetOther", kitName, target.getDisplayName())); | ||
| } | ||
|
|
||
| @Override | ||
| protected List<String> getTabCompleteOptions(Server server, CommandSource sender, String commandLabel, String[] args) { | ||
mdcfe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (args.length == 1) { | ||
| return new ArrayList<>(ess.getKits().getKits().getKeys(false)); | ||
| } else if (args.length == 2 && sender.isAuthorized("essentials.kitreset.others", ess)) { | ||
| return getPlayers(server, sender); | ||
| } else { | ||
| return Collections.emptyList(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.