diff --git a/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_ConfigLoader.java b/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_ConfigLoader.java index 1202e4e..fa5f7ab 100644 --- a/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_ConfigLoader.java +++ b/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_ConfigLoader.java @@ -36,6 +36,7 @@ public class BTC_ConfigLoader private final ServerEntry.ServerEntryList servers = new ServerEntry.ServerEntryList(); private final PlayerCommandEntry.PlayerCommandEntryList playerCommands = new PlayerCommandEntry.PlayerCommandEntryList(); + private final FavoriteButtonEntry.FavoriteButtonEntryList favoriteButtons = new FavoriteButtonEntry.FavoriteButtonEntryList(); public BTC_ConfigLoader() { @@ -102,6 +103,11 @@ public class BTC_ConfigLoader return this.servers.getList(); } + public Collection getFavoriteButtons() + { + return favoriteButtons.getList(); + } + private boolean generateXML(final File file) { try @@ -111,8 +117,9 @@ public class BTC_ConfigLoader final Element rootElement = doc.createElement("configuration"); doc.appendChild(rootElement); - rootElement.appendChild(this.playerCommands.toXML(doc)); rootElement.appendChild(this.servers.toXML(doc)); + rootElement.appendChild(this.playerCommands.toXML(doc)); + rootElement.appendChild(this.favoriteButtons.toXML(doc)); final Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); @@ -139,15 +146,21 @@ public class BTC_ConfigLoader final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file); doc.getDocumentElement().normalize(); + if (!this.servers.fromXML(doc)) + { + System.out.println("Error loading servers."); + hadErrors = true; + } + if (!this.playerCommands.fromXML(doc)) { System.out.println("Error loading playerCommands."); hadErrors = true; } - if (!this.servers.fromXML(doc)) + if (!this.favoriteButtons.fromXML(doc)) { - System.out.println("Error loading servers."); + System.out.println("Error favorite buttons."); hadErrors = true; } } diff --git a/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_FavoriteButtonsPanel.java b/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_FavoriteButtonsPanel.java index 375559f..f0bb8cb 100644 --- a/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_FavoriteButtonsPanel.java +++ b/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_FavoriteButtonsPanel.java @@ -21,13 +21,13 @@ package me.StevenLawson.BukkitTelnetClient; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.List; +import java.util.Collection; import javax.swing.JButton; import javax.swing.JPanel; public class BTC_FavoriteButtonsPanel extends JPanel { - public BTC_FavoriteButtonsPanel(final List buttonList) + public BTC_FavoriteButtonsPanel(final Collection buttonList) { super.setLayout(new GridLayout(0, 2, 1, 1)); @@ -43,7 +43,7 @@ public class BTC_FavoriteButtonsPanel extends JPanel } }; - for (final FavoriteButtonData buttonData : buttonList) + for (final FavoriteButtonEntry buttonData : buttonList) { final JButton button = new JButton(); button.setText(buttonData.getLabel()); diff --git a/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_MainPanel.java b/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_MainPanel.java index 94626ce..1db38b0 100644 --- a/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_MainPanel.java +++ b/src/main/java/me/StevenLawson/BukkitTelnetClient/BTC_MainPanel.java @@ -37,31 +37,10 @@ public class BTC_MainPanel extends javax.swing.JFrame private final BTC_ConnectionManager connectionManager = new BTC_ConnectionManager(); private final List playerList = new ArrayList<>(); private final PlayerListTableModel playerListTableModel = new PlayerListTableModel(playerList); - - private final List favButtonList = new ArrayList<>(); + private final Collection favButtonList = BukkitTelnetClient.config.getFavoriteButtons(); public BTC_MainPanel() { - favButtonList.add(new FavoriteButtonData("Op All", "opall")); - favButtonList.add(new FavoriteButtonData("Deop All", "deopall")); - favButtonList.add(new FavoriteButtonData("Nick Clean", "nickclean")); - favButtonList.add(new FavoriteButtonData("Adminmode ON", "adminmode on")); - favButtonList.add(new FavoriteButtonData("Adminmode OFF", "adminmode off")); - favButtonList.add(new FavoriteButtonData("Cake", "cake")); - favButtonList.add(new FavoriteButtonData("Mob Purge", "mp")); - favButtonList.add(new FavoriteButtonData("Remove Drops", "rd")); - favButtonList.add(new FavoriteButtonData("Purge All", "purgeall")); - favButtonList.add(new FavoriteButtonData("Set Limit = 500", "setl")); - favButtonList.add(new FavoriteButtonData("Stop Server", "stop")); - favButtonList.add(new FavoriteButtonData("Toggle Water Placement", "toggle waterplace")); - favButtonList.add(new FavoriteButtonData("Toggle Fire Placement", "toggle fireplace")); - favButtonList.add(new FavoriteButtonData("Toggle Lava Placement", "toggle lavaplace")); - favButtonList.add(new FavoriteButtonData("Toggle Fluid Spread", "toggle fluidspread")); - favButtonList.add(new FavoriteButtonData("Toggle Lava Damage", "toggle lavadmg")); - favButtonList.add(new FavoriteButtonData("Toggle Fire Spread", "toggle firespread")); - favButtonList.add(new FavoriteButtonData("Toggle Lockdown", "toggle lockdown")); - favButtonList.add(new FavoriteButtonData("Toggle Explosives", "toggle explosives")); - initComponents(); } @@ -521,7 +500,7 @@ public class BTC_MainPanel extends javax.swing.JFrame mainOutput = new javax.swing.JTextPane(); btnDisconnect = new javax.swing.JButton(); btnSend = new javax.swing.JButton(); - txtServer = new javax.swing.JComboBox(); + txtServer = new javax.swing.JComboBox(); chkAutoScroll = new javax.swing.JCheckBox(); txtCommand = new javax.swing.JTextField(); btnConnect = new javax.swing.JButton(); @@ -853,7 +832,7 @@ public class BTC_MainPanel extends javax.swing.JFrame private javax.swing.JTable tblPlayers; private javax.swing.JTextField txtCommand; private javax.swing.JTextField txtNumPlayers; - private javax.swing.JComboBox txtServer; + private javax.swing.JComboBox txtServer; // End of variables declaration//GEN-END:variables public javax.swing.JButton getBtnConnect() diff --git a/src/main/java/me/StevenLawson/BukkitTelnetClient/FavoriteButtonData.java b/src/main/java/me/StevenLawson/BukkitTelnetClient/FavoriteButtonData.java deleted file mode 100644 index 1f72049..0000000 --- a/src/main/java/me/StevenLawson/BukkitTelnetClient/FavoriteButtonData.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2012-2014 Steven Lawson - * - * This file is part of BukkitTelnetClient. - * - * BukkitTelnetClient is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package me.StevenLawson.BukkitTelnetClient; - -public class FavoriteButtonData -{ - private final String label; - private final String command; - - public FavoriteButtonData(String label, String command) - { - this.label = label; - this.command = command; - } - - public String getLabel() - { - return label; - } - - public String getCommand() - { - return command; - } -} diff --git a/src/main/java/me/StevenLawson/BukkitTelnetClient/FavoriteButtonEntry.java b/src/main/java/me/StevenLawson/BukkitTelnetClient/FavoriteButtonEntry.java new file mode 100644 index 0000000..77d676d --- /dev/null +++ b/src/main/java/me/StevenLawson/BukkitTelnetClient/FavoriteButtonEntry.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2012-2014 Steven Lawson + * + * This file is part of BukkitTelnetClient. + * + * BukkitTelnetClient is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package me.StevenLawson.BukkitTelnetClient; + +import java.util.ArrayList; + +public class FavoriteButtonEntry implements ConfigEntry +{ + private String label; + private String command; + + public FavoriteButtonEntry() + { + } + + public FavoriteButtonEntry(final String label, final String command) + { + this.label = label; + this.command = command; + } + + @ConfigEntryList.ParameterGetter(name = "label") + public String getLabel() + { + return label; + } + + @ConfigEntryList.ParameterSetter(name = "label") + public void setLabel(String label) + { + this.label = label; + } + + @ConfigEntryList.ParameterGetter(name = "command") + public String getCommand() + { + return command; + } + + @ConfigEntryList.ParameterSetter(name = "command") + public void setCommand(String command) + { + this.command = command; + } + + public static class FavoriteButtonEntryList extends ConfigEntryList + { + public FavoriteButtonEntryList() + { + super(new ArrayList(), FavoriteButtonEntry.class); + } + + @Override + public String getParentElementName() + { + return "favoriteButtons"; + } + + @Override + public String getItemElementName() + { + return "favoriteButton"; + } + } +} diff --git a/src/main/java/me/StevenLawson/BukkitTelnetClient/PlayerCommandEntry.java b/src/main/java/me/StevenLawson/BukkitTelnetClient/PlayerCommandEntry.java index 1eb115b..5fcda43 100644 --- a/src/main/java/me/StevenLawson/BukkitTelnetClient/PlayerCommandEntry.java +++ b/src/main/java/me/StevenLawson/BukkitTelnetClient/PlayerCommandEntry.java @@ -18,7 +18,7 @@ */ package me.StevenLawson.BukkitTelnetClient; -import java.util.HashSet; +import java.util.ArrayList; public class PlayerCommandEntry implements ConfigEntry { @@ -63,7 +63,7 @@ public class PlayerCommandEntry implements ConfigEntry { public PlayerCommandEntryList() { - super(new HashSet(), PlayerCommandEntry.class); + super(new ArrayList(), PlayerCommandEntry.class); } @Override diff --git a/src/main/resources/settings.xml b/src/main/resources/settings.xml index 3d61696..df3fbad 100644 --- a/src/main/resources/settings.xml +++ b/src/main/resources/settings.xml @@ -1,5 +1,6 @@ + Ban @@ -58,5 +59,82 @@ survival %s - + + + + opall + + + + deopall + + + + nickclean + + + + adminmode on + + + + adminmode off + + + + cake + + + + mp + + + + rd + + + + purgeall + + + + setl + + + + stop + + + + toggle waterplace + + + + toggle fireplace + + + + toggle lavaplace + + + + toggle fluidspread + + + + toggle lavadmg + + + + toggle firespread + + + + toggle lockdown + + + + toggle explosives + +