Compare commits
148 Commits
master
...
feat/postg
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9d2da1f35 | ||
|
|
e4430a3860 | ||
|
|
f2b8ced976 | ||
|
|
a4f8086da1 | ||
|
|
e295a24d98 | ||
|
|
64f99a29c6 | ||
|
|
40425ac4e1 | ||
|
|
2b6ef9feb5 | ||
|
|
e38344ceae | ||
|
|
5d81e05458 | ||
|
|
af02f8b744 | ||
|
|
7661cd0f75 | ||
|
|
167937bb88 | ||
|
|
988d898d6f | ||
|
|
e35060da2a | ||
|
|
c0ee1f8ffe | ||
|
|
99006c2dda | ||
|
|
f142e21bbb | ||
|
|
1c6245fa6c | ||
|
|
a307afae3c | ||
|
|
50524a7740 | ||
|
|
d00b4ed678 | ||
|
|
b45620154c | ||
|
|
5450c29178 | ||
|
|
fa666c98e6 | ||
|
|
902f1a154e | ||
|
|
4e1aa1eb1a | ||
|
|
a580e44bc9 | ||
|
|
da4a467453 | ||
|
|
0bb14e415e | ||
|
|
0a8591aa08 | ||
|
|
813768ec47 | ||
|
|
5595f5763b | ||
|
|
1be775394e | ||
|
|
55c9d4abbb | ||
|
|
93bbe868cb | ||
|
|
ec39f0fa06 | ||
|
|
439280947c | ||
|
|
5abae50be5 | ||
|
|
082e0c0486 | ||
|
|
2044166967 | ||
|
|
f33d4fbc1c | ||
|
|
0f2ef341ce | ||
|
|
c7f835da0d | ||
|
|
647e67f6e8 | ||
|
|
bf9c02bc16 | ||
|
|
1d5c26e67c | ||
|
|
b85233359f | ||
|
|
7335914695 | ||
|
|
b4e673baab | ||
|
|
767c4402e7 | ||
|
|
a9967d53b1 | ||
|
|
00fc3ed1a1 | ||
|
|
98d76ad45e | ||
|
|
0c9643fd7e | ||
|
|
ce5dee39ae | ||
|
|
e57d2a9ee2 | ||
|
|
f827e23ccc | ||
|
|
f8726640c3 | ||
|
|
4778482cdd | ||
|
|
7297cd09b6 | ||
|
|
08eeeb54dc | ||
|
|
abbec8120e | ||
|
|
23a8a33e5f | ||
|
|
758347f7bc | ||
|
|
1b6c0167de | ||
|
|
8bce0922d9 | ||
|
|
f41268cdde | ||
|
|
719b079cbc | ||
|
|
7bd5fa387d | ||
|
|
09a75e89c9 | ||
|
|
559fe2d550 | ||
|
|
a7d03cf8c0 | ||
|
|
033d91ed71 | ||
|
|
392a350eab | ||
|
|
f33df59f49 | ||
|
|
cd75e85bec | ||
|
|
cb31121fe7 | ||
|
|
d5682a5f65 | ||
|
|
f6d06ba82a | ||
|
|
bbee8d7caa | ||
|
|
5b5888cf65 | ||
|
|
48d9aaa871 | ||
|
|
f44083aeba | ||
|
|
810dbcc1d7 | ||
|
|
449ab01bc2 | ||
|
|
2686b2b02d | ||
|
|
e9819fac87 | ||
|
|
4e39142fb3 | ||
|
|
e52f646558 | ||
|
|
02d4ff524a | ||
|
|
05b7ec77c8 | ||
|
|
f6aa8ceba6 | ||
|
|
b3ec325e95 | ||
|
|
e31465a1b5 | ||
|
|
84ad5b4db8 | ||
|
|
855b66c459 | ||
|
|
46f767d79c | ||
|
|
785f74ed21 | ||
|
|
699da37f06 | ||
|
|
c3badba73b | ||
|
|
5f0e9a355b | ||
|
|
39d759595d | ||
|
|
fe9dd75a23 | ||
|
|
2139147dcd | ||
|
|
c71ca7f4d5 | ||
|
|
705efb4340 | ||
|
|
ec1450cec1 | ||
|
|
290bf78db3 | ||
|
|
02c1fe46f3 | ||
|
|
7315dd80fc | ||
|
|
a496c0f2b4 | ||
|
|
ab0239ba84 | ||
|
|
f2f3abdb32 | ||
|
|
5a35b55d7a | ||
|
|
02aa4a237f | ||
|
|
cc88d382e6 | ||
|
|
a95fa2efc1 | ||
|
|
45e2b93724 | ||
|
|
fa3481fa99 | ||
|
|
eed94ec34a | ||
|
|
a6a7a26ebc | ||
|
|
7ed7b25268 | ||
|
|
703ae30a27 | ||
|
|
6bf8785f22 | ||
|
|
53768555a2 | ||
|
|
a70f4e303d | ||
|
|
7a848cf6a1 | ||
|
|
0be48568d7 | ||
|
|
1fd0963401 | ||
|
|
d2d4b442d2 | ||
|
|
9d6574d3ba | ||
|
|
f2ca67aba4 | ||
|
|
6073b20d65 | ||
|
|
b329709776 | ||
|
|
932f9fc443 | ||
|
|
c0c0a2d2d9 | ||
|
|
5cecb7adb6 | ||
|
|
26357a8d7b | ||
|
|
9819fd5bb1 | ||
|
|
adbdb89917 | ||
|
|
b7c79800eb | ||
|
|
55e1f65bbd | ||
|
|
d018b0f5e5 | ||
|
|
12745c207d | ||
|
|
f6f3c9c3e3 | ||
|
|
8bb825ef02 | ||
|
|
f1192279bf |
18
config.yaml
18
config.yaml
@@ -165,6 +165,14 @@ server:
|
||||
DB_PASS: ""
|
||||
INIT_CONNECTION_POOL_TIMEOUT: 90 # Seconds
|
||||
|
||||
PG_DB_URL: "jdbc:postgresql://localhost:5432/cosmic"
|
||||
PG_DB_SCHEMA: "cosmic"
|
||||
PG_DB_ADMIN_USERNAME: "cosmic_admin"
|
||||
PG_DB_ADMIN_PASSWORD: "redsnailshell"
|
||||
PG_DB_USERNAME: "cosmic_server"
|
||||
PG_DB_PASSWORD: "bluesnailshell"
|
||||
PG_DB_CLEAN: false # !!! WARNING !!! Deletes the entire database - starts from scratch.
|
||||
|
||||
#Login Configuration
|
||||
WORLDS: 1 #Initial number of worlds on the server.
|
||||
WLDLIST_SIZE: 21 #Max possible worlds on the server.
|
||||
@@ -185,7 +193,6 @@ server:
|
||||
BYPASS_PIN_EXPIRATION: 15 #Enables PIN bypass, which will remain active for that account by that client machine for N minutes. Set 0 to disable.
|
||||
|
||||
AUTOMATIC_REGISTER: true #Automatically register players when they login with a nonexistent username.
|
||||
BCRYPT_MIGRATION: true #Performs a migration from old SHA-1 and SHA-512 password to bcrypt.
|
||||
COLLECTIVE_CHARSLOT: false #Available character slots are contabilized globally rather than per world server.
|
||||
DETERRED_MULTICLIENT: false #Enables detection of multi-client and suspicious remote IP on the login system.
|
||||
#Besides blocking logging in with several client sessions on the same machine, this also blocks suspicious login attempts for players that tries to login on an account using several diferent remote addresses.
|
||||
@@ -234,7 +241,6 @@ server:
|
||||
USE_AUTOBAN: false #Commands the server to detect infractors automatically.
|
||||
USE_AUTOBAN_LOG: true #Log autoban related messages. Still logs even with USE_AUTOBAN disabled.
|
||||
USE_EXP_GAIN_LOG: false #Logs characters exp gains; logs world rate & coupon exp, total gained exp, and current exp, level can be calculated from "ExpTable".
|
||||
USE_AUTOSAVE: true #Enables server autosaving feature (saves characters to DB each 1 hour).
|
||||
USE_SERVER_AUTOASSIGNER: false #HeavenMS-builtin autoassigner, uses algorithm based on distributing AP accordingly with required secondary stat on equipments.
|
||||
USE_REFRESH_RANK_MOVE: true
|
||||
USE_ENFORCE_ADMIN_ACCOUNT: false #Forces accounts having GM characters to be treated as a "GM account" by the client (localhost). Some of the GM account perks is the ability to FLY, but unable to TRADE.
|
||||
@@ -246,7 +252,6 @@ server:
|
||||
USE_ENFORCE_ITEM_SUGGESTION: false #Forces the Owl of Minerva and the Cash Shop to always display the defined item array instead of those featured by the players.
|
||||
USE_ENFORCE_UNMERCHABLE_CASH: true #Forces players to not sell CASH items via merchants, drops of it disappears.
|
||||
USE_ENFORCE_UNMERCHABLE_PET: true #Forces players to not sell pets via merchants, drops of it disappears. (since non-named pets gets dirty name and other possible DB-related issues)
|
||||
USE_ENFORCE_MERCHANT_SAVE: true #Forces automatic DB save on merchant owners, at every item movement on shop.
|
||||
USE_ENFORCE_MDOOR_POSITION: false #Forces mystic door to be spawned near spawnpoints.
|
||||
USE_SPAWN_CLEAN_MDOOR: false #Makes mystic doors to be spawned without deploy animation. This clears disconnecting issues that may happen when trying to cancel doors a couple seconds after deployment.
|
||||
USE_SPAWN_RELEVANT_LOOT: true #Forces to only spawn loots that are collectable by the player or any of their party members.
|
||||
@@ -355,7 +360,6 @@ server:
|
||||
USE_FULL_HOLY_SYMBOL: false #Holy symbol doesn't require EXP sharers to work in full.
|
||||
|
||||
#Character Configuration
|
||||
USE_ADD_SLOTS_BY_LEVEL: false #Slots are added each 20 levels.
|
||||
USE_ADD_RATES_BY_LEVEL: false #Rates are added each 20 levels.
|
||||
USE_STACK_COUPON_RATES: false #Multiple coupons effects builds up together.
|
||||
USE_PERFECT_PITCH: false #For lvl 30 or above, each lvlup grants player 1 perfect pitch.
|
||||
@@ -363,12 +367,6 @@ server:
|
||||
#Quest Configuration
|
||||
USE_QUEST_RATE: false #Exp/Meso gained by quests uses fixed server exp/meso rate times quest rate as multiplier, instead of player rates.
|
||||
|
||||
#Quest Points Configuration
|
||||
QUEST_POINT_REPEATABLE_INTERVAL: 25 #Minimum interval between repeatable quest completions for quest points to be awarded.
|
||||
QUEST_POINT_REQUIREMENT: 0 #Exchange factor between N quest points to +1 fame, set 0 to disable the entire quest point mechanism.
|
||||
QUEST_POINT_PER_QUEST_COMPLETE: 0 #Each completed quest awards N quest points, set 0 to disable.
|
||||
QUEST_POINT_PER_EVENT_CLEAR: 0 #Each completed event instance awards N quest points, set 0 to disable.
|
||||
|
||||
#Guild Configuration
|
||||
CREATE_GUILD_MIN_PARTNERS: 6 #Minimum number of members on Guild Headquarters to establish a new guild.
|
||||
CREATE_GUILD_COST: 1500000
|
||||
|
||||
2
database/.gitignore
vendored
Normal file
2
database/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
docker-db-data/*
|
||||
docker-pg-db-data/*
|
||||
3
database/docker-db-data/.gitignore
vendored
3
database/docker-db-data/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
*
|
||||
*/
|
||||
!.gitignore
|
||||
3
database/postgres-scripts/create-db-and-admin-user.sql
Normal file
3
database/postgres-scripts/create-db-and-admin-user.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
CREATE DATABASE cosmic;
|
||||
CREATE USER cosmic_admin WITH CREATEROLE ENCRYPTED PASSWORD 'redsnailshell';
|
||||
GRANT ALL PRIVILEGES ON DATABASE cosmic TO cosmic_admin;
|
||||
1
database/sql/1-db_database.sql
Normal file
1
database/sql/1-db_database.sql
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
@@ -4,6 +4,7 @@ services:
|
||||
build: .
|
||||
depends_on:
|
||||
- db
|
||||
- pg_db
|
||||
ports:
|
||||
# Login server
|
||||
- "8484:8484"
|
||||
@@ -19,7 +20,8 @@ services:
|
||||
- ./wz:/opt/server/wz
|
||||
environment:
|
||||
DB_HOST: "db" ## Remember if this is present it will OVERRIDE the host in the config.yaml, if you put here anything other than db, you'll need to change the config.yaml jdbc string to port 3307, and not port 3306
|
||||
|
||||
PG_DB_HOST: "pg_db"
|
||||
|
||||
db:
|
||||
image: mysql:8.4.0
|
||||
environment:
|
||||
@@ -30,3 +32,13 @@ services:
|
||||
- "3307:3306"
|
||||
volumes:
|
||||
- ./database/docker-db-data:/var/lib/mysql
|
||||
|
||||
pg_db:
|
||||
image: postgres:15.0
|
||||
ports:
|
||||
- "5433:5432"
|
||||
environment:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
volumes:
|
||||
- ./database/docker-pg-db-data:/var/lib/postgresql/data
|
||||
- ./database/postgres-scripts:/docker-entrypoint-initdb.d
|
||||
|
||||
45
pom.xml
45
pom.xml
@@ -69,6 +69,11 @@
|
||||
<liquibase-core.version>4.32.0</liquibase-core.version> <!-- Database migrations -->
|
||||
<junit.version>5.13.1</junit.version> <!-- Unit test -->
|
||||
<mockito.version>5.18.0</mockito.version> <!-- Unit test -->
|
||||
<testcontainers.version>1.20.1</testcontainers.version> <!-- Docker test with real temporary database -->
|
||||
<postgresql.version>42.5.4</postgresql.version> <!-- PostgreSQL JDBC driver -->
|
||||
<flyway.version>9.15.1</flyway.version> <!-- Database migration -->
|
||||
<caffeine.version>3.1.4</caffeine.version> <!-- Caching -->
|
||||
<lombok.version>1.18.34</lombok.version> <!-- Code generation -->
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -82,6 +87,17 @@
|
||||
<artifactId>jcip-annotations</artifactId>
|
||||
<version>${jcip-annotations.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>${caffeine.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Database -->
|
||||
<dependency>
|
||||
@@ -94,11 +110,21 @@
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>${mysql-connector-j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${postgresql.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jdbi</groupId>
|
||||
<artifactId>jdbi3-core</artifactId>
|
||||
<version>${jdbi-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>${flyway.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.liquibase</groupId>
|
||||
<artifactId>liquibase-core</artifactId>
|
||||
@@ -192,6 +218,25 @@
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${testcontainers.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>mysql</artifactId>
|
||||
<version>${testcontainers.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${testcontainers.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/* Rooney
|
||||
Map Name (Map ID)
|
||||
Used to exchange VP for Maple Leaves, and Maple Leaves for rewards.
|
||||
*/
|
||||
|
||||
var itemToUse = 4001126;
|
||||
|
||||
var chairs = [3010000, 3010001, 3010002, 3010003, 3010004, 3010005, 3010006, 3010007, 3010008, 3010009, 3010010, 3010011, 3010012, 3010013, 3010015, 3010016, 3010017, 3010018, 3010019, 3010022, 3010023, 3010024, 3010025, 3010026, 3010028, 3010040, 3010041, 3010043, 3010045, 3010046, 3010047, 3010057, 3010058, 3010060, 3010061, 3010062, 3010063, 3010064, 3010065, 3010066, 3010067, 3010069, 3010071, 3010072, 3010073, 3010080, 3010081, 3010082, 3010083, 3010084, 3010085, 3010097, 3010098, 3010099, 3010101, 3010106, 3010116, 3011000, 3012005, 3012010, 3012011];
|
||||
var scrolls = [2040603, 2044503, 2041024, 2041025, 2044703, 2044603, 2043303, 2040807, 2040806, 2040006, 2040007, 2043103, 2043203, 2043003, 2040506, 2044403, 2040903, 2040709, 2040710, 2040711, 2044303, 2043803, 2040403, 2044103, 2044203, 2044003, 2043703];
|
||||
var weapons = [1302020, 1302030, 1302033, 1302058, 1302064, 1302080, 1312032, 1322054, 1332025, 1332055, 1332056, 1372034, 1382009, 1382012, 1382039, 1402039, 1412011, 1412027, 1422014, 1422029, 1432012, 1432040, 1432046, 1442024, 1442030, 1442051, 1452016, 1452022, 1452045, 1462014, 1462019, 1462040, 1472030, 1472032, 1472055, 1482020, 1482021, 1482022, 1492020, 1492021, 1492022, 1092030, 1092045, 1092046, 1092047];
|
||||
|
||||
var nxAmount = 3000;
|
||||
var chairAmount = 2;
|
||||
var weaponAmount = 2;
|
||||
var buffAmount = 2;
|
||||
var hiredMerchantLength = 7;
|
||||
|
||||
var buff1ID = 2022273;
|
||||
var buff2ID = 2022179;
|
||||
var status;
|
||||
var vp;
|
||||
var choice;
|
||||
|
||||
function start() {
|
||||
//vp = cm.getClient().getVotePoints();
|
||||
//if(vp == null)
|
||||
vp = 0;
|
||||
|
||||
status = -1;
|
||||
action(1, 0, 0);
|
||||
}
|
||||
|
||||
function action(mode, type, selection) {
|
||||
if (mode < 0) {
|
||||
cm.dispose();
|
||||
} else {
|
||||
if (mode == 1) {
|
||||
status++;
|
||||
} else {
|
||||
status--;
|
||||
}
|
||||
if (status == 0 && mode == 1) {
|
||||
if (cm.getPlayer().getLevel() < 20) {
|
||||
cm.sendOk("Hello, I am the Vote Point exchanger for #rMapleSolaxia#k!\r\n\r\nI am sorry, but I can only exchange Vote Points for players #blevel 20 or over#k.");
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
var outStr = "Hello, I am the Vote Point exchanger for #rMapleSolaxia#k!\r\n";
|
||||
outStr += "You currently have #r#c" + itemToUse + "##k #t" + itemToUse + "# and #r" + vp + "#k Vote Points.#b\r\n\r\n";
|
||||
outStr += "#L0#I would like to exchange my vote points for Maple Leaves#l\r\n";
|
||||
outStr += "#L1#I would like to exchange 1 #t" + itemToUse + "# for " + nxAmount + " NX Cash#l\r\n";
|
||||
outStr += "#L2#I would like to exchange 1 #t" + itemToUse + "# for " + chairAmount + " Random Chair" + (chairAmount > 1 ? "s" : "") + "#l\r\n";
|
||||
outStr += "#L3#I would like to exchange 1 #t" + itemToUse + "# for " + weaponAmount + " Maple Weapons#l\r\n";
|
||||
outStr += "#L4#I would like to exchange 1 #t" + itemToUse + "# for " + buffAmount + " #t" + buff1ID + "#s and " + buffAmount + " #t" + buff2ID + "#s#l\r\n";
|
||||
outStr += "#L5#I would like to exchange 1 #t" + itemToUse + "# for a " + hiredMerchantLength + " Day Hired Merchant#l\r\n";
|
||||
cm.sendSimple(outStr);
|
||||
} else if (status == 1) {
|
||||
choice = selection;
|
||||
|
||||
if (selection > 0) {
|
||||
if (!cm.haveItem(itemToUse) && vp == 0) {
|
||||
cm.sendOk("I'm sorry, but you don't have any #t" + itemToUse + " or Vote Points.");
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (selection == 0) {
|
||||
// Exchange VP for leaves
|
||||
if (vp <= 0) {
|
||||
cm.sendOk("I'm sorry, but you don't have any Vote Points to exchange!");
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
cm.sendYesNo("Would you like to exchange " + vp + " Vote Point" + (vp > 0 ? "s" : "") + " for " + vp + " #t" + itemToUse + "# " + (vp > 0 ? "s" : "") + "?");
|
||||
} else if (selection == 1) {
|
||||
// Exchange 1 Leaf for Cash
|
||||
cm.sendYesNo("Would you like to exchange 1 #t" + itemToUse + "# for " + nxAmount + " NX Cash?");
|
||||
} else if (selection == 2) {
|
||||
// Exchange 1 Leaf for Chair
|
||||
cm.sendYesNo("Would you like to exchange 1 #t" + itemToUse + "# for " + chairAmount + " Random Chair" + (chairAmount > 1 ? "s" : "") + "?");
|
||||
} else if (selection == 3) {
|
||||
// Exchange 1 Leaf for Maple Weapons
|
||||
cm.sendYesNo("Would you like to exchange 1 #t" + itemToUse + "# for " + weaponAmount + " Random Maple Weapons?");
|
||||
} else if (selection == 4) {
|
||||
// Exchange 1 Leaf for Apples/Cheese
|
||||
cm.sendYesNo("Would you like to exchange 1 #t" + itemToUse + "# for " + buffAmount + " #t" + buff1ID + "# and #t" + buff2ID + "#?");
|
||||
} else if (selection == 5) {
|
||||
// Echange 1 Leaf for Merchant
|
||||
cm.sendYesNo("Would you like to exchange 1 #t" + itemToUse + "# for a " + hiredMerchantLength + " Day Hired Merchant?");
|
||||
} else {
|
||||
cm.dispose();
|
||||
}
|
||||
} else if (status == 2) {
|
||||
var useVP = false;
|
||||
if (!cm.hasItem(itemToUse) && vp > 0) {
|
||||
useVP = true;
|
||||
}
|
||||
|
||||
const InventoryType = Java.type('client.inventory.InventoryType');
|
||||
if (choice == 0) {
|
||||
// VP Exchange
|
||||
if (!cm.canHold(itemToUse)) {
|
||||
cm.sendOk("It looks like you don't have enough space in your #rETC#k inventory to hold the #t" + itemToUse + "#" + (vp > 0 ? "s" : "") + ".");
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
cm.getClient().useVotePoints(vp);
|
||||
cm.gainItem(itemToUse, vp);
|
||||
cm.dispose();
|
||||
} else if (choice == 1) {
|
||||
// Leaf for Cash
|
||||
if (useVP) {
|
||||
cm.getClient().useVotePoints(1);
|
||||
} else {
|
||||
cm.gainItem(itemToUse, -1);
|
||||
}
|
||||
|
||||
cm.getPlayer().getCashShop().gainCash(1, nxAmount);
|
||||
const PacketCreator = Java.type('tools.PacketCreator');
|
||||
cm.getPlayer().sendPacket(PacketCreator.earnTitleMessage("You have earned " + nxAmount + " NX"));
|
||||
cm.logLeaf(nxAmount + " NX");
|
||||
cm.dispose();
|
||||
} else if (choice == 2) {
|
||||
if (!cm.getPlayer().getInventory(InventoryType.SETUP).isFull(chairAmount)) {
|
||||
|
||||
var chairStr = "";
|
||||
for (var i = 0; i < chairAmount; i++) {
|
||||
var chair = chairs[Math.floor(Math.random() * chairs.length)];
|
||||
cm.gainItem(chair, 1, true);
|
||||
chairStr += chair + " ";
|
||||
}
|
||||
|
||||
if (useVP) {
|
||||
cm.getClient().useVotePoints(1);
|
||||
} else {
|
||||
cm.gainItem(itemToUse, -1);
|
||||
}
|
||||
|
||||
cm.logLeaf("Chair ID: " + chairStr);
|
||||
cm.dispose();
|
||||
} else {
|
||||
cm.sendOk("Please make sure you have enough space to hold the items!");
|
||||
}
|
||||
} else if (choice == 3) {
|
||||
if (!cm.getPlayer().getInventory(InventoryType.EQUIP).isFull(weaponAmount)) {
|
||||
|
||||
var weaponStr = "";
|
||||
for (var i = 0; i < weaponAmount; i++) {
|
||||
var weapon = weapons[Math.floor(Math.random() * weapons.length)];
|
||||
cm.gainItem(weapon, 1, true, true);
|
||||
weaponStr += weapon + " ";
|
||||
}
|
||||
|
||||
if (useVP) {
|
||||
cm.getClient().useVotePoints(1);
|
||||
} else {
|
||||
cm.gainItem(itemToUse, -1);
|
||||
}
|
||||
|
||||
cm.logLeaf("Maple Weapon IDs: " + weaponStr);
|
||||
cm.dispose();
|
||||
} else {
|
||||
cm.sendOk("Please make sure you have enough space to hold the items!");
|
||||
}
|
||||
} else if (choice == 4) {
|
||||
if (!cm.getPlayer().getInventory(InventoryType.USE).isFull(2)) {
|
||||
cm.gainItem(buff1ID, buffAmount, true);
|
||||
cm.gainItem(buff2ID, buffAmount, true);
|
||||
cm.gainItem(itemToUse, -1);
|
||||
cm.logLeaf(buffAmount + " cheeses and apples");
|
||||
cm.dispose();
|
||||
} else {
|
||||
cm.sendOk("Please make sure you have enough space to hold the items!");
|
||||
}
|
||||
} else if (choice == 5) {
|
||||
if (!cm.haveItem(5030000, 1)) {
|
||||
if (!cm.getPlayer().getInventory(InventoryType.CASH).isFull(1)) {
|
||||
cm.gainItem(5030000, 1, false, true, 1000 * 60 * 60 * 24 * hiredMerchantLength);
|
||||
|
||||
if (useVP) {
|
||||
cm.getClient().useVotePoints(1);
|
||||
} else {
|
||||
cm.gainItem(itemToUse, -1);
|
||||
}
|
||||
|
||||
cm.logLeaf(hiredMerchantLength + " day hired merchant");
|
||||
cm.dispose();
|
||||
} else {
|
||||
cm.sendOk("Please make sure you have enough space to hold these items!");
|
||||
}
|
||||
} else {
|
||||
cm.sendOk("I can't give you a merchant if you already have one!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cm.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function start() {
|
||||
const ShopFactory = Java.type('server.ShopFactory');
|
||||
ShopFactory.getInstance().getShop(11000).sendShop(cm.getClient());
|
||||
cm.dispose();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
var status = 0;
|
||||
|
||||
function start() {
|
||||
status = -1;
|
||||
action(1, 0, 0);
|
||||
}
|
||||
|
||||
function action(mode, type, selection) {
|
||||
cm.openShopNPC(2100002);
|
||||
cm.dispose();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
var status = 0;
|
||||
|
||||
function start() {
|
||||
status = -1;
|
||||
action(1, 0, 0);
|
||||
}
|
||||
|
||||
function action(mode, type, selection) {
|
||||
cm.openShopNPC(2100003);
|
||||
cm.dispose();
|
||||
}
|
||||
@@ -1,14 +1,88 @@
|
||||
/**
|
||||
*9201098 - Mo
|
||||
*@author Ronan
|
||||
* 9201098 - Mo
|
||||
* @author Ronan
|
||||
* @author Ponk
|
||||
*/
|
||||
|
||||
let status = 0;
|
||||
let selectedItem = undefined;
|
||||
|
||||
/*
|
||||
References:
|
||||
- https://www.youtube.com/watch?v=g6y2zmCGglI
|
||||
- https://www.youtube.com/watch?v=CttmlVWLJKM
|
||||
*/
|
||||
function start() {
|
||||
if (cm.getQuestStatus(8224) == 2) {
|
||||
cm.openShopNPC(9201099);
|
||||
} else {
|
||||
cm.sendOk("Hm, at who do you think you are looking at?");
|
||||
if (cm.getQuestStatus(8224) !== 2) {
|
||||
cm.sendDefault();
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
cm.dispose();
|
||||
cm.sendSimple("Name's Mo. I've got Mo' items for Mo' mesos. What business do you bring me?\r\n#L0##bI'd like to buy some items#k");
|
||||
}
|
||||
|
||||
function action(action, type, selection) {
|
||||
if (!action) {
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
if (status === 0) {
|
||||
let index = 0;
|
||||
const selections = "#e" + shopItems()
|
||||
.map(i => {
|
||||
const mesoText = i.quantity === 1 ? "meso" : `meso per ${i.quantity} arrows`;
|
||||
return `\r\n#L${index++}##i${i.itemId}# #z${i.itemId}# #b${i.cost} ${mesoText}#k`;
|
||||
})
|
||||
.join("");
|
||||
cm.sendSimple("An ally of the Raven Ninja Clan is welcome to buy from me!" + selections);
|
||||
status++;
|
||||
} else if (status === 1 && selection !== -1) {
|
||||
selectedItem = shopItems()[selection];
|
||||
cm.sendAcceptDecline("Are you sure you want to buy it?");
|
||||
status++;
|
||||
} else if (status === 2) {
|
||||
if (!selectedItem) {
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
if (!cm.hasMeso(selectedItem.cost)) {
|
||||
cm.sendOk("You don't have enough mesos.");
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
if (!cm.canHold(selectedItem.itemId, selectedItem.quantity)) {
|
||||
cm.sendOk("There's no room in your inventory.");
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
cm.loseMeso(selectedItem.cost);
|
||||
cm.gainItem(selectedItem.itemId, selectedItem.quantity);
|
||||
cm.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
function shopItems() {
|
||||
return [
|
||||
{itemId: 2050004, quantity: 1, cost: 400}, // All-Cure Potion
|
||||
{itemId: 2050000, quantity: 1, cost: 200}, // Antidote
|
||||
{itemId: 2020012, quantity: 1, cost: 4500}, // Melting Cheese
|
||||
{itemId: 2020013, quantity: 1, cost: 5000}, // Reindeer Milk
|
||||
{itemId: 2020014, quantity: 1, cost: 8100}, // Sunrise Dew
|
||||
{itemId: 2020015, quantity: 1, cost: 9690}, // Sunset Dew
|
||||
{itemId: 2050001, quantity: 1, cost: 200}, // Eyedrop
|
||||
{itemId: 2050002, quantity: 1, cost: 300}, // Tonic
|
||||
{itemId: 2050003, quantity: 1, cost: 500}, // Holy Water
|
||||
{itemId: 2022000, quantity: 1, cost: 1650}, // Pure Water
|
||||
{itemId: 2002017, quantity: 1, cost: 5000}, // Warrior Elixir
|
||||
{itemId: 2060004, quantity: 2000, cost: 40_000}, // Diamond Arrow for Bow
|
||||
{itemId: 2061004, quantity: 2000, cost: 40_000}, // Diamond Arrow for Crossbow
|
||||
{itemId: 2070010, quantity: 1, cost: 2000}, // Icicle
|
||||
{itemId: 2022003, quantity: 1, cost: 1100}, // Unagi
|
||||
{itemId: 2000006, quantity: 1, cost: 620}, // Mana Elixir
|
||||
{itemId: 2022002, quantity: 1, cost: 1000}, // Cider
|
||||
{itemId: 2030020, quantity: 1, cost: 400}, // Return to New Leaf City Scroll
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ var staff_heading = "!";
|
||||
var levels = ["Common", "Donator", "JrGM", "GM", "SuperGM", "Developer", "Admin"];
|
||||
var commands;
|
||||
|
||||
// Expectation: "ce" bound to an instance of java.client.command.CommandsExecutor
|
||||
function writeHeavenMSCommands() {
|
||||
const CommandsExecutor = Java.type('client.command.CommandsExecutor');
|
||||
commands = CommandsExecutor.getInstance().getGmCommands();
|
||||
commands = ce.getGmCommands();
|
||||
}
|
||||
|
||||
function start() {
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class AbstractCharacterObject extends AbstractAnimatedMapObject
|
||||
protected MapleMap map;
|
||||
protected int str, dex, luk, int_, hp, maxhp, mp, maxmp;
|
||||
protected int hpMpApUsed, remainingAp;
|
||||
protected int[] remainingSp = new int[10];
|
||||
protected int[] remainingSp = new int[10]; // TODO: change to a simple int. Evan is not in v83, so why support it?
|
||||
protected transient int clientmaxhp, clientmaxmp, localmaxhp = 50, localmaxmp = 5;
|
||||
protected float transienthp = Float.NEGATIVE_INFINITY, transientmp = Float.NEGATIVE_INFINITY;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package client;
|
||||
|
||||
import model.CharacterIdentity;
|
||||
import net.packet.Packet;
|
||||
import net.server.PlayerStorage;
|
||||
import tools.DatabaseConnection;
|
||||
@@ -48,7 +49,7 @@ public class BuddyList {
|
||||
|
||||
private final Map<Integer, BuddylistEntry> buddies = new LinkedHashMap<>();
|
||||
private int capacity;
|
||||
private final Deque<CharacterNameAndId> pendingRequests = new LinkedList<>();
|
||||
private final Deque<CharacterIdentity> pendingRequests = new LinkedList<>();
|
||||
|
||||
public BuddyList(int capacity) {
|
||||
this.capacity = capacity;
|
||||
@@ -150,7 +151,7 @@ public class BuddyList {
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
if (rs.getInt("pending") == 1) {
|
||||
pendingRequests.push(new CharacterNameAndId(rs.getInt("buddyid"), rs.getString("buddyname")));
|
||||
pendingRequests.push(new CharacterIdentity(rs.getString("buddyname"), rs.getInt("buddyid")));
|
||||
} else {
|
||||
put(new BuddylistEntry(rs.getString("buddyname"), rs.getString("group"), rs.getInt("buddyid"), (byte) -1, true));
|
||||
}
|
||||
@@ -167,7 +168,7 @@ public class BuddyList {
|
||||
}
|
||||
}
|
||||
|
||||
public CharacterNameAndId pollPendingRequest() {
|
||||
public CharacterIdentity pollPendingRequest() {
|
||||
return pendingRequests.pollLast();
|
||||
}
|
||||
|
||||
@@ -176,7 +177,7 @@ public class BuddyList {
|
||||
if (pendingRequests.isEmpty()) {
|
||||
c.sendPacket(PacketCreator.requestBuddylistAdd(cidFrom, c.getPlayer().getId(), nameFrom));
|
||||
} else {
|
||||
pendingRequests.push(new CharacterNameAndId(cidFrom, nameFrom));
|
||||
pendingRequests.push(new CharacterIdentity(nameFrom, cidFrom));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
66
src/main/java/client/CharacterStats.java
Normal file
66
src/main/java/client/CharacterStats.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package client;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
@Builder
|
||||
public record CharacterStats(
|
||||
int account,
|
||||
int world,
|
||||
String name,
|
||||
int id,
|
||||
int level,
|
||||
int fame,
|
||||
int str,
|
||||
int dex,
|
||||
int luk,
|
||||
int int_,
|
||||
int exp,
|
||||
int gachaExp,
|
||||
int hp,
|
||||
int mp,
|
||||
int maxHp,
|
||||
int maxMp,
|
||||
int sp,
|
||||
int ap,
|
||||
int gmLevel,
|
||||
int skin,
|
||||
int gender,
|
||||
int job,
|
||||
int hair,
|
||||
int face,
|
||||
int mapId,
|
||||
int meso,
|
||||
int hpMpApUsed,
|
||||
int spawnPortal,
|
||||
Integer party,
|
||||
int buddyCapacity,
|
||||
Integer messenger,
|
||||
Integer messengerPosition,
|
||||
Integer mountLevel,
|
||||
Integer mountExp,
|
||||
Integer mountTiredness,
|
||||
int equipSlots,
|
||||
int useSlots,
|
||||
int setupSlots,
|
||||
int etcSlots,
|
||||
Integer monsterBookCover,
|
||||
Integer dojoVanquisherStage,
|
||||
int dojoPoints,
|
||||
Integer dojoStage,
|
||||
boolean dojoTutorialComplete,
|
||||
int dojoVanquisherKills,
|
||||
int matchCardWins,
|
||||
int matchCardLosses,
|
||||
int matchCardTies,
|
||||
int omokWins,
|
||||
int omokLosses,
|
||||
int omokTies,
|
||||
String dataString,
|
||||
Long jailExpiration,
|
||||
Integer partnerId,
|
||||
Integer marriageItemId,
|
||||
Long lastExpGainTime,
|
||||
int ariantPoints,
|
||||
boolean canRecvPartySearchInvite
|
||||
) {
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
10
src/main/java/client/Gender.java
Normal file
10
src/main/java/client/Gender.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package client;
|
||||
|
||||
/**
|
||||
* @author Ponk
|
||||
*/
|
||||
public class Gender {
|
||||
public static final byte MALE = 0;
|
||||
public static final byte FEMALE = 1;
|
||||
public static final byte NOT_SET = 10;
|
||||
}
|
||||
29
src/main/java/client/LoginState.java
Normal file
29
src/main/java/client/LoginState.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author Ponk
|
||||
*/
|
||||
public enum LoginState {
|
||||
LOGGED_OUT(0),
|
||||
SERVER_TRANSITION(1),
|
||||
LOGGED_IN(2);
|
||||
|
||||
private final byte value;
|
||||
|
||||
LoginState(int value) {
|
||||
this.value = (byte) value;
|
||||
}
|
||||
|
||||
public byte getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Optional<LoginState> fromValue(int value) {
|
||||
return Arrays.stream(values())
|
||||
.filter(v -> v.getValue() == value)
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
@@ -1,225 +1,110 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package client;
|
||||
|
||||
import tools.DatabaseConnection;
|
||||
import database.monsterbook.MonsterCard;
|
||||
import net.jcip.annotations.ThreadSafe;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class MonsterBook {
|
||||
private int specialCard = 0;
|
||||
private int normalCard = 0;
|
||||
private int bookLevel = 1;
|
||||
private final Map<Integer, Integer> cards = new LinkedHashMap<>();
|
||||
private final Lock lock = new ReentrantLock();
|
||||
// TODO: add tests
|
||||
@ThreadSafe
|
||||
public class MonsterBook {
|
||||
private final Map<Integer, MonsterCard> cards;
|
||||
private int bookLevel;
|
||||
|
||||
public Set<Entry<Integer, Integer>> getCardSet() {
|
||||
lock.lock();
|
||||
try {
|
||||
return new HashSet<>(cards.entrySet());
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
public MonsterBook(List<MonsterCard> monsterCards) {
|
||||
this.cards = monsterCards.stream()
|
||||
.collect(Collectors.toMap(MonsterCard::cardId, Function.identity()));
|
||||
}
|
||||
|
||||
public void addCard(final Client c, final int cardid) {
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), PacketCreator.showForeignCardEffect(c.getPlayer().getId()), false);
|
||||
public synchronized List<MonsterCard> getCards() {
|
||||
return new ArrayList<>(cards.values());
|
||||
}
|
||||
|
||||
Integer qty;
|
||||
lock.lock();
|
||||
try {
|
||||
qty = cards.get(cardid);
|
||||
|
||||
if (qty != null) {
|
||||
if (qty < 5) {
|
||||
cards.put(cardid, qty + 1);
|
||||
}
|
||||
} else {
|
||||
cards.put(cardid, 1);
|
||||
qty = 0;
|
||||
|
||||
if (cardid / 1000 >= 2388) {
|
||||
specialCard++;
|
||||
} else {
|
||||
normalCard++;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
public synchronized void addCard(int cardId, Client client) {
|
||||
var monsterCard = cards.get(cardId);
|
||||
if (monsterCard != null && monsterCard.isMaxLevel()) {
|
||||
client.sendPacket(PacketCreator.addMonsterCardAlreadyFull());
|
||||
return;
|
||||
}
|
||||
|
||||
if (qty < 5) {
|
||||
if (qty == 0) { // leveling system only accounts unique cards
|
||||
calculateLevel();
|
||||
}
|
||||
|
||||
c.sendPacket(PacketCreator.addCard(false, cardid, qty + 1));
|
||||
c.sendPacket(PacketCreator.showGainCard());
|
||||
boolean isNewCard = monsterCard == null;
|
||||
final MonsterCard card;
|
||||
if (isNewCard) {
|
||||
card = new MonsterCard(cardId, (byte) 1);
|
||||
cards.put(cardId, card);
|
||||
calculateAndSetLevel();
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.addCard(true, cardid, 5));
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateLevel() {
|
||||
lock.lock();
|
||||
try {
|
||||
int collectionExp = (normalCard + specialCard);
|
||||
|
||||
int level = 0, expToNextlevel = 1;
|
||||
do {
|
||||
level++;
|
||||
expToNextlevel += level * 10;
|
||||
} while (collectionExp >= expToNextlevel);
|
||||
|
||||
bookLevel = level; // thanks IxianMace for noticing book level differing between book UI and character info UI
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public int getBookLevel() {
|
||||
lock.lock();
|
||||
try {
|
||||
return bookLevel;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getCards() {
|
||||
lock.lock();
|
||||
try {
|
||||
return Collections.unmodifiableMap(cards);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public int getTotalCards() {
|
||||
lock.lock();
|
||||
try {
|
||||
return specialCard + normalCard;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public int getNormalCard() {
|
||||
lock.lock();
|
||||
try {
|
||||
return normalCard;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public int getSpecialCard() {
|
||||
lock.lock();
|
||||
try {
|
||||
return specialCard;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCards(final int charid) throws SQLException {
|
||||
lock.lock();
|
||||
try (Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT cardid, level FROM monsterbook WHERE charid = ? ORDER BY cardid ASC")) {
|
||||
ps.setInt(1, charid);
|
||||
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
int cardid;
|
||||
int level;
|
||||
while (rs.next()) {
|
||||
cardid = rs.getInt("cardid");
|
||||
level = rs.getInt("level");
|
||||
if (cardid / 1000 >= 2388) {
|
||||
specialCard++;
|
||||
} else {
|
||||
normalCard++;
|
||||
}
|
||||
cards.put(cardid, level);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
card = new MonsterCard(cardId, (byte) (monsterCard.level() + 1));
|
||||
cards.put(cardId, card);
|
||||
}
|
||||
|
||||
calculateLevel();
|
||||
var chr = client.getPlayer();
|
||||
chr.sendPacket(PacketCreator.addMonsterCard(card));
|
||||
chr.sendPacket(PacketCreator.showMonsterCardEffect());
|
||||
chr.getMap().broadcastMessage(chr, PacketCreator.showForeignMonsterCardEffect(chr.getId()), false);
|
||||
}
|
||||
|
||||
public void saveCards(Connection con, int chrId) throws SQLException {
|
||||
private synchronized void calculateAndSetLevel() {
|
||||
int collectionExp = getTotalCards();
|
||||
|
||||
int level = 0;
|
||||
int expToNextLevel = 1;
|
||||
do {
|
||||
level++;
|
||||
expToNextLevel += level * 10;
|
||||
} while (collectionExp >= expToNextLevel);
|
||||
|
||||
this.bookLevel = level;
|
||||
}
|
||||
|
||||
public synchronized int getBookLevel() {
|
||||
return bookLevel;
|
||||
}
|
||||
|
||||
public synchronized int getNormalCards() {
|
||||
return (int) cards.values().stream()
|
||||
.filter(Predicate.not(MonsterCard::isSpecial))
|
||||
.count();
|
||||
}
|
||||
|
||||
public synchronized int getSpecialCards() {
|
||||
return (int) cards.values().stream()
|
||||
.filter(MonsterCard::isSpecial)
|
||||
.count();
|
||||
}
|
||||
|
||||
public synchronized int getTotalCards() {
|
||||
return cards.size();
|
||||
}
|
||||
|
||||
public synchronized void saveCards(Connection con, int chrId) throws SQLException {
|
||||
final String query = """
|
||||
INSERT INTO monsterbook (charid, cardid, level)
|
||||
VALUES (?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE level = ?;
|
||||
""";
|
||||
try (final PreparedStatement ps = con.prepareStatement(query)) {
|
||||
for (Map.Entry<Integer, Integer> cardAndLevel : cards.entrySet()) {
|
||||
final int card = cardAndLevel.getKey();
|
||||
final int level = cardAndLevel.getValue();
|
||||
for (MonsterCard card : cards.values()) {
|
||||
// insert
|
||||
ps.setInt(1, chrId);
|
||||
ps.setInt(2, card);
|
||||
ps.setInt(3, level);
|
||||
ps.setInt(2, card.cardId());
|
||||
ps.setInt(3, card.level());
|
||||
|
||||
// update
|
||||
ps.setInt(4, level);
|
||||
ps.setInt(4, card.level());
|
||||
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
}
|
||||
}
|
||||
|
||||
public static int[] getCardTierSize() {
|
||||
try (Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) FROM monstercarddata GROUP BY floor(cardid / 1000);", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ResultSet rs = ps.executeQuery()) {
|
||||
rs.last();
|
||||
int[] tierSizes = new int[rs.getRow()];
|
||||
rs.beforeFirst();
|
||||
|
||||
while (rs.next()) {
|
||||
tierSizes[rs.getRow() - 1] = rs.getInt(1);
|
||||
}
|
||||
|
||||
return tierSizes;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +88,6 @@ public enum AutobanFactory {
|
||||
return expiretime;
|
||||
}
|
||||
|
||||
public void addPoint(AutobanManager ban, String reason) {
|
||||
ban.addPoint(this, reason);
|
||||
}
|
||||
|
||||
public void alert(Character chr, String reason) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
if (chr != null && isIgnored(chr.getId())) {
|
||||
@@ -105,13 +101,6 @@ public enum AutobanFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public void autoban(Character chr, String value) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
chr.autoban("Autobanned for (" + this.name() + ": " + value + ")");
|
||||
//chr.sendPolice("You will be disconnected for (" + this.name() + ": " + value + ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle ignored status for a character id.
|
||||
* An ignored character will not trigger GM alerts.
|
||||
|
||||
@@ -7,6 +7,7 @@ package client.autoban;
|
||||
|
||||
import client.Character;
|
||||
import config.YamlConfig;
|
||||
import net.netty.GameViolationException;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -35,35 +36,27 @@ public class AutobanManager {
|
||||
this.chr = chr;
|
||||
}
|
||||
|
||||
public void addPoint(AutobanFactory fac, String reason) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
if (chr.isGM() || chr.isBanned()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastTime.containsKey(fac)) {
|
||||
if (lastTime.get(fac) < (Server.getInstance().getCurrentTime() - fac.getExpire())) {
|
||||
points.put(fac, points.get(fac) / 2); //So the points are not completely gone.
|
||||
}
|
||||
}
|
||||
if (fac.getExpire() != -1) {
|
||||
lastTime.put(fac, Server.getInstance().getCurrentTime());
|
||||
}
|
||||
|
||||
if (points.containsKey(fac)) {
|
||||
points.put(fac, points.get(fac) + 1);
|
||||
} else {
|
||||
points.put(fac, 1);
|
||||
}
|
||||
|
||||
if (points.get(fac) >= fac.getMaximum()) {
|
||||
chr.autoban(reason);
|
||||
/**
|
||||
* @return true if the added point should result in an autoban
|
||||
*/
|
||||
public boolean addPoint(AutobanFactory fac) {
|
||||
if (lastTime.containsKey(fac)) {
|
||||
if (lastTime.get(fac) < (Server.getInstance().getCurrentTime() - fac.getExpire())) {
|
||||
points.put(fac, points.get(fac) / 2); //So the points are not completely gone.
|
||||
}
|
||||
}
|
||||
if (YamlConfig.config.server.USE_AUTOBAN_LOG) {
|
||||
// Lets log every single point too.
|
||||
log.info("Autoban - chr {} caused {} {}", Character.makeMapleReadable(chr.getName()), fac.name(), reason);
|
||||
|
||||
if (fac.getExpire() != -1) {
|
||||
lastTime.put(fac, Server.getInstance().getCurrentTime());
|
||||
}
|
||||
|
||||
if (points.containsKey(fac)) {
|
||||
points.put(fac, points.get(fac) + 1);
|
||||
} else {
|
||||
points.put(fac, 1);
|
||||
}
|
||||
|
||||
return points.get(fac) >= fac.getMaximum();
|
||||
}
|
||||
|
||||
public void addMiss() {
|
||||
@@ -118,11 +111,10 @@ public class AutobanManager {
|
||||
if (this.timestamp[type] == time) {
|
||||
this.timestampcounter[type]++;
|
||||
if (this.timestampcounter[type] >= times) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
chr.getClient().disconnect(false, false);
|
||||
}
|
||||
|
||||
log.info("Autoban - Chr {} was caught spamming TYPE {} and has been disconnected", chr, type);
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
throw new GameViolationException("Auto ban");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.timestamp[type] = time;
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class Command {
|
||||
protected int rank;
|
||||
protected String description;
|
||||
|
||||
public abstract void execute(Client client, String[] params);
|
||||
public abstract void execute(Client client, String[] params, CommandContext ctx);
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
|
||||
19
src/main/java/client/command/CommandContext.java
Normal file
19
src/main/java/client/command/CommandContext.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package client.command;
|
||||
|
||||
import database.character.CharacterSaver;
|
||||
import database.drop.DropProvider;
|
||||
import server.shop.ShopFactory;
|
||||
import service.BanService;
|
||||
import service.TransitionService;
|
||||
|
||||
/**
|
||||
* @author Ponk
|
||||
*/
|
||||
public record CommandContext(CommandsExecutor commandsExecutor, DropProvider dropProvider, ShopFactory shopFactory,
|
||||
CharacterSaver characterSaver, TransitionService transitionService, BanService banService
|
||||
) {
|
||||
|
||||
public CommandContext with(CommandsExecutor ce) {
|
||||
return new CommandContext(ce, dropProvider, shopFactory, characterSaver, transitionService, banService);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@
|
||||
package client.command;
|
||||
|
||||
import client.Client;
|
||||
import client.command.commands.gm0.ChangeLanguageCommand;
|
||||
import client.command.commands.gm0.DisposeCommand;
|
||||
import client.command.commands.gm0.DropLimitCommand;
|
||||
import client.command.commands.gm0.EnableAuthCommand;
|
||||
@@ -38,7 +37,6 @@ import client.command.commands.gm0.MapOwnerClaimCommand;
|
||||
import client.command.commands.gm0.OnlineCommand;
|
||||
import client.command.commands.gm0.RanksCommand;
|
||||
import client.command.commands.gm0.RatesCommand;
|
||||
import client.command.commands.gm0.ReadPointsCommand;
|
||||
import client.command.commands.gm0.ReportBugCommand;
|
||||
import client.command.commands.gm0.ShowRatesCommand;
|
||||
import client.command.commands.gm0.StaffCommand;
|
||||
@@ -106,8 +104,6 @@ import client.command.commands.gm3.FameCommand;
|
||||
import client.command.commands.gm3.FlyCommand;
|
||||
import client.command.commands.gm3.GiveMesosCommand;
|
||||
import client.command.commands.gm3.GiveNxCommand;
|
||||
import client.command.commands.gm3.GiveRpCommand;
|
||||
import client.command.commands.gm3.GiveVpCommand;
|
||||
import client.command.commands.gm3.HairCommand;
|
||||
import client.command.commands.gm3.HealMapCommand;
|
||||
import client.command.commands.gm3.HealPersonCommand;
|
||||
@@ -189,15 +185,10 @@ import client.command.commands.gm6.EraseAllPNpcsCommand;
|
||||
import client.command.commands.gm6.GetAccCommand;
|
||||
import client.command.commands.gm6.MapPlayersCommand;
|
||||
import client.command.commands.gm6.SaveAllCommand;
|
||||
import client.command.commands.gm6.ServerAddChannelCommand;
|
||||
import client.command.commands.gm6.ServerAddWorldCommand;
|
||||
import client.command.commands.gm6.ServerRemoveChannelCommand;
|
||||
import client.command.commands.gm6.ServerRemoveWorldCommand;
|
||||
import client.command.commands.gm6.SetGmLevelCommand;
|
||||
import client.command.commands.gm6.ShutdownCommand;
|
||||
import client.command.commands.gm6.SpawnAllPNpcsCommand;
|
||||
import client.command.commands.gm6.SupplyRateCouponCommand;
|
||||
import client.command.commands.gm6.WarpWorldCommand;
|
||||
import constants.id.MapId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -210,16 +201,27 @@ import java.util.List;
|
||||
|
||||
public class CommandsExecutor {
|
||||
private static final Logger log = LoggerFactory.getLogger(CommandsExecutor.class);
|
||||
private static final CommandsExecutor instance = new CommandsExecutor();
|
||||
private static final char USER_HEADING = '@';
|
||||
private static final char GM_HEADING = '!';
|
||||
|
||||
private final HashMap<String, Command> registeredCommands = new HashMap<>();
|
||||
private final List<Pair<List<String>, List<String>>> commandsNameDesc = new ArrayList<>();
|
||||
private final CommandContext commandContext;
|
||||
private Pair<List<String>, List<String>> levelCommandsCursor;
|
||||
|
||||
public static CommandsExecutor getInstance() {
|
||||
return instance;
|
||||
public CommandsExecutor(CommandContext commandContext) {
|
||||
this.commandContext = commandContext.with(this);
|
||||
registerCommands();
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
registerLv0Commands();
|
||||
registerLv1Commands();
|
||||
registerLv2Commands();
|
||||
registerLv3Commands();
|
||||
registerLv4Commands();
|
||||
registerLv5Commands();
|
||||
registerLv6Commands();
|
||||
}
|
||||
|
||||
public static boolean isCommand(Client client, String content) {
|
||||
@@ -230,16 +232,6 @@ public class CommandsExecutor {
|
||||
return heading == USER_HEADING;
|
||||
}
|
||||
|
||||
private CommandsExecutor() {
|
||||
registerLv0Commands();
|
||||
registerLv1Commands();
|
||||
registerLv2Commands();
|
||||
registerLv3Commands();
|
||||
registerLv4Commands();
|
||||
registerLv5Commands();
|
||||
registerLv6Commands();
|
||||
}
|
||||
|
||||
public List<Pair<List<String>, List<String>>> getGmCommands() {
|
||||
return commandsNameDesc;
|
||||
}
|
||||
@@ -287,7 +279,7 @@ public class CommandsExecutor {
|
||||
params = new String[]{};
|
||||
}
|
||||
|
||||
command.execute(client, params);
|
||||
command.execute(client, params, commandContext);
|
||||
log.info("Chr {} used command {}", client.getPlayer().getName(), command.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@@ -347,14 +339,12 @@ public class CommandsExecutor {
|
||||
addCommand("uptime", UptimeCommand.class);
|
||||
addCommand("gacha", GachaCommand.class);
|
||||
addCommand("dispose", DisposeCommand.class);
|
||||
addCommand("changel", ChangeLanguageCommand.class);
|
||||
addCommand("equiplv", EquipLvCommand.class);
|
||||
addCommand("showrates", ShowRatesCommand.class);
|
||||
addCommand("rates", RatesCommand.class);
|
||||
addCommand("online", OnlineCommand.class);
|
||||
addCommand("gm", GmCommand.class);
|
||||
addCommand("reportbug", ReportBugCommand.class);
|
||||
addCommand("points", ReadPointsCommand.class);
|
||||
addCommand("joinevent", JoinEventCommand.class);
|
||||
addCommand("leaveevent", LeaveEventCommand.class);
|
||||
addCommand("ranks", RanksCommand.class);
|
||||
@@ -454,9 +444,7 @@ public class CommandsExecutor {
|
||||
addCommand("togglewhitechat", 3, ChatCommand.class);
|
||||
addCommand("fame", 3, FameCommand.class);
|
||||
addCommand("givenx", 3, GiveNxCommand.class);
|
||||
addCommand("givevp", 3, GiveVpCommand.class);
|
||||
addCommand("givems", 3, GiveMesosCommand.class);
|
||||
addCommand("giverp", 3, GiveRpCommand.class);
|
||||
addCommand("expeds", 3, ExpedsCommand.class);
|
||||
addCommand("kill", 3, KillCommand.class);
|
||||
addCommand("seed", 3, SeedCommand.class);
|
||||
@@ -542,7 +530,6 @@ public class CommandsExecutor {
|
||||
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
|
||||
|
||||
addCommand("setgmlevel", 6, SetGmLevelCommand.class);
|
||||
addCommand("warpworld", 6, WarpWorldCommand.class);
|
||||
addCommand("saveall", 6, SaveAllCommand.class);
|
||||
addCommand("dcall", 6, DCAllCommand.class);
|
||||
addCommand("mapplayers", 6, MapPlayersCommand.class);
|
||||
@@ -553,10 +540,6 @@ public class CommandsExecutor {
|
||||
addCommand("supplyratecoupon", 6, SupplyRateCouponCommand.class);
|
||||
addCommand("spawnallpnpcs", 6, SpawnAllPNpcsCommand.class);
|
||||
addCommand("eraseallpnpcs", 6, EraseAllPNpcsCommand.class);
|
||||
addCommand("addchannel", 6, ServerAddChannelCommand.class);
|
||||
addCommand("addworld", 6, ServerAddWorldCommand.class);
|
||||
addCommand("removechannel", 6, ServerRemoveChannelCommand.class);
|
||||
addCommand("removeworld", 6, ServerRemoveWorldCommand.class);
|
||||
addCommand("devtest", 6, DevtestCommand.class);
|
||||
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server, commands OdinMS-based
|
||||
Copyleft (L) 2016 - 2019 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
@Author: Arthur L - Refactored command content into modules
|
||||
*/
|
||||
package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
|
||||
public class ChangeLanguageCommand extends Command {
|
||||
{
|
||||
setDescription("Change language settings.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
if (params.length < 1) {
|
||||
c.getPlayer().yellowMessage("Syntax: !changel <0=ptb, 1=esp, 2=eng>");
|
||||
return;
|
||||
}
|
||||
c.setLanguage(Integer.parseInt(params[0]));
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import scripting.npc.NPCScriptManager;
|
||||
import scripting.quest.QuestScriptManager;
|
||||
import tools.PacketCreator;
|
||||
@@ -35,7 +36,7 @@ public class DisposeCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
NPCScriptManager.getInstance().dispose(c);
|
||||
QuestScriptManager.getInstance().dispose(c);
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class DropLimitCommand extends Command {
|
||||
@@ -33,7 +34,7 @@ public class DropLimitCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
int dropCount = c.getPlayer().getMap().getDroppedItemCount();
|
||||
if (((float) dropCount) / YamlConfig.config.server.ITEM_LIMIT_ON_MAP < 0.75f) {
|
||||
c.getPlayer().showHint("Current drop count: #b" + dropCount + "#k / #e" + YamlConfig.config.server.ITEM_LIMIT_ON_MAP + "#n", 300);
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import net.server.coordinator.login.LoginBypassCoordinator;
|
||||
|
||||
public class EnableAuthCommand extends Command {
|
||||
@@ -33,7 +34,7 @@ public class EnableAuthCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
LoginBypassCoordinator.getInstance().unregisterLoginBypassEntry(c.getHwid(), c.getAccID());
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class EquipLvCommand extends Command {
|
||||
{
|
||||
@@ -32,7 +33,7 @@ public class EquipLvCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
c.getPlayer().showAllEquipFeatures();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.NpcId;
|
||||
import server.ItemInformationProvider;
|
||||
import server.gachapon.Gachapon;
|
||||
@@ -35,7 +36,7 @@ public class GachaCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Gachapon.GachaponType gacha = null;
|
||||
String search = c.getPlayer().getLastCommandMessage();
|
||||
String gachaName = "";
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -40,7 +41,7 @@ public class GmCommand extends Command {
|
||||
private static final Logger log = LoggerFactory.getLogger(GmCommand.class);
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
String[] tips = {
|
||||
"Please only use @gm in emergencies or to report somebody.",
|
||||
"To report a bug or make a suggestion, use the forum.",
|
||||
|
||||
@@ -25,15 +25,19 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.NpcId;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class HelpCommand extends Command {
|
||||
{
|
||||
setDescription("Show available commands.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client client, String[] params) {
|
||||
client.getAbstractPlayerInteraction().openNpc(NpcId.STEWARD, "commands");
|
||||
public void execute(Client client, String[] params, CommandContext ctx) {
|
||||
Map<String, Object> bindings = Map.of("ce", ctx.commandsExecutor());
|
||||
client.getAbstractPlayerInteraction().openNpc(NpcId.STEWARD, "commands", bindings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.MapId;
|
||||
import server.events.gm.Event;
|
||||
import server.maps.FieldLimit;
|
||||
@@ -36,7 +37,7 @@ public class JoinEventCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (!FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
|
||||
Event event = c.getChannelServer().getEvent();
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class LeaveEventCommand extends Command {
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class LeaveEventCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
int returnMap = player.getSavedLocation("EVENT");
|
||||
if (returnMap != -1) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
import server.maps.MapleMap;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class MapOwnerClaimCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
Character chr = c.getPlayer();
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class OnlineCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
for (Channel ch : Server.getInstance().getChannelsFromWorld(player.getWorld())) {
|
||||
player.yellowMessage("Players in Channel " + ch.getId() + ":");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.NpcId;
|
||||
import net.server.Server;
|
||||
import net.server.guild.GuildPackets;
|
||||
@@ -39,7 +40,7 @@ public class RanksCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
List<Pair<String, Integer>> worldRanking = Server.getInstance().getWorldPlayerRanking(player.getWorld());
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class RatesCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class RatesCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
// travel rates not applicable since it's intrinsically a server/environment rate rather than a character rate
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package client.command.commands.gm0;
|
||||
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
|
||||
public class ReadPointsCommand extends Command {
|
||||
{
|
||||
setDescription("Show point total.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client client, String[] params) {
|
||||
|
||||
Character player = client.getPlayer();
|
||||
if (params.length > 2) {
|
||||
player.yellowMessage("Syntax: @points (rp|vp|all)");
|
||||
return;
|
||||
} else if (params.length == 0) {
|
||||
player.yellowMessage("RewardPoints: " + player.getRewardPoints() + " | "
|
||||
+ "VotePoints: " + player.getClient().getVotePoints());
|
||||
return;
|
||||
}
|
||||
|
||||
switch (params[0]) {
|
||||
case "rp":
|
||||
player.yellowMessage("RewardPoints: " + player.getRewardPoints());
|
||||
break;
|
||||
case "vp":
|
||||
player.yellowMessage("VotePoints: " + player.getClient().getVotePoints());
|
||||
break;
|
||||
default:
|
||||
player.yellowMessage("RewardPoints: " + player.getRewardPoints() + " | "
|
||||
+ "VotePoints: " + player.getClient().getVotePoints());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import net.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -39,7 +40,7 @@ public class ReportBugCommand extends Command {
|
||||
private static final Logger log = LoggerFactory.getLogger(ReportBugCommand.class);
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
if (params.length < 1) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class ShowRatesCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class ShowRatesCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
String showMsg = "#eEXP RATE#n" + "\r\n";
|
||||
showMsg += "World EXP Rate: #k" + c.getWorldServer().getExpRate() + "x#k" + "\r\n";
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.NpcId;
|
||||
|
||||
public class StaffCommand extends Command {
|
||||
@@ -33,7 +34,7 @@ public class StaffCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
c.getAbstractPlayerInteraction().openNpc(NpcId.HERACLE, "credits");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class StatDexCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class StatDexCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
int remainingAp = player.getRemainingAp();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class StatIntCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class StatIntCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
int remainingAp = player.getRemainingAp();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class StatLukCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class StatLukCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
int remainingAp = player.getRemainingAp();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm0;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class StatStrCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class StatStrCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
int remainingAp = player.getRemainingAp();
|
||||
int amount;
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -37,7 +38,7 @@ public class TimeCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client client, String[] params) {
|
||||
public void execute(Client client, String[] params, CommandContext ctx) {
|
||||
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
dateFormat.setTimeZone(TimeZone.getDefault());
|
||||
client.getPlayer().yellowMessage("Cosmic Server Time: " + dateFormat.format(new Date()));
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class ToggleExpCommand extends Command {
|
||||
{
|
||||
@@ -32,7 +33,7 @@ public class ToggleExpCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
c.getPlayer().toggleExpGain(); // Vcoc's idea
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm0;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import net.server.Server;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
@@ -38,7 +39,7 @@ public class UptimeCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
long milliseconds = System.currentTimeMillis() - Server.uptime;
|
||||
int seconds = (int) (milliseconds / SECONDS.toMillis(1)) % 60;
|
||||
int minutes = (int) ((milliseconds / MINUTES.toMillis(1)) % 60);
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm1;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.life.Monster;
|
||||
|
||||
public class BossHpCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class BossHpCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
for (Monster monster : player.getMap().getAllMonsters()) {
|
||||
if (monster != null && monster.isBoss() && monster.getHp() > 0) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.SkillFactory;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class BuffMeCommand extends Command {
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class BuffMeCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
SkillFactory.getSkill(4101004).getEffect(SkillFactory.getSkill(4101004).getMaxLevel()).applyTo(player);
|
||||
SkillFactory.getSkill(2311003).getEffect(SkillFactory.getSkill(2311003).getMaxLevel()).applyTo(player);
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm1;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.game.GameConstants;
|
||||
import constants.id.NpcId;
|
||||
import server.maps.FieldLimit;
|
||||
@@ -77,7 +78,7 @@ public class GotoCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
String sendStr = "Syntax: #b@goto <map name>#k. Available areas:\r\n\r\n#rTowns:#k\r\n" + GOTO_TOWNS_INFO;
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm1;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.life.Monster;
|
||||
|
||||
public class MobHpCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class MobHpCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
for (Monster monster : player.getMap().getAllMonsters()) {
|
||||
if (monster != null && monster.getHp() > 0) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm1;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.NpcId;
|
||||
import server.ItemInformationProvider;
|
||||
import server.life.MonsterDropEntry;
|
||||
@@ -40,7 +41,7 @@ public class WhatDropsFromCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.dropMessage(5, "Please do @whatdropsfrom <monster name>");
|
||||
@@ -56,7 +57,7 @@ public class WhatDropsFromCommand extends Command {
|
||||
int mobId = data.getLeft();
|
||||
String mobName = data.getRight();
|
||||
output += mobName + " drops the following items:\r\n\r\n";
|
||||
for (MonsterDropEntry drop : MonsterInformationProvider.getInstance().retrieveDrop(mobId)) {
|
||||
for (MonsterDropEntry drop : ctx.dropProvider().getMonsterDropEntries(mobId)) {
|
||||
try {
|
||||
String name = ItemInformationProvider.getInstance().getName(drop.itemId);
|
||||
if (name == null || name.equals("null") || drop.chance == 0) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm1;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.NpcId;
|
||||
import server.ItemInformationProvider;
|
||||
import server.life.MonsterInformationProvider;
|
||||
@@ -43,7 +44,7 @@ public class WhoDropsCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.dropMessage(5, "Please do @whodrops <item name>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class ApCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class ApCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !ap [<playername>] <newap>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.MobId;
|
||||
import net.server.Server;
|
||||
import server.life.LifeFactory;
|
||||
@@ -37,7 +38,7 @@ public class BombCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length > 0) {
|
||||
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
|
||||
@@ -28,6 +28,7 @@ import client.Client;
|
||||
import client.Skill;
|
||||
import client.SkillFactory;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class BuffCommand extends Command {
|
||||
{
|
||||
@@ -35,7 +36,7 @@ public class BuffCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !buff <buffid>");
|
||||
|
||||
@@ -27,6 +27,7 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.SkillFactory;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class BuffMapCommand extends Command {
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class BuffMapCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
SkillFactory.getSkill(9101001).getEffect(SkillFactory.getSkill(9101001).getMaxLevel()).applyTo(player, true);
|
||||
SkillFactory.getSkill(9101002).getEffect(SkillFactory.getSkill(9101002).getMaxLevel()).applyTo(player, true);
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class ClearDropsCommand extends Command {
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class ClearDropsCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
player.getMap().clearDrops(player);
|
||||
player.dropMessage(5, "Cleared dropped items");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.maps.SavedLocationType;
|
||||
|
||||
public class ClearSavedLocationsCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class ClearSavedLocationsCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer(), victim;
|
||||
|
||||
if (params.length > 0) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.manipulator.InventoryManipulator;
|
||||
@@ -36,7 +37,7 @@ public class ClearSlotCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !clearslot <all, equip, use, setup, etc or cash.>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class DcCommand extends Command {
|
||||
{
|
||||
@@ -33,21 +34,22 @@ public class DcCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !dc <playername>");
|
||||
return;
|
||||
}
|
||||
|
||||
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
String chrName = params[0];
|
||||
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(chrName);
|
||||
if (victim == null) {
|
||||
victim = c.getChannelServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
victim = c.getChannelServer().getPlayerStorage().getCharacterByName(chrName);
|
||||
if (victim == null) {
|
||||
victim = player.getMap().getCharacterByName(params[0]);
|
||||
victim = player.getMap().getCharacterByName(chrName);
|
||||
if (victim != null) {
|
||||
try {//sometimes bugged because the map = null
|
||||
victim.getClient().disconnect(true, false);
|
||||
ctx.transitionService().disconnect(victim.getClient(), true);
|
||||
player.getMap().removePlayer(victim);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -60,6 +62,6 @@ public class DcCommand extends Command {
|
||||
if (player.gmLevel() < victim.gmLevel()) {
|
||||
victim = player;
|
||||
}
|
||||
victim.getClient().disconnect(false, false);
|
||||
ctx.transitionService().disconnect(victim.getClient(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.SkillFactory;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class EmpowerMeCommand extends Command {
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class EmpowerMeCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
final int[] array = {2311003, 2301004, 1301007, 4101004, 2001002, 1101007, 1005, 2301003, 5121009, 1111002, 4111001, 4111002, 4211003, 4211005, 1321000, 2321004, 3121002};
|
||||
for (int i : array) {
|
||||
|
||||
@@ -21,6 +21,7 @@ package client.command.commands.gm2;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
/**
|
||||
* @author Ronan
|
||||
@@ -31,7 +32,7 @@ public class GachaListCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
c.getAbstractPlayerInteraction().openNpc(10000, "gachaponInfo");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,15 +25,17 @@ package client.command.commands.gm2;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import server.ShopFactory;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class GmShopCommand extends Command {
|
||||
{
|
||||
setDescription("Open the GM shop.");
|
||||
}
|
||||
|
||||
private static final int GM_SHOP_ID = 1337;
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
ShopFactory.getInstance().getShop(1337).sendShop(c);
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
ctx.shopFactory().getShop(GM_SHOP_ID).ifPresent(shop -> shop.sendShop(c));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class HealCommand extends Command {
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class HealCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
player.healHpMp();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.SkillFactory;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class HideCommand extends Command {
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class HideCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
SkillFactory.getSkill(9101004).getEffect(SkillFactory.getSkill(9101004).getMaxLevel()).applyTo(player);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.game.NpcChat;
|
||||
import constants.id.NpcId;
|
||||
import server.ThreadManager;
|
||||
@@ -86,7 +87,7 @@ public class IdCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client client, final String[] params) {
|
||||
public void execute(Client client, final String[] params, CommandContext ctx) {
|
||||
final Character chr = client.getPlayer();
|
||||
if (params.length < 2) {
|
||||
chr.yellowMessage("Syntax: !id <type> <query>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import client.inventory.Pet;
|
||||
import client.inventory.manipulator.InventoryManipulator;
|
||||
import config.YamlConfig;
|
||||
@@ -40,7 +41,7 @@ public class ItemCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
if (params.length < 1) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.Pet;
|
||||
@@ -41,7 +42,7 @@ public class ItemDropCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
if (params.length < 1) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.MapId;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.Portal;
|
||||
@@ -38,7 +39,7 @@ public class JailCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !jail <playername> [<minutes>]");
|
||||
|
||||
@@ -27,6 +27,7 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.Job;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class JobCommand extends Command {
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class JobCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length == 1) {
|
||||
int jobid = Integer.parseInt(params[0]);
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class LevelCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class LevelCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !level <newlevel>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class LevelProCommand extends Command {
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class LevelProCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !levelpro <newlevel>");
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm2;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.maps.MapItem;
|
||||
import server.maps.MapObject;
|
||||
import server.maps.MapObjectType;
|
||||
@@ -39,7 +40,7 @@ public class LootCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
List<MapObject> items = c.getPlayer().getMap().getMapObjectsInRange(c.getPlayer().getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapObjectType.ITEM));
|
||||
for (MapObject item : items) {
|
||||
MapItem mapItem = (MapItem) item;
|
||||
|
||||
@@ -29,6 +29,7 @@ import client.Job;
|
||||
import client.Skill;
|
||||
import client.SkillFactory;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import provider.Data;
|
||||
import provider.DataProviderFactory;
|
||||
import provider.wz.WZFiles;
|
||||
@@ -39,7 +40,7 @@ public class MaxSkillCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
for (Data skill_ : DataProviderFactory.getDataProvider(WZFiles.STRING).getData("Skill.img").getChildren()) {
|
||||
try {
|
||||
|
||||
@@ -27,6 +27,7 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.Stat;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class MaxStatCommand extends Command {
|
||||
@@ -35,7 +36,7 @@ public class MaxStatCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
player.loseExp(player.getExp(), false, false);
|
||||
player.setLevel(255);
|
||||
|
||||
@@ -3,6 +3,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.life.MobSkill;
|
||||
import server.life.MobSkillFactory;
|
||||
import server.life.MobSkillType;
|
||||
@@ -16,7 +17,7 @@ public class MobSkillCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client client, String[] params) {
|
||||
public void execute(Client client, String[] params, CommandContext ctx) {
|
||||
if (params.length < 2) {
|
||||
throw new IllegalArgumentException("Mob skill command requires two args: mob skill id and level");
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.maps.MapleMap;
|
||||
|
||||
public class ReachCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class ReachCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !reach <playername>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import client.inventory.InventoryType;
|
||||
import client.inventory.Item;
|
||||
import constants.inventory.ItemConstants;
|
||||
@@ -37,7 +38,7 @@ public class RechargeCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
for (Item torecharge : c.getPlayer().getInventory(InventoryType.USE).list()) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import client.Job;
|
||||
import client.Skill;
|
||||
import client.SkillFactory;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import provider.Data;
|
||||
import provider.DataProviderFactory;
|
||||
import provider.wz.WZFiles;
|
||||
@@ -39,7 +40,7 @@ public class ResetSkillCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
for (Data skill_ : DataProviderFactory.getDataProvider(WZFiles.STRING).getData("Skill.img").getChildren()) {
|
||||
try {
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import constants.id.NpcId;
|
||||
import provider.Data;
|
||||
import provider.DataProvider;
|
||||
@@ -53,7 +54,7 @@ public class SearchCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 2) {
|
||||
player.yellowMessage("Syntax: !search <type> <name>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class SetSlotCommand extends Command {
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class SetSlotCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !setslot <newlevel>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class SetStatCommand extends Command {
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class SetStatCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !setstat <newstat>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import config.YamlConfig;
|
||||
|
||||
public class SpCommand extends Command {
|
||||
@@ -34,7 +35,7 @@ public class SpCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !sp [<playername>] <newsp>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
import server.maps.MapleMap;
|
||||
@@ -36,7 +37,7 @@ public class SummonCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !warphere <playername>");
|
||||
@@ -62,7 +63,7 @@ public class SummonCommand extends Command {
|
||||
|
||||
if (player.getClient().getChannel() != victim.getClient().getChannel()) {//And then change channel if needed.
|
||||
victim.dropMessage("Changing channel, please wait a moment.");
|
||||
victim.getClient().changeChannel(player.getClient().getChannel());
|
||||
ctx.transitionService().changeChannel(victim.getClient(), player.getClient().getChannel());
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -25,6 +25,7 @@ package client.command.commands.gm2;
|
||||
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import tools.PacketCreator;
|
||||
|
||||
public class UnBugCommand extends Command {
|
||||
@@ -33,7 +34,7 @@ public class UnBugCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
c.getPlayer().getMap().broadcastMessage(PacketCreator.enableActions());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import client.Character;
|
||||
import client.Client;
|
||||
import client.SkillFactory;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class UnHideCommand extends Command {
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class UnHideCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
SkillFactory.getSkill(9101004).getEffect(SkillFactory.getSkill(9101004).getMaxLevel()).applyTo(player);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class UnJailCommand extends Command {
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class UnJailCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !unjail <playername>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.maps.MapleMap;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -37,7 +38,7 @@ public class WarpAreaCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !warparea <mapid>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.maps.FieldLimit;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MiniDungeonInfo;
|
||||
@@ -36,7 +37,7 @@ public class WarpCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !warp <mapid>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.maps.MapleMap;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -36,7 +37,7 @@ public class WarpMapCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !warpmap <mapid>");
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm2;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
import server.life.Monster;
|
||||
import server.life.NPC;
|
||||
import server.life.PlayerNPC;
|
||||
@@ -39,7 +40,7 @@ public class WhereaMiCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
HashSet<Character> chars = new HashSet<>();
|
||||
|
||||
@@ -26,14 +26,7 @@ package client.command.commands.gm3;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import net.server.Server;
|
||||
import server.TimerManager;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class BanCommand extends Command {
|
||||
{
|
||||
@@ -41,7 +34,7 @@ public class BanCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 2) {
|
||||
player.yellowMessage("Syntax: !ban <IGN> <Reason> (Please be descriptive)");
|
||||
@@ -49,39 +42,6 @@ public class BanCommand extends Command {
|
||||
}
|
||||
String ign = params[0];
|
||||
String reason = joinStringFrom(params, 1);
|
||||
Character target = c.getChannelServer().getPlayerStorage().getCharacterByName(ign);
|
||||
if (target != null) {
|
||||
String readableTargetName = Character.makeMapleReadable(target.getName());
|
||||
String ip = target.getClient().getRemoteAddress();
|
||||
//Ban ip
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
if (ip.matches("/[0-9]{1,3}\\..*")) {
|
||||
try (PreparedStatement ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?, ?)")) {
|
||||
ps.setString(1, ip);
|
||||
ps.setString(2, String.valueOf(target.getClient().getAccID()));
|
||||
|
||||
ps.executeUpdate();
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
c.getPlayer().message("Error occured while banning IP address");
|
||||
c.getPlayer().message(target.getName() + "'s IP was not banned: " + ip);
|
||||
}
|
||||
target.getClient().banMacs();
|
||||
reason = c.getPlayer().getName() + " banned " + readableTargetName + " for " + reason + " (IP: " + ip + ") " + "(MAC: " + c.getMacs() + ")";
|
||||
target.ban(reason);
|
||||
target.yellowMessage("You have been banned by #b" + c.getPlayer().getName() + " #k.");
|
||||
target.yellowMessage("Reason: " + reason);
|
||||
c.sendPacket(PacketCreator.getGMEffect(4, (byte) 0));
|
||||
final Character rip = target;
|
||||
TimerManager.getInstance().schedule(() -> rip.getClient().disconnect(false, false), 5000); //5 Seconds
|
||||
Server.getInstance().broadcastMessage(c.getWorld(), PacketCreator.serverNotice(6, "[RIP]: " + ign + " has been banned."));
|
||||
} else if (Character.ban(ign, reason, false)) {
|
||||
c.sendPacket(PacketCreator.getGMEffect(4, (byte) 0));
|
||||
Server.getInstance().broadcastMessage(c.getWorld(), PacketCreator.serverNotice(6, "[RIP]: " + ign + " has been banned."));
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.getGMEffect(6, (byte) 1));
|
||||
}
|
||||
ctx.banService().permaBan(c, ign, (byte) 0, reason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm3;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class ChatCommand extends Command {
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class ChatCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
player.toggleWhiteChat();
|
||||
player.message("Your chat is now " + (player.getWhiteChat() ? " white" : "normal") + ".");
|
||||
|
||||
@@ -27,6 +27,7 @@ import client.BuffStat;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class CheckDmgCommand extends Command {
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class CheckDmgCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
if (victim != null) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package client.command.commands.gm3;
|
||||
import client.Character;
|
||||
import client.Client;
|
||||
import client.command.Command;
|
||||
import client.command.CommandContext;
|
||||
|
||||
public class ClosePortalCommand extends Command {
|
||||
{
|
||||
@@ -33,7 +34,7 @@ public class ClosePortalCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
public void execute(Client c, String[] params, CommandContext ctx) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !closeportal <portalid>");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user