mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
parent
b6c9bc1439
commit
7a5aea0bcf
3 changed files with 86 additions and 0 deletions
|
@ -0,0 +1,74 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandeditsign extends EssentialsCommand {
|
||||
public Commandeditsign() {
|
||||
super("editsign");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
if (args.length == 0 || (args.length > 1 && !NumberUtil.isInt(args[1]))) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
Block target = user.getBase().getTargetBlock(null, 5); //5 is a good number
|
||||
if (!(target.getState() instanceof Sign)) {
|
||||
throw new Exception(tl("editsignCommandTarget"));
|
||||
}
|
||||
Sign sign = (Sign) target.getState();
|
||||
try {
|
||||
if (args[0].equalsIgnoreCase("set") && args.length > 2) {
|
||||
int line = Integer.parseInt(args[1]) - 1;
|
||||
String text = FormatUtil.formatString(user, "essentials.editsign", getFinalArg(args, 2)).trim();
|
||||
if (ChatColor.stripColor(text).length() > 15 && !user.isAuthorized("essentials.editsign.unlimited")) {
|
||||
throw new Exception(tl("editsignCommandLimit"));
|
||||
}
|
||||
sign.setLine(line, text);
|
||||
sign.update();
|
||||
user.sendMessage(tl("editsignCommandSetSuccess", line + 1, text));
|
||||
} else if (args[0].equalsIgnoreCase("clear")) {
|
||||
if (args.length == 1) {
|
||||
for (int i = 0; i < 4; i++) { // A whole one line of line savings!
|
||||
sign.setLine(i, "");
|
||||
}
|
||||
sign.update();
|
||||
user.sendMessage(tl("editsignCommandClear"));
|
||||
} else {
|
||||
int line = Integer.parseInt(args[1]) - 1;
|
||||
sign.setLine(line, "");
|
||||
sign.update();
|
||||
user.sendMessage(tl("editsignCommandClearLine", line + 1));
|
||||
}
|
||||
} else {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new Exception(tl("editsignCommandNoLine"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return Lists.newArrayList("set", "clear");
|
||||
} else if (args.length == 2) {
|
||||
return Lists.newArrayList("1", "2", "3", "4");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -691,7 +691,15 @@ setworthCommandDescription=Set the sell value of an item.
|
|||
setworthCommandUsage=/<command> [itemname|id] <price>
|
||||
sheepMalformedColor=\u00a74Malformed color.
|
||||
shoutFormat=\u00a76[Shout]\u00a7r {0}
|
||||
editsignCommandClear=\u00a76Sign cleared.
|
||||
editsignCommandClearLine=\u00a76Cleared line\u00a7c {0}\u00a76.
|
||||
showkitCommandDescription=Show contents of a kit.
|
||||
editsignCommandDescription=Edits a sign in the world.
|
||||
editsignCommandLimit=\u00a74Your provided text is too big to fit on the target sign.
|
||||
editsignCommandNoLine=\u00a74You must enter a line number between \u00a7c1-4\u00a74.
|
||||
editsignCommandSetSuccess=\u00a76Set line\u00a7c {0}\u00a76 to "\u00a7c{1}\u00a76".
|
||||
editsignCommandTarget=\u00a74You must be looking at a sign to edit its text.
|
||||
editsignCommandUsage=/<command> <set/clear> [line number] [text]
|
||||
showkitCommandUsage=/<command> <kitname>
|
||||
signFormatFail=\u00a74[{0}]
|
||||
signFormatSuccess=\u00a71[{0}]
|
||||
|
|
|
@ -396,6 +396,10 @@ commands:
|
|||
description: Show contents of a kit.
|
||||
usage: /<command> <kitname>
|
||||
aliases: [kitpreview,preview,kitshow]
|
||||
editsign:
|
||||
description: Edits a sign in the world.
|
||||
usage: /<command> <set/clear> <line number> [text]
|
||||
aliases: [sign, esign, eeditsign]
|
||||
skull:
|
||||
description: Set the owner of a player skull
|
||||
usage: /<command> [owner]
|
||||
|
|
Loading…
Reference in a new issue