mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-15 19:10:18 -07:00
Big woah
This commit is contained in:
parent
ff14a8bd36
commit
b865befb0b
13 changed files with 1512 additions and 21 deletions
BIN
09HDscape-server/data/libs/json-simple-1.1.1.jar
Normal file
BIN
09HDscape-server/data/libs/json-simple-1.1.1.jar
Normal file
Binary file not shown.
|
|
@ -59,7 +59,8 @@ public final class GatheringSkillPulse extends SkillPulse<GameObject> {
|
|||
|
||||
@Override
|
||||
public void start() {
|
||||
resource = SkillingResource.forId(node.getId());
|
||||
resource = SkillingResource.forId(
|
||||
node.getId());
|
||||
if (SkillingResource.isEmpty(node.getId())) {
|
||||
player.getPacketDispatch().sendMessage("This rock contains no ore.");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -77,8 +77,6 @@ import org.crandor.net.packet.out.SkillLevel;
|
|||
import org.crandor.net.packet.out.UpdateSceneGraph;
|
||||
import org.crandor.plugin.Plugin;
|
||||
import org.crandor.tools.StringUtils;
|
||||
import org.crandor.tools.panel.Controller;
|
||||
import org.crandor.tools.panel.PlayerListPulse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -250,7 +248,6 @@ public class Player extends Entity {
|
|||
*/
|
||||
private final HunterManager hunterManager = new HunterManager(this);
|
||||
|
||||
private final PlayerListPulse playerListPulse = new PlayerListPulse(this);
|
||||
|
||||
/**
|
||||
* The treasure trail manager.
|
||||
|
|
@ -277,7 +274,6 @@ public class Player extends Entity {
|
|||
*/
|
||||
private final IronmanManager ironmanManager = new IronmanManager(this);
|
||||
|
||||
private final Controller controller = new Controller(this);
|
||||
|
||||
/**
|
||||
* The logout plugins.
|
||||
|
|
@ -1261,15 +1257,6 @@ public class Player extends Entity {
|
|||
this.skillTasks = skillTasks;
|
||||
}
|
||||
|
||||
public Controller getController() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
public PlayerListPulse getPlayerListPulse() {
|
||||
return playerListPulse;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Player [name=" + name + ", getRights()=" + getRights() + "]";
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import org.crandor.game.node.object.GameObject;
|
|||
import org.crandor.game.system.task.Pulse;
|
||||
import org.crandor.game.world.GameWorld;
|
||||
import org.crandor.game.world.map.Location;
|
||||
import org.crandor.game.world.map.RegionManager;
|
||||
import org.crandor.game.world.map.path.Pathfinder;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -39,7 +40,7 @@ public class ResourceAIPActions {
|
|||
resource_players.remove(bot);
|
||||
return true;
|
||||
}
|
||||
chopTree(bot, new GameObject(1278, new Location(3212, 3232, 0)));
|
||||
chopTree(bot, RegionManager.getObject(Location.create(3234,3231,0)));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
@ -47,10 +48,10 @@ public class ResourceAIPActions {
|
|||
}
|
||||
|
||||
private static void chopTree(final AIPlayer bot, final GameObject node) {
|
||||
//bot.sendChat("WE CHOPPIN");
|
||||
Pathfinder.find(bot, node);
|
||||
Pulse pulse = new GatheringSkillPulse(bot, node);
|
||||
bot.getPulseManager().run(pulse);
|
||||
pulse.start();
|
||||
bot.sendChat("WE CHOPPIN");
|
||||
// Pathfinder.find(bot, node);
|
||||
// Pulse pulse = new GatheringSkillPulse(bot, node);
|
||||
bot.getPulseManager().run(new GatheringSkillPulse(bot, node));
|
||||
// pulse.start();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import org.crandor.game.node.entity.player.ai.AIPBuilder;
|
|||
import org.crandor.game.node.entity.player.ai.AIPlayer;
|
||||
import org.crandor.game.node.entity.player.ai.pvp.PVPAIPActions;
|
||||
import org.crandor.game.node.entity.player.ai.pvp.PVPAIPBuilderUtils;
|
||||
import org.crandor.game.node.entity.player.ai.resource.ResourceAIPManager;
|
||||
import org.crandor.game.node.entity.player.link.appearance.Gender;
|
||||
import org.crandor.game.node.object.GameObject;
|
||||
import org.crandor.game.system.SystemLogger;
|
||||
|
|
@ -270,6 +271,7 @@ public final class GameWorld {
|
|||
ScriptManager.load();
|
||||
PluginManager.init();
|
||||
GlobalEventManager.get().init();
|
||||
ResourceAIPManager.get().init();
|
||||
SQLManager.postPlugin();
|
||||
parseObjects();
|
||||
CallbackHub.call();
|
||||
|
|
|
|||
168
09HDscape-server/src/org/crandor/gui/ConsoleFrame.java
Normal file
168
09HDscape-server/src/org/crandor/gui/ConsoleFrame.java
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
package org.crandor.gui;
|
||||
|
||||
|
||||
import org.crandor.gui.tab.GrandExchangeTab;
|
||||
import org.crandor.gui.tab.PlayerTab;
|
||||
import org.crandor.gui.tab.StatisticsTab;
|
||||
import org.crandor.gui.tab.UtilityTab;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The console frame tool.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class ConsoleFrame extends JFrame {
|
||||
|
||||
/**
|
||||
* The console frame instance.
|
||||
*/
|
||||
public static final ConsoleFrame INSTANCE = new ConsoleFrame();
|
||||
|
||||
/**
|
||||
* The serail UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 6368064564449356833L;
|
||||
|
||||
/**
|
||||
* The size of the frame.
|
||||
*/
|
||||
private static final Dimension SIZE = new Dimension(1074, 664);
|
||||
|
||||
/**
|
||||
* The tabbed pane.
|
||||
*/
|
||||
private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
|
||||
/**
|
||||
* The statistics tab.
|
||||
*/
|
||||
private final StatisticsTab statisticsTab = StatisticsTab.INSTANCE.init();
|
||||
|
||||
/**
|
||||
* The player tab.
|
||||
*/
|
||||
private final PlayerTab playerTab = new PlayerTab();
|
||||
|
||||
/**
|
||||
* The grand exchange tab.
|
||||
*/
|
||||
private final GrandExchangeTab grandExchangeTab = new GrandExchangeTab();
|
||||
|
||||
/**
|
||||
* The utility tab.
|
||||
*/
|
||||
private final UtilityTab utilityTab = UtilityTab.getInstance();
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code consoleFrame} {@Code Object}
|
||||
*/
|
||||
private ConsoleFrame() {
|
||||
super("Console");
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the console frame.
|
||||
*
|
||||
* @return the frame.
|
||||
*/
|
||||
public ConsoleFrame init() {
|
||||
setLocationRelativeTo(null);
|
||||
setSize(SIZE);
|
||||
getContentPane().setLayout(null);
|
||||
tabbedPane.setBounds(0, 0, 1068, 636);
|
||||
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);
|
||||
getContentPane().add(tabbedPane);
|
||||
addTabs(statisticsTab, utilityTab, playerTab, grandExchangeTab);
|
||||
setResizable(false);
|
||||
setVisible(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void main(String... args) {
|
||||
INSTANCE.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds tabs.
|
||||
*
|
||||
* @param tabs the tabs.
|
||||
*/
|
||||
public void addTabs(ConsoleTab... tabs) {
|
||||
for (ConsoleTab tab : tabs) {
|
||||
addTab(tab);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tab to the tabbed pane.
|
||||
*
|
||||
* @param tab the tab.
|
||||
*/
|
||||
public void addTab(ConsoleTab tab) {
|
||||
tabbedPane.add(tab.getName(), tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the statisticsTab.
|
||||
*
|
||||
* @return the statisticsTab
|
||||
*/
|
||||
public StatisticsTab getStatisticsTab() {
|
||||
return statisticsTab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tabbedPane.
|
||||
*
|
||||
* @return the tabbedPane
|
||||
*/
|
||||
public JTabbedPane getTabbedPane() {
|
||||
return tabbedPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the playerTab.
|
||||
*
|
||||
* @return the playerTab
|
||||
*/
|
||||
public PlayerTab getPlayerTab() {
|
||||
return playerTab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the utilityTab.
|
||||
*
|
||||
* @return the utilityTab
|
||||
*/
|
||||
public UtilityTab getUtilityTab() {
|
||||
return utilityTab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance.
|
||||
*
|
||||
* @return the instance.
|
||||
*/
|
||||
public static ConsoleFrame getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the grandExchangeTab.
|
||||
*
|
||||
* @return the grandExchangeTab
|
||||
*/
|
||||
public GrandExchangeTab getGrandExchangeTab() {
|
||||
return grandExchangeTab;
|
||||
}
|
||||
|
||||
}
|
||||
44
09HDscape-server/src/org/crandor/gui/ConsoleTab.java
Normal file
44
09HDscape-server/src/org/crandor/gui/ConsoleTab.java
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package org.crandor.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The console tab.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class ConsoleTab extends JPanel {
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 2899642836866716523L;
|
||||
|
||||
/**
|
||||
* The name of the console tab.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code consoleTab} {@Code Object}
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
public ConsoleTab(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
setLayout(null);
|
||||
setBounds(new Rectangle(0, 0, 1068, 663));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
270
09HDscape-server/src/org/crandor/gui/component/PlayerViewer.java
Normal file
270
09HDscape-server/src/org/crandor/gui/component/PlayerViewer.java
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
package org.crandor.gui.component;
|
||||
|
||||
|
||||
import org.crandor.game.container.Container;
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.node.entity.player.info.PlayerDetails;
|
||||
import org.crandor.game.node.item.Item;
|
||||
import org.crandor.game.world.GameWorld;
|
||||
import org.crandor.game.world.repository.Repository;
|
||||
import org.crandor.gui.ConsoleFrame;
|
||||
import org.crandor.tools.PlayerLoader;
|
||||
import org.crandor.tools.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Views a players details.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class PlayerViewer extends JPanel {
|
||||
|
||||
/**
|
||||
* The serail UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 1589056461884384398L;
|
||||
|
||||
/**
|
||||
* The name of the viewer.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The player details.
|
||||
*/
|
||||
private PlayerDetails details;
|
||||
|
||||
/**
|
||||
* The player file.
|
||||
*/
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code PlayerViewer} {@Code Object}
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
public PlayerViewer(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.details = PlayerLoader.getPlayerDetailFile(name);
|
||||
if (Repository.getPlayerByName(name) != null) {
|
||||
setPlayer(Repository.getPlayerByName(name));
|
||||
} else {
|
||||
if (GameWorld.getMajorUpdateWorker().isStarted()) {
|
||||
setPlayer(PlayerLoader.getPlayerFile(name));
|
||||
}
|
||||
}
|
||||
setBounds(new Rectangle(0, 0, 755, 539));
|
||||
setLayout(null);
|
||||
JButton btnClose = new JButton("Close");
|
||||
btnClose.addActionListener(e -> ConsoleFrame.getInstance().getPlayerTab().closeViewer(PlayerViewer.this));
|
||||
btnClose.setBounds(6, 6, 117, 29);
|
||||
add(btnClose);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "Info", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(6, 35, 286, 428);
|
||||
add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblName = new JLabel("Username: " + details.getUsername());
|
||||
lblName.setBounds(6, 16, 224, 16);
|
||||
panel.add(lblName);
|
||||
|
||||
JLabel lblIp = new JLabel("IP: " + details.getInfo().getIp());
|
||||
lblIp.setBounds(6, 96, 190, 16);
|
||||
panel.add(lblIp);
|
||||
|
||||
JLabel lblMac = new JLabel("Mac: " + details.getInfo().getMac());
|
||||
lblMac.setBounds(6, 124, 224, 16);
|
||||
panel.add(lblMac);
|
||||
|
||||
JLabel lblCompName = new JLabel("Comp name: " + details.getInfo().getCompName());
|
||||
lblCompName.setBounds(6, 208, 236, 16);
|
||||
panel.add(lblCompName);
|
||||
|
||||
JLabel lblLastLogin = new JLabel("Last login: " + new Date(details.getLastLogin()));
|
||||
lblLastLogin.setBounds(6, 152, 274, 16);
|
||||
panel.add(lblLastLogin);
|
||||
|
||||
JLabel lblStatus = new JLabel("Status: " + getStatus());
|
||||
lblStatus.setBounds(6, 236, 149, 16);
|
||||
panel.add(lblStatus);
|
||||
|
||||
// JLabel lblCredits = new JLabel("Credits: " + details.getShop().getCredits());
|
||||
// lblCredits.setBounds(6, 180, 139, 16);
|
||||
// panel.add(lblCredits);
|
||||
|
||||
JLabel lblRights = new JLabel("Rights: " + StringUtils.formatDisplayName(details.getRights().toString()));
|
||||
lblRights.setBounds(6, 68, 176, 16);
|
||||
panel.add(lblRights);
|
||||
|
||||
// JLabel lblDisplayName = new JLabel("Display name: " + details.getUsername());
|
||||
// lblDisplayName.setBounds(6, 40, 213, 16);
|
||||
// panel.add(lblDisplayName);
|
||||
|
||||
JLabel lblNetworth = new JLabel("Networth:");
|
||||
lblNetworth.setBounds(6, 264, 165, 16);
|
||||
panel.add(lblNetworth);
|
||||
|
||||
JLabel lblBanned = new JLabel("Banned: " + (details.getBanTime() > 0));
|
||||
lblBanned.setBounds(6, 292, 149, 16);
|
||||
panel.add(lblBanned);
|
||||
|
||||
JLabel lblMuted = new JLabel("Muted: " + (details.getMuteTime() > 0));
|
||||
lblMuted.setBounds(6, 317, 149, 16);
|
||||
panel.add(lblMuted);
|
||||
|
||||
JLabel lblActive = new JLabel("Active: " + checkActive());
|
||||
lblActive.setBounds(6, 342, 165, 16);
|
||||
panel.add(lblActive);
|
||||
if (player != null) {
|
||||
lblNetworth.setText("Networth: " + player.getMonitor().getNetworth() + "");
|
||||
}
|
||||
|
||||
JButton btnRefresh = new JButton("Refresh");
|
||||
btnRefresh.setBounds(124, 6, 117, 29);
|
||||
add(btnRefresh);
|
||||
|
||||
JButton btnViewContainer = new JButton("View Container");
|
||||
btnViewContainer.addActionListener(e -> {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
viewContainer();
|
||||
});
|
||||
btnViewContainer.setBounds(365, 6, 144, 29);
|
||||
add(btnViewContainer);
|
||||
|
||||
JButton btnDelete = new JButton("Delete");
|
||||
btnDelete.addActionListener(e -> {
|
||||
int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this account!?");
|
||||
if (result == 0) {
|
||||
ConsoleFrame.getInstance().getUtilityTab().delete(details);
|
||||
ConsoleFrame.getInstance().getPlayerTab().closeViewer(PlayerViewer.this);
|
||||
}
|
||||
});
|
||||
btnDelete.setBounds(244, 6, 117, 29);
|
||||
add(btnDelete);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the view containermanager.
|
||||
*/
|
||||
public void viewContainer() {
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
ActionListener listener = e -> {
|
||||
String name1 = e.getActionCommand();
|
||||
Container container = null;
|
||||
switch (name1) {
|
||||
case "Inventory":
|
||||
container = player.getInventory();
|
||||
break;
|
||||
case "Equipment":
|
||||
container = player.getEquipment();
|
||||
break;
|
||||
case "Bank":
|
||||
container = player.getBank();
|
||||
break;
|
||||
}
|
||||
if (container != null) {
|
||||
showContainer(container, name1);
|
||||
}
|
||||
};
|
||||
JButton invy = new JButton("Inventory");
|
||||
panel.add(invy);
|
||||
invy.addActionListener(listener);
|
||||
JButton equip = new JButton("Equipment");
|
||||
panel.add(equip);
|
||||
equip.addActionListener(listener);
|
||||
JButton bank = new JButton("Bank");
|
||||
bank.addActionListener(listener);
|
||||
panel.add(bank);
|
||||
JOptionPane.showConfirmDialog(null, panel, "View Container", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a container.
|
||||
*
|
||||
* @param container the container.
|
||||
* @param name the name.
|
||||
*/
|
||||
public void showContainer(org.crandor.game.container.Container container, String name) {
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<>();
|
||||
JList<String> list = new JList<>();
|
||||
for (Item i : container.toArray()) {
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
model.addElement(i.toString());
|
||||
}
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player is active.
|
||||
*
|
||||
* @return {@code True} if so.
|
||||
*/
|
||||
public String checkActive() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date cutOff = null;
|
||||
long mili = 0;
|
||||
try {
|
||||
cutOff = sdf.parse("2014-6-10");
|
||||
mili = cutOff.getTime();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ((details.getLastLogin() < mili) ? "Not " : "") + "Active";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks active status.
|
||||
*
|
||||
* @return the status.
|
||||
*/
|
||||
public String getStatus() {
|
||||
return Repository.getPlayerByName(name) != null ? "Online" : "Offline";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the baplayer.
|
||||
*
|
||||
* @param player the player to set.
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
193
09HDscape-server/src/org/crandor/gui/tab/GrandExchangeTab.java
Normal file
193
09HDscape-server/src/org/crandor/gui/tab/GrandExchangeTab.java
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
package org.crandor.gui.tab;
|
||||
|
||||
|
||||
import org.crandor.game.content.eco.ge.GEOfferDispatch;
|
||||
import org.crandor.game.content.eco.ge.GrandExchangeOffer;
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.gui.ConsoleFrame;
|
||||
import org.crandor.gui.ConsoleTab;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* A tab used to view the grand exchange.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class GrandExchangeTab extends ConsoleTab {
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = -1619650762760289798L;
|
||||
|
||||
/**
|
||||
* The search field.
|
||||
*/
|
||||
private JTextField searchField;
|
||||
|
||||
/**
|
||||
* The jlist.
|
||||
*/
|
||||
private final JList<GrandExchangeOffer> list = new JList<GrandExchangeOffer>();
|
||||
|
||||
/**
|
||||
* The model.
|
||||
*/
|
||||
private final DefaultListModel<GrandExchangeOffer> model = new DefaultListModel<GrandExchangeOffer>();
|
||||
|
||||
/**
|
||||
* The id search field.
|
||||
*/
|
||||
private JTextField idSearchField;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code GrandExchangeTab} {@Code Object}
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public GrandExchangeTab() {
|
||||
super("Grand Exchange");
|
||||
list.setCellRenderer(new DefaultListCellRenderer() {
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
GrandExchangeOffer offer = (GrandExchangeOffer) value;
|
||||
if (offer == null) {
|
||||
return label;
|
||||
}
|
||||
Player player = null;
|
||||
for (Player p : ConsoleFrame.getInstance().getUtilityTab().getPlayers()) {
|
||||
if (p == null) {
|
||||
continue;
|
||||
}
|
||||
if (p.getDetails().getUid() == offer.getUid()) {
|
||||
player = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
label.setText((player == null ? "" : player.getName() + " - ") + offer.toString());
|
||||
return label;
|
||||
}
|
||||
|
||||
});
|
||||
list.setModel(model);
|
||||
JLabel lblSearch = new JLabel("Search player:");
|
||||
lblSearch.setBounds(24, 20, 95, 16);
|
||||
add(lblSearch);
|
||||
|
||||
searchField = new JTextField();
|
||||
searchField.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
searchPlayer();
|
||||
}
|
||||
});
|
||||
searchField.setBounds(119, 14, 185, 28);
|
||||
add(searchField);
|
||||
searchField.setColumns(10);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBounds(24, 78, 1015, 518);
|
||||
add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setBounds(6, 6, 375, 517);
|
||||
panel.add(scrollPane);
|
||||
scrollPane.setViewportView(list);
|
||||
|
||||
JButton btnDisplayDatabase = new JButton("Display Database");
|
||||
btnDisplayDatabase.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
displayDatabase();
|
||||
}
|
||||
});
|
||||
btnDisplayDatabase.setBounds(316, 15, 173, 29);
|
||||
add(btnDisplayDatabase);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("Search id:");
|
||||
lblNewLabel.setBounds(24, 48, 61, 16);
|
||||
add(lblNewLabel);
|
||||
|
||||
idSearchField = new JTextField();
|
||||
idSearchField.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
searchId();
|
||||
}
|
||||
});
|
||||
idSearchField.setColumns(10);
|
||||
idSearchField.setBounds(119, 48, 185, 28);
|
||||
add(idSearchField);
|
||||
|
||||
JButton btnNewButton = new JButton("Load");
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ConsoleFrame.getInstance().getUtilityTab().populateList();
|
||||
}
|
||||
});
|
||||
btnNewButton.setBounds(316, 43, 173, 29);
|
||||
add(btnNewButton);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the player.
|
||||
*/
|
||||
private void searchPlayer() {
|
||||
model.clear();
|
||||
Player player = ConsoleFrame.getInstance().getUtilityTab().getPlayer(searchField.getText());
|
||||
if (player == null) {
|
||||
JOptionPane.showMessageDialog(null, "Error! No player found.");
|
||||
return;
|
||||
}
|
||||
for (GrandExchangeOffer o : player.getGrandExchange().getOffers()) {
|
||||
if (o == null) {
|
||||
continue;
|
||||
}
|
||||
addOffer(o);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the id.
|
||||
*/
|
||||
private void searchId() {
|
||||
model.clear();
|
||||
int itemId = 0;
|
||||
try {
|
||||
itemId = Integer.parseInt(idSearchField.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
for (GrandExchangeOffer o : GEOfferDispatch.getOfferMapping().values()) {
|
||||
if (o == null) {
|
||||
continue;
|
||||
}
|
||||
if (o.getItemId() == itemId) {
|
||||
addOffer(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a g.e offer.
|
||||
*/
|
||||
private void addOffer(GrandExchangeOffer offer) {
|
||||
model.addElement(offer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a database.
|
||||
*/
|
||||
private void displayDatabase() {
|
||||
if (ConsoleFrame.getInstance().getUtilityTab().getPlayers().size() == 0) {
|
||||
JOptionPane.showMessageDialog(null, "Error! No data in DB yet. Press load.");
|
||||
return;
|
||||
}
|
||||
for (GrandExchangeOffer offer : GEOfferDispatch.getOfferMapping().values()) {
|
||||
model.addElement(offer);
|
||||
}
|
||||
}
|
||||
}
|
||||
185
09HDscape-server/src/org/crandor/gui/tab/PlayerTab.java
Normal file
185
09HDscape-server/src/org/crandor/gui/tab/PlayerTab.java
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
package org.crandor.gui.tab;
|
||||
|
||||
|
||||
import org.crandor.gui.ConsoleTab;
|
||||
import org.crandor.gui.component.PlayerViewer;
|
||||
import org.crandor.net.Constants;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.SoftBevelBorder;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The player tab.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public class PlayerTab extends ConsoleTab {
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 8865322670299347942L;
|
||||
|
||||
/**
|
||||
* The list of player names to search through.
|
||||
*/
|
||||
private final List<String> playerNames = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* The player name text field.
|
||||
*/
|
||||
private JTextField textField;
|
||||
|
||||
/**
|
||||
* The default model.
|
||||
*/
|
||||
private final DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
|
||||
/**
|
||||
* The tabbed panes.
|
||||
*/
|
||||
private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
|
||||
/**
|
||||
* The mapping of open player viewers.
|
||||
*/
|
||||
private final Map<String, PlayerViewer> viewers = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code PlayerTab} {@Code Object}
|
||||
*/
|
||||
public PlayerTab() {
|
||||
super("Players");
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setBounds(6, 43, 260, 539);
|
||||
add(scrollPane);
|
||||
|
||||
final JList<String> list = new JList<String>();
|
||||
list.addListSelectionListener(e -> {
|
||||
if (list.getSelectedValue() != null) {
|
||||
openViewer(list.getSelectedValue());
|
||||
}
|
||||
});
|
||||
list.setModel(model);
|
||||
scrollPane.setViewportView(list);
|
||||
|
||||
JLabel lblSearchForPlayer = new JLabel("Search for player:");
|
||||
lblSearchForPlayer.setBounds(6, 15, 143, 16);
|
||||
add(lblSearchForPlayer);
|
||||
|
||||
textField = new JTextField();
|
||||
textField.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
model.clear();
|
||||
if (textField.getText() == null || textField.getText().length() < 1) {
|
||||
return;
|
||||
}
|
||||
for (String name : playerNames) {
|
||||
if (name.toLowerCase().startsWith(textField.getText())) {
|
||||
model.addElement(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
textField.setBounds(117, 9, 149, 28);
|
||||
add(textField);
|
||||
textField.setColumns(10);
|
||||
|
||||
tabbedPane.setBounds(278, 43, 755, 539);
|
||||
add(tabbedPane);
|
||||
|
||||
JButton btnRepopulate = new JButton("Repopulate");
|
||||
btnRepopulate.addActionListener(e -> populatePlayerSearch());
|
||||
btnRepopulate.setBounds(278, 10, 117, 29);
|
||||
add(btnRepopulate);
|
||||
populatePlayerSearch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a viewer for a player.
|
||||
*
|
||||
* @param name the name.
|
||||
* @return {@code True} if opened.
|
||||
*/
|
||||
public boolean openViewer(String name) {
|
||||
if (viewers.containsKey(name)) {
|
||||
return false;
|
||||
}
|
||||
PlayerViewer viewer = new PlayerViewer(name);
|
||||
viewers.put(name, viewer);
|
||||
tabbedPane.add(viewer.getName(), viewer);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a viewer.
|
||||
*
|
||||
* @param viewer the viewer.
|
||||
* @return {@code True} if closed.
|
||||
*/
|
||||
public boolean closeViewer(PlayerViewer viewer) {
|
||||
if (!viewers.containsValue(viewer)) {
|
||||
JOptionPane.showMessageDialog(null, "Error! Viewer wasn't open.");
|
||||
return false;
|
||||
}
|
||||
viewers.remove(viewer.getName());
|
||||
tabbedPane.remove(viewer);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the searchable names.
|
||||
*/
|
||||
public void populatePlayerSearch() {
|
||||
playerNames.clear();
|
||||
model.clear();
|
||||
File f = new File("./data/players/");
|
||||
if (f.listFiles() == null) {
|
||||
System.out.println("Player directory was null!");
|
||||
return;
|
||||
}
|
||||
System.out.println(getPlayerNames().toString());
|
||||
for (File file : Objects.requireNonNull(f.listFiles())) {
|
||||
playerNames.add(file.getName().replace(".keldagrim", "").trim());
|
||||
model.addElement(file.getName().replace(".keldagrim", "").trim());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a searchable name to the list.
|
||||
*
|
||||
* @param name the name.
|
||||
*/
|
||||
public void addSearchableName(String name) {
|
||||
playerNames.add(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the playerNames.
|
||||
*
|
||||
* @return the playerNames
|
||||
*/
|
||||
public List<String> getPlayerNames() {
|
||||
return playerNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the viewers.
|
||||
*
|
||||
* @return the viewers
|
||||
*/
|
||||
public Map<String, PlayerViewer> getViewers() {
|
||||
return viewers;
|
||||
}
|
||||
}
|
||||
598
09HDscape-server/src/org/crandor/gui/tab/UtilityTab.java
Normal file
598
09HDscape-server/src/org/crandor/gui/tab/UtilityTab.java
Normal file
|
|
@ -0,0 +1,598 @@
|
|||
package org.crandor.gui.tab;
|
||||
|
||||
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.node.entity.player.info.PlayerDetails;
|
||||
import org.crandor.game.node.entity.player.info.Rights;
|
||||
import org.crandor.game.node.item.Item;
|
||||
import org.crandor.game.system.task.TaskExecutor;
|
||||
import org.crandor.gui.ConsoleFrame;
|
||||
import org.crandor.gui.ConsoleTab;
|
||||
import org.crandor.tools.PlayerLoader;
|
||||
import org.crandor.tools.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Handles the utility programs.
|
||||
*
|
||||
* @author Vexia
|
||||
*/
|
||||
public final class UtilityTab extends ConsoleTab {
|
||||
/**
|
||||
* The {@link Logger} instance.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger(UtilityTab.class.getName());
|
||||
/**
|
||||
* The utility tab.
|
||||
*/
|
||||
private static final UtilityTab INSTANCE = new UtilityTab();
|
||||
|
||||
/**
|
||||
* The serial UID.
|
||||
*/
|
||||
private static final long serialVersionUID = -4962790192758757624L;
|
||||
|
||||
/**
|
||||
* The list of players.
|
||||
*/
|
||||
private final List<Player> players = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* The mapping of ips & their users.
|
||||
*/
|
||||
private final Map<String, List<String>> IPS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The mapping of macs & their users.
|
||||
*/
|
||||
private final Map<String, List<String>> MACS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The mapping of comp names & their users.
|
||||
*/
|
||||
private final Map<String, List<String>> COMPS = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The players loaded list.
|
||||
*/
|
||||
private final JLabel lblPlayersLoaded = new JLabel("Players loaded: ");
|
||||
|
||||
/**
|
||||
* If the map is being populated.
|
||||
*/
|
||||
private boolean populating;
|
||||
|
||||
/**
|
||||
* Constructs a new {@Code UtilityTab} {@Code Object}
|
||||
*/
|
||||
public UtilityTab() {
|
||||
super("Utilities");
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "Resolvers & Trackers", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBackground(UIManager.getColor("Button.background"));
|
||||
panel.setBounds(18, 98, 152, 219);
|
||||
add(panel);
|
||||
panel.setLayout(null);
|
||||
JButton btnResolveIp = new JButton("Resolve Ip");
|
||||
btnResolveIp.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
resolve(IPS);
|
||||
}
|
||||
});
|
||||
btnResolveIp.setBounds(17, 28, 117, 29);
|
||||
panel.add(btnResolveIp);
|
||||
|
||||
JButton btnResolveMac = new JButton("Resolve Mac");
|
||||
btnResolveMac.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
resolve(MACS);
|
||||
}
|
||||
});
|
||||
btnResolveMac.setBounds(17, 69, 117, 29);
|
||||
panel.add(btnResolveMac);
|
||||
|
||||
JButton btnResolveCompName = new JButton("Resolve Comp");
|
||||
btnResolveCompName.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
resolve(COMPS);
|
||||
}
|
||||
});
|
||||
btnResolveCompName.setBounds(17, 110, 117, 29);
|
||||
panel.add(btnResolveCompName);
|
||||
|
||||
JButton btnPopulateMaps = new JButton("Populate Maps");
|
||||
btnPopulateMaps.addActionListener(e -> {
|
||||
populateList();
|
||||
JOptionPane.showMessageDialog(null, "Finished populating maps!");
|
||||
});
|
||||
btnPopulateMaps.setBounds(405, 32, 236, 29);
|
||||
add(btnPopulateMaps);
|
||||
|
||||
JLabel lblMustBeDone = new JLabel("MUST BE DONE BEFORE RUNNING TOOLS");
|
||||
lblMustBeDone.setBounds(390, 6, 379, 16);
|
||||
add(lblMustBeDone);
|
||||
|
||||
lblPlayersLoaded.setBounds(460, 61, 157, 16);
|
||||
add(lblPlayersLoaded);
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setLayout(null);
|
||||
panel_1.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Wealth & Items", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel_1.setBackground(UIManager.getColor("Button.background"));
|
||||
panel_1.setBounds(182, 98, 145, 219);
|
||||
add(panel_1);
|
||||
|
||||
JButton btnWealthScanner = new JButton("Wealth Scanner");
|
||||
btnWealthScanner.addActionListener(e -> wealthScanner());
|
||||
btnWealthScanner.setBounds(6, 29, 129, 29);
|
||||
panel_1.add(btnWealthScanner);
|
||||
|
||||
JButton btnItemScanner = new JButton("Item Scanner");
|
||||
btnItemScanner.addActionListener(e -> itemScanner());
|
||||
btnItemScanner.setBounds(6, 69, 129, 29);
|
||||
panel_1.add(btnItemScanner);
|
||||
|
||||
JPanel panel_2 = new JPanel();
|
||||
panel_2.setLayout(null);
|
||||
panel_2.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Player Utils", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel_2.setBackground(UIManager.getColor("Button.background"));
|
||||
panel_2.setBounds(345, 98, 145, 219);
|
||||
add(panel_2);
|
||||
|
||||
JButton btnStaffChecker = new JButton("Staff Scanner");
|
||||
btnStaffChecker.addActionListener(e -> staffScanner());
|
||||
btnStaffChecker.setBounds(6, 29, 129, 29);
|
||||
panel_2.add(btnStaffChecker);
|
||||
|
||||
JPanel panel_3 = new JPanel();
|
||||
panel_3.setLayout(null);
|
||||
panel_3.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Security", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel_3.setBackground(UIManager.getColor("Button.background"));
|
||||
panel_3.setBounds(502, 98, 145, 219);
|
||||
add(panel_3);
|
||||
|
||||
JButton btnMacViewer = new JButton("Mac Viewer");
|
||||
btnMacViewer.addActionListener(e -> viewMacs());
|
||||
btnMacViewer.setBounds(6, 29, 129, 29);
|
||||
panel_3.add(btnMacViewer);
|
||||
|
||||
JButton btnMacRemover = new JButton("Mac Remover");
|
||||
btnMacRemover.addActionListener(e -> removeMac());
|
||||
btnMacRemover.setBounds(6, 64, 129, 29);
|
||||
panel_3.add(btnMacRemover);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a mac.
|
||||
*/
|
||||
public void removeMac() {
|
||||
String mac = JOptionPane.showInputDialog("Enter address:");
|
||||
if (mac == null || mac.length() <= 1) {
|
||||
JOptionPane.showMessageDialog(null, "Error! Nothing entered.");
|
||||
return;
|
||||
}
|
||||
// if (SystemManager.getSecurity().isBanned(mac)) {
|
||||
// SystemManager.getSecurity().remove(mac);
|
||||
// JOptionPane.showMessageDialog(null, "Removed the mac - " + mac + "!");
|
||||
// } else {
|
||||
// JOptionPane.showMessageDialog(null, "Error! Couldn't find mac in system manager.");
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Views the banned macs.
|
||||
*/
|
||||
public void viewMacs() {
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
JList<String> list = new JList<String>();
|
||||
// for (String i : SystemManager.getSecurity().getBannedAddresses()) {
|
||||
// if (i == null) {
|
||||
// continue;
|
||||
// }
|
||||
// model.addElement(i.toString());
|
||||
// }
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, "Banned Addresses", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wealth scanner.
|
||||
*/
|
||||
public void wealthScanner() {
|
||||
String args = JOptionPane.showInputDialog("Enter item id:");
|
||||
int id = -1;
|
||||
if (args != null && args.length() > 0) {
|
||||
try {
|
||||
id = Integer.parseInt(args);
|
||||
} catch (NumberFormatException e) {
|
||||
id = -1;
|
||||
logger.log(Level.WARNING, "Error in wealth scanner, number exception!");
|
||||
}
|
||||
}
|
||||
List<String> data = wealthScanner(id);
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
JList<String> list = new JList<String>();
|
||||
for (String i : data) {
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
model.addElement(i.toString());
|
||||
}
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, "Wealth Scanner", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wealth scanner.
|
||||
*/
|
||||
public List<String> wealthScanner(int itemId) {
|
||||
Item item = null;
|
||||
if (itemId != -1) {
|
||||
item = new Item(itemId);
|
||||
}
|
||||
Object[][] mostWealthy = new Object[50][2];
|
||||
int player = 0;
|
||||
long count = 0;
|
||||
for (Player p : players) {
|
||||
if (p.getDetails().getRights() == Rights.PLAYER_MODERATOR) {
|
||||
continue;
|
||||
}
|
||||
if (item != null) {
|
||||
long old = count;
|
||||
count += p.getInventory().getAmount(item);
|
||||
count += p.getEquipment().getAmount(item);
|
||||
count += p.getBank().getAmount(item);
|
||||
if (old != count) {
|
||||
player++;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mostWealthy.length; i++) {
|
||||
Long value = (Long) mostWealthy[i][0];
|
||||
if (value == null || value < p.getMonitor().getNetworth()) {
|
||||
for (int j = mostWealthy.length - 1; j > i; j--) {
|
||||
mostWealthy[j] = mostWealthy[j - 1];
|
||||
}
|
||||
mostWealthy[i] = new Object[2];
|
||||
mostWealthy[i][0] = p.getMonitor().getNetworth();
|
||||
mostWealthy[i][1] = p.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> formats = new ArrayList<>();
|
||||
for (int i = mostWealthy.length - 1; i >= 0; i--) {
|
||||
Object[] info = mostWealthy[i];
|
||||
if (info != null && info[0] != null) {
|
||||
formats.add(i + ": " + info[1] + " - " + NumberFormat.getNumberInstance(Locale.US).format((Long) info[0]) + " coins.");
|
||||
}
|
||||
}
|
||||
if (item != null) {
|
||||
formats.add(NumberFormat.getNumberInstance(Locale.US).format(count) + " occurrences of item " + item.getName() + " (id=" + item.getId() + ") by " + player + " players!");
|
||||
}
|
||||
return formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* The item scanner.
|
||||
*/
|
||||
public void itemScanner() {
|
||||
String args = JOptionPane.showInputDialog("Enter item id:");
|
||||
Item item = new Item(11694);
|
||||
if (args != null && args.length() > 0) {
|
||||
try {
|
||||
item = new Item(Integer.parseInt(args));
|
||||
} catch (NumberFormatException e) {
|
||||
item = new Item(11694);
|
||||
logger.log(Level.WARNING, "Error in wealth scanner, number exception!");
|
||||
}
|
||||
}
|
||||
List<String> formats = itemScanner(item);
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
JList<String> list = new JList<String>();
|
||||
for (String i : formats) {
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
model.addElement(i.toString());
|
||||
}
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, "Item Scanner", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans for items in the eco.
|
||||
*/
|
||||
public List<String> itemScanner(Item item) {
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
for (Player p : players) {
|
||||
p.getAnimator();
|
||||
List<org.crandor.game.container.Container> containers = new ArrayList<>();
|
||||
containers.add(p.getInventory());
|
||||
containers.add(p.getBank());
|
||||
containers.add(p.getEquipment());
|
||||
int amount = 0;
|
||||
for (org.crandor.game.container.Container container : containers) {
|
||||
Item i = container.getItem(item);
|
||||
if (i != null) {
|
||||
amount += i.getAmount();
|
||||
}
|
||||
}
|
||||
if (amount > 0) {
|
||||
map.put(p.getName(), amount);
|
||||
}
|
||||
}
|
||||
List<String> formats = new ArrayList<>();
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
formats.add("Player name=" + entry.getKey() + ", contained a total of " + entry.getValue() + " " + item.getName() + ".");
|
||||
}
|
||||
if (formats.size() == 0) {
|
||||
formats.add("There were no occurrences of " + item + ".");
|
||||
}
|
||||
return formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the address.
|
||||
*
|
||||
* @param map the map.
|
||||
*/
|
||||
public void resolve(Map<String, List<String>> map) {
|
||||
String address = JOptionPane.showInputDialog("Enter the address.");
|
||||
List<String> names = resolve(map, address, false);
|
||||
String string = "No names found registered with that address!";
|
||||
if (names == null) {
|
||||
JOptionPane.showMessageDialog(null, string);
|
||||
} else {
|
||||
string = "Names:" + Arrays.toString(names.toArray());
|
||||
JOptionPane.showMessageDialog(null, string);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves & tracks an adddress.
|
||||
*
|
||||
* @param map the map.
|
||||
* @param value the value.
|
||||
* @param name if the name or not.
|
||||
* @return the names resolved.
|
||||
*/
|
||||
public List<String> resolve(Map<String, List<String>> map, String value, boolean name) {
|
||||
List<String> names = null;
|
||||
String address = !name ? value : "";
|
||||
if (name) {
|
||||
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
||||
for (String s : entry.getValue()) {
|
||||
if (s.equals(value)) {
|
||||
address = entry.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
names = map.get(address);
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mapping.
|
||||
*
|
||||
* @param id the id.
|
||||
* @return the map.
|
||||
*/
|
||||
public Map<String, List<String>> getMap(int id) {
|
||||
return id == 1 ? IPS : id == 2 ? MACS : COMPS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the lists.
|
||||
*/
|
||||
public void populateList() {
|
||||
if (populating) {
|
||||
return;
|
||||
}
|
||||
populating = true;
|
||||
players.clear();
|
||||
TaskExecutor.execute(() -> {
|
||||
ConsoleFrame.getInstance().getPlayerTab().getPlayerNames().clear();
|
||||
ConsoleFrame.getInstance().getPlayerTab().populatePlayerSearch();
|
||||
for (String name : ConsoleFrame.getInstance().getPlayerTab().getPlayerNames()) {
|
||||
Player player = PlayerLoader.getPlayerFile(name);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
PlayerDetails details = player.getDetails();
|
||||
if (details != null) {
|
||||
addAddressToMap(name, details.getIpAddress(), IPS);
|
||||
addAddressToMap(name, details.getMacAddress(), MACS);
|
||||
addAddressToMap(name, details.getCompName(), COMPS);
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
populating = false;
|
||||
System.gc();
|
||||
lblPlayersLoaded.setText("Players loaded: " + players.size());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the staff.
|
||||
*/
|
||||
public void staffScanner() {
|
||||
List<String> staff = new ArrayList<>();
|
||||
for (Player player : players) {
|
||||
if (player.getDetails().getRights() != Rights.REGULAR_PLAYER) {
|
||||
staff.add(player.getName() + " - " + StringUtils.formatDisplayName(player.getDetails().getRights().toString()));
|
||||
}
|
||||
}
|
||||
JPanel panel = new JPanel(new GridLayout(0, 1));
|
||||
JScrollPane pane = new JScrollPane();
|
||||
DefaultListModel<String> model = new DefaultListModel<String>();
|
||||
JList<String> list = new JList<String>();
|
||||
for (String i : staff) {
|
||||
if (i == null) {
|
||||
continue;
|
||||
}
|
||||
model.addElement(i.toString());
|
||||
}
|
||||
list.setModel(model);
|
||||
pane.setViewportView(list);
|
||||
panel.add(pane);
|
||||
JOptionPane.showConfirmDialog(null, panel, "Staff Scanner", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an address with its names to the map.
|
||||
*
|
||||
* @param name the name.
|
||||
* @param address the address.
|
||||
* @param map the map.
|
||||
*/
|
||||
public void addAddressToMap(String name, String address, Map<String, List<String>> map) {
|
||||
if (address == null) {
|
||||
return;
|
||||
}
|
||||
List<String> names = map.get(address);
|
||||
if (names == null) {
|
||||
names = new ArrayList<String>();
|
||||
}
|
||||
names.add(name);
|
||||
map.put(address, names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a player.
|
||||
*
|
||||
* @param details the details.
|
||||
*/
|
||||
public void delete(PlayerDetails details) {
|
||||
if (details.getRights() == Rights.PLAYER_MODERATOR) {
|
||||
return;
|
||||
}
|
||||
// TODO
|
||||
// Connection connection = SQLManager.getConnection();
|
||||
// PreparedStatement statement;
|
||||
// try {
|
||||
// statement = connection.prepareStatement("DELETE FROM " + "playerdata" + " WHERE " + "" + "username" + "='" + details.getUsername().toLowerCase() + "'");
|
||||
// statement.execute();
|
||||
// statement = connection.prepareStatement("DELETE FROM " + "highscores" + " WHERE " + "" + "username" + "='" + details.getUsername().toLowerCase() + "'");
|
||||
// statement.execute();
|
||||
// } catch (SQLException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// File detailFile = new File(GameConstants.getPlayerDetailsPath() + "/" + details.getUsername() + ".store");
|
||||
// File playerFile = new File(GameConstants.getPlayerSavePath() + "/" + details.getUsername() + ".store");
|
||||
// detailFile.delete();
|
||||
// playerFile.delete();
|
||||
// SQLManager.close(connection);
|
||||
// ConsoleFrame.getInstance().getPlayerTab().getPlayerNames().remove(details.getUsername());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @param name the name.
|
||||
* @return the player.
|
||||
*/
|
||||
public Player getPlayer(String name) {
|
||||
if (players.size() == 0) {
|
||||
populateList();
|
||||
return null;
|
||||
}
|
||||
for (Player p : players) {
|
||||
if (p.getName().equals(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ips.
|
||||
*
|
||||
* @return the ips.
|
||||
*/
|
||||
public Map<String, List<String>> getIps() {
|
||||
return IPS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macs.
|
||||
*
|
||||
* @return the macs.
|
||||
*/
|
||||
public Map<String, List<String>> getMacs() {
|
||||
return MACS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the comps.
|
||||
*
|
||||
* @return the comps.
|
||||
*/
|
||||
public Map<String, List<String>> getComps() {
|
||||
return COMPS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the players.
|
||||
*
|
||||
* @return the players.
|
||||
*/
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the populating.
|
||||
*
|
||||
* @return the populating
|
||||
*/
|
||||
public boolean isPopulating() {
|
||||
return populating;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bapopulating.
|
||||
*
|
||||
* @param populating the populating to set.
|
||||
*/
|
||||
public void setPopulating(boolean populating) {
|
||||
this.populating = populating;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance.
|
||||
*
|
||||
* @return the instance
|
||||
*/
|
||||
public static UtilityTab getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ public final class InteractionPacket implements IncomingPacket {
|
|||
* @param y The y-coordinate of the object.
|
||||
* @param objectId The object id.
|
||||
*/
|
||||
private static void handleObjectInteraction(final Player player, int optionIndex, int x, int y, int objectId) {
|
||||
public static void handleObjectInteraction(final Player player, int optionIndex, int x, int y, int objectId) {
|
||||
GameObject object = RegionManager.getObject(player.getLocation().getZ(), x, y, objectId);
|
||||
if (objectId == 29735) {//player safety.
|
||||
player.getPulseManager().run(new MovementPulse(player, Location.create(x, y, player .getLocation().getZ())) {
|
||||
|
|
|
|||
42
09HDscape-server/src/org/crandor/tools/PlayerLoader.java
Normal file
42
09HDscape-server/src/org/crandor/tools/PlayerLoader.java
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package org.crandor.tools;
|
||||
|
||||
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.node.entity.player.info.PlayerDetails;
|
||||
import org.crandor.game.node.entity.player.info.login.PlayerParser;
|
||||
import org.crandor.game.world.GameWorld;
|
||||
|
||||
/**
|
||||
* Represents a class that is used to load a player, or details of it.
|
||||
*
|
||||
* @author 'Vexia
|
||||
*/
|
||||
public final class PlayerLoader {
|
||||
|
||||
/**
|
||||
* Method used to load the player file.
|
||||
*
|
||||
* @param name the name.
|
||||
* @return the player.
|
||||
*/
|
||||
public static Player getPlayerFile(String name) {
|
||||
final PlayerDetails playerDetails = new PlayerDetails(name, "");
|
||||
playerDetails.parse();
|
||||
final Player player = new Player(playerDetails);
|
||||
PlayerParser.parse(player);
|
||||
// GameWorld.getWorld().getAccountService().loadPlayer(player);
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to load the player details file.
|
||||
*
|
||||
* @param name the name.
|
||||
* @return the details
|
||||
*/
|
||||
public static PlayerDetails getPlayerDetailFile(String name) {
|
||||
final PlayerDetails playerDetails = new PlayerDetails(name, "");
|
||||
playerDetails.parse();
|
||||
return playerDetails;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue