mirror of
https://github.com/TotalFreedomMC/ZeroTelnetClient.git
synced 2024-12-23 00:35:22 +00:00
Switch popup to XML Player Command Entry.
This commit is contained in:
parent
737abc7697
commit
ade3933322
3 changed files with 10 additions and 85 deletions
|
@ -235,43 +235,6 @@ public class BTC_MainPanel extends javax.swing.JFrame
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum ServerCommand
|
|
||||||
{
|
|
||||||
BAN("Ban", "glist ban %s"),
|
|
||||||
MUTE("Toggle Mute", "mute %s"),
|
|
||||||
KICK("Kick", "tempban %s 10s Kicked"),
|
|
||||||
TEMPBAN("Tempban 5m", "tempban %s 5m"),
|
|
||||||
SMITE("Smite", "smite %s"),
|
|
||||||
OP("Op", "op %s"),
|
|
||||||
DEOP("Deop", "deop %s"),
|
|
||||||
GTFO("GTFO", "gtfo %s"),
|
|
||||||
FREEZE("Toggle Freeze", "fr %s"),
|
|
||||||
CAGE("Cage", "cage %s"),
|
|
||||||
UNCAGE("Uncage", "cage %s off"),
|
|
||||||
DOOM("Doom", "doom %s"),
|
|
||||||
CREATIVE("Creative", "creative %s"),
|
|
||||||
SURVIVAL("Survival", "survival %s");
|
|
||||||
|
|
||||||
private final String commandName;
|
|
||||||
private final String commandFormat;
|
|
||||||
|
|
||||||
private ServerCommand(String commandName, String commandFormat)
|
|
||||||
{
|
|
||||||
this.commandName = commandName;
|
|
||||||
this.commandFormat = commandFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCommandName()
|
|
||||||
{
|
|
||||||
return commandName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCommandFormat()
|
|
||||||
{
|
|
||||||
return commandFormat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PlayerListPopupItem extends JMenuItem
|
public static class PlayerListPopupItem extends JMenuItem
|
||||||
{
|
{
|
||||||
private final PlayerInfo player;
|
private final PlayerInfo player;
|
||||||
|
@ -290,15 +253,15 @@ public class BTC_MainPanel extends javax.swing.JFrame
|
||||||
|
|
||||||
public static class PlayerListPopupItem_Command extends PlayerListPopupItem
|
public static class PlayerListPopupItem_Command extends PlayerListPopupItem
|
||||||
{
|
{
|
||||||
private final ServerCommand command;
|
private final PlayerCommandEntry command;
|
||||||
|
|
||||||
public PlayerListPopupItem_Command(String text, PlayerInfo player, ServerCommand command)
|
public PlayerListPopupItem_Command(String text, PlayerInfo player, PlayerCommandEntry command)
|
||||||
{
|
{
|
||||||
super(text, player);
|
super(text, player);
|
||||||
this.command = command;
|
this.command = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerCommand getCommand()
|
public PlayerCommandEntry getCommand()
|
||||||
{
|
{
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
@ -352,9 +315,9 @@ public class BTC_MainPanel extends javax.swing.JFrame
|
||||||
final PlayerListPopupItem_Command source = (PlayerListPopupItem_Command) _source;
|
final PlayerListPopupItem_Command source = (PlayerListPopupItem_Command) _source;
|
||||||
|
|
||||||
final PlayerInfo _player = source.getPlayer();
|
final PlayerInfo _player = source.getPlayer();
|
||||||
final ServerCommand _command = source.getCommand();
|
final PlayerCommandEntry _command = source.getCommand();
|
||||||
|
|
||||||
final String output = String.format(_command.getCommandFormat(), _player.getName());
|
final String output = String.format(_command.getFormat(), _player.getName());
|
||||||
|
|
||||||
BTC_MainPanel.this.connectionManager.sendDelayedCommand(output, true, 100);
|
BTC_MainPanel.this.connectionManager.sendDelayedCommand(output, true, 100);
|
||||||
}
|
}
|
||||||
|
@ -383,9 +346,9 @@ public class BTC_MainPanel extends javax.swing.JFrame
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (final ServerCommand command : ServerCommand.values())
|
for (final PlayerCommandEntry command : BukkitTelnetClient.config.getCommands())
|
||||||
{
|
{
|
||||||
final PlayerListPopupItem_Command item = new PlayerListPopupItem_Command(command.getCommandName(), player, command);
|
final PlayerListPopupItem_Command item = new PlayerListPopupItem_Command(command.getName(), player, command);
|
||||||
item.addActionListener(popupAction);
|
item.addActionListener(popupAction);
|
||||||
popup.add(item);
|
popup.add(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
package me.StevenLawson.BukkitTelnetClient;
|
package me.StevenLawson.BukkitTelnetClient;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.json.JSONArray;
|
import org.json.*;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
public class BTC_PlayerListDecoder
|
public class BTC_PlayerListDecoder
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package me.StevenLawson.BukkitTelnetClient;
|
package me.StevenLawson.BukkitTelnetClient;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
public class PlayerInfo
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
public final class PlayerInfo
|
|
||||||
{
|
{
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String ip;
|
private final String ip;
|
||||||
|
@ -31,37 +28,6 @@ public final class PlayerInfo
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
return new HashCodeBuilder(17, 31).
|
|
||||||
append(name).
|
|
||||||
append(ip).
|
|
||||||
append(displayName).
|
|
||||||
toHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (!(obj instanceof PlayerInfo))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj == this)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerInfo rhs = (PlayerInfo) obj;
|
|
||||||
return new EqualsBuilder().
|
|
||||||
append(name, rhs.name).
|
|
||||||
append(ip, rhs.ip).
|
|
||||||
append(displayName, rhs.displayName).
|
|
||||||
isEquals();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue