Added more wildcard parameters for player commands + an optional 'reason' dialog.

This commit is contained in:
StevenLawson 2014-08-28 12:44:56 -04:00
parent 88c6b73b0b
commit 051a53ab21
3 changed files with 60 additions and 20 deletions

View file

@ -346,12 +346,7 @@ public class BTC_MainPanel extends javax.swing.JFrame
if (_source instanceof PlayerListPopupItem_Command)
{
final PlayerListPopupItem_Command source = (PlayerListPopupItem_Command) _source;
final PlayerInfo _player = source.getPlayer();
final PlayerCommandEntry _command = source.getCommand();
final String output = String.format(_command.getFormat(), _player.getName());
final String output = source.getCommand().buildOutput(source.getPlayer(), true);
BTC_MainPanel.this.getConnectionManager().sendDelayedCommand(output, true, 100);
}
else if (_source instanceof PlayerListPopupItem)

View file

@ -19,6 +19,8 @@
package me.StevenLawson.BukkitTelnetClient;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import org.apache.commons.lang3.StringUtils;
public class PlayerCommandEntry extends ConfigEntry
{
@ -53,6 +55,33 @@ public class PlayerCommandEntry extends ConfigEntry
this.name = name;
}
public String buildOutput(PlayerInfo player, boolean useReasonPrompt)
{
String output = StringUtils.replaceEach(getFormat(),
new String[]
{
"$TARGET_NAME",
"$TARGET_IP",
"$TARGET_UUID",
}, new String[]
{
player.getName(),
player.getIp(),
player.getUuid()
}
);
if (useReasonPrompt && output.contains("$REASON"))
{
final String reason = StringUtils.trimToEmpty(
JOptionPane.showInputDialog(null, "Input reason:\n" + output, "Input Reason", JOptionPane.PLAIN_MESSAGE)
);
output = StringUtils.replace(output, "$REASON", reason);
}
return StringUtils.trimToEmpty(output);
}
public static class PlayerCommandEntryList extends ConfigEntryList<PlayerCommandEntry>
{
public PlayerCommandEntryList()

View file

@ -4,59 +4,75 @@
<playerCommands>
<playerCommand>
<name>Ban</name>
<format>glist ban %s</format>
<format>glist ban $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Toggle Mute</name>
<format>mute %s</format>
<format>mute $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Kick</name>
<format>tempban %s 10s Kicked</format>
<format>tempban $TARGET_NAME 10s Kicked</format>
</playerCommand>
<playerCommand>
<name>Tempban 5m + Reason</name>
<format>tempban $TARGET_NAME 5m $REASON</format>
</playerCommand>
<playerCommand>
<name>Tempban 5m</name>
<format>tempban %s 5m</format>
<format>tempban $TARGET_NAME 5m</format>
</playerCommand>
<playerCommand>
<name>Smite</name>
<format>smite %s</format>
<format>smite $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Op</name>
<format>op %s</format>
<format>op $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Deop</name>
<format>deop %s</format>
<format>deop $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>GTFO + Reason</name>
<format>gtfo $TARGET_NAME $REASON</format>
</playerCommand>
<playerCommand>
<name>GTFO</name>
<format>gtfo %s</format>
<format>gtfo $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Toggle Freeze</name>
<format>fr %s</format>
<format>fr $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Cage</name>
<format>cage %s</format>
<format>cage $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Uncage</name>
<format>cage %s off</format>
<format>cage $TARGET_NAME off</format>
</playerCommand>
<playerCommand>
<name>Doom</name>
<format>doom %s</format>
<format>doom $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Creative</name>
<format>creative %s</format>
<format>creative $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Survival</name>
<format>survival %s</format>
<format>survival $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Seen Name</name>
<format>seen $TARGET_NAME</format>
</playerCommand>
<playerCommand>
<name>Seen IP</name>
<format>seen $TARGET_IP</format>
</playerCommand>
</playerCommands>
<favoriteButtons>