mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
Add /kitreset command (#3909)
Co-authored-by: darbyjack <admin@glaremasters.me> Closes #163. Ports #2645, which had its branch messed up by merges.
This commit is contained in:
parent
500edb7860
commit
fccf796eeb
@ -75,6 +75,10 @@ public class Kit {
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
}
|
||||
|
||||
public void resetTime(final User user) {
|
||||
user.setKitTimestamp(kitName, 0);
|
||||
}
|
||||
|
||||
public void chargeUser(final User user) throws Exception {
|
||||
charge.charge(user);
|
||||
}
|
||||
|
@ -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) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -405,6 +405,10 @@ kitItem=\u00a76- \u00a7f{0}
|
||||
kitNotFound=\u00a74That kit does not exist.
|
||||
kitOnce=\u00a74You can''t use that kit again.
|
||||
kitReceive=\u00a76Received kit\u00a7c {0}\u00a76.
|
||||
kitReset=\u00a76Reset cooldown for kit \u00a7c{0}\u00a76.
|
||||
kitresetCommandDescription=Resets the cooldown on the specified kit.
|
||||
kitresetCommandUsage=/<command> <kit> [player]
|
||||
kitResetOther=\u00a76Resetting kit \u00a7c{0} \u00a76cooldown for \u00a7c{1}\u00a76.
|
||||
kits=\u00a76Kits\:\u00a7r {0}
|
||||
kittycannonCommandDescription=Throw an exploding kitten at your opponent.
|
||||
kittycannonCommandUsage=/<command>
|
||||
|
@ -260,6 +260,10 @@ commands:
|
||||
description: Obtains the specified kit or views all available kits.
|
||||
usage: /<command> [kit] [player]
|
||||
aliases: [ekit,kits,ekits]
|
||||
kitreset:
|
||||
description: Resets the cooldown on the specified kit.
|
||||
usage: /<command> <kit> [player]
|
||||
aliases: [ekitreset, kitr, ekitr, resetkit, eresetkit]
|
||||
kittycannon:
|
||||
description: Throw an exploding kitten at your opponent.
|
||||
usage: /<command>
|
||||
|
Loading…
Reference in New Issue
Block a user