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