Commit 4b6cef6b authored by Kenix Whisperwind's avatar Kenix Whisperwind

Constant static World class members have been moved to Constants class

parent 3bd5ed6e
......@@ -102,8 +102,8 @@ public final class Admins implements CommandListener {
player.message(messagePrefix + "Saved " + count + " players on server!");
} else if (cmd.equalsIgnoreCase("cleanregions")) {
Server.getServer().submitTask(() -> {
final int HORIZONTAL_PLANES = (World.MAX_WIDTH / Constants.REGION_SIZE) + 1;
final int VERTICAL_PLANES = (World.MAX_HEIGHT / Constants.REGION_SIZE) + 1;
final int HORIZONTAL_PLANES = (Constants.MAX_WIDTH / Constants.REGION_SIZE) + 1;
final int VERTICAL_PLANES = (Constants.MAX_HEIGHT / Constants.REGION_SIZE) + 1;
for (int x = 0; x < HORIZONTAL_PLANES; ++x) {
for (int y = 0; y < VERTICAL_PLANES; ++y) {
Region r = player.getWorld().getRegionManager().getRegion(x * Constants.REGION_SIZE,
......@@ -1365,17 +1365,17 @@ public final class Admins implements CommandListener {
if (rule.equalsIgnoreCase("god")) {
int start = Integer.parseInt(args[1]);
int end = Integer.parseInt(args[2]);
World.godSpellsStart = startLevel;
World.godSpellsMax = endLevel;
player.message(messagePrefix + "Wilderness rule for god spells set to [" + World.godSpellsStart + " -> "
+ World.godSpellsMax + "]");
player.getWorld().godSpellsStart = startLevel;
player.getWorld().godSpellsMax = endLevel;
player.message(messagePrefix + "Wilderness rule for god spells set to [" + player.getWorld().godSpellsStart + " -> "
+ player.getWorld().godSpellsMax + "]");
} else if (rule.equalsIgnoreCase("members")) {
int start = Integer.parseInt(args[1]);
int end = Integer.parseInt(args[2]);
World.membersWildStart = startLevel;
World.membersWildMax = endLevel;
player.message(messagePrefix + "Wilderness rule for members set to [" + World.membersWildStart + " -> "
+ World.membersWildMax + "]");
player.getWorld().membersWildStart = startLevel;
player.getWorld().membersWildMax = endLevel;
player.message(messagePrefix + "Wilderness rule for members set to [" + player.getWorld().membersWildStart + " -> "
+ player.getWorld().membersWildMax + "]");
} else {
player.message(badSyntaxPrefix + cmd.toUpperCase() + " [god/members] [startLevel] [endLevel]");
}
......
......@@ -446,11 +446,11 @@ public final class Event implements CommandListener {
}
}
else if (cmd.equalsIgnoreCase("stopevent")) {
World.EVENT_X = -1;
World.EVENT_Y = -1;
World.EVENT = false;
World.EVENT_COMBAT_MIN = -1;
World.EVENT_COMBAT_MAX = -1;
player.getWorld().EVENT_X = -1;
player.getWorld().EVENT_Y = -1;
player.getWorld().EVENT = false;
player.getWorld().EVENT_COMBAT_MIN = -1;
player.getWorld().EVENT_COMBAT_MAX = -1;
player.message(messagePrefix + "Event disabled");
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 8, "Stopped an ongoing event"));
}
......@@ -496,14 +496,14 @@ public final class Event implements CommandListener {
return;
}
World.EVENT_X = x;
World.EVENT_Y = y;
World.EVENT = true;
World.EVENT_COMBAT_MIN = cbMin;
World.EVENT_COMBAT_MAX = cbMax;
player.message(messagePrefix + "Event enabled: " + x + ", " + y + ", Combat level range: " + World.EVENT_COMBAT_MIN + " - "
+ World.EVENT_COMBAT_MAX + "");
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 9, "Created event at: (" + x + ", " + y + ") cb-min: " + World.EVENT_COMBAT_MIN + " cb-max: " + World.EVENT_COMBAT_MAX + ""));
player.getWorld().EVENT_X = x;
player.getWorld().EVENT_Y = y;
player.getWorld().EVENT = true;
player.getWorld().EVENT_COMBAT_MIN = cbMin;
player.getWorld().EVENT_COMBAT_MAX = cbMax;
player.message(messagePrefix + "Event enabled: " + x + ", " + y + ", Combat level range: " + player.getWorld().EVENT_COMBAT_MIN + " - "
+ player.getWorld().EVENT_COMBAT_MAX + "");
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 9, "Created event at: (" + x + ", " + y + ") cb-min: " + player.getWorld().EVENT_COMBAT_MIN + " cb-max: " + player.getWorld().EVENT_COMBAT_MAX + ""));
}
else if (cmd.equalsIgnoreCase("setgroup") || cmd.equalsIgnoreCase("setrank") || cmd.equalsIgnoreCase("group") || cmd.equalsIgnoreCase("rank")) {
if (args.length < 1) {
......
......@@ -182,7 +182,7 @@ public final class RegularPlayer implements CommandListener {
+ "@gre@Total Time Played:@whi@ " + DataConversions.getDateFromMsec(timePlayed) + " %"
, true);
} else if (cmd.equalsIgnoreCase("event")) {
if (!World.EVENT) {
if (!player.getWorld().EVENT) {
player.message(messagePrefix + "There is no event running at the moment");
return;
}
......@@ -193,12 +193,12 @@ public final class RegularPlayer implements CommandListener {
player.message(messagePrefix + "You can't participate in events while you are jailed.");
return;
}
if (player.getCombatLevel() > World.EVENT_COMBAT_MAX || player.getCombatLevel() < World.EVENT_COMBAT_MIN) {
player.message(messagePrefix + "This event is only for combat level range: " + World.EVENT_COMBAT_MIN + " - "
+ World.EVENT_COMBAT_MAX);
if (player.getCombatLevel() > player.getWorld().EVENT_COMBAT_MAX || player.getCombatLevel() < player.getWorld().EVENT_COMBAT_MIN) {
player.message(messagePrefix + "This event is only for combat level range: " + player.getWorld().EVENT_COMBAT_MIN + " - "
+ player.getWorld().EVENT_COMBAT_MAX);
return;
}
player.teleport(World.EVENT_X, World.EVENT_Y);
player.teleport(player.getWorld().EVENT_X, player.getWorld().EVENT_Y);
} else if (cmd.equalsIgnoreCase("g") || cmd.equalsIgnoreCase("p")) {
if (!Server.getServer().getConfig().WANT_GLOBAL_CHAT) return;
if (player.isMuted()) {
......
package com.openrsc.server.plugins.misc;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.constants.Constants;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.event.custom.BatchEvent;
import com.openrsc.server.model.container.Item;
import com.openrsc.server.model.entity.GameObject;
import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.model.world.World;
import com.openrsc.server.plugins.listeners.action.InvActionListener;
import com.openrsc.server.plugins.listeners.action.InvUseOnObjectListener;
import com.openrsc.server.plugins.listeners.executive.InvActionExecutiveListener;
import com.openrsc.server.plugins.listeners.executive.InvUseOnObjectExecutiveListener;
import static com.openrsc.server.plugins.Functions.message;
import static com.openrsc.server.plugins.Functions.showMenu;
import static com.openrsc.server.plugins.Functions.sleep;
import static com.openrsc.server.plugins.Functions.*;
public class DragonstoneAmulet implements InvActionListener, InvActionExecutiveListener, InvUseOnObjectListener, InvUseOnObjectExecutiveListener {
......@@ -38,7 +36,7 @@ public class DragonstoneAmulet implements InvActionListener, InvActionExecutiveL
// p.message("You need to stay out of combat for 10 seconds before using a teleport.");
// return;
//}
if (p.getLocation().wildernessLevel() >= World.GLORY_TELEPORT_LIMIT || p.getLocation().isInFisherKingRealm()
if (p.getLocation().wildernessLevel() >= Constants.GLORY_TELEPORT_LIMIT || p.getLocation().isInFisherKingRealm()
|| p.getLocation().isInsideGrandTreeGround()
|| (p.getLocation().inModRoom() && !p.isAdmin())) {
p.message("A mysterious force blocks your teleport!");
......
......@@ -87,6 +87,24 @@ public final class Constants {
* Maximum number of users of a party
*/
public static final int MAX_PARTY_SIZE = 5;
/**
* How far in the Wilderness can you teleport with Charged Dragonstone Amulet of Glory
*/
public static final int GLORY_TELEPORT_LIMIT = 30;
/**
* Objects that block projectiles
*/
public static final String[] objectsProjectileClipAllowed = {"gravestone", "sign", "broken pillar", "bone",
"animalskull", "skull", "egg", "eggs", "ladder", "torch", "rock", "treestump", "railing",
"railings", "gate", "fence", "table", "smashed chair", "smashed table", "longtable", "fence", "chair"};
/**
* Maximum world height
*/
public static final int MAX_HEIGHT = 4032; // 3776
/**
* Maximum world width
*/
public static final int MAX_WIDTH = 1008; // 944
//public static final class Skillcapes {
// public static final int ATTACK_CAPE = 2111;
......
......@@ -89,25 +89,25 @@ public class WildernessCycleEvent extends DelayedEvent {
switch (lastWildernessType) {
case 0:
case 1:
World.godSpellsStart = 60;
World.godSpellsMax = 60;
Server.getServer().getWorld().godSpellsStart = 60;
Server.getServer().getWorld().godSpellsMax = 60;
World.membersWildStart = 48;
World.membersWildMax = 60;
Server.getServer().getWorld().membersWildStart = 48;
Server.getServer().getWorld().membersWildMax = 60;
break;
case 2:
World.godSpellsStart = 0;
World.godSpellsMax = 60;
Server.getServer().getWorld().godSpellsStart = 0;
Server.getServer().getWorld().godSpellsMax = 60;
World.membersWildStart = 0;
World.membersWildMax = 60;
Server.getServer().getWorld().membersWildStart = 0;
Server.getServer().getWorld().membersWildMax = 60;
break;
case 3:
World.godSpellsStart = 60;
World.godSpellsMax = 60;
Server.getServer().getWorld().godSpellsStart = 60;
Server.getServer().getWorld().godSpellsMax = 60;
World.membersWildStart = 0;
World.membersWildMax = 60;
Server.getServer().getWorld().membersWildStart = 0;
Server.getServer().getWorld().membersWildMax = 60;
break;
}
......
package com.openrsc.server.model.entity.player;
import com.openrsc.server.Server;
import com.openrsc.server.constants.Constants;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.content.achievement.Achievement;
import com.openrsc.server.content.achievement.AchievementSystem;
......@@ -2883,7 +2884,7 @@ public final class Player extends Mob {
public boolean checkRingOfLife(Mob hitter) {
if (this.isPlayer() && Functions.isWielding(this, ItemId.RING_OF_LIFE.id())
&& (!this.getLocation().inWilderness()
|| (this.getLocation().inWilderness() && this.getLocation().wildernessLevel() <= World.GLORY_TELEPORT_LIMIT))) {
|| (this.getLocation().inWilderness() && this.getLocation().wildernessLevel() <= Constants.GLORY_TELEPORT_LIMIT))) {
if (((float) this.getSkills().getLevel(3)) / ((float) this.getSkills().getMaxStat(3)) <= 0.1f) {
this.resetCombatEvent();
this.resetRange();
......
package com.openrsc.server.model.world;
import com.openrsc.server.Server;
import com.openrsc.server.constants.Constants;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.NpcId;
import com.openrsc.server.content.DropTable;
......@@ -41,9 +42,6 @@ import java.util.*;
public final class World implements SimpleSubscriber<FishingTrawler> {
public static final int MAX_HEIGHT = 4032; // 3776
public static final int MAX_WIDTH = 1008; // 944
/**
* The asynchronous logger.
*/
......@@ -59,18 +57,16 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
*/
private final static IPTracker<String> wildernessIPTracker = new ThreadSafeIPTracker<String>();
private static final String[] objectsProjectileClipAllowed = {"gravestone", "sign", "broken pillar", "bone",
"animalskull", "skull", "egg", "eggs", "ladder", "torch", "rock", "treestump", "railing",
"railings", "gate", "fence", "table", "smashed chair", "smashed table", "longtable", "fence", "chair"};
public static int membersWildStart = 48;
public static int membersWildMax = 56;
public static int godSpellsStart = 1;
public static int godSpellsMax = 5;
public static final int GLORY_TELEPORT_LIMIT = 30;
public static boolean EVENT = false;
public static int EVENT_X = -1, EVENT_Y = -1;
public static int EVENT_COMBAT_MIN, EVENT_COMBAT_MAX;
public static boolean WORLD_TELEGRAB_TOGGLE = false;
private boolean telegrabEnabled = true;
public boolean EVENT = false;
public int EVENT_X = -1, EVENT_Y = -1;
public int EVENT_COMBAT_MIN, EVENT_COMBAT_MAX;
public int membersWildStart = 48;
public int membersWildMax = 56;
public int godSpellsStart = 1;
public int godSpellsMax = 5;
private static World worldInstance;
private final RegionManager regionManager;
......@@ -114,7 +110,7 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
npcUnderAttackMap = new HashMap<Npc, Boolean>();
fishingTrawler = new HashMap<TrawlerBoat, FishingTrawler>();
snapshots = new LinkedList<Snapshot>();
tiles = new TileValue[MAX_WIDTH][MAX_HEIGHT];
tiles = new TileValue[Constants.MAX_WIDTH][Constants.MAX_HEIGHT];
worldLoader = new WorldLoader(this);
regionManager = new RegionManager(this);
clanManager = new ClanManager(this);
......@@ -507,7 +503,7 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
}
private boolean isProjectileClipAllowed(GameObject o) {
for (String s : objectsProjectileClipAllowed) {
for (String s : com.openrsc.server.constants.Constants.objectsProjectileClipAllowed) {
if (o.getType() == 0) {
// there are many of the objects that need to
// have clip enabled.
......@@ -769,7 +765,7 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
* Are the given coords within the world boundaries
*/
public boolean withinWorld(int x, int y) {
return x >= 0 && x < MAX_WIDTH && y >= 0 && y < MAX_HEIGHT;
return x >= 0 && x < Constants.MAX_WIDTH && y >= 0 && y < Constants.MAX_HEIGHT;
}
public FishingTrawler getFishingTrawler(TrawlerBoat boat) {
......@@ -964,4 +960,8 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
public ClanManager getClanManager() {
return clanManager;
}
public boolean isTelegrabEnabled() {
return telegrabEnabled;
}
}
......@@ -17,9 +17,9 @@ import java.util.LinkedHashSet;
public class RegionManager {
private static final int HORIZONTAL_PLANES = (World.MAX_WIDTH / Constants.REGION_SIZE) + 1;
private static final int HORIZONTAL_PLANES = (Constants.MAX_WIDTH / Constants.REGION_SIZE) + 1;
private static final int VERTICAL_PLANES = (World.MAX_HEIGHT / Constants.REGION_SIZE) + 1;
private static final int VERTICAL_PLANES = (Constants.MAX_HEIGHT / Constants.REGION_SIZE) + 1;
private final Region[][] regions;
......
......@@ -783,8 +783,8 @@ public class SpellHandler implements PacketHandler {
return;
}
if (World.WORLD_TELEGRAB_TOGGLE) {
player.message("Telegrab has been disabled due to an running global event, please try again later");
if (player.getWorld().isTelegrabEnabled()) {
player.message("Telegrab has been disabled");
return;
}
if (affectedItem.getLocation().isInSeersPartyHall()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment