Compare commits

...

15 Commits

Author SHA1 Message Date
dependabot[bot] 74f7b7f034 Bump xstream from 1.4.18 to 1.4.19 in /2006Scape Server
Bumps [xstream](https://github.com/x-stream/xstream) from 1.4.18 to 1.4.19.
- [Release notes](https://github.com/x-stream/xstream/releases)
- [Commits](https://github.com/x-stream/xstream/commits)

---
updated-dependencies:
- dependency-name: com.thoughtworks.xstream:xstream
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-04 01:04:22 +00:00
darkaidz98@gmail.com 81cd126a33 Revert Library Updates To Fix Server 2022-01-29 10:45:52 +00:00
Josh Shippam 54a3e5cdec Various Changes (#523)
* Discord Bot Update

Updated JavaCord To Latest
Changed Some Commands To No Longer Be World Specific
Added An "AdminCommands" Command

* Update Some Server Libs

* Added Purge & Pin/Un-Pin To Commands Discord Bot

* Fixed -dev & -no-crc Client Args

* Add Discord User ID Linking Support(Useless For Now)

* Added Support For User's Kicking Own Accounts Through Discord Bot

* Merge Website Integration Stuff Into One Var
2022-01-27 01:32:17 +00:00
Teddy 63055f9181 East falador staircase was falling into the last if which was teleporting the player to a void (#522)
Co-authored-by: Sad Emu <wcpro111@gmail.com>
2022-01-22 03:32:48 +00:00
Teddy 9a3cf5867a Added jad ranged attack projectile (#521)
Co-authored-by: Sad Emu <wcpro111@gmail.com>
2022-01-20 23:53:19 +00:00
Dark98 c5c4471a4f Added Current World To Client Title 2022-01-08 01:54:00 +00:00
Dark98 500441d551 Added/Fixed Right Click Banking For Fadli(Duel Arena Banker) 2022-01-08 00:46:56 +00:00
Dark98 803346323b Fix Discord Bot Derp 2022-01-08 00:18:35 +00:00
Josh Shippam e1a8d85408 Second World Setup (#518)
* Start Setting Up Second World

Added World Number To Login Message
Added World Number To Login Interface
Made World 2 Listen On Different Port
Made Client Connect To 43597 For World 2

* Small Cleanup For World 2 Support

Calculate Port For World Based On World Number
Use Existing World int For World In Server

* Woops Wrong Ports

* Set Server Port After Loading Config

* Add xpRate Var & Include With XPRate Calculations

* Add -w/-world arg to client

* Add XP Rate Multiplier For Non-Bot Worlds

* More Multi World Stuff

Update Integrations(Discord Bot/Website Stuff) For Multiple Worlds
Added More XP Rate Dialogue Stuff

* Add Kick Command To Discord Bot & Fix Type In ConfigLoader

* Create/Use commandPrefix Var For Discord Bot

* Small Fixup For World 2

Renamed BOT_WORLD to VARIABLE_XP_RATE
Fixed Dialogue/Message grammar
Added a check for VARIABLE_XP_RATES to ::xprate command

* More Discord Commands(GameKick, MoveHome & Update)

*GameKick kicks A player if their client froze but acc stayed logged in
*MoveHome removes the need for ::stuck which removes potential for abuse
*Update schedules A server update

* Minor fixup

* 43597 → 43598

* Fix XP Rate Multiplier & add ::xprate to cooamnds list if enabled

* Use Either VARIABLE_SKILL_RATE OR XP_RATE Not Both

TODO(Convert Player.xpRate Into An Array For Easier Rate Changes)

* Create/Use PLAYER_XP_RATES For Easier Rate Changes

* Fixed Abusive Client Command Privileges & Added myxprate/checkxprate

* Allow Loading VARIABLE_XP_RATES & PLAYER_XP_RATES From Config

* Properly Update Client Title Logo

If The Cache Has Already Been Downloaded You Will Need To Delete It & Let The Client ReDownload It

* Fix Cache CRC Checks For The Client(Allows Cache To Actually Check For Updates)

* Add -no-crc & -dev Arguments To Client

* Fix Naming For Some Vars

* Make CHECK_CRC Description More Descriptive

* Fix More Var Descriptions

* Cleanup Unused GameConstants Vars & Add More Vars To ConfigLoader

Co-authored-by: Danial <admin@redsparr0w.com>
2021-12-31 03:47:48 +00:00
Josh Shippam 1c5b400f00 Merge The File&Game Servers Into One Module (#519)
* Merge The File&Game Servers Into One Module

* Make SettingsLoader A GameConstants ConfigLoader
If A Config File Isn't Used, The Server Will Fall Back To The Defaults Set In GameConstants.java

Config Files Can Be Loaded With The "-c/-config configfilelocation.json"
Added A Default Prefilled ServerConfig.json

* Update ConfigLoader

* Bring Back Independant "Secrets" Loader For External Password Stuff
* Added A Bunch More Vars To The ConfigLoader
* Included A Sample "Server Config"
* Also Updated README.md As Parabot Is No Longer Maintained & We No Longer Have A FileServer Module

* Bundle FileServer with Server (docker)

* Remove /udp and http port

* Update .gitignore

* Move FileServer from `org.apollo.jagcached` → `org/apollo/jagcached`

* Tidy GameConstants & Add More Vars To ConfigLoader

* Organised Up GameConstants A Little To Separate ConfigLoader Vars From The Rest
* Added Some More Variables To Be Loaded Through The ConfigLoader

* Fix A Derp Caused By Laziness

* Add -c/-config arg to README.md

* Enable FileServer By Default

Co-authored-by: Danial <admin@redsparr0w.com>
2021-11-23 00:29:25 +00:00
Dark98 ba7f84fc45 Only Print Loaded Plugins When Debug Enabled
(cherry picked from commit 2629186cc0)
2021-11-09 02:07:21 +00:00
Dark98 f30a936ff6 Revert "Update Client Title Logo"
woops this broke the cache
This reverts commit 97f1eb72e4.

(cherry picked from commit 7a2a6d362b)
2021-11-09 02:06:54 +00:00
Dark98 abe34d86b1 Add Plugins/Kotlin Support To Maven
(cherry picked from commit 546669ead0)
2021-11-09 02:06:49 +00:00
Danial d23b176a28 Make file server optional if cache already downloaded (#514)
(cherry picked from commit 669573c660)
2021-11-09 02:06:46 +00:00
Danial c1202e8989 Couple of fixups (#513)
* Show preference state

* Fixup multiple of the same item on the ground.

* Fixup combat

* Fixup yell, decrease delay

* Tidy up yell

* use jdk8

(cherry picked from commit 1fe76d739e)
2021-11-09 02:06:42 +00:00
95 changed files with 897 additions and 422 deletions
+3
View File
@@ -12,3 +12,6 @@
2006Scape Client/bin/
*.prefs
*.classpath
# Ignore any json files in the server root (should only be config files, the sample file should still be updated)
2006Scape Server/*.json
@@ -1,11 +1,16 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
@@ -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";
public static String SERVER_IP = "server.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
*/
+36 -23
View File
@@ -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;
@@ -6849,8 +6859,10 @@ public class Game extends RSApplet {
}
catch(IOException _ex)
{
s = "Connection problem -- Make sure FileServer is running!!";
expectedCRCs[8] = 0;
s = "FileServer Connection problem";
// Check if we already have cache files, if so then allow the client to load anyway
String cacheDir = Signlink.findcachedir();
expectedCRCs[8] = new File(cacheDir + "main_file_cache.dat").length() > 0 ? 1 : 0;
}
catch(Exception _ex)
{
@@ -6870,7 +6882,7 @@ public class Game extends RSApplet {
l = 10;
} else
{
drawLoadingText(10, s + " - Will retry in " + l + " secs.");
drawLoadingText(10, s + " - retry in " + l + " secs.");
}
try
{
@@ -12044,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;
+16 -3
View File
@@ -8,16 +8,25 @@ 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) {
try {
// Process server/ip address to connect to
for (int i = 0; i < args.length; i++) {
switch(args[i]) {
case "-dev" :
case "-local":
case "-offline":
ClientSettings.SERVER_IP = "localhost";
ClientSettings.CHECK_CRC = false;
break;
case "-no-crc":
case "-no-cache-crc":
ClientSettings.CHECK_CRC = false;
break;
}
if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) {
switch(args[i]) {
case "-s":
@@ -45,6 +54,10 @@ public final class Main {
case "-password":
game.myPassword = args[++i];
break;
case "-w":
case "-world":
ClientSettings.SERVER_WORLD = Integer.parseInt(args[++i]);
break;
}
}
}
+1 -2
View File
@@ -4,12 +4,11 @@
import java.awt.*;
@SuppressWarnings("serial")
final class RSFrame extends Frame {
public RSFrame(RSApplet RSApplet_, int i, int j) {
rsApplet = RSApplet_;
setTitle(ClientSettings.SERVER_NAME);
setTitle(ClientSettings.SERVER_NAME + " World: " + ClientSettings.SERVER_WORLD);
setResizable(false);
setMinimumSize(new Dimension(i + 8, j + 28));
setVisible(true);
+23
View File
@@ -0,0 +1,23 @@
{
"server_name": "2006Scape",
"website_link": "https://2006Scape.org",
"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,
"clues_enabled": true,
"admin_can_trade": false,
"admin_can_sell": false,
"respawn_x": 3222,
"respawn_y": 3218,
"save_timer": 120,
"timeout": 60,
"item_requirements": true,
"max_players": 200,
"website_integration": false
}
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
{"token":""}
@@ -0,0 +1,17 @@
package plugin.npc.fadli
import com.rs2.event.EventContext
import com.rs2.event.EventSubscriber
import com.rs2.event.SubscribesTo
import com.rs2.event.impl.NpcSecondClickEvent
import com.rs2.game.players.Player
@SubscribesTo(NpcSecondClickEvent::class)
class SecondClick : EventSubscriber<NpcSecondClickEvent> {
override fun subscribe(context: EventContext, player: Player, event: NpcSecondClickEvent) {
if (event.npc == 958) {
player.packetSender.openUpBank()
}
}
}
+65 -3
View File
@@ -9,6 +9,11 @@
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<kotlin.version>1.6.10</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
</properties>
<repositories>
<repository>
<id>libs-local</id>
@@ -18,6 +23,11 @@
</repositories>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
@@ -118,19 +128,19 @@
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.17</version>
<version>1.4.19</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.javacord/javacord-api -->
<dependency>
<groupId>org.javacord</groupId>
<artifactId>javacord-api</artifactId>
<version>3.1.1</version>
<version>3.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.javacord/javacord-core -->
<dependency>
<groupId>org.javacord</groupId>
<artifactId>javacord-core</artifactId>
<version>3.1.1</version>
<version>3.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
@@ -150,18 +160,70 @@
<artifactId>google-collections</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>3.6.6.Final</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/plugins</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>8</source>
<target>8</target>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
@@ -0,0 +1,110 @@
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.*;
import java.util.stream.Collectors;
public class ConfigLoader {
public static void loadSettings(String config) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(config));
String out = br.lines().collect(Collectors.joining("\n"));
JSONObject obj = new JSONObject(out);
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"))
GameConstants.SERVER_DEBUG = obj.getBoolean("debug");
if(obj.has("file_server"))
GameConstants.FILE_SERVER = obj.getBoolean("file_server");
if(obj.has("world_id"))
GameConstants.WORLD = obj.getInt("world_id");
if(obj.has("members_only"))
GameConstants.MEMBERS_ONLY = obj.getBoolean("members_only");
if(obj.has("tutorial_island_enabled"))
GameConstants.TUTORIAL_ISLAND = obj.getBoolean("tutorial_island_enabled");
if(obj.has("party_room_enabled"))
GameConstants.PARTY_ROOM_DISABLED = !obj.getBoolean("party_room_enabled");
if(obj.has("clues_enabled"))
GameConstants.CLUES_ENABLED = obj.getBoolean("clues_enabled");
if(obj.has("admin_can_trade"))
GameConstants.ADMIN_CAN_TRADE = obj.getBoolean("admin_can_trade");
if(obj.has("admin_can_drop_items"))
GameConstants.ADMIN_DROP_ITEMS = obj.getBoolean("admin_can_drop_items");
if(obj.has("admin_can_sell"))
GameConstants.ADMIN_CAN_SELL_ITEMS = obj.getBoolean("admin_can_sell");
if(obj.has("respawn_x"))
GameConstants.RESPAWN_X = obj.getInt("respawn_x");
if(obj.has("respawn_y"))
GameConstants.RESPAWN_Y = obj.getInt("respawn_y");
if(obj.has("save_timer"))
GameConstants.SAVE_TIMER = obj.getInt("save_timer");
if(obj.has("timeout"))
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_integration"))
GameConstants.WEBSITE_INTEGRATION = obj.getBoolean("website_integration");
}
private static void initialize() {
JSONObject main = new JSONObject();
main
.put("bot-token", "")
.put("websitepass", "")
.put("erssecret", "");
try {
BufferedWriter br = new BufferedWriter(new FileWriter("data/secrets.json"));
br.write(main.toString());
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void loadSecrets() throws IOException {
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!");
} else {
BufferedReader br = new BufferedReader(new FileReader("data/secrets.json"));
String out = br.lines().collect(Collectors.joining("\n"));
JSONObject obj = new JSONObject(out);
/*
* Sets External Services Vars
*/
if(obj.has("bot-token"))
JavaCord.token = obj.getString("bot-token");
if(obj.has("websitepass"))
PlayersOnlineWebsite.password = obj.getString("websitepass");
RegisteredAccsWebsite.password = obj.getString("websitepass");
if(obj.has("erssecret"))
GameEngine.ersSecret = obj.getString("erssecret");
}
}
}
@@ -2,43 +2,58 @@ package com.rs2;
public class GameConstants {
public final static boolean SERVER_DEBUG = false;
/**
* The Variables Below Can Be Also Changed On Server Startup By Using The ConfigLoader
*
* SERVER_NAME Sets The Name The Server Will Use
* WEBSITE_LINK Defines The Server Website Links
* WORLD Sets The Servers World ID
* MAX_PLAYERS Sets The Maximum Amount Of Players Allow To Be Logged In At Once
* TIMEOUT Sets The Amount Of Time Before A Player Timeouts From A Bad Connection
* SAVE_TIMER Sets In Seconds How Often The Server Shouls Auto-Save All Characters
* RESPAWN_X Sets The X Coordinate That You Will Respawn At After Death
* RESPAWN_Y Sets The Y Coordinate That You Will Respawn At After Death
* 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 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
* 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
* WEBSITE_INTEGRATION Enables/Disables Website Features(Total Accounts Registered & Players Online)
*/
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 = false,
WEBSITE_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;
public final static String SERVER_NAME = "2006Scape", SERVER_VERSION = "Server Stage v " + GameConstants.TEST_VERSION + ".";
/**
* The Variables Below Should Only Be Changed If You Understand What You Are Doing
*/
public final static int ITEM_LIMIT = 15000, MAXITEM_AMOUNT = Integer.MAX_VALUE,
IPS_ALLOWED = 250, CONNECTION_DELAY = 100;
public final static String WEBSITE_LINK = "https://2006Scape.org";
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, CLIENT_VERSION = 999999,
WORLD = 1, IPS_ALLOWED = 250, CONNECTION_DELAY = 100,
MESSAGE_DELAY = 6000, MAX_PLAYERS = 200, REQ_AMOUNT = 150;
public final static boolean SOUND = true,
GUILDS = true,
PARTY_ROOM_DISABLED = false,
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 };
public static boolean TUTORIAL_ISLAND = false,
MEMBERS_ONLY = false, sendServerPackets = false,
CLUES_ENABLED = true;
public final static int[] FUN_WEAPONS = { 2460, 2461, 2462, 2463, 2464,
2465, 2466, 2467, 2468, 2469, 2470, 2471, 2471, 2473, 2474, 2475,
2476, 2477 }; // fun weapons for dueling
public static boolean ADMIN_CAN_TRADE = false; // can admins trade?
public final static boolean ADMIN_DROP_ITEMS = false;
public final static boolean ADMIN_CAN_SELL_ITEMS = false;
public final static int RESPAWN_X = 3222; // when dead respawn here
public final static int RESPAWN_Y = 3218;
public final static int DUELING_RESPAWN_X = 3362;
@@ -46,16 +61,6 @@ public class GameConstants {
public final static int NO_TELEPORT_WILD_LEVEL = 20;
public final static boolean ITEM_REQUIREMENTS = true;
public final static int CASTLE_WARS_X = 2439;
public final static int CASTLE_WARS_Y = 3087;
public static double XP_RATE = 1;
public final static int SAVE_TIMER = 120; // save every x seconds
public final static int NPC_RANDOM_WALK_DISTANCE = 5;
public final static int NPC_FOLLOW_DISTANCE = 10;
@@ -69,8 +74,6 @@ public class GameConstants {
"skorge", "tortured soul", "undead chicken", "undead cow", "undead one", "undead troll", "zombie", "zombie rat", "zogre"
};
public final static int TIMEOUT = 60;
public final static int CYCLE_TIME = 600;
public final static int BUFFER_SIZE = 10000;
@@ -35,7 +35,6 @@ import com.rs2.game.players.PlayerSave;
import com.rs2.game.shops.ShopHandler;
import com.rs2.integrations.PlayersOnlineWebsite;
import com.rs2.integrations.RegisteredAccsWebsite;
import com.rs2.integrations.SettingsLoader;
import com.rs2.integrations.discord.DiscordActivity;
import com.rs2.integrations.discord.JavaCord;
import com.rs2.net.ConnectionHandler;
@@ -49,10 +48,11 @@ import com.rs2.world.ObjectHandler;
import com.rs2.world.ObjectManager;
import com.rs2.world.clip.ObjectDefinition;
import com.rs2.world.clip.RegionFactory;
import org.apollo.jagcached.FileServer;
/**
* Server.java
*
*
* @author Sanity
* @author Graham
* @author Blake
@@ -60,10 +60,10 @@ import com.rs2.world.clip.RegionFactory;
* @author Integration Julian.
*/
public class GameEngine {
private static long minutesCounter;
private static void startMinutesCounter() {
try {
minuteFile = new BufferedReader(new FileReader(
@@ -102,13 +102,12 @@ public class GameEngine {
public static void schedule(Tick tick) {
getScheduler().schedule(tick);
}
public static String ersSecret;
public static int[] cannonsX = new int [50];
public static int[] cannonsY = new int [50];
public static String[] cannonsO = new String [50];
public static int[] cannonsX = new int[50];
public static int[] cannonsY = new int[50];
public static String[] cannonsO = new String[50];
public static boolean sleeping;
public static boolean updateServer = false;
public static long lastMassSave = System.currentTimeMillis();
@@ -127,28 +126,41 @@ public class GameEngine {
public static ObjectManager objectManager = new ObjectManager();
public static FightCaves fightCaves = new FightCaves();
private static PestControl pestControl = new PestControl();
public static Trawler trawler = new Trawler();
public static Trawler trawler = new Trawler();
private final static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private final static Lock lock = new ReentrantLock();
/**
* Port and Cycle rate.
*/
static {
serverlistenerPort = 43594;
shutdownServer = false;
}
public static void main(java.lang.String[] args)
throws NullPointerException, IOException {
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("-") && (i + 1) < args.length && !args[i + 1].startsWith("-")) {
switch (args[i]) {
case "-c":
case "-config":
try {
System.out.println("Loading External Config..");
ConfigLoader.loadSettings(args[++i]);
System.out.println("Loaded Config File " + args[i]);
} catch (IOException e) {
System.out.println("Config File Not Found");
}
break;
}
}
}
serverlistenerPort = (GameConstants.WORLD == 1) ? 43594 : 43596 + GameConstants.WORLD;
System.out.println("Starting game engine..");
if (GameConstants.SERVER_DEBUG) {
System.out.println("@@@@ DEBUG MODE IS ENABLED @@@@");
}
if (!new File("data").exists())
{
System.out.println("************************************");
if (!new File("data").exists()) {
System.out.println("************************************");
System.out.println("************************************");
System.out.println("************************************");
System.out.println("WARNING: I could not find the /data folder. You are LIKELY running this in the wrong directory!");
@@ -163,12 +175,24 @@ public class GameEngine {
/**
* Starting Up Server
*/
System.out.println("Launching " + GameConstants.SERVER_NAME + "...");
System.out.println("Launching " + GameConstants.SERVER_NAME + " World: " + GameConstants.WORLD + "...");
/**
* Starts The File Server If Enabled In GameConstants
*/
if (GameConstants.FILE_SERVER) {
FileServer fs = new FileServer();
try {
fs.start();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Start Integration Services
**/
SettingsLoader.loadSettings();
**/
ConfigLoader.loadSecrets();
JavaCord.init();
/**
@@ -213,11 +237,11 @@ public class GameEngine {
/**
* Main Server Tick
*
*
* This scheduler will tick once every 600ms. If the previous tick takes
* 300ms to execute, this scheduler will wait 300ms only before the next
* tick.
*
*
* scheduleAtFixedRate() does not invoke concurrent Runnables.
*/
scheduler.scheduleAtFixedRate(new Runnable() {
@@ -240,11 +264,11 @@ public class GameEngine {
objectHandler.process();
MageTrainingArena.process();
CycleEventHandler.getSingleton().process();
PlayersOnlineWebsite.addUpdatePlayersOnlineTask();
if(GameConstants.WEBSITE_TOTAL_CHARACTERS_INTEGRATION) {
RegisteredAccsWebsite.addUpdateRegisteredUsersTask();
if (GameConstants.WEBSITE_INTEGRATION) {
PlayersOnlineWebsite.addUpdatePlayersOnlineTask();
RegisteredAccsWebsite.addUpdateRegisteredUsersTask();
}
if(DiscordActivity.playerCount) {
if (DiscordActivity.playerCount) {
DiscordActivity.updateActivity();
}
if (System.currentTimeMillis() - lastMassSave > 300000) {
@@ -277,13 +301,13 @@ public class GameEngine {
}
}
}, 0, GameConstants.CYCLE_TIME, TimeUnit.MILLISECONDS);
/*
* I'd recommend disabling this until I can be bothered to implement it
* properly.
*/
// CommandConsole.getInstance();
try {
while (!scheduler.awaitTermination(60, TimeUnit.SECONDS)) {
// TODO
@@ -292,7 +316,7 @@ public class GameEngine {
} catch (InterruptedException e) {
e.printStackTrace();
}
acceptor = null;
connectionHandler = null;
sac = null;
@@ -301,6 +325,4 @@ public class GameEngine {
public static boolean playerExecuted = false;
private static BufferedReader minuteFile;
}
}
@@ -1806,7 +1806,7 @@ public class CombatAssistant {
}
public boolean checkMagicReqs(int spell) {
return MagicRequirements.checkMagicReqs(player, spell);
return MagicRequirements.checkMagicReqs(player, spell, player.usingMagic);
}
public int calculateRangeDefence() {
@@ -508,8 +508,7 @@ public class NpcCombat {
NpcHandler.npcs[i].projectileId = 448;
} else if (r3 == 1) {
NpcHandler.npcs[i].attackType = 1;
NpcHandler.npcs[i].endGfx = 451;
NpcHandler.npcs[i].projectileId = -1;
NpcHandler.npcs[i].projectileId = 451;
} else if (r3 == 2) {
NpcHandler.npcs[i].attackType = 0;
NpcHandler.npcs[i].projectileId = -1;
@@ -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,
@@ -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;
}
}
@@ -229,6 +229,8 @@ public class Climbing {
} else if (client.objectX == 2603 && client.objectY == 3078) {
client.getPlayerAssistant().feature("using this staircase");
client.resetWalkingQueue();
} else if (client.objectX == 3058 && client.objectY == 3376) {
client.resetWalkingQueue();
} else if (client.absX != 3186) {
client.getPlayerAssistant().movePlayer(client.absX,
client.absY + 6393, 0);
@@ -98,7 +98,9 @@ public abstract class Player {
public byte buffer[] = null;
public String lastConnectedFrom;
private Compost compost = new Compost(this);
public static int xpRate = 1;
public String discordCode;
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 +168,14 @@ 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 String getDiscordCode() { return discordCode; }
public void setDiscordCode(String code) { this.discordCode = code; }
public boolean isPreaching() {
return preaching;
}
@@ -173,9 +183,9 @@ public abstract class Player {
public void setPreaching(boolean preaching) {
this.preaching = preaching;
}
public boolean preaching;
public Compost getCompost() {
return compost;
}
@@ -223,12 +233,12 @@ public abstract class Player {
public ToolLeprechaun getFarmingTools() {
return toolLeprechaun;
}
public LogCuttingInterface getFletching() {
return fletching;
}
public SingleGates getSingleGates() {
return singleGates;
}
@@ -404,7 +414,7 @@ public abstract class Player {
public MageTrainingArena getMageTrainingArena() {
return mageArena;
}
public Trading getTrading() {
return trading;
}
@@ -444,13 +454,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 +470,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 +991,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 +1408,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 +1705,7 @@ public abstract class Player {
4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 2097152,
8388608, 16777216, 67108864, 134217728 };
/**
* Combat variables
*/
@@ -1713,7 +1723,7 @@ public abstract class Player {
/**
* End
*/
public int clickNpcType, clickObjectType, objectId, objectX,
objectY, npcIndex, npcClickIndex, npcType;
public int pItemX, pItemY, pItemId;
@@ -2130,11 +2140,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 +2158,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 +2517,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
@@ -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])) {
@@ -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;
@@ -431,6 +433,9 @@ public class PlayerSave {
case "unlocked-bones-to-peaches":
player.unlockedBonesToPeaches = Boolean.parseBoolean(token2);
break;
case "discord-user-id":
player.discordCode = token2;
break;
}
break;
case 3:
@@ -593,6 +598,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);
@@ -819,6 +826,8 @@ public class PlayerSave {
}
characterfile.write("void = " + voidStatus.trim());
characterfile.newLine();
characterfile.write("discord-user-id = " + player.discordCode);
characterfile.newLine();
characterfile.newLine();
/* EQUIPMENT */
@@ -8,12 +8,12 @@ import com.rs2.game.players.PlayerHandler;
public class PlayersOnlineWebsite {
static String password;
public static String password;
private static boolean hasntwared = true;
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();
}
@@ -7,12 +7,12 @@ import java.net.URL;
import com.rs2.GameConstants;
public class RegisteredAccsWebsite {
static String password;
public static String password;
private static boolean hasntwarned = true;
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();
}
@@ -1,45 +0,0 @@
package com.rs2.integrations;
import org.json.JSONObject;
import com.rs2.GameEngine;
import com.rs2.integrations.discord.JavaCord;
import java.io.*;
import java.util.stream.Collectors;
public class SettingsLoader {
private static void initialize() {
JSONObject main = new JSONObject();
main
.put("bot-token", "")
.put("websitepass", "")
.put("erssecret", "");
try {
BufferedWriter br = new BufferedWriter(new FileWriter("data/secrets.json"));
br.write(main.toString());
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void loadSettings() throws IOException {
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!");
} else {
BufferedReader br = new BufferedReader(new FileReader("data/secrets.json"));
String out = br.lines().collect(Collectors.joining("\n"));
JSONObject obj = new JSONObject(out);
JavaCord.token = obj.getString("bot-token");
PlayersOnlineWebsite.password = obj.getString("websitepass");
RegisteredAccsWebsite.password = obj.getString("websitepass");
GameEngine.ersSecret = obj.getString("erssecret");
}
}
}
@@ -1,12 +1,13 @@
package com.rs2.integrations.discord;
import com.rs2.GameConstants;
import com.rs2.integrations.discord.commands.*;
import com.rs2.integrations.discord.commands.admin.*;
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 +18,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 +36,19 @@ public class JavaCord {
api.addListener(new Players());
api.addListener(new Vote());
api.addListener(new Website());
//Admin Commands
api.addListener(new AdminCommands());
api.addListener(new GameKick());
api.addListener(new MoveHome());
api.addListener(new Update());
api.addListener(new Pin());
api.addListener(new Purge());
//api.addListener(new Link());
//api.addListener(new WelcomeMessage());
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) {
@@ -0,0 +1,16 @@
package com.rs2.integrations.discord;
import com.rs2.GameConstants;
import org.javacord.api.event.server.member.ServerMemberJoinEvent;
import org.javacord.api.listener.server.member.ServerMemberJoinListener;
public class WelcomeMessage implements ServerMemberJoinListener {
@Override
public void onServerMemberJoin(ServerMemberJoinEvent event) {
String welcomeMessageChannel = "655143683083206667";
if (GameConstants.WORLD == 1) {
event.getApi().getTextChannelById(welcomeMessageChannel).get().
sendMessage("Hello " + event.getUser().getMentionTag() + " And Welcome To " + JavaCord.serverName + ".");
}
}
}
@@ -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,18 +9,18 @@ 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"
+ System.lineSeparator() +
"::hiscores/::highscores"
JavaCord.commandPrefix + " gamekick(if account id linked)"
+ System.lineSeparator() +
JavaCord.commandPrefix + " hiscores/" + JavaCord.commandPrefix + " highscores"
+ System.lineSeparator() +
"::issues/::bugs"
+ System.lineSeparator() +
"::online"
+ System.lineSeparator() +
"::players"
JavaCord.commandPrefix + " online"
+ System.lineSeparator() +
"::vote"
+ System.lineSeparator() +
@@ -11,7 +11,9 @@ public class Forum implements MessageCreateListener {
public void onMessageCreate(MessageCreateEvent event) {
Message message = event.getMessage();
if (message.getContent().equalsIgnoreCase("::forum") || message.getContent().equalsIgnoreCase("::forums")) {
event.getChannel().sendMessage(GameConstants.WEBSITE_LINK + "/forums/index.php");
if (GameConstants.WORLD == 1) {
event.getChannel().sendMessage(GameConstants.WEBSITE_LINK + "/forums/index.php");
}
}
}
}
@@ -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");
}
}
@@ -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;
@@ -9,7 +10,9 @@ public class Issues implements MessageCreateListener {
public void onMessageCreate(MessageCreateEvent event) {
Message message = event.getMessage();
if (message.getContent().equalsIgnoreCase("::issues") || message.getContent().equalsIgnoreCase("::bugs")) {
event.getChannel().sendMessage("https://github.com/2006-Scape/2006Scape/issues");
if (GameConstants.WORLD == 1) {
event.getChannel().sendMessage("https://github.com/2006-Scape/2006Scape/issues");
}
}
}
}
@@ -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:");
}
}
}
@@ -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 {
@@ -11,7 +11,9 @@ public class Vote implements MessageCreateListener {
public void onMessageCreate(MessageCreateEvent event) {
Message message = event.getMessage();
if (message.getContent().equalsIgnoreCase("::vote")) {
if (GameConstants.WORLD == 1) {
event.getChannel().sendMessage("Visit " + GameConstants.WEBSITE_LINK + "/vote.html then type \"::claimvote\" in-game to receive your reward!");
}
}
}
}
@@ -11,7 +11,9 @@ public class Website implements MessageCreateListener {
public void onMessageCreate(MessageCreateEvent event) {
Message message = event.getMessage();
if (message.getContent().equalsIgnoreCase("::website") || message.getContent().equalsIgnoreCase("::site")) {
event.getChannel().sendMessage(GameConstants.WEBSITE_LINK);
if (GameConstants.WORLD == 1) {
event.getChannel().sendMessage(GameConstants.WEBSITE_LINK);
}
}
}
}
@@ -0,0 +1,31 @@
package com.rs2.integrations.discord.commands.admin;
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;
public class AdminCommands implements MessageCreateListener {
@Override
public void onMessageCreate(MessageCreateEvent event) {
Message message = event.getMessage();
if (message.getContent().equalsIgnoreCase(JavaCord.commandPrefix + " admincommands")) {
if (event.getMessageAuthor().isServerAdmin()) {
event.getChannel().sendMessage("```fix"
+ System.lineSeparator() +
"::pin/::unpin(Pins/Un-Pins The Replied Mesage)"
+ System.lineSeparator() +
"::purge(Purges The Specified Amount Of Messages From Discord Channel)"
+ System.lineSeparator() +
JavaCord.commandPrefix + " gamekick(Kicks The Specified Player From The GameServer)"
+ System.lineSeparator() +
JavaCord.commandPrefix + " movehome(Moves The Specified Player To Lumbridge)"
+ System.lineSeparator() +
JavaCord.commandPrefix + " update(Triggers A GameServer Update In The Specified Amount Of Seconds)"
+ "```");
} else {
event.getChannel().sendMessage("You do not have permission to perform this command");
}
}
}
}
@@ -0,0 +1,34 @@
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;
import java.util.Objects;
public class GameKick implements MessageCreateListener {
@Override
public void onMessageCreate(MessageCreateEvent event) {
if (event.getMessageContent().startsWith(JavaCord.commandPrefix + " gamekick")) {
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;
if (event.getMessageAuthor().isServerAdmin() || Objects.equals(event.getMessageAuthor().getIdAsString(), c2.discordCode)) {
event.getChannel().sendMessage(playerToKick + " was kicked by " + event.getMessageAuthor().getDisplayName() + ".");
c2.disconnected = true;
c2.logout(true);
} else {
event.getChannel().sendMessage("You do not have permission to perform this command");
}
break;
}
}
}
}
}
}
@@ -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");
}
}
}
}
@@ -0,0 +1,39 @@
package com.rs2.integrations.discord.commands.admin;
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;
public class Pin implements MessageCreateListener {
@Override
public void onMessageCreate(MessageCreateEvent event) {
Message message = event.getMessage();
if (message.getContent().startsWith("::pin")) {
if (event.getMessageAuthor().isServerAdmin()) {
if(GameConstants.WORLD == 1) {
if (message.getReferencedMessage().isPresent()) {
Message messageToPin = message.getReferencedMessage().get();
messageToPin.pin();
}
}
} else {
event.getChannel().sendMessage("You do not have permission to perform this command");
}
}
if (message.getContent().startsWith("::unpin")) {
if (event.getMessageAuthor().isServerAdmin()) {
if(GameConstants.WORLD == 1) {
if (message.getReferencedMessage().isPresent()) {
Message messageToUnpin = message.getReferencedMessage().get();
messageToUnpin.unpin();
event.getChannel().sendMessage("Un-Pinned Message: " + messageToUnpin.getLink());
}
}
} else {
event.getChannel().sendMessage("You do not have permission to perform this command");
}
}
}
}
@@ -0,0 +1,40 @@
package com.rs2.integrations.discord.commands.admin;
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;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
public class Purge implements MessageCreateListener {
@Override
public void onMessageCreate(MessageCreateEvent event) {
Message message = event.getMessage();
if (message.getContent().startsWith("::purge")) {
if (event.getMessageAuthor().isServerAdmin()) {
if(GameConstants.WORLD == 1) {
int messagesToPurge = Integer.parseInt(event.getMessageContent().replace("::purge ", ""));
if (messagesToPurge > 50) {
event.getChannel().sendMessage("Can't purge more than 50 messages at once.");
return;
}
try {
event.getChannel().sendMessage("Purging " + messagesToPurge + " Messages.");
message.getMessagesBefore(messagesToPurge).get().deleteAll();
Message Purge = message.getMessagesAfter(1).get().getNewestMessage().get();
Purge.edit("Purged " + messagesToPurge + " Messages.");
TimeUnit.SECONDS.sleep(5);
message.delete();
Purge.delete();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
} else {
event.getChannel().sendMessage("You do not have permission to perform this command");
}
}
}
}
@@ -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) {
String seconds = event.getMessageContent().replace(JavaCord.commandPrefix + " update ", "");
if (event.getMessageContent().startsWith(JavaCord.commandPrefix + " update")) {
if (event.getMessageAuthor().isServerAdmin()) {
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");
}
}
}
}
@@ -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");
@@ -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,16 +44,51 @@ public class Commands implements PacketType {
public static void playerCommands(Player player, String playerCommand, String[] arguments) {
switch (playerCommand.toLowerCase()) {
case "link":
player.setDiscordCode(arguments[0]);
player.getPacketSender().sendMessage("Your Account has now been linked with Discord User ID:");
player.getPacketSender().sendMessage(player.getDiscordCode());
break;
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":
player.hideYell = !player.hideYell;
player.getPacketSender().sendMessage("Your yell visibility preferences have been updated.");
player.getPacketSender().sendMessage("Your yell visibility preferences have been updated: " + (player.hideYell ? "hidden" : "visible"));
break;
case "yell":
int delay = 0;
if (player.playerRights <= 1) {
delay = 30000;
delay = 10000;
}
if (!AntiSpam.blockedWords(player, arguments[0].substring(5), true)) {
if (!AntiSpam.blockedWords(player, String.join(" ", arguments), true)) {
return;
}
if (Connection.isMuted(player)) {
@@ -69,17 +103,20 @@ public class Commands implements PacketType {
if (PlayerHandler.players[j] != null) {
Client c2 = (Client) PlayerHandler.players[j];
if (c2.hideYell) {
return;
continue;
}
String msg = "";
if (player.playerRights == 0) {
c2.getPacketSender().sendMessage("[Player]" + Misc.optimizeText(player.playerName) + ": " + Misc.optimizeText(String.join(" ", arguments)) + "");
msg = "@bla@[Player] ";
} else if (player.playerRights == 1) {
c2.getPacketSender().sendMessage("@blu@[Moderator] @bla@" + Misc.optimizeText(player.playerName) + ": " + Misc.optimizeText(String.join(" ", arguments)) + "");
msg = "@blu@[Moderator] ";
} else if (player.playerRights == 2) {
c2.getPacketSender().sendMessage("@gre@[Administator] @bla@" + Misc.optimizeText(player.playerName) + ": " + Misc.optimizeText(String.join(" ", arguments)) + "");
msg = "@gre@[Administator] ";
} else if (player.playerRights == 3) {
c2.getPacketSender().sendMessage("@red@[Developer] @bla@" + Misc.optimizeText(player.playerName) + ": " + Misc.optimizeText(String.join(" ", arguments)) + "");
msg = "@red@[Developer] ";
}
msg += "@bla@" + Misc.optimizeText(player.playerName) + ": @blu@" + Misc.optimizeText(String.join(" ", arguments));
c2.getPacketSender().sendMessage(msg);
player.lastYell = System.currentTimeMillis();
}
}
@@ -252,9 +289,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",
"",
@@ -275,6 +309,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
@@ -289,17 +325,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":
@@ -7,6 +7,7 @@ import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.rs2.GameConstants;
import com.rs2.event.EventSubscriber;
import com.rs2.game.players.Player;
import com.rs2.util.LoggerUtils;
@@ -73,8 +74,9 @@ public final class PluginService {
base = base.replace(".java", "");
System.out.println(base);
System.out.println(dir.getName());
if (GameConstants.SERVER_DEBUG) {
System.out.println(base);
}
if (!file.isDirectory()) {
try {
@@ -102,23 +102,26 @@ public class ItemHandler {
**/
public void reloadItems(Player c) {
for (GroundItem i : items) {
if (c != null) {
if (c != null && i != null) {
if (c.getH() == i.getItemH() && c.distanceToPoint(i.getItemX(), i.getItemY()) <= 120) {
c.getPacketSender().removeGroundItem(
i.getItemId(), i.getItemX(), i.getItemY(),
i.getItemAmount());
}
}
}
for (GroundItem i : items) {
if (c != null && i != null) {
// If it's a players item or tradeable
if (c.getItemAssistant().tradeable(i.getItemId()) || i.getName().equalsIgnoreCase(c.playerName)) {
// Make sure item on the same height and within 60 blocks
if (c.getH() == i.getItemH() && c.distanceToPoint(i.getItemX(), i.getItemY()) <= 60) {
if (i.hideTicks > 0 && i.getName().equalsIgnoreCase(c.playerName)) {
c.getPacketSender().removeGroundItem(
i.getItemId(), i.getItemX(), i.getItemY(),
i.getItemAmount());
c.getPacketSender().createGroundItem(
i.getItemId(), i.getItemX(), i.getItemY(),
i.getItemAmount());
}
if (i.hideTicks == 0) {
c.getPacketSender().removeGroundItem(
i.getItemId(), i.getItemX(), i.getItemY(),
i.getItemAmount());
c.getPacketSender().createGroundItem(
i.getItemId(), i.getItemX(), i.getItemY(),
i.getItemAmount());
@@ -14,7 +14,7 @@ public final class Constants {
/**
* The directory of the file system.
*/
public static final String FILE_SYSTEM_DIR = "./cache/";
public static final String FILE_SYSTEM_DIR = "./data/cache/";
/**
* Default private constructor to prevent instantiation.
@@ -69,14 +69,15 @@ public final class FileServer {
* @throws Exception if an error occurs.
*/
public void start() throws Exception {
if (!new File("cache").exists())
if (!new File(Constants.FILE_SYSTEM_DIR).exists())
{
System.out.println("Working Directory = " + System.getProperty("user.dir"));
System.out.println("************************************");
System.out.println("************************************");
System.out.println("************************************");
System.out.println("WARNING: I could not find the /cache folder. You are LIKELY running this in the wrong directory!");
System.out.println("In IntelliJ, fix it by clicking \"FileServer\" > Edit Configurations at the top of your screen");
System.out.println("Then changing the \"Working Directory\" to be in \"2006Scape/2006Scape file_server\", instead of just \"2006Scape\"");
System.out.println("WARNING: I could not find the data/cache folder. You are LIKELY running this in the wrong directory!");
System.out.println("In IntelliJ, fix it by clicking \"GameEngine\" > Edit Configurations at the top of your screen");
System.out.println("Then changing the \"Working Directory\" to be in \"2006Scape/2006Scape Server\", instead of just \"2006Scape\"");
System.out.println("************************************");
System.out.println("************************************");
System.out.println("************************************");
-4
View File
@@ -1,4 +0,0 @@
/bin/
*.iml
/target/
file_server-1.0-jar-with-dependencies.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-118
View File
@@ -1,118 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>2006Scape</artifactId>
<groupId>com.rs2</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>file_server</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>libs-local</id>
<name>libs</name>
<url>file://${project.basedir}/libs</url>
</repository>
</repositories>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.mina/mina-core -->
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>1.1.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.netty/netty -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>3.6.6.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-nop -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.5.8</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.17</version>
</dependency>
<dependency>
<groupId>javac</groupId>
<artifactId>javac</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/javac++.jar</systemPath>
</dependency>
<dependency>
<groupId>org.xmlpull.v1</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.4c</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/xpp3-1.1.4c.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.apollo.jagcached.FileServer</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
-6
View File
@@ -1,6 +0,0 @@
echo This is meant to be run by the live server admin! You probably don\'t want to do this!
for i in {0..50}
do
cp target/file_server-1.0-jar-with-dependencies.jar ./fserver.jar
java -jar fserver.jar
done
+4 -7
View File
@@ -4,8 +4,7 @@
## How to Play
### Client (non-bottable download): https://github.com/2006-Scape/2006Scape/releases/
### Parabot client (recommended): https://www.parabot.org/community/
### Client/Launcher Download: https://2006Scape.org/
### Rune-Server project thread: [Project thread](https://www.rune-server.ee/runescape-development/rs2-server/projects/686444-2006rebotted-remake-server-will-allow-supply-creatable-bots.html)
# Installation + Running (Developers)
@@ -14,17 +13,16 @@
2. Hit File > Project Settings > Set SDK to Java 8 (Download [Java 8 SDK](https://adoptopenjdk.net/?variant=openjdk8) if you don't have one already)
2. Navigate to `2006Scape file_server` > `src` > `main` > `java` > `org.apollo.jagcached`, right click FileServer and hit Run [Image](https://i.imgur.com/tsg9q1Z.png)
3. Navigate to `2006Scape Server` > `src` > `main` > `java` > `com.rs2`, right click GameEngine and hit Run [Image](https://i.imgur.com/HHooeVu.png)
4. Navigate to `2006Scape Client` > `src` > `main` > `java`, right click Client and hit Run [Image](https://i.imgur.com/gSmqGLn.png)
[(You Can Also Run The Server With The -c/-config Argument)](https://wiki.2006scape.org/books/getting-setup/page/server-arguments)
5. Navigate to `2006Scape Client` > `src` > `main` > `java`, right click Client and hit Run [Image](https://i.imgur.com/gSmqGLn.png)
*Advanced*
To compile any module from the command line, run `mvn clean install`
## Using Parabot with your local server:
## Using Parabot with your local server: (OUTDATED)
- **1:** Download the latest `localhost_2006Scape.jar` from [here](https://github.com/2006-Scape/2006Scape/releases) (or, if testing server changes, compile it yourself like [this](https://i.imgur.com/uDrF0gl.png))
- **2:** Download the latest `Provider-version.jar` file from [here](http://v3.bdn.parabot.org/api/bot/download/default-provider?nightly=false)
- **3:** Create a file called `localhost.json` in `{user}\Documents\Parabot\servers`
@@ -55,7 +53,6 @@ java -jar Client-2.8.1.jar -login username password -loadlocal -v -clearcache
- `2006Scape Server` contains all the server code; mark `src` as the Sources directory
- `2006Scape Client` contains all the client code; likewise mark `src`
- If more than 2 arguments are passed in (can be anything), the client runs locally
- `2006Scape file_server` contains the file server code that is *required* to be running before a client can connect to a server. It must be running locally before a client can connect. `src` is the Sources directory
## Building from command line
+3 -15
View File
@@ -10,26 +10,14 @@ services:
working_dir: /usr/src/2006scape
restart: "no"
rsps-2006scape-file-server:
image: openjdk:8-alpine
container_name: rsps-2006scape-file-server
command: ["java", "-jar", "target/file_server-1.0-jar-with-dependencies.jar"]
volumes:
- ./2006Scape file_server:/usr/src/fileserver
working_dir: /usr/src/fileserver
ports:
- 8080:8080 # web panel
- 43595-43596:43595-43596 # File Server
restart: unless-stopped
rsps-2006scape-server:
image: openjdk:8-alpine
container_name: rsps-2006scape-server
command: ["java", "-jar", "target/server-1.0-jar-with-dependencies.jar"]
command: ["java", "-jar", "target/server-1.0-jar-with-dependencies.jar", "-c", "ServerConfig.json"]
volumes:
- ./2006Scape Server:/usr/src/server
working_dir: /usr/src/server
ports:
ports: # You will need to open other ports if your world ID is not 1 (43598 for world 2)
- 43594:43594 # Server
- 43594:43594/udp # Server
- 43595-43596:43595-43596 # File Server
restart: unless-stopped
-1
View File
@@ -11,7 +11,6 @@
<modules>
<module>2006Scape Client</module>
<module>2006Scape file_server</module>
<module>2006Scape Server</module>
</modules>