Merge pull request #253 from P0nk/cleanup/rebirth #minor

Remove rebirth system
This commit is contained in:
Ponk
2024-07-19 17:24:18 +02:00
committed by GitHub
7 changed files with 1 additions and 168 deletions

View File

@@ -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.

View File

@@ -1,79 +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/>.
*/
/* 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();
}
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {
}
}
}
}
}

View File

@@ -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));
}

View File

@@ -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);
}
}