From cad10c4d5cac9f2eced7980e957ce0a4e1888ca0 Mon Sep 17 00:00:00 2001 From: P0nk Date: Fri, 19 Jul 2024 17:16:14 +0200 Subject: [PATCH] Remove rebirth system --- config.yaml | 2 - scripts/npc/rebirth.js | 79 ------------------- src/main/java/client/Character.java | 65 --------------- src/main/java/config/ServerConfig.java | 2 - .../channel/handlers/NPCTalkHandler.java | 4 +- .../handlers/PlayerLoggedinHandler.java | 5 -- .../tools/exceptions/NotEnabledException.java | 12 --- 7 files changed, 1 insertion(+), 168 deletions(-) delete mode 100644 scripts/npc/rebirth.js delete mode 100644 src/main/java/tools/exceptions/NotEnabledException.java diff --git a/config.yaml b/config.yaml index 5765529882..49c4572dca 100644 --- a/config.yaml +++ b/config.yaml @@ -259,7 +259,6 @@ server: USE_MULTIPLE_SAME_EQUIP_DROP: true #Enables multiple drops by mobs of the same equipment, number of possible drops based on the quantities provided at the drop data. USE_ENABLE_FULL_RESPAWN: false #At respawn task, always respawn missing mobs when they're available. Spawn count doesn't depend on how many players are currently there. USE_ENABLE_CHAT_LOG: false #Write in-game chat to log - USE_REBIRTH_SYSTEM: false #Flag to enable/disable rebirth system USE_MAP_OWNERSHIP_SYSTEM: false #Flag to enable/disable map ownership system USE_FISHING_SYSTEM: false #Flag to enable/disable custom fishing system USE_NPCS_SCRIPTABLE: true #Flag to enable/disable serverside predefined script NPCs. @@ -317,7 +316,6 @@ server: NAME_CHANGE_COOLDOWN: 2592000000 # (30*24*60*60*1000) Cooldown for name changes, default (GMS) is 30 days. WORLD_TRANSFER_COOLDOWN: 2592000000 # (30*24*60*60*1000) Cooldown for world tranfers, default is same as name change (30 days). INSTANT_NAME_CHANGE: false #Whether or not to wait for server restart to apply name changes. Does on reconnect otherwise (requires queries on every login). - REBIRTH_NPC_ID: 9010021 #ID of the NPC that should be replaced with the rebirth mechanic, if enabled. #Dangling Items/Locks Configuration ITEM_EXPIRE_TIME: 180000 # (3 * 60 * 1000) Time before items start disappearing. Recommended to be set up to 3 minutes. diff --git a/scripts/npc/rebirth.js b/scripts/npc/rebirth.js deleted file mode 100644 index 7859407880..0000000000 --- a/scripts/npc/rebirth.js +++ /dev/null @@ -1,79 +0,0 @@ -/* - This file is part of the OdinMS Maple Story Server - Copyright (C) 2008 Patrick Huy - Matthias Butz - Jan Christian Meyer - - 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 . -*/ -/* Rebirth NPC - @author Ronan - @author wejrox -*/ -var status; -var jobId = 0; - -function start() { - status = -1; - const YamlConfig = Java.type('config.YamlConfig'); - if (!YamlConfig.config.server.USE_REBIRTH_SYSTEM) { - cm.sendOk("Rebirths aren't enabled on this server, how did you get here?"); - cm.dispose(); - return; - } - action(1, 0, 0); -} - -function action(mode, type, selection) { - if (mode === 1) { - status++; - } else { - cm.dispose(); - return; - } - if (status === 0) { - cm.sendNext("Come to me when you want to be reborn again. You currently have a total of #r" + cm.getChar().getReborns() + " #krebirths."); - } else if (status === 1) { - cm.sendSimple("What do you want me to do today: \r\n \r\n #L0##bI want to be reborn!#l \r\n #L1##bNothing for now...#k#l"); - } else if (status === 2) { - if (selection === 0) { - if (cm.getChar().getLevel() === cm.getChar().getMaxClassLevel()) { - cm.sendSimple("I see... and which path would you like to take? \r\n\r\n #L0##bExplorer (Beginner)#l \r\n #L1##bCygnus Knight (Noblesse)#l \r\n #L2##bAran (Legend)#l"); - } else { - cm.sendOk("It looks like your journey has not yet ended... come back when you're level " + cm.getChar().getMaxClassLevel()); - cm.dispose(); - } - } else if (selection === 1) { - cm.sendOk("See you soon!") - cm.dispose(); - } - } else if (status === 3) { - // 0 => beginner, 1000 => noblesse, 2000 => legend - // makes this very easy :-) - jobId = selection * 1000; - - var job = ""; - if (selection === 0) job = "Beginner"; - else if (selection === 1) job = "Noblesse"; - else if (selection === 2) job = "Legend"; - cm.sendYesNo("Are you sure you want to be reborn as a " + job + "?"); - } - else if (status === 4 && type === 1) { - cm.getChar().executeRebornAsId(jobId); - cm.sendOk("You have now been reborn. That's a total of #r" + cm.getChar().getReborns() + "#k rebirths"); - cm.dispose(); - } -} \ No newline at end of file diff --git a/src/main/java/client/Character.java b/src/main/java/client/Character.java index 9962b5c822..8a17639625 100644 --- a/src/main/java/client/Character.java +++ b/src/main/java/client/Character.java @@ -154,7 +154,6 @@ import tools.LongTool; import tools.PacketCreator; import tools.Pair; import tools.Randomizer; -import tools.exceptions.NotEnabledException; import tools.packets.WeddingPackets; import java.awt.*; @@ -10962,70 +10961,6 @@ public class Character extends AbstractCharacterObject { } } - public void setReborns(int value) { - if (!YamlConfig.config.server.USE_REBIRTH_SYSTEM) { - yellowMessage("Rebirth system is not enabled!"); - throw new NotEnabledException(); - } - - try (Connection con = DatabaseConnection.getConnection(); - PreparedStatement ps = con.prepareStatement("UPDATE characters SET reborns=? WHERE id=?;")) { - ps.setInt(1, value); - ps.setInt(2, id); - ps.executeUpdate(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - public void addReborns() { - setReborns(getReborns() + 1); - } - - public int getReborns() { - if (!YamlConfig.config.server.USE_REBIRTH_SYSTEM) { - yellowMessage("Rebirth system is not enabled!"); - throw new NotEnabledException(); - } - - try (Connection con = DatabaseConnection.getConnection(); - PreparedStatement ps = con.prepareStatement("SELECT reborns FROM characters WHERE id=?;")) { - ps.setInt(1, id); - - try (ResultSet rs = ps.executeQuery()) { - rs.next(); - return rs.getInt(1); - } - } catch (SQLException e) { - e.printStackTrace(); - } - throw new RuntimeException(); - } - - public void executeReborn() { - // default to beginner: job id = 0 - // this prevents a breaking change - executeRebornAs(Job.BEGINNER); - } - - public void executeRebornAsId(int jobId) { - executeRebornAs(Job.getById(jobId)); - } - - public void executeRebornAs(Job job) { - if (!YamlConfig.config.server.USE_REBIRTH_SYSTEM) { - yellowMessage("Rebirth system is not enabled!"); - throw new NotEnabledException(); - } - if (getLevel() != getMaxClassLevel()) { - return; - } - addReborns(); - changeJob(job); - setLevel(0); - levelUp(true); - } - //EVENTS private byte team = 0; private Fitness fitness; diff --git a/src/main/java/config/ServerConfig.java b/src/main/java/config/ServerConfig.java index f22a9f44fe..3aef4172d9 100644 --- a/src/main/java/config/ServerConfig.java +++ b/src/main/java/config/ServerConfig.java @@ -107,7 +107,6 @@ public class ServerConfig { public boolean USE_MULTIPLE_SAME_EQUIP_DROP; public boolean USE_ENABLE_FULL_RESPAWN; public boolean USE_ENABLE_CHAT_LOG; - public boolean USE_REBIRTH_SYSTEM; public boolean USE_MAP_OWNERSHIP_SYSTEM; public boolean USE_FISHING_SYSTEM; public boolean USE_NPCS_SCRIPTABLE; @@ -165,7 +164,6 @@ public class ServerConfig { public long NAME_CHANGE_COOLDOWN; public long WORLD_TRANSFER_COOLDOWN = NAME_CHANGE_COOLDOWN;//Cooldown for world tranfers, default is same as name change (30 days). public boolean INSTANT_NAME_CHANGE; - public int REBIRTH_NPC_ID; //Dangling Items/Locks Configuration public int ITEM_EXPIRE_TIME; diff --git a/src/main/java/net/server/channel/handlers/NPCTalkHandler.java b/src/main/java/net/server/channel/handlers/NPCTalkHandler.java index 413b925642..e99f633452 100644 --- a/src/main/java/net/server/channel/handlers/NPCTalkHandler.java +++ b/src/main/java/net/server/channel/handlers/NPCTalkHandler.java @@ -70,8 +70,6 @@ public final class NPCTalkHandler extends AbstractPacketHandler { NPCScriptManager.getInstance().start(c, npc.getId(), "gachapon", null); } else if (npc.getName().endsWith("Maple TV")) { NPCScriptManager.getInstance().start(c, npc.getId(), "mapleTV", null); - } else if (YamlConfig.config.server.USE_REBIRTH_SYSTEM && npc.getId() == YamlConfig.config.server.REBIRTH_NPC_ID) { - NPCScriptManager.getInstance().start(c, npc.getId(), "rebirth", null); } else { boolean hasNpcScript = NPCScriptManager.getInstance().start(c, npc.getId(), oid, null); if (!hasNpcScript) { @@ -97,4 +95,4 @@ public final class NPCTalkHandler extends AbstractPacketHandler { } } } -} \ No newline at end of file +} diff --git a/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java b/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java index f3e2b9288c..d55064d757 100644 --- a/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java +++ b/src/main/java/net/server/channel/handlers/PlayerLoggedinHandler.java @@ -448,11 +448,6 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler { Entry::getValue )); - // Any npc be specified as the rebirth npc. Allow the npc to use custom scripts explicitly. - if (YamlConfig.config.server.USE_REBIRTH_SYSTEM) { - npcsIds.put(YamlConfig.config.server.REBIRTH_NPC_ID, "Rebirth"); - } - c.sendPacket(PacketCreator.setNPCScriptable(npcsIds)); } diff --git a/src/main/java/tools/exceptions/NotEnabledException.java b/src/main/java/tools/exceptions/NotEnabledException.java deleted file mode 100644 index 8f6bd509d6..0000000000 --- a/src/main/java/tools/exceptions/NotEnabledException.java +++ /dev/null @@ -1,12 +0,0 @@ -package tools.exceptions; - -public class NotEnabledException extends RuntimeException { - - public NotEnabledException() { - super("Feature not enabled, please enable the feature in ServerConstant"); - } - - public NotEnabledException(String message) { - super(message); - } -}