Implemented & Adapted RobGob69's Server ControlPanel (#568)

This commit is contained in:
Josh Shippam
2023-01-30 22:27:20 +00:00
committed by GitHub
parent 32947bbd15
commit 0754b24aa7
8 changed files with 1750 additions and 1 deletions
@@ -1,6 +1,7 @@
{
"server_name": "2006Scape",
"server_test_version": 2.3,
"gui_enabled": true,
"website_link": "https://2006Scape.org",
"server_debug": false,
"file_server": true,
@@ -16,6 +16,7 @@ object ConfigLoader {
val obj = JSONObject(out)
if (obj.has("server_name")) GameConstants.SERVER_NAME = obj.getString("server_name")
if (obj.has("server_test_version")) GameConstants.TEST_VERSION = obj.getDouble("server_test_version")
if (obj.has("gui_enabled")) GameConstants.GUI_ENABLED = obj.getBoolean("gui_enabled")
if (obj.has("website_link")) GameConstants.WEBSITE_LINK = obj.getString("website_link")
if (obj.has("server_debug")) GameConstants.SERVER_DEBUG = obj.getBoolean("server_debug")
if (obj.has("file_server")) GameConstants.FILE_SERVER = obj.getBoolean("file_server")
@@ -7,6 +7,7 @@ object GameConstants {
* SERVER_NAME Sets The Name The Server Will Use
* WEBSITE_LINK Defines The Server Website Links
* WORLD Sets The Servers World ID
* GUI_ENABLED Enables/Disables The Server Control Panel
* MAX_PLAYERS Sets The Maximum Amount Of Players Allow To Be Logged In At Once
* TIMEOUT Sets The Amount Of Time Before A Player Timeouts From A Bad Connection
* SAVE_TIMER Sets In Seconds How Often The Server Shouls Auto-Save All Characters
@@ -33,6 +34,8 @@ object GameConstants {
var WEBSITE_LINK = "https://2006Scape.org"
@JvmField
var WORLD = 1
@JvmField
var GUI_ENABLED: Boolean = false
@JvmField
var MAX_PLAYERS = 200
@JvmField
@@ -13,6 +13,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import com.rs2.gui.ControlPanel;
import org.apollo.jagcached.FileServer;
import com.rs2.game.bots.BotHandler;
@@ -117,7 +118,7 @@ public class GameEngine {
public static ItemHandler itemHandler = new ItemHandler();
public static PlayerHandler playerHandler = new PlayerHandler();
public static NpcHandler npcHandler = new NpcHandler();
private static ShopHandler shopHandler = new ShopHandler();
public static ShopHandler shopHandler = new ShopHandler();
public static ObjectHandler objectHandler = new ObjectHandler();
public static ObjectManager objectManager = new ObjectManager();
public static FightCaves fightCaves = new FightCaves();
@@ -125,6 +126,7 @@ public class GameEngine {
public static Trawler trawler = new Trawler();
private final static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private final static Lock lock = new ReentrantLock();
public static ControlPanel panel = new ControlPanel();
static {
shutdownServer = false;
@@ -133,6 +135,8 @@ public class GameEngine {
public static void main(java.lang.String[] args)
throws NullPointerException, IOException {
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-gui"))
GameConstants.GUI_ENABLED = true;
if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) {
switch (args[i]) {
case "-c":
@@ -215,6 +219,14 @@ public class GameEngine {
*/
System.out.println("World Server listening on " + fs.service.toString());
/**
* Makes Visible Control Panel If Enabled
*/
if(GameConstants.GUI_ENABLED) {
panel.setVisible(true);
System.out.println("Control Panel Enabled.");
}
/**
* Main Server Tick
*
@@ -559,6 +559,7 @@ public abstract class Player {
if (session == null) {
return;
}
GameEngine.panel.removeEntity(playerName);
if (getCannon().hasCannon()) {
getCannon().removeObject(cannonX, cannonY);
for(int i = 0; i < GameEngine.cannonsX.length; i++) {
@@ -0,0 +1,997 @@
package com.rs2.gui;
import com.rs2.GameConstants;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ControlPanel extends JFrame {
private static final long serialVersionUID = 1L;
public final String[] MESSAGE_COLOR = {"Red", "Blue", "Green", "Yellow", "Magenta", "Orange", "Dark Red", "Dark Blue", "None"};
public final String[] PANEL_TELEPORTS = {"Cutsom Location", "Edgevill", "Lumbridge", "Al-kharid", "Varrock", "Falador", "Camelot", "Ardounge", "Watchtower", "Trollheim", "Ape Atoll", "Canifas", "Port Sarim", "Rimmington", "Draynor", "IceQueen Lair", "Brimhaven Dungeon", "Gnome Agility", "Wilderness Agility", "Distant kingdom", "Maze Event", "Drill Instructor", "Grave Digger", "Karamja Lessers", "Evil Bob's Island", "Secret Island", "Ibans Trap", "Fishing Docks", "Mage Trainging", "Quest Place", "Duel Arena", "Bandit Camp", "Uzer"};
// Variables declaration - do not modify
public JButton ADD_ITEM;
public JButton ADD_NPC_BUTTON;
public JCheckBox ADMINS_CAN_DROP;
public JCheckBox ADMINS_CAN_TRADE;
public JButton BAN_PLAYER;
public JButton CLEAR_CONSOLE_BUTTON;
public JLabel CLEAR_CONSOLE_LABEL;
public JTabbedPane CONTROL_TABS;
public JLabel DANGEROUS_COMMAND;
public JCheckBoxMenuItem DEBUG_MODE;
public JButton DROP_ITEM;
public JButton EMPTY_BANK;
public JButton EMPTY_INVENTORY;
public JList ENTITY_LIST;
public DefaultListModel LIST_MODEL;
public DefaultListModel LIST_NPCS;
public JMenuItem EXIT_ITEM;
public JMenu FILE_MENU;
public JButton FORCE_CHAT;
public JList FORCE_COMMANDS;
public JTextField FORCE_NPCS_CHAT_TEXT;
public JButton FORCE_NPC_CHAT_CMD;
public JLabel FORCE_NPC_CHAT_LABEL;
public JButton INIT_COMMAND;
public JButton IPBAN_PLAYER;
public JButton IPMUTE_PLAYER;
public JButton KICK_ALL;
public JButton KICK_PLAYER;
public JLabel LABELBUTTON;
public JButton MAKE_NPC;
public JMenuBar MENU_BAR;
public JLabel MESSAGE_ALL;
public JButton MESSAGE_ALL_BUTTON;
public JTextField MESSAGE_ALL_TEXT;
public JComboBox MESSAGE_ALL_BOX;
public JComboBox MESSAGE_ALL_COLOR_BOX;
public JLabel MESSAGE_ALL_NAME_LABEL = null;
public JLabel MESSAGE_ALL_COLOR_LABEL = null;
public JButton MUTE_PLAYER;
public JPanel NPCS_PANEL;
public JButton NPC_ANIMATION_BUTTON;
public JTextField NPC_ANIMATION_TEXT;
public JCheckBox NPC_CHECKBOX;
public JList NPC_OPTION_LIST;
public JPanel PLAYER_CONTROLS;
public JTabbedPane PLAYER_CONTROLS_TAB;
public JPanel PLAYER_EQUIPMENT;
public JCheckBox ADMINS_CAN_SELL_ITEMS;
public JPanel PLAYER_LOCATION;
public JPanel PLAYER_MISC;
public JPanel PLAYER_PANEL;
public JButton REMOVE_ITEM;
public JButton REMOVE_NPC_BUTTON1;
public JButton REMOVE_OBTAINED_ITEMS;
public JButton RESET_NPCS_BUTTON;
public JLabel RESET_NPCS_LABEL;
public JScrollPane SCROLL_PANE;
public JButton SEND_MESSAGE;
public JPopupMenu.Separator SEPARATOR_ITEM;
public JPanel SERVER_CONTROLS;
public JLabel SERVER_NAME_LABEL;
public JTextField SERVER_NAME_TEXT;
public JPanel SERVER_PANEL;
public JTabbedPane SERVER_SETTINGS;
public JPanel SETTINGS_PANEL;
public JButton TELEPORT_BUTTON;
public JList TELEPORT_LIST;
public JButton TELE_ALL;
public JButton FORCE_NPC;
public JButton UNEQUIP_ITEM;
public JButton UPDATE_PLAYERS;
public JButton UPDATE_SERVER_CMD;
public JLabel UPDATE_SERVER_LABEL;
public JTextField UPDATE_SERVER_TEXT;
public JButton UPDATE_SETTINGS;
public JLabel UPDATE_TIME_LABEL;
public ButtonGroup buttonGroup1;
public JScrollPane jScrollPane1;
public JScrollPane jScrollPane2;
public JScrollPane jScrollPane3;
public JScrollPane jScrollPane4;
private PanelSettings settings = null;
public ControlPanel() {
initComponents();
}
public void addEntity(String name) {
this.LIST_MODEL.addElement(name);
}
public void removeEntity(String name) {
this.LIST_MODEL.removeElement(name);
}
public PanelSettings settings() {
return settings;
}
@SuppressWarnings("serial")
public void initComponents() {
settings = new PanelSettings(this);
LIST_MODEL = new DefaultListModel();
LIST_NPCS = new DefaultListModel();
buttonGroup1 = new ButtonGroup();
CONTROL_TABS = new JTabbedPane();
PLAYER_PANEL = new JPanel();
PLAYER_CONTROLS_TAB = new JTabbedPane();
PLAYER_CONTROLS = new JPanel();
MUTE_PLAYER = new JButton();
BAN_PLAYER = new JButton();
KICK_PLAYER = new JButton();
SEND_MESSAGE = new JButton();
IPBAN_PLAYER = new JButton();
IPMUTE_PLAYER = new JButton();
FORCE_NPC = new JButton();
PLAYER_EQUIPMENT = new JPanel();
ADD_ITEM = new JButton();
REMOVE_ITEM = new JButton();
EMPTY_INVENTORY = new JButton();
EMPTY_BANK = new JButton();
DROP_ITEM = new JButton();
UNEQUIP_ITEM = new JButton();
REMOVE_OBTAINED_ITEMS = new JButton();
DANGEROUS_COMMAND = new JLabel();
PLAYER_MISC = new JPanel();
jScrollPane1 = new JScrollPane();
FORCE_COMMANDS = new JList();
INIT_COMMAND = new JButton();
PLAYER_LOCATION = new JPanel();
jScrollPane2 = new JScrollPane();
TELEPORT_LIST = new JList();
TELEPORT_BUTTON = new JButton();
MAKE_NPC = new JButton();
UPDATE_PLAYERS = new JButton();
TELE_ALL = new JButton();
KICK_ALL = new JButton();
FORCE_CHAT = new JButton();
NPCS_PANEL = new JPanel();
FORCE_NPCS_CHAT_TEXT = new JTextField();
FORCE_NPC_CHAT_LABEL = new JLabel();
FORCE_NPC_CHAT_CMD = new JButton();
LABELBUTTON = new JLabel();
NPC_ANIMATION_TEXT = new JTextField();
NPC_ANIMATION_BUTTON = new JButton();
NPC_CHECKBOX = new JCheckBox();
jScrollPane3 = new JScrollPane();
NPC_OPTION_LIST = new JList(LIST_NPCS);
ADD_NPC_BUTTON = new JButton();
REMOVE_NPC_BUTTON1 = new JButton();
SERVER_PANEL = new JPanel();
SERVER_SETTINGS = new JTabbedPane();
SETTINGS_PANEL = new JPanel();
SERVER_NAME_LABEL = new JLabel();
SERVER_NAME_TEXT = new JTextField();
ADMINS_CAN_TRADE = new JCheckBox();
ADMINS_CAN_DROP = new JCheckBox();
ADMINS_CAN_SELL_ITEMS = new JCheckBox();
UPDATE_SETTINGS = new JButton();
SERVER_CONTROLS = new JPanel();
MESSAGE_ALL = new JLabel();
MESSAGE_ALL_TEXT = new JTextField();
MESSAGE_ALL_BUTTON = new JButton();
MESSAGE_ALL_BOX = new JComboBox();
MESSAGE_ALL_BOX.setEditable(true);
MESSAGE_ALL_BOX.setModel(new DefaultComboBoxModel(new String[]{"[Alert]", "[Update]", "[Server]", "[Control Panel]", "[Panel]", "[Console]", "[Prompt]", "[None]"}));
MESSAGE_ALL_BOX.setToolTipText("Choose a name that will show next to the message.");
MESSAGE_ALL_COLOR_BOX = new JComboBox();
MESSAGE_ALL_COLOR_BOX.setModel(new DefaultComboBoxModel(MESSAGE_COLOR));
MESSAGE_ALL_NAME_LABEL = new JLabel();
MESSAGE_ALL_NAME_LABEL.setText("Name:");
MESSAGE_ALL_COLOR_LABEL = new JLabel();
MESSAGE_ALL_COLOR_LABEL.setText("Color:");
UPDATE_SERVER_LABEL = new JLabel();
UPDATE_SERVER_TEXT = new JTextField();
UPDATE_TIME_LABEL = new JLabel();
UPDATE_SERVER_CMD = new JButton();
RESET_NPCS_LABEL = new JLabel();
RESET_NPCS_BUTTON = new JButton();
CLEAR_CONSOLE_LABEL = new JLabel();
CLEAR_CONSOLE_BUTTON = new JButton();
jScrollPane4 = new JScrollPane();
SCROLL_PANE = new JScrollPane();
ENTITY_LIST = new JList(LIST_MODEL);
MENU_BAR = new JMenuBar();
FILE_MENU = new JMenu();
DEBUG_MODE = new JCheckBoxMenuItem();
SEPARATOR_ITEM = new JPopupMenu.Separator();
EXIT_ITEM = new JMenuItem();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setTitle(GameConstants.SERVER_NAME + " ControlPanel");
setBackground(new Color(245, 244, 244));
setResizable(false);
PLAYER_CONTROLS_TAB.setToolTipText("Player Options");
MUTE_PLAYER.setText("Mute Player");
MUTE_PLAYER.setToolTipText("Mute a player so that they cannot speak.");
MUTE_PLAYER.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
BAN_PLAYER.setText("Ban Player");
BAN_PLAYER.setToolTipText("Ban a player.");
BAN_PLAYER.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
KICK_PLAYER.setText("Disconnect");
KICK_PLAYER.setToolTipText("Disconnect a player from the server.");
KICK_PLAYER.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
SEND_MESSAGE.setText("Send Message");
SEND_MESSAGE.setToolTipText("Send the lpayer a lovely message.");
SEND_MESSAGE.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
IPBAN_PLAYER.setText("IP-Ban");
IPBAN_PLAYER.setToolTipText("IP-Ban a player from ever connecting.");
IPBAN_PLAYER.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
IPMUTE_PLAYER.setText("IP-Mute");
IPMUTE_PLAYER.setToolTipText("IP-Mute a player so that any same connection cannot speak.");
IPMUTE_PLAYER.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
FORCE_NPC.setText("Make Npc");
FORCE_NPC.setToolTipText("Turn the player into a npc.");
FORCE_NPC.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
GroupLayout PLAYER_CONTROLSLayout = new GroupLayout(PLAYER_CONTROLS);
PLAYER_CONTROLS.setLayout(PLAYER_CONTROLSLayout);
PLAYER_CONTROLSLayout.setHorizontalGroup(
PLAYER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(PLAYER_CONTROLSLayout.createSequentialGroup()
.addContainerGap()
.addGroup(PLAYER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(SEND_MESSAGE, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
.addGroup(GroupLayout.Alignment.LEADING, PLAYER_CONTROLSLayout.createSequentialGroup()
.addComponent(BAN_PLAYER, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(IPBAN_PLAYER, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE))
.addGroup(GroupLayout.Alignment.LEADING, PLAYER_CONTROLSLayout.createSequentialGroup()
.addComponent(MUTE_PLAYER, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(IPMUTE_PLAYER, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE))
.addGroup(GroupLayout.Alignment.LEADING, PLAYER_CONTROLSLayout.createSequentialGroup()
.addComponent(KICK_PLAYER, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(FORCE_NPC, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE)))
.addContainerGap(11, Short.MAX_VALUE))
);
PLAYER_CONTROLSLayout.setVerticalGroup(
PLAYER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(PLAYER_CONTROLSLayout.createSequentialGroup()
.addContainerGap()
.addGroup(PLAYER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(BAN_PLAYER, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
.addComponent(IPBAN_PLAYER, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PLAYER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(MUTE_PLAYER, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
.addComponent(IPMUTE_PLAYER, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PLAYER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(KICK_PLAYER, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
.addComponent(FORCE_NPC, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
.addComponent(SEND_MESSAGE, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
PLAYER_CONTROLS_TAB.addTab("Main", PLAYER_CONTROLS);
ADD_ITEM.setText("Add Item");
ADD_ITEM.setToolTipText("Add an item to the players Inventory. (etc: 995, 1046, 1050, 4151)");
ADD_ITEM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
REMOVE_ITEM.setText("Remove Item");
REMOVE_ITEM.setToolTipText("Remove an item from the players inventory.");
REMOVE_ITEM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
EMPTY_INVENTORY.setText("Empty Inv.");
EMPTY_INVENTORY.setToolTipText("Delete ALL items in the players Inventory.");
EMPTY_INVENTORY.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
EMPTY_BANK.setText("Empty Bank");
EMPTY_BANK.setToolTipText("Delete ALL items from the players bank.");
EMPTY_BANK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
DROP_ITEM.setText("Drop Item");
DROP_ITEM.setToolTipText("Force the player to drop an item.");
DROP_ITEM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
UNEQUIP_ITEM.setText("Unequip Item");
UNEQUIP_ITEM.setToolTipText("Force the player to remove an item from their equipment slot.");
UNEQUIP_ITEM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
REMOVE_OBTAINED_ITEMS.setText("Remove All Obtained Items");
REMOVE_OBTAINED_ITEMS.setToolTipText("Warning! This will delete ALL of the players items!!!!");
REMOVE_OBTAINED_ITEMS.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
DANGEROUS_COMMAND.setText("Warning! This will delete EVERYTHING!");
GroupLayout PLAYER_EQUIPMENTLayout = new GroupLayout(PLAYER_EQUIPMENT);
PLAYER_EQUIPMENT.setLayout(PLAYER_EQUIPMENTLayout);
PLAYER_EQUIPMENTLayout.setHorizontalGroup(
PLAYER_EQUIPMENTLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(PLAYER_EQUIPMENTLayout.createSequentialGroup()
.addContainerGap()
.addGroup(PLAYER_EQUIPMENTLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(REMOVE_OBTAINED_ITEMS, GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)
.addGroup(PLAYER_EQUIPMENTLayout.createSequentialGroup()
.addComponent(ADD_ITEM, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(REMOVE_ITEM, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE))
.addGroup(PLAYER_EQUIPMENTLayout.createSequentialGroup()
.addComponent(EMPTY_INVENTORY, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(EMPTY_BANK, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE))
.addGroup(PLAYER_EQUIPMENTLayout.createSequentialGroup()
.addComponent(DROP_ITEM, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(UNEQUIP_ITEM, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE))
.addComponent(DANGEROUS_COMMAND))
.addContainerGap())
);
PLAYER_EQUIPMENTLayout.setVerticalGroup(
PLAYER_EQUIPMENTLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(PLAYER_EQUIPMENTLayout.createSequentialGroup()
.addContainerGap()
.addGroup(PLAYER_EQUIPMENTLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(ADD_ITEM, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
.addComponent(REMOVE_ITEM, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PLAYER_EQUIPMENTLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(EMPTY_INVENTORY, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
.addComponent(EMPTY_BANK, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(PLAYER_EQUIPMENTLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(DROP_ITEM, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
.addComponent(UNEQUIP_ITEM, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(DANGEROUS_COMMAND)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(REMOVE_OBTAINED_ITEMS, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
PLAYER_CONTROLS_TAB.addTab("Equipment", PLAYER_EQUIPMENT);
FORCE_COMMANDS.setBackground(new Color(254, 254, 254));
FORCE_COMMANDS.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
FORCE_COMMANDS.setFont(new Font("Tahoma", 0, 12));
FORCE_COMMANDS.setForeground(new Color(153, 0, 51));
FORCE_COMMANDS.setModel(new AbstractListModel() {
String[] strings = {"Force Animation", "Display GFX", "Lock EXP", "Force Bank", "Force Shop", "Force Death", "Force Command", "Force Chat", "Give Master", "Add SkillXP", "Remove SkillXP", "Reset Skill", "Reset All Skills"};
public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
});
FORCE_COMMANDS.setToolTipText("Another list of commands you can force the player to perfoem.");
jScrollPane1.setViewportView(FORCE_COMMANDS);
INIT_COMMAND.setText("Initiate CMD");
INIT_COMMAND.setToolTipText("Initiates the selected comand.");
INIT_COMMAND.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
GroupLayout PLAYER_MISCLayout = new GroupLayout(PLAYER_MISC);
PLAYER_MISC.setLayout(PLAYER_MISCLayout);
PLAYER_MISCLayout.setHorizontalGroup(
PLAYER_MISCLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, PLAYER_MISCLayout.createSequentialGroup()
.addContainerGap()
.addGroup(PLAYER_MISCLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(INIT_COMMAND, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)
.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE))
.addContainerGap())
);
PLAYER_MISCLayout.setVerticalGroup(
PLAYER_MISCLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(PLAYER_MISCLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 135, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(INIT_COMMAND, GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
.addContainerGap())
);
PLAYER_CONTROLS_TAB.addTab("Misc", PLAYER_MISC);
TELEPORT_LIST.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
TELEPORT_LIST.setForeground(new Color(0, 51, 102));
TELEPORT_LIST.setModel(new AbstractListModel() {
public int getSize() {
return PANEL_TELEPORTS.length;
}
public Object getElementAt(int i) {
return PANEL_TELEPORTS[i];
}
});
jScrollPane2.setViewportView(TELEPORT_LIST);
TELEPORT_BUTTON.setText("Teleport Player");
TELEPORT_BUTTON.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
GroupLayout PLAYER_LOCATIONLayout = new GroupLayout(PLAYER_LOCATION);
PLAYER_LOCATION.setLayout(PLAYER_LOCATIONLayout);
PLAYER_LOCATIONLayout.setHorizontalGroup(
PLAYER_LOCATIONLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(PLAYER_LOCATIONLayout.createSequentialGroup()
.addContainerGap()
.addGroup(PLAYER_LOCATIONLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(TELEPORT_BUTTON, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)
.addComponent(jScrollPane2, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE))
.addContainerGap())
);
PLAYER_LOCATIONLayout.setVerticalGroup(
PLAYER_LOCATIONLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(PLAYER_LOCATIONLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 136, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(TELEPORT_BUTTON, GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)
.addContainerGap())
);
PLAYER_CONTROLS_TAB.addTab("Location", PLAYER_LOCATION);
MAKE_NPC.setText("Players to Npcs");
MAKE_NPC.setToolTipText("Turn all of the players into Npcs.");
MAKE_NPC.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
UPDATE_PLAYERS.setText("Update Players");
UPDATE_PLAYERS.setToolTipText("Update the players to their origional look.");
UPDATE_PLAYERS.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
TELE_ALL.setText("Teleport All");
TELE_ALL.setToolTipText("Teleport all players to a set location.");
TELE_ALL.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
KICK_ALL.setText("Disconnect All");
KICK_ALL.setToolTipText("Disconnect all players from the server.");
KICK_ALL.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
FORCE_CHAT.setText("Force Chat");
FORCE_CHAT.setToolTipText("Force all players to say something.");
FORCE_CHAT.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
GroupLayout PLAYER_PANELLayout = new GroupLayout(PLAYER_PANEL);
PLAYER_PANEL.setLayout(PLAYER_PANELLayout);
PLAYER_PANELLayout.setHorizontalGroup(
PLAYER_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(PLAYER_PANELLayout.createSequentialGroup()
.addContainerGap()
.addComponent(PLAYER_CONTROLS_TAB, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(PLAYER_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(FORCE_CHAT, GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
.addComponent(KICK_ALL, GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
.addComponent(TELE_ALL, GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
.addComponent(UPDATE_PLAYERS, GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
.addComponent(MAKE_NPC, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(24, 24, 24))
);
PLAYER_PANELLayout.setVerticalGroup(
PLAYER_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(PLAYER_PANELLayout.createSequentialGroup()
.addContainerGap()
.addComponent(MAKE_NPC, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(UPDATE_PLAYERS, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(TELE_ALL, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(KICK_ALL, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(FORCE_CHAT, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
.addGap(47, 47, 47))
.addGroup(PLAYER_PANELLayout.createSequentialGroup()
.addComponent(PLAYER_CONTROLS_TAB)
.addGap(22, 22, 22))
);
CONTROL_TABS.addTab("Player", PLAYER_PANEL);
FORCE_NPCS_CHAT_TEXT.setText("I love you!");
FORCE_NPCS_CHAT_TEXT.setToolTipText("Enter a line of text you wish to have all npcs in game to say.");
FORCE_NPC_CHAT_LABEL.setText("Force Chat:");
FORCE_NPC_CHAT_LABEL.setToolTipText("Its just a label...");
FORCE_NPC_CHAT_CMD.setText("Send");
FORCE_NPC_CHAT_CMD.setToolTipText("Send the message.");
FORCE_NPC_CHAT_CMD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
LABELBUTTON.setText("Force Animation:");
NPC_ANIMATION_TEXT.setText("811");
NPC_ANIMATION_TEXT.setToolTipText("Enter the npc ID");
NPC_ANIMATION_BUTTON.setText("Animate");
NPC_ANIMATION_BUTTON.setToolTipText("Animate npc's");
NPC_ANIMATION_BUTTON.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
NPC_CHECKBOX.setText("Use Npc's from list");
NPC_OPTION_LIST.setBorder(BorderFactory.createLineBorder(new Color(102, 0, 102)));
NPC_OPTION_LIST.setForeground(new Color(153, 0, 153));
NPC_OPTION_LIST.setToolTipText("A list of Npc ID's to use for the following settings.");
jScrollPane3.setViewportView(NPC_OPTION_LIST);
ADD_NPC_BUTTON.setText("Add Npc");
ADD_NPC_BUTTON.setToolTipText("Add an Npc ID to the list.");
ADD_NPC_BUTTON.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
REMOVE_NPC_BUTTON1.setText("Remove Npc");
REMOVE_NPC_BUTTON1.setToolTipText("Remove an Npc ID from the list.");
REMOVE_NPC_BUTTON1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
GroupLayout NPCS_PANELLayout = new GroupLayout(NPCS_PANEL);
NPCS_PANEL.setLayout(NPCS_PANELLayout);
NPCS_PANELLayout.setHorizontalGroup(
NPCS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, NPCS_PANELLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane3, GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addGroup(NPCS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(NPC_CHECKBOX)
.addComponent(LABELBUTTON)
.addGroup(NPCS_PANELLayout.createSequentialGroup()
.addGroup(NPCS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(NPCS_PANELLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(FORCE_NPCS_CHAT_TEXT, GroupLayout.PREFERRED_SIZE, 165, GroupLayout.PREFERRED_SIZE))
.addComponent(FORCE_NPC_CHAT_LABEL))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(FORCE_NPC_CHAT_CMD))
.addGroup(NPCS_PANELLayout.createSequentialGroup()
.addGap(15, 15, 15)
.addComponent(NPC_ANIMATION_TEXT, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(NPC_ANIMATION_BUTTON))
.addGroup(NPCS_PANELLayout.createSequentialGroup()
.addComponent(ADD_NPC_BUTTON, GroupLayout.PREFERRED_SIZE, 107, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(REMOVE_NPC_BUTTON1, GroupLayout.PREFERRED_SIZE, 107, GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
NPCS_PANELLayout.setVerticalGroup(
NPCS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(NPCS_PANELLayout.createSequentialGroup()
.addContainerGap()
.addGroup(NPCS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(NPCS_PANELLayout.createSequentialGroup()
.addComponent(jScrollPane3, GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
.addContainerGap())
.addGroup(NPCS_PANELLayout.createSequentialGroup()
.addComponent(NPC_CHECKBOX)
.addGap(11, 11, 11)
.addComponent(FORCE_NPC_CHAT_LABEL)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(NPCS_PANELLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(FORCE_NPCS_CHAT_TEXT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(FORCE_NPC_CHAT_CMD))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(LABELBUTTON)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(NPCS_PANELLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(NPC_ANIMATION_TEXT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(NPC_ANIMATION_BUTTON))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 55, Short.MAX_VALUE)
.addGroup(NPCS_PANELLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(ADD_NPC_BUTTON, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
.addComponent(REMOVE_NPC_BUTTON1, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE))
.addGap(22, 22, 22))))
);
CONTROL_TABS.addTab("Npcs", NPCS_PANEL);
SERVER_NAME_LABEL.setText("Server Name:");
SERVER_NAME_TEXT.setText(GameConstants.SERVER_NAME);
SERVER_NAME_TEXT.setToolTipText("Set the name of the server.");
ADMINS_CAN_TRADE.setSelected(GameConstants.ADMIN_CAN_TRADE);
ADMINS_CAN_TRADE.setText("Admins can Trade");
ADMINS_CAN_TRADE.setToolTipText("Determins wether or not an admin can trade other players.");
ADMINS_CAN_DROP.setText("Admins can Drop");
ADMINS_CAN_DROP.setSelected(GameConstants.ADMIN_DROP_ITEMS);
ADMINS_CAN_DROP.setToolTipText("Determins if admins can drop an item.");
ADMINS_CAN_SELL_ITEMS.setText("Admins can sell Items");
ADMINS_CAN_SELL_ITEMS.setSelected(GameConstants.ADMIN_CAN_SELL_ITEMS);
ADMINS_CAN_SELL_ITEMS.setToolTipText("Determins if admins can sell items or not.");
UPDATE_SETTINGS.setText("Update Settings");
UPDATE_SETTINGS.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
GroupLayout SETTINGS_PANELLayout = new GroupLayout(SETTINGS_PANEL);
SETTINGS_PANEL.setLayout(SETTINGS_PANELLayout);
SETTINGS_PANELLayout.setHorizontalGroup(
SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(SETTINGS_PANELLayout.createSequentialGroup()
.addContainerGap()
.addGroup(SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(ADMINS_CAN_SELL_ITEMS)
.addGroup(SETTINGS_PANELLayout.createSequentialGroup()
.addGroup(SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(SERVER_NAME_LABEL)
.addGroup(SETTINGS_PANELLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(SERVER_NAME_TEXT, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE))
.addComponent(ADMINS_CAN_TRADE)
.addComponent(ADMINS_CAN_DROP))
.addGap(69, 69, 69)
.addGroup(SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(SETTINGS_PANELLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
.addComponent(UPDATE_SETTINGS, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE))))))
.addContainerGap())
);
SETTINGS_PANELLayout.setVerticalGroup(
SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(SETTINGS_PANELLayout.createSequentialGroup()
.addContainerGap()
.addGroup(SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(SERVER_NAME_LABEL))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(SERVER_NAME_TEXT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(ADMINS_CAN_TRADE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(ADMINS_CAN_DROP))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ADMINS_CAN_SELL_ITEMS)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(SETTINGS_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(UPDATE_SETTINGS, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
.addContainerGap(30, Short.MAX_VALUE))
);
SERVER_SETTINGS.addTab("Settings", SETTINGS_PANEL);
MESSAGE_ALL.setText("Message All Players:");
MESSAGE_ALL_TEXT.setToolTipText("Set and send a message to everyone.");
UPDATE_SERVER_LABEL.setText("Update Server:");
UPDATE_SERVER_TEXT.setText("60");
UPDATE_SERVER_TEXT.setToolTipText("Set the update timer in seconds.");
UPDATE_TIME_LABEL.setText("Seconds:");
UPDATE_SERVER_CMD.setText("Update");
UPDATE_SERVER_CMD.setToolTipText("Initiate the update sequence.");
UPDATE_SERVER_CMD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
RESET_NPCS_LABEL.setText("Reset Npcs:");
RESET_NPCS_BUTTON.setText("Reset");
RESET_NPCS_BUTTON.setToolTipText("Reset all npcs by death.");
RESET_NPCS_BUTTON.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
CLEAR_CONSOLE_LABEL.setText("Clear Console:");
CLEAR_CONSOLE_BUTTON.setText("Clear Text");
CLEAR_CONSOLE_BUTTON.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
MESSAGE_ALL_BUTTON.setText("Message");
MESSAGE_ALL_BUTTON.setToolTipText("Send a message to everyone on the server");
MESSAGE_ALL_BUTTON.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ActionPerformed(evt);
}
});
MESSAGE_ALL_BOX.setEditable(true);
MESSAGE_ALL_BOX.setModel(new DefaultComboBoxModel(new String[]{"[Alert]", "[Update]", "[Server]", "[Control Panel]", "[Panel]", "[Console]", "[Prompt]", "[None]"}));
MESSAGE_ALL_BOX.setToolTipText("Choose a name that will show next to the message.");
GroupLayout SERVER_CONTROLSLayout = new GroupLayout(SERVER_CONTROLS);
SERVER_CONTROLS.setLayout(SERVER_CONTROLSLayout);
SERVER_CONTROLSLayout.setHorizontalGroup(
SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addContainerGap()
.addComponent(MESSAGE_ALL)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 137, Short.MAX_VALUE)
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(UPDATE_SERVER_LABEL)
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(UPDATE_SERVER_CMD))
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addComponent(UPDATE_TIME_LABEL, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(UPDATE_SERVER_TEXT, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE)))))
.addGap(41, 41, 41))
.addGroup(GroupLayout.Alignment.TRAILING, SERVER_CONTROLSLayout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(MESSAGE_ALL_TEXT, GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(MESSAGE_ALL_BUTTON)
.addGap(21, 21, 21))
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(MESSAGE_ALL_COLOR_LABEL)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(MESSAGE_ALL_COLOR_BOX, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE)
.addContainerGap(275, Short.MAX_VALUE))
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addGap(15, 15, 15)
.addComponent(MESSAGE_ALL_NAME_LABEL)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(MESSAGE_ALL_BOX, GroupLayout.PREFERRED_SIZE, 125, GroupLayout.PREFERRED_SIZE)
.addContainerGap(226, Short.MAX_VALUE))
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addContainerGap()
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(CLEAR_CONSOLE_BUTTON, GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE))
.addComponent(CLEAR_CONSOLE_LABEL))
.addGap(18, 18, 18)
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(RESET_NPCS_LABEL)
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(RESET_NPCS_BUTTON)))
.addGap(203, 203, 203))
);
SERVER_CONTROLSLayout.setVerticalGroup(
SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addContainerGap()
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addComponent(MESSAGE_ALL)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(MESSAGE_ALL_BOX, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(MESSAGE_ALL_NAME_LABEL))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(MESSAGE_ALL_COLOR_BOX, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(MESSAGE_ALL_COLOR_LABEL)))
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addComponent(UPDATE_SERVER_LABEL)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(UPDATE_TIME_LABEL)
.addComponent(UPDATE_SERVER_TEXT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(UPDATE_SERVER_CMD)))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addComponent(MESSAGE_ALL_BUTTON)
.addComponent(MESSAGE_ALL_TEXT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(SERVER_CONTROLSLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addComponent(CLEAR_CONSOLE_LABEL)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(CLEAR_CONSOLE_BUTTON))
.addGroup(SERVER_CONTROLSLayout.createSequentialGroup()
.addComponent(RESET_NPCS_LABEL)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(RESET_NPCS_BUTTON)))
.addGap(60, 60, 60))
);
SERVER_SETTINGS.addTab("Administration", SERVER_CONTROLS);
GroupLayout SERVER_PANELLayout = new GroupLayout(SERVER_PANEL);
SERVER_PANEL.setLayout(SERVER_PANELLayout);
SERVER_PANELLayout.setHorizontalGroup(
SERVER_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(SERVER_PANELLayout.createSequentialGroup()
.addComponent(SERVER_SETTINGS, GroupLayout.PREFERRED_SIZE, 412, GroupLayout.PREFERRED_SIZE)
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
SERVER_PANELLayout.setVerticalGroup(
SERVER_PANELLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(SERVER_SETTINGS, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE)
);
CONTROL_TABS.addTab("Server", SERVER_PANEL);
jScrollPane4.setForeground(new Color(0, 153, 0));
ENTITY_LIST.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
ENTITY_LIST.setForeground(new Color(51, 102, 0));
ENTITY_LIST.setToolTipText("A list of Online players.");
SCROLL_PANE.setViewportView(ENTITY_LIST);
MENU_BAR.setToolTipText("Tooltips :D");
FILE_MENU.setText("File");
DEBUG_MODE.setText("Debug Mode");
DEBUG_MODE.setCursor(new Cursor(Cursor.HAND_CURSOR));
FILE_MENU.add(DEBUG_MODE);
FILE_MENU.add(SEPARATOR_ITEM);
EXIT_ITEM.setText("Exit");
FILE_MENU.add(EXIT_ITEM);
MENU_BAR.add(FILE_MENU);
setJMenuBar(MENU_BAR);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(SCROLL_PANE, GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(CONTROL_TABS, GroupLayout.PREFERRED_SIZE, 414, GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10))
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(CONTROL_TABS, GroupLayout.PREFERRED_SIZE, 280, GroupLayout.PREFERRED_SIZE)
.addComponent(SCROLL_PANE, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
.addContainerGap())
);
pack();
setVisible(GameConstants.GUI_ENABLED);
}
// Holds the button commands
public void ActionPerformed(ActionEvent evt) {
String cmd = evt.getActionCommand();
if (cmd == null) {
System.out.println("[Console]: Null Command.");
return;
}
settings().executeCommand(cmd);
}
public void displayMessage(String msg, String title, int type) {
JOptionPane.showMessageDialog(this, msg, title, type);
}
// End of variables declaration
}
@@ -0,0 +1,733 @@
package com.rs2.gui;
import com.rs2.Connection;
import com.rs2.GameConstants;
import com.rs2.GameEngine;
import com.rs2.game.npcs.Npc;
import com.rs2.game.npcs.NpcHandler;
import com.rs2.game.players.Client;
import javax.swing.*;
import java.util.ArrayList;
public class PanelSettings {
public static ArrayList<String> npcList = new ArrayList<String>();
public String[][] MESSAGE_COLORS = {
{"Red", "@red@"},
{"Blue", "@blu@"},
{"Green", "@gre@"},
{"Yellow", "@yel@"},
{"Magenta", "@mag@"},
{"Orange", "@or1@"},
{"Dark Red", "@dre@"},
{"Dark Blue", "@dbl@"}};
private ControlPanel p;
public PanelSettings(ControlPanel p) {
this.p = p;
}
public static String trim(String str) {
if (str == null) {
return null;
}
StringBuffer strBuff = new StringBuffer();
char c;
for (int i = 0; i < str.length(); i++) {
c = str.charAt(i);
if (Character.isDigit(c)) {
strBuff.append(c);
}
}
return strBuff.toString();
}
public String getSelectedPlayer() {
return p.ENTITY_LIST.getSelectedValue().toString();
}
public boolean inList(String id) {
try {
for (int i = 0; i < npcList.size(); i++) {
if (npcList.get(i).equals(id))
return true;
}
} catch (Exception e) {
}
return false;
}
public String getColor(String color) {
for (int i = 0; i < MESSAGE_COLORS.length; i++) {
if (color.equalsIgnoreCase(MESSAGE_COLORS[i][0])) {
return MESSAGE_COLORS[i][1];
}
}
return "@bla@";
}
public Client getClient(String name) {
name = name.toLowerCase();
for (int i = 0; i < GameConstants.MAX_PLAYERS; i++) {
if (validClient(i)) {
Client c = getClient(i);
if (c.playerName.toLowerCase().equalsIgnoreCase(name)) {
return c;
}
}
}
return null;
}
public Client getClient(int id) {
return (Client) GameEngine.playerHandler.players[id];
}
public boolean validClient(int id) {
if (id < 0 || id > GameConstants.MAX_PLAYERS)
return false;
return validClient(getClient(id));
}
public boolean validClient(String name) {
return validClient(getClient(name));
}
public boolean validClient(Client c) {
return (c != null && !c.disconnected);
}
public boolean validNpc(int index) {
if (index < 0 || index > NpcHandler.MAX_NPCS) {
return false;
}
Npc n = getNpc(index);
if (n != null) {
return true;
}
return false;
}
public int getEntity(String name) {
Client c = getClient(name);
if (c != null)
return c.playerId;
return -1;
}
public Npc getNpc(int index) {
return (Npc) GameEngine.npcHandler.npcs[index];
}
public String getInput(String title, String msg) {
return JOptionPane.showInputDialog(p, msg, title, 3);
}
public int getInt(String title, String msg) {
int i = -1;
try {
i = Integer.parseInt(getInput(title, msg));
} catch (Exception e) {
i = -1;
p.displayMessage("There was an error parsing the Integer.", "Error", 0);
}
return i;
}
public void executeCommand(String cmd) {
if (cmd.equalsIgnoreCase("Message")) {
// Getting the Message name
String SelectedName = p.MESSAGE_ALL_BOX.getSelectedItem() + ": ";
if (SelectedName.equalsIgnoreCase("[None]: ")) {
SelectedName = "";
}
// Getting the color
String color = p.MESSAGE_ALL_COLOR_BOX.getSelectedItem().toString();
SelectedName = SelectedName + getColor(color);
// Sending the message
for (int i = 0; i < GameConstants.MAX_PLAYERS; i++) {
if (validClient(i)) {
Client c = getClient(i);
c.getPacketSender().sendMessage(SelectedName + p.MESSAGE_ALL_TEXT.getText());
}
}
p.MESSAGE_ALL_TEXT.setText("");
return;
}
if (cmd.equalsIgnoreCase("Players to Npcs")) {
for (int i = 0; i < GameConstants.MAX_PLAYERS; i++) {
if (validClient(i)) {
Client c = getClient(i);
try {
int newNPC = getInt(cmd, "Enter an Npc ID:");
if (newNPC <= 3871 && newNPC >= 0) {
c.npcId2 = newNPC;
c.isNpc = true;
c.updateRequired = true;
c.appearanceUpdateRequired = true;
p.displayMessage("You turn all players into a npc!", cmd, 1);
} else {
p.displayMessage(newNPC + " is not a valid Npc type!", "Error", 0);
}
} catch (Exception e) {
p.displayMessage("There was an error parsing the ID.", "Error", 0);
}
}
}
return;
}
if (cmd.equalsIgnoreCase("Update Players")) {
for (int i = 0; i < GameConstants.MAX_PLAYERS; i++) {
if (validClient(i)) {
Client c = getClient(i);
c.isNpc = false;
c.updateRequired = true;
c.appearanceUpdateRequired = true;
}
}
return;
}
if (cmd.equalsIgnoreCase("Teleport All")) {
String area = (String) JOptionPane.showInputDialog(null, "Select a location:", cmd, -1, null, p.PANEL_TELEPORTS, p.PANEL_TELEPORTS);
int x, y, z;
if (area.equals("Cutsom Location")) {
x = getInt(cmd, "Enter the X Coord:");
y = getInt(cmd, "Enter the Y Coord:");
z = getInt(cmd, "Enter the Z Coord:");
} else {
Location tele = new Location(0, 0, 0);
tele = tele.getLocationByName(area);
if (tele == null) {
p.displayMessage("This location has yet to be set.", cmd, 3);
return;
}
x = tele.getX();
y = tele.getY();
z = tele.getZ();
}
for (int i = 0; i < GameConstants.MAX_PLAYERS; i++) {
if (validClient(i)) {
Client c = getClient(i);
c.getPlayerAssistant().spellTeleport(x, y, z);
}
}
p.displayMessage("You successfully teleport all players to " + (area.equals("Cutsom Location") ? "x" + x + " y" + y + " z" + z : area) + "!", cmd, 1);
return;
}
if (cmd.equals("Force Chat")) {
String msg = getInput(cmd, "Enter a message for the players to say:");
if (msg == null) {
p.displayMessage("You must enter a message!", cmd, 3);
return;
}
for (int i = 0; i < GameConstants.MAX_PLAYERS; i++) {
if (validClient(i)) {
Client c = getClient(i);
c.forcedChat(msg);
}
}
}
if (cmd.equalsIgnoreCase("Disconnect All")) {
for (int i = 0; i < GameConstants.MAX_PLAYERS; i++) {
if (validClient(i)) {
Client c = getClient(i);
c.disconnected = true;
}
}
return;
}
if (cmd.equalsIgnoreCase("Send")) {
if (p.NPC_CHECKBOX.isSelected()) {
for (int i = 0; i < NpcHandler.MAX_NPCS; i++) {
if (validNpc(i)) {
Npc n = getNpc(i);
if (inList("" + n.npcType))
n.forceChat(p.FORCE_NPCS_CHAT_TEXT.getText());
}
}
} else {
for (int i = 0; i < NpcHandler.MAX_NPCS; i++) {
if (validNpc(i)) {
getNpc(i).forceChat(p.FORCE_NPCS_CHAT_TEXT.getText());
}
}
}
p.FORCE_NPCS_CHAT_TEXT.setText("");
return;
}
if (cmd.equalsIgnoreCase("Animate")) {
if (p.NPC_CHECKBOX.isSelected()) {
for (int i = 0; i < NpcHandler.MAX_NPCS; i++) {
if (validNpc(i)) {
Npc n = getNpc(i);
if (inList("" + n.npcType)) {
n.animNumber = Integer.parseInt(p.NPC_ANIMATION_TEXT.getText());
n.updateRequired = true;
}
}
}
} else {
for (int i = 0; i < NpcHandler.MAX_NPCS; i++) {
if (validNpc(i)) {
Npc n = getNpc(i);
n.animNumber = Integer.parseInt(p.NPC_ANIMATION_TEXT.getText());
n.updateRequired = true;
}
}
}
p.NPC_ANIMATION_TEXT.setText("");
return;
}
if (cmd.equalsIgnoreCase("Add Npc")) {
String id = getInput(cmd, "Enter an Npc ID");
if (!inList(id)) {
npcList.add(trim(id));
p.LIST_NPCS.addElement(trim(id));
}
return;
}
if (cmd.equalsIgnoreCase("Remove Npc")) {
if (p.NPC_OPTION_LIST.getSelectedValue() != null) {
p.LIST_NPCS.removeElement(p.NPC_OPTION_LIST.getSelectedValue().toString());
npcList.remove(p.NPC_OPTION_LIST.getSelectedValue().toString());
}
return;
}
if (cmd.equalsIgnoreCase("Update")) {
GameEngine.playerHandler.updateSeconds = (Integer.parseInt(p.UPDATE_SERVER_TEXT.getText()));
GameEngine.playerHandler.updateAnnounced = false;
GameEngine.playerHandler.updateRunning = true;
GameEngine.playerHandler.updateStartTime = System.currentTimeMillis();
return;
}
if (cmd.equalsIgnoreCase("Reset")) {
int[] SKIP_NPCS = {2627, 2630, 2743, 2745, 2746, 2738, 3500, 3491, 3493, 3494, 3495, 3496};
for (int i = 0; i < NpcHandler.MAX_NPCS; i++) {
boolean skip = false;
Npc n = GameEngine.npcHandler.npcs[i];
if (n != null) {
for (int k : SKIP_NPCS) {
if (n.npcType == k) {
skip = true;
}
}
if (!skip) {
n.isDead = true;
}
}
} // Getting the Message name
String SelectedName = p.MESSAGE_ALL_BOX.getSelectedItem() + ": ";
if (SelectedName.equalsIgnoreCase("[None]: "))
SelectedName = "";
String color = p.MESSAGE_ALL_COLOR_BOX.getSelectedItem().toString();
SelectedName = SelectedName + getColor(color);
for (int i = 0; i < GameConstants.MAX_PLAYERS; i++) {
if (validClient(i)) {
getClient(i).getPacketSender().sendMessage(SelectedName + "Npcs have been reset.");
}
}
return;
}
if (cmd.equalsIgnoreCase("Update Settings")) {
GameConstants.SERVER_NAME = p.SERVER_NAME_TEXT.getText();
GameConstants.ADMIN_CAN_TRADE = p.ADMINS_CAN_TRADE.isSelected();
GameConstants.ADMIN_DROP_ITEMS = p.ADMINS_CAN_DROP.isSelected();
GameConstants.ADMIN_CAN_SELL_ITEMS = p.ADMINS_CAN_SELL_ITEMS.isSelected();
p.setTitle(GameConstants.SERVER_NAME + " ControlPanel");
return;
}
/*
* All commands based on the selected player!
* If the player is not selected it will not work.
*/
if (p.ENTITY_LIST.getSelectedValue() != null) {
int entity = getEntity(getSelectedPlayer());
if (!validClient(entity)) {
p.displayMessage("This player is not valid..", "Error", 0);
return;
}
Client c = getClient(entity);
if (cmd.equalsIgnoreCase("Ban Player")) {
Connection.addNameToBanList(c.playerName);
Connection.addNameToFile(c.playerName);
c.disconnected = true;
return;
}
if (cmd.equalsIgnoreCase("IP-Ban")) {
Connection.addIpToBanList(c.connectedFrom);
Connection.addIpToFile(c.connectedFrom);
c.disconnected = true;
return;
}
if (cmd.equalsIgnoreCase("Mute Player")) {
c.getPacketSender().sendMessage("You have been muted.");
Connection.addNameToMuteList(c.playerName);
return;
}
if (cmd.equalsIgnoreCase("IP-Mute")) {
Connection.addIpToMuteList(c.connectedFrom);
c.getPacketSender().sendMessage("You have been muted.");
return;
}
if (cmd.equalsIgnoreCase("Disconnect")) {
c.disconnected = true;
return;
}
if (cmd.equalsIgnoreCase("Make Npc")) {
try {
int newNPC = getInt(cmd, "Enter an Npc ID:");
if (newNPC <= 3871 && newNPC >= 0) {
c.npcId2 = newNPC;
c.isNpc = true;
c.updateRequired = true;
c.appearanceUpdateRequired = true;
p.displayMessage("You turn " + c.playerName + " into a Npc!", cmd, 1);
} else {
p.displayMessage(newNPC + " is not a valid Npc type!", "Error", 0);
}
} catch (Exception e) {
p.displayMessage("There was an error parsing the ID.", "Error", 0);
}
return;
}
if (cmd.equalsIgnoreCase("Send Message")) {
String message = getInput(cmd, "Enter a message you wish to send.");
c.getPacketSender().sendMessage(message);
return;
}
if (cmd.equalsIgnoreCase("Add Item")) {
int item = getInt(cmd, "Enter an item ID");
int amount = getInt(cmd, "Enter the amount");
if (item <= 160000 && item > 0) {
c.getItemAssistant().addItem(item, amount);
p.displayMessage("You give " + c.playerName + " " + amount + " " + c.getItemAssistant().getItemName(item) + "s!", cmd, 1);
}
return;
}
if (cmd.equalsIgnoreCase("Remove Item")) {
int item = getInt(cmd, "Enter an item ID");
if (item <= 160000 && item > 0) {
if (c.getItemAssistant().playerHasItem(item)) {
c.getItemAssistant().deleteItem(item, c.getItemAssistant().getItemSlot(item), c.getItemAssistant().itemAmount(item + 1));
p.displayMessage("The selecetd item has been deleted!", cmd, 1);
} else {
String invItems = "";
for (int i = 0; i < 28; i++) {
if (c.playerItems[i] != 0) {
invItems = (invItems + i + ". " + c.playerItems[i] + "\n");
}
}
p.displayMessage("This player does not have that item..\n Inventory:\n" + invItems, "Error", 0);
}
}
return;
}
if (cmd.equalsIgnoreCase("Empty Inv.")) {
int confirm = JOptionPane.showConfirmDialog(p, "Do you really want to empty this players inventory?", cmd, 2);
if (confirm == 0) {
c.getItemAssistant().removeAllItems();
c.getPacketSender().sendMessage("Your inventory has been cleared.");
p.displayMessage(c.playerName + "'s inventory has been cleared!", cmd, 1);
}
return;
}
if (cmd.equalsIgnoreCase("Empty Bank")) {
int confirm = JOptionPane.showConfirmDialog(p, "Do you really want to empty this players bank?", cmd, 2);
if (confirm == 0) {
for (int i = 0; i < c.bankItems.length; i++) { // Setting bank items
c.bankItems[i] = 0;
c.bankItemsN[i] = 0;
}
c.getItemAssistant().resetBank();
c.getItemAssistant().resetItems(5064);
c.getPacketSender().sendMessage("Your bank has been cleared.");
p.displayMessage(c.playerName + "'s bank has been cleared!", cmd, 1);
}
return;
}
if (cmd.equalsIgnoreCase("Drop Item")) {
int item = getInt(cmd, "Enter an item ID");
if (item <= 160000 && item > 0) {
if (c.getItemAssistant().playerHasItem(item)) {
int slot = c.getItemAssistant().getItemSlot(item);
GameEngine.itemHandler.createGroundItem(c, item, c.getX(), c.getY(), c.playerItemsN[slot], c.getId());
c.getItemAssistant().deleteItem(item, slot, c.playerItemsN[slot]);
p.displayMessage("The selecetd item has been dropped!", cmd, 1);
} else {
String invItems = "";
for (int i = 0; i < 28; i++) {
if (c.playerItems[i] != 0) {
invItems = (invItems + i + ". " + c.playerItems[i] + "\n");
}
}
p.displayMessage("This player does not have that item..\n\n" + c.playerName + "'s Inventory:\n" + invItems, "Error", 0);
}
}
return;
}
if (cmd.equalsIgnoreCase("Unequip Item")) {
int slot = -1;
String[] equipment = {"Hat", "Cape", "Amulet", "Weapon", "Chest", "Shield", "Legs", "Hands", "Feet", "Ring", "Arrows"};
String id = (String) JOptionPane.showInputDialog(null, "Chose the Equipment you wish to remove:\n", "Magic Bomber", -1, null, equipment, equipment);
for (int j = 0; j < equipment.length; j++) {
if (id.equals(equipment[j]))
slot = j;
}
if (slot < 14 && slot >= 0) {
c.getItemAssistant().removeItem(c.playerEquipment[slot], slot);
} else {
p.displayMessage("You must enter an ID number of 0 - 13", "Error", 0);
}
return;
}
if (cmd.equalsIgnoreCase("Remove All Obtained Items")) {
int con = JOptionPane.showConfirmDialog(p, "Do you really want to delete EVERY item?!", cmd, 2);
if (con == 0) {
int firm = JOptionPane.showConfirmDialog(p, "REALLY!! Are you sure you want to do that?!", cmd, 2);
if (firm == 0) {
c.getItemAssistant().removeAllItems();
for (int i = 0; i < 13; i++) {
c.getItemAssistant().removeItem(c.playerEquipment[i], i);
}
c.getItemAssistant().removeAllItems();
for (int i = 0; i < c.bankItems.length; i++) { // Setting bank items
c.bankItems[i] = 0;
c.bankItemsN[i] = 0;
}
c.getItemAssistant().resetBank();
c.getItemAssistant().resetItems(5064);
c.getPacketSender().sendMessage("I'm sorry to say, but every item you have has been deleted..");
p.displayMessage("The cruel dark deed you requested has been fulfilled.. Jerk..", cmd, 1);
}
}
return;
}
if (cmd.equalsIgnoreCase("Initiate CMD")) {
playerCommand(p.FORCE_COMMANDS.getSelectedValue().toString(), c);
return;
}
if (cmd.equalsIgnoreCase("Teleport Player")) {
if (p.TELEPORT_LIST.getSelectedValue() == null) {
p.displayMessage("No location selected!", "Error", 0);
return;
}
String area = p.TELEPORT_LIST.getSelectedValue().toString();
if (area.equals("Cutsom Location")) {
int x = getInt(cmd, "Enter the X Coord:");
int y = getInt(cmd, "Enter the Y Coord:");
int z = getInt(cmd, "Enter the Z Coord:");
c.getPlayerAssistant().spellTeleport(x, y, z);
p.displayMessage("You successfully teleport " + c.playerName + "!", cmd, 1);
} else {
Location tele = Location.getLocationByName(area);
if (tele != null) {
c.getPlayerAssistant().spellTeleport(tele.getX(), tele.getY(), tele.getZ());
p.displayMessage("You successfully teleport " + c.playerName + " to " + area + "!", cmd, 1);
return;
}
}
}
} else {
p.displayMessage("No player selected!", "Error", 0);
return;
}
p.displayMessage("This command has not yet been added.", "Error", 0);
System.out.println("[Console]: No such command: " + cmd);
}
public void playerCommand(String cmd, Client c) {
String SKILL_NAME[] = {
"Attack", "Defence", "Strength", "Constitution",
"Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching",
"Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore",
"Agility", "Thieving", "Slayer", "Farming", "Runecrafting"
};
if (cmd.equals("Force Animation")) {
int id = getInt(cmd, "Enter the animation id:");
if (id != -1)
c.startAnimation(id);
}
if (cmd.equals("Display GFX")) {
int id = getInt(cmd, "Enter the GFX id:");
if (id != -1)
c.gfx0(id);
}
if (cmd.equals("Lock EXP")) {
p.displayMessage("Command not added! Add it yourself :D", cmd, 1);
}
if (cmd.equals("Force Bank")) {
c.getPacketSender().openUpBank();
}
if (cmd.equals("Force Shop")) {
int shop = -1;
String name = (String) JOptionPane.showInputDialog(null, "Chose the Equipment you wish to remove:\n", "Magic Bomber", -1, null, GameEngine.shopHandler.shopName, GameEngine.shopHandler.shopName);
for (int i = 0; i < GameEngine.shopHandler.shopName.length; i++) {
if (name.equals(GameEngine.shopHandler.shopName[i]))
shop = i;
}
if (shop != -1)
c.getShopAssistant().openShop(shop);
else
p.displayMessage("Could not find shop.", cmd, 1);
}
if (cmd.equals("Force Death")) {
c.getPlayerAssistant().applyDead();
}
if (cmd.equals("Force Command")) {
p.displayMessage("This command is not yet added! ADD IT YOURSELF :D", cmd, 1);
}
if (cmd.equals("Force Chat")) {
c.forcedChat(getInput(cmd, "Enter a message for the player to say."));
}
if (cmd.equals("Give Master")) {
for (int i = 0; i < 21; i++)
c.getPlayerAssistant().addSkillXP((15000000), i);
c.playerXP[3] = c.getPlayerAssistant().getXPForLevel(99) + 5;
c.playerLevel[3] = c.getPlayerAssistant().getLevelForXP(c.playerXP[3]);
}
if (cmd.equals("Add SkillXP")) {
int id = -1;
String name = (String) JOptionPane.showInputDialog(null, "Chose a Skill:", cmd, -1, null, SKILL_NAME, SKILL_NAME);
int amount = getInt(cmd, "Enter te amount of Exp you want to add:");
for (int i = 0; i < SKILL_NAME.length; i++) {
if (name.equals(SKILL_NAME[i]))
id = i;
}
if (id != -1) {
if (amount < 0)
amount = 0;
c.getPlayerAssistant().addSkillXP(amount, id);
p.displayMessage("You have added " + amount + " experience to " + c.playerName + "s " + SKILL_NAME[id] + "!", cmd, 1);
} else
p.displayMessage("Error finding Input.", cmd, 1);
}
if (cmd.equals("Remove SkillXP")) {
int id = -1;
String name = (String) JOptionPane.showInputDialog(null, "Chose a Skill:", cmd, -1, null, SKILL_NAME, SKILL_NAME);
int amount = getInt(cmd, "Enter te amount of Exp you want to take away:");
for (int i = 0; i < SKILL_NAME.length; i++) {
if (name.equals(SKILL_NAME[i]))
id = i;
}
if (id != -1) {
if (c.playerXP[id] < amount)
amount = c.playerXP[id];
c.playerXP[id] -= amount + 1;
p.displayMessage("You have removed " + amount + " experience from " + c.playerName + "s " + SKILL_NAME[id] + "!", cmd, 1);
} else
p.displayMessage("Error finding Input.", cmd, 1);
}
if (cmd.equals("Reset Skill")) {
p.displayMessage("This command is not yet added!", cmd, 1);
}
if (cmd.equals("Reset All Skills")) {
p.displayMessage("This command is not yet added!", cmd, 1);
}
}
public static class Location {
public int x, y, z;
public Location(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public static Location getLocationByName(String name) {
if (name.equals("Edgevill"))
return new Location(3087, 3492, 0);
if (name.equals("Lumbridge"))
return new Location(3222, 3219, 0);
if (name.equals("Al-kharid"))
return new Location(3293, 3188, 0);
if (name.equals("Varrock"))
return new Location(3211, 3423, 0);
if (name.equals("Falador"))
return new Location(2965, 3379, 0);
if (name.equals("Camelot"))
return new Location(2757, 3478, 0);
if (name.equals("Ardounge"))
return new Location(2661, 3305, 0);
if (name.equals("Watchtower"))
return new Location(2569, 3098, 0);
if (name.equals("Trollheim"))
return new Location(2867, 3593, 0);
if (name.equals("Ape Atoll"))
return new Location(2764, 2775, 0);
if (name.equals("Canifas"))
return new Location(3052, 3497, 0);
if (name.equals("Port Sarim"))
return new Location(3025, 3217, 0);
if (name.equals("Rimmington"))
return new Location(2957, 3214, 0);
if (name.equals("Draynor"))
return new Location(3093, 3244, 0);
if (name.equals("IceQueen Lair"))
return new Location(2866, 9953, 0);
if (name.equals("Brimhaven Dungeon"))
return new Location(2713, 9453, 0);
if (name.equals("Gnome Agility"))
return new Location(2477, 3438, 0);
if (name.equals("Wilderness Agility"))
return new Location(2998, 3932, 0);
if (name.equals("Distant kingdom"))
return new Location(2767, 4723, 0);
if (name.equals("Maze Event"))
return new Location(2911, 4551, 0);
if (name.equals("Drill Instructor"))
return new Location(3163, 4828, 0);
if (name.equals("Grave Digger"))
return new Location(1928, 5002, 0);
if (name.equals("Karamja Lessers"))
return new Location(2835, 9563, 0);
if (name.equals("Evil Bob's Island"))
return new Location(2525, 4776, 0);
if (name.equals("Secret Island"))
return new Location(2152, 5095, 0);
if (name.equals("Ibans Trap"))
return new Location(2319, 9804, 0);
if (name.equals("Fishing Docks"))
return new Location(2767, 3277, 0);
if (name.equals("Mage Trainging"))
return new Location(3365, 9640, 0);
if (name.equals("Quest Place"))
return new Location(2907, 9712, 0);
if (name.equals("Duel Arena"))
return new Location(3367, 3267, 0);
if (name.equals("Bandit Camp"))
return new Location(3171, 3028, 0);
if (name.equals("Uzer"))
return new Location(3484, 3092, 0);
return null;
}
public void update(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
}
}
@@ -73,6 +73,7 @@ public class PacketSender {
}
public PacketSender loginPlayer() {
GameEngine.panel.addEntity(player.playerName);
player.getPlayerAssistant().loginScreen();
if (Connection.isNamedBanned(player.playerName)) {
player.logout();