Merge pull request #89 from truongdatnhan/master
Fixing bugs, Clean up code, Upgrade to new Syntax
This commit is contained in:
@@ -7402,10 +7402,18 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ret.buddylist.loadFromDb(charid);
|
||||
ret.storage = wserv.getAccountStorage(ret.accountid);
|
||||
|
||||
/* Double-check storage incase player is first time on server
|
||||
* The storage won't exist so nothing to load
|
||||
*/
|
||||
if(ret.storage == null) {
|
||||
wserv.loadAccountStorage(ret.accountid);
|
||||
ret.storage = wserv.getAccountStorage(ret.accountid);
|
||||
}
|
||||
|
||||
int startHp = ret.hp, startMp = ret.mp;
|
||||
ret.reapplyLocalStats();
|
||||
ret.changeHpMp(startHp, startMp, true);
|
||||
@@ -8296,7 +8304,7 @@ public class Character extends AbstractCharacterObject {
|
||||
ps.executeBatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
con.commit();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -174,8 +174,8 @@ public class Ring implements Comparable<Ring> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof Ring) {
|
||||
return ((Ring) o).getRingId() == getRingId();
|
||||
if (o instanceof Ring ring) {
|
||||
return ring.getRingId() == getRingId();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@ import server.ThreadManager;
|
||||
import tools.exceptions.IdTypeNotSupportedException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -75,12 +76,13 @@ public class IdCommand extends Command {
|
||||
throw new IdTypeNotSupportedException();
|
||||
}
|
||||
itemMap.put(type, new HashMap<>());
|
||||
BufferedReader reader = new BufferedReader(new FileReader(handbookDirectory.get(type)));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String[] row = line.split(" - ", 2);
|
||||
if (row.length == 2) {
|
||||
itemMap.get(type).put(row[1].toLowerCase(), row[0]);
|
||||
try (BufferedReader reader = Files.newBufferedReader(Paths.get(handbookDirectory.get(type)))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String[] row = line.split(" - ", 2);
|
||||
if (row.length == 2) {
|
||||
itemMap.get(type).put(row[1].toLowerCase(), row[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,19 +48,15 @@ public class WhereaMiCommand extends Command {
|
||||
HashSet<Monster> mobs = new HashSet<>();
|
||||
|
||||
for (MapObject mmo : player.getMap().getMapObjects()) {
|
||||
if (mmo instanceof NPC) {
|
||||
NPC npc = (NPC) mmo;
|
||||
if (mmo instanceof NPC npc) {
|
||||
npcs.add(npc);
|
||||
} else if (mmo instanceof Character) {
|
||||
Character mc = (Character) mmo;
|
||||
} else if (mmo instanceof Character mc) {
|
||||
chars.add(mc);
|
||||
} else if (mmo instanceof Monster) {
|
||||
Monster mob = (Monster) mmo;
|
||||
} else if (mmo instanceof Monster mob) {
|
||||
if (mob.isAlive()) {
|
||||
mobs.add(mob);
|
||||
}
|
||||
} else if (mmo instanceof PlayerNPC) {
|
||||
PlayerNPC npc = (PlayerNPC) mmo;
|
||||
} else if (mmo instanceof PlayerNPC npc) {
|
||||
playernpcs.add(npc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class FaceCommand extends Command {
|
||||
}
|
||||
|
||||
Character victim = c.getChannelServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
if (victim == null) {
|
||||
if (victim != null) {
|
||||
victim.setFace(itemId);
|
||||
victim.updateSingleStat(Stat.FACE, itemId);
|
||||
victim.equipChanged();
|
||||
|
||||
@@ -35,9 +35,10 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import tools.HexTool;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Properties;
|
||||
|
||||
public class PeCommand extends Command {
|
||||
@@ -51,11 +52,9 @@ public class PeCommand extends Command {
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
String packet = "";
|
||||
try {
|
||||
InputStreamReader is = new FileReader("pe.txt");
|
||||
try (BufferedReader br = Files.newBufferedReader(Paths.get("pe.txt"))) {
|
||||
Properties packetProps = new Properties();
|
||||
packetProps.load(is);
|
||||
is.close();
|
||||
packetProps.load(br);
|
||||
packet = packetProps.getProperty("pe");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
|
||||
@@ -538,7 +538,8 @@ public class InventoryManipulator {
|
||||
|
||||
itemChanged = true;
|
||||
}
|
||||
if (dst == -6) { // unequip the overall
|
||||
switch (dst) {
|
||||
case -6: // unequip the overall
|
||||
Item top = eqpdInv.getItem((short) -5);
|
||||
if (top != null && ItemConstants.isOverall(top.getItemId())) {
|
||||
if (eqpInv.isFull()) {
|
||||
@@ -548,7 +549,8 @@ public class InventoryManipulator {
|
||||
}
|
||||
unequip(c, (byte) -5, eqpInv.getNextFreeSlot());
|
||||
}
|
||||
} else if (dst == -5) {
|
||||
break;
|
||||
case -5:
|
||||
final Item bottom = eqpdInv.getItem((short) -6);
|
||||
if (bottom != null && ItemConstants.isOverall(source.getItemId())) {
|
||||
if (eqpInv.isFull()) {
|
||||
@@ -558,7 +560,8 @@ public class InventoryManipulator {
|
||||
}
|
||||
unequip(c, (byte) -6, eqpInv.getNextFreeSlot());
|
||||
}
|
||||
} else if (dst == -10) {// check if weapon is two-handed
|
||||
break;
|
||||
case -10: // check if weapon is two-handed
|
||||
Item weapon = eqpdInv.getItem((short) -11);
|
||||
if (weapon != null && ii.isTwoHanded(weapon.getItemId())) {
|
||||
if (eqpInv.isFull()) {
|
||||
@@ -568,7 +571,8 @@ public class InventoryManipulator {
|
||||
}
|
||||
unequip(c, (byte) -11, eqpInv.getNextFreeSlot());
|
||||
}
|
||||
} else if (dst == -11) {
|
||||
break;
|
||||
case -11:
|
||||
Item shield = eqpdInv.getItem((short) -10);
|
||||
if (shield != null && ii.isTwoHanded(source.getItemId())) {
|
||||
if (eqpInv.isFull()) {
|
||||
@@ -578,11 +582,12 @@ public class InventoryManipulator {
|
||||
}
|
||||
unequip(c, (byte) -10, eqpInv.getNextFreeSlot());
|
||||
}
|
||||
}
|
||||
if (dst == -18) {
|
||||
break;
|
||||
case -18:
|
||||
if (chr.getMount() != null) {
|
||||
chr.getMount().setItemId(source.getItemId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//1112413, 1112414, 1112405 (Lilin's Ring)
|
||||
|
||||
@@ -60,7 +60,8 @@ public class StorageProcessor {
|
||||
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
if (mode == 4) { // take out
|
||||
switch (mode) {
|
||||
case 4: { // take out
|
||||
byte type = p.readByte();
|
||||
byte slot = p.readByte();
|
||||
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
||||
@@ -104,14 +105,17 @@ public class StorageProcessor {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0A));
|
||||
}
|
||||
}
|
||||
} else if (mode == 5) { // store
|
||||
break;
|
||||
}
|
||||
case 5: { // store
|
||||
short slot = p.readShort();
|
||||
int itemId = p.readInt();
|
||||
short quantity = p.readShort();
|
||||
InventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
Inventory inv = chr.getInventory(invType);
|
||||
if (slot < 1 || slot > inv.getSlotLimit()) { //player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
if (slot < 1 || slot > inv.getSlotLimit()) { // player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(),
|
||||
c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
log.warn("Chr {} tried to store item at slot {}", c.getPlayer().getName(), slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
@@ -124,17 +128,17 @@ public class StorageProcessor {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x11));
|
||||
return;
|
||||
}
|
||||
|
||||
int storeFee = storage.getStoreFee();
|
||||
if (chr.getMeso() < storeFee) {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0B));
|
||||
} else {
|
||||
Item item;
|
||||
|
||||
inv.lockInventory(); // thanks imbee for pointing a dupe within storage
|
||||
inv.lockInventory(); // thanks imbee for pointing a dupe within storage
|
||||
try {
|
||||
item = inv.getItem(slot);
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (item != null && item.getItemId() == itemId
|
||||
&& (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemId.isWeddingRing(itemId) || ItemId.isWeddingToken(itemId)) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
@@ -150,7 +154,7 @@ public class StorageProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
item = item.copy(); // thanks Robin Schulz & BHB88 for noticing a inventory glitch when storing items
|
||||
item = item.copy(); // thanks Robin Schulz & BHB88 for noticing a inventory glitch when storing items
|
||||
} finally {
|
||||
inv.unlockInventory();
|
||||
}
|
||||
@@ -160,19 +164,22 @@ public class StorageProcessor {
|
||||
KarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
item.setQuantity(quantity);
|
||||
|
||||
storage.store(item); // inside a critical section, "!(storage.isFull())" is still in effect...
|
||||
storage.store(item); // inside a critical section, "!(storage.isFull())" is still in effect...
|
||||
chr.setUsedStorage();
|
||||
|
||||
String itemName = ii.getName(item.getItemId());
|
||||
log.debug("Chr {} stored {}x {} ({})", c.getPlayer().getName(), item.getQuantity(), itemName, item.getItemId());
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
break;
|
||||
}
|
||||
case 6: // arrange items
|
||||
if (YamlConfig.config.server.USE_STORAGE_ITEM_SORT) {
|
||||
storage.arrangeItems(c);
|
||||
}
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
} else if (mode == 7) { // meso
|
||||
break;
|
||||
case 7: { // meso
|
||||
int meso = p.readInt();
|
||||
int storageMesos = storage.getMeso();
|
||||
int playerMesos = chr.getMeso();
|
||||
@@ -199,8 +206,11 @@ public class StorageProcessor {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (mode == 8) {// close... unless the player decides to enter cash shop!
|
||||
break;
|
||||
}
|
||||
case 8: // close... unless the player decides to enter cash shop!
|
||||
storage.close();
|
||||
break;
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
|
||||
@@ -418,7 +418,8 @@ public class AssignAPProcessor {
|
||||
}
|
||||
|
||||
int newVal = 0;
|
||||
if (type.equals(Stat.STR)) {
|
||||
switch (type) {
|
||||
case STR:
|
||||
newVal = statUpdate[0] + gain;
|
||||
if (newVal > YamlConfig.config.server.MAX_AP) {
|
||||
statGain[0] += (gain - (newVal - YamlConfig.config.server.MAX_AP));
|
||||
@@ -427,7 +428,8 @@ public class AssignAPProcessor {
|
||||
statGain[0] += gain;
|
||||
statUpdate[0] = newVal;
|
||||
}
|
||||
} else if (type.equals(Stat.INT)) {
|
||||
break;
|
||||
case INT:
|
||||
newVal = statUpdate[3] + gain;
|
||||
if (newVal > YamlConfig.config.server.MAX_AP) {
|
||||
statGain[3] += (gain - (newVal - YamlConfig.config.server.MAX_AP));
|
||||
@@ -436,7 +438,8 @@ public class AssignAPProcessor {
|
||||
statGain[3] += gain;
|
||||
statUpdate[3] = newVal;
|
||||
}
|
||||
} else if (type.equals(Stat.LUK)) {
|
||||
break;
|
||||
case LUK:
|
||||
newVal = statUpdate[2] + gain;
|
||||
if (newVal > YamlConfig.config.server.MAX_AP) {
|
||||
statGain[2] += (gain - (newVal - YamlConfig.config.server.MAX_AP));
|
||||
@@ -445,7 +448,8 @@ public class AssignAPProcessor {
|
||||
statGain[2] += gain;
|
||||
statUpdate[2] = newVal;
|
||||
}
|
||||
} else if (type.equals(Stat.DEX)) {
|
||||
break;
|
||||
case DEX:
|
||||
newVal = statUpdate[1] + gain;
|
||||
if (newVal > YamlConfig.config.server.MAX_AP) {
|
||||
statGain[1] += (gain - (newVal - YamlConfig.config.server.MAX_AP));
|
||||
@@ -454,6 +458,7 @@ public class AssignAPProcessor {
|
||||
statGain[1] += gain;
|
||||
statUpdate[1] = newVal;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (newVal > YamlConfig.config.server.MAX_AP) {
|
||||
|
||||
@@ -4,8 +4,9 @@ import com.esotericsoftware.yamlbeans.YamlReader;
|
||||
import constants.string.CharsetConstants;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -18,7 +19,7 @@ public class YamlConfig {
|
||||
|
||||
private static YamlConfig loadConfig() {
|
||||
try {
|
||||
YamlReader reader = new YamlReader(new FileReader(CONFIG_FILE_NAME, CharsetConstants.CHARSET));
|
||||
YamlReader reader = new YamlReader(Files.newBufferedReader(Paths.get(CONFIG_FILE_NAME), CharsetConstants.CHARSET));
|
||||
YamlConfig config = reader.read(YamlConfig.class);
|
||||
reader.close();
|
||||
return config;
|
||||
|
||||
@@ -19,10 +19,11 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -61,7 +62,7 @@ public class CharsetConstants {
|
||||
|
||||
private static String loadCharsetFromConfig() {
|
||||
try {
|
||||
YamlReader reader = new YamlReader(new FileReader(YamlConfig.CONFIG_FILE_NAME, StandardCharsets.US_ASCII));
|
||||
YamlReader reader = new YamlReader(Files.newBufferedReader(Paths.get(YamlConfig.CONFIG_FILE_NAME), StandardCharsets.US_ASCII));
|
||||
reader.getConfig().readConfig.setIgnoreUnknownProperties(true);
|
||||
StrippedYamlConfig charsetConfig = reader.read(StrippedYamlConfig.class);
|
||||
reader.close();
|
||||
|
||||
@@ -1934,13 +1934,7 @@ public class Server {
|
||||
new Thread(() -> System.exit(0)).start();
|
||||
} else {
|
||||
log.info("Restarting the server...");
|
||||
try {
|
||||
instance.finalize();//FUU I CAN AND IT'S FREE
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
instance = null;
|
||||
System.gc();
|
||||
getInstance().init();//DID I DO EVERYTHING?! D:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,28 +303,21 @@ public final class BBSOperationHandler extends AbstractPacketHandler {
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
// TODO clean up this block and use try-with-resources
|
||||
PreparedStatement ps2;
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM bbs_threads WHERE guildid = ? AND " + (bIsThreadIdLocal ? "local" : "") + "threadid = ?")) {
|
||||
ps.setInt(1, mc.getGuildId());
|
||||
ps.setInt(2, threadid);
|
||||
ResultSet threadRS = ps.executeQuery();
|
||||
if (!threadRS.next()) {
|
||||
threadRS.close();
|
||||
ps.close();
|
||||
return;
|
||||
}
|
||||
ResultSet repliesRS = null;
|
||||
ps2 = null;
|
||||
if (threadRS.getInt("replycount") >= 0) {
|
||||
ps2 = con.prepareStatement("SELECT * FROM bbs_replies WHERE threadid = ?");
|
||||
ps2.setInt(1, !bIsThreadIdLocal ? threadid : threadRS.getInt("threadid"));
|
||||
repliesRS = ps2.executeQuery();
|
||||
try (PreparedStatement ps2 = con.prepareStatement("SELECT * FROM bbs_replies WHERE threadid = ?")) {
|
||||
if (threadRS.getInt("replycount") >= 0) {
|
||||
ps2.setInt(1, !bIsThreadIdLocal ? threadid : threadRS.getInt("threadid"));
|
||||
repliesRS = ps2.executeQuery();
|
||||
}
|
||||
client.sendPacket(GuildPackets.showThread(bIsThreadIdLocal ? threadid : threadRS.getInt("localthreadid"), threadRS, repliesRS));
|
||||
}
|
||||
client.sendPacket(GuildPackets.showThread(bIsThreadIdLocal ? threadid : threadRS.getInt("localthreadid"), threadRS, repliesRS));
|
||||
repliesRS.close();
|
||||
}
|
||||
if (ps2 != null) {
|
||||
ps2.close();
|
||||
}
|
||||
} catch (SQLException se) {
|
||||
log.error("Error displaying thread", se);
|
||||
|
||||
@@ -269,8 +269,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
cs.removeFromInventory(item);
|
||||
c.sendPacket(PacketCreator.takeFromCashInventory(item));
|
||||
|
||||
if (item instanceof Equip) {
|
||||
Equip equip = (Equip) item;
|
||||
if (item instanceof Equip equip) {
|
||||
if (equip.getRingId() >= 0) {
|
||||
Ring ring = Ring.loadFromDb(equip.getRingId());
|
||||
chr.addPlayerRing(ring);
|
||||
@@ -323,8 +322,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
return;
|
||||
}*/ //Gotta let them faggots marry too, hence why this is commented out <3
|
||||
|
||||
if (itemRing.toItem() instanceof Equip) {
|
||||
Equip eqp = (Equip) itemRing.toItem();
|
||||
if (itemRing.toItem() instanceof Equip eqp) {
|
||||
Pair<Integer, Integer> rings = Ring.createRing(itemRing.getItemId(), chr, partner);
|
||||
eqp.setRingId(rings.getLeft());
|
||||
cs.addToInventory(eqp);
|
||||
@@ -387,8 +385,7 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
c.sendPacket(PacketCreator.showCashShopMessage((byte) 0xBE));
|
||||
} else {
|
||||
// Need to check to make sure its actually an equip and the right SN...
|
||||
if (itemRing.toItem() instanceof Equip) {
|
||||
Equip eqp = (Equip) itemRing.toItem();
|
||||
if (itemRing.toItem() instanceof Equip eqp) {
|
||||
Pair<Integer, Integer> rings = Ring.createRing(itemRing.getItemId(), chr, partner);
|
||||
eqp.setRingId(rings.getLeft());
|
||||
cs.addToInventory(eqp);
|
||||
|
||||
@@ -36,8 +36,7 @@ public final class CharInfoRequestHandler extends AbstractPacketHandler {
|
||||
int cid = p.readInt();
|
||||
MapObject target = c.getPlayer().getMap().getMapObject(cid);
|
||||
if (target != null) {
|
||||
if (target instanceof Character) {
|
||||
Character player = (Character) target;
|
||||
if (target instanceof Character player) {
|
||||
|
||||
if (c.getPlayer().getId() != player.getId()) {
|
||||
player.exportExcludedItems(c);
|
||||
|
||||
@@ -45,8 +45,7 @@ public final class DoorHandler extends AbstractPacketHandler {
|
||||
}
|
||||
|
||||
for (MapObject obj : chr.getMap().getMapObjects()) {
|
||||
if (obj instanceof DoorObject) {
|
||||
DoorObject door = (DoorObject) obj;
|
||||
if (obj instanceof DoorObject door) {
|
||||
if (door.getOwnerId() == ownerid) {
|
||||
door.warp(chr);
|
||||
return;
|
||||
|
||||
@@ -47,8 +47,7 @@ public final class HiredMerchantRequest extends AbstractPacketHandler {
|
||||
|
||||
try {
|
||||
for (MapObject mmo : chr.getMap().getMapObjectsInRange(chr.getPosition(), 23000, Arrays.asList(MapObjectType.HIRED_MERCHANT, MapObjectType.PLAYER))) {
|
||||
if (mmo instanceof Character) {
|
||||
Character mc = (Character) mmo;
|
||||
if (mmo instanceof Character mc) {
|
||||
|
||||
PlayerShop shop = mc.getPlayerShop();
|
||||
if (shop != null && shop.isOwner(mc)) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -52,22 +52,30 @@ public final class MobDamageMobFriendlyHandler extends AbstractPacketHandler {
|
||||
int damage = Randomizer.nextInt(((monster.getMaxHp() / 13 + monster.getPADamage() * 10)) * 2 + 500) / 10; // Formula planned by Beng.
|
||||
|
||||
if (monster.getHp() - damage < 1) { // friendly dies
|
||||
if (monster.getId() == MobId.WATCH_HOG) {
|
||||
switch (monster.getId()) {
|
||||
case MobId.WATCH_HOG:
|
||||
map.broadcastMessage(PacketCreator.serverNotice(6, "The Watch Hog has been injured by the aliens. Better luck next time..."));
|
||||
} else if (monster.getId() == MobId.MOON_BUNNY) { //moon bunny
|
||||
break;
|
||||
case MobId.MOON_BUNNY: //moon bunny
|
||||
map.broadcastMessage(PacketCreator.serverNotice(6, "The Moon Bunny went home because he was sick."));
|
||||
} else if (monster.getId() == MobId.TYLUS) { //tylus
|
||||
break;
|
||||
case MobId.TYLUS: //tylus
|
||||
map.broadcastMessage(PacketCreator.serverNotice(6, "Tylus has fallen by the overwhelming forces of the ambush."));
|
||||
} else if (monster.getId() == MobId.JULIET) { //juliet
|
||||
break;
|
||||
case MobId.JULIET: //juliet
|
||||
map.broadcastMessage(PacketCreator.serverNotice(6, "Juliet has fainted in the middle of the combat."));
|
||||
} else if (monster.getId() == MobId.ROMEO) { //romeo
|
||||
break;
|
||||
case MobId.ROMEO: //romeo
|
||||
map.broadcastMessage(PacketCreator.serverNotice(6, "Romeo has fainted in the middle of the combat."));
|
||||
} else if (monster.getId() == MobId.GIANT_SNOWMAN_LV1_EASY || monster.getId() == MobId.GIANT_SNOWMAN_LV1_MEDIUM || monster.getId() == MobId.GIANT_SNOWMAN_LV1_HARD) {
|
||||
break;
|
||||
case MobId.GIANT_SNOWMAN_LV1_EASY, MobId.GIANT_SNOWMAN_LV1_MEDIUM, MobId.GIANT_SNOWMAN_LV1_HARD:
|
||||
map.broadcastMessage(PacketCreator.serverNotice(6, "The Snowman has melted on the heat of the battle."));
|
||||
} else if (monster.getId() == MobId.DELLI) { //delli
|
||||
break;
|
||||
case MobId.DELLI: //delli
|
||||
map.broadcastMessage(PacketCreator.serverNotice(6, "Delli vanished after the ambush, sheets still laying on the ground..."));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
map.killFriendlies(monster);
|
||||
} else {
|
||||
EventInstanceManager eim = map.getEventInstance();
|
||||
|
||||
@@ -38,27 +38,38 @@ public final class NPCShopHandler extends AbstractPacketHandler {
|
||||
@Override
|
||||
public void handlePacket(InPacket p, Client c) {
|
||||
byte bmode = p.readByte();
|
||||
if (bmode == 0) { // mode 0 = buy :)
|
||||
switch (bmode) {
|
||||
case 0: { // mode 0 = buy :)
|
||||
short slot = p.readShort();// slot
|
||||
int itemId = p.readInt();
|
||||
short quantity = p.readShort();
|
||||
if (quantity < 1) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit a npc shop.");
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(),
|
||||
c.getPlayer().getName() + " tried to packet edit a npc shop.");
|
||||
log.warn("Chr {} tried to buy quantity {} of itemid {}", c.getPlayer().getName(), quantity, itemId);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
c.getPlayer().getShop().buy(c, slot, itemId, quantity);
|
||||
} else if (bmode == 1) { // sell ;)
|
||||
break;
|
||||
}
|
||||
case 1: { // sell ;)
|
||||
short slot = p.readShort();
|
||||
int itemId = p.readInt();
|
||||
short quantity = p.readShort();
|
||||
c.getPlayer().getShop().sell(c, ItemConstants.getInventoryType(itemId), slot, quantity);
|
||||
} else if (bmode == 2) { // recharge ;)
|
||||
break;
|
||||
}
|
||||
case 2: { // recharge ;)
|
||||
|
||||
byte slot = (byte) p.readShort();
|
||||
c.getPlayer().getShop().recharge(c, slot);
|
||||
} else if (bmode == 3) { // leaving :(
|
||||
c.getPlayer().setShop(null);
|
||||
break;
|
||||
}
|
||||
case 3: // leaving :(
|
||||
c.getPlayer().setShop(null);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,8 +87,7 @@ public final class NPCTalkHandler extends AbstractPacketHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (obj instanceof PlayerNPC) {
|
||||
PlayerNPC pnpc = (PlayerNPC) obj;
|
||||
} else if (obj instanceof PlayerNPC pnpc) {
|
||||
NPCScriptManager nsm = NPCScriptManager.getInstance();
|
||||
|
||||
if (pnpc.getScriptId() < NpcId.CUSTOM_DEV && !nsm.isNpcScriptAvailable(c, "" + pnpc.getScriptId())) {
|
||||
|
||||
@@ -291,11 +291,10 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
||||
MapObject ob = chr.getMap().getMapObject(oid);
|
||||
if (ob instanceof PlayerShop shop) {
|
||||
shop.visitShop(chr);
|
||||
} else if (ob instanceof MiniGame) {
|
||||
} else if (ob instanceof MiniGame game) {
|
||||
p.skip(1);
|
||||
String pw = p.available() > 1 ? p.readString() : "";
|
||||
|
||||
MiniGame game = (MiniGame) ob;
|
||||
if (game.checkPassword(pw)) {
|
||||
if (game.hasFreeSlot() && !game.isVisitor(chr)) {
|
||||
game.addVisitor(chr);
|
||||
@@ -849,8 +848,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
||||
private static boolean canPlaceStore(Character chr) {
|
||||
try {
|
||||
for (MapObject mmo : chr.getMap().getMapObjectsInRange(chr.getPosition(), 23000, Arrays.asList(MapObjectType.HIRED_MERCHANT, MapObjectType.PLAYER))) {
|
||||
if (mmo instanceof Character) {
|
||||
Character mc = (Character) mmo;
|
||||
if (mmo instanceof Character mc) {
|
||||
if (mc.getId() == chr.getId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -73,25 +73,27 @@ public final class QuestActionHandler extends AbstractPacketHandler {
|
||||
Character player = c.getPlayer();
|
||||
Quest quest = Quest.getInstance(questid);
|
||||
|
||||
if (action == 0) { // Restore lost item, Credits Darter ( Rajan )
|
||||
switch (action) {
|
||||
case 0: // Restore lost item, Credits Darter ( Rajan )
|
||||
p.readInt();
|
||||
int itemid = p.readInt();
|
||||
quest.restoreLostItem(player, itemid);
|
||||
} else if (action == 1) { //Start Quest
|
||||
break;
|
||||
case 1: { // Start Quest
|
||||
int npc = p.readInt();
|
||||
if (!isNpcNearby(p, player, quest, npc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (quest.canStart(player, npc)) {
|
||||
quest.start(player, npc);
|
||||
}
|
||||
} else if (action == 2) { // Complete Quest
|
||||
break;
|
||||
}
|
||||
case 2: { // Complete Quest
|
||||
int npc = p.readInt();
|
||||
if (!isNpcNearby(p, player, quest, npc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (quest.canComplete(player, npc)) {
|
||||
if (p.available() >= 2) {
|
||||
int selection = p.readShort();
|
||||
@@ -100,26 +102,31 @@ public final class QuestActionHandler extends AbstractPacketHandler {
|
||||
quest.complete(player, npc);
|
||||
}
|
||||
}
|
||||
} else if (action == 3) {// forfeit quest
|
||||
break;
|
||||
}
|
||||
case 3: // forfeit quest
|
||||
quest.forfeit(player);
|
||||
} else if (action == 4) { // scripted start quest
|
||||
break;
|
||||
case 4: { // scripted start quest
|
||||
int npc = p.readInt();
|
||||
if (!isNpcNearby(p, player, quest, npc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (quest.canStart(player, npc)) {
|
||||
QuestScriptManager.getInstance().start(c, questid, npc);
|
||||
}
|
||||
} else if (action == 5) { // scripted end quests
|
||||
break;
|
||||
}
|
||||
case 5: { // scripted end quests
|
||||
int npc = p.readInt();
|
||||
if (!isNpcNearby(p, player, quest, npc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (quest.canComplete(player, npc)) {
|
||||
QuestScriptManager.getInstance().end(c, questid, npc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,11 +604,10 @@ public class Guild {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof GuildCharacter)) {
|
||||
return false;
|
||||
if (other instanceof GuildCharacter o) {
|
||||
return (o.getId() == id && o.getName().equals(name));
|
||||
}
|
||||
GuildCharacter o = (GuildCharacter) other;
|
||||
return (o.getId() == id && o.getName().equals(name));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -150,11 +150,10 @@ public class GuildCharacter {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof GuildCharacter)) {
|
||||
return false;
|
||||
if (other instanceof GuildCharacter o) {
|
||||
return (o.getId() == id && o.getName().equals(name));
|
||||
}
|
||||
GuildCharacter o = (GuildCharacter) other;
|
||||
return (o.getId() == id && o.getName().equals(name));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -86,13 +86,17 @@ public final class CreateCharHandler extends AbstractPacketHandler {
|
||||
}
|
||||
|
||||
int status;
|
||||
if (job == 0) { // Knights of Cygnus
|
||||
switch (job) {
|
||||
case 0: // Knights of Cygnus
|
||||
status = NoblesseCreator.createCharacter(c, name, face, hair + haircolor, skincolor, top, bottom, shoes, weapon, gender);
|
||||
} else if (job == 1) { // Adventurer
|
||||
break;
|
||||
case 1: // Adventurer
|
||||
status = BeginnerCreator.createCharacter(c, name, face, hair + haircolor, skincolor, top, bottom, shoes, weapon, gender);
|
||||
} else if (job == 2) { // Aran
|
||||
break;
|
||||
case 2: // Aran
|
||||
status = LegendCreator.createCharacter(c, name, face, hair + haircolor, skincolor, top, bottom, shoes, weapon, gender);
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
c.sendPacket(PacketCreator.deleteCharResponse(0, 9));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ package provider;
|
||||
import provider.wz.WZFiles;
|
||||
import provider.wz.XMLWZFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class DataProviderFactory {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package provider.wz;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -38,7 +38,7 @@ public enum WZFiles {
|
||||
private static String getWzDirectory() {
|
||||
// Either provide a custom directory path through the "wz-path" property when launching the .jar, or don't provide one to use the default "wz" directory
|
||||
String propertyPath = System.getProperty("wz-path");
|
||||
if (propertyPath != null && new File(propertyPath).isDirectory()) {
|
||||
if (propertyPath != null && Files.isDirectory(Paths.get(propertyPath))) {
|
||||
return propertyPath;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
@@ -28,9 +28,12 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.script.*;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* @author Matze
|
||||
@@ -44,9 +47,8 @@ public abstract class AbstractScriptManager {
|
||||
}
|
||||
|
||||
protected ScriptEngine getInvocableScriptEngine(String path) {
|
||||
path = "scripts/" + path;
|
||||
File scriptFile = new File(path);
|
||||
if (!scriptFile.exists()) {
|
||||
Path scriptFile = Paths.get("scripts").resolve(path);
|
||||
if (!Files.exists(scriptFile)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -57,8 +59,8 @@ public abstract class AbstractScriptManager {
|
||||
|
||||
enableScriptHostAccess(graalScriptEngine);
|
||||
|
||||
try (FileReader fr = new FileReader(scriptFile, CharsetConstants.CHARSET)) {
|
||||
engine.eval(fr);
|
||||
try (BufferedReader br = Files.newBufferedReader(scriptFile, CharsetConstants.CHARSET)) {
|
||||
engine.eval(br);
|
||||
} catch (final ScriptException | IOException t) {
|
||||
log.warn("Exception during script eval for file: {}", path, t);
|
||||
return null;
|
||||
|
||||
@@ -72,21 +72,22 @@ public class MapScriptMethods extends AbstractPlayerInteraction {
|
||||
}
|
||||
|
||||
public void startExplorerExperience() {
|
||||
if (c.getPlayer().getMapId() == 1020100) //Swordman
|
||||
{
|
||||
switch (c.getPlayer().getMapId()) {
|
||||
case 1020100: //Swordman
|
||||
c.sendPacket(PacketCreator.showIntro("Effect/Direction3.img/swordman/Scene" + c.getPlayer().getGender()));
|
||||
} else if (c.getPlayer().getMapId() == 1020200) //Magician
|
||||
{
|
||||
break;
|
||||
case 1020200: //Magician
|
||||
c.sendPacket(PacketCreator.showIntro("Effect/Direction3.img/magician/Scene" + c.getPlayer().getGender()));
|
||||
} else if (c.getPlayer().getMapId() == 1020300) //Archer
|
||||
{
|
||||
break;
|
||||
case 1020300: //Archer
|
||||
c.sendPacket(PacketCreator.showIntro("Effect/Direction3.img/archer/Scene" + c.getPlayer().getGender()));
|
||||
} else if (c.getPlayer().getMapId() == 1020400) //Rogue
|
||||
{
|
||||
break;
|
||||
case 1020400: //Rogue
|
||||
c.sendPacket(PacketCreator.showIntro("Effect/Direction3.img/rogue/Scene" + c.getPlayer().getGender()));
|
||||
} else if (c.getPlayer().getMapId() == 1020500) //Pirate
|
||||
{
|
||||
break;
|
||||
case 1020500: //Pirate
|
||||
c.sendPacket(PacketCreator.showIntro("Effect/Direction3.img/pirate/Scene" + c.getPlayer().getGender()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,16 +104,20 @@ public class CashShop {
|
||||
|
||||
if (ItemConstants.EXPIRING_ITEMS) {
|
||||
if (period == 1) {
|
||||
if (itemId == ItemId.EXP_COUPON_2X_4H || itemId == ItemId.DROP_COUPON_2X_4H) { // 4 Hour 2X coupons, the period is 1, but we don't want them to last a day.
|
||||
switch (itemId) {
|
||||
case ItemId.DROP_COUPON_2X_4H, ItemId.EXP_COUPON_2X_4H: // 4 Hour 2X coupons, the period is 1, but we don't want them to last a day.
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(4));
|
||||
/*
|
||||
} else if(itemId == 5211047 || itemId == 5360014) { // 3 Hour 2X coupons, unused as of now
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(3));
|
||||
*/
|
||||
} else if (itemId == ItemId.EXP_COUPON_3X_2H) { // 2 Hour 3X coupons.
|
||||
break;
|
||||
case ItemId.EXP_COUPON_3X_2H:
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + HOURS.toMillis(2));
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + DAYS.toMillis(1));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
item.setExpiration(Server.getInstance().getCurrentTime() + DAYS.toMillis(period));
|
||||
@@ -264,12 +268,16 @@ public class CashShop {
|
||||
this.characterId = characterId;
|
||||
|
||||
if (!YamlConfig.config.server.USE_JOINT_CASHSHOP_INVENTORY) {
|
||||
if (jobType == 0) {
|
||||
switch (jobType) {
|
||||
case 0:
|
||||
factory = ItemFactory.CASH_EXPLORER;
|
||||
} else if (jobType == 1) {
|
||||
break;
|
||||
case 1:
|
||||
factory = ItemFactory.CASH_CYGNUS;
|
||||
} else if (jobType == 2) {
|
||||
break;
|
||||
case 2:
|
||||
factory = ItemFactory.CASH_ARAN;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
factory = ItemFactory.CASH_OVERALL;
|
||||
|
||||
@@ -1033,8 +1033,7 @@ public class ItemInformationProvider {
|
||||
public Item scrollEquipWithId(Item equip, int scrollId, boolean usingWhiteScroll, int vegaItemId, boolean isGM) {
|
||||
boolean assertGM = (isGM && YamlConfig.config.server.USE_PERFECT_GM_SCROLL);
|
||||
|
||||
if (equip instanceof Equip) {
|
||||
Equip nEquip = (Equip) equip;
|
||||
if (equip instanceof Equip nEquip) {
|
||||
Map<String, Integer> stats = this.getEquipStats(scrollId);
|
||||
|
||||
if (((nEquip.getUpgradeSlots() > 0 || ItemConstants.isCleanSlate(scrollId))) || assertGM) {
|
||||
|
||||
@@ -26,12 +26,9 @@ import provider.Data;
|
||||
import provider.DataProvider;
|
||||
import provider.DataProviderFactory;
|
||||
import provider.DataTool;
|
||||
import provider.wz.WZDirectoryEntry;
|
||||
import provider.wz.WZFileEntry;
|
||||
import provider.wz.WZFiles;
|
||||
import tools.DatabaseConnection;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
|
||||
@@ -128,12 +128,16 @@ public class Snowball {
|
||||
|
||||
if (this.hits == 0) {
|
||||
this.position += 1;
|
||||
if (this.position == 45) {
|
||||
switch (this.position) {
|
||||
case 45:
|
||||
map.getSnowball(team == 0 ? 1 : 0).message(1);
|
||||
} else if (this.position == 290) {
|
||||
break;
|
||||
case 290:
|
||||
map.getSnowball(team == 0 ? 1 : 0).message(2);
|
||||
} else if (this.position == 560) {
|
||||
break;
|
||||
case 560:
|
||||
map.getSnowball(team == 0 ? 1 : 0).message(3);
|
||||
break;
|
||||
}
|
||||
|
||||
this.hits = 3;
|
||||
|
||||
@@ -43,14 +43,16 @@ public abstract class GachaponItems {
|
||||
}
|
||||
|
||||
public final int[] getItems(int tier) {
|
||||
if (tier == 0) {
|
||||
switch (tier) {
|
||||
case 0:
|
||||
return commonItems;
|
||||
} else if (tier == 1) {
|
||||
case 1:
|
||||
return uncommonItems;
|
||||
} else if (tier == 2) {
|
||||
case 2:
|
||||
return rareItems;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,8 +112,7 @@ public class MapFactory {
|
||||
|
||||
private static void loadLifeRaw(MapleMap map, int id, String type, int cy, int f, int fh, int rx0, int rx1, int x, int y, int hide, int mobTime, int team) {
|
||||
AbstractLoadedLife myLife = loadLife(id, type, cy, f, fh, rx0, rx1, x, y, hide);
|
||||
if (myLife instanceof Monster) {
|
||||
Monster monster = (Monster) myLife;
|
||||
if (myLife instanceof Monster monster) {
|
||||
|
||||
if (mobTime == -1) { //does not respawn, force spawn once
|
||||
map.spawnMonster(monster);
|
||||
|
||||
@@ -1650,8 +1650,7 @@ public class MapleMap {
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (Object ob : list) {
|
||||
if (ob instanceof MapObject) {
|
||||
MapObject mmo = (MapObject) ob;
|
||||
if (ob instanceof MapObject mmo) {
|
||||
|
||||
if (mapobjects.containsValue(mmo) && mmo.getType() == MapObjectType.REACTOR) {
|
||||
listObjects.add(mmo);
|
||||
|
||||
@@ -249,16 +249,14 @@ public class AriantColiseum {
|
||||
}
|
||||
|
||||
private ExpeditionType getExpeditionType() {
|
||||
ExpeditionType type;
|
||||
if (map.getId() == MapId.ARPQ_ARENA_1) {
|
||||
type = ExpeditionType.ARIANT;
|
||||
} else if (map.getId() == MapId.ARPQ_ARENA_2) {
|
||||
type = ExpeditionType.ARIANT1;
|
||||
} else {
|
||||
type = ExpeditionType.ARIANT2;
|
||||
switch (map.getId()) {
|
||||
case MapId.ARPQ_ARENA_1:
|
||||
return ExpeditionType.ARIANT;
|
||||
case MapId.ARPQ_ARENA_2:
|
||||
return ExpeditionType.ARIANT1;
|
||||
default:
|
||||
return ExpeditionType.ARIANT2;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
private void enterKingsRoom() {
|
||||
|
||||
@@ -70,48 +70,47 @@ public class PartyQuest {
|
||||
synchronized (participants) {
|
||||
participants.remove(chr);
|
||||
chr.setPartyQuest(null);
|
||||
if (participants.isEmpty()) {
|
||||
super.finalize();
|
||||
}
|
||||
//System.gc();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getExp(String PQ, int level) {
|
||||
if (PQ.equals("HenesysPQ")) {
|
||||
switch (PQ) {
|
||||
case "HenesysPQ":
|
||||
return 1250 * level / 5;
|
||||
} else if (PQ.equals("KerningPQFinal")) {
|
||||
case "KerningPQFinal":
|
||||
return 500 * level / 5;
|
||||
} else if (PQ.equals("KerningPQ4th")) {
|
||||
case "KerningPQ4th":
|
||||
return 400 * level / 5;
|
||||
} else if (PQ.equals("KerningPQ3rd")) {
|
||||
case "KerningPQ3rd":
|
||||
return 300 * level / 5;
|
||||
} else if (PQ.equals("KerningPQ2nd")) {
|
||||
case "KerningPQ2nd":
|
||||
return 200 * level / 5;
|
||||
} else if (PQ.equals("KerningPQ1st")) {
|
||||
case "KerningPQ1st":
|
||||
return 100 * level / 5;
|
||||
} else if (PQ.equals("LudiMazePQ")) {
|
||||
case "LudiMazePQ":
|
||||
return 2000 * level / 5;
|
||||
} else if (PQ.equals("LudiPQ1st")) {
|
||||
case "LudiPQ1st":
|
||||
return 100 * level / 5;
|
||||
} else if (PQ.equals("LudiPQ2nd")) {
|
||||
case "LudiPQ2nd":
|
||||
return 250 * level / 5;
|
||||
} else if (PQ.equals("LudiPQ3rd")) {
|
||||
case "LudiPQ3rd":
|
||||
return 350 * level / 5;
|
||||
} else if (PQ.equals("LudiPQ4th")) {
|
||||
case "LudiPQ4th":
|
||||
return 350 * level / 5;
|
||||
} else if (PQ.equals("LudiPQ5th")) {
|
||||
case "LudiPQ5th":
|
||||
return 400 * level / 5;
|
||||
} else if (PQ.equals("LudiPQ6th")) {
|
||||
case "LudiPQ6th":
|
||||
return 450 * level / 5;
|
||||
} else if (PQ.equals("LudiPQ7th")) {
|
||||
case "LudiPQ7th":
|
||||
return 500 * level / 5;
|
||||
} else if (PQ.equals("LudiPQ8th")) {
|
||||
case "LudiPQ8th":
|
||||
return 650 * level / 5;
|
||||
} else if (PQ.equals("LudiPQLast")) {
|
||||
case "LudiPQLast":
|
||||
return 800 * level / 5;
|
||||
default:
|
||||
log.warn("Unhandled PartyQuest: {}", PQ);
|
||||
return 0;
|
||||
}
|
||||
log.warn("Unhandled PartyQuest: {}", PQ);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,12 +111,15 @@ public class Quest {
|
||||
if (startReqData != null) {
|
||||
for (Data startReq : startReqData.getChildren()) {
|
||||
QuestRequirementType type = QuestRequirementType.getByWZName(startReq.getName());
|
||||
if (type.equals(QuestRequirementType.INTERVAL)) {
|
||||
switch (type) {
|
||||
case INTERVAL:
|
||||
repeatable = true;
|
||||
} else if (type.equals(QuestRequirementType.MOB)) {
|
||||
break;
|
||||
case MOB:
|
||||
for (Data mob : startReq.getChildren()) {
|
||||
relevantMobs.add(DataTool.getInt(mob.getChildByPath("id")));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
AbstractQuestRequirement req = this.getRequirement(type, startReq);
|
||||
|
||||
@@ -52,41 +52,42 @@ public enum QuestActionType {
|
||||
}
|
||||
|
||||
public static QuestActionType getByWZName(String name) {
|
||||
if (name.equals("exp")) {
|
||||
switch (name) {
|
||||
case "exp":
|
||||
return EXP;
|
||||
} else if (name.equals("money")) {
|
||||
case "money":
|
||||
return MESO;
|
||||
} else if (name.equals("item")) {
|
||||
case "item":
|
||||
return ITEM;
|
||||
} else if (name.equals("skill")) {
|
||||
case "skill":
|
||||
return SKILL;
|
||||
} else if (name.equals("nextQuest")) {
|
||||
case "nextQuest":
|
||||
return NEXTQUEST;
|
||||
} else if (name.equals("pop")) {
|
||||
case "pop":
|
||||
return FAME;
|
||||
} else if (name.equals("buffItemID")) {
|
||||
case "buffItemID":
|
||||
return BUFF;
|
||||
} else if (name.equals("petskill")) {
|
||||
case "petskill":
|
||||
return PETSKILL;
|
||||
} else if (name.equals("no")) {
|
||||
case "no":
|
||||
return NO;
|
||||
} else if (name.equals("yes")) {
|
||||
case "yes":
|
||||
return YES;
|
||||
} else if (name.equals("npc")) {
|
||||
case "npc":
|
||||
return NPC;
|
||||
} else if (name.equals("lvmin")) {
|
||||
case "lvmin":
|
||||
return MIN_LEVEL;
|
||||
} else if (name.equals("normalAutoStart")) {
|
||||
case "normalAutoStart":
|
||||
return NORMAL_AUTO_START;
|
||||
} else if (name.equals("pettameness")) {
|
||||
case "pettameness":
|
||||
return PETTAMENESS;
|
||||
} else if (name.equals("petspeed")) {
|
||||
case "petspeed":
|
||||
return PETSPEED;
|
||||
} else if (name.equals("info")) {
|
||||
case "info":
|
||||
return INFO;
|
||||
} else if (name.equals("0")) {
|
||||
case "0":
|
||||
return ZERO;
|
||||
} else {
|
||||
default:
|
||||
return UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,57 +62,58 @@ public enum QuestRequirementType {
|
||||
}
|
||||
|
||||
public static QuestRequirementType getByWZName(String name) {
|
||||
if (name.equals("job")) {
|
||||
switch (name) {
|
||||
case "job":
|
||||
return JOB;
|
||||
} else if (name.equals("quest")) {
|
||||
case "quest":
|
||||
return QUEST;
|
||||
} else if (name.equals("item")) {
|
||||
case "item":
|
||||
return ITEM;
|
||||
} else if (name.equals("lvmin")) {
|
||||
case "lvmin":
|
||||
return MIN_LEVEL;
|
||||
} else if (name.equals("lvmax")) {
|
||||
case "lvmax":
|
||||
return MAX_LEVEL;
|
||||
} else if (name.equals("end")) {
|
||||
case "end":
|
||||
return END_DATE;
|
||||
} else if (name.equals("mob")) {
|
||||
case "mob":
|
||||
return MOB;
|
||||
} else if (name.equals("npc")) {
|
||||
case "npc":
|
||||
return NPC;
|
||||
} else if (name.equals("fieldEnter")) {
|
||||
case "fieldEnter":
|
||||
return FIELD_ENTER;
|
||||
} else if (name.equals("interval")) {
|
||||
case "interval":
|
||||
return INTERVAL;
|
||||
} else if (name.equals("startscript")) {
|
||||
case "startscript":
|
||||
return SCRIPT;
|
||||
} else if (name.equals("endscript")) {
|
||||
case "endscript":
|
||||
return SCRIPT;
|
||||
} else if (name.equals("pet")) {
|
||||
case "pet":
|
||||
return PET;
|
||||
} else if (name.equals("pettamenessmin")) {
|
||||
case "pettamenessmin":
|
||||
return MIN_PET_TAMENESS;
|
||||
} else if (name.equals("mbmin")) {
|
||||
case "mbmin":
|
||||
return MONSTER_BOOK;
|
||||
} else if (name.equals("normalAutoStart")) {
|
||||
case "normalAutoStart":
|
||||
return NORMAL_AUTO_START;
|
||||
} else if (name.equals("infoNumber")) {
|
||||
case "infoNumber":
|
||||
return INFO_NUMBER;
|
||||
} else if (name.equals("infoex")) {
|
||||
case "infoex":
|
||||
return INFO_EX;
|
||||
} else if (name.equals("questComplete")) {
|
||||
case "questComplete":
|
||||
return COMPLETED_QUEST;
|
||||
} else if (name.equals("start")) {
|
||||
case "start":
|
||||
return START;
|
||||
/*} else if(name.equals("end")) { already coded
|
||||
/* case "end":already coded
|
||||
return END;*/
|
||||
} else if (name.equals("daybyday")) {
|
||||
case "daybyday":
|
||||
return DAY_BY_DAY;
|
||||
} else if (name.equals("money")) {
|
||||
case "money":
|
||||
return MESO;
|
||||
} else if (name.equals("buff")) {
|
||||
case "buff":
|
||||
return BUFF;
|
||||
} else if (name.equals("exceptbuff")) {
|
||||
case "exceptbuff":
|
||||
return EXCEPT_BUFF;
|
||||
} else {
|
||||
default:
|
||||
return UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,10 @@ public class ArrayMap<K, V> extends AbstractMap<K, V> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Map.Entry<?, ?>)) {
|
||||
return false;
|
||||
if (o instanceof Map.Entry<?, ?> e) {
|
||||
return (key == null ? e.getKey() == null : key.equals(e.getKey())) && (value == null ? e.getValue() == null : value.equals(e.getValue()));
|
||||
}
|
||||
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
|
||||
return (key == null ? e.getKey() == null : key.equals(e.getKey())) && (value == null ? e.getValue() == null : value.equals(e.getValue()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,6 @@ package tools.mapletools;
|
||||
import provider.wz.WZFiles;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.Connection;
|
||||
|
||||
Reference in New Issue
Block a user