diff --git a/2006Scape Client/src/main/java/ClientSettings.java b/2006Scape Client/src/main/java/ClientSettings.java index 13e1b682..34fade5b 100644 --- a/2006Scape Client/src/main/java/ClientSettings.java +++ b/2006Scape Client/src/main/java/ClientSettings.java @@ -6,8 +6,8 @@ import java.math.BigInteger; */ public class ClientSettings { - - public static String SNOW_MONTH = ".12"; + + public static String SNOW_MONTH = ".12"; /** * The Servers Name */ @@ -18,12 +18,24 @@ public class ClientSettings { public final static String SERVER_WEBSITE = "www.2006Scape.org"; /** * The Servers Ip - * * You don't have to change this, the client will automatically connect to the server * on localhost (Assuming you're running Client and LocalGame respectively) - * */ public static String SERVER_IP = "www.2006Scape.org"; + /** + * The Servers World + * This Determines The Port The Server Will Connect On + * World 1 Will Connect On Port 43594 + * World 2 Will Connect On Port 43598 + */ + public static int SERVER_WORLD = 1; + + /** + * Enables/Disables FileServer CRC Checking For Cache Updates + * FileServer Must Be Running Before Starting The Client If This Is True + */ + public static boolean CHECK_CRC = true; + /** * The Npc Bits for the Server */ diff --git a/2006Scape Client/src/main/java/Game.java b/2006Scape Client/src/main/java/Game.java index b4ec8421..83fb46e0 100644 --- a/2006Scape Client/src/main/java/Game.java +++ b/2006Scape Client/src/main/java/Game.java @@ -25,6 +25,7 @@ import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Calendar; import java.util.Date; +import java.util.zip.CRC32; /** * NOTICE: IF YOU CHANGE ANYTHING IN GAME.JAVA, PLEASE COPY-PASTE THE WHOLE CLASS OVER TO LOCALGAME.JAVA @@ -3429,11 +3430,12 @@ public class Game extends RSApplet { } } catch (Exception _ex) { } - if (abyte0 != null) { - // aCRC32_930.reset(); - // aCRC32_930.update(abyte0); - // int i1 = (int)aCRC32_930.getValue(); - // if(i1 != j) + if(abyte0 != null && ClientSettings.CHECK_CRC) { + aCRC32_930.reset(); + aCRC32_930.update(abyte0); + int i1 = (int)aCRC32_930.getValue(); + if(i1 != j) + abyte0 = null; } if (abyte0 != null) { StreamLoader streamLoader = new StreamLoader(abyte0); @@ -3480,12 +3482,20 @@ public class Game extends RSApplet { } catch (Exception _ex) { decompressors[0] = null; } - /* - * if(abyte0 != null) { aCRC32_930.reset(); - * aCRC32_930.update(abyte0); int i3 = - * (int)aCRC32_930.getValue(); if(i3 != j) { abyte0 = null; - * j1++; s2 = "Checksum error: " + i3; } } - */ + + if(abyte0 != null && ClientSettings.CHECK_CRC) + { + aCRC32_930.reset(); + aCRC32_930.update(abyte0); + int i3 = (int)aCRC32_930.getValue(); + if(i3 != j) + { + abyte0 = null; + j1++; + s2 = "Checksum error: " + i3; + } + } + } catch (IOException ioexception) { if (s2.equals("Unknown error")) { s2 = "Connection error"; @@ -5021,12 +5031,12 @@ public class Game extends RSApplet { if (inputString.equals("::gfxtgl") || inputString.equals("::tglgfx") || inputString.equals("::togglerender") || inputString.equals("::togglegfx")) { graphicsEnabled = !graphicsEnabled; } - if (myPrivilege >= 0) { - if(inputString.equals("::noclip")) - for(int k1 = 0; k1 < 4; k1++) - for(int i2 = 1; i2 < 103; i2++) - for(int k2 = 1; k2 < 103; k2++) - aClass11Array1230[k1].anIntArrayArray294[i2][k2] = 0; + if (myPrivilege >= 2) { + if (inputString.equals("::noclip")) + for (int k1 = 0; k1 < 4; k1++) + for (int i2 = 1; i2 < 103; i2++) + for (int k2 = 1; k2 < 103; k2++) + aClass11Array1230[k1].anIntArrayArray294[i2][k2] = 0; if (inputString.equals("::clientdrop")) { dropClient(); } @@ -5060,6 +5070,7 @@ public class Game extends RSApplet { onDemandFetcher.method563((byte) 1, 2, j1); } } + } if (inputString.startsWith("::dd")) { String[] args = inputString.split(" "); int distance = 25; @@ -5078,7 +5089,6 @@ public class Game extends RSApplet { if (inputString.equals("::dataon")) { showInfo = !showInfo; } - } if (inputString.startsWith("::")) { stream.createFrame(103); stream.writeWordBigEndian(inputString.length() - 1); @@ -5927,7 +5937,7 @@ public class Game extends RSApplet { loginMessage2 = "Connecting to server..."; drawLoginScreen(true); } - socketStream = new RSSocket(this, openSocket(43594 + portOff)); + socketStream = new RSSocket(this, openSocket((ClientSettings.SERVER_WORLD == 1) ? 43594 : 43596 + ClientSettings.SERVER_WORLD + portOff)); long l = TextClass.longForName(s); int i = (int) (l >> 16 & 31L); stream.currentOffset = 0; @@ -12046,8 +12056,9 @@ public class Game extends RSApplet { bigX = new int[4000]; bigY = new int[4000]; anInt1289 = -1; + aCRC32_930 = new CRC32(); } - + public CRC32 aCRC32_930; public static String server; public int ignoreCount; public long aLong824; diff --git a/2006Scape Client/src/main/java/Main.java b/2006Scape Client/src/main/java/Main.java index bde63f3f..4c599152 100644 --- a/2006Scape Client/src/main/java/Main.java +++ b/2006Scape Client/src/main/java/Main.java @@ -8,10 +8,7 @@ public final class Main { DEAR DEVELOPER! If you want to run the client locally, the easiest way to do that is run the class "Client.java" instead! - If you REALLY want to use this class, add program arguments "-s localhost". - But seriously, Client.java is just a copy-paste of this class and does it locally. Use that instead! - */ public static void main(String[] args) { @@ -25,6 +22,16 @@ public final class Main { case "-ip": ClientSettings.SERVER_IP = args[++i]; break; + case "-no-crc": + case "-no-cache-crc": + ClientSettings.CHECK_CRC = false; + break; + case "-dev" : + case "-local": + case "-offline": + ClientSettings.SERVER_IP = "localhost"; + ClientSettings.CHECK_CRC = false; + break; } } } @@ -45,6 +52,10 @@ public final class Main { case "-password": game.myPassword = args[++i]; break; + case "-w": + case "-world": + ClientSettings.SERVER_WORLD = Integer.parseInt(args[++i]); + break; } } } diff --git a/2006Scape Server/ServerConfig.Sample.json b/2006Scape Server/ServerConfig.Sample.json index 019ddbb7..9ac53e36 100644 --- a/2006Scape Server/ServerConfig.Sample.json +++ b/2006Scape Server/ServerConfig.Sample.json @@ -4,6 +4,9 @@ "server_debug": false, "file_server": true, "world_id": 1, + "xp_rate": 1.0, + "variable_xp_rate": false, + "variable_xp_rates": [1, 2, 5, 10], "members_only": false, "tutorial_island_enabled": false, "party_room_enabled": true, @@ -15,6 +18,6 @@ "save_timer": 120, "timeout": 60, "item_requirements": true, - "xp_rate": 1.0, - "max_players": 200 + "max_players": 200, + "website_total_characters_integration": false } \ No newline at end of file diff --git a/2006Scape Server/data/cache/main_file_cache.dat b/2006Scape Server/data/cache/main_file_cache.dat index fab8e811..8fd42b89 100644 Binary files a/2006Scape Server/data/cache/main_file_cache.dat and b/2006Scape Server/data/cache/main_file_cache.dat differ diff --git a/2006Scape Server/data/cache/main_file_cache.idx0 b/2006Scape Server/data/cache/main_file_cache.idx0 index 7b344613..35f9372d 100644 Binary files a/2006Scape Server/data/cache/main_file_cache.idx0 and b/2006Scape Server/data/cache/main_file_cache.idx0 differ diff --git a/2006Scape Server/data/discord.json b/2006Scape Server/data/discord.json deleted file mode 100644 index 6d308feb..00000000 --- a/2006Scape Server/data/discord.json +++ /dev/null @@ -1 +0,0 @@ -{"token":""} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/ConfigLoader.java b/2006Scape Server/src/main/java/com/rs2/ConfigLoader.java index c3248f90..6e01ec09 100644 --- a/2006Scape Server/src/main/java/com/rs2/ConfigLoader.java +++ b/2006Scape Server/src/main/java/com/rs2/ConfigLoader.java @@ -3,6 +3,7 @@ package com.rs2; import com.rs2.integrations.PlayersOnlineWebsite; import com.rs2.integrations.RegisteredAccsWebsite; import com.rs2.integrations.discord.JavaCord; +import org.json.JSONArray; import org.json.JSONObject; import java.io.*; @@ -17,6 +18,8 @@ public class ConfigLoader { if(obj.has("server_name")) GameConstants.SERVER_NAME = obj.getString("server_name"); + if(obj.has("server_test_version")) + GameConstants.TEST_VERSION = obj.getDouble("server_test_version"); if(obj.has("website_link")) GameConstants.WEBSITE_LINK = obj.getString("website_link"); if(obj.has("debug")) @@ -49,10 +52,20 @@ public class ConfigLoader { GameConstants.TIMEOUT = obj.getInt("timeout"); if(obj.has("item_requirements")) GameConstants.ITEM_REQUIREMENTS = obj.getBoolean("item_requirements"); + if(obj.has("variable_xp_rate")) + GameConstants.VARIABLE_XP_RATE = obj.getBoolean("variable_xp_rate"); if(obj.has("xp_rate")) GameConstants.XP_RATE = obj.getDouble("xp_rate"); if(obj.has("max_players")) GameConstants.MAX_PLAYERS = obj.getInt("max_players"); + if (obj.has("variable_xp_rates")) { + JSONArray rates = obj.optJSONArray("variable_xp_rates"); + for (int i = 0; i < rates.length(); ++i) { + GameConstants.VARIABLE_XP_RATES[i] = rates.optInt(i); + } + } + if(obj.has("website_total_characters_integration")) + GameConstants.WEBSITE_TOTAL_CHARACTERS_INTEGRATION = obj.getBoolean("website_total_characters_integration"); } private static void initialize() { @@ -71,7 +84,7 @@ public class ConfigLoader { } public static void loadSecrets() throws IOException { - if (!new File("data/Secrets.json").exists()) { + if (!new File("data/secrets.json").exists()) { initialize(); System.out.println("Please open \"data/secrets.json\" file and enter your discord token bot there!"); System.out.println("Please open \"data/secrets.json\" file and enter your Website Password there!"); @@ -88,7 +101,7 @@ public class ConfigLoader { JavaCord.token = obj.getString("bot-token"); if(obj.has("websitepass")) PlayersOnlineWebsite.password = obj.getString("websitepass"); - RegisteredAccsWebsite.password = obj.getString("websitepass"); + RegisteredAccsWebsite.password = obj.getString("websitepass"); if(obj.has("erssecret")) GameEngine.ersSecret = obj.getString("erssecret"); diff --git a/2006Scape Server/src/main/java/com/rs2/GameConstants.java b/2006Scape Server/src/main/java/com/rs2/GameConstants.java index bf79476d..0da4b947 100644 --- a/2006Scape Server/src/main/java/com/rs2/GameConstants.java +++ b/2006Scape Server/src/main/java/com/rs2/GameConstants.java @@ -16,38 +16,35 @@ public class GameConstants { * FILE_SERVER Sets Whether The FileServer Should Run With The Server * SERVER_DEBUG Sets Whether The Server Should Start In Debug Mode * MEMBERS_ONLY Sets Whether The World Is Members Only - * TUTORIAL_ISLAND Sets Enables/Disables Tutorial Island For Players On First Login + * TUTORIAL_ISLAND Enables/Disables Tutorial Island For Players On First Login * PARTY_ROOM_DISABLED Enables/Disables The Party Room Should Be Disabled * CLUES_ENABLED Enables/Disables Clue Scrolls * ITEM_REQUIREMENTS Enables/Disables Item Requirements for All Players * ADMIN_CAN_TRADE Defines Whether Admins Can Trade * ADMIN_DROP_ITEMS Defines Whether Admins Can Drop Items * ADMIN_CAN_SELL_ITEMS Defines Whether Admins Can Sell Items - * XP_RATE Sets The XP Rate Multiplier For All Players/Skills + * VARIABLE_XP_RATE Allows Players To Choose An XP Rate Set In VARIABLE_XP_RATES + * VARIABLE_XP_RATES Defines The XP Rates That Should Be Available To Players When VARIABLE_XP_RATES is true(Array Must Contain Four Entries) + * XP_RATE Sets The XP Rate Multiplier For All Players/Skills If VARIABLE_XP_RATES is false */ public static String SERVER_NAME = "2006Scape", WEBSITE_LINK = "https://2006Scape.org"; public static int WORLD = 1, MAX_PLAYERS = 200, TIMEOUT = 60, SAVE_TIMER = 120, RESPAWN_X = 3222, RESPAWN_Y = 3218; public static boolean FILE_SERVER = true, SERVER_DEBUG = false, MEMBERS_ONLY = false, TUTORIAL_ISLAND = false, PARTY_ROOM_DISABLED = false, CLUES_ENABLED = true, ITEM_REQUIREMENTS = true, - ADMIN_CAN_TRADE = false, ADMIN_DROP_ITEMS = false, ADMIN_CAN_SELL_ITEMS = false; - public static double XP_RATE = 1; + ADMIN_CAN_TRADE = false, ADMIN_DROP_ITEMS = false, ADMIN_CAN_SELL_ITEMS = false, VARIABLE_XP_RATE = false, + WEBSITE_TOTAL_CHARACTERS_INTEGRATION = false; + public static int[] VARIABLE_XP_RATES = new int[] {1, 2, 5, 10}; + public static double TEST_VERSION = 2.3, XP_RATE = 1.0; /** * The Variables Below Should Only Be Changed If You Understand What You Are Doing */ - - public final static String SERVER_VERSION = "Server Stage v " + GameConstants.TEST_VERSION + "."; - public final static boolean WEBSITE_TOTAL_CHARACTERS_INTEGRATION = false; - public final static double TEST_VERSION = 2.3; + public final static int ITEM_LIMIT = 15000, MAXITEM_AMOUNT = Integer.MAX_VALUE, + IPS_ALLOWED = 250, CONNECTION_DELAY = 100; - public final static int ITEM_LIMIT = 15000, MAXITEM_AMOUNT = Integer.MAX_VALUE, CLIENT_VERSION = 999999, - IPS_ALLOWED = 250, CONNECTION_DELAY = 100, - MESSAGE_DELAY = 6000, REQ_AMOUNT = 150; - - public final static boolean sendServerPackets = false, SOUND = true, GUILDS = true, - PRINT_OBJECT_ID = false, EXPERIMENTS = false; + public final static boolean sendServerPackets = false, SOUND = true, GUILDS = true; public static int[] SIDEBARS = { 2423, 3917, 638, 3213, 1644, 5608, 1151, 18128, 5065, 5715, 2449, 904, 147, 962 }; @@ -63,10 +60,6 @@ public class GameConstants { public final static int NO_TELEPORT_WILD_LEVEL = 20; - public final static int CASTLE_WARS_X = 2439; - - public final static int CASTLE_WARS_Y = 3087; - public final static int NPC_RANDOM_WALK_DISTANCE = 5; public final static int NPC_FOLLOW_DISTANCE = 10; diff --git a/2006Scape Server/src/main/java/com/rs2/GameEngine.java b/2006Scape Server/src/main/java/com/rs2/GameEngine.java index 8a2d4c0a..ee92341b 100644 --- a/2006Scape Server/src/main/java/com/rs2/GameEngine.java +++ b/2006Scape Server/src/main/java/com/rs2/GameEngine.java @@ -131,11 +131,7 @@ public class GameEngine { private final static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); private final static Lock lock = new ReentrantLock(); - /** - * Port and Cycle rate. - */ static { - serverlistenerPort = 43594; shutdownServer = false; } @@ -158,6 +154,7 @@ public class GameEngine { } } } + serverlistenerPort = (GameConstants.WORLD == 1) ? 43594 : 43596 + GameConstants.WORLD; System.out.println("Starting game engine.."); if (GameConstants.SERVER_DEBUG) { diff --git a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java index b30e76a7..7d902855 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java +++ b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueHandler.java @@ -6137,10 +6137,14 @@ public class DialogueHandler { break; case 3116: - player.getPacketSender().showInterface(3559); - player.canChangeAppearance = true; - player.closeTutorialInterface = true; - player.nextChat = 0; + if(GameConstants.VARIABLE_XP_RATE) { + player.getDialogueHandler().sendDialogues(10001, -1); + } else { + player.getPacketSender().showInterface(3559); + player.canChangeAppearance = true; + player.closeTutorialInterface = true; + player.nextChat = 0; + } break; case 3117: @@ -7594,6 +7598,34 @@ public class DialogueHandler { ); player.dialogueAction = 10000; break; + case 10001: + sendNpcChat(2244, ChatEmotes.HAPPY_JOYFUL, "Please select the XP rate you'd like.", "this can be increased, but not decreased later on."); + player.nextChat = 10002; + break; + case 10002: + sendOption("x" + GameConstants.VARIABLE_XP_RATES[0], "x" + GameConstants.VARIABLE_XP_RATES[1], "x" + GameConstants.VARIABLE_XP_RATES[2], "x" + GameConstants.VARIABLE_XP_RATES[3]); + player.dialogueAction = 10002; + break; + case 10003: + sendNpcChat(2244, ChatEmotes.HAPPY_JOYFUL, "Are you sure x" + player.getXPRate() + " is the XP rate you'd like?"); + player.nextChat = 10004; + break; + case 10004: + sendOption("Yes", "No"); + player.dialogueAction = 10004; + break; + case 10005: + sendOption("x" + GameConstants.VARIABLE_XP_RATES[1], "x" + GameConstants.VARIABLE_XP_RATES[2], "x" + GameConstants.VARIABLE_XP_RATES[3]); + player.dialogueAction = 10005; + break; + case 10006: + sendOption("x" + GameConstants.VARIABLE_XP_RATES[2], "x" + GameConstants.VARIABLE_XP_RATES[3]); + player.dialogueAction = 10006; + break; + case 10007: + sendOption("x" + GameConstants.VARIABLE_XP_RATES[3], "Don't Change"); + player.dialogueAction = 10007; + break; } } public void chatboxText(String text, String text1, String text2, diff --git a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueOptions.java b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueOptions.java index 4200552e..089eda23 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueOptions.java +++ b/2006Scape Server/src/main/java/com/rs2/game/dialogues/DialogueOptions.java @@ -104,6 +104,12 @@ public class DialogueOptions { player.getDialogueHandler().sendStatement("You summoned your shop!"); BotHandler.playerShop(player); return; + case 10005: + player.setXPRate(GameConstants.VARIABLE_XP_RATES[1]); + player.getPacketSender().sendMessage("Your XP rate is now set to x" + player.getXPRate() + " you can increase your rate in the future by using"); + player.getPacketSender().sendMessage("::xprate"); + player.getPacketSender().closeAllWindows(); + return; } player.dialogueAction = 0; player.getPacketSender().closeAllWindows(); @@ -192,6 +198,12 @@ public class DialogueOptions { player.getDialogueHandler().sendStatement("You close your shop!"); BotHandler.closeShop(player); return; + case 10005: + player.setXPRate(GameConstants.VARIABLE_XP_RATES[2]); + player.getPacketSender().sendMessage("Your XP rate is now set to x" + player.getXPRate() + " you can increase your rate in the future by using"); + player.getPacketSender().sendMessage("::xprate"); + player.getPacketSender().closeAllWindows(); + return; } player.dialogueAction = 0; player.getPacketSender().closeAllWindows(); @@ -283,6 +295,11 @@ public class DialogueOptions { player.getDialogueHandler().sendStatement("You withdraw " + Bot.formatSellPrice(BotHandler.checkCoins(player)) + " from your shop!"); BotHandler.takeCoins(player); return; + case 10005: + player.setXPRate(GameConstants.VARIABLE_XP_RATES[3]); + player.getPacketSender().sendMessage("Your XP rate is now set to x" + player.getXPRate() + " you now have the highest XP rate."); + player.getPacketSender().closeAllWindows(); + return; } player.dialogueAction = 0; player.getPacketSender().closeAllWindows(); @@ -618,11 +635,37 @@ public class DialogueOptions { player.getDialogueHandler().sendDialogues(3586, player.npcType); return; } - else if (player.dialogueAction == 7559) - { + else if (player.dialogueAction == 7559) { player.getDialogueHandler().sendDialogues(3864, player.npcType); return; - } + } else if (player.dialogueAction == 10004) { + if(!player.closeTutorialInterface) { + player.getPacketSender().sendMessage("Your XP rate is now set to x" + player.getXPRate() + " you can increase your rate in the future by using"); + player.getPacketSender().sendMessage("::xprate"); + player.getPacketSender().showInterface(3559); + player.canChangeAppearance = true; + player.closeTutorialInterface = true; + return; + } else if (player.getXPRate() != + GameConstants.VARIABLE_XP_RATES[3]) { + player.getPacketSender().sendMessage("Your XP rate is now set to x" + player.getXPRate() + " you can increase your rate in the future by using"); + player.getPacketSender().sendMessage("::xprate"); + return; + } else { + player.getPacketSender().sendMessage("Your XP rate is now set to x" + player.getXPRate() + " you now have the highest XP rate."); + return; + } + } else if(player.dialogueAction == 10006) { + player.setXPRate(GameConstants.VARIABLE_XP_RATES[2]); + player.getPacketSender().sendMessage("Your XP rate is now set to x" + player.getXPRate() + " you can increase your rate in the future by using"); + player.getPacketSender().sendMessage("::xprate"); + player.getPacketSender().closeAllWindows(); + return; + } else if(player.dialogueAction == 10007) { + player.setXPRate(GameConstants.VARIABLE_XP_RATES[3]); + player.getPacketSender().sendMessage("Your XP rate is now set to x" + player.getXPRate() + " you now have the highest XP rate."); + player.getPacketSender().closeAllWindows(); + return; + } player.dialogueAction = 0; player.getPacketSender().closeAllWindows(); break; @@ -848,6 +891,15 @@ public class DialogueOptions { { player.getDialogueHandler().sendDialogues(3865, player.npcType); return; + } else if (player.dialogueAction == 10004) { + player.getDialogueHandler().sendDialogues(10002, 2244); + return; + } else if(player.dialogueAction == 10006) { + player.setXPRate(GameConstants.VARIABLE_XP_RATES[3]); + player.getPacketSender().sendMessage("Your XP rate is now set to x" + player.getXPRate() + " you now have the highest XP rate."); + player.getPacketSender().sendMessage("::xprate"); + player.getPacketSender().closeAllWindows(); + return; } player.dialogueAction = 0; player.getPacketSender().closeAllWindows(); @@ -922,6 +974,10 @@ public class DialogueOptions { if (player.dialogueAction == 701) { player.getDialogueHandler().sendDialogues(3561, player.npcType); } + if (player.dialogueAction == 10002) { + player.setXPRate(GameConstants.VARIABLE_XP_RATES[0]); + player.getDialogueHandler().sendDialogues(10003, player.npcType); + } break; case 9179: @@ -991,6 +1047,10 @@ public class DialogueOptions { if (player.dialogueAction == 701) { player.getDialogueHandler().sendDialogues(3562, player.npcType); } + if (player.dialogueAction == 10002) { + player.setXPRate(GameConstants.VARIABLE_XP_RATES[1]); + player.getDialogueHandler().sendDialogues(10003, player.npcType); + } break; case 9180: @@ -1063,6 +1123,10 @@ public class DialogueOptions { if (player.dialogueAction == 701) { player.getDialogueHandler().sendDialogues(3563, player.npcType); } + if (player.dialogueAction == 10002) { + player.setXPRate(GameConstants.VARIABLE_XP_RATES[2]); + player.getDialogueHandler().sendDialogues(10003, player.npcType); + } break; case 9181: @@ -1120,6 +1184,10 @@ public class DialogueOptions { if (player.dialogueAction == 701) { player.getDialogueHandler().sendDialogues(3564, player.npcType); } + if (player.dialogueAction == 10002) { + player.setXPRate(GameConstants.VARIABLE_XP_RATES[3]); + player.getDialogueHandler().sendDialogues(10003, player.npcType); + } break; } } diff --git a/2006Scape Server/src/main/java/com/rs2/game/players/Player.java b/2006Scape Server/src/main/java/com/rs2/game/players/Player.java index ee715d6d..ef31bdca 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/players/Player.java +++ b/2006Scape Server/src/main/java/com/rs2/game/players/Player.java @@ -98,7 +98,8 @@ public abstract class Player { public byte buffer[] = null; public String lastConnectedFrom; - private Compost compost = new Compost(this); + public static int xpRate = 1; + private Compost compost = new Compost(this); private Allotments allotment = new Allotments(this); private Flowers flower = new Flowers(this); private Herbs herb = new Herbs(this); @@ -166,6 +167,10 @@ public abstract class Player { private DoubleGates doubleGates = new DoubleGates(); public int lastMainFrameInterface = -1; //Possibly used in future to prevent packet exploits + public int getXPRate() { return xpRate; } + + public void setXPRate(int xpRate) { this.xpRate = xpRate; } + public boolean isPreaching() { return preaching; } @@ -173,9 +178,9 @@ public abstract class Player { public void setPreaching(boolean preaching) { this.preaching = preaching; } - + public boolean preaching; - + public Compost getCompost() { return compost; } @@ -223,12 +228,12 @@ public abstract class Player { public ToolLeprechaun getFarmingTools() { return toolLeprechaun; } - + public LogCuttingInterface getFletching() { return fletching; } - + public SingleGates getSingleGates() { return singleGates; } @@ -404,7 +409,7 @@ public abstract class Player { public MageTrainingArena getMageTrainingArena() { return mageArena; } - + public Trading getTrading() { return trading; } @@ -444,13 +449,13 @@ public abstract class Player { public Inventory getInventory() { return inventory; } - + private Inventory inventory = new Inventory(this); - - + + private int tempInteger; public boolean tempBoolean; - + public void setTempInteger(int tempInteger) { this.tempInteger = tempInteger; } @@ -460,17 +465,17 @@ public abstract class Player { } public int totalShopItems; - + public boolean stopPlayer(boolean stop) { return (stop ? stopPlayerPacket == true : stopPlayerPacket == false); } - + public long objectDelay; - + public long getObjectDelay() { return (objectDelay); } - + public long setObjectDelay(long delay) { return (objectDelay = delay); } @@ -981,7 +986,7 @@ public abstract class Player { if (System.currentTimeMillis() - singleCombatDelay2 > 3300) { underAttackBy2 = 0; } - + if (System.currentTimeMillis() - restoreStatsDelay > 60000) { restoreStatsDelay = System.currentTimeMillis(); for (int skill = 0; skill < playerLevel.length; skill++) { @@ -1398,20 +1403,20 @@ public abstract class Player { restoreStatsDelay, logoutDelay, buryDelay, foodDelay, potDelay, doorDelay, doubleDoorDelay, buySlayerTimer, lastIncrease, boneDelay, leverDelay = 0, searchObjectDelay = 0, clickDelay = 0; - + public boolean hideYell; private Npc specialTarget = null; - + public void setSpecialTarget(Npc target) { this.specialTarget = target; } - + public Npc getSpecialTarget() { return specialTarget; } - + public int miningAxe = -1, woodcuttingAxe = -1; public boolean initialized, musicOn = true, luthas, @@ -1695,7 +1700,7 @@ public abstract class Player { 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 2097152, 8388608, 16777216, 67108864, 134217728 }; - + /** * Combat variables */ @@ -1713,7 +1718,7 @@ public abstract class Player { /** * End */ - + public int clickNpcType, clickObjectType, objectId, objectX, objectY, npcIndex, npcClickIndex, npcType; public int pItemX, pItemY, pItemId; @@ -2130,11 +2135,11 @@ public abstract class Player { walkingQueueY[wQueueWritePtr] = y; wQueueWritePtr = next; } - + public boolean checkRangeDistance() { return (usingRangeWeapon || usingBow); } - + public int gatherRangeDistance(int distance) { //dart (non long range) if (usingRangeWeapon && RangeData.usingDart(this) && fightMode != 3) { @@ -2148,7 +2153,7 @@ public abstract class Player { //dart, knife, throwing axe (long range) } else if (usingRangeWeapon && fightMode == 3) { distance = RangeData.usingDart(this) ? 5 : 6; - //short bow + //short bow } else if (usingBow && !RangeData.usingLongbow(this)) { distance = fightMode == 3 ? 7 : 9; } @@ -2507,74 +2512,74 @@ public abstract class Player { } else { playerProps.writeByte(0); } - + if (playerEquipment[ItemConstants.CAPE] > 1) { playerProps.writeWord(0x200 + playerEquipment[ItemConstants.CAPE]); } else { playerProps.writeByte(0); } - + if (playerEquipment[ItemConstants.AMULET] > 1) { playerProps.writeWord(0x200 + playerEquipment[ItemConstants.AMULET]); } else { playerProps.writeByte(0); } - + if (playerEquipment[ItemConstants.WEAPON] > 1) { playerProps.writeWord(0x200 + playerEquipment[ItemConstants.WEAPON]); } else { playerProps.writeByte(0); } - + if (playerEquipment[ItemConstants.CHEST] > 1) { playerProps.writeWord(0x200 + playerEquipment[ItemConstants.CHEST]); } else { playerProps.writeWord(0x100 + playerAppearance[2]); } - + if (playerEquipment[ItemConstants.SHIELD] > 1) { playerProps.writeWord(0x200 + playerEquipment[ItemConstants.SHIELD]); } else { playerProps.writeByte(0); } - + if (!ItemData.isFullBody(playerEquipment[ItemConstants.CHEST])) { playerProps.writeWord(0x100 + playerAppearance[3]); } else { playerProps.writeByte(0); } - + if (playerEquipment[ItemConstants.LEGS] > 1) { playerProps.writeWord(0x200 + playerEquipment[ItemConstants.LEGS]); } else { playerProps.writeWord(0x100 + playerAppearance[5]); } - + if (!ItemData.isFullHelm(playerEquipment[ItemConstants.HAT]) && !ItemData.isFullMask(playerEquipment[ItemConstants.HAT])) { playerProps.writeWord(0x100 + playerAppearance[1]); } else { playerProps.writeByte(0); } - + if (playerEquipment[ItemConstants.HANDS] > 1) { playerProps.writeWord(0x200 + playerEquipment[ItemConstants.HANDS]); } else { playerProps.writeWord(0x100 + playerAppearance[4]); } - + if (playerEquipment[ItemConstants.FEET] > 1) { playerProps.writeWord(0x200 + playerEquipment[ItemConstants.FEET]); } else { playerProps.writeWord(0x100 + playerAppearance[6]); } - + if (playerAppearance[0] != 1 && !ItemData.isFullMask(playerEquipment[ItemConstants.HAT])) { playerProps.writeWord(0x100 + playerAppearance[7]); } else { playerProps.writeByte(0); } - + } else {//send npc data playerProps.writeWord(-1);//Tells client that were being a npc playerProps.writeWord(npcId2);//send NpcID diff --git a/2006Scape Server/src/main/java/com/rs2/game/players/PlayerAssistant.java b/2006Scape Server/src/main/java/com/rs2/game/players/PlayerAssistant.java index c2f89f4b..5d5caf91 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/players/PlayerAssistant.java +++ b/2006Scape Server/src/main/java/com/rs2/game/players/PlayerAssistant.java @@ -17,7 +17,6 @@ import com.rs2.game.content.music.sound.SoundList; import com.rs2.game.content.randomevents.RandomEventHandler; import com.rs2.game.content.skills.SkillData; import com.rs2.game.content.skills.SkillHandler; -import com.rs2.game.content.skills.smithing.Superheat; import com.rs2.game.items.GameItem; import com.rs2.game.items.ItemAssistant; import com.rs2.game.items.ItemConstants; @@ -95,7 +94,7 @@ public class PlayerAssistant { public void loginScreen() { player.getPacketSender().showInterface(15244); - player.getPacketSender().sendString("Welcome to " + GameConstants.SERVER_NAME + "\\n", 15257); + player.getPacketSender().sendString("Welcome to " + GameConstants.SERVER_NAME + " World: " + GameConstants.WORLD + "\\n", 15257); int currentDay = player.getLastLogin() - player.lastLoginDate; if (player.playerLevel[GameConstants.HERBLORE] < 3) { @@ -1833,7 +1832,7 @@ public class PlayerAssistant { player.getItemAssistant().clearBank(); player.getPlayerAssistant().addStarter(); player.getPlayerAssistant().movePlayer(3233, 3229, 0); - player.getPacketSender().sendMessage("Welcome to @blu@" + GameConstants.SERVER_NAME + "@bla@ - we are currently in Server Stage v@blu@" + GameConstants.TEST_VERSION + "@bla@."); + player.getPacketSender().sendMessage("Welcome to @blu@" + GameConstants.SERVER_NAME + " World: " + GameConstants.WORLD + "@bla@ - we are currently in Server Stage v@blu@" + GameConstants.TEST_VERSION + "@bla@."); player.getPacketSender().sendMessage("@red@Did you know?@bla@ We're open source and pull requests are welcome!"); player.getPacketSender().sendMessage("Source code: github.com/2006-Scape/2006Scape"); player.getPacketSender().sendMessage("Discord: https://discord.gg/hZ6VfWG"); @@ -2033,7 +2032,11 @@ public class PlayerAssistant { if (player.tutorialProgress < 36 && player.playerLevel[skill] == 3 && GameConstants.TUTORIAL_ISLAND) { return false; } - amount *= GameConstants.XP_RATE; + if (GameConstants.VARIABLE_XP_RATE){ + amount *= player.getXPRate(); + } else { + amount *= GameConstants.XP_RATE; + } int oldLevel = getLevelForXP(player.playerXP[skill]); player.playerXP[skill] += amount; if (oldLevel < getLevelForXP(player.playerXP[skill])) { diff --git a/2006Scape Server/src/main/java/com/rs2/game/players/PlayerSave.java b/2006Scape Server/src/main/java/com/rs2/game/players/PlayerSave.java index 96a38cc0..9e9c5130 100644 --- a/2006Scape Server/src/main/java/com/rs2/game/players/PlayerSave.java +++ b/2006Scape Server/src/main/java/com/rs2/game/players/PlayerSave.java @@ -92,6 +92,8 @@ public class PlayerSave { case "character-rights": player.playerRights = Integer.parseInt(token2); break; + case "xp-rate": + player.xpRate = Integer.parseInt(token2); case "last-ip": player.lastConnectedFrom = token2; break; @@ -593,6 +595,8 @@ public class PlayerSave { characterfile.newLine(); characterfile.write("character-rights = " + player.playerRights); characterfile.newLine(); + characterfile.write("xp-rate = " + player.xpRate); + characterfile.newLine(); characterfile.write("last-ip = " + player.connectedFrom); characterfile.newLine(); characterfile.write("isBot = " + player.isBot); diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/PlayersOnlineWebsite.java b/2006Scape Server/src/main/java/com/rs2/integrations/PlayersOnlineWebsite.java index 5e34806d..2e1fd0f5 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/PlayersOnlineWebsite.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/PlayersOnlineWebsite.java @@ -13,7 +13,7 @@ public class PlayersOnlineWebsite { private static void setWebsitePlayersOnline(int amount) throws IOException { URL url; - url = new URL(GameConstants.WEBSITE_LINK + "/playersonline.php?pass=" + password + "&amount=" + amount); + url = new URL(GameConstants.WEBSITE_LINK + "/playersonline.php?pass=" + password + "&amount=" + amount + "&world=" + GameConstants.WORLD); url.openStream().close(); } diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/RegisteredAccsWebsite.java b/2006Scape Server/src/main/java/com/rs2/integrations/RegisteredAccsWebsite.java index 14efc934..79eadf71 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/RegisteredAccsWebsite.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/RegisteredAccsWebsite.java @@ -12,7 +12,7 @@ public class RegisteredAccsWebsite { private static void setAccountsRegistered(int amount) throws IOException { URL url; - url = new URL(GameConstants.WEBSITE_LINK + "/accountsregistered.php?pass=" + password + "&amount=" + amount); + url = new URL(GameConstants.WEBSITE_LINK + "/accountsregistered.php?pass=" + password + "&amount=" + amount + "&world=" + GameConstants.WORLD); url.openStream().close(); } diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/JavaCord.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/JavaCord.java index f964317a..1b5c8ec1 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/discord/JavaCord.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/JavaCord.java @@ -1,12 +1,15 @@ package com.rs2.integrations.discord; import com.rs2.GameConstants; +import com.rs2.integrations.discord.commands.*; +import com.rs2.integrations.discord.commands.admin.GameKick; +import com.rs2.integrations.discord.commands.admin.MoveHome; +import com.rs2.integrations.discord.commands.admin.Update; import org.javacord.api.DiscordApi; import org.javacord.api.DiscordApiBuilder; import org.javacord.api.entity.channel.TextChannel; import org.javacord.api.entity.message.MessageBuilder; import org.javacord.api.util.logging.ExceptionLogger; -import com.rs2.integrations.discord.commands.*; import java.io.IOException; @@ -17,6 +20,7 @@ import java.io.IOException; public class JavaCord { public static String serverName = GameConstants.SERVER_NAME; + public static String commandPrefix = "::w" + GameConstants.WORLD; public static String token; public static DiscordApi api = null; @@ -34,19 +38,14 @@ public class JavaCord { api.addListener(new Players()); api.addListener(new Vote()); api.addListener(new Website()); + //Admin Commands + api.addListener(new GameKick()); + api.addListener(new MoveHome()); + api.addListener(new Update()); if(!DiscordActivity.playerCount) { api.updateActivity(GameConstants.WEBSITE_LINK); } api.addMessageCreateListener(event -> { - - if (event.getMessageContent().startsWith("::movehome")) { - if (event.getMessageAuthor().isServerAdmin()) { - System.out.println("perms"); - event.getChannel().sendMessage("perms"); - } else { - event.getChannel().sendMessage("You do not have permission to preform this command"); - } - } }); } catch (Exception e) { diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Commands.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Commands.java index 8c7a9615..7ad8a966 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Commands.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Commands.java @@ -1,5 +1,6 @@ package com.rs2.integrations.discord.commands; +import com.rs2.integrations.discord.JavaCord; import org.javacord.api.entity.message.Message; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; @@ -8,22 +9,20 @@ public class Commands implements MessageCreateListener { @Override public void onMessageCreate(MessageCreateEvent event) { Message message = event.getMessage(); - if (message.getContent().equalsIgnoreCase("::commands")) { + if (message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " commands")) { event.getChannel().sendMessage("```fix" + System.lineSeparator() + - "::forum/::forums" + JavaCord.commandPrefix + " forum/" + JavaCord.commandPrefix + " forums" + System.lineSeparator() + - "::hiscores/::highscores" + JavaCord.commandPrefix + " hiscores/" + JavaCord.commandPrefix + " highscores" + System.lineSeparator() + - "::issues/::bugs" + JavaCord.commandPrefix + " issues/" + JavaCord.commandPrefix + " bugs" + System.lineSeparator() + - "::online" + JavaCord.commandPrefix + " online" + System.lineSeparator() + - "::players" + JavaCord.commandPrefix + " vote" + System.lineSeparator() + - "::vote" - + System.lineSeparator() + - "::website/::site" + JavaCord.commandPrefix + " website/" + JavaCord.commandPrefix + " site" + "```"); } } diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Forum.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Forum.java index b746b3c1..d5a6991c 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Forum.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Forum.java @@ -1,5 +1,6 @@ package com.rs2.integrations.discord.commands; +import com.rs2.integrations.discord.JavaCord; import org.javacord.api.entity.message.Message; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; @@ -10,7 +11,7 @@ public class Forum implements MessageCreateListener { @Override public void onMessageCreate(MessageCreateEvent event) { Message message = event.getMessage(); - if (message.getContent().equalsIgnoreCase("::forum") || message.getContent().equalsIgnoreCase("::forums")) { + if (message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " forum") || message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " forums")) { event.getChannel().sendMessage(GameConstants.WEBSITE_LINK + "/forums/index.php"); } } diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Hiscores.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Hiscores.java index c3ccd26e..fc72e2bb 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Hiscores.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Hiscores.java @@ -1,5 +1,6 @@ package com.rs2.integrations.discord.commands; +import com.rs2.integrations.discord.JavaCord; import org.javacord.api.entity.message.Message; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; @@ -10,7 +11,7 @@ public class Hiscores implements MessageCreateListener { @Override public void onMessageCreate(MessageCreateEvent event) { Message message = event.getMessage(); - if (message.getContent().equalsIgnoreCase("::hiscores") || message.getContent().equalsIgnoreCase("::highscores")) { + if (message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " hiscores") || message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " highscores")) { event.getChannel().sendMessage(GameConstants.WEBSITE_LINK + "/hiscores.html"); } } diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Issues.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Issues.java index 83760dc6..43e2668d 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Issues.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Issues.java @@ -1,5 +1,6 @@ package com.rs2.integrations.discord.commands; +import com.rs2.integrations.discord.JavaCord; import org.javacord.api.entity.message.Message; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; @@ -8,7 +9,7 @@ public class Issues implements MessageCreateListener { @Override public void onMessageCreate(MessageCreateEvent event) { Message message = event.getMessage(); - if (message.getContent().equalsIgnoreCase("::issues") || message.getContent().equalsIgnoreCase("::bugs")) { + if (message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " issues") || message.getContent().equalsIgnoreCase(JavaCord.commandPrefix+ " bugs")) { event.getChannel().sendMessage("https://github.com/2006-Scape/2006Scape/issues"); } } diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Online.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Online.java index e040e743..cf0376b5 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Online.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Online.java @@ -1,5 +1,6 @@ package com.rs2.integrations.discord.commands; +import com.rs2.GameConstants; import org.javacord.api.entity.message.Message; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; @@ -10,8 +11,8 @@ public class Online implements MessageCreateListener { @Override public void onMessageCreate(MessageCreateEvent event) { Message message = event.getMessage(); - if (message.getContent().equalsIgnoreCase("::online")) { - event.getChannel().sendMessage(":tada: " + JavaCord.serverName + " is Online! :tada:"); + if (message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " online")) { + event.getChannel().sendMessage(":tada: " + JavaCord.serverName + " World:" + GameConstants.WORLD + " is Online! :tada:"); } } } \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Players.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Players.java index 3d3fa556..83d95c7e 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Players.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Players.java @@ -1,16 +1,16 @@ package com.rs2.integrations.discord.commands; +import com.rs2.game.players.PlayerHandler; +import com.rs2.integrations.discord.JavaCord; import org.javacord.api.entity.message.Message; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; -import com.rs2.game.players.PlayerHandler; - public class Players implements MessageCreateListener { @Override public void onMessageCreate(MessageCreateEvent event) { Message message = event.getMessage(); - if (message.getContent().equalsIgnoreCase("::players")) { + if (message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " players")) { if (PlayerHandler.getPlayerCount() != 1) { event.getChannel().sendMessage("There are currently " + PlayerHandler.getPlayerCount() + " players online (" + PlayerHandler.getNonPlayerCount() + " staff online)."); } else { diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Vote.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Vote.java index 5c73a72f..88587bc8 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Vote.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Vote.java @@ -1,5 +1,6 @@ package com.rs2.integrations.discord.commands; +import com.rs2.integrations.discord.JavaCord; import org.javacord.api.entity.message.Message; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; @@ -10,7 +11,7 @@ public class Vote implements MessageCreateListener { @Override public void onMessageCreate(MessageCreateEvent event) { Message message = event.getMessage(); - if (message.getContent().equalsIgnoreCase("::vote")) { + if (message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " vote")) { event.getChannel().sendMessage("Visit " + GameConstants.WEBSITE_LINK + "/vote.html then type \"::claimvote\" in-game to receive your reward!"); } } diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Website.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Website.java index b391eb3b..73ded7eb 100644 --- a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Website.java +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/Website.java @@ -1,5 +1,6 @@ package com.rs2.integrations.discord.commands; +import com.rs2.integrations.discord.JavaCord; import org.javacord.api.entity.message.Message; import org.javacord.api.event.message.MessageCreateEvent; import org.javacord.api.listener.message.MessageCreateListener; @@ -10,7 +11,7 @@ public class Website implements MessageCreateListener { @Override public void onMessageCreate(MessageCreateEvent event) { Message message = event.getMessage(); - if (message.getContent().equalsIgnoreCase("::website") || message.getContent().equalsIgnoreCase("::site")) { + if (message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " website") || message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " site")) { event.getChannel().sendMessage(GameConstants.WEBSITE_LINK); } } diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/admin/GameKick.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/admin/GameKick.java new file mode 100644 index 00000000..42b45fe3 --- /dev/null +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/admin/GameKick.java @@ -0,0 +1,32 @@ +package com.rs2.integrations.discord.commands.admin; + +import com.rs2.game.players.Client; +import com.rs2.game.players.Player; +import com.rs2.game.players.PlayerHandler; +import com.rs2.integrations.discord.JavaCord; +import org.javacord.api.event.message.MessageCreateEvent; +import org.javacord.api.listener.message.MessageCreateListener; + +public class GameKick implements MessageCreateListener { + @Override + public void onMessageCreate(MessageCreateEvent event) { + if (event.getMessageContent().startsWith(JavaCord.commandPrefix + " gamekick")) { + if (event.getMessageAuthor().isServerAdmin()) { + String playerToKick = event.getMessageContent().replace( JavaCord.commandPrefix + " gamekick ", ""); + for (Player player2 : PlayerHandler.players) { + if (player2 != null) { + if (player2.playerName.equalsIgnoreCase(playerToKick)) { + Client c2 = (Client) player2; + event.getChannel().sendMessage( playerToKick+ " was kicked by " + event.getMessageAuthor().getDisplayName() + "."); + c2.disconnected = true; + c2.logout(true); + break; + } + } + } + } else { + event.getChannel().sendMessage("You do not have permission to perform this command"); + } + } + } +} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/admin/MoveHome.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/admin/MoveHome.java new file mode 100644 index 00000000..1dfba022 --- /dev/null +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/admin/MoveHome.java @@ -0,0 +1,31 @@ +package com.rs2.integrations.discord.commands.admin; + +import com.rs2.GameConstants; +import com.rs2.game.players.Client; +import com.rs2.game.players.PlayerHandler; +import com.rs2.integrations.discord.JavaCord; +import org.javacord.api.event.message.MessageCreateEvent; +import org.javacord.api.listener.message.MessageCreateListener; + +public class MoveHome implements MessageCreateListener { + + @Override + public void onMessageCreate(MessageCreateEvent event) { + if (event.getMessageContent().startsWith(JavaCord.commandPrefix + " movehome")) { + if (event.getMessageAuthor().isServerAdmin()) { + String teleToMe = event.getMessageContent().replace( JavaCord.commandPrefix + " movehome ", ""); + for (int i = 0; i < PlayerHandler.players.length; i++) { + if (PlayerHandler.players[i] != null) { + if (PlayerHandler.players[i].playerName.equalsIgnoreCase(teleToMe)) { + Client p = (Client) PlayerHandler.players[i]; + event.getChannel().sendMessage(p.playerName + " has been moved to Lumbridge."); + p.getPlayerAssistant().movePlayer(GameConstants.RESPAWN_X, GameConstants.RESPAWN_Y, 0); + } + } + } + } else { + event.getChannel().sendMessage("You do not have permission to perform this command"); + } + } + } +} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/admin/Update.java b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/admin/Update.java new file mode 100644 index 00000000..f60bfd11 --- /dev/null +++ b/2006Scape Server/src/main/java/com/rs2/integrations/discord/commands/admin/Update.java @@ -0,0 +1,24 @@ +package com.rs2.integrations.discord.commands.admin; + +import com.rs2.game.players.PlayerHandler; +import com.rs2.integrations.discord.JavaCord; +import org.javacord.api.event.message.MessageCreateEvent; +import org.javacord.api.listener.message.MessageCreateListener; + +public class Update implements MessageCreateListener { + @Override + public void onMessageCreate(MessageCreateEvent event) { + if(event.getMessageAuthor().isServerAdmin()) { + String seconds = event.getMessageContent().replace(JavaCord.commandPrefix + " update ", ""); + if (event.getMessageContent().startsWith(JavaCord.commandPrefix + " update")) { + PlayerHandler.updateSeconds = Integer.parseInt(seconds); + PlayerHandler.updateAnnounced = false; + PlayerHandler.updateRunning = true; + PlayerHandler.updateStartTime = System.currentTimeMillis(); + event.getChannel().sendMessage("Server update will begin in " + seconds + " seconds."); + } + } else { + event.getChannel().sendMessage("You do not have permission to perform this command"); + } + } +} \ No newline at end of file diff --git a/2006Scape Server/src/main/java/com/rs2/net/PacketSender.java b/2006Scape Server/src/main/java/com/rs2/net/PacketSender.java index 8d3e1821..8ef6e169 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/PacketSender.java +++ b/2006Scape Server/src/main/java/com/rs2/net/PacketSender.java @@ -116,7 +116,7 @@ public class PacketSender { if (player.tutorialProgress > 35) { player.getPlayerAssistant().sendSidebars(); Weight.updateWeight(player); - player.getPacketSender().sendMessage("Welcome to @blu@" + GameConstants.SERVER_NAME + "@bla@ - we are currently in Server Stage v@blu@" + GameConstants.TEST_VERSION + "@bla@."); + player.getPacketSender().sendMessage("Welcome to @blu@" + GameConstants.SERVER_NAME + " World: " + GameConstants.WORLD + "@bla@ - we are currently in Server Stage v@blu@" + GameConstants.TEST_VERSION + "@bla@."); player.getPacketSender().sendMessage("@red@Did you know?@bla@ We're open source! Pull requests are welcome"); player.getPacketSender().sendMessage("Source code at github.com/2006-Scape/2006Scape"); player.getPacketSender().sendMessage("Join our Discord: https://discord.gg/hZ6VfWG"); diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java index 365a973a..4c644aeb 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/Commands.java @@ -8,7 +8,6 @@ import com.rs2.Connection; import com.rs2.GameConstants; import com.rs2.GameEngine; import com.rs2.game.bots.BotHandler; -import com.rs2.game.content.combat.magic.SpellTeleport; import com.rs2.game.npcs.NpcHandler; import com.rs2.game.players.*; import com.rs2.game.players.antimacro.AntiSpam; @@ -45,6 +44,34 @@ public class Commands implements PacketType { public static void playerCommands(Player player, String playerCommand, String[] arguments) { switch (playerCommand.toLowerCase()) { + case "myxprate": + case "checkxprate": + if(GameConstants.VARIABLE_XP_RATE) { + player.getPacketSender().sendMessage("Your current XP rate is x" + player.getXPRate()); + break; + } + case "xprate": + if(GameConstants.VARIABLE_XP_RATE) { + if (player.getXPRate() == GameConstants.VARIABLE_XP_RATES[0]) { + player.getDialogueHandler().sendDialogues(10005, 2244); + return; + } else if (player.getXPRate() == GameConstants.VARIABLE_XP_RATES[1]) { + player.getDialogueHandler().sendDialogues(10006, 2244); + return; + } else if (player.getXPRate() == GameConstants.VARIABLE_XP_RATES[2]) { + player.getDialogueHandler().sendDialogues(10007, 2244); + return; + } else if (player.getXPRate() == GameConstants.VARIABLE_XP_RATES[3]) { + player.getPacketSender().sendMessage("You already have the highest XP rate."); + return; + } else { + player.getDialogueHandler().sendDialogues(10001, 2244); + return; + } + } else { + player.getPacketSender().sendMessage("You can't use this command in this world."); + } + break; case "toggleyell": case "tglyell": case "hideyell": @@ -257,9 +284,6 @@ public class Commands implements PacketType { "::loc, ::pos, ::coord", "Get your current world position", "", - "::stuck", - "Return to Lumbridge when stuck", - "", "::randomtoggle", "Enable/Disable random events", "", @@ -280,6 +304,8 @@ public class Commands implements PacketType { "", "::snow", "Add some snow in your mainscreen(works only in december)", + (GameConstants.VARIABLE_XP_RATE ? "\\n" + "::xprate\\n" + "Opens dialogue for the player to set/increase their XP rate." : ""), + (GameConstants.VARIABLE_XP_RATE ? "\\n" + "::checkxprate(::myxprate)\\n" + "Displays the players currently set XP rate." : ""), }; // Clear all lines @@ -294,17 +320,6 @@ public class Commands implements PacketType { } player.getPacketSender().showInterface(8134); break; - case "stuck": - if (player.getCombatAssistant().inCombat()) { - player.getPacketSender().sendMessage("You cannot do that while in combat."); - return; - } - player.getPlayerAssistant().movePlayer(SpellTeleport.LUMBRIDGE.getDestX(), SpellTeleport.LUMBRIDGE.getDestY(), 0); - player.getPacketSender().sendMessage("How did you manage that one..."); - player.getPacketSender().sendMessage("If it's bug related, please report on Github/Discord!"); - player.gfx100(80); - player.startAnimation(404); - break; case "randomtoggle": case "togglerandom": case "random": diff --git a/docker-compose.yml b/docker-compose.yml index 12babfff..a86545be 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: volumes: - ./2006Scape Server:/usr/src/server working_dir: /usr/src/server - ports: # You will need to open other ports if your world ID is not 1 (43597 for world 2) + ports: # You will need to open other ports if your world ID is not 1 (43598 for world 2) - 43594:43594 # Server - 43595-43596:43595-43596 # File Server restart: unless-stopped