Allow Loading VARIABLE_XP_RATES & PLAYER_XP_RATES From Config

This commit is contained in:
Dark98
2021-12-14 00:31:37 +00:00
parent c7a6cb2811
commit 49a2810e3e
6 changed files with 22 additions and 15 deletions
@@ -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.*;
@@ -25,8 +26,6 @@ public class ConfigLoader {
GameConstants.FILE_SERVER = obj.getBoolean("file_server");
if(obj.has("world_id"))
GameConstants.WORLD = obj.getInt("world_id");
if(obj.has("variable_xp_rate"))
GameConstants.VARIABLE_XP_RATE = obj.getBoolean("variable_xp_rate");
if(obj.has("members_only"))
GameConstants.MEMBERS_ONLY = obj.getBoolean("members_only");
if(obj.has("tutorial_island_enabled"))
@@ -51,10 +50,18 @@ 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_rates"))
GameConstants.VARIABLE_XP_RATES = obj.getBoolean("variable_xp_rates");
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("player_xp_rates")) {
JSONArray rates = obj.optJSONArray("player_xp_rates");
for (int i = 0; i < rates.length(); ++i) {
GameConstants.PLAYER_XP_RATES[i] = rates.optInt(i);
}
}
}
private static void initialize() {
@@ -25,16 +25,16 @@ public class GameConstants {
* 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
* VARIABLE_XP_RATE Allows Players To Choose An XP Rate(x1,x2,x5,x10)
* PLAYER_XP_RATES Defines The XP Rates That Should Be Available To Players When VARIABLE_XP_RATE is true
* XP_RATE Sets The XP Rate Multiplier For All Players/Skills If VARIABLE_XP_RATE is false
* VARIABLE_XP_RATES Allows Players To Choose An XP Rate Set In PLAYER_XP_RATES
* PLAYER_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, VARIABLE_XP_RATE = true;
ADMIN_CAN_TRADE = false, ADMIN_DROP_ITEMS = false, ADMIN_CAN_SELL_ITEMS = false, VARIABLE_XP_RATES = true;
public static int[] PLAYER_XP_RATES = new int[] {1, 2, 5, 10};
public static double XP_RATE = 1.0;
@@ -6137,7 +6137,7 @@ public class DialogueHandler {
break;
case 3116:
if(GameConstants.VARIABLE_XP_RATE) {
if(GameConstants.VARIABLE_XP_RATES) {
player.getDialogueHandler().sendDialogues(10001, -1);
} else {
player.getPacketSender().showInterface(3559);
@@ -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;
@@ -2033,7 +2032,7 @@ public class PlayerAssistant {
if (player.tutorialProgress < 36 && player.playerLevel[skill] == 3 && GameConstants.TUTORIAL_ISLAND) {
return false;
}
if (GameConstants.VARIABLE_XP_RATE){
if (GameConstants.VARIABLE_XP_RATES){
amount *= player.getXPRate();
} else {
amount *= GameConstants.XP_RATE;
@@ -46,12 +46,12 @@ public class Commands implements PacketType {
switch (playerCommand.toLowerCase()) {
case "myxprate":
case "checkxprate":
if(GameConstants.VARIABLE_XP_RATE) {
if(GameConstants.VARIABLE_XP_RATES) {
player.getPacketSender().sendMessage("Your current XP rate is x" + player.getXPRate());
break;
}
case "xprate":
if(GameConstants.VARIABLE_XP_RATE) {
if(GameConstants.VARIABLE_XP_RATES) {
if (player.getXPRate() == GameConstants.PLAYER_XP_RATES[0]) {
player.getDialogueHandler().sendDialogues(10005, 2244);
return;
@@ -304,8 +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.." : ""),
(GameConstants.VARIABLE_XP_RATES ? "\\n" + "::xprate\\n" + "Opens dialogue for the player to set/increase their XP rate." : ""),
(GameConstants.VARIABLE_XP_RATES ? "\\n" + "::checkxprate(::myxprate)\\n" + "Displays the players currently set XP rate." : ""),
};
// Clear all lines