diff --git a/09HDscape-client/src/org/runite/jagex/Class3_Sub13_Sub3.java b/09HDscape-client/src/org/runite/jagex/Class3_Sub13_Sub3.java index cd7049108..98b783898 100644 --- a/09HDscape-client/src/org/runite/jagex/Class3_Sub13_Sub3.java +++ b/09HDscape-client/src/org/runite/jagex/Class3_Sub13_Sub3.java @@ -1,4 +1,6 @@ package org.runite.jagex; +import org.runite.GameLaunch; + import java.io.IOException; final class Class3_Sub13_Sub3 extends Class3_Sub13 { @@ -42,10 +44,10 @@ final class Class3_Sub13_Sub3 extends Class3_Sub13 { } } if (var4.toString().contains("RuneScape")) { - var4 = RSString.createRSString(var4.toString().replace("RuneScape", "Runite")); + var4 = RSString.createRSString(var4.toString().replace("RuneScape", GameLaunch.SETTINGS.getName())); } if (var4.toString().contains("Jagex")) { - var4 = RSString.createRSString(var4.toString().replace("Jagex", "Runite")); + var4 = RSString.createRSString(var4.toString().replace("Jagex", GameLaunch.SETTINGS.getName())); } return var4; } catch (RuntimeException var6) { diff --git a/09HDscape-client/src/org/runite/jagex/ClientLoader.java b/09HDscape-client/src/org/runite/jagex/ClientLoader.java index 897d47b21..12c69da09 100644 --- a/09HDscape-client/src/org/runite/jagex/ClientLoader.java +++ b/09HDscape-client/src/org/runite/jagex/ClientLoader.java @@ -89,7 +89,7 @@ public class ClientLoader extends Applet { try { ClientLoader.world = "" + GameLaunch.SETTINGS.getWorld(); System.out.println(GameLaunch.SETTINGS.getWorld()); - this.frame = new JFrame("Runite"); + this.frame = new JFrame(GameLaunch.SETTINGS.getName()); this.frame.setLayout(new BorderLayout()); this.frame.setBackground(Color.BLACK); if (!GameLaunch.SETTINGS.isSwiftKit()) diff --git a/09HDscape-client/src/org/runite/jagex/GameShell.java b/09HDscape-client/src/org/runite/jagex/GameShell.java index 0d0e4dfa8..6406c2c51 100644 --- a/09HDscape-client/src/org/runite/jagex/GameShell.java +++ b/09HDscape-client/src/org/runite/jagex/GameShell.java @@ -1,6 +1,7 @@ package org.runite.jagex; import org.runite.Configurations; +import org.runite.GameLaunch; import org.runite.GameSetting; import java.applet.Applet; @@ -19,7 +20,7 @@ public abstract class GameShell extends Applet implements Runnable, FocusListene /** * The game settings. */ - public static GameSetting SETTINGS = new GameSetting("Runite", Configurations.LOCAL_MS ? "127.0.0.1" : "frostblades.org", 1, "live", false, false); + public static GameSetting SETTINGS = new GameSetting(GameLaunch.SETTINGS.getName(), Configurations.LOCAL_MS ? "127.0.0.1" : "frostblades.org", 1, "live", false, false); private boolean aBoolean1 = false; diff --git a/09HDscape-client/src/org/runite/jagex/RSString.java b/09HDscape-client/src/org/runite/jagex/RSString.java index 519429888..d1641319d 100644 --- a/09HDscape-client/src/org/runite/jagex/RSString.java +++ b/09HDscape-client/src/org/runite/jagex/RSString.java @@ -1,4 +1,6 @@ package org.runite.jagex; +import org.runite.GameLaunch; + import java.applet.Applet; import java.awt.FontMetrics; import java.awt.Graphics; @@ -1578,7 +1580,7 @@ final class RSString implements Interface3 { static final RSString createRSString(String string) { if (string != null) { - string = string.replace("RuneScape", "Runite"); + string = string.replace("RuneScape", GameLaunch.SETTINGS.getName()); } try { byte[] var2 = string.getBytes(); diff --git a/09HDscape-server/data/eco/grand_exchange_db.emp b/09HDscape-server/data/eco/grand_exchange_db.emp index 91a0d6b56..6c5e146ee 100644 Binary files a/09HDscape-server/data/eco/grand_exchange_db.emp and b/09HDscape-server/data/eco/grand_exchange_db.emp differ diff --git a/09HDscape-server/data/eco/offer_dispatch_db.emp b/09HDscape-server/data/eco/offer_dispatch_db.emp index 83ff37780..7a924a3c4 100644 Binary files a/09HDscape-server/data/eco/offer_dispatch_db.emp and b/09HDscape-server/data/eco/offer_dispatch_db.emp differ diff --git a/09HDscape-server/server1.properties b/09HDscape-server/server1.properties index 7d1976987..46b3bb091 100644 --- a/09HDscape-server/server1.properties +++ b/09HDscape-server/server1.properties @@ -2,7 +2,7 @@ name=Crandor beta=true sql=true devMode=false -gui=false +gui=true gameType=economy worldId=1 country=0 diff --git a/09HDscape-server/src/org/crandor/Main.java b/09HDscape-server/src/org/crandor/Main.java index 7c324ca6c..1a7b15d19 100644 --- a/09HDscape-server/src/org/crandor/Main.java +++ b/09HDscape-server/src/org/crandor/Main.java @@ -10,6 +10,7 @@ import org.crandor.game.system.SystemShutdownHook; import org.crandor.game.system.mysql.SQLManager; import org.crandor.game.world.GameSettings; import org.crandor.game.world.GameWorld; +import org.crandor.gui.ConsoleFrame; import org.crandor.net.NioReactor; import org.crandor.net.amsc.WorldCommunicator; import org.crandor.tools.TimeStamp; @@ -21,7 +22,7 @@ import org.crandor.tools.backup.AutoBackup; * @author Vexia * */ -public final class Main { +public final class Main extends Application { /** * The time stamp of when the server started running. @@ -45,9 +46,9 @@ public final class Main { if (args.length > 0) { GameWorld.setSettings(GameSettings.parse(args)); } -// if (GameWorld.getSettings().isGui()) { -// KeldagrimFrame.getInstance().init(); -// } + if (GameWorld.getSettings().isGui()) { + ConsoleFrame.getInstance().init(); + } startTime = System.currentTimeMillis(); final TimeStamp t = new TimeStamp(); // backup = new AutoBackup(); @@ -78,4 +79,12 @@ public final class Main { public static void setStartTime(long startTime) { Main.startTime = startTime; } + + @Override + public void start(Stage primaryStage) throws Exception { + Parent root = FXMLLoader.load(getClass().getResource("Main Frame.fxml")); + primaryStage.setTitle("Management Panel"); + primaryStage.setScene(new Scene(root, 600, 450)); + primaryStage.show(); + } } \ No newline at end of file diff --git a/09HDscape-server/src/org/crandor/ServerConstants.java b/09HDscape-server/src/org/crandor/ServerConstants.java index 750aac856..5c0cc854d 100644 --- a/09HDscape-server/src/org/crandor/ServerConstants.java +++ b/09HDscape-server/src/org/crandor/ServerConstants.java @@ -16,7 +16,7 @@ public final class ServerConstants { * The administrators. */ public static final String[] ADMINISTRATORS = { - "torv", + "ethan", "austin", }; diff --git a/09HDscape-server/src/org/crandor/game/content/dialogue/DialoguePlugin.java b/09HDscape-server/src/org/crandor/game/content/dialogue/DialoguePlugin.java index 76cfa4bbf..bda901138 100644 --- a/09HDscape-server/src/org/crandor/game/content/dialogue/DialoguePlugin.java +++ b/09HDscape-server/src/org/crandor/game/content/dialogue/DialoguePlugin.java @@ -209,6 +209,13 @@ public abstract class DialoguePlugin implements Plugin { public Component player(final String... messages) { return interpreter.sendDialogues(player, null, messages); } + /** + * Method wrapper to send a player dial. + * @return the component. + */ + public Component player(FacialExpression expression, final String... messages) { + return interpreter.sendDialogues(player, expression, messages); + } /** * Method used to send options. diff --git a/09HDscape-server/src/org/crandor/game/content/dialogue/FacialExpression.java b/09HDscape-server/src/org/crandor/game/content/dialogue/FacialExpression.java index 53f33d34a..854c83f45 100644 --- a/09HDscape-server/src/org/crandor/game/content/dialogue/FacialExpression.java +++ b/09HDscape-server/src/org/crandor/game/content/dialogue/FacialExpression.java @@ -3,35 +3,45 @@ package org.crandor.game.content.dialogue; /** * Represents the facial expressions (the animations the entity does when * talking). + * * @author Emperor * @author Empathy */ public enum FacialExpression { - /** - * The normal talking expression. - */ - OSRS_HAPPY(588), OSRS_NORMAL(594), OSRS_SAD(596), OSRS_LAUGH1(605), OSRS_LAUGH2(606), OSRS_LAUGH3(607), OSRS_LAUGH4(608), //TODO: More - NORMAL(9760), ANGRY(9792), GRUMPY(9784), ANNOYED(9812), SNEAKY(595), SAD(9776), DISTRESSED(9820), HAPPY(9851), NEARLY_CRYING(9836), CHILD_QUESTIONABLE(7171), CHILD_BACK_AND_FORTH(7172), CHILD_NORMAL(7173), CHILD_SLOW_NOD(7174), CHILD_CRAZY_LAUGH(7175), CHILD_THINKING(7176), CHILD_SAD(7177), CHILD_BIG_EYES(7178), CHILD_LOOKING_OUT(7179); + /** + * The normal talking expression. + */ + OSRS_HAPPY(588), OSRS_NORMAL(594), OSRS_SAD(596), OSRS_LAUGH1(605), OSRS_LAUGH2(606), OSRS_LAUGH3(607), OSRS_LAUGH4(608), //TODO: More + NORMAL(9760), ANGRY(9792), GRUMPY(9784), ANNOYED(9812), SNEAKY(595), SAD(9776), DISTRESSED(9820), HAPPY(9851), NEARLY_CRYING(9836), CHILD_QUESTIONABLE(7171), CHILD_BACK_AND_FORTH(7172), CHILD_NORMAL(7173), CHILD_SLOW_NOD(7174), CHILD_CRAZY_LAUGH(7175), CHILD_THINKING(7176), CHILD_SAD(7177), CHILD_BIG_EYES(7178), CHILD_LOOKING_OUT(7179), - /** - * The animation id. - */ - private final int animationId; + NO_EXPRESSION(9760), SAD_TWO(9768), NO_EXPRESSION_TWO(9772), WHY(9776), + SCARED(9780), MIDLY_ANGRY(9784), VERY_ANGRY(9792), ANGRY_TWO(9796), + JUST_LISTEN(9804), CALM_TALKING(9808), LOOK_DOWN(9812), WHAT_THE(9816), WHAT_THE_TWO(9820), + CROOKED_HEAD(9828), GLANCE_DOWN(9832), UNSURE(9836), LISTEN_LAUGH(9840), + TALK_SWING(9844), GOOFY_LAUGH(9851), DRUNK(9835), ASKING(9827), SUSPICIOUS(9831); - /** - * Constructs a new {@code FacialExpression} {@code Object}. - * @param animationId The animation id. - */ - private FacialExpression(int animationId) { - this.animationId = animationId; - } - /** - * Gets the animation id. - * @return The animation id. - */ - public int getAnimationId() { - return animationId; - } + /** + * The animation id. + */ + private final int animationId; + + /** + * Constructs a new {@code FacialExpression} {@code Object}. + * + * @param animationId The animation id. + */ + FacialExpression(int animationId) { + this.animationId = animationId; + } + + /** + * Gets the animation id. + * + * @return The animation id. + */ + public int getAnimationId() { + return animationId; + } } \ No newline at end of file diff --git a/09HDscape-server/src/org/crandor/game/content/global/shop/Shop.java b/09HDscape-server/src/org/crandor/game/content/global/shop/Shop.java index 511a1ef59..25c8cf260 100644 --- a/09HDscape-server/src/org/crandor/game/content/global/shop/Shop.java +++ b/09HDscape-server/src/org/crandor/game/content/global/shop/Shop.java @@ -15,788 +15,850 @@ import java.util.List; /** * A class representing a shop. + * * @author 'Vexia */ public class Shop { - /** - * Represents the general store items. - */ - public final static Item[] GENERAL_STORE_ITEMS = { new Item(1931, 30), new Item(1935, 30), new Item(1735, 10), new Item(1925, 10), new Item(1923, 10), new Item(1887, 10), new Item(590, 10), new Item(1755, 10), new Item(2347, 10), new Item(550, 10), new Item(9003, 10) }; + /** + * Represents the general store items. + */ + public final static Item[] GENERAL_STORE_ITEMS = {new Item(1931, 30), new Item(1935, 30), new Item(1735, 10), new Item(1925, 10), new Item(1923, 10), new Item(1887, 10), new Item(590, 10), new Item(1755, 10), new Item(2347, 10), new Item(550, 10), new Item(9003, 10)}; + /** + * Represents the coins item. + */ + private static final int COINS = 995; + /** + * Represents the tokkul item id. + */ + private static final int TOKKUL = 6529; + /** + * Represents the shop containers. + */ + private final Container[] containers = new Container[]{new Container(40, ContainerType.SHOP), new Container(40, ContainerType.SHOP)}; + /** + * Represents the list of shop viewers. + */ + private final List viewers = new ArrayList<>(); - /** - * Represents the shop containers. - */ - private final Container[] containers = new Container[] { new Container(40, ContainerType.SHOP), new Container(40, ContainerType.SHOP) }; + /** + * Represents the title of the shop. + */ + private final String title; - /** - * Represents the coins item. - */ - private static final int COINS = 995; + /** + * Represents the items in the store. + */ + private final Item[] items; - /** - * Represents the tokkul item id. - */ - private static final int TOKKUL = 6529; + /** + * Represents if it's a general store. + */ + private final boolean general; - /** - * Represents the list of shop viewers. - */ - private final List viewers = new ArrayList<>(); + /** + * Represents the currency the shop allows. + */ + private final int currency; - /** - * Represents the title of the shop. - */ - private final String title; + /** + * If the shop buys for high alch. + */ + private final boolean highAlch; - /** - * Represents the items in the store. - */ - private final Item[] items; + /** + * Sell price for all shop items, if needed. + */ + private int sellAllFor; - /** - * Represents if it's a general store. - */ - private final boolean general; + /** + * The last restock. + */ + private int lastRestock; - /** - * Represents the currency the shop allows. - */ - private final int currency; + /** + * If the shop should restock. + */ + private boolean restock; - /** - * If the shop buys for high alch. - */ - private final boolean highAlch; - - /** - * Sell price for all shop items, if needed. - */ - private int sellAllFor; - - /** - * The last restock. - */ - private int lastRestock; - - /** - * If the shop should restock. - */ - private boolean restock; - /** * If it's a point shop. */ private boolean pointShop; - /** - * The npcs of the shop. - */ - private int[] npcs; - - /** - * Constructs a new {@code Shop} {@code Object}. - * @param title the title. - * @param items the items. - * @param npcs the npcs. - * @param general the general. - * @param currency the currency. - * @param highAlch if high alch. - */ - public Shop(String title, Item[] items, boolean general, int currency, boolean highAlch) { - this.title = title; - this.items = items; - this.general = general; - this.currency = currency; - this.highAlch = highAlch; - this.getContainer(0).add(items); - this.setRestock(true); - lastRestock = GameWorld.getTicks() + 100; - } + /** + * The npcs of the shop. + */ + private int[] npcs; + + /** + * Constructs a new {@code Shop} {@code Object}. + * + * @param title the title. + * @param items the items. + * @param npcs the npcs. + * @param general the general. + * @param currency the currency. + * @param highAlch if high alch. + */ + public Shop(String title, Item[] items, boolean general, int currency, boolean highAlch) { + this.title = title; + this.items = items; + this.general = general; + this.currency = currency; + this.highAlch = highAlch; + this.getContainer(0).add(items); + this.setRestock(true); + lastRestock = GameWorld.getTicks() + 100; + } - - /** - * Constructs a new {@code Shop} {@code Object}. - * @param title the title. - * @param items the items. - * @param npcs the npcs. - * @param general the general. - * @param currency the currency. - * @param highAlch if high alch. - * @param restock if restock. - */ - public Shop(String title, Item[] items, boolean general, int currency, boolean highAlch, boolean restock, int sellAllFor) { - this(title, items, general, currency, highAlch); - this.sellAllFor = sellAllFor; - this.setRestock(restock); - } + /** + * Constructs a new {@code Shop} {@code Object}. + * + * @param title the title. + * @param items the items. + * @param npcs the npcs. + * @param general the general. + * @param currency the currency. + * @param highAlch if high alch. + * @param restock if restock. + */ + public Shop(String title, Item[] items, boolean general, int currency, boolean highAlch, boolean restock, int sellAllFor) { + this(title, items, general, currency, highAlch); + this.sellAllFor = sellAllFor; + this.setRestock(restock); + } - /** - * Constructs a new {@Code Shop} {@Code Object} - * @param title - * @param items - * @param npcs - * @param general - * @param currency - */ - public Shop(String title, Item[] items, int[] npcs, boolean general, int currency) { - this(title, items, general, currency, false); - this.setNpcs(npcs); - } + /** + * Constructs a new {@Code Shop} {@Code Object} + * + * @param title + * @param items + * @param npcs + * @param general + * @param currency + */ + public Shop(String title, Item[] items, int[] npcs, boolean general, int currency) { + this(title, items, general, currency, false); + this.setNpcs(npcs); + } - /** - * Constructs a new {@code Shop} {@code Object}. - * @param title the title. - * @param items the items. - * @param npcs the npcs. - * @param general the general. - */ - public Shop(String title, Item[] items, boolean general) { - this(title, items, general, COINS, false); - } + /** + * Constructs a new {@code Shop} {@code Object}. + * + * @param title the title. + * @param items the items. + * @param npcs the npcs. + * @param general the general. + */ + public Shop(String title, Item[] items, boolean general) { + this(title, items, general, COINS, false); + } - /** - * Constructs a new {@code Shop} {@code Object}. - * @param title the title. - * @param npcs the npcs. - * @param general the general. - */ - public Shop(String title, boolean general) { - this(title, GENERAL_STORE_ITEMS, general); - } + /** + * Constructs a new {@code Shop} {@code Object}. + * + * @param title the title. + * @param npcs the npcs. + * @param general the general. + */ + public Shop(String title, boolean general) { + this(title, GENERAL_STORE_ITEMS, general); + } - /** - * Constructs a new {@code Shop} {@code Object}. - * @param title the title. - * @param npcs the npcs. - * @param general the general. - * @param highAlch if highAlch. - */ - public Shop(String title, boolean general, boolean highAlch) { - this(title, GENERAL_STORE_ITEMS, general, COINS, highAlch); - } + /** + * Constructs a new {@code Shop} {@code Object}. + * + * @param title the title. + * @param npcs the npcs. + * @param general the general. + * @param highAlch if highAlch. + */ + public Shop(String title, boolean general, boolean highAlch) { + this(title, GENERAL_STORE_ITEMS, general, COINS, highAlch); + } - /** - * Constructs a new {@code Shop} {@code Object}. - * @param title the title. - * @param npcs the npcs. - * @param general the general. - * @param highAlch if highAlch. - */ - public Shop(String title, boolean general, int currency, boolean highAlch) { - this(title, GENERAL_STORE_ITEMS, general, currency, highAlch); - } + /** + * Constructs a new {@code Shop} {@code Object}. + * + * @param title the title. + * @param npcs the npcs. + * @param general the general. + * @param highAlch if highAlch. + */ + public Shop(String title, boolean general, int currency, boolean highAlch) { + this(title, GENERAL_STORE_ITEMS, general, currency, highAlch); + } - /** - * Constructs a new {@code Shop} {@code Object}. - * @param title the title. - * @param items the items. - * @param npcs the npcs. - * @param general the general. - */ - public Shop(String title, Item[] items, int[] npcs, boolean general) { - this(title, items, general, COINS, false); - this.setNpcs(npcs); - } + /** + * Constructs a new {@code Shop} {@code Object}. + * + * @param title the title. + * @param items the items. + * @param npcs the npcs. + * @param general the general. + */ + public Shop(String title, Item[] items, int[] npcs, boolean general) { + this(title, items, general, COINS, false); + this.setNpcs(npcs); + } - /** - * Constructs a new {@code Shop} {@code Object}. - * @param title the title. - * @param npcs the npcs. - * @param general the general. - */ - public Shop(String title, int[] npcs, boolean general) { - this(title, GENERAL_STORE_ITEMS, npcs, general); - this.setNpcs(npcs); - } + /** + * Constructs a new {@code Shop} {@code Object}. + * + * @param title the title. + * @param npcs the npcs. + * @param general the general. + */ + public Shop(String title, int[] npcs, boolean general) { + this(title, GENERAL_STORE_ITEMS, npcs, general); + this.setNpcs(npcs); + } - /** - * Constructs a new {@code Shop} {@code Object}. - * @param title the title. - * @param npcs the npcs. - * @param general the general. - * @param highAlch if highAlch. - */ - public Shop(String title, int[] npcs, boolean general, boolean highAlch) { - this(title, GENERAL_STORE_ITEMS, general, 995, highAlch); - this.setNpcs(npcs); - } + /** + * Constructs a new {@code Shop} {@code Object}. + * + * @param title the title. + * @param npcs the npcs. + * @param general the general. + * @param highAlch if highAlch. + */ + public Shop(String title, int[] npcs, boolean general, boolean highAlch) { + this(title, GENERAL_STORE_ITEMS, general, 995, highAlch); + this.setNpcs(npcs); + } - /** - * Method used to open the shop. - * @param player the shop. - */ - public void open(final Player player) { - ShopViewer.extend(player, this).open(); - } + /** + * Method used to open the shop. + * + * @param player the shop. + */ + public void open(final Player player) { + ShopViewer.extend(player, this).open(); + } - /** - * Method used to buy an item from the shop. - * @param slot the slot. - * @param amount the amount. - */ - public void buy(Player player, final int slot, int amount, int tabIndex) { - if (tabIndex == 1 && player.getIronmanManager().checkRestriction()) { - return; - } - final Container container = getContainer(tabIndex); - final Item item = container.get(slot); - if (item == null) { - return; - } - if (item.getAmount() < 1) { - player.getPacketDispatch().sendMessage("There is no stock of that item at the moment."); - return; - } - if (amount > item.getAmount()) { - amount = item.getAmount(); - } - final Item add = new Item(item.getId(), amount); - if (player.getInventory().getMaximumAdd(add) < amount) { - add.setAmount(player.getInventory().getMaximumAdd(add)); - } - if (add.getAmount() < 1 || !player.getInventory().hasSpaceFor(add)) { - player.getPacketDispatch().sendMessage("You have no inventory space at the moment and cannot buy anything."); - return; - } - add.setAmount(getAmount(player, add)); - if (add.getAmount() < 1 || !player.getInventory().hasSpaceFor(add)) { - player.getPacketDispatch().sendMessage("You have no inventory space at the moment and cannot buy anything."); - return; - } - int price = add.getAmount() * getBuyPrice(item, player); - final Item currency = new Item(getCurrency(), price); - if (!canBuy(player, item, price, currency)) { - return; - } - if (handleBuy(player, currency)) { - if (pointShop) { - decrementPoints(player, price); - } - if (tabIndex == 0) { - container.replace(new Item(item.getId(), container.getAmount(item) - add.getAmount()), slot, true); - } else { - container.remove(add); - container.shift(); - } - if (add.getId() == 7462 && getTitle().equals("Culinaromancer's Chest") && !player.getAchievementDiaryManager().getDiary(DiaryType.LUMBRIDGE).isComplete(2, 3)) { - player.getAchievementDiaryManager().updateTask(player, DiaryType.LUMBRIDGE, 2, 3, true); - } - player.getInventory().add(add); - update(); - } - } + public void give(Player player, final int slot, int amount, int tabIndex) { + final Container container = getContainer(tabIndex); + final Item item = container.get(slot); + if (item == null) { + return; + } + final Item add = new Item(item.getId(), amount); + if (add.getAmount() < 1 || !player.getInventory().hasSpaceFor(add)) { + player.getPacketDispatch().sendMessage("You have no inventory space at the moment and cannot get anything."); + return; + } + add.setAmount(getAmount(player, add)); + if (add.getAmount() < 1 || !player.getInventory().hasSpaceFor(add)) { + player.getPacketDispatch().sendMessage("You have no inventory space at the moment and cannot get anything."); + return; + } + player.getInventory().add(add); + update(); + } - /** - * Method used to sell an item to the shop. - * @param slot the slot. - * @param amount the amount. - */ - public void sell(Player player, final int slot, int amount, int tabIndex) { - final Item item = player.getInventory().get(slot); - if (item == null) { - return; - } - final ItemDefinition def = ItemDefinition.forId(item.getId()); - if (!canSell(player, item, def)) { - return; - } - final Container container = getContainer(item); - if (amount > player.getInventory().getAmount(item)) { - amount = player.getInventory().getAmount(item); - } - Item add = new Item(item.getId(), amount); - if (add.getAmount() > container.getMaximumAdd(add)) { - add.setAmount(container.getMaximumAdd(add)); - } - if (!container.hasSpaceFor(add) || add.getAmount() < 1) { - player.getPacketDispatch().sendMessage("The shop has ran out of space."); - return; - } - final Item currency = new Item(getCurrency(), getSellingValue(add, player)); - if (!player.getInventory().hasSpaceFor(currency)) { - player.getPacketDispatch().sendMessage("You don't have enough space for that many " + currency.getName().toLowerCase() + "."); - return; - } - if (currency.getAmount() > player.getInventory().getMaximumAdd(currency)) { - currency.setAmount(player.getInventory().getMaximumAdd(currency)); - } - if (player.getInventory().remove(add, slot, true)) { - if (!add.getDefinition().isUnnoted()) { - add = new Item(add.getNoteChange(), add.getAmount()); - } - if (container.add(add)) { - if (currency.getAmount() > 0) { - player.getInventory().add(currency); - } - final ShopViewer viewer = player.getExtension(ShopViewer.class); - tabIndex = container == getContainers()[0] ? 0 : 1; - sendStock(player, tabIndex); - if (viewer != null) { - viewer.setTabIndex(tabIndex); - } - update(); - } - } - } + /** + * Method used to buy an item from the shop. + * + * @param slot the slot. + * @param amount the amount. + */ + public void buy(Player player, final int slot, int amount, int tabIndex) { + if (tabIndex == 1 && player.getIronmanManager().checkRestriction()) { + return; + } + final Container container = getContainer(tabIndex); + final Item item = container.get(slot); + if (item == null) { + return; + } + if (item.getAmount() < 1) { + player.getPacketDispatch().sendMessage("There is no stock of that item at the moment."); + return; + } + if (amount > item.getAmount()) { + amount = item.getAmount(); + } + final Item add = new Item(item.getId(), amount); + if (player.getInventory().getMaximumAdd(add) < amount) { + add.setAmount(player.getInventory().getMaximumAdd(add)); + } + if (add.getAmount() < 1 || !player.getInventory().hasSpaceFor(add)) { + player.getPacketDispatch().sendMessage("You have no inventory space at the moment and cannot buy anything."); + return; + } + add.setAmount(getAmount(player, add)); + if (add.getAmount() < 1 || !player.getInventory().hasSpaceFor(add)) { + player.getPacketDispatch().sendMessage("You have no inventory space at the moment and cannot buy anything."); + return; + } + int price = add.getAmount() * getBuyPrice(item, player); + final Item currency = new Item(getCurrency(), price); + if (!canBuy(player, item, price, currency)) { + return; + } + if (handleBuy(player, currency)) { + if (pointShop) { + decrementPoints(player, price); + } + if (tabIndex == 0) { + container.replace(new Item(item.getId(), container.getAmount(item) - add.getAmount()), slot, true); + } else { + container.remove(add); + container.shift(); + } + if (add.getId() == 7462 && getTitle().equals("Culinaromancer's Chest") && !player.getAchievementDiaryManager().getDiary(DiaryType.LUMBRIDGE).isComplete(2, 3)) { + player.getAchievementDiaryManager().updateTask(player, DiaryType.LUMBRIDGE, 2, 3, true); + } + player.getInventory().add(add); + update(); + } + } - /** - * Values an item. - * @param player the player. - * @param viewer the viewer. - * @param item the item. - * @param sell the sell. - */ - public void value(Player player, ShopViewer viewer, Item item, boolean sell) { - if (sell) { - if (pointShop || item.getId() == viewer.getShop().getCurrency() || !item.getDefinition().isTradeable() || !viewer.getShop().itemAllowed(item.getId())) { - player.getPacketDispatch().sendMessage("You can't sell this item."); - return; - } - final int value = viewer.getShop().getSellingValue(new Item(item.getId(), 1), player); - String currency = pointShop ? getPointsName() : ItemDefinition.forId(viewer.getShop().getCurrency()).getName().toLowerCase(); - if (value == 1 && currency.charAt(currency.length() - 1) == 's') { - currency = currency.substring(0, currency.length() - 1); - } - player.getPacketDispatch().sendMessage(item.getName() + ": shop will buy for " + value + " " + currency + "."); - } else { - int value = viewer.getShop().getBuyPrice(item, player); - String name = pointShop ? getPointsName() + "s" : ItemDefinition.forId(viewer.getShop().getCurrency()).getName().toLowerCase(); - if (value == 1 && (name.charAt(name.length() - 1) == 's')) { - name = name.substring(0, name.length() - 1); - } - player.getPacketDispatch().sendMessage("" + item.getName() + ": currently costs " + value + " " + name + "."); - } - } + /** + * Method used to sell an item to the shop. + * + * @param slot the slot. + * @param amount the amount. + */ + public void sell(Player player, final int slot, int amount, int tabIndex) { + final Item item = player.getInventory().get(slot); + if (item == null) { + return; + } + final ItemDefinition def = ItemDefinition.forId(item.getId()); + if (!canSell(player, item, def)) { + return; + } + final Container container = getContainer(item); + if (amount > player.getInventory().getAmount(item)) { + amount = player.getInventory().getAmount(item); + } + Item add = new Item(item.getId(), amount); + if (add.getAmount() > container.getMaximumAdd(add)) { + add.setAmount(container.getMaximumAdd(add)); + } + if (!container.hasSpaceFor(add) || add.getAmount() < 1) { + player.getPacketDispatch().sendMessage("The shop has ran out of space."); + return; + } + final Item currency = new Item(getCurrency(), getSellingValue(add, player)); + if (!player.getInventory().hasSpaceFor(currency)) { + player.getPacketDispatch().sendMessage("You don't have enough space for that many " + currency.getName().toLowerCase() + "."); + return; + } + if (currency.getAmount() > player.getInventory().getMaximumAdd(currency)) { + currency.setAmount(player.getInventory().getMaximumAdd(currency)); + } + if (player.getInventory().remove(add, slot, true)) { + if (!add.getDefinition().isUnnoted()) { + add = new Item(add.getNoteChange(), add.getAmount()); + } + if (container.add(add)) { + if (currency.getAmount() > 0) { + player.getInventory().add(currency); + } + final ShopViewer viewer = player.getExtension(ShopViewer.class); + tabIndex = container == getContainers()[0] ? 0 : 1; + sendStock(player, tabIndex); + if (viewer != null) { + viewer.setTabIndex(tabIndex); + } + update(); + } + } + } - /** - * Method used to send a stock - * @param player - * @param tabIndex - */ - public void sendStock(final Player player, int tabIndex) { - final boolean main = tabIndex == 0; - player.getPacketDispatch().sendInterfaceConfig(620, 23, main ? false : true); - player.getPacketDispatch().sendInterfaceConfig(620, 24, main ? true : false); - player.getPacketDispatch().sendInterfaceConfig(620, 29, main ? false : true); - player.getPacketDispatch().sendInterfaceConfig(620, 25, main ? true : false); - player.getPacketDispatch().sendInterfaceConfig(620, 27, main ? true : false); - player.getPacketDispatch().sendInterfaceConfig(620, 26, main ? false : false); - player.getPacketDispatch().sendAccessMask(1278, main ? 23 : 24, 620, 0, 40); - } + /** + * Values an item. + * + * @param player the player. + * @param viewer the viewer. + * @param item the item. + * @param sell the sell. + */ + public void value(Player player, ShopViewer viewer, Item item, boolean sell) { + if (sell) { + if (pointShop || item.getId() == viewer.getShop().getCurrency() || !item.getDefinition().isTradeable() || !viewer.getShop().itemAllowed(item.getId())) { + player.getPacketDispatch().sendMessage("You can't sell this item."); + return; + } + final int value = viewer.getShop().getSellingValue(new Item(item.getId(), 1), player); + String currency = pointShop ? getPointsName() : ItemDefinition.forId(viewer.getShop().getCurrency()).getName().toLowerCase(); + if (value == 1 && currency.charAt(currency.length() - 1) == 's') { + currency = currency.substring(0, currency.length() - 1); + } + player.getPacketDispatch().sendMessage(item.getName() + ": shop will buy for " + value + " " + currency + "."); + } else { + int value = viewer.getShop().getBuyPrice(item, player); + String name = pointShop ? getPointsName() + "s" : ItemDefinition.forId(viewer.getShop().getCurrency()).getName().toLowerCase(); + if (value == 1 && (name.charAt(name.length() - 1) == 's')) { + name = name.substring(0, name.length() - 1); + } + player.getPacketDispatch().sendMessage("" + item.getName() + ": currently costs " + value + " " + name + "."); + } + } - /** - * Method used to update the viewers. - */ - public void update() { - for (ShopViewer viewer : viewers) { - viewer.update(); - } - } + /** + * Method used to send a stock + * + * @param player + * @param tabIndex + */ + public void sendStock(final Player player, int tabIndex) { + final boolean main = tabIndex == 0; + player.getPacketDispatch().sendInterfaceConfig(620, 23, main ? false : true); + player.getPacketDispatch().sendInterfaceConfig(620, 24, main ? true : false); + player.getPacketDispatch().sendInterfaceConfig(620, 29, main ? false : true); + player.getPacketDispatch().sendInterfaceConfig(620, 25, main ? true : false); + player.getPacketDispatch().sendInterfaceConfig(620, 27, main ? true : false); + player.getPacketDispatch().sendInterfaceConfig(620, 26, main ? false : false); + player.getPacketDispatch().sendAccessMask(1278, main ? 23 : 24, 620, 0, 40); + } - /** - * Method used to restock the shop. - */ - public void restock() { - for (Container container : containers) { - for (int i = 0; i < container.toArray().length; i++) { - final boolean main = (container == containers[0]); - final Item item = container.toArray()[i]; - if (item == null) { - continue; - } - boolean reduce = !main; - if (main) { - if (item.getAmount() < items[i].getAmount()) { - item.setAmount(item.getAmount() + 1); - } - reduce = item.getAmount() > items[i].getAmount(); - } - if (reduce) { - int amount = item.getAmount() - 1; - if (amount < 1 && !main) { - container.remove(item); - } else { - item.setAmount(amount); - } - if (!main) { - container.shift(); - } - } - } - } - update(); - } + /** + * Method used to update the viewers. + */ + public void update() { + for (ShopViewer viewer : viewers) { + viewer.update(); + } + } - /** - * Checks if the player can sell an item to the shop. - * @param player the player. - * @param item the item. - * @param def the def. - * @return {@code True} if so. - */ - public boolean canSell(Player player, Item item, ItemDefinition def) { - if (pointShop || item.getDefinition().hasDestroyAction() || !def.isTradeable() || !itemAllowed(item.getId())) { - player.getPacketDispatch().sendMessage("You can't sell this item to this shop."); - return false; - } - if (item.getId() == getCurrency()) { - player.getPacketDispatch().sendMessage("You can't sell " + item.getName().toLowerCase() + " to a shop."); - return false; - } - return true; - } + /** + * Method used to restock the shop. + */ + public void restock() { + for (Container container : containers) { + for (int i = 0; i < container.toArray().length; i++) { + final boolean main = (container == containers[0]); + final Item item = container.toArray()[i]; + if (item == null) { + continue; + } + boolean reduce = !main; + if (main) { + if (item.getAmount() < items[i].getAmount()) { + item.setAmount(item.getAmount() + 1); + } + reduce = item.getAmount() > items[i].getAmount(); + } + if (reduce) { + int amount = item.getAmount() - 1; + if (amount < 1 && !main) { + container.remove(item); + } else { + item.setAmount(amount); + } + if (!main) { + container.shift(); + } + } + } + } + update(); + } - /** - * Gets the amount to buy/sell. - * @param player the player. - * @param add the added item. - * @return the amount. - */ - public int getAmount(Player player, Item add) { - return add.getAmount(); - } + /** + * Checks if the player can sell an item to the shop. + * + * @param player the player. + * @param item the item. + * @param def the def. + * @return {@code True} if so. + */ + public boolean canSell(Player player, Item item, ItemDefinition def) { + if (pointShop || item.getDefinition().hasDestroyAction() || !def.isTradeable() || !itemAllowed(item.getId())) { + player.getPacketDispatch().sendMessage("You can't sell this item to this shop."); + return false; + } + if (item.getId() == getCurrency()) { + player.getPacketDispatch().sendMessage("You can't sell " + item.getName().toLowerCase() + " to a shop."); + return false; + } + return true; + } + + /** + * Gets the amount to buy/sell. + * + * @param player the player. + * @param add the added item. + * @return the amount. + */ + public int getAmount(Player player, Item add) { + return add.getAmount(); + } /** * Checks if the player can buy the item. - * @param player the player. + * + * @param player the player. * @param currency the currency. * @return {@code True} if so. */ public boolean handleBuy(Player player, Item currency) { - return pointShop || player.getInventory().remove(currency); + return pointShop || player.getInventory().remove(currency); } /** * Checks if the player can buy from the shop. - * @param player the player. - * @param item the item. - * @param price the price. + * + * @param player the player. + * @param item the item. + * @param price the price. * @param currency the currency. * @return {@code True} if they can buy. */ public boolean canBuy(Player player, Item item, int price, Item currency) { - if (!pointShop && !player.getInventory().containsItem(currency)) { - player.getPacketDispatch().sendMessage("You don't have enough " + ItemDefinition.forId(getCurrency()).getName().toLowerCase() + "."); - return false; - } - if (pointShop && getPoints(player) < price) { - player.sendMessage("You don't have enough " + getPointsName() + "s."); - return false; - } - return true; + if (!pointShop && !player.getInventory().containsItem(currency)) { + player.getPacketDispatch().sendMessage("You don't have enough " + ItemDefinition.forId(getCurrency()).getName().toLowerCase() + "."); + return false; + } + if (pointShop && getPoints(player) < price) { + player.sendMessage("You don't have enough " + getPointsName() + "s."); + return false; + } + return true; } - /** - * Gets the points. - * @param player the player. - * @return the points. - */ - public int getPoints(Player player) { - return 0; - } + /** + * Gets the points. + * + * @param player the player. + * @return the points. + */ + public int getPoints(Player player) { + return 0; + } - /** - * Decrements the points. - * @param player the player. - * @param decrement the decrementation. - */ - public void decrementPoints(Player player, int decrement) { + /** + * Decrements the points. + * + * @param player the player. + * @param decrement the decrementation. + */ + public void decrementPoints(Player player, int decrement) { - } + } - /** - * Gets the points name. - * @return the name. - */ - public String getPointsName() { - return ""; - } + /** + * Gets the points name. + * + * @return the name. + */ + public String getPointsName() { + return ""; + } - /** - * Gets the value gained for selling this item to a certain shop. - * @param item The item to sell. - * @param player the player. - * @return The value. - */ - public int getSellingValue(Item item, Player player) { - if (!item.getDefinition().isUnnoted()) { - item = new Item(item.getNoteChange(), item.getAmount()); - } - int amount = getContainer(1).getAmount(item); - if (getCurrency() == TOKKUL) { - for (Item i : items) { - if (i.getId() == item.getId()) { - amount = i.getAmount(); - } - } - } - if (amount < 1) { - amount = getContainer(0).getAmount(item); - } - int value = getSellValue(player, amount, item); - if (getCurrency() == TOKKUL) { - int tokkul = item.getDefinition().getConfiguration(ItemConfigSQLHandler.TOKKUL_PRICE, -1); - if (tokkul > 0) { - value = tokkul /= 10; - } - } - return value; - } + /** + * Gets the value gained for selling this item to a certain shop. + * + * @param item The item to sell. + * @param player the player. + * @return The value. + */ + public int getSellingValue(Item item, Player player) { + if (!item.getDefinition().isUnnoted()) { + item = new Item(item.getNoteChange(), item.getAmount()); + } + int amount = getContainer(1).getAmount(item); + if (getCurrency() == TOKKUL) { + for (Item i : items) { + if (i.getId() == item.getId()) { + amount = i.getAmount(); + } + } + } + if (amount < 1) { + amount = getContainer(0).getAmount(item); + } + int value = getSellValue(player, amount, item); + if (getCurrency() == TOKKUL) { + int tokkul = item.getDefinition().getConfiguration(ItemConfigSQLHandler.TOKKUL_PRICE, -1); + if (tokkul > 0) { + value = tokkul /= 10; + } + } + return value; + } - /** - * Gets the selling value formula based. - * @param amount the amount. - * @param item the item. - * @return the selling value. - */ - private int getSellValue(Player player, int amount, Item item) { - if (player.isDonator() && player.getZoneMonitor().isInZone("Donator Zone")) { - return (int) (item.getDefinition().getAlchemyValue(highAlch) * item.getAmount()); - } - double diff = item.getDefinition().isStackable() ? 0.005 : 0.05; - double maxMod = 1.0 - (amount * diff); - if (maxMod < 0.25) { - maxMod = 0.25; - } - double minMod = maxMod - ((item.getAmount() - 1) * diff); - if (minMod < 0.25) { - minMod = 0.25; - } - double mod = (maxMod + minMod) / 2; - int value = (int) (item.getDefinition().getAlchemyValue(highAlch) * mod * item.getAmount()); - return value; - } + /** + * Gets the selling value formula based. + * + * @param amount the amount. + * @param item the item. + * @return the selling value. + */ + private int getSellValue(Player player, int amount, Item item) { + if (player.isDonator() && player.getZoneMonitor().isInZone("Donator Zone")) { + return (int) (item.getDefinition().getAlchemyValue(highAlch) * item.getAmount()); + } + double diff = item.getDefinition().isStackable() ? 0.005 : 0.05; + double maxMod = 1.0 - (amount * diff); + if (maxMod < 0.25) { + maxMod = 0.25; + } + double minMod = maxMod - ((item.getAmount() - 1) * diff); + if (minMod < 0.25) { + minMod = 0.25; + } + double mod = (maxMod + minMod) / 2; + int value = (int) (item.getDefinition().getAlchemyValue(highAlch) * mod * item.getAmount()); + return value; + } - /** - * Gets the buying price. - * @param item the item. - * @return the price. - */ - public int getBuyPrice(Item item, Player player) { - item = new Item(item.getId(), 1); - int price = item.getDefinition().getMaxValue(); - int sellVal = getSellingValue(item, player); - if (price < sellVal) { - price = getSellValue(player, 0, item) + sellVal - (sellVal - item.getDefinition().getMaxValue()); - } - if (price < 0) { - price = 1; - } - if (getCurrency() == TOKKUL) { - int tokkul = item.getDefinition().getConfiguration(ItemConfigSQLHandler.TOKKUL_PRICE, -1); - if (tokkul > 0) { - price = tokkul; - } - if (player.getAchievementDiaryManager().getKaramjaGlove() != -1) { - price *= 0.86666666667; - } - } - return (getSellAllFor() > 0 ? getSellAllFor() : price); - } + /** + * Gets the buying price. + * + * @param item the item. + * @return the price. + */ + public int getBuyPrice(Item item, Player player) { + item = new Item(item.getId(), 1); + int price = item.getDefinition().getMaxValue(); + int sellVal = getSellingValue(item, player); + if (price < sellVal) { + price = getSellValue(player, 0, item) + sellVal - (sellVal - item.getDefinition().getMaxValue()); + } + if (price < 0) { + price = 1; + } + if (getCurrency() == TOKKUL) { + int tokkul = item.getDefinition().getConfiguration(ItemConfigSQLHandler.TOKKUL_PRICE, -1); + if (tokkul > 0) { + price = tokkul; + } + if (player.getAchievementDiaryManager().getKaramjaGlove() != -1) { + price *= 0.86666666667; + } + } + return (getSellAllFor() > 0 ? getSellAllFor() : price); + } - /** - * Checks if the item is allowed to be sold to the shop. - * @param item the item id. - * @return {@code True} if so. - */ - public boolean itemAllowed(int itemId) { - if (general) { - return true; - } - int noteId = ItemDefinition.forId(itemId).getNoteId(); - if (!ItemDefinition.forId(itemId).isUnnoted()) { - noteId = ItemDefinition.forId(noteId).getNoteId(); - } - for (Item id : items) { - if (itemId == id.getId() || (noteId > -1 && noteId == ItemDefinition.forId(id.getId()).getNoteId())) { - return true; - } - } - return false; - } + /** + * Checks if the item is allowed to be sold to the shop. + * + * @param item the item id. + * @return {@code True} if so. + */ + public boolean itemAllowed(int itemId) { + if (general) { + return true; + } + int noteId = ItemDefinition.forId(itemId).getNoteId(); + if (!ItemDefinition.forId(itemId).isUnnoted()) { + noteId = ItemDefinition.forId(noteId).getNoteId(); + } + for (Item id : items) { + if (itemId == id.getId() || (noteId > -1 && noteId == ItemDefinition.forId(id.getId()).getNoteId())) { + return true; + } + } + return false; + } - /** - * Gets the container the item should go to. - * @param item the item. - * @return the container. - */ - public Container getContainer(Item item) { - int itemId = item.getId(); - int noteId = ItemDefinition.forId(itemId).getNoteId(); - if (!ItemDefinition.forId(itemId).isUnnoted()) { - noteId = ItemDefinition.forId(noteId).getNoteId(); - } - for (Item i : items) { - if (i.getId() == item.getId() || (noteId > -1 && noteId == ItemDefinition.forId(i.getId()).getNoteId())) { - return getContainer(0); - } - } - return getContainer(1); - } + /** + * Gets the container the item should go to. + * + * @param item the item. + * @return the container. + */ + public Container getContainer(Item item) { + int itemId = item.getId(); + int noteId = ItemDefinition.forId(itemId).getNoteId(); + if (!ItemDefinition.forId(itemId).isUnnoted()) { + noteId = ItemDefinition.forId(noteId).getNoteId(); + } + for (Item i : items) { + if (i.getId() == item.getId() || (noteId > -1 && noteId == ItemDefinition.forId(i.getId()).getNoteId())) { + return getContainer(0); + } + } + return getContainer(1); + } - /** - * Creates a copy of this shop. - * @return the shop. - */ - public Shop copy() { - return new Shop(title, items, general, currency, highAlch); - } + /** + * Creates a copy of this shop. + * + * @return the shop. + */ + public Shop copy() { + return new Shop(title, items, general, currency, highAlch); + } - /** - * Gets the container on the slot. - * @param tabIndex the tab index. - * @return the container. - */ - public Container getContainer(int tabIndex) { - if (tabIndex > containers.length) { - throw new IndexOutOfBoundsException("Error! Shop tab index out of bounds."); - } - return containers[tabIndex]; - } + /** + * Gets the container on the slot. + * + * @param tabIndex the tab index. + * @return the container. + */ + public Container getContainer(int tabIndex) { + if (tabIndex > containers.length) { + throw new IndexOutOfBoundsException("Error! Shop tab index out of bounds."); + } + return containers[tabIndex]; + } - /** - * Gets the viewers. - * @return The viewers. - */ - public List getViewers() { - return viewers; - } + /** + * Gets the viewers. + * + * @return The viewers. + */ + public List getViewers() { + return viewers; + } - /** - * Gets the title. - * @return The title. - */ - public String getTitle() { - return title; - } + /** + * Gets the title. + * + * @return The title. + */ + public String getTitle() { + return title; + } - /** - * Gets the items. - * @return The items. - */ - public Item[] getItems() { - return items; - } - - /** - * Sets the items. - * @return true if the items were changed. - */ - public boolean setItems(Item...item) { - return items == item; - } + /** + * Gets the items. + * + * @return The items. + */ + public Item[] getItems() { + return items; + } - /** - * Gets the general. - * @return The general. - */ - public boolean isGeneral() { - return general; - } + /** + * Sets the items. + * + * @return true if the items were changed. + */ + public boolean setItems(Item... item) { + return items == item; + } - /** - * Gets the currency. - * @return The currency. - */ - public int getCurrency() { - return currency; - } + /** + * Gets the general. + * + * @return The general. + */ + public boolean isGeneral() { + return general; + } - /** - * Gets the containers. - * @return The containers. - */ - public Container[] getContainers() { - return containers; - } + /** + * Gets the currency. + * + * @return The currency. + */ + public int getCurrency() { + return currency; + } - /** - * Gets the bhighAlch. - * @return the highAlch - */ - public boolean isHighAlch() { - return highAlch; - } + /** + * Gets the containers. + * + * @return The containers. + */ + public Container[] getContainers() { + return containers; + } - @Override - public String toString() { - return "Shop [containers=" + Arrays.toString(containers) + ", viewers=" + viewers + ", title=" + title + ", items=" + Arrays.toString(items) + ", general=" + general + ", currency=" + currency + ", highAlch=" + highAlch + "]"; - } + /** + * Gets the bhighAlch. + * + * @return the highAlch + */ + public boolean isHighAlch() { + return highAlch; + } - /** - * Gets the lastRestock. - * @return the lastRestock - */ - public int getLastRestock() { - return lastRestock; - } + @Override + public String toString() { + return "Shop [containers=" + Arrays.toString(containers) + ", viewers=" + viewers + ", title=" + title + ", items=" + Arrays.toString(items) + ", general=" + general + ", currency=" + currency + ", highAlch=" + highAlch + "]"; + } - /** - * Sets the balastRestock. - * @param lastRestock the lastRestock to set. - */ - public void setLastRestock(int lastRestock) { - this.lastRestock = lastRestock; - } + /** + * Gets the lastRestock. + * + * @return the lastRestock + */ + public int getLastRestock() { + return lastRestock; + } - /** - * Gets the npcs. - * @return the npcs - */ - public int[] getNpcs() { - return npcs; - } + /** + * Sets the balastRestock. + * + * @param lastRestock the lastRestock to set. + */ + public void setLastRestock(int lastRestock) { + this.lastRestock = lastRestock; + } + + /** + * Gets the npcs. + * + * @return the npcs + */ + public int[] getNpcs() { + return npcs; + } + + /** + * Sets the banpcs. + * + * @param npcs the npcs to set. + */ + public void setNpcs(int[] npcs) { + this.npcs = npcs; + } - /** - * Sets the banpcs. - * @param npcs the npcs to set. - */ - public void setNpcs(int[] npcs) { - this.npcs = npcs; - } - /** * Gets the pointShop. + * * @return the pointShop */ public boolean isPointShop() { - return pointShop; + return pointShop; } /** * Sets the pointShop. + * * @param pointShop the pointShop to set. */ public void setPointShop(boolean pointShop) { - this.pointShop = pointShop; + this.pointShop = pointShop; + } + + /** + * Check if shop should restock. + * + * @return the restock + */ + public boolean isRestock() { + return restock; + } + + /** + * Sets the restock. + * + * @param reStock + */ + public void setRestock(boolean reStock) { + restock = reStock; } - - /** - * Check if shop should restock. - * @return the restock - */ - public boolean isRestock() { - return restock; - } - - /** - * Sets the restock. - * @param reStock - */ - public void setRestock(boolean reStock) { - restock = reStock; - } - /** - * Gets the SellAllFor value. - * @return the sellAllFor - */ - public int getSellAllFor() { - return sellAllFor; - } + /** + * Gets the SellAllFor value. + * + * @return the sellAllFor + */ + public int getSellAllFor() { + return sellAllFor; + } } \ No newline at end of file diff --git a/09HDscape-server/src/org/crandor/game/content/global/shop/ShopViewer.java b/09HDscape-server/src/org/crandor/game/content/global/shop/ShopViewer.java index 7ed3d4b95..8e8095099 100644 --- a/09HDscape-server/src/org/crandor/game/content/global/shop/ShopViewer.java +++ b/09HDscape-server/src/org/crandor/game/content/global/shop/ShopViewer.java @@ -31,7 +31,7 @@ public final class ShopViewer { /** * Represents the shop being viewed. */ - private final Shop shop; + private Shop shop; /** * Represents the tab index. @@ -146,6 +146,7 @@ public final class ShopViewer { player.removeExtension(ShopViewer.class); viewer.getShop().getViewers().remove(viewer); player.getInterfaceManager().closeSingleTab(); + player.removeAttribute("spawning_items"); return true; } diff --git a/09HDscape-server/src/org/crandor/game/content/global/tutorial/TutorialStage.java b/09HDscape-server/src/org/crandor/game/content/global/tutorial/TutorialStage.java index e50e2394e..9c9722c71 100644 --- a/09HDscape-server/src/org/crandor/game/content/global/tutorial/TutorialStage.java +++ b/09HDscape-server/src/org/crandor/game/content/global/tutorial/TutorialStage.java @@ -65,7 +65,6 @@ public enum TutorialStage { player.getInterfaceManager().hideTabs(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13); ActivityManager.start(player, "ltr:dragon_fight_cs", false); } -// player.setAttribute("tut-island:hi_slot", HintIconManager.registerHintIcon(player, Repository.findNPC(945))); Component.setUnclosable(player, player.getDialogueInterpreter().sendPlaneMessageWithBlueTitle("Cutscenes", "There are moments in " + GameWorld.getName() + " that you cannot change what is", "going on you must simply watch to see what unfolds. Some call", "these 'cutscenes'. Watch the knight fight the dragon in this cutscene.", "")); } }, @@ -74,11 +73,13 @@ public enum TutorialStage { public void run(final Player player) { if (login) { player.getInterfaceManager().hideTabs(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13); + player.setAttribute("tut-island:hi_slot", HintIconManager.registerHintIcon(player, Repository.findNPC(7938), HintIconManager.DEFAULT_ARROW, HintIconManager.ARROW_CIRCLE_MODEL)); } else { removeHintIcon(player); } - player.setAttribute("tut-island:hi_slot", HintIconManager.registerHintIcon(player, Location.create(3098, 3107, 0), 1, -1, player.getHintIconManager().freeSlot(), 125, 3)); - Component.setUnclosable(player, player.getDialogueInterpreter().sendScrollMessageWithBlueTitle("Interacting with scenery", "You can interact with many items of scenery by simply clicking", "on them. Right clicking will also give more options. Feel free to", "try it with the things in this room, then click on the door", "indicated with the yellow arrow to go though to the next", "instructor.")); + player.getInterfaceManager().hideTabs(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13); + player.setAttribute("tut-island:hi_slot", HintIconManager.registerHintIcon(player, Repository.findNPC(7938), HintIconManager.DEFAULT_ARROW, HintIconManager.ARROW_CIRCLE_MODEL)); + Component.setUnclosable(player, player.getDialogueInterpreter().sendPlaneMessageWithBlueTitle("Combat!", TutorialStage.blue("Left-click") + "on the knight to talk to him about combat. I have", "put a flashing yellow arrow above his head. If you can't see", "him, use your keyboard's arrow keys to rotate your view.")); } }, STAGE_4(4) { @@ -86,12 +87,14 @@ public enum TutorialStage { public void run(final Player player) { if (login) { player.getInterfaceManager().hideTabs(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13); + player.setAttribute("tut-island:hi_slot", HintIconManager.registerHintIcon(player, Repository.findNPC(7938), HintIconManager.DEFAULT_ARROW, HintIconManager.ARROW_CIRCLE_MODEL)); } else { removeHintIcon(player); } - player.getConfigManager().set(406, 2); - player.setAttribute("tut-island:hi_slot", HintIconManager.registerHintIcon(player, Repository.findNPC(943))); - Component.setUnclosable(player, player.getDialogueInterpreter().sendPlaneMessageWithBlueTitle("Moving around", "Follow the path to find the next instructor. Clicking on the", "ground will walk you to that point. Talk to the Survival Expert by", "the pond to continue the tutorial. Remember you can rotate", "the view by pressing the arrow keys.")); + player.getInterfaceManager().hideTabs(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13); + player.setAttribute("tut-island:hi_slot", HintIconManager.registerHintIcon(player, Repository.findNPC(7938), HintIconManager.DEFAULT_ARROW, HintIconManager.ARROW_CIRCLE_MODEL)); + Component.setUnclosable(player, player.getDialogueInterpreter().sendScrollMessageWithBlueTitle( + "Getting started", "Now is the time for adventure!", "The story has humble beginnings: in a cellar, in fact. Talk to", "Sir Vant by " + TutorialStage.blue("left-clicking")+ " on him. He is indicated by a yellow", "arrow, flashing both above his head and on your minimap","in the top-right of the screen. If you can't see the", "knight, use your keyboard's " + TutorialStage.blue("arrow keys") + " to rotate","your viewpoint.")); } }, STAGE_5(5) { diff --git a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/BuildHotspot.java b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/BuildHotspot.java index eb4c04e13..fd9f6e571 100644 --- a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/BuildHotspot.java +++ b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/BuildHotspot.java @@ -395,6 +395,7 @@ public enum BuildHotspot { linkedHotspots.add(new BuildHotspot[] { DUNGEON_DOOR_LEFT, DUNGEON_DOOR_RIGHT }); linkedHotspots.add(new BuildHotspot[] { DUNGEON_DOOR_LEFT2, DUNGEON_DOOR_RIGHT2 }); linkedHotspots.add(new BuildHotspot[] { HABITAT_1, HABITAT_2 }); + linkedHotspots.add(new BuildHotspot[] { SMALL_PLANT_1, SMALL_PLANT1 }); } /** diff --git a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/BuildingUtils.java b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/BuildingUtils.java index 51e6ce8f6..dcd6a3959 100644 --- a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/BuildingUtils.java +++ b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/BuildingUtils.java @@ -1,9 +1,9 @@ package org.crandor.game.content.skill.member.construction; - import org.crandor.cache.def.impl.ItemDefinition; import org.crandor.game.component.Component; import org.crandor.game.content.skill.Skills; +import org.crandor.game.content.skill.member.construction.*; import org.crandor.game.node.entity.player.Player; import org.crandor.game.node.item.Item; import org.crandor.game.node.object.GameObject; @@ -34,26 +34,26 @@ public final class BuildingUtils { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST }; - /** + /** * The building a decoration animation. */ public static final Animation BUILD_LOW_ANIM = Animation.create(3683); - + /** * The building a decoration animation. */ public static final Animation BUILD_MID_ANIM = Animation.create(3676); - + /** * The building a decoration animation. */ public static final Animation BUILD_HIGH_ANIM = Animation.create(3684); - + /** * The planting animation. */ public static final Animation PLANT_ANIM = Animation.create(3691); - + /** * The removing a decoration animation. */ @@ -78,29 +78,33 @@ public final class BuildingUtils { */ public static void openBuildInterface(Player player, BuildHotspot hotspot) { player.getInterfaceManager().open(new Component(396)); - player.getPacketDispatch().sendInterSetItemsOptionsScript(396, 11, 8, 2, 4, "Build"); - player.getPacketDispatch().sendAccessMask(1278, 11, 396, 0, 7); Item[] items = new Item[7]; + + int c261Value = 0; + for (int i = 0; i < 7; i++) { - int offset = i * 5; + int itemsStringOffset = 97 + (i * 5); + + //97 + if (i >= hotspot.getDecorations().length || (hotspot.getDecorations()[i] != null && hotspot.getDecorations()[i].isInvisibleNode())) { - for (int j = 14; j < 19; j++) { - player.getPacketDispatch().sendString("", 396, j + offset); + for (int j = 0; j < 5; j++) { + player.getPacketDispatch().sendString("", 396, itemsStringOffset + j); } - player.getPacketDispatch().sendString("", 396, 56 + i); - player.getPacketDispatch().sendInterfaceConfig(396, 49 + i, true); + player.getPacketDispatch().sendString("", 396, 140 + i); + c261Value += (1 << (i + 1)); continue; } + Decoration decoration = hotspot.getDecorations()[i]; items[BUILD_INDEXES[i]] = new Item(decoration.getInterfaceItem()); - player.getPacketDispatch().sendString(ItemDefinition.forId(decoration.getInterfaceItem()).getName(), 396, 14 + offset); + player.getPacketDispatch().sendString(ItemDefinition.forId(decoration.getInterfaceItem()).getName(), 396, itemsStringOffset); boolean hasRequirements = player.getSkills().getLevel(Skills.CONSTRUCTION) >= decoration.getLevel(); for (int j = 0; j < 4; j++) { if (j >= decoration.getItems().length) { if (j == decoration.getItems().length && decoration.getNailAmount() > 0) { - player.getPacketDispatch().sendString("Nails: " + decoration.getNailAmount(), 396, 15 + offset + j); + player.getPacketDispatch().sendString("Nails: " + decoration.getNailAmount(), 396, (itemsStringOffset + 1) + j); } else { - player.getPacketDispatch().sendString("", 396, 15 + offset + j); + player.getPacketDispatch().sendString("", 396, (itemsStringOffset + 1) + j); } } else { Item item = decoration.getItems()[j]; @@ -108,25 +112,28 @@ public final class BuildingUtils { hasRequirements = false; } String s = item.getName() + ": " + item.getAmount(); - if (j > 1 && (decoration == Decoration.RUNE_CASE1 || decoration == Decoration.RUNE_CASE2)) { - if (j == 3) { - offset--; - item = decoration.getItems()[++j]; - s = item.getName() + ": " + item.getAmount(); - } - item = decoration.getItems()[j + 1]; - s += ", " + item.getName() + ": " + item.getAmount(); - player.getPacketDispatch().sendString(s, 396, 15 + offset + j); - continue; - } - player.getPacketDispatch().sendString(s, 396, 15 + offset + j); + /*if (j > 1 && (decoration == Decoration.RUNE_CASE1 || decoration == Decoration.RUNE_CASE2)) { + if (j == 3) { + offset--; + item = decoration.getItems()[++j]; + s = item.getName() + ": " + item.getAmount(); + } + item = decoration.getItems()[j + 1]; + s += ", " + item.getName() + ": " + item.getAmount(); + player.getPacketDispatch().sendString(s, 396, 15 + offset + j); + continue; + }*/ + player.getPacketDispatch().sendString(s, 396, (itemsStringOffset + 1) + j); + if (hasRequirements) + c261Value += (1 << (i + 1)); } } player.getConfigManager().set(1485 + i, hasRequirements || player.isStaff() ? 1 : 0); - player.getPacketDispatch().sendString("Lvl " + decoration.getLevel(), 396, 56 + i); + player.getPacketDispatch().sendString("Lvl " + decoration.getLevel(), 396, 140 + i); //player.getPacketDispatch().sendItemZoomOnInterface(items[i].protocol(), 50000, 396, 49 + i); } - PacketRepository.send(ContainerPacket.class, new ContainerContext(player, -1, -2, 8, items, false)); + player.getConfigManager().set(261, c261Value); + PacketRepository.send(ContainerPacket.class, new ContainerContext(player, 396, 132, 8, items, false)); } /** @@ -143,7 +150,7 @@ public final class BuildingUtils { * @param player The player. * @param deco The decoration. * @param object The object. - */ + */ public static void buildDecoration(final Player player, final Hotspot hotspot, final Decoration deco, final GameObject object) { final int nailAmount = deco.getNailAmount(); final NailType type = nailAmount > 0 ? NailType.get(player, nailAmount) : null; @@ -205,7 +212,7 @@ public final class BuildingUtils { } }); } - + /** * Sets a decoration for the given hotspot. * @param player The player. @@ -220,91 +227,91 @@ public final class BuildingUtils { HousingStyle style = player.getHouseManager().getStyle(); int decIndex = hotspot.getHotspot().getDecorationIndex(deco); switch(hotspot.getHotspot().getType()) { - case STAIRCASE: - int z = l.getZ(); - if (region == player.getHouseManager().getDungeonRegion()) { - z = 3; - } - for (int i = -1; i <= 1; i++) { - int plane = (z + (i == -1 ? 3 : i)) % 4; - Room r = player.getHouseManager().getRooms()[plane][l.getChunkX()][l.getChunkY()]; - if (r != null && r.getRotation() == room.getRotation() && !r.getProperties().isLand()) { - Hotspot h = r.getStairs(); - if (h != null) { - h.setDecorationIndex(decIndex); - Region reg = plane == 3 ? player.getHouseManager().getDungeonRegion() : player.getHouseManager().getRegion(); - if (reg == null) { - continue; - } - BuildRegionChunk chunk = (BuildRegionChunk) reg.getPlanes()[plane % 3].getChunks()[l.getChunkX()][l.getChunkY()]; - GameObject[] objects = chunk.getObjects(h.getCurrentX(), h.getCurrentY()); - for (GameObject o : objects) { - if (o != null && o.getType() == object.getType()) { - ObjectBuilder.replace(o, o.transform(h.getHotspot().getDecorations()[decIndex].getObjectId(style))); - System.err.println("Found stairs!"); - if (plane == 1) { - if (r.getProperties() == RoomProperties.SKILL_HALL) { - r.updateProperties(player, RoomProperties.SKILL_HALL_2); - } else if (r.getProperties() == RoomProperties.QUEST_HALL) { - r.updateProperties(player, RoomProperties.QUEST_HALL_2); - } - else { - break; - } - player.getHouseManager().reload(player, true); - } - break; - } - } - } else { - System.err.println("Couldn't find stairs! " + plane); - } + case STAIRCASE: + int z = l.getZ(); + if (region == player.getHouseManager().getDungeonRegion()) { + z = 3; } - } - break; - case CREST: - ObjectBuilder.replace(object, object.transform(deco.getObjectId(style) + player.getHouseManager().getCrest().ordinal())); - hotspot.setDecorationIndex(decIndex); - break; - case INDIVIDUAL: - ObjectBuilder.replace(object, object.transform(deco.getObjectId(style))); - hotspot.setDecorationIndex(decIndex); - break; - case RECURSIVE: - BuildRegionChunk chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()]; - for (int x = 0; x < 8; x++) { - for (int y = 0; y < 8; y++) { - Hotspot h = room.getHotspot(hotspot.getHotspot(), x, y); - if (h != null) { - h.setDecorationIndex(decIndex); - int objectId = hotspot.getHotspot().getObjectId(style); - GameObject o = chunk.get(x, y, chunk.getIndex(x, y, objectId)); - if (o != null && objectId == o.getId()) { - ObjectBuilder.replace(o, o.transform(hotspot.getHotspot().getDecorations()[decIndex].getObjectId(style))); - } - } - } - } - break; - case LINKED: - BuildHotspot[] linkedHotspots = BuildHotspot.getLinkedHotspots(hotspot.getHotspot()); - chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()]; - for (int x = 0; x < 8; x++) { - for (int y = 0; y < 8; y++) { - for (BuildHotspot bh : linkedHotspots) { - Hotspot h = room.getHotspot(bh, x, y); + for (int i = -1; i <= 1; i++) { + int plane = (z + (i == -1 ? 3 : i)) % 4; + Room r = player.getHouseManager().getRooms()[plane][l.getChunkX()][l.getChunkY()]; + if (r != null && r.getRotation() == room.getRotation() && !r.getProperties().isLand()) { + Hotspot h = r.getStairs(); if (h != null) { h.setDecorationIndex(decIndex); - int objectId = bh.getObjectId(style); + Region reg = plane == 3 ? player.getHouseManager().getDungeonRegion() : player.getHouseManager().getRegion(); + if (reg == null) { + continue; + } + BuildRegionChunk chunk = (BuildRegionChunk) reg.getPlanes()[plane % 3].getChunks()[l.getChunkX()][l.getChunkY()]; + GameObject[] objects = chunk.getObjects(h.getCurrentX(), h.getCurrentY()); + for (GameObject o : objects) { + if (o != null && o.getType() == object.getType()) { + ObjectBuilder.replace(o, o.transform(h.getHotspot().getDecorations()[decIndex].getObjectId(style))); + System.err.println("Found stairs!"); + if (plane == 1) { + if (r.getProperties() == RoomProperties.SKILL_HALL) { + r.updateProperties(player, RoomProperties.SKILL_HALL_2); + } else if (r.getProperties() == RoomProperties.QUEST_HALL) { + r.updateProperties(player, RoomProperties.QUEST_HALL_2); + } + else { + break; + } + player.getHouseManager().reload(player, true); + } + break; + } + } + } else { + System.err.println("Couldn't find stairs! " + plane); + } + } + } + break; + case CREST: + ObjectBuilder.replace(object, object.transform(deco.getObjectId(style) + player.getHouseManager().getCrest().ordinal())); + hotspot.setDecorationIndex(decIndex); + break; + case INDIVIDUAL: + ObjectBuilder.replace(object, object.transform(deco.getObjectId(style))); + hotspot.setDecorationIndex(decIndex); + break; + case RECURSIVE: + BuildRegionChunk chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()]; + for (int x = 0; x < 8; x++) { + for (int y = 0; y < 8; y++) { + Hotspot h = room.getHotspot(hotspot.getHotspot(), x, y); + if (h != null) { + h.setDecorationIndex(decIndex); + int objectId = hotspot.getHotspot().getObjectId(style); GameObject o = chunk.get(x, y, chunk.getIndex(x, y, objectId)); if (o != null && objectId == o.getId()) { - ObjectBuilder.replace(o, o.transform(bh.getDecorations()[decIndex].getObjectId(style))); + ObjectBuilder.replace(o, o.transform(hotspot.getHotspot().getDecorations()[decIndex].getObjectId(style))); } } } } - } - break; + break; + case LINKED: + BuildHotspot[] linkedHotspots = BuildHotspot.getLinkedHotspots(hotspot.getHotspot()); + chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()]; + for (int x = 0; x < 8; x++) { + for (int y = 0; y < 8; y++) { + for (BuildHotspot bh : linkedHotspots) { + Hotspot h = room.getHotspot(bh, x, y); + if (h != null) { + h.setDecorationIndex(decIndex); + int objectId = bh.getObjectId(style); + GameObject o = chunk.get(x, y, chunk.getIndex(x, y, objectId)); + if (o != null && objectId == o.getId()) { + ObjectBuilder.replace(o, o.transform(bh.getDecorations()[decIndex].getObjectId(style))); + } + } + } + } + } + break; } } @@ -352,112 +359,111 @@ public final class BuildingUtils { private static void removeDecoration(Player player, Region region, Room room, Hotspot hotspot, GameObject object, HousingStyle style) { Location l = object.getLocation(); switch (hotspot.getHotspot().getType()) { - case STAIRCASE: - int z = l.getZ(); - if (region == player.getHouseManager().getDungeonRegion()) { - z = 3; - } - for (int i = -1; i <= 1; i++) { - int plane = (z + (i == -1 ? 3 : i)) % 4; - Room r = player.getHouseManager().getRooms()[plane][l.getChunkX()][l.getChunkY()]; - if (r != null && r.getRotation() == room.getRotation()) { - Hotspot h = r.getStairs(); - if (h != null) { - h.setDecorationIndex(-1); - Region reg = plane == 3 ? player.getHouseManager().getDungeonRegion() : player.getHouseManager().getRegion(); - if (reg == null) { - continue; - } - BuildRegionChunk chunk = (BuildRegionChunk) reg.getPlanes()[plane % 3].getChunks()[l.getChunkX()][l.getChunkY()]; - GameObject[] objects = chunk.getObjects(h.getCurrentX(), h.getCurrentY()); - for (GameObject o : objects) { - if (o != null && o.getType() == object.getType()) { - ObjectBuilder.replace(o, o.transform(h.getHotspot().getObjectId(style))); - break; - } - } - } else { - System.err.println("Couldn't find stairs! " + plane); - } + case STAIRCASE: + int z = l.getZ(); + if (region == player.getHouseManager().getDungeonRegion()) { + z = 3; } - } - if (l.getZ() == 1) { - if (room.getProperties() == RoomProperties.SKILL_HALL_2) { - room.updateProperties(player, RoomProperties.SKILL_HALL); - } - else if (room.getProperties() == RoomProperties.QUEST_HALL_2) { - room.updateProperties(player, RoomProperties.QUEST_HALL); - } - else { - break; - } - player.getHouseManager().reload(player, true); - } - break; - case INDIVIDUAL: - case CREST: - ObjectBuilder.replace(object, object.transform(hotspot.getHotspot().getObjectId(style))); - hotspot.setDecorationIndex(-1); - break; - case RECURSIVE: - BuildRegionChunk chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()]; - for (int x = 0; x < 8; x++) { - for (int y = 0; y < 8; y++) { - Hotspot h = room.getHotspot(hotspot.getHotspot(), x, y); - if (h != null) { - int objectId = hotspot.getHotspot().getDecorations()[h.getDecorationIndex()].getObjectId(style); - GameObject o = chunk.get(x, y, chunk.getIndex(x, y, objectId)); - h.setDecorationIndex(-1); - if (o != null && objectId == o.getId()) { - ObjectBuilder.replace(o, o.transform(hotspot.getHotspot().getObjectId(style))); - } - } - } - } - break; - case LINKED: - BuildHotspot[] linkedHotspots = BuildHotspot.getLinkedHotspots(hotspot.getHotspot()); - chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()]; - for (int x = 0; x < 8; x++) { - for (int y = 0; y < 8; y++) { - for (BuildHotspot bh : linkedHotspots) { - Hotspot h = room.getHotspot(bh, x, y); + for (int i = -1; i <= 1; i++) { + int plane = (z + (i == -1 ? 3 : i)) % 4; + Room r = player.getHouseManager().getRooms()[plane][l.getChunkX()][l.getChunkY()]; + if (r != null && r.getRotation() == room.getRotation()) { + Hotspot h = r.getStairs(); if (h != null) { - int objectId = bh.getDecorations()[h.getDecorationIndex()].getObjectId(style); + h.setDecorationIndex(-1); + Region reg = plane == 3 ? player.getHouseManager().getDungeonRegion() : player.getHouseManager().getRegion(); + if (reg == null) { + continue; + } + BuildRegionChunk chunk = (BuildRegionChunk) reg.getPlanes()[plane % 3].getChunks()[l.getChunkX()][l.getChunkY()]; + GameObject[] objects = chunk.getObjects(h.getCurrentX(), h.getCurrentY()); + for (GameObject o : objects) { + if (o != null && o.getType() == object.getType()) { + ObjectBuilder.replace(o, o.transform(h.getHotspot().getObjectId(style))); + break; + } + } + } else { + System.err.println("Couldn't find stairs! " + plane); + } + } + } + if (l.getZ() == 1) { + if (room.getProperties() == RoomProperties.SKILL_HALL_2) { + room.updateProperties(player, RoomProperties.SKILL_HALL); + } + else if (room.getProperties() == RoomProperties.QUEST_HALL_2) { + room.updateProperties(player, RoomProperties.QUEST_HALL); + } + else { + break; + } + player.getHouseManager().reload(player, true); + } + break; + case INDIVIDUAL: + case CREST: + ObjectBuilder.replace(object, object.transform(hotspot.getHotspot().getObjectId(style))); + hotspot.setDecorationIndex(-1); + break; + case RECURSIVE: + BuildRegionChunk chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()]; + for (int x = 0; x < 8; x++) { + for (int y = 0; y < 8; y++) { + Hotspot h = room.getHotspot(hotspot.getHotspot(), x, y); + if (h != null) { + int objectId = hotspot.getHotspot().getDecorations()[h.getDecorationIndex()].getObjectId(style); GameObject o = chunk.get(x, y, chunk.getIndex(x, y, objectId)); h.setDecorationIndex(-1); if (o != null && objectId == o.getId()) { - ObjectBuilder.replace(o, o.transform(bh.getObjectId(style))); + ObjectBuilder.replace(o, o.transform(hotspot.getHotspot().getObjectId(style))); } } } } - } - break; + break; + case LINKED: + BuildHotspot[] linkedHotspots = BuildHotspot.getLinkedHotspots(hotspot.getHotspot()); + chunk = (BuildRegionChunk) region.getPlanes()[l.getZ()].getChunks()[l.getChunkX()][l.getChunkY()]; + for (int x = 0; x < 8; x++) { + for (int y = 0; y < 8; y++) { + for (BuildHotspot bh : linkedHotspots) { + Hotspot h = room.getHotspot(bh, x, y); + if (h != null) { + int objectId = bh.getDecorations()[h.getDecorationIndex()].getObjectId(style); + GameObject o = chunk.get(x, y, chunk.getIndex(x, y, objectId)); + h.setDecorationIndex(-1); + if (o != null && objectId == o.getId()) { + ObjectBuilder.replace(o, o.transform(bh.getObjectId(style))); + } + } + } + } + } + break; } } /** * Checks if the decoration can be built. * @param player The player. - * @param hotspot The hotspot. * @param deco The decoration. * @param object The object. * @return {@code True} if so. */ private static boolean canBuildDecoration(Player player, Room room, Decoration deco, GameObject object) { switch (deco) { - case TENTACLE_MID: - case TENTACLE_SIDE: - case TENTACLE_CORNER: - case TENTACLE_FL: - if (!room.isBuilt(BuildHotspot.PRISON)) { - player.getPacketDispatch().sendMessage("You can't build a tentacle pool without a cage."); - return false; - } - return true; - default: - return true; + case TENTACLE_MID: + case TENTACLE_SIDE: + case TENTACLE_CORNER: + case TENTACLE_FL: + if (!room.isBuilt(BuildHotspot.PRISON)) { + player.getPacketDispatch().sendMessage("You can't build a tentacle pool without a cage."); + return false; + } + return true; + default: + return true; } } @@ -465,7 +471,6 @@ public final class BuildingUtils { * Checks if the decoration can be built. * @param player The player. * @param hotspot The hotspot. - * @param deco The decoration. * @param object The object. * @return {@code True} if so. */ @@ -474,27 +479,27 @@ public final class BuildingUtils { Location l = object.getLocation(); int z = l.getZ(); switch (hotspot.getHotspot()) { - case STAIRWAYS: - case QUEST_STAIRWAYS: - case STAIRWAYS_DUNGEON: - BuildHotspot[] stairs = { BuildHotspot.STAIRS_DOWN, BuildHotspot.STAIRS_DOWN2, BuildHotspot.STAIRWAYS, BuildHotspot.QUEST_STAIRWAYS, BuildHotspot.STAIRWAYS_DUNGEON }; - for (int i = 0; i < 2; i++) { - int plane = (z + 1 + (i * 2)) % 4; - Room r = player.getHouseManager().getRooms()[plane][l.getChunkX()][l.getChunkY()]; - if (r != null) { - for (BuildHotspot h : stairs) { - Hotspot hs = r.getHotspot(h, hotspot.getCurrentX(), hotspot.getCurrentY()); - if (hs != null) { - hs.setDecorationIndex(decorationIndex); - ObjectBuilder.replace(object, object.transform(h.getDecorations()[decorationIndex].getObjectId(player.getHouseManager().getStyle()))); - break; + case STAIRWAYS: + case QUEST_STAIRWAYS: + case STAIRWAYS_DUNGEON: + BuildHotspot[] stairs = { BuildHotspot.STAIRS_DOWN, BuildHotspot.STAIRS_DOWN2, BuildHotspot.STAIRWAYS, BuildHotspot.QUEST_STAIRWAYS, BuildHotspot.STAIRWAYS_DUNGEON }; + for (int i = 0; i < 2; i++) { + int plane = (z + 1 + (i * 2)) % 4; + Room r = player.getHouseManager().getRooms()[plane][l.getChunkX()][l.getChunkY()]; + if (r != null) { + for (BuildHotspot h : stairs) { + Hotspot hs = r.getHotspot(h, hotspot.getCurrentX(), hotspot.getCurrentY()); + if (hs != null) { + hs.setDecorationIndex(decorationIndex); + ObjectBuilder.replace(object, object.transform(h.getDecorations()[decorationIndex].getObjectId(player.getHouseManager().getStyle()))); + break; + } } } } - } - return true; - default: - return true; + return true; + default: + return true; } } @@ -502,8 +507,7 @@ public final class BuildingUtils { * Builds a room. * @param player The player. * @param room The room to build. - * @param reload - * @param door The door hotspot. + * @param reload */ public static void buildRoom(Player player, Room room, int z, int x, int y, boolean[] exits, boolean reload) { player.getHouseManager().getRooms()[z][x][y] = room; @@ -574,19 +578,19 @@ public final class BuildingUtils { public static int[] getRoomPosition(Player player, GameObject door) { Location l = door.getLocation(); int rotation = door.getRotation(); - if (player.getLocation().getChunkX() != l.getLocation().getChunkX() + if (player.getLocation().getChunkX() != l.getLocation().getChunkX() || player.getLocation().getChunkY() != l.getLocation().getChunkY()) { return new int[] { l.getChunkX(), l.getChunkY() }; } switch (rotation) { - case 0: //West - return new int[] { l.getChunkX() - 1, l.getChunkY() }; - case 1: //North - return new int[] { l.getChunkX(), l.getChunkY() + 1}; - case 2: //East - return new int[] { l.getChunkX() + 1, l.getChunkY() }; - case 3: //South - return new int[] { l.getChunkX(), l.getChunkY() - 1}; + case 0: //West + return new int[] { l.getChunkX() - 1, l.getChunkY() }; + case 1: //North + return new int[] { l.getChunkX(), l.getChunkY() + 1}; + case 2: //East + return new int[] { l.getChunkX() + 1, l.getChunkY() }; + case 3: //South + return new int[] { l.getChunkX(), l.getChunkY() - 1}; } return null; } diff --git a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/HouseLocation.java b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/HouseLocation.java index b4ced89ab..d9392c1b0 100644 --- a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/HouseLocation.java +++ b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/HouseLocation.java @@ -1,7 +1,10 @@ package org.crandor.game.content.skill.member.construction; +import org.crandor.game.content.skill.Skills; +import org.crandor.game.node.entity.player.Player; import org.crandor.game.world.map.Location; +import org.crandor.tools.StringUtils; /** * The house locations. @@ -91,6 +94,16 @@ public enum HouseLocation { HOUSE_OPTIONS.addPage(new Page(pageActions)); }*/ } + + /** + * Checks if the player has the level. + * + * @param player the player. + * @return {@code True} if so. + */ + public boolean hasLevel(Player player) { + return player.getSkills().getStaticLevel(Skills.CONSTRUCTION) >= levelRequirement; + } /** * Constructs a new {@code HouseLocation} {@code Object} @@ -103,6 +116,15 @@ public enum HouseLocation { this.cost = cost; this.levelRequirement = levelRequirement; } + /** + * Gets the name formatted. + * + * @return the formatted name. + */ + public String getName() { + return StringUtils.formatDisplayName(name().toLowerCase()); + } + /** * Gets the portalId. diff --git a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/HouseZone.java b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/HouseZone.java index fb0c744e8..7b51ae254 100644 --- a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/HouseZone.java +++ b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/HouseZone.java @@ -8,60 +8,71 @@ import org.crandor.game.world.map.zone.ZoneRestriction; /** * Handles the player owned house zone. - * @author Emperor * + * @author Emperor */ public final class HouseZone extends MapZone { - /** - * The house manager. - */ - private HouseManager house; - - /** - * The previous house region id. - */ - private int previousRegion = -1; - - /** - * The previous dungeon region id. - */ - private int previousDungeon = -1; + /** + * The house manager. + */ + private HouseManager house; - /** - * Constructs the house zone object. - */ - public HouseZone(HouseManager house) { - super("poh-zone" + house, true, ZoneRestriction.RANDOM_EVENTS, ZoneRestriction.FOLLOWERS); - this.house = house; - } + /** + * The previous house region id. + */ + private int previousRegion = -1; - @Override - public void configure() { - if (previousRegion != -1) { - unregisterRegion(previousRegion); - } - if (previousDungeon != -1) { - unregisterRegion(previousDungeon); - } - registerRegion(house.getRegion().getId()); - if (house.getDungeonRegion() != null) { - registerRegion(house.getRegion().getId()); - } - } - - @Override - public boolean enter(Entity e) { - return super.enter(e); - } - - @Override - public boolean death(Entity e, Entity killer) { - if (e instanceof Player) { - Player p = (Player) e; - HouseManager.leave(p); - } - return true; - } + /** + * The previous dungeon region id. + */ + private int previousDungeon = -1; + /** + * Constructs the house zone object. + */ + public HouseZone(HouseManager house) { + super("poh-zone" + house, true, ZoneRestriction.RANDOM_EVENTS, ZoneRestriction.FOLLOWERS); + this.house = house; + } + + @Override + public void configure() { + if (previousRegion != -1) { + unregisterRegion(previousRegion); + } + if (previousDungeon != -1) { + unregisterRegion(previousDungeon); + } + registerRegion(house.getRegion().getId()); + if (house.getDungeonRegion() != null) { + registerRegion(house.getRegion().getId()); + } + } + + @Override + public boolean enter(Entity e) { + return super.enter(e); + } + + @Override + public boolean death(Entity e, Entity killer) { + if (e instanceof Player) { + Player p = (Player) e; + HouseManager.leave(p); + } + return true; + } + + @Override + public boolean leave(Entity e, boolean logout) { + if (logout) { + if (e instanceof Player) { + Player p = (Player) e; + HouseManager.leave(p); + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/RoomProperties.java b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/RoomProperties.java index 8915a5df6..f84af7ed1 100644 --- a/09HDscape-server/src/org/crandor/game/content/skill/member/construction/RoomProperties.java +++ b/09HDscape-server/src/org/crandor/game/content/skill/member/construction/RoomProperties.java @@ -376,12 +376,12 @@ public enum RoomProperties { /** * Study. */ - Menagerie(30000, 37, 0, 7, 2, Room.LAND, +/* Menagerie(30000, 37, 0, 7, 2, Room.LAND, new Hotspot(BuildHotspot.PET_HOUSE, 1, 1), new Hotspot(BuildHotspot.PET_FEEDER, 5, 1), new Hotspot(BuildHotspot.OBELISK, 5, 5), new Hotspot(BuildHotspot.HABITAT_2, 1, 5), - new Hotspot(BuildHotspot.HABITAT_1, 6, 6)), + new Hotspot(BuildHotspot.HABITAT_1, 6, 6)),*/ /** * Study. @@ -514,13 +514,18 @@ public enum RoomProperties { new Hotspot(BuildHotspot.SMALL_PLANT2, 1, 2), new Hotspot(BuildHotspot.SMALL_PLANT2, 5, 6), new Hotspot(BuildHotspot.SMALL_PLANT2, 6, 5), + new Hotspot(BuildHotspot.SMALL_PLANT2, 2, 6), + new Hotspot(BuildHotspot.SMALL_PLANT2, 1, 5), new Hotspot(BuildHotspot.BIG_PLANT2, 1, 1), new Hotspot(BuildHotspot.BIG_PLANT2, 6, 6), + new Hotspot(BuildHotspot.BIG_PLANT2, 1, 6), new Hotspot(BuildHotspot.SMALL_PLANT1, 5, 1), new Hotspot(BuildHotspot.SMALL_PLANT1, 6, 2), new Hotspot(BuildHotspot.SMALL_PLANT1, 1, 5), + new Hotspot(BuildHotspot.SMALL_PLANT1, 2, 1), new Hotspot(BuildHotspot.SMALL_PLANT1, 2, 6), new Hotspot(BuildHotspot.BIG_PLANT1, 1, 6), + new Hotspot(BuildHotspot.BIG_PLANT1, 1, 1), new Hotspot(BuildHotspot.BIG_PLANT1, 6, 1)), /** diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/Player.java b/09HDscape-server/src/org/crandor/game/node/entity/player/Player.java index 59992bee0..616ae8d00 100644 --- a/09HDscape-server/src/org/crandor/game/node/entity/player/Player.java +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/Player.java @@ -77,6 +77,8 @@ 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; @@ -248,6 +250,7 @@ public class Player extends Entity { */ private final HunterManager hunterManager = new HunterManager(this); + private final PlayerListPulse playerListPulse = new PlayerListPulse(this); /** * The treasure trail manager. @@ -274,6 +277,7 @@ public class Player extends Entity { */ private final IronmanManager ironmanManager = new IronmanManager(this); + private final Controller controller = new Controller(this); /** * The logout plugins. @@ -1257,6 +1261,13 @@ public class Player extends Entity { this.skillTasks = skillTasks; } + public Controller getController() { + return controller; + } + + public PlayerListPulse getPlayerListPulse() { + return playerListPulse; + } @Override diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/GlobalAIManager.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/GlobalAIManager.java new file mode 100644 index 000000000..5fe57c9d9 --- /dev/null +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/GlobalAIManager.java @@ -0,0 +1,33 @@ +package org.crandor.game.node.entity.player.ai.system; + + +import org.crandor.game.node.entity.player.ai.AIPlayer; +import org.crandor.game.world.repository.NodeList; + +import java.util.HashMap; +import java.util.Map; + +public class GlobalAIManager { + + + /** + * The active Artificial intelligent players mapping. + */ + private static final Map BOT_MAPPING = new HashMap<>(); + + + /** + * Constructs a new {@code GlobalAIManager} {@code Object}. + */ + public GlobalAIManager() { + + } + + public static void addBot(int uid, AIPlayer player) { + BOT_MAPPING.put(uid, player); + } + + public static AIPlayer getBot(int uid) { + return BOT_MAPPING.get(uid); + } +} diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/android/CombatDroid.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/android/CombatDroid.java new file mode 100644 index 000000000..659434efd --- /dev/null +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/android/CombatDroid.java @@ -0,0 +1,4 @@ +package org.crandor.game.node.entity.player.ai.system.android; + +public class CombatDroid { +} diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/android/GatheringDroid.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/android/GatheringDroid.java new file mode 100644 index 000000000..fbcd99285 --- /dev/null +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/android/GatheringDroid.java @@ -0,0 +1,4 @@ +package org.crandor.game.node.entity.player.ai.system.android; + +public class GatheringDroid { +} diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/predicate/Predicate.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/predicate/Predicate.java new file mode 100644 index 000000000..df23a0b34 --- /dev/null +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/predicate/Predicate.java @@ -0,0 +1,102 @@ +package org.crandor.game.node.entity.player.ai.system.predicate; + +import javax.security.auth.Destroyable; + +import org.crandor.game.node.entity.player.ai.system.GlobalAIManager; + +/** + * An android predicate. + * + * @author Viper + * @version 1.0 - 13/07/2016 + */ +public abstract class Predicate implements Cloneable, Runnable, Destroyable { + + protected GlobalAIManager bot; + + /** + * Predicate started. + */ + private boolean started; + + /** + * The predicate priority factor. + */ + private byte priority; + + /** + * The predicate type. + */ + public abstract PredicateType getType(); + + /** + * Constructs a new {@link Predicate} {@code Object}. + * + * @param priority + * The priority of this predicate. + */ + public Predicate(int priority) { + this.priority = (byte) priority; + } + + public Predicate clone() { + final Predicate pred = this; + return new Predicate(priority) { + + @Override + public void run() { + pred.run(); + } + + @Override + public PredicateType getType() { + return pred.getType(); + } + }.setStarted(pred.started); + } + + /** + * @return the priority + */ + public byte getPriority() { + return priority; + } + + /** + * @param priority the priority to set + */ + public void setPriority(byte priority) { + this.priority = priority; + } + + /** + * @return the bot + */ + public GlobalAIManager getBot() { + return bot; + } + + /** + * @param bot the bot to set + */ + public Predicate setBot(GlobalAIManager bot) { + this.bot = bot; + return this; + } + + /** + * @return the started + */ + public boolean hasStarted() { + return started; + } + + /** + * @param started the started to set + */ + public Predicate setStarted(boolean started) { + this.started = started; + return this; + } + +} \ No newline at end of file diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/predicate/PredicateType.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/predicate/PredicateType.java new file mode 100644 index 000000000..3a8872939 --- /dev/null +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/predicate/PredicateType.java @@ -0,0 +1,13 @@ +package org.crandor.game.node.entity.player.ai.system.predicate; + +/** + * Types of predicates. + * + * @author Viper + * @version 1.0 - 13/07/2016 + */ +public enum PredicateType { + + BOOT, TRANSCENDING, PARSING, TRIVIAL; + +} \ No newline at end of file diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/predicate/impl/AppearancePredicate.java b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/predicate/impl/AppearancePredicate.java new file mode 100644 index 000000000..8bff25312 --- /dev/null +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/ai/system/predicate/impl/AppearancePredicate.java @@ -0,0 +1,60 @@ +package org.crandor.game.node.entity.player.ai.system.predicate.impl; + + +import org.crandor.game.node.entity.player.ai.system.predicate.Predicate; +import org.crandor.game.node.entity.player.ai.system.predicate.PredicateType; + +/** + * Generates random appearance for the droid. + * + * @author Viper + * @version 1.0 - 13/07/2016 + */ +public class AppearancePredicate extends Predicate { + + /** + * If the bot is a male. + */ + private boolean male; + + /** + * Constructs a new appearance predicate. + */ + public AppearancePredicate(boolean male) { + super(-1); + this.male = male; + } + + @Override + public PredicateType getType() { + return PredicateType.PARSING; + } + + @Override + public void run() { + if (isMale()) { + /*bot.getAppearence().getBodyStyle()[0] = Utility.random(0, 8); + bot.getAppearence().getBodyStyle()[1] = Utility.random(10, 17); + bot.getAppearence().getBodyStyle()[2] = Utility.random(18, 25); + bot.getAppearence().getBodyStyle()[3] = Utility.random(26, 32); + bot.getAppearence().getBodyStyle()[4] = Utility.random(33, 34); + bot.getAppearence().getBodyStyle()[5] = Utility.random(36, 41); + bot.getAppearence().getBodyStyle()[6] = Utility.random(42, 44); + + bot.getAppearence().getBodyColors()[2] = (byte) Utility.random(0, 127); + bot.getAppearence().getBodyColors()[1] = (byte) Utility.random(0, 127); + bot.getAppearence().getBodyColors()[0] = (byte) Utility.random(0, 24);*/ + } else { + + } +// bot.getAppearence().generateAppearenceData(); + } + + /** + * @return the male + */ + public boolean isMale() { + return male; + } + +} \ No newline at end of file diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/info/login/LoginConfiguration.java b/09HDscape-server/src/org/crandor/game/node/entity/player/info/login/LoginConfiguration.java index 5fd411e74..ea35fa608 100644 --- a/09HDscape-server/src/org/crandor/game/node/entity/player/info/login/LoginConfiguration.java +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/info/login/LoginConfiguration.java @@ -86,9 +86,7 @@ public final class LoginConfiguration { int random = RandomFunction.getRandom(50); if(player.getUsername().equalsIgnoreCase("ethan")) player.getDetails().setRights(Rights.ADMINISTRATOR); - if(player.getUsername().equalsIgnoreCase("amber")) - player.getDetails().setRights(Rights.ADMINISTRATOR); - + Repository.getLobbyPlayers().add(player); player.getPacketDispatch().sendString(getLastLogin(player), 378, 116); player.getPacketDispatch().sendString("Welcome to " + GameWorld.getName(), 378, 115); @@ -128,7 +126,7 @@ public final class LoginConfiguration { * @param player The player to send to. */ public static void sendGameConfiguration(final Player player) { - TutorialSession.getExtension(player).setStage(TutorialSession.MAX_STAGE); + TutorialSession.getExtension(player).setStage(0); player.setAttribute("tut-island", true); player.getInterfaceManager().openWindowsPane(new Component(player.getInterfaceManager().isResizable() ? 746 : 548)); player.getInterfaceManager().openChatbox(137); diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/link/InterfaceManager.java b/09HDscape-server/src/org/crandor/game/node/entity/player/link/InterfaceManager.java index 887b0ced6..cad298d8f 100644 --- a/09HDscape-server/src/org/crandor/game/node/entity/player/link/InterfaceManager.java +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/link/InterfaceManager.java @@ -119,6 +119,16 @@ public final class InterfaceManager { return windowsPane; } + public void openWindowsPane(Component windowsPane, int type) { + this.windowsPane = windowsPane; + if (windowsPane.getDefinition().getType() != InterfaceType.WINDOW_PANE) { + System.err.println("Set interface type to WINDOW_PANE for component " + windowsPane.getId() + ", definition requires updating!"); + windowsPane.getDefinition().setType(InterfaceType.SINGLE_TAB); + } + PacketRepository.send(WindowsPane.class, new WindowsPaneContext(player, windowsPane.getId(), type)); + windowsPane.open(player); + } + /** * Opens a component. * diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/link/PacketDispatch.java b/09HDscape-server/src/org/crandor/game/node/entity/player/link/PacketDispatch.java index abe0ff683..404ca6f91 100644 --- a/09HDscape-server/src/org/crandor/game/node/entity/player/link/PacketDispatch.java +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/link/PacketDispatch.java @@ -136,8 +136,8 @@ public final class PacketDispatch { * @param id The id to set. * @param value The value of the config. */ - public void sendScriptConfig(int id, int value) { - PacketRepository.send(CSConfigPacket.class, new CSConfigContext(player, id, value)); + public void sendScriptConfig(int id, int value, String types, Object... parameters) { + PacketRepository.send(CSConfigPacket.class, new CSConfigContext(player, id, value, types, parameters)); } /** @@ -370,6 +370,10 @@ public final class PacketDispatch { public void sendGraphic(int id, int height) { player.getUpdateMasks().register(new GraphicFlag(new Graphics(id, height))); } + public void sendVarClient(int id, int value, boolean cs2) { + PacketRepository.send(Config.class, new ConfigContext(player, id, value, cs2)); + } + /** * Gets the player. diff --git a/09HDscape-server/src/org/crandor/game/node/entity/player/link/TeleportManager.java b/09HDscape-server/src/org/crandor/game/node/entity/player/link/TeleportManager.java index 0c5ccd0be..5c8607f81 100644 --- a/09HDscape-server/src/org/crandor/game/node/entity/player/link/TeleportManager.java +++ b/09HDscape-server/src/org/crandor/game/node/entity/player/link/TeleportManager.java @@ -363,7 +363,7 @@ public class TeleportManager { stop(); return; } - if (player.getSavedData().getGlobalData().getHomeTeleportDelay() > System.currentTimeMillis() && !player.isDonator()) { + /*if (player.getSavedData().getGlobalData().getHomeTeleportDelay() > System.currentTimeMillis() && !player.isDonator()) { long milliseconds = player.getSavedData().getGlobalData().getHomeTeleportDelay() - System.currentTimeMillis(); int minutes = (int) Math.round(milliseconds / 120000); if (minutes > 15) { @@ -376,7 +376,7 @@ public class TeleportManager { stop(); return; } - } + }*/ super.start(); } diff --git a/09HDscape-server/src/org/crandor/game/system/mysql/impl/NPCSpawnSQLHandler.java b/09HDscape-server/src/org/crandor/game/system/mysql/impl/NPCSpawnSQLHandler.java index ea1d4520f..f6aff9ef7 100644 --- a/09HDscape-server/src/org/crandor/game/system/mysql/impl/NPCSpawnSQLHandler.java +++ b/09HDscape-server/src/org/crandor/game/system/mysql/impl/NPCSpawnSQLHandler.java @@ -9,138 +9,231 @@ import org.crandor.game.system.mysql.SQLManager; import org.crandor.game.world.map.Direction; import org.crandor.game.world.map.Location; import org.crandor.tools.TimeStamp; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import java.io.FileWriter; +import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; /** * Handles the spawning of NPC's. - * @author Vexia * + * @author Vexia */ public class NPCSpawnSQLHandler extends SQLEntryHandler { - /** - * The current npc being spawned. - */ - private NPC npc; + private ArrayList NPC_SPAWNS = new ArrayList<>(); + private ArrayList REGIONS = new ArrayList<>(); - /** - * Constructs a new {@Code NPCSpawnSqlHandler} {@Code Object} - */ - public NPCSpawnSQLHandler() { - super(null, (SQLManager.LOCAL ? "server" : ServerConstants.DATABASE_NAMES[0]) + ".npc_spawns", "", ""); - } + /** + * The current npc being spawned. + */ + private NPC npc; - /** - * Constructs a new {@Code NPCSpawnSqlHandler} {@Code Object} - * @param entry the entry. - * @param table the table. - * @param column the column. - * @param value the value. - */ - public NPCSpawnSQLHandler(NPC entry, String table, String column, String value) { - super(entry, (SQLManager.LOCAL ? "server" : ServerConstants.DATABASE_NAMES[0]) + ".npc_spawns", "npc_id", "" + entry.getId()); - } + /** + * Constructs a new {@Code NPCSpawnSqlHandler} {@Code Object} + */ + public NPCSpawnSQLHandler() { + super(null, (SQLManager.LOCAL ? "server" : ServerConstants.DATABASE_NAMES[0]) + ".npc_spawns", "", ""); + } - /** - * Runs the NPC Spawn SQL handler. - * @param args the args. - * @throws SQLException the exception if thrown. - */ - public static void main(String... args) throws SQLException { - Cache.init(); - TimeStamp stamp = new TimeStamp(); - new NPCSpawnSQLHandler().parse(); - stamp.duration(true, ""); - } + /** + * Constructs a new {@Code NPCSpawnSqlHandler} {@Code Object} + * + * @param entry the entry. + * @param table the table. + * @param column the column. + * @param value the value. + */ + public NPCSpawnSQLHandler(NPC entry, String table, String column, String value) { + super(entry, (SQLManager.LOCAL ? "server" : ServerConstants.DATABASE_NAMES[0]) + ".npc_spawns", "npc_id", "" + entry.getId()); + } - @Override - public void parse() throws SQLException { - connection = getConnection(); - if (connection == null) { - SQLManager.close(connection); - return; - } - PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + (SQLManager.LOCAL ? "server" : ServerConstants.DATABASE_NAMES[0]) + ".npc_spawns"); - ResultSet set = statement.executeQuery(); - while (set.next()) { - parseNpc(set.getInt(1), set.getString(2)); - } - SQLManager.close(statement.getConnection()); - } + /** + * Runs the NPC Spawn SQL handler. + * + * @param args the args. + * @throws SQLException the exception if thrown. + */ + public static void main(String... args) throws SQLException { + Cache.init(); + TimeStamp stamp = new TimeStamp(); + new NPCSpawnSQLHandler().parse(); + stamp.duration(true, ""); + } - @Override - public void create() throws SQLException { - PreparedStatement statement = connection.prepareStatement(""); - statement.executeUpdate(); - SQLManager.close(statement.getConnection()); - } + @Override + public void parse() throws SQLException { + connection = getConnection(); + if (connection == null) { + SQLManager.close(connection); + return; + } + PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + (SQLManager.LOCAL ? "server" : ServerConstants.DATABASE_NAMES[0]) + ".npc_spawns"); + ResultSet set = statement.executeQuery(); + while (set.next()) { + parseNpc(set.getInt(1), set.getString(2)); + } + SQLManager.close(statement.getConnection()); + } - @Override - public void save() throws SQLException { - PreparedStatement statement = connection.prepareStatement(""); - statement.executeUpdate(); - SQLManager.close(statement.getConnection()); - } + @Override + public void create() throws SQLException { + PreparedStatement statement = connection.prepareStatement(""); + statement.executeUpdate(); + SQLManager.close(statement.getConnection()); + } - /** - * Parses an npc id's spawns. - * @param id the id. - * @param data the data. - */ - public void parseNpc(int id, String data) { - String[] datas = data.split("-"); - String[] tokens = null; - for (String d : datas) { - try { - tokens = d.replace("{", "").replace("}", "").split(","); - npc = NPC.create(id, Location.create(Integer.valueOf(tokens[0].trim()), Integer.valueOf(tokens[1].trim()), Integer.valueOf(tokens[2].trim()))); - npc.setWalks(tokens[3].trim().equals("1")); - npc.setDirection(Direction.values()[Integer.valueOf(tokens[4].trim())]); - npc.setAttribute("spawned:npc", true); - npc.init(); - } catch (Throwable t) { - System.err.println("Error on " + id); - t.printStackTrace(); - } - } - npc = null; - } + @Override + public void save() throws SQLException { + PreparedStatement statement = connection.prepareStatement(""); + statement.executeUpdate(); + SQLManager.close(statement.getConnection()); + } - public void addNPC(Player player, String id) { - try { - connection = getConnection(); - if (connection == null) { - SQLManager.close(connection); - return; - } - int npc_id = Integer.parseInt(id); - StringBuilder b = new StringBuilder("UPDATE `npc_spawns` "); - //{3222,3221,0,1,3} - b.append("SET `loc_data`='" + (result.next() ? "-{" + - player.getLocation().getX() + ", " - +player.getLocation().getY() + ", " - + player.getLocation().getZ() + ", 1, 0}" - : "{" + - player.getLocation().getX() + ", " - +player.getLocation().getY() + ", " - + player.getLocation().getZ() + ", 1, 0}") + "' WHERE `npc_id`='"+ npc_id +"'"); - PreparedStatement statement = connection.prepareStatement(b.toString()); - statement.executeUpdate(); - SQLManager.close(statement.getConnection()); - } catch (SQLException e) { - e.printStackTrace(); - } - } + /** + * Parses an npc id's spawns. + * + * @param id the id. + * @param data the data. + */ + public void parseNpc(int id, String data) { + String[] datas = data.split("-"); + String[] tokens = null; + for (String d : datas) { + try { + tokens = d.replace("{", "").replace("}", "").split(","); + npc = NPC.create(id, Location.create(Integer.valueOf(tokens[0].trim()), Integer.valueOf(tokens[1].trim()), Integer.valueOf(tokens[2].trim()))); + npc.setWalks(tokens[3].trim().equals("1")); + npc.setDirection(Direction.values()[Integer.valueOf(tokens[4].trim())]); + npc.setAttribute("spawned:npc", true); + npc.init(); + NPC_SPAWNS.add(npc); + int region_id = npc.getLocation().getRegionId(); + boolean walks = tokens[3].trim().equals("1"); + if (!REGIONS.contains(region_id)) { + REGIONS.add(region_id); + } +// System.out.println(npc.getName() + " " + walks); +// convertNPC(npc); +// System.out.println("Added npc " + npc.getName()); + } catch (Throwable t) { + System.err.println("Error on " + id); + t.printStackTrace(); + } + } + npc = null; + } + + public void convertNPC(NPC npc) { + JSONArray npcs_in_region = new JSONArray(); + int r = 0; + for (NPC n : NPC_SPAWNS) { + if (n.getLocation().getRegionId() == npc.getLocation().getRegionId()) { + Map obj = new LinkedHashMap(); + obj.put("npcId", n.getId()); + obj.put("xPos", n.getLocation().getX()); + obj.put("yPos", n.getLocation().getY()); + obj.put("height", n.getLocation().getZ()); + obj.put("walks", n.isWalks()); + if (n.isWalks()) { + obj.put("radius", 4); + } + obj.put("direction", n.getDirection().toInteger()); + obj.put("name", n.getName()); + npcs_in_region.add(obj); + r = n.getLocation().getRegionId(); + } + + } + try (FileWriter file = new FileWriter("spawns/" + r + ".json")) { + file.write(formatJSONStr(npcs_in_region.toString(), 3)); + r = 0; + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static String formatJSONStr(final String json_str, final int indent_width) { + final char[] chars = json_str.toCharArray(); + final String newline = System.lineSeparator(); + + String ret = ""; + boolean begin_quotes = false; + + for (int i = 0, indent = 0; i < chars.length; i++) { + char c = chars[i]; + + if (c == '\"') { + ret += c; + begin_quotes = !begin_quotes; + continue; + } + + if (!begin_quotes) { + switch (c) { + case '{': + case '[': + ret += c + newline + String.format("%" + (indent += indent_width) + "s", ""); + continue; + case '}': + case ']': + ret += newline + ((indent -= indent_width) > 0 ? String.format("%" + indent + "s", "") : "") + c; + continue; + case ':': + ret += c + " "; + continue; + case ',': + ret += c + newline + (indent > 0 ? String.format("%" + indent + "s", "") : ""); + continue; + default: + if (Character.isWhitespace(c)) continue; + } + } + + ret += c + (c == '\\' ? "" + chars[++i] : ""); + } + + return ret; + } + + public void addNPC(Player player, String id) { + try { + connection = getConnection(); + if (connection == null) { + SQLManager.close(connection); + return; + } + int npc_id = Integer.parseInt(id); + StringBuilder b = new StringBuilder("UPDATE `npc_spawns` "); + //{3222,3221,0,1,3} + b.append("SET `loc_data`='" + (result.next() ? "-{" + + player.getLocation().getX() + ", " + + player.getLocation().getY() + ", " + + player.getLocation().getZ() + ", 1, 0}" + : "{" + + player.getLocation().getX() + ", " + + player.getLocation().getY() + ", " + + player.getLocation().getZ() + ", 1, 0}") + "' WHERE `npc_id`='" + npc_id + "'"); + PreparedStatement statement = connection.prepareStatement(b.toString()); + statement.executeUpdate(); + SQLManager.close(statement.getConnection()); + } catch (SQLException e) { + e.printStackTrace(); + } + } - - @Override - public Connection getConnection() { - return SQLManager.getConnectionServer(); - } + @Override + public Connection getConnection() { + return SQLManager.getConnectionServer(); + } } diff --git a/09HDscape-server/src/org/crandor/gui/KeldagrimFrame.java b/09HDscape-server/src/org/crandor/gui/KeldagrimFrame.java deleted file mode 100644 index 8dc64ab7d..000000000 --- a/09HDscape-server/src/org/crandor/gui/KeldagrimFrame.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.crandor.gui; - -import org.crandor.gui.component.ConsoleLogger; -import org.crandor.gui.tab.StatisticsTab; - -import javax.swing.*; -import java.awt.*; - -/** - * The Keldagrim frame tool. - * @author Austin - */ -public class KeldagrimFrame extends JFrame { - - /** - * The Keldagrim frame instance. - */ - public static final KeldagrimFrame INSTANCE = new KeldagrimFrame(); - - /** - * 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(); - - /** - * Constructs a new {@Code KeldagrimFrame} {@Code Object} - */ - private KeldagrimFrame() { - super("Keldagrim Frame"); - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { - e.printStackTrace(); - } - } - - /** - * Initializes the Keldagrim frame. - * @return the frame. - */ - public KeldagrimFrame init() { - setLocationRelativeTo(null); - setSize(SIZE); - getContentPane().setLayout(null); - tabbedPane.setBounds(0, 0, 1068, 636); - getContentPane().add(tabbedPane); - addTabs(statisticsTab/* , playerTab, grandExchangeTab, utilityTab */); - setResizable(false); - setVisible(true); - setLocationRelativeTo(null); - System.setOut(new ConsoleLogger(System.out)); - return this; - } - - /** - * Adds tabs. - * @param tabs the tabs. - */ - public void addTabs(KeldagrimTab... tabs) { - for (KeldagrimTab tab : tabs) { - addTab(tab); - } - } - - /** - * Adds a tab to the tabbed pane. - * @param tab the tab. - */ - public void addTab(KeldagrimTab 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 instance. - * @return the instance. - */ - public static KeldagrimFrame getInstance() { - return INSTANCE; - } - -} diff --git a/09HDscape-server/src/org/crandor/gui/KeldagrimTab.java b/09HDscape-server/src/org/crandor/gui/KeldagrimTab.java deleted file mode 100644 index 86e0fe1e8..000000000 --- a/09HDscape-server/src/org/crandor/gui/KeldagrimTab.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.crandor.gui; - -import javax.swing.JPanel; -import java.awt.Rectangle; - -/** - * The Keldagrim tab. - * @author Austin - */ -public class KeldagrimTab extends JPanel { - - /** - * The serial UID. - */ - private static final long serialVersionUID = 2899642836866716523L; - - /** - * The name of the Keldagrim tab. - */ - private final String name; - - /** - * Constructs a new {@Code KeldagrimTab} {@Code Object} - * @param name the name. - */ - public KeldagrimTab(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; - } - -} diff --git a/09HDscape-server/src/org/crandor/gui/component/ConsoleLogger.java b/09HDscape-server/src/org/crandor/gui/component/ConsoleLogger.java index 6ed133565..c9f38a77d 100644 --- a/09HDscape-server/src/org/crandor/gui/component/ConsoleLogger.java +++ b/09HDscape-server/src/org/crandor/gui/component/ConsoleLogger.java @@ -1,69 +1,68 @@ package org.crandor.gui.component; + +import org.crandor.gui.ConsoleFrame; + import java.io.PrintStream; -import org.crandor.gui.KeldagrimFrame; - /** - * Logs output to the gui console. + * Loggs output to the gui console. + * * @author Vexia */ public class ConsoleLogger extends PrintStream { - /** - * Constructs a new {@code WorkLogger} {@code Object} - * @param stream the stream. - */ - public ConsoleLogger(PrintStream stream) { - super(stream); - } + /** + * Constructs a new {@code WorkLogger} {@code Object} + * + * @param stream the stream. + */ + public ConsoleLogger(PrintStream stream) { + super(stream); + } - @Override - public void println(String message) { - log(message); - } + @Override + public void println(String message) { + log(message); + } - @Override - public PrintStream printf(String message, Object... objects) { - return null; - } + @Override + public PrintStream printf(String message, Object... objects) { + return null; + } - @Override - public void println(boolean message) { - log(String.valueOf(message)); - } + @Override + public void println(boolean message) { + log(String.valueOf(message)); + } - @Override - public void println(int message) { - log(String.valueOf(message)); - } + @Override + public void println(int message) { + log(String.valueOf(message)); + } - @Override - public void println(double message) { - log(String.valueOf(message)); - } + @Override + public void println(double message) { + log(String.valueOf(message)); + } - @Override - public void println(char message) { - log(Character.toString(message)); - } + @Override + public void println(char message) { + log("" + message); + } - @Override - public void println(long message) { - log(Long.toString(message)); - } + @Override + public void println(long message) { + log("" + message); + } - @Override - public void println(Object message) { - log(String.valueOf(message)); - } - - /** - * Method used to log the message. - * @param message the message. - */ - public void log(final String message) { - KeldagrimFrame.getInstance().getStatisticsTab().log(message); - } + /** + * Method used to log the message. + * + * @param message the message. + */ + public void log(final String message) { + ConsoleFrame.getInstance().getStatisticsTab().log(message); + } } diff --git a/09HDscape-server/src/org/crandor/gui/tab/StatisticsTab.java b/09HDscape-server/src/org/crandor/gui/tab/StatisticsTab.java index a6ac6977c..23b16fbc8 100644 --- a/09HDscape-server/src/org/crandor/gui/tab/StatisticsTab.java +++ b/09HDscape-server/src/org/crandor/gui/tab/StatisticsTab.java @@ -1,10 +1,19 @@ package org.crandor.gui.tab; -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Point; + +import org.crandor.Main; +import org.crandor.game.node.item.GroundItemManager; +import org.crandor.game.system.SystemManager; +import org.crandor.game.system.SystemState; +import org.crandor.game.world.GameWorld; +import org.crandor.game.world.map.RegionManager; +import org.crandor.game.world.repository.Repository; +import org.crandor.gui.ConsoleTab; +import org.crandor.plugin.PluginManager; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -12,672 +21,649 @@ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.net.URL; -import java.nio.ByteBuffer; - -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.JTextPane; -import javax.swing.ToolTipManager; -import javax.swing.JScrollPane; -import javax.swing.border.TitledBorder; - -import org.crandor.cache.ServerStore; -import org.crandor.cache.StoreFile; -import org.crandor.game.node.item.GroundItemManager; -import org.crandor.game.system.SystemManager; -import org.crandor.game.system.SystemState; -import org.crandor.game.world.GameWorld; -import org.crandor.game.world.map.RegionManager; -import org.crandor.game.world.repository.Repository; -import org.crandor.plugin.PluginManager; -import org.crandor.Main; -import org.crandor.gui.KeldagrimTab; - -import javax.swing.JTextArea; -import javax.swing.UIManager; -import javax.swing.ScrollPaneConstants; -import javax.swing.JLabel; /** * Handles server info tab. + * * @author Emperor */ -public class StatisticsTab extends KeldagrimTab { +public class StatisticsTab extends ConsoleTab { - /** - * The serial UID. - */ - private static final long serialVersionUID = 6164020580271944550L; + /** + * The serial UID. + */ + private static final long serialVersionUID = 6164020580271944550L; - /** - * The queue size. - */ - public static final int QUEUE_SIZE = 1 << 16; + /** + * The queue size. + */ + public static final int QUEUE_SIZE = 1 << 16; - /** - * The performance data queue. - */ - private static short[] performanceQueue = new short[QUEUE_SIZE]; + /** + * The performance data queue. + */ + private static short[] performanceQueue = new short[QUEUE_SIZE]; - /** - * The memory data queue. - */ - private static short[] memoryQueue = new short[QUEUE_SIZE]; + /** + * The memory data queue. + */ + private static short[] memoryQueue = new short[QUEUE_SIZE]; - /** - * The current index of the performance queue. - */ - private static int queueIndex = 0; + /** + * The current index of the performance queue. + */ + private static int queueIndex = 0; - /** - * The current statistics zoom. - */ - private static int statisticsZoom = 5; + /** + * The current statistics zoom. + */ + private static int statisticsZoom = 5; - /** - * The singleton. - */ - public static final StatisticsTab INSTANCE = new StatisticsTab(); + /** + * The singleton. + */ + public static final StatisticsTab INSTANCE = new StatisticsTab(); - /** - * The statistics mouse coordinates. - */ - private Point statisticMousePoint = null; + /** + * The statistics mouse coordinates. + */ + private Point statisticMousePoint = null; - /** - * The zoom in button. - */ - private JButton zoomIn; + /** + * The zoom in button. + */ + private JButton zoomIn; - /** - * The zoom out button. - */ - private JButton zoomOut; + /** + * The zoom out button. + */ + private JButton zoomOut; - /** - * The reset button. - */ - private JButton resetButton; + /** + * The reset button. + */ + private JButton resetButton; - /** - * The save log button. - */ - private JButton saveLogButton; + /** + * The save log button. + */ + private JButton saveLogButton; - /** - * The shutdown button. - */ - private JButton shutdown; + /** + * The shutdown button. + */ + private JButton shutdown; - /** - * The file chooser instance. - */ - private JFileChooser fileChooser; + /** + * The file chooser instance. + */ + private JFileChooser fileChooser; - /** - * If the tool tip is currently opened. - */ - private boolean toolTipOpened; + /** + * If the tool tip is currently opened. + */ + private boolean toolTipOpened; - /** - * The world statistics text pane. - */ - private StatsTextPane worldStatistics; + /** + * The world statistics text pane. + */ + private StatsTextPane worldStatistics; - /** - * The thread statistics text pane. - */ - private StatsTextPane threadStatistics; + /** + * The thread statistics text pane. + */ + private StatsTextPane threadStatistics; - /** - * The working time of the main thread. - */ - private static long workingTime; + /** + * The working time of the main thread. + */ + private static long workingTime; - /** - * The maximum amount of players being active at the same time. - */ - private static int maximumPlayers; + /** + * The maximum amount of players being active at the same time. + */ + private static int maximumPlayers; - /** - * The text area. - */ - private final JTextArea console = new JTextArea(); + /** + * The text area. + */ + private final JTextArea console = new JTextArea(); - /** - * Constructs a new {@Code StatisticsTab} {@Code Object} - */ - public StatisticsTab() { - super("Statistics"); - setLayout(null); + /** + * Constructs a new {@Code StatisticsTab} {@Code Object} + */ + public StatisticsTab() { + super("Statistics"); + setLayout(null); - JScrollPane scrollPane = new JScrollPane(); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); - scrollPane.setBackground(UIManager.getColor("Button.background")); - scrollPane.setBounds(6, 403, 1042, 189); - scrollPane.setBorder(new TitledBorder(null, "Console", TitledBorder.LEADING, TitledBorder.TOP, null, null)); - add(scrollPane); + JScrollPane scrollPane = new JScrollPane(); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPane.setBackground(UIManager.getColor("Button.background")); + scrollPane.setBounds(6, 403, 1042, 189); + scrollPane.setBorder(new TitledBorder(null, "Console", TitledBorder.LEADING, TitledBorder.TOP, null, null)); + add(scrollPane); - console.setLineWrap(true); - console.setBackground(UIManager.getColor("CheckBox.background")); - console.setEditable(false); - scrollPane.setViewportView(console); + console.setLineWrap(true); + console.setBackground(UIManager.getColor("CheckBox.background")); + console.setEditable(false); + scrollPane.setViewportView(console); - JLabel label = new JLabel("Made by: Emperor & Vexia"); - label.setBounds(450, 345, 163, 16); - add(label); - } + JLabel label = new JLabel(); + label.setBounds(450, 345, 163, 16); + add(label); + } - @Override - public String getToolTipText(MouseEvent e) { - if (e.getX() > getWidth() / 2 && e.getX() < getWidth() && e.getY() > 2 && e.getY() < getHeight() / 2) { - int max = (getWidth() / 2) / statisticsZoom; - int index = queueIndex - (max - (e.getX() - (getWidth() / 2)) / statisticsZoom); - toolTipOpened = true; - if (index < 0) { - return "Tick: null, time: null."; - } - return new StringBuilder("Tick: ").append(index).append(", time: ").append(performanceQueue[index] + 600).append(".").toString(); - } - toolTipOpened = false; - return null; - } + @Override + public String getToolTipText(MouseEvent e) { + if (e.getX() > getWidth() / 2 && e.getX() < getWidth() + && e.getY() > 2 && e.getY() < getHeight() / 2) { + int max = (getWidth() / 2) / statisticsZoom; + int index = queueIndex - (max - (e.getX() - (getWidth() / 2)) / statisticsZoom); + toolTipOpened = true; + if (index < 0) { + return "Tick: null, time: null."; + } + return new StringBuilder("Tick: ").append(index).append(", time: ").append(performanceQueue[index] + 600).append(".").toString(); + } + toolTipOpened = false; + return null; + } - @Override - public Point getToolTipLocation(MouseEvent e) { - if (e.getX() > getWidth() / 2 && e.getX() < getWidth() && e.getY() > 2 && e.getY() < getHeight() / 2) { - return new Point(e.getX() + 15, e.getY() + 10); - } - return null; - } + @Override + public Point getToolTipLocation(MouseEvent e) { + if (e.getX() > getWidth() / 2 && e.getX() < getWidth() + && e.getY() > 2 && e.getY() < getHeight() / 2) { + return new Point(e.getX() + 15, e.getY() + 10); + } + return null; + } - @Override - public void paint(Graphics g) { - super.paint(g); - drawPerformanceStatistics(this, g); - } + @Override + public void paint(Graphics g) { + super.paint(g); + drawPerformanceStatistics(this, g); + } - /** - * Positions the components. - */ - public void positionComponents() { - int init = 90; - int diff = 5; - zoomIn.setLocation(getWidth() / 2 - (zoomIn.getWidth() / 2) - diff, 5 + init); - zoomOut.setLocation(getWidth() / 2 - (zoomOut.getWidth() / 2) - diff, 30 + init); - resetButton.setLocation(getWidth() / 2 - (resetButton.getWidth() / 2) - diff, 55 + init); - saveLogButton.setLocation(getWidth() / 2 - (saveLogButton.getWidth() / 2) - diff, 80 + init); - shutdown.setLocation(getWidth() / 2 - (shutdown.getWidth() / 2), 310); - worldStatistics.setLocation(55, 310); - threadStatistics.setLocation(shutdown.getX() + shutdown.getWidth() + 35, 310); - } + /** + * Positions the components. + */ + public void positionComponents() { + int init = 90; + int diff = 5; + zoomIn.setLocation(getWidth() / 2 - (zoomIn.getWidth() / 2) - diff, 5 + init); + zoomOut.setLocation(getWidth() / 2 - (zoomOut.getWidth() / 2) - diff, 30 + init); + resetButton.setLocation(getWidth() / 2 - (resetButton.getWidth() / 2) - diff, 55 + init); + saveLogButton.setLocation(getWidth() / 2 - (saveLogButton.getWidth() / 2) - diff, 80 + init); + shutdown.setLocation(getWidth() / 2 - (shutdown.getWidth() / 2), 310); + worldStatistics.setLocation(55, 310); + threadStatistics.setLocation(shutdown.getX() + shutdown.getWidth() + 35, 310); + } - /** - * Initializes the server info tab. - * @return This instance. - */ - public StatisticsTab init() { - initMaximumPlayers(); - fileChooser = new JFileChooser("./"); - zoomIn = new JButton("+"); - zoomIn.setLayout(null); - zoomIn.setVisible(true); - zoomIn.setSize(50, 20); - zoomIn.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - zoomOut.setEnabled(true); - if (++statisticsZoom > 20) { - statisticsZoom = 20; - zoomIn.setEnabled(false); - return; - } - drawPerformanceStatistics(StatisticsTab.this, getGraphics()); - } - }); - zoomOut = new JButton("-"); - zoomOut.setLayout(null); - zoomOut.setVisible(true); - zoomOut.setSize(50, 20); - zoomOut.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - zoomIn.setEnabled(true); - if (--statisticsZoom < 2) { - statisticsZoom = 2; - zoomOut.setEnabled(false); - return; - } - drawPerformanceStatistics(StatisticsTab.this, getGraphics()); - } - }); - resetButton = new JButton("x"); - resetButton.setLayout(null); - resetButton.setVisible(true); - resetButton.setSize(50, 20); - resetButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - queueIndex = 0; - } - }); - saveLogButton = new JButton("", createImageIcon("Save16.gif")); - saveLogButton.setLayout(null); - saveLogButton.setVisible(true); - saveLogButton.setSize(50, 20); - saveLogButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - int returnVal = fileChooser.showSaveDialog(StatisticsTab.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fileChooser.getSelectedFile(); - if (!file.getName().contains(".")) { - file = new File(file.getPath() + ".txt"); - } - logQueues(file); - } - } - }); - add(resetButton); - add(zoomIn); - add(zoomOut); - add(saveLogButton); - shutdown = new JButton("Shutdown"); - shutdown.setLayout(null); - shutdown.setVisible(true); - shutdown.setSize(100, 20); - shutdown.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - SystemManager.flag(SystemState.TERMINATED); - } - }); - add(shutdown); - worldStatistics = new StatsTextPane().init(); - worldStatistics.setSize(390, 90); - add(worldStatistics); - updateWorldText(); - threadStatistics = new StatsTextPane().init(); - threadStatistics.setSize(390, 90); - add(threadStatistics); - updateThreadText(); - setLayout(null); - setVisible(true); - ToolTipManager.sharedInstance().setInitialDelay(0); - positionComponents(); - return this; - } + /** + * Initializes the server info tab. + * + * @return This instance. + */ + public StatisticsTab init() { + initMaximumPlayers(); + fileChooser = new JFileChooser("./"); + zoomIn = new JButton("+"); + zoomIn.setLayout(null); + zoomIn.setVisible(true); + zoomIn.setSize(50, 20); + zoomIn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + zoomOut.setEnabled(true); + if (++statisticsZoom > 20) { + statisticsZoom = 20; + zoomIn.setEnabled(false); + return; + } + drawPerformanceStatistics(StatisticsTab.this, getGraphics()); + } + }); + zoomOut = new JButton("-"); + zoomOut.setLayout(null); + zoomOut.setVisible(true); + zoomOut.setSize(50, 20); + zoomOut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + zoomIn.setEnabled(true); + if (--statisticsZoom < 2) { + statisticsZoom = 2; + zoomOut.setEnabled(false); + return; + } + drawPerformanceStatistics(StatisticsTab.this, getGraphics()); + } + }); + resetButton = new JButton("x"); + resetButton.setLayout(null); + resetButton.setVisible(true); + resetButton.setSize(50, 20); + resetButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + queueIndex = 0; + } + }); + saveLogButton = new JButton("", createImageIcon("Save16.gif")); + saveLogButton.setLayout(null); + saveLogButton.setVisible(true); + saveLogButton.setSize(50, 20); + saveLogButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int returnVal = fileChooser.showSaveDialog(StatisticsTab.this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + if (!file.getName().contains(".")) { + file = new File(file.getPath() + ".txt"); + } + logQueues(file); + } + } + }); + add(resetButton); + add(zoomIn); + add(zoomOut); + add(saveLogButton); + shutdown = new JButton("Shutdown"); + shutdown.setLayout(null); + shutdown.setVisible(true); + shutdown.setSize(100, 20); + shutdown.addActionListener(e -> SystemManager.flag(SystemState.TERMINATED)); + add(shutdown); + worldStatistics = new StatsTextPane().init(); + worldStatistics.setSize(390, 90); + add(worldStatistics); + updateWorldText(); + threadStatistics = new StatsTextPane().init(); + threadStatistics.setSize(390, 90); + add(threadStatistics); + updateThreadText(); + setLayout(null); + setVisible(true); + ToolTipManager.sharedInstance().setInitialDelay(0); + positionComponents(); + return this; + } - /** - * Initializes the maximum players count. - */ - private static void initMaximumPlayers() { - StoreFile file = ServerStore.get("max_players"); - if (file == null) { - return; - } - setMaximumPlayers(file.data().getShort() & 0xFFFF); - } + /** + * Initializes the maximum players count. + */ + private static void initMaximumPlayers() { + setMaximumPlayers(0); + } - /** - * Sets the maximum amount of players. - * @param maximum The maximum. - */ - private static void setMaximumPlayers(int maximum) { - maximumPlayers = maximum; - ServerStore.setArchive("max_players", (ByteBuffer) ByteBuffer.allocate(2).putShort((short) maximum).flip()); - } + /** + * Sets the maximum amount of players. + * + * @param maximum The maximum. + */ + private static void setMaximumPlayers(int maximum) { + maximumPlayers = maximum; + } - /** - * Logs the queues. - * @param file The file to log to. - */ - protected static void logQueues(File file) { - try (BufferedWriter bw = new BufferedWriter(new FileWriter(file, true))) { - bw.append("/////////////////////////////////////////////////////////////////////////"); - bw.newLine(); - bw.append("/////////////////////////////////////////////////////////////////////////"); - bw.newLine(); - // bw.append("// " + CalenderDate.getFormattedDate() + - // " performance log results:"); - bw.newLine(); - bw.append("// Dumped using Keldagrim #498 GUI"); - bw.newLine(); - bw.append("// Created by Emperor"); - bw.newLine(); - bw.append("/////////////////////////////////////////////////////////////////////////"); - bw.newLine(); - for (int i = 0; i < queueIndex; i++) { - bw.append(new StringBuilder("performance_report:memory_usage-[tick=").append(i).append(", mem=").append(memoryQueue[i]).append("mb].")); - bw.newLine(); - } - for (int i = 0; i < queueIndex; i++) { - int value = 600 + performanceQueue[i]; - bw.append(new StringBuilder("performance_report:clock_speed-[tick=").append(i).append(", time=").append(value).append(", status=").append(value < 601 ? "NORMAL]." : "DELAYED].")); - bw.newLine(); - } - bw.append("/////////////////////////////////////////////////////////////////////////"); - bw.newLine(); - bw.flush(); - bw.close(); - } catch (Throwable t) { - t.printStackTrace(); - } - } + /** + * Logs the queues. + * + * @param file The file to log to. + */ + protected static void logQueues(File file) { + try (BufferedWriter bw = new BufferedWriter(new FileWriter(file, true))) { + bw.append("/////////////////////////////////////////////////////////////////////////"); + bw.newLine(); + bw.append("/////////////////////////////////////////////////////////////////////////"); + bw.newLine(); + // bw.append("// " + CalenderDate.getFormattedDate() + " performance log results:"); + bw.newLine(); + bw.append("/////////////////////////////////////////////////////////////////////////"); + bw.newLine(); + for (int i = 0; i < queueIndex; i++) { + bw.append(new StringBuilder("performance_report:memory_usage-[tick=").append(i).append(", mem=").append(memoryQueue[i]).append("mb].")); + bw.newLine(); + } + for (int i = 0; i < queueIndex; i++) { + int value = 600 + performanceQueue[i]; + bw.append(new StringBuilder("performance_report:clock_speed-[tick=").append(i).append(", time=").append(value).append(", status=").append(value < 601 ? "NORMAL]." : "DELAYED].")); + bw.newLine(); + } + bw.append("/////////////////////////////////////////////////////////////////////////"); + bw.newLine(); + bw.flush(); + bw.close(); + } catch (Throwable t) { + t.printStackTrace(); + } + } - /** - * Creates an image icon. - * @param path The path of the image file. - * @return The image icon. - */ - private static ImageIcon createImageIcon(String path) { - URL imgURL = StatisticsTab.class.getResource(path); - if (imgURL != null) { - return new ImageIcon(imgURL); - } - return null; - } + /** + * Creates an image icon. + * + * @param path The path of the image file. + * @return The image icon. + */ + private static ImageIcon createImageIcon(String path) { + URL imgURL = StatisticsTab.class.getResource(path); + if (imgURL != null) { + return new ImageIcon(imgURL); + } + return null; + } - /** - * Reports the performance value. - * @param value The value. - */ - public static void reportPerformance(int value) { - if (value >= Short.MAX_VALUE) { - value = Short.MAX_VALUE - 1; - } - secureQueues(); - performanceQueue[queueIndex] = (short) value; - memoryQueue[queueIndex++] = (short) ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1_000_000); - INSTANCE.repaint(); - workingTime += (600 + value); - if (INSTANCE.threadStatistics != null) { - INSTANCE.updateThreadText(); - if ((GameWorld.getTicks() % 10) == 0) { - INSTANCE.updateWorldText(); - } - } - } + /** + * Reports the performance value. + * + * @param value The value. + */ + public static void reportPerformance(int value) { + if (value >= Short.MAX_VALUE) { + value = Short.MAX_VALUE - 1; + } + secureQueues(); + performanceQueue[queueIndex] = (short) value; + memoryQueue[queueIndex++] = (short) ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1_000_000); + INSTANCE.repaint(); + workingTime += (600 + value); + if (INSTANCE.threadStatistics != null) { + INSTANCE.updateThreadText(); + if ((GameWorld.getTicks() % 10) == 0) { + INSTANCE.updateWorldText(); + } + } + } - /** - * Updates the thread statistics text. - */ - public void updateThreadText() { - StringBuilder sb = new StringBuilder(); - long runtime = System.currentTimeMillis() - Main.startTime; - double percentage = workingTime / (runtime * 0.01); - long hours = runtime / 3600000; - runtime -= hours * 3600000; - long minutes = runtime / 60000; - runtime -= minutes * 60000; - long seconds = runtime / 1000; - sb.append("Runtime: ").append(hours).append("h ").append(minutes).append("m ").append(seconds).append("s").append(" - ").append(GameWorld.getTicks()).append(" ticks").append("\n"); - sb.append("Working time: ").append(workingTime).append("ms").append(" - ").append(String.format("%.2f", percentage)).append("%").append("\n"); - sb.append("Average cycle: ").append(String.format("%.1f", (double) workingTime / GameWorld.getTicks())).append("ms").append("\n"); - threadStatistics.setText(sb.toString()); - } + /** + * Updates the thread statistics text. + */ + public void updateThreadText() { + StringBuilder sb = new StringBuilder(); + long runtime = System.currentTimeMillis() - Main.startTime; + double percentage = workingTime / (runtime * 0.01); + long hours = runtime / 3600000; + runtime -= hours * 3600000; + long minutes = runtime / 60000; + runtime -= minutes * 60000; + long seconds = runtime / 1000; + sb.append("Runtime: ").append(hours).append("h ").append(minutes).append("m ").append(seconds).append("s").append(" - ").append(GameWorld.getTicks()).append(" ticks").append("\n"); + sb.append("Working time: ").append(workingTime).append("ms").append(" - ").append(String.format("%.2f", percentage)).append("%").append("\n"); + sb.append("Average cycle: ").append(String.format("%.1f", (double) workingTime / GameWorld.getTicks())).append("ms").append("\n"); + threadStatistics.setText(sb.toString()); + } - /** - * Updates the world statistics text. - */ - public void updateWorldText() { - int players = Repository.getPlayers().size(); - if (players > getMaximumPlayers()) { - setMaximumPlayers(players); - } - StringBuilder sb = new StringBuilder(); - sb.append("Players: ").append(players).append(", max: ").append(getMaximumPlayers()).append("\n"); - sb.append("NPCs: ").append(Repository.getNpcs().size()).append("\n"); - sb.append("Regions: ").append(RegionManager.getRegionCache().size()).append("\n"); - sb.append("Ground items: ").append(GroundItemManager.getItems().size()).append("\n"); - sb.append("Plugins: ").append(PluginManager.getAmountLoaded()).append("\n"); - worldStatistics.setText(sb.toString()); - } + /** + * Updates the world statistics text. + */ + public void updateWorldText() { + int players = Repository.getPlayers().size(); + if (players > getMaximumPlayers()) { + setMaximumPlayers(players); + } + StringBuilder sb = new StringBuilder(); + sb.append("Players: ").append(players).append(", max: ").append(getMaximumPlayers()).append("\n"); + sb.append("NPCs: ").append(Repository.getNpcs().size()).append("\n"); + sb.append("Regions: ").append(RegionManager.getRegionCache().size()).append("\n"); + sb.append("Ground items: ").append(GroundItemManager.getItems().size()).append("\n"); + sb.append("Plugins: ").append(PluginManager.getAmountLoaded()).append("\n"); + worldStatistics.setText(sb.toString()); + } - /** - * Draws the performance statistics. - * @param c The component. - * @param g The graphics. - */ - private static void drawPerformanceStatistics(Component c, Graphics g) { - int x = c.getWidth() / 2 + 48; - int y = c.getHeight() / 2; + /** + * Draws the performance statistics. + * + * @param c The component. + * @param g The graphics. + */ + private static void drawPerformanceStatistics(Component c, Graphics g) { + int x = c.getWidth() / 2 + 48; + int y = c.getHeight() / 2; - Point zero = new Point(x, y / 2); - g.setColor(Color.LIGHT_GRAY); + Point zero = new Point(x, y / 2); + g.setColor(Color.LIGHT_GRAY); - // Fill the background rectangle. - g.fillRect(x, 5, c.getWidth() - 4 - x, y - 5); - g.setColor(Color.GRAY); + //Fill the background rectangle. + g.fillRect(x, 5, c.getWidth() - 4 - x, y - 5); + g.setColor(Color.GRAY); - int count = 0; - for (int i = 0; i < c.getWidth() - 4 - x; i += statisticsZoom) { - g.drawLine((int) (zero.getX() + i), 5, (int) (zero.getX() + i), y - 1); - count++; - } + int count = 0; + for (int i = 0; i < c.getWidth() - 4 - x; i += statisticsZoom) { + g.drawLine((int) (zero.getX() + i), 5, + (int) (zero.getX() + i), y - 1); + count++; + } - int space = (y / 2 - 10) / 4; - g.setFont(new Font(null, Font.PLAIN, 9)); - for (int i = 0; i < 5; i++) { - g.setColor(Color.GRAY); - g.drawLine(x, (int) zero.getY() - (space * i), c.getWidth() - 5, (int) zero.getY() - (space * i)); - g.drawLine(x, (int) zero.getY() + (space * i), c.getWidth() - 5, (int) zero.getY() + (space * i)); - g.setColor(Color.BLACK); - g.drawString("" + (i * 150), x - 18, (int) zero.getY() - (space * i) + 2); - if (i != 0) - g.drawString("-" + (i * 150), x - 20, (int) zero.getY() + (space * i) + 2); - } - g.setColor(Color.GREEN); - for (int i = 1; i < count; i++) { - int index = queueIndex - i; - if (index < 1) { - break; - } - int fromPoint = performanceQueue[index]; - int fromX = (count - i) * statisticsZoom; - int fromY = (int) (-fromPoint / (600D / (space * 4))); - int toPoint = index == 0 ? 0 : performanceQueue[index - 1]; - int toX = (count - i - 1) * statisticsZoom; - int toY = (int) (-toPoint / (600D / (space * 4))); - if (fromY < 0) { - g.setColor(Color.RED); - } - g.drawLine((int) (zero.getX() + fromX), (int) (zero.getY() + fromY), (int) (zero.getX() + toX), (int) (zero.getY() + toY)); - if (fromY < 0) { - g.setColor(Color.GREEN); - } - } - g.setColor(Color.BLACK); - // Draw horizontal line. - g.drawLine(x - 4, (int) zero.getY(), c.getWidth() - 2, (int) zero.getY()); - // Draw vertical line. - g.drawLine(x, y + 4, x, 1); - Point p = ((StatisticsTab) c).statisticMousePoint; - if (p != null) { - g.setColor(new Color(251, 230, 130)); - g.fillRoundRect((int) (p.getX() + 10), (int) (p.getY() - 10), 100, 50, 10, 10); - } - if (((StatisticsTab) c).toolTipOpened) { - ((StatisticsTab) c).setToolTipText("test"); - } - drawMemoryStatistics(c, g); - } + int space = (y / 2 - 10) / 4; + g.setFont(new Font(null, Font.PLAIN, 9)); + for (int i = 0; i < 5; i++) { + g.setColor(Color.GRAY); + g.drawLine(x, (int) zero.getY() - (space * i), c.getWidth() - 5, (int) zero.getY() - (space * i)); + g.drawLine(x, (int) zero.getY() + (space * i), c.getWidth() - 5, (int) zero.getY() + (space * i)); + g.setColor(Color.BLACK); + g.drawString("" + (i * 150), x - 18, (int) zero.getY() - (space * i) + 2); + if (i != 0) { + g.drawString("-" + (i * 150), x - 20, (int) zero.getY() + (space * i) + 2); + } + } + g.setColor(Color.GREEN); + for (int i = 1; i < count; i++) { + int index = queueIndex - i; + if (index < 1) { + break; + } + int fromPoint = performanceQueue[index]; + int fromX = (count - i) * statisticsZoom; + int fromY = (int) (-fromPoint / (600D / (space * 4))); + int toPoint = index == 0 ? 0 : performanceQueue[index - 1]; + int toX = (count - i - 1) * statisticsZoom; + int toY = (int) (-toPoint / (600D / (space * 4))); + if (fromY < 0) { + g.setColor(Color.RED); + } + g.drawLine((int) (zero.getX() + fromX), (int) (zero.getY() + fromY), + (int) (zero.getX() + toX), (int) (zero.getY() + toY)); + if (fromY < 0) { + g.setColor(Color.GREEN); + } + } + g.setColor(Color.BLACK); + //Draw horizontal line. + g.drawLine(x - 4, (int) zero.getY(), c.getWidth() - 2, (int) zero.getY()); + //Draw vertical line. + g.drawLine(x, y + 4, x, 1); + Point p = ((StatisticsTab) c).statisticMousePoint; + if (p != null) { + g.setColor(new Color(251, 230, 130)); + g.fillRoundRect((int) (p.getX() + 10), (int) (p.getY() - 10), 100, 50, 10, 10); + } + if (((StatisticsTab) c).toolTipOpened) { + ((StatisticsTab) c).setToolTipText("test"); + } + drawMemoryStatistics(c, g); + } - /** - * Draws the performance statistics. - * @param c The component. - * @param g The graphics. - */ - private static void drawMemoryStatistics(Component c, Graphics g) { - int x = 5; - int y = c.getHeight() / 2; - int endX = (c.getWidth() / 2) - 48; + /** + * Draws the performance statistics. + * + * @param c The component. + * @param g The graphics. + */ + private static void drawMemoryStatistics(Component c, Graphics g) { + int x = 5; + int y = c.getHeight() / 2; + int endX = (c.getWidth() / 2) - 48; - Point zero = new Point(x + 18, y); - g.setColor(Color.LIGHT_GRAY); + Point zero = new Point(x + 18, y); + g.setColor(Color.LIGHT_GRAY); - // Fill the background rectangle. - g.fillRect((int) zero.getX(), 5, endX - x, y - 5); - g.setColor(Color.GRAY); + //Fill the background rectangle. + g.fillRect((int) zero.getX(), 5, endX - x, y - 5); + g.setColor(Color.GRAY); - int count = 0; - for (int i = 0; i < endX - x; i += statisticsZoom) { - g.drawLine((int) (zero.getX() + i), 5, (int) (zero.getX() + i), y - 1); - count++; - } + int count = 0; + for (int i = 0; i < endX - x; i += statisticsZoom) { + g.drawLine((int) (zero.getX() + i), 5, + (int) (zero.getX() + i), y - 1); + count++; + } - int space = (y) / 10; - g.setFont(new Font(null, Font.PLAIN, 9)); - for (int i = 0; i < 10; i++) { - g.setColor(Color.GRAY); - g.drawLine((int) zero.getX() - 2, (int) zero.getY() - (space * i), endX + 17, (int) zero.getY() - (space * i)); - g.setColor(Color.BLACK); - g.drawString("" + (i * 100), 2, (int) zero.getY() - (space * i) + 2); - } - g.setColor(Color.BLUE); - for (int i = 1; i < count; i++) { - int index = queueIndex - i; - if (index < 1) { - break; - } - int fromPoint = memoryQueue[index]; - int fromX = (count - i) * statisticsZoom; - int fromY = (int) (fromPoint / (900D / (space * 10))); - int toPoint = index == 0 ? 0 : memoryQueue[index - 1]; - int toX = (count - i - 1) * statisticsZoom; - int toY = (int) (toPoint / (900D / (space * 10))); - if (fromY < 0) { - g.setColor(Color.RED); - } - g.drawLine((int) (zero.getX() + fromX), (int) (zero.getY() - fromY), (int) (zero.getX() + toX), (int) (zero.getY() - toY)); - if (fromY < 0) { - g.setColor(Color.GREEN); - } - } - g.setColor(Color.BLACK); - // Draw horizontal line. - g.drawLine((int) (zero.getX() - 4), (int) zero.getY(), endX + 21, (int) zero.getY()); - // Draw vertical line. - g.drawLine((int) zero.getX(), (int) zero.getY() + 4, (int) zero.getX(), 1); - Point p = ((StatisticsTab) c).statisticMousePoint; - if (p != null) { - g.setColor(new Color(251, 230, 130)); - g.fillRoundRect((int) (p.getX() + 10), (int) (p.getY() - 10), 100, 50, 10, 10); - } - if (((StatisticsTab) c).toolTipOpened) { - ((StatisticsTab) c).setToolTipText("test"); - } - } + int space = (y) / 10; + g.setFont(new Font(null, Font.PLAIN, 9)); + for (int i = 0; i < 10; i++) { + g.setColor(Color.GRAY); + g.drawLine((int) zero.getX() - 2, (int) zero.getY() - (space * i), endX + 17, (int) zero.getY() - (space * i)); + g.setColor(Color.BLACK); + g.drawString("" + (i * 100), 2, (int) zero.getY() - (space * i) + 2); + } + g.setColor(Color.BLUE); + for (int i = 1; i < count; i++) { + int index = queueIndex - i; + if (index < 1) { + break; + } + int fromPoint = memoryQueue[index]; + int fromX = (count - i) * statisticsZoom; + int fromY = (int) (fromPoint / (900D / (space * 10))); + int toPoint = index == 0 ? 0 : memoryQueue[index - 1]; + int toX = (count - i - 1) * statisticsZoom; + int toY = (int) (toPoint / (900D / (space * 10))); + if (fromY < 0) { + g.setColor(Color.RED); + } + g.drawLine((int) (zero.getX() + fromX), (int) (zero.getY() - fromY), + (int) (zero.getX() + toX), (int) (zero.getY() - toY)); + if (fromY < 0) { + g.setColor(Color.GREEN); + } + } + g.setColor(Color.BLACK); + //Draw horizontal line. + g.drawLine((int) (zero.getX() - 4), (int) zero.getY(), endX + 21, (int) zero.getY()); + //Draw vertical line. + g.drawLine((int) zero.getX(), (int) zero.getY() + 4, (int) zero.getX(), 1); + Point p = ((StatisticsTab) c).statisticMousePoint; + if (p != null) { + g.setColor(new Color(251, 230, 130)); + g.fillRoundRect((int) (p.getX() + 10), (int) (p.getY() - 10), 100, 50, 10, 10); + } + if (((StatisticsTab) c).toolTipOpened) { + ((StatisticsTab) c).setToolTipText("test"); + } + } - /** - * Secures the queues. - */ - private static void secureQueues() { - if (queueIndex >= QUEUE_SIZE) { - int lagSpikes = 0; - int memoryUsageSpikes = 0; - @SuppressWarnings("unused") - int totalMemory = 0; - @SuppressWarnings("unused") - int totalCycleTime = 0; - // Start at tick 500, the JVM has to "warm up" first. - for (int i = 500; i < QUEUE_SIZE; i++) { - if (performanceQueue[i] > 0) { // Anything above 0 (-600 + 600) - // = lag - lagSpikes++; - } - if (memoryQueue[i] > 700) { // Over 700Mb - memoryUsageSpikes++; - } - totalMemory += memoryQueue[i]; - totalCycleTime += performanceQueue[i]; - } - if (lagSpikes > 350 || memoryUsageSpikes > 350) { - logQueues(new File("./data/logs/system/Performance-log.txt")); - } - // System.out.println("Average cycle time: " + (600 + - // (totalCycleTime / (QUEUE_SIZE - 500))) + "ms."); - // System.out.println("Average memory usage: " + (totalMemory / - // (QUEUE_SIZE - 500)) + "Mb."); - queueIndex = 0; - } - } + /** + * Secures the queues. + */ + private static void secureQueues() { + if (queueIndex >= QUEUE_SIZE) { + int lagSpikes = 0; + int memoryUsageSpikes = 0; + @SuppressWarnings("unused") + int totalMemory = 0; + @SuppressWarnings("unused") + int totalCycleTime = 0; + //Start at tick 500, the JVM has to "warm up" first. + for (int i = 500; i < QUEUE_SIZE; i++) { + if (performanceQueue[i] > 0) { //Anything above 0 (-600 + 600) = lag + lagSpikes++; + } + if (memoryQueue[i] > 700) { //Over 700Mb + memoryUsageSpikes++; + } + totalMemory += memoryQueue[i]; + totalCycleTime += performanceQueue[i]; + } + if (lagSpikes > 350 || memoryUsageSpikes > 350) { + logQueues(new File("./data/logs/system/Performance-log.txt")); + } + //System.out.println("Average cycle time: " + (600 + (totalCycleTime / (QUEUE_SIZE - 500))) + "ms."); + //System.out.println("Average memory usage: " + (totalMemory / (QUEUE_SIZE - 500)) + "Mb."); + queueIndex = 0; + } + } - /** - * Logs a message to the console. - * @param message the message. - */ - public void log(String message) { - console.append(message + "\n"); - console.setCaretPosition(console.getDocument().getLength()); - } + /** + * Logs a message to the console. + * + * @param message the message. + */ + public void log(String message) { + console.append(message + "\n"); + console.setCaretPosition(console.getDocument().getLength()); + } - /** - * Sets the statistics zoom. - * @param pixels The amount of pixels. - */ - public static void setStatisticsZoom(int pixels) { - statisticsZoom = pixels; - } + /** + * Sets the statistics zoom. + * + * @param pixels The amount of pixels. + */ + public static void setStatisticsZoom(int pixels) { + statisticsZoom = pixels; + } - /** - * Gets the workingTime. - * @return The workingTime. - */ - public static long getWorkingTime() { - return workingTime; - } + /** + * Gets the workingTime. + * + * @return The workingTime. + */ + public static long getWorkingTime() { + return workingTime; + } - /** - * Sets the workingTime. - * @param workingTime The workingTime to set. - */ - public static void setWorkingTime(long workingTime) { - StatisticsTab.workingTime = workingTime; - } + /** + * Sets the workingTime. + * + * @param workingTime The workingTime to set. + */ + public static void setWorkingTime(long workingTime) { + StatisticsTab.workingTime = workingTime; + } - /** - * Gets the maximumPlayers. - * @return The maximumPlayers. - */ - public static int getMaximumPlayers() { - return maximumPlayers; - } + /** + * Gets the maximumPlayers. + * + * @return The maximumPlayers. + */ + public static int getMaximumPlayers() { + return maximumPlayers; + } - /** - * Handles the statistics tab text pane. - * @author Emperor - */ - public final class StatsTextPane extends JTextPane { + /** + * Handles the statistics tab text pane. + * + * @author Emperor + */ + public final class StatsTextPane extends JTextPane { - /** - * The serial UID. - */ - private static final long serialVersionUID = 664276151176087663L; + /** + * The serial UID. + */ + private static final long serialVersionUID = 664276151176087663L; - /** - * Constructs a new {@code StatsTextPane} {@code Object}. - */ - public StatsTextPane() { - super(); - } + /** + * Constructs a new {@code StatsTextPane} {@code Object}. + */ + public StatsTextPane() { + super(); + } - /** - * Initializes the stats text pane. - * @return The stats text pane. - */ - public StatsTextPane init() { - setEditable(false); - setLayout(null); - Font font = new Font("Monospaced", Font.PLAIN, 12); - setFont(font); - super.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); - super.setVisible(true); - return this; - } + /** + * Initializes the stats text pane. + * + * @return The stats text pane. + */ + public StatsTextPane init() { + setEditable(false); + setLayout(null); + Font font = new Font("Monospaced", Font.PLAIN, 12); + setFont(font); + super.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); + super.setVisible(true); + return this; + } - } + } } diff --git a/09HDscape-server/src/org/crandor/net/packet/PacketRepository.java b/09HDscape-server/src/org/crandor/net/packet/PacketRepository.java index 47e7ab13e..3d07c18b4 100644 --- a/09HDscape-server/src/org/crandor/net/packet/PacketRepository.java +++ b/09HDscape-server/src/org/crandor/net/packet/PacketRepository.java @@ -72,7 +72,7 @@ public final class PacketRepository { OUTGOING_PACKETS.put(WeightUpdate.class, new WeightUpdate()); OUTGOING_PACKETS.put(UpdateRandomFile.class, new UpdateRandomFile()); OUTGOING_PACKETS.put(InstancedLocationUpdate.class, new InstancedLocationUpdate()); - //OUTGOING_PACKETS.put(CSConfigPacket.class, new CSConfigPacket()); + OUTGOING_PACKETS.put(CSConfigPacket.class, new CSConfigPacket()); INCOMING_PACKETS.put(22, new ClientFocusPacket()); INCOMING_PACKETS.put(93, new PingPacketHandler()); INCOMING_PACKETS.put(44, new CommandPacket()); diff --git a/09HDscape-server/src/org/crandor/net/packet/context/CSConfigContext.java b/09HDscape-server/src/org/crandor/net/packet/context/CSConfigContext.java index b69b8d297..7f99a0ecd 100644 --- a/09HDscape-server/src/org/crandor/net/packet/context/CSConfigContext.java +++ b/09HDscape-server/src/org/crandor/net/packet/context/CSConfigContext.java @@ -23,18 +23,24 @@ public class CSConfigContext implements Context { * The id. */ private int id; + private final Object[] parameters; + private final String types; /** * Constructs a new {@Code CSConfigContext} {@Code Object} * @param player The player. - * @param value The config value. * @param id The id. + * @param value The config value. + * @param parameters + * @param types */ - public CSConfigContext(Player player, int id, int value) { + public CSConfigContext(Player player, int id, int value, String types, Object[] parameters) { this.player = player; this.value = value; this.id = id; + this.parameters = parameters; + this.types = types; } @Override @@ -68,4 +74,11 @@ public class CSConfigContext implements Context { return id; } + public String getTypes() { + return types; + } + + public Object[] getParameters() { + return parameters; + } } \ No newline at end of file diff --git a/09HDscape-server/src/org/crandor/net/packet/out/CSConfigPacket.java b/09HDscape-server/src/org/crandor/net/packet/out/CSConfigPacket.java index ea257ce2e..d26f223ed 100644 --- a/09HDscape-server/src/org/crandor/net/packet/out/CSConfigPacket.java +++ b/09HDscape-server/src/org/crandor/net/packet/out/CSConfigPacket.java @@ -1,5 +1,6 @@ package org.crandor.net.packet.out; +import com.oracle.jrockit.jfr.DataType; import org.crandor.net.packet.IoBuffer; import org.crandor.net.packet.OutgoingPacket; import org.crandor.net.packet.context.CSConfigContext; @@ -14,7 +15,17 @@ public class CSConfigPacket implements OutgoingPacket { @Override public void send(CSConfigContext context) { IoBuffer buffer = new IoBuffer(115); - buffer.putShort(context.getId()).putString(""); + buffer.putShort(context.getId()); + buffer.putString(context.getTypes()); + + for (int i = context.getTypes().length() - 1; i >= 0; i--) { + if (context.getTypes().charAt(i) == 's') { + buffer.putString((String) context.getParameters()[i]); + } else { + buffer.putInt(((Number) context.getParameters()[i]).intValue()); + } + } + buffer.putInt(context.getValue()); context.getPlayer().getDetails().getSession().write(buffer); } diff --git a/09HDscape-server/src/org/crandor/net/packet/out/Config.java b/09HDscape-server/src/org/crandor/net/packet/out/Config.java index 280faa84c..7cbc523b5 100644 --- a/09HDscape-server/src/org/crandor/net/packet/out/Config.java +++ b/09HDscape-server/src/org/crandor/net/packet/out/Config.java @@ -1,8 +1,8 @@ package org.crandor.net.packet.out; +import org.crandor.net.packet.context.ConfigContext; import org.crandor.net.packet.IoBuffer; import org.crandor.net.packet.OutgoingPacket; -import org.crandor.net.packet.context.ConfigContext; /** * The config outgoing packet. diff --git a/09HDscape-server/src/org/crandor/tools/URLParser.java b/09HDscape-server/src/org/crandor/tools/URLParser.java index c452e541c..a78157573 100644 --- a/09HDscape-server/src/org/crandor/tools/URLParser.java +++ b/09HDscape-server/src/org/crandor/tools/URLParser.java @@ -174,7 +174,7 @@ public class URLParser { */ public Map> getData() { if (!finished) { - throw new IllegalStateException("Parser has not finished!"); + throw new IllegalStateException("Reader has not finished!"); } return data; } diff --git a/09HDscape-server/src/plugin/activity/mta/AlchemySpell.java b/09HDscape-server/src/plugin/activity/mta/AlchemySpell.java index a326eb59e..f78056b1a 100644 --- a/09HDscape-server/src/plugin/activity/mta/AlchemySpell.java +++ b/09HDscape-server/src/plugin/activity/mta/AlchemySpell.java @@ -81,7 +81,7 @@ public final class AlchemySpell extends MagicSpell { boolean alchZone = p.getZoneMonitor().isInZone("Alchemists' Playground"); AlchemistItem alch = null; if (alchZone) { - alch = AlchemistZone.AlchemistItem.forItem(item.getId()); + alch = AlchemistItem.forItem(item.getId()); if (alch == null) { p.getDialogueInterpreter().sendDialogue("You can only convert the items you find in the cupboards."); return false; diff --git a/09HDscape-server/src/plugin/activity/mta/EnchantSpell.java b/09HDscape-server/src/plugin/activity/mta/EnchantSpell.java index 554e21ab8..ba5abd8cc 100644 --- a/09HDscape-server/src/plugin/activity/mta/EnchantSpell.java +++ b/09HDscape-server/src/plugin/activity/mta/EnchantSpell.java @@ -89,7 +89,7 @@ public final class EnchantSpell extends MagicSpell { if (item.getId() == 6903) { pizazz = (getSpellId() == 5 ? 1 : getSpellId() == 16 ? 2 : getSpellId() == 28 ? 3 : getSpellId() == 36 ? 4 : getSpellId() == 51 ? 5 : 6) * 2; } else { - Shapes shape = EnchantingZone.Shapes.forItem(item); + Shapes shape = Shapes.forItem(item); if (shape != null) { int convert = p.getAttribute("mta-convert", 0); convert += 1; diff --git a/09HDscape-server/src/plugin/command/DeveloperCommandPlugin.java b/09HDscape-server/src/plugin/command/DeveloperCommandPlugin.java index 9f62a4993..4ff8ca831 100644 --- a/09HDscape-server/src/plugin/command/DeveloperCommandPlugin.java +++ b/09HDscape-server/src/plugin/command/DeveloperCommandPlugin.java @@ -1,12 +1,16 @@ package plugin.command; +import com.sun.xml.internal.ws.util.StringUtils; import org.crandor.ServerConstants; import org.crandor.cache.Cache; import org.crandor.cache.def.impl.ItemDefinition; import org.crandor.cache.def.impl.NPCDefinition; +import org.crandor.game.component.Component; import org.crandor.game.container.Container; import org.crandor.game.container.impl.EquipmentContainer; import org.crandor.game.content.eco.EconomyManagement; +import org.crandor.game.content.global.shop.Shop; +import org.crandor.game.content.global.shop.ShopViewer; import org.crandor.game.content.global.tutorial.TutorialSession; import org.crandor.game.content.holiday.HolidayItem; import org.crandor.game.content.holiday.ItemLimitation; @@ -46,6 +50,9 @@ import org.crandor.game.world.map.zone.RegionZone; import org.crandor.game.world.repository.Repository; import org.crandor.game.world.update.flag.context.Animation; import org.crandor.game.world.update.flag.context.Graphics; +import org.crandor.net.packet.PacketRepository; +import org.crandor.net.packet.context.ContainerContext; +import org.crandor.net.packet.out.ContainerPacket; import org.crandor.plugin.InitializablePlugin; import org.crandor.plugin.Plugin; import org.crandor.plugin.PluginManager; @@ -56,10 +63,8 @@ import java.awt.*; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.*; import java.util.List; -import java.util.Map; import java.util.Map.Entry; /** @@ -76,12 +81,33 @@ public final class DeveloperCommandPlugin extends CommandPlugin { return this; } + public static class SpawnSearch extends Shop { + + public SpawnSearch() { + super("Spawn Search", false); + } + + @Override + public void open(Player player) { + super.open(player); + player.getPacketDispatch().sendInterfaceConfig(620, 29, true); + player.getPacketDispatch().sendInterfaceConfig(620, 26, true); + } + + @Override + public boolean canSell(Player player, Item item, ItemDefinition def) { + player.sendMessage("You cannot sell items to this store."); + return false; + } + } + @SuppressWarnings("deprecation") @Override public boolean parse(final Player player, String name, String[] args) { switch (name) { - /* case "itemn": + case "find": try { + player.getAttributes().put("spawning_items", true); String itemName = ""; for (int i = 1; i < args.length; i++) itemName += args[i] + ((i == args.length - 1) ? "" : " "); @@ -89,7 +115,6 @@ public final class DeveloperCommandPlugin extends CommandPlugin { player.getAttributes().computeIfAbsent("found_items", k -> new HashMap()); player.getAttributes().remove("found_items"); Container storeItems = new Container(1200); -// ItemsContainer storeItems = new ItemsContainer(1200, false); for (int i = 0; i < ItemDefinition.getDefinitions().size(); i++) { ItemDefinition definition = ItemDefinition.forId(i); itemName = itemName.toLowerCase(); @@ -99,24 +124,19 @@ public final class DeveloperCommandPlugin extends CommandPlugin { int itemId = definition.getId(); if (output.contains(itemName)) { storeItems.add(new Item(itemId, 1)); - player.spawns.put(count, itemId); + player.getAttributes().put("" + count, itemId); count++; } } - player.getPacketDispatch().sendItems(-1, 0, 91, storeItems); - player.getPacketDispatch().sendUnlockIComponentOptionSlots(860, 23, 0, count, 0, 1, 2, 3, 4, 5, 6); - player.getPackets().sendInterSetItemsOptionsScript(860, 23, 91, 8, 150, "Take-1", "Take-10", "Take-1000", "Take-10000", "Take-X"); - player.getPackets().sendHideIComponent(860, 20, true); - player.getPackets().sendHideIComponent(860, 26, true); - player.getPackets().sendHideIComponent(860, 21, true); - player.getPackets().sendIComponentText(860, 18, "Found " + count + " results for item " + StringUtils.capitalize(itemName)); - player.getPackets().sendIComponentText(860, 19, "Click items to spawn them to your inventory."); - player.getInterfaceManager().openComponent(860); - player.getPacketDispatch().sendMessage("Found " + count + " results for the item " + StringUtils.capitalize(itemName) + "."); + + SpawnSearch shop = new SpawnSearch(); + shop.getContainer(0).copy(storeItems); + shop.open(player); + } catch (NumberFormatException e) { return true; } - break;*/ + break; case "tut": if (player.getInventory().isEmpty()) { player.getPacketDispatch().sendMessage("You have nothing to deposit."); diff --git a/09HDscape-server/src/plugin/command/PlayerCommandPlugin.java b/09HDscape-server/src/plugin/command/PlayerCommandPlugin.java index 0cf1017ad..d8e65fe7f 100644 --- a/09HDscape-server/src/plugin/command/PlayerCommandPlugin.java +++ b/09HDscape-server/src/plugin/command/PlayerCommandPlugin.java @@ -14,6 +14,7 @@ import org.crandor.game.system.command.CommandSet; import org.crandor.game.system.communication.ClanRepository; import org.crandor.game.system.communication.CommunicationInfo; import org.crandor.game.world.GameWorld; +import org.crandor.game.world.map.Location; import org.crandor.game.world.repository.Repository; import org.crandor.net.amsc.WorldCommunicator; import org.crandor.plugin.InitializablePlugin; diff --git a/09HDscape-server/src/plugin/command/SystemCommand.java b/09HDscape-server/src/plugin/command/SystemCommand.java index 851c456da..a3104f48d 100644 --- a/09HDscape-server/src/plugin/command/SystemCommand.java +++ b/09HDscape-server/src/plugin/command/SystemCommand.java @@ -12,7 +12,6 @@ import org.crandor.game.system.command.CommandPlugin; import org.crandor.game.system.command.CommandSet; import org.crandor.game.system.mysql.impl.ItemConfigSQLHandler; import org.crandor.game.world.repository.Repository; -import org.crandor.gui.KeldagrimFrame; import org.crandor.net.amsc.WorldCommunicator; import org.crandor.plugin.InitializablePlugin; import org.crandor.plugin.Plugin; @@ -47,9 +46,6 @@ public final class SystemCommand extends CommandPlugin { WorldCommunicator.terminate(); WorldCommunicator.connect(); return true; - case "showgui": - KeldagrimFrame.INSTANCE.setVisible(true); - return true; case "update": if (args.length > 1) { SystemManager.getUpdater().setCountdown(Integer.parseInt(args[1])); diff --git a/09HDscape-server/src/plugin/command/VisualCommand.java b/09HDscape-server/src/plugin/command/VisualCommand.java index 2ce689f83..79264ddc0 100644 --- a/09HDscape-server/src/plugin/command/VisualCommand.java +++ b/09HDscape-server/src/plugin/command/VisualCommand.java @@ -238,7 +238,8 @@ public final class VisualCommand extends CommandPlugin { @Override public boolean pulse() { - PacketRepository.send(Interface.class, new InterfaceContext(player, 548, 77, id, false)); +// PacketRepository.send(Interface.class, new InterfaceContext(player, 548, 77, id, false)); + player.getInterfaceManager().openComponent(id); player.debug("Interface id: " + id); return ++id >= en; } diff --git a/09HDscape-server/src/plugin/consumable/PotionPlugin.java b/09HDscape-server/src/plugin/consumable/PotionPlugin.java index 3cbf79cfe..6f688f04d 100644 --- a/09HDscape-server/src/plugin/consumable/PotionPlugin.java +++ b/09HDscape-server/src/plugin/consumable/PotionPlugin.java @@ -122,8 +122,8 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new CombatPotion(new PotionEffect.Effect("Combat potion", new int[] { 9739, 9741, 9743, 9745 }, null))); - Consumables.add(new CombatPotion(new PotionEffect.Effect("Overload", new int[] { 14784, 14785, 14786, 14787 }, null))); + Consumables.add(new CombatPotion(new Effect("Combat potion", new int[] { 9739, 9741, 9743, 9745 }, null))); + Consumables.add(new CombatPotion(new Effect("Overload", new int[] { 14784, 14785, 14786, 14787 }, null))); return this; } @@ -215,7 +215,7 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new EnergyPotion(new PotionEffect.Effect("Energy potion", new int[] { 3008, 3010, 3012, 3014 }, null))); + Consumables.add(new EnergyPotion(new Effect("Energy potion", new int[] { 3008, 3010, 3012, 3014 }, null))); return this; } @@ -255,7 +255,7 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new FishingPotion(new PotionEffect.Effect("Fishing potion", new int[] { 2438, 151, 153, 155 }, null))); + Consumables.add(new FishingPotion(new Effect("Fishing potion", new int[] { 2438, 151, 153, 155 }, null))); return this; } @@ -293,7 +293,7 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new PrayerPotion(new PotionEffect.Effect("Prayer potion", new int[] { 2434, 139, 141, 143 }, null))); + Consumables.add(new PrayerPotion(new Effect("Prayer potion", new int[] { 2434, 139, 141, 143 }, null))); return this; } @@ -377,7 +377,7 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new RestorePotion(new PotionEffect.Effect("Restore potion", new int[] { 2430, 127, 129, 131 }, null))); + Consumables.add(new RestorePotion(new Effect("Restore potion", new int[] { 2430, 127, 129, 131 }, null))); return this; } @@ -426,7 +426,7 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new SaradominBrew(new PotionEffect.Effect("Saradomin brew", new int[] { 6685, 6687, 6689, 6691 }, null))); + Consumables.add(new SaradominBrew(new Effect("Saradomin brew", new int[] { 6685, 6687, 6689, 6691 }, null))); return this; } @@ -467,7 +467,7 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new SummoningPotion(new PotionEffect.Effect("Summoning potion", new int[] { 12140, 12142, 12144, 12146 }, null))); + Consumables.add(new SummoningPotion(new Effect("Summoning potion", new int[] { 12140, 12142, 12144, 12146 }, null))); return this; } @@ -543,7 +543,7 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new SuperenergyPotion(new PotionEffect.Effect("Super energy", new int[] { 3016, 3018, 3020, 3022 }, null))); + Consumables.add(new SuperenergyPotion(new Effect("Super energy", new int[] { 3016, 3018, 3020, 3022 }, null))); return this; } @@ -551,7 +551,7 @@ public final class PotionPlugin implements Plugin { * Constructs a new {@code SuperenergyPotion} {@code Object}. * @param effect the effect. */ - public SuperenergyPotion(PotionEffect.Effect effect) { + public SuperenergyPotion(Effect effect) { super(effect); super.emptyItem = VIAL; } @@ -581,7 +581,7 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new SuperestorePlugin(new PotionEffect.Effect("Super restore", new int[] { 3024, 3026, 3028, 3030 }, null))); + Consumables.add(new SuperestorePlugin(new Effect("Super restore", new int[] { 3024, 3026, 3028, 3030 }, null))); return this; } @@ -634,8 +634,8 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new ZamorakBrew(new PotionEffect.Effect("Zamorak brew", new int[] { 2450, 189, 191, 193 }, null))); - Consumables.add(new ZamorakBrew(new PotionEffect.Effect("Zamorak mix", new int[] { 11521, 11523 }, null))); + Consumables.add(new ZamorakBrew(new Effect("Zamorak brew", new int[] { 2450, 189, 191, 193 }, null))); + Consumables.add(new ZamorakBrew(new Effect("Zamorak mix", new int[] { 11521, 11523 }, null))); return this; } @@ -679,14 +679,14 @@ public final class PotionPlugin implements Plugin { * Constructs a new {@code AntifirePotion} {@code Object}. * @param effect the effect. */ - public AntifirePotion(final PotionEffect.Effect effect) { + public AntifirePotion(final Effect effect) { super(effect); } @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new AntifirePotion(new PotionEffect.Effect("Antifire potion", new int[] { 2452, 2454, 2456, 2458 }, null))); - Consumables.add(new AntifirePotion(new PotionEffect.Effect("Antifire potion", new int[] { 14753, 14755, 14757, 14759 }, null))); + Consumables.add(new AntifirePotion(new Effect("Antifire potion", new int[] { 2452, 2454, 2456, 2458 }, null))); + Consumables.add(new AntifirePotion(new Effect("Antifire potion", new int[] { 14753, 14755, 14757, 14759 }, null))); return this; } @@ -715,8 +715,8 @@ public final class PotionPlugin implements Plugin { @Override public Plugin newInstance(Object arg) throws Throwable { - Consumables.add(new SuperOSRSPotionPlugin(new PotionEffect.Effect("Super magic potion", new int[] { 14780, 14781, 14782, 14783 }, null))); - Consumables.add(new SuperOSRSPotionPlugin(new PotionEffect.Effect("Super range potion", new int[] { 14776, 14777, 14778, 14779 }, null))); + Consumables.add(new SuperOSRSPotionPlugin(new Effect("Super magic potion", new int[] { 14780, 14781, 14782, 14783 }, null))); + Consumables.add(new SuperOSRSPotionPlugin(new Effect("Super range potion", new int[] { 14776, 14777, 14778, 14779 }, null))); return this; } diff --git a/09HDscape-server/src/plugin/interaction/inter/GameInterface.java b/09HDscape-server/src/plugin/interaction/inter/GameInterface.java index 8b17c37c5..f5d1f2006 100644 --- a/09HDscape-server/src/plugin/interaction/inter/GameInterface.java +++ b/09HDscape-server/src/plugin/interaction/inter/GameInterface.java @@ -31,6 +31,7 @@ public final class GameInterface extends ComponentPlugin { ComponentDefinition.put(750, this); ComponentDefinition.put(751, this); ComponentDefinition.put(740, this); + ComponentDefinition.put(746, this); return this; } @@ -44,6 +45,13 @@ public final class GameInterface extends ComponentPlugin { break; } return true; + case 746: + switch (button){ + case 110: + configureWorldMap(player); + break; + } + return true; case 548: int tut_stage = TutorialSession.getExtension(player).getStage(); if (button >= 38 && button<= 44 || button >= 20 && button <= 26) { @@ -202,11 +210,22 @@ public final class GameInterface extends ComponentPlugin { player.getPacketDispatch().sendMessage("It wouldn't be very wise opening the world map during combat."); return; } - player.getPacketDispatch().sendWindowsPane(755, 0); +// player.getInterfaceManager().openWindowsPane(new Component(755), 1); +// player.getPacketDispatch().sendScriptConfig(1187, 0, "ii", 0); + int position = player.getLocation().getX() << 14 | player.getLocation().getY() | player.getLocation().getZ() << 28; + +// player.getPacketDispatch().sendScriptConfig(622, position, "ii"); +// player.getPacketDispatch().sendScriptConfig(674, position, "ii"); +// player.getPacketDispatch().sendScriptConfig(622, position); +// player.getPacketDispatch().sendScriptConfig(674, position); + System.out.println(position); + + + /*player.getPacketDispatch().sendWindowsPane(755, 1); int hash = player.getLocation().getX() << 14 | player.getLocation().getY(); -// player.getPacketDispatch().sendRunScript(622, "", hash); -// player.getPacketDispatch().sendRunScript(674, "", hash); + player.getPacketDispatch().sendRunScript(622, "", hash); + player.getPacketDispatch().sendRunScript(674, "", hash); PacketRepository.send(InterfaceConfig.class, new InterfaceConfigContext(player, 371, 25, true)); - player.setAttribute("worldMap:viewing", true); + player.setAttribute("worldMap:viewing", true);*/ } } diff --git a/09HDscape-server/src/plugin/interaction/inter/JewelleryInterface.java b/09HDscape-server/src/plugin/interaction/inter/JewelleryInterface.java index 5df7b9ed9..a302d38cf 100644 --- a/09HDscape-server/src/plugin/interaction/inter/JewelleryInterface.java +++ b/09HDscape-server/src/plugin/interaction/inter/JewelleryInterface.java @@ -36,7 +36,7 @@ public final class JewelleryInterface extends ComponentPlugin { @Override public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) { int amount = 0; - JewelleryCrafting.JewelleryItem data = null; + JewelleryItem data = null; switch(button){ case 20: data = JewelleryItem.GOLD_RING; diff --git a/09HDscape-server/src/plugin/interaction/inter/ShoppingPlugin.java b/09HDscape-server/src/plugin/interaction/inter/ShoppingPlugin.java index 927af367e..c64c1e785 100644 --- a/09HDscape-server/src/plugin/interaction/inter/ShoppingPlugin.java +++ b/09HDscape-server/src/plugin/interaction/inter/ShoppingPlugin.java @@ -30,7 +30,22 @@ public final class ShoppingPlugin extends ComponentPlugin { @Override public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) { final ShopViewer viewer = player.getExtension(ShopViewer.class); + if (player.getAttributes().containsKey("spawning_items")) { + switch (opcode) { + case 155: + switch (button) { + case 23: + case 24: + case 0: + viewer.getShop().give(player, slot, 1, viewer.getTabIndex()); + break; + } + break; + } + return true; + } if (viewer == null) { + System.out.println("shop is null"); return true; } final Container container = button == 0 ? player.getInventory() : viewer.getShop().getContainer(viewer.getTabIndex()); @@ -104,6 +119,7 @@ public final class ShoppingPlugin extends ComponentPlugin { public boolean handle() { switch (componentId){ case 620: + System.out.println("hmmm"); viewer.getShop().buy(viewer.getPlayer(), slot, (int) getValue(), viewer.getTabIndex()); break; case 621: diff --git a/09HDscape-server/src/plugin/interaction/inter/WorldMapInterface.java b/09HDscape-server/src/plugin/interaction/inter/WorldMapInterface.java index f8b8cf824..548652fe9 100644 --- a/09HDscape-server/src/plugin/interaction/inter/WorldMapInterface.java +++ b/09HDscape-server/src/plugin/interaction/inter/WorldMapInterface.java @@ -25,10 +25,7 @@ public final class WorldMapInterface extends ComponentPlugin { public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) { switch (button) { case 3: - player.getInterfaceManager().openWindowsPane(new Component(player.getInterfaceManager().isResizable() ? 746 : 548)); - int posHash = player.getLocation().getX() << 14 | player.getLocation().getY(); - player.getPacketDispatch().sendScriptConfig(622, posHash); - player.getPacketDispatch().sendScriptConfig(674, posHash); +// player.getInterfaceManager().openWindowsPane(new Component(player.getInterfaceManager().isResizable() ? 746 : 548), 2); return true; } return false; diff --git a/09HDscape-server/src/plugin/interaction/item/withitem/FruitCuttingPlugin.java b/09HDscape-server/src/plugin/interaction/item/withitem/FruitCuttingPlugin.java index 803fccc98..549b5b43e 100644 --- a/09HDscape-server/src/plugin/interaction/item/withitem/FruitCuttingPlugin.java +++ b/09HDscape-server/src/plugin/interaction/item/withitem/FruitCuttingPlugin.java @@ -182,7 +182,7 @@ public final class FruitCuttingPlugin extends UseWithHandler { @Override public boolean open(Object... args) { - fruit = ((FruitCuttingPlugin.Fruit) args[0]); + fruit = ((Fruit) args[0]); player.getPacketDispatch().sendString("Would you like to...", 140, 4); player.getPacketDispatch().sendItemOnInterface(fruit.getSliced().getId(), 1, 140, 5); player.getPacketDispatch().sendItemOnInterface(fruit.getDiced().getId(), 1, 140, 6); @@ -256,7 +256,7 @@ public final class FruitCuttingPlugin extends UseWithHandler { return; } if (player.getInventory().remove(remove)) { - player.getPacketDispatch().sendMessage("You cut the " + fruit.name().toLowerCase() + " into " + (slice ? fruit == FruitCuttingPlugin.Fruit.PINEAPPLE ? "rings" : "slices" : "chunks") + "."); + player.getPacketDispatch().sendMessage("You cut the " + fruit.name().toLowerCase() + " into " + (slice ? fruit == Fruit.PINEAPPLE ? "rings" : "slices" : "chunks") + "."); for (int i = 0; i < amount; i++) { player.getInventory().add(slice ? fruit.getSliced() : fruit.getDiced()); } diff --git a/09HDscape-server/src/plugin/interaction/item/withobject/PriestInPerilUsePlugin.java b/09HDscape-server/src/plugin/interaction/item/withobject/PriestInPerilUsePlugin.java index 0cbeade42..e8f789c6c 100644 --- a/09HDscape-server/src/plugin/interaction/item/withobject/PriestInPerilUsePlugin.java +++ b/09HDscape-server/src/plugin/interaction/item/withobject/PriestInPerilUsePlugin.java @@ -25,7 +25,7 @@ public class PriestInPerilUsePlugin extends UseWithHandler { /** * (non-Javadoc) - * @see Plugin#newInstance(java.lang.Object) + * @see Plugin#newInstance(Object) */ @Override public Plugin newInstance(Object arg) throws Throwable { diff --git a/09HDscape-server/src/plugin/interaction/object/FlourMakingPlugin.java b/09HDscape-server/src/plugin/interaction/object/FlourMakingPlugin.java index b59a1b843..8ff3dfdea 100644 --- a/09HDscape-server/src/plugin/interaction/object/FlourMakingPlugin.java +++ b/09HDscape-server/src/plugin/interaction/object/FlourMakingPlugin.java @@ -267,8 +267,8 @@ public final class FlourMakingPlugin extends OptionHandler { @Override public boolean handle(NodeUsageEvent event) { final Player player = event.getPlayer(); - FlourMakingPlugin.FlourExtension.extend(player); - final FlourMakingPlugin.FlourExtension extension = player.getExtension(FlourMakingPlugin.FlourExtension.class); + FlourExtension.extend(player); + final FlourExtension extension = player.getExtension(FlourExtension.class); if (extension.getSemiCharges() > 0) { player.getPacketDispatch().sendMessage("There is already grain in the hopper."); return true; diff --git a/09HDscape-server/src/plugin/interaction/object/PriestInPerilOptionPlugin.java b/09HDscape-server/src/plugin/interaction/object/PriestInPerilOptionPlugin.java index b2f179e82..113d3ee30 100644 --- a/09HDscape-server/src/plugin/interaction/object/PriestInPerilOptionPlugin.java +++ b/09HDscape-server/src/plugin/interaction/object/PriestInPerilOptionPlugin.java @@ -23,7 +23,7 @@ import org.crandor.plugin.Plugin; public class PriestInPerilOptionPlugin extends OptionHandler { /** * (non-Javadoc) - * @see Plugin#newInstance(java.lang.Object) + * @see Plugin#newInstance(Object) */ @Override public Plugin newInstance(Object arg) throws Throwable { diff --git a/09HDscape-server/src/plugin/interaction/object/sorceress/GardenObjectsPlugin.java b/09HDscape-server/src/plugin/interaction/object/sorceress/GardenObjectsPlugin.java index 3c682e03a..a3ef7d7dc 100644 --- a/09HDscape-server/src/plugin/interaction/object/sorceress/GardenObjectsPlugin.java +++ b/09HDscape-server/src/plugin/interaction/object/sorceress/GardenObjectsPlugin.java @@ -182,7 +182,7 @@ public final class GardenObjectsPlugin extends OptionHandler { * @param object the object. * @param herbDef the herbdef. */ - private void handleElementalGarden(final Player player, GameObject object, final GardenObjectsPlugin.HerbDefinition herbDef) { + private void handleElementalGarden(final Player player, GameObject object, final HerbDefinition herbDef) { player.lock(); player.addExtension(LogoutTask.class, new LocationLogoutTask(99, herbDef.getRespawn())); player.animate(ANIMATION); @@ -563,7 +563,7 @@ public final class GardenObjectsPlugin extends OptionHandler { Item item = event.getUsedItem(); Item with = event.getBaseItem(); Player player = event.getPlayer(); - GardenObjectsPlugin.SeasonDefinitions def = GardenObjectsPlugin.SeasonDefinitions.forFruitId(item.getId()); + SeasonDefinitions def = SeasonDefinitions.forFruitId(item.getId()); if (item == null || with == null || player == null || def == null) return true; int amt = player.getInventory().getAmount(item); @@ -1213,7 +1213,7 @@ public final class GardenObjectsPlugin extends OptionHandler { public double getExperience() { double total = 0; for (int juiceId : JUICES) { - GardenObjectsPlugin.SeasonDefinitions def = GardenObjectsPlugin.SeasonDefinitions.forJuiceId(juiceId); + SeasonDefinitions def = SeasonDefinitions.forJuiceId(juiceId); if (def == null) { continue; } @@ -1273,7 +1273,7 @@ public final class GardenObjectsPlugin extends OptionHandler { private int dialogueId; - private GardenObjectsPlugin.SeasonDefinitions definition; + private SeasonDefinitions definition; /** * Constructs a new {@code SqirkMakingDialogue.java} {@code Object}. @@ -1329,7 +1329,7 @@ public final class GardenObjectsPlugin extends OptionHandler { interpreter.sendDialogues(player, FacialExpression.ANNOYED, "I should get an empty beer glass to", "hold the juice before I squeeze the fruit."); break; case 1: - definition = GardenObjectsPlugin.SeasonDefinitions.forFruitId((int) args[1]); + definition = SeasonDefinitions.forFruitId((int) args[1]); if (definition == null) end(); interpreter.sendDialogues(player, FacialExpression.ANNOYED, "I think I should wait till I have", "enough fruits to make a full glass."); diff --git a/09HDscape-server/src/plugin/interaction/player/LoginValidationPlugin.java b/09HDscape-server/src/plugin/interaction/player/LoginValidationPlugin.java index 08cdba420..d7747e63d 100644 --- a/09HDscape-server/src/plugin/interaction/player/LoginValidationPlugin.java +++ b/09HDscape-server/src/plugin/interaction/player/LoginValidationPlugin.java @@ -56,11 +56,12 @@ public final class LoginValidationPlugin implements Plugin { if (GameWorld.getSettings().isDevMode()) { player.toggleDebug(); } - if (player.getUsername().equalsIgnoreCase("Ethan")) { +// if (player.getUsername().equalsIgnoreCase("Ethan")) { player.getDetails().setRights(Rights.ADMINISTRATOR); - return this; - } +// return this; +// } TutorialSession.extend(player); + TutorialSession.getExtension(player).setStage(TutorialSession.MAX_STAGE); if (!TutorialSession.getExtension(player).finished()) { GameWorld.submit(new Pulse(1, player) { @Override diff --git a/09HDscape-server/src/plugin/quest/icthlarinslittlehelper/WandererDialogue.java b/09HDscape-server/src/plugin/quest/icthlarinslittlehelper/WandererDialogue.java new file mode 100644 index 000000000..7ba8e6fac --- /dev/null +++ b/09HDscape-server/src/plugin/quest/icthlarinslittlehelper/WandererDialogue.java @@ -0,0 +1,49 @@ +package plugin.quest.icthlarinslittlehelper; + +import org.crandor.game.content.dialogue.DialoguePlugin; +import org.crandor.game.node.entity.player.Player; + +/** + * @author Ethan Kyle Millard + * @since Tue, October 09, 2018 @ 9:02 PM + */ +public class WandererDialogue extends DialoguePlugin { + + public WandererDialogue() { + } + + public WandererDialogue(Player player) { + super(player); + } + + @Override + public DialoguePlugin newInstance(Player player) { + return new WandererDialogue(player); + } + + @Override + public boolean open(Object... args) { + player ("Good day, wanderer."); + return true; + } + + @Override + public boolean handle(int interfaceId, int buttonId) { + switch (stage){ + case 0: + npc ("Hello to you too adventurer."); + next(); + break; + case 1: + break; + } + return true; + } + + @Override + public int[] getIds() { + return new int[] {}; + + + } +} diff --git a/09HDscape-server/src/plugin/quest/learningtheropes/CellarMapZone.java b/09HDscape-server/src/plugin/quest/learningtheropes/CellarMapZone.java new file mode 100644 index 000000000..3d1961249 --- /dev/null +++ b/09HDscape-server/src/plugin/quest/learningtheropes/CellarMapZone.java @@ -0,0 +1,98 @@ +package plugin.quest.learningtheropes; + +import org.crandor.game.node.entity.npc.NPC; +import org.crandor.game.node.entity.player.Player; +import org.crandor.game.world.map.Direction; +import org.crandor.game.world.map.Location; +import org.crandor.game.world.map.build.DynamicRegion; +import org.crandor.game.world.map.zone.MapZone; +import org.crandor.game.world.update.flag.context.Animation; + +/** + * @author Ethan Kyle Millard + * @since Wed, October 10, 2018 @ 1:03 PM + */ +public class CellarMapZone extends MapZone { + + private static final NPC[] NPCS = new NPC[]{ + /** sir vant */ + NPC.create(7938, Location.create(2524, 5005, 0), Direction.NORTH), + /** goblin*/ + NPC.create(7965, Location.create(2524, 4997, 0), Direction.NORTH), + }; + + public static final CellarMapZone INSTANCE = new CellarMapZone(); + + /** + * The region of the zone. + */ + private DynamicRegion region; + + /** + * The base location. + */ + private Location base; + + + /** + * Constructs a new {@code MapZone} {@code Object}. + */ + public CellarMapZone() { + super("Cellar Map Zone", true); + } + + @Override + public void configure() { + region = DynamicRegion.create(10062); + setRegionBase(); + registerRegion(region.getId()); + setNpcs(); + } + + public void create(Player player) { + configure(); + player.teleport(getBase().transform(28, 12, 0)); + } + + private void setNpcs() { + for (NPC n : NPCS) { + n = NPC.create(n.getId(), n.getLocation(), n.getDirection()); + n.setLocation(base.transform(n.getLocation().getLocalX(), n.getLocation().getLocalY(), 0)); + n.setRespawn(false); + n.init(); + n.setWalks(false); + n.animate(new Animation(-1)); + } + } + + /** + * Sets the region base. + */ + private void setRegionBase() { + if (region != null) { + setBase(Location.create(region.getBorders().getSouthWestX(), region.getBorders().getSouthWestY(), 0)); + } + } + + /** + * Gets the base. + * + * @return the base + */ + public Location getBase() { + return base; + } + + /** + * Sets the base. + * + * @param base the base to set. + */ + public void setBase(Location base) { + this.base = base; + } + + public static CellarMapZone get() { + return INSTANCE; + } +} diff --git a/09HDscape-server/src/plugin/quest/learningtheropes/LTRDragonFightCutscene.java b/09HDscape-server/src/plugin/quest/learningtheropes/LTRDragonFightCutscene.java index 9483d4081..7116430ae 100644 --- a/09HDscape-server/src/plugin/quest/learningtheropes/LTRDragonFightCutscene.java +++ b/09HDscape-server/src/plugin/quest/learningtheropes/LTRDragonFightCutscene.java @@ -2,8 +2,15 @@ package plugin.quest.learningtheropes; import org.crandor.game.content.activity.ActivityPlugin; import org.crandor.game.content.activity.CutscenePlugin; +import org.crandor.game.content.global.tutorial.TutorialSession; +import org.crandor.game.content.global.tutorial.TutorialStage; +import org.crandor.game.content.skill.Skills; +import org.crandor.game.node.entity.combat.ImpactHandler; +import org.crandor.game.node.entity.combat.equipment.FireType; import org.crandor.game.node.entity.npc.NPC; import org.crandor.game.node.entity.player.Player; +import org.crandor.game.node.entity.player.link.audio.Audio; +import org.crandor.game.node.entity.state.EntityState; import org.crandor.game.system.task.Pulse; import org.crandor.game.world.GameWorld; import org.crandor.game.world.map.Direction; @@ -11,6 +18,10 @@ import org.crandor.game.world.map.Location; import org.crandor.game.world.map.build.DynamicRegion; import org.crandor.game.world.map.path.Path; import org.crandor.game.world.map.path.Pathfinder; +import org.crandor.game.world.map.zone.Zone; +import org.crandor.game.world.map.zone.ZoneBuilder; +import org.crandor.game.world.update.flag.context.Animation; +import org.crandor.game.world.update.flag.context.Graphics; import org.crandor.net.packet.PacketRepository; import org.crandor.net.packet.context.CameraContext; import org.crandor.net.packet.out.CameraViewPacket; @@ -28,10 +39,34 @@ public class LTRDragonFightCutscene extends CutscenePlugin { NPC.create(7943, Location.create(2524, 5015, 0), Direction.SOUTH), /** sir vant */ NPC.create(7938, Location.create(2524, 5005, 0), Direction.NORTH), - }; + /** goblin*/ + NPC.create(7964, Location.create(2522, 5000, 0), Direction.NORTH), + }; + + private static final Animation SIR_VANT_BLOCK = Animation.create(9941); + private static final Animation SIR_VANT_STAB = Animation.create(9938); + private static final Animation SIR_VANT_SLASH = Animation.create(9939); + private static final Animation SIR_VANT_BLOCK_FIRE = Animation.create(9942); + private static final Animation SIR_VANT_BIG_SLASH = Animation.create(9943); + private static final Animation DRAGON_ATTACK = Animation.create(9922); + private static final Animation DRAGON_BLOCK = Animation.create(9923); + private static final Animation DRAGON_FIRE_BREATH = Animation.create(9919); + private static final Graphics DRAGON_FIRE_BREATH_GFX = new Graphics(1, 64); + private static final Animation DRAGON_SLASHED = Animation.create(9921); + private static final Animation DRAGON_STANDING_UNCUT = Animation.create(9914); + private static final Animation DRAGON_STANDING_CUT = Animation.create(9915); + private static final Animation DRAGON_STANDING_WOBBLING = Animation.create(9916); + private static final Animation DRAGON_STANDING_CUTTING = Animation.create(9917); + private static final Animation DRAGON_FLYING = Animation.create(9913); + private static final Animation GOBLIN_FALLING = Animation.create(9965); + private static final Animation GOBLIN_PLUNDERING = Animation.create(9963); + private static final Animation GOBLIN_HIT_ON_HEAD= Animation.create(9964); + + private final FightPulse fightPulse = new FightPulse(); + public LTRDragonFightCutscene() { this(null); } @@ -63,6 +98,7 @@ public class LTRDragonFightCutscene extends CutscenePlugin { @Override public void open() { + ZoneBuilder.configure(CellarMapZone.get()); setNpcs(); GameWorld.submit(fightPulse); player.lock(); @@ -71,7 +107,6 @@ public class LTRDragonFightCutscene extends CutscenePlugin { } - public final class FightPulse extends Pulse { /** @@ -91,6 +126,12 @@ public class LTRDragonFightCutscene extends CutscenePlugin { switch (counter++) { case 1: System.out.println("Fight begin"); + getSirVant().getSkills().setStaticLevel(Skills.HITPOINTS, 99); + getSirVant().getSkills().setLifepoints(99); + getDragon().getSkills().setStaticLevel(Skills.HITPOINTS, 99); + getDragon().getSkills().setLifepoints(99); + System.out.println("getGoblin().getLocation().getLocalX() = " + getGoblin().getLocation().getLocalX()); + System.out.println("getGoblin().getLocation().getLocalY() = " + getGoblin().getLocation().getLocalY()); break; case 4: @@ -104,13 +145,108 @@ public class LTRDragonFightCutscene extends CutscenePlugin { break; case 13: - camera(32, 10, -3, 5, 450, 100); + camera(32, 10, -4, 5, 450, 100); break; - case 20: + case 15: + getDragon().animate(DRAGON_ATTACK);//attack + getSirVant().animate(SIR_VANT_BLOCK);//block + getSirVant().getImpactHandler().manualHit(getDragon(), 12, ImpactHandler.HitsplatType.NORMAL); + break; + + case 17: + getDragon().animate(DRAGON_BLOCK); + getSirVant().animate(SIR_VANT_STAB); + getDragon().getImpactHandler().manualHit(getSirVant(), 11, ImpactHandler.HitsplatType.NORMAL); + break; + + case 19: + getDragon().animate(DRAGON_BLOCK); + getSirVant().animate(SIR_VANT_SLASH); + getDragon().getImpactHandler().manualHit(getSirVant(), 8, ImpactHandler.HitsplatType.NORMAL); + break; + + case 21: + getDragon().animate(DRAGON_FIRE_BREATH); + getDragon().graphics(DRAGON_FIRE_BREATH_GFX); + getSirVant().animate(SIR_VANT_BLOCK_FIRE); + getSirVant().getImpactHandler().manualHit(getDragon(), 18, ImpactHandler.HitsplatType.NORMAL); + break; + + case 23: + getSirVant().sendChat("Look out behind you!"); + break; + + case 25: + camera(32, 13, -5, -5, 300, 100); + getGoblin().animate(GOBLIN_FALLING); + break; + case 26: + camera(31, 9, -3, -3, 250, 75); + break; + case 27: + path = Pathfinder.find(getGoblin(), getGoblin().getLocation().transform(2, -3, 0), true, Pathfinder.DUMB, (a, b, c) -> 0); + path.walk(getGoblin()); + break; + + case 30: + getGoblin().sendChat("What can I steal in here?"); + getGoblin().animate(GOBLIN_PLUNDERING); + break; + + case 34: + camera(32, 10, -3, 5, 500, 100); + break; + + case 35: + getDragon().animate(DRAGON_FLYING); + break; + + case 39: + getDragon().animate(DRAGON_STANDING_UNCUT); + break; + case 40: + getDragon().animate(DRAGON_STANDING_CUT); + getSirVant().animate(SIR_VANT_BIG_SLASH); + getDragon().getImpactHandler().manualHit(getSirVant(), 30, ImpactHandler.HitsplatType.NORMAL); + break; + case 42: + getDragon().animate(DRAGON_STANDING_WOBBLING); + break; + + case 45: + PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraContext.CameraType.SHAKE, 4, 4, 1200, 4, 4)); + camera(31, 9, -3, -3, 250, 45); + break; + case 46: + getGoblin().face(player); + break; + case 47: + getGoblin().animate(GOBLIN_HIT_ON_HEAD); + break; + case 50: + PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraContext.CameraType.SHAKE, 3, 2, 2, 2, 2)); + getGoblin().getStateManager().set(EntityState.STUNNED, 4); + player.face(getGoblin()); + break; + case 53: + PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraContext.CameraType.RESET, 5, 2, 450, 100, 0)); + break; + case 54: + camera(28, 5, 2, 6, 450, 100); + break; + case 55: + path = Pathfinder.find(getDragon(), getDragon().getLocation().transform(0, 9, 0), true, Pathfinder.DUMB, (a, b, c) -> 0); + path.walk(getDragon()); + break; + case 60: System.out.println("Fight end"); LTRDragonFightCutscene.this.stop(true); + TutorialStage.load(player, 3, false); + CellarMapZone.get().create(player); return true; + case 61: + break; } return !player.isActive(); } @@ -171,6 +307,7 @@ public class LTRDragonFightCutscene extends CutscenePlugin { public void stop(boolean fade) { super.stop(false); player.teleport(Location.create(2524, 5004, 0)); + PacketRepository.send(CameraViewPacket.class, new CameraContext(player, CameraContext.CameraType.RESET, 0, 0, 0, 0, 0)); } /** @@ -204,10 +341,19 @@ public class LTRDragonFightCutscene extends CutscenePlugin { return null; } + private void walk(NPC npc, final Location location) { + Pathfinder.find(npc, location, true, Pathfinder.DUMB).walk(npc); + } + public NPC getDragon() { return getNpc(7943); } public NPC getSirVant() { return getNpc(7938); } + public NPC getGoblin() { + return getNpc(7964); + } + + } diff --git a/09HDscape-server/src/plugin/quest/learningtheropes/SirVantDialogue.java b/09HDscape-server/src/plugin/quest/learningtheropes/SirVantDialogue.java index 772cab742..9bf632c0c 100644 --- a/09HDscape-server/src/plugin/quest/learningtheropes/SirVantDialogue.java +++ b/09HDscape-server/src/plugin/quest/learningtheropes/SirVantDialogue.java @@ -1,9 +1,12 @@ package plugin.quest.learningtheropes; +import org.crandor.game.container.impl.EquipmentContainer; import org.crandor.game.content.dialogue.DialoguePlugin; import org.crandor.game.content.dialogue.FacialExpression; +import org.crandor.game.content.global.tutorial.TutorialSession; import org.crandor.game.content.global.tutorial.TutorialStage; import org.crandor.game.node.entity.player.Player; +import org.crandor.game.node.item.Item; import org.crandor.plugin.InitializablePlugin; /** @@ -13,6 +16,7 @@ import org.crandor.plugin.InitializablePlugin; @InitializablePlugin public class SirVantDialogue extends DialoguePlugin { + /** * Default Constructor */ @@ -33,8 +37,23 @@ public class SirVantDialogue extends DialoguePlugin { @Override public boolean open(Object... args) { - npc(FacialExpression.HAPPY, "My Word! You scared me there, friend. I have no idea", "where you came from, but you have fantastic timing.", "You see, I have come across a dragon."); - setStage(1); + int tut_stage = TutorialSession.getExtension(player).getStage(); + System.out.println("tut_stage = " + tut_stage); + switch (tut_stage) { + case 0: + case 1: + case 2: + case 72: + npc(FacialExpression.HAPPY, "My Word! You scared me there, friend. I have no idea", "where you came from, but you have fantastic timing.", "You see, I have come across a dragon."); + setStage(1); + break; + case 3: + player.getEquipment().replace(new Item(9703), EquipmentContainer.SLOT_WEAPON); + player.getEquipment().replace(new Item(9704), EquipmentContainer.SLOT_SHIELD); + npc("I think we have found a job for you, whoever you are.", "Here, take this sword and shield."); + setStage(10); + break; + } return true; } @@ -69,6 +88,34 @@ public class SirVantDialogue extends DialoguePlugin { end(); TutorialStage.load(player, 2, false); break; + case 10: + npc("I think the value of this property has slumped a little."); + next(); + break; + case 11: + player(FacialExpression.ASKING, "A little? It's got a huge dragon on it!"); + next(); + break; + case 12: + npc(FacialExpression.HAPPY, "I'm sure the owners has no idea when they bought it.", "It would take and interesting individual to deliberately","build a cellar in a dragon's den."); + next(); + break; + case 13: + npc("I believe this dragon has been asleep for a while - at", "least as long as it has taken Lumbridge, the town above","us, to be established. Something must have roused the","dragon - a large noise, tail cramp, the smell of damsels."); + next(); + break; + case 14: + npc("Don't worry, the goblin is stunned, so it can't hurt you", "at the moment. You should know something about","basic combat before tackling it."); + next(); + break; + case 15: + npc("Now, I have to keep watch for the dragon."); + next(); + break; + case 16: + end(); + TutorialStage.load(player, 4, false); + break; } return true; } diff --git a/09HDscape-server/src/plugin/skill/construction/BuildOptionPlugin.java b/09HDscape-server/src/plugin/skill/construction/BuildOptionPlugin.java index 8fb4e1027..52bf55ad7 100644 --- a/09HDscape-server/src/plugin/skill/construction/BuildOptionPlugin.java +++ b/09HDscape-server/src/plugin/skill/construction/BuildOptionPlugin.java @@ -64,9 +64,11 @@ public final class BuildOptionPlugin extends OptionHandler { Hotspot hotspot = player.getHouseManager().getHotspot(object); if (hotspot == null || !isBuildable(player, object, hotspot)) { System.out.println(hotspot == null); - System.err.println("Construction (building): " + hotspot + " : " + object); + System.err.println("Construction (building): " + hotspot + " : " + object + " chunkX = " + object.getLocation().getChunkX() + ", chunkY = " + object.getLocation().getChunkY()); return true; } + System.out.println(object + " chunkX = " + object.getCenterLocation().getChunkX() + ", chunkY = " + object.getCenterLocation().getChunkY()); + player.setAttribute("con:hotspot", hotspot); BuildingUtils.openBuildInterface(player, hotspot.getHotspot()); return true; diff --git a/09HDscape-server/src/plugin/skill/construction/ConstructionInterface.java b/09HDscape-server/src/plugin/skill/construction/ConstructionInterface.java index 453684eaf..409c57716 100644 --- a/09HDscape-server/src/plugin/skill/construction/ConstructionInterface.java +++ b/09HDscape-server/src/plugin/skill/construction/ConstructionInterface.java @@ -21,7 +21,7 @@ import org.crandor.plugin.Plugin; public final class ConstructionInterface extends ComponentPlugin { @Override - public Plugin newInstance(Object arg) throws Throwable { + public Plugin newInstance(Object arg) { ComponentDefinition.put(396, this); ComponentDefinition.put(398, this); ComponentDefinition.put(402, this); @@ -31,85 +31,85 @@ public final class ConstructionInterface extends ComponentPlugin { @Override public boolean handle(Player player, Component component, int opcode, int button, int slot, int itemId) { switch (component.getId()) { - case 396: - switch (button) { - case 11: - player.getInterfaceManager().close(); - Hotspot hotspot = player.getAttribute("con:hotspot"); - GameObject object = player.getAttribute("con:hsobject"); - if (hotspot == null || object == null) { - System.err.println("Failed building decoration " + hotspot + " : " + object); - break; - } - slot = ((slot % 2 != 0) ? 4 : 0) + (slot >> 1); - if (slot >= hotspot.getHotspot().getDecorations().length) { - System.err.println("Failed building decoration " + slot + "/" + hotspot.getHotspot().getDecorations().length); - break; - } - boolean debug = player.isStaff(); - Decoration deco = hotspot.getHotspot().getDecorations()[slot]; - if (!debug) { - if (player.getSkills().getLevel(Skills.CONSTRUCTION) < deco.getLevel()) { - player.getPacketDispatch().sendMessage("You need to have a Construction level of " + deco.getLevel() + " to build that."); - return true; - } - if (!player.getInventory().containsItems(deco.getItems())) { - player.getPacketDispatch().sendMessage("You don't have the right materials."); - return true; - } - for (int tool : deco.getTools()) { - if (tool == BuildingUtils.WATERING_CAN) { - boolean hasWateringCan = false; - for (int i = 0; i < 8; i++) { - if (player.getInventory().contains(tool - i, 1)) { - hasWateringCan = true; - break; - } - } - if (!hasWateringCan) { - player.getPacketDispatch().sendMessage("You need a watering can to plant this."); + case 396: + switch (button) { + case 132: + player.getInterfaceManager().close(); + Hotspot hotspot = player.getAttribute("con:hotspot"); + GameObject object = player.getAttribute("con:hsobject"); + if (hotspot == null || object == null) { + System.err.println("Failed building decoration " + hotspot + " : " + object); + break; + } + slot = ((slot % 2 != 0) ? 4 : 0) + (slot >> 1); + if (slot >= hotspot.getHotspot().getDecorations().length) { + System.err.println("Failed building decoration " + slot + "/" + hotspot.getHotspot().getDecorations().length); + break; + } + boolean debug = player.isStaff(); + Decoration deco = hotspot.getHotspot().getDecorations()[slot]; + if (!debug) { + if (player.getSkills().getLevel(Skills.CONSTRUCTION) < deco.getLevel()) { + player.sendMessage("You need to have a Construction level of " + deco.getLevel() + " to build that."); return true; } - continue; + if (!player.getInventory().containsItems(deco.getItems())) { + player.sendMessage("You don't have the right materials."); + return true; + } + for (int tool : deco.getTools()) { + if (tool == BuildingUtils.WATERING_CAN) { + boolean hasWateringCan = false; + for (int i = 0; i < 8; i++) { + if (player.getInventory().contains(tool - i, 1)) { + hasWateringCan = true; + break; + } + } + if (!hasWateringCan) { + player.sendMessage("You need a watering can to plant this."); + return true; + } + continue; + } + if (!player.getInventory().contains(tool, 1)) { + player.sendMessage("You need a " + ItemDefinition.forId(tool).getName() + " to build this."); + return true; + } + } } - if (!player.getInventory().contains(tool, 1)) { - player.getPacketDispatch().sendMessage("You need a " + ItemDefinition.forId(tool).getName() + " to build this."); + BuildingUtils.buildDecoration(player, hotspot, deco, object); + return true; + } + break; + case 398: + switch (button) { + case 14: + player.getHouseManager().toggleBuildingMode(player, true); + return true; + case 1: + player.getHouseManager().toggleBuildingMode(player, false); + return true; + case 15: + player.getHouseManager().expelGuests(player); + return true; + case 13: + if (!player.getHouseManager().isInHouse(player)) { + player.sendMessage("You can't do this outside of your house."); return true; } - } + HouseManager.leave(player); + return true; } - BuildingUtils.buildDecoration(player, hotspot, deco, object); - return true; - } - break; - case 398: - switch (button) { - case 15: - player.getHouseManager().toggleBuildingMode(player, true); - return true; - case 1: - player.getHouseManager().toggleBuildingMode(player, false); - return true; - case 27: - player.getHouseManager().expelGuests(player); - return true; - case 29: - if (!player.getHouseManager().isInHouse(player)) { - player.getPacketDispatch().sendMessage("You can't do this outside of your house."); + break; + case 402: + int index = button - 160; + System.err.println("BuildRoom Interface Index: " + index); + if (index > -1 && index < RoomProperties.values().length) { + player.getDialogueInterpreter().open("con:room", RoomProperties.values()[index]); return true; } - HouseManager.leave(player); - return true; - } - break; - case 402: - int index = button - 160; - //System.err.println("BuildRoom Interface Index: " + index); - if (index > -1 && index < RoomProperties.values().length) { - player.getDialogueInterpreter().open("con:room", RoomProperties.values()[index]); - return true; - } - break; + break; } return false; } diff --git a/09HDscape-server/src/plugin/skill/construction/EstateAgentDialogue.java b/09HDscape-server/src/plugin/skill/construction/EstateAgentDialogue.java index 686c8c260..3cc924043 100644 --- a/09HDscape-server/src/plugin/skill/construction/EstateAgentDialogue.java +++ b/09HDscape-server/src/plugin/skill/construction/EstateAgentDialogue.java @@ -15,304 +15,360 @@ import org.crandor.plugin.InitializablePlugin; /** * Represents the estate agent dialogue. + * * @author 'Vexia * @version 1.0 */ @InitializablePlugin public final class EstateAgentDialogue extends DialoguePlugin { - - /** - * Represents the book item. - */ - private static final Item BOOK = new Item(8463, 1); - /** - * Constructs a new {@code EstateAgentDialogue} {@code Object}. - */ - public EstateAgentDialogue() { - /** - * empty. - */ - } + /** + * Represents the book item. + */ + private static final Item BOOK = new Item(8463, 1); - /** - * Constructs a new {@code EstateAgentDialogue} {@code Object}. - * @param player the player. - */ - public EstateAgentDialogue(Player player) { - super(player); - } - - @Override - public DialoguePlugin newInstance(Player player) { - return new EstateAgentDialogue(player); - } + /** + * Constructs a new {@code EstateAgentDialogue} {@code Object}. + */ + public EstateAgentDialogue() { + /** + * empty. + */ + } - @Override - public boolean open(Object... args) { - npc = (NPC) args[0]; - interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Hello. Welcome to the " + GameWorld.getName() + " Housing Agency! What", "can I do for you?"); - stage = 0; - return true; - } + /** + * Constructs a new {@code EstateAgentDialogue} {@code Object}. + * + * @param player the player. + */ + public EstateAgentDialogue(Player player) { + super(player); + } - @Override - public boolean handle(int interfaceId, int buttonId) { - switch (stage) { - case 0: - if (player.getHouseManager().hasHouse()) { - interpreter.sendOptions("Select an Option", "Can you move my house please?", "Can you redecorate my house please?", "Could I have a Construction guidebook?", "Tell me about houses.", "Tell me about that skillcape you're wearing."); - stage = 1; - } else { - interpreter.sendOptions("Select an Option", "How can I get a house?", "Tell me about houses."); - stage = 2; - } - break; - case 1: - switch (buttonId) { - case 1: - interpreter.sendDialogues(player, FacialExpression.NORMAL, "Can you move my house please?"); - stage = 10; - break; - case 2: - interpreter.sendDialogues(player, FacialExpression.NORMAL, "Can you redecorate my house please?"); - stage = 30; - break; - case 3: - interpreter.sendDialogues(player, FacialExpression.NORMAL, "Could I have a Construction guidebook?"); - stage = 60; - break; - case 4: - interpreter.sendDialogues(player, FacialExpression.NORMAL, "Tell me about houses!"); - stage = 90; - break; - case 5: - interpreter.sendDialogues(player, FacialExpression.NORMAL, "Tell me about that skillcape you're wearing!"); - stage = Skillcape.isMaster(player, Skills.CONSTRUCTION) ? 102 : 100; - break; - } - break; - case 2: - switch (buttonId) { - case 1: - player("How can I get a house?"); - stage = 3; - break; - case 2: - player("Tell me about houses."); - stage = 90; - break; - } - break; - case 3: - npc("I can sell you a starting house in Rimmington for", "1000 coins. As you increase your construction skill you", "will be able to have your house moved to other areas", "and redecorated in other styles."); - stage = 4; - break; - case 4: - npc("Do you want to buy a starter house?"); - stage = 5; - break; - case 5: - options("Yes please!", "No thanks."); - stage = 6; - break; - case 6: - switch (buttonId) { - case 1: - player("Yes please!"); - stage = 7; - break; - case 2: - player("No thanks."); - stage = 150; - break; - } - break; - case 7: - if (player.getInventory().contains(995, 1000)) { - player.getInventory().remove(new Item(995, 1000)); - player.getHouseManager().create(HouseLocation.RIMMINGTON); - npc("Thank you. Go through the Rimmington house portal", "and you will find your house ready for you to start", "building in it."); - stage = 150; - } else { - npc("You don't have enough money to buy a house,", "come back when you can afford one."); - stage = 150; - } - break; - case 8: - if (GameWorld.getSettings().isDevMode() && GameWorld.getSettings().isBeta()) { - npc("This book will help you to start building your house.", "When you open the book you will receive some", "Construction resources."); - } else { - npc("This book will help you to start building your house."); - } - player.getInventory().add(BOOK); - stage = 150; - break; - case 10: - //HouseLocation.HOUSE_OPTIONS.open(player); - end(); - break; - case 30: - npc("Certainly. My magic can rebuild the house in a", "completely new style! What style would you like?"); - stage = 31; - break; - case 31: - options("Basic wood (5,000)", "Basic stone (5,000)", "Whitewashed stone (7,500)", "Fremennik-style wood (10,000)", "More..."); - stage = 32; - break; - case 32: - switch (buttonId) { - case 1: - player("Basic wood please!"); - stage = 33; - break; - case 2: - player("Basic stone please!"); - stage = 34; - break; - case 3: - player("Whitewashed stone please!"); - stage = 35; - break; - case 4: - player("Fremennik-style wood please!"); - stage = 36; - break; - case 5: - options("Tropical wood (15,000)", "Fancy stone (25,000)", "Previous..."); - stage = 39; - break; - } - break; - case 33: - redecorate(HousingStyle.BASIC_WOOD); - break; - case 34: - redecorate(HousingStyle.BASIC_STONE); - break; - case 35: - redecorate(HousingStyle.WHITEWASHED_STONE); - break; - case 36: - redecorate(HousingStyle.FREMENNIK_STYLE_WOOD); - break; - case 37: - redecorate(HousingStyle.TROPICAL_WOOD); - break; - case 38: - redecorate(HousingStyle.FANCY_STONE); - break; - case 39: - switch (buttonId) { - case 1: - player("Tropical wood please!"); - stage = 37; - break; - case 2: - player("Fancy stone please!"); - stage = 38; - break; - case 3: - options("Basic wood (5,000)", "Basic stone (5,000)", "Whitewashed stone (7,500)", "Fremennik-style wood (10,000)", "More..."); - stage = 32; - break; - } - break; - case 60: - interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Certainly."); - player.getInventory().add(BOOK); - stage = 150; - break; - case 90: - interpreter.sendDialogues(npc, FacialExpression.NORMAL, "It all came out of the wizards' experiments. They found", "a way to fold space, so that they could pack many", "acres of land into an area only a foot across."); - stage = 91; - break; - case 91: - interpreter.sendDialogues(npc, FacialExpression.NORMAL, "They created several folded-space regions across", "" + GameWorld.getName() + ". Each one contains hundreds of small plots", "where people can build houses."); - stage = 92; - break; - case 92: - interpreter.sendDialogues(player, FacialExpression.NORMAL, "Ah, so that's how everyone can have a house without", "them cluttering up the world!"); - stage = 93; - break; - case 93: - interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Quite. The wizards didn't want to get bogged down", "in the business side of things so they ", "hired me to sell the houses."); - stage = 94; - break; - case 94: - interpreter.sendDialogues(npc, FacialExpression.NORMAL, "There are various other people across " + GameWorld.getName() + " who can", "help you furnish your house. You should start buying", "planks from the sawmill operator in Varrock."); - stage = 150; - break; - case 100: - interpreter.sendDialogues(npc, FacialExpression.NORMAL, "As you may know, skillcapes are only available to masters", "in a skill. I have spent my entire life building houses and", "now I spend my time selling them! As a sign of my abilites", "I wear this Skillcape of Construction. If you ever have"); - stage = 101; - break; - case 101: - interpreter.sendDialogues(npc, FacialExpression.NORMAL, "enough skill to build a demonic throne, come and talk to", "me and I'll sell you a skillcape like mine."); - stage = 150; - break; - case 102: - interpreter.sendDialogues(npc, FacialExpression.HAPPY, "I see you have recently achieved 99 construction.", "Would you like to buy a cape for 99,0000 gp?"); - stage = 103; - break; - case 103: - interpreter.sendOptions("Select an Option", "Yes, I'll pay the 99k", "No thanks, maybe later."); - stage = 104; - break; - case 104: - switch (buttonId) { - case 1: - if (Skillcape.purchase(player, Skills.CONSTRUCTION)) { - npc("Here you go lad, enjoy!"); - } - stage = 150; - break; - case 2: - stage = 150; - break; - } - break; - case 150: - end(); - break; - } - return true; - } - - /** - * Redecorates the player's house. - * @param style The house style. - */ - private void redecorate(HousingStyle style) { - boolean diary = false;//player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR).isComplete(0); - if (style == player.getHouseManager().getStyle()) { - npc("Your house is already in that style!"); - stage = 31; - return; - } - if (style.getLevel() > player.getSkills().getStaticLevel(Skills.CONSTRUCTION)) { - npc("You need a Construction level of " + style.getLevel() + " to buy this style."); - stage = 31; - return; - } - if (!player.getInventory().contains(995, style.getCost()) && !diary) { - npc("Hmph. Come back when you have " + style.getCost() + " coins."); - stage = 150; - return; - } - if (!diary) { - player.getInventory().remove(new Item(995, style.getCost())); - } - player.getHouseManager().redecorate(style); - npc("Your house has been redecorated."); - if (player.getLocation().withinDistance(new Location(2982, 3370))) { - //player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR).updateTask(player, 1, 5, true); - } - stage = 150; - } + @Override + public DialoguePlugin newInstance(Player player) { + return new EstateAgentDialogue(player); + } - @Override - public int[] getIds() { - return new int[] { 4247 }; - } + @Override + public boolean open(Object... args) { + npc = (NPC) args[0]; + interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Hello. Welcome to the " + GameWorld.getName() + " Housing Agency! What", "can I do for you?"); + stage = 0; + return true; + } + + @Override + public boolean handle(int interfaceId, int buttonId) { + switch (stage) { + case 0: + if (player.getHouseManager().hasHouse()) { + interpreter.sendOptions("Select an Option", "Can you move my house please?", "Can you redecorate my house please?", "Could I have a Construction guidebook?", "Tell me about houses.", "Tell me about that skillcape you're wearing."); + stage = 1; + } else { + interpreter.sendOptions("Select an Option", "How can I get a house?", "Tell me about houses."); + stage = 2; + } + break; + case 1: + switch (buttonId) { + case 1: + interpreter.sendDialogues(player, FacialExpression.NORMAL, "Can you move my house please?"); + stage = 10; + break; + case 2: + interpreter.sendDialogues(player, FacialExpression.NORMAL, "Can you redecorate my house please?"); + stage = 30; + break; + case 3: + interpreter.sendDialogues(player, FacialExpression.NORMAL, "Could I have a Construction guidebook?"); + stage = 60; + break; + case 4: + interpreter.sendDialogues(player, FacialExpression.NORMAL, "Tell me about houses!"); + stage = 90; + break; + case 5: + interpreter.sendDialogues(player, FacialExpression.NORMAL, "Tell me about that skillcape you're wearing!"); + stage = Skillcape.isMaster(player, Skills.CONSTRUCTION) ? 102 : 100; + break; + } + break; + case 2: + switch (buttonId) { + case 1: + player("How can I get a house?"); + stage = 3; + break; + case 2: + player("Tell me about houses."); + stage = 90; + break; + } + break; + case 3: + npc("I can sell you a starting house in Rimmington for", "1000 coins. As you increase your construction skill you", "will be able to have your house moved to other areas", "and redecorated in other styles."); + stage = 4; + break; + case 4: + npc("Do you want to buy a starter house?"); + stage = 5; + break; + case 5: + options("Yes please!", "No thanks."); + stage = 6; + break; + case 6: + switch (buttonId) { + case 1: + player("Yes please!"); + stage = 7; + break; + case 2: + player("No thanks."); + stage = 150; + break; + } + break; + case 7: + if (player.getInventory().contains(995, 1000)) { + player.getInventory().remove(new Item(995, 1000)); + player.getHouseManager().create(HouseLocation.RIMMINGTON); + npc("Thank you. Go through the Rimmington house portal", "and you will find your house ready for you to start", "building in it."); + stage = 150; + } else { + npc("You don't have enough money to buy a house,", "come back when you can afford one."); + stage = 150; + } + break; + case 8: + if (GameWorld.getSettings().isDevMode() && GameWorld.getSettings().isBeta()) { + npc("This book will help you to start building your house.", "When you open the book you will receive some", "Construction resources."); + } else { + npc("This book will help you to start building your house."); + } + player.getInventory().add(BOOK); + stage = 150; + break; + case 10: + player("Can you move my house please?"); +// HouseLocation.HOUSE_OPTIONS.open(player); + stage = 200; + break; + case 30: + npc("Certainly. My magic can rebuild the house in a", "completely new style! What style would you like?"); + stage = 31; + break; + case 31: + options("Basic wood (5,000)", "Basic stone (5,000)", "Whitewashed stone (7,500)", "Fremennik-style wood (10,000)", "More..."); + stage = 32; + break; + case 32: + switch (buttonId) { + case 1: + player("Basic wood please!"); + stage = 33; + break; + case 2: + player("Basic stone please!"); + stage = 34; + break; + case 3: + player("Whitewashed stone please!"); + stage = 35; + break; + case 4: + player("Fremennik-style wood please!"); + stage = 36; + break; + case 5: + options("Tropical wood (15,000)", "Fancy stone (25,000)", "Previous..."); + stage = 39; + break; + } + break; + case 33: + redecorate(HousingStyle.BASIC_WOOD); + break; + case 34: + redecorate(HousingStyle.BASIC_STONE); + break; + case 35: + redecorate(HousingStyle.WHITEWASHED_STONE); + break; + case 36: + redecorate(HousingStyle.FREMENNIK_STYLE_WOOD); + break; + case 37: + redecorate(HousingStyle.TROPICAL_WOOD); + break; + case 38: + redecorate(HousingStyle.FANCY_STONE); + break; + case 39: + switch (buttonId) { + case 1: + player("Tropical wood please!"); + stage = 37; + break; + case 2: + player("Fancy stone please!"); + stage = 38; + break; + case 3: + options("Basic wood (5,000)", "Basic stone (5,000)", "Whitewashed stone (7,500)", "Fremennik-style wood (10,000)", "More..."); + stage = 32; + break; + } + break; + case 60: + interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Certainly."); + player.getInventory().add(BOOK); + stage = 150; + break; + case 90: + interpreter.sendDialogues(npc, FacialExpression.NORMAL, "It all came out of the wizards' experiments. They found", "a way to fold space, so that they could pack many", "acres of land into an area only a foot across."); + stage = 91; + break; + case 91: + interpreter.sendDialogues(npc, FacialExpression.NORMAL, "They created several folded-space regions across", "" + GameWorld.getName() + ". Each one contains hundreds of small plots", "where people can build houses."); + stage = 92; + break; + case 92: + interpreter.sendDialogues(player, FacialExpression.NORMAL, "Ah, so that's how everyone can have a house without", "them cluttering up the world!"); + stage = 93; + break; + case 93: + interpreter.sendDialogues(npc, FacialExpression.NORMAL, "Quite. The wizards didn't want to get bogged down", "in the business side of things so they ", "hired me to sell the houses."); + stage = 94; + break; + case 94: + interpreter.sendDialogues(npc, FacialExpression.NORMAL, "There are various other people across " + GameWorld.getName() + " who can", "help you furnish your house. You should start buying", "planks from the sawmill operator in Varrock."); + stage = 150; + break; + case 100: + interpreter.sendDialogues(npc, FacialExpression.NORMAL, "As you may know, skillcapes are only available to masters", "in a skill. I have spent my entire life building houses and", "now I spend my time selling them! As a sign of my abilites", "I wear this Skillcape of Construction. If you ever have"); + stage = 101; + break; + case 101: + interpreter.sendDialogues(npc, FacialExpression.NORMAL, "enough skill to build a demonic throne, come and talk to", "me and I'll sell you a skillcape like mine."); + stage = 150; + break; + case 102: + interpreter.sendDialogues(npc, FacialExpression.HAPPY, "I see you have recently achieved 99 construction.", "Would you like to buy a cape for 99,0000 gp?"); + stage = 103; + break; + case 103: + interpreter.sendOptions("Select an Option", "Yes, I'll pay the 99k", "No thanks, maybe later."); + stage = 104; + break; + case 104: + switch (buttonId) { + case 1: + if (Skillcape.purchase(player, Skills.CONSTRUCTION)) { + npc("Here you go lad, enjoy!"); + } + stage = 150; + break; + case 2: + stage = 150; + break; + } + break; + case 200: + npc("Certainly. Where would you like it moved to?"); + stage++; + break; + case 201: + options("Rimmington (5,000)", "Taverley (5,000)", "Pollnivneach (7,500)", "Rellekka (10,000)", "More..."); + stage++; + break; + case 202: + switch (buttonId) { + case 5: + options("Brimhaven (15,000)", "Yanille (25,000)", "...Previous"); + stage++; + break; + default: + configureMove(HouseLocation.values()[5 + buttonId]); + break; + } + break; + case 203: + switch (buttonId) { + case 3: + options("Rimmington (5,000)", "Taverley (5,000)", "Pollnivneach (7,500)", "Rellekka (10,000)", "More..."); + stage++; + break; + default: + configureMove(HouseLocation.values()[buttonId]); + break; + } + break; + case 204: + HouseLocation moveLoc = player.getAttribute("con:moveLoc", HouseLocation.RIMMINGTON); + if (player.getHouseManager().getLocation() == moveLoc) { + npc("Your house is already there!"); + break; + } + if (!moveLoc.hasLevel(player)) { + npc("I'm afraid you don't have a high enough construction", "level to move there. You need to have level " + moveLoc.getLevelRequirement() + "."); + break; + } + break; + case 150: + end(); + break; + } + return true; + } + + /** + * Configures the move. + * + * @param location The house location. + */ + private void configureMove(HouseLocation location) { + player.setAttribute("con:moveLoc", location); + player("To " + location.getName() + " please!"); + stage = 64; + } + + /** + * Redecorates the player's house. + * + * @param style The house style. + */ + private void redecorate(HousingStyle style) { + boolean diary = false;//player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR).isComplete(0); + if (style == player.getHouseManager().getStyle()) { + npc("Your house is already in that style!"); + stage = 31; + return; + } + if (style.getLevel() > player.getSkills().getStaticLevel(Skills.CONSTRUCTION)) { + npc("You need a Construction level of " + style.getLevel() + " to buy this style."); + stage = 31; + return; + } + if (!player.getInventory().contains(995, style.getCost()) && !diary) { + npc("Hmph. Come back when you have " + style.getCost() + " coins."); + stage = 150; + return; + } + if (!diary) { + player.getInventory().remove(new Item(995, style.getCost())); + } + player.getHouseManager().redecorate(style); + npc("Your house has been redecorated."); + if (player.getLocation().withinDistance(new Location(2982, 3370))) { + //player.getAchievementDiaryManager().getDiary(DiaryType.FALADOR).updateTask(player, 1, 5, true); + } + stage = 150; + } + + @Override + public int[] getIds() { + return new int[]{4247}; + } } \ No newline at end of file diff --git a/09HDscape-server/src/plugin/skill/construction/decoration/bedroom/ClockPlugin.java b/09HDscape-server/src/plugin/skill/construction/decoration/bedroom/ClockPlugin.java index db73971d4..0517e6f00 100644 --- a/09HDscape-server/src/plugin/skill/construction/decoration/bedroom/ClockPlugin.java +++ b/09HDscape-server/src/plugin/skill/construction/decoration/bedroom/ClockPlugin.java @@ -8,8 +8,7 @@ import org.crandor.game.node.entity.player.Player; import org.crandor.game.node.object.GameObject; import org.crandor.plugin.InitializablePlugin; import org.crandor.plugin.Plugin; - -import java.util.Calendar; +import org.joda.time.DateTime; /** * ClockPlugin.java @@ -30,8 +29,8 @@ public class ClockPlugin extends OptionHandler { @Override public boolean handle(Player player, Node node, String option) { GameObject object = node.asObject(); - Calendar now = Calendar.getInstance(); - int minuteDisplay = ((int) (now.get(Calendar.MINUTE) / 5)) * 5; + DateTime now = new DateTime(); + int minuteDisplay = ((int) (now.getMinuteOfHour() / 5)) * 5; StringBuilder sb = new StringBuilder("It's "); if (minuteDisplay == 0) { sb.append("Rune o'clock."); diff --git a/09HDscape-server/src/plugin/skill/farming/FarmHolderPlugin.java b/09HDscape-server/src/plugin/skill/farming/FarmHolderPlugin.java index fd8c8f858..97ffbeb3e 100644 --- a/09HDscape-server/src/plugin/skill/farming/FarmHolderPlugin.java +++ b/09HDscape-server/src/plugin/skill/farming/FarmHolderPlugin.java @@ -121,7 +121,7 @@ public final class FarmHolderPlugin implements Plugin { final FarmingItemHolder holder = FarmingItemHolder.forHolder(item); switch (option) { case "fill": - final boolean sack = holder != null && holder.ordinal() < 3 ? true : (item.getId() == SACK.getId() ? true : false); + final boolean sack = holder != null && holder.ordinal() < 3 || (item.getId() == SACK.getId()); final Item base = getRemoveItem(player, item, sack); if (base == null) { player.getPacketDispatch().sendMessage(sack ? "You don't have any potatoes, onions, or cabbages." : "You don't have any fruit to fill the basket with."); diff --git a/09HDscape-server/src/plugin/zone/GrandExchangeZone.java b/09HDscape-server/src/plugin/zone/GrandExchangeZone.java index bbaaddaaf..f903de1b7 100644 --- a/09HDscape-server/src/plugin/zone/GrandExchangeZone.java +++ b/09HDscape-server/src/plugin/zone/GrandExchangeZone.java @@ -55,7 +55,7 @@ public final class GrandExchangeZone extends MapZone implements Plugin { @Override public void configure() { - addObjects(); +// addObjects(); PluginManager.definePlugin(new TeleporterDialogue(), new GnomeTravellerPlugin(), new RewardTraderDialogue()); ShopSQLHandler.getUidShops().put(1485756, CREDIT_STORE); super.register(new ZoneBorders(3146, 3472, 3183, 3508)); @@ -408,7 +408,7 @@ public final class GrandExchangeZone extends MapZone implements Plugin { ShopSQLHandler.openUid(player, 200); break; case 2: - if (player.getSavedData().getGlobalData().getGlobalTeleporterDelay() > System.currentTimeMillis()) { + /*if (player.getSavedData().getGlobalData().getGlobalTeleporterDelay() > System.currentTimeMillis()) { long millis = player.getSavedData().getGlobalData().getGlobalTeleporterDelay() - System.currentTimeMillis(); int minutes = (int) TimeUnit.MILLISECONDS.toMinutes(millis); if (minutes < 1) { @@ -417,7 +417,7 @@ public final class GrandExchangeZone extends MapZone implements Plugin { interpreter.sendDialogue("You need to wait " + minutes + " more minute" + (minutes > 1 ? "s" : "") + " in order to use the free", "teleportation system again."); stage = -10; return true; - } + }*/ player.removeAttribute("global_teleporter"); String[] options = new String[TELEPORTS.length]; for (int i = 0; i < TELEPORTS.length; i++) {