Reformat and clean up "client" package
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
package client;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public interface AbstractCharacterListener {
|
||||
|
||||
@@ -40,31 +40,32 @@ public class BuddyList {
|
||||
public enum BuddyAddResult {
|
||||
BUDDYLIST_FULL, ALREADY_ON_LIST, OK
|
||||
}
|
||||
private Map<Integer, BuddylistEntry> buddies = new LinkedHashMap<>();
|
||||
|
||||
private final Map<Integer, BuddylistEntry> buddies = new LinkedHashMap<>();
|
||||
private int capacity;
|
||||
private Deque<CharacterNameAndId> pendingRequests = new LinkedList<>();
|
||||
private final Deque<CharacterNameAndId> pendingRequests = new LinkedList<>();
|
||||
|
||||
public BuddyList(int capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public boolean contains(int characterId) {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
return buddies.containsKey(characterId);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsVisible(int characterId) {
|
||||
BuddylistEntry ble;
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
ble = buddies.get(characterId);
|
||||
}
|
||||
|
||||
|
||||
if (ble == null) {
|
||||
return false;
|
||||
}
|
||||
return ble.isVisible();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
@@ -76,7 +77,7 @@ public class BuddyList {
|
||||
}
|
||||
|
||||
public BuddylistEntry get(int characterId) {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
return buddies.get(characterId);
|
||||
}
|
||||
}
|
||||
@@ -88,36 +89,36 @@ public class BuddyList {
|
||||
return ble;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void put(BuddylistEntry entry) {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
buddies.put(entry.getCharacterId(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(int characterId) {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
buddies.remove(characterId);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<BuddylistEntry> getBuddies() {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
return Collections.unmodifiableCollection(buddies.values());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
return buddies.size() >= capacity;
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getBuddyIds() {
|
||||
synchronized(buddies) {
|
||||
synchronized (buddies) {
|
||||
int[] buddyIds = new int[buddies.size()];
|
||||
int i = 0;
|
||||
for (BuddylistEntry ble : buddies.values()) {
|
||||
@@ -126,12 +127,12 @@ public class BuddyList {
|
||||
return buddyIds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void broadcast(Packet packet, PlayerStorage pstorage) {
|
||||
for(int bid : getBuddyIds()) {
|
||||
for (int bid : getBuddyIds()) {
|
||||
Character chr = pstorage.getCharacterById(bid);
|
||||
|
||||
if(chr != null && chr.isLoggedinWorld()) {
|
||||
|
||||
if (chr != null && chr.isLoggedinWorld()) {
|
||||
chr.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,17 +22,16 @@
|
||||
package client;
|
||||
|
||||
public class BuddylistEntry {
|
||||
private String name;
|
||||
private final String name;
|
||||
private String group;
|
||||
private int cid;
|
||||
private final int cid;
|
||||
private int channel;
|
||||
private boolean visible;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param characterId
|
||||
* @param channel should be -1 if the buddy is offline
|
||||
* @param channel should be -1 if the buddy is offline
|
||||
* @param visible
|
||||
*/
|
||||
public BuddylistEntry(String name, String group, int characterId, int channel, boolean visible) {
|
||||
@@ -102,9 +101,6 @@ public class BuddylistEntry {
|
||||
return false;
|
||||
}
|
||||
final BuddylistEntry other = (BuddylistEntry) obj;
|
||||
if (cid != other.cid) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return cid == other.cid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
package client;
|
||||
|
||||
public class CharacterNameAndId {
|
||||
private int id;
|
||||
private String name;
|
||||
private final int id;
|
||||
private final String name;
|
||||
|
||||
public CharacterNameAndId(int id, String name) {
|
||||
super();
|
||||
|
||||
@@ -153,7 +153,7 @@ public class Client extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
public static Client createMock() {
|
||||
return new Client(null, -1,null, null, -123, -123);
|
||||
return new Client(null, -1, null, null, -123, -123);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -447,7 +447,9 @@ public class FamilyEntry {
|
||||
public synchronized boolean isJunior(FamilyEntry entry) { //require locking since result accuracy is vital
|
||||
if (juniors[0] == entry) {
|
||||
return true;
|
||||
} else return juniors[1] == entry;
|
||||
} else {
|
||||
return juniors[1] == entry;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean removeJunior(FamilyEntry junior) {
|
||||
|
||||
@@ -37,12 +37,12 @@ import java.util.concurrent.locks.Lock;
|
||||
|
||||
public final class MonsterBook {
|
||||
private static final Semaphore semaphore = new Semaphore(10);
|
||||
|
||||
|
||||
private int specialCard = 0;
|
||||
private int normalCard = 0;
|
||||
private int bookLevel = 1;
|
||||
private Map<Integer, Integer> cards = new LinkedHashMap<>();
|
||||
private Lock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.BOOK);
|
||||
private final Map<Integer, Integer> cards = new LinkedHashMap<>();
|
||||
private final Lock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.BOOK);
|
||||
|
||||
public Set<Entry<Integer, Integer>> getCardSet() {
|
||||
lock.lock();
|
||||
@@ -52,23 +52,23 @@ public final class MonsterBook {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addCard(final Client c, final int cardid) {
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), PacketCreator.showForeignCardEffect(c.getPlayer().getId()), false);
|
||||
|
||||
|
||||
Integer qty;
|
||||
lock.lock();
|
||||
try {
|
||||
qty = cards.get(cardid);
|
||||
|
||||
if(qty != null) {
|
||||
if(qty < 5) {
|
||||
|
||||
if (qty != null) {
|
||||
if (qty < 5) {
|
||||
cards.put(cardid, qty + 1);
|
||||
}
|
||||
} else {
|
||||
cards.put(cardid, 1);
|
||||
qty = 0;
|
||||
|
||||
|
||||
if (cardid / 1000 >= 2388) {
|
||||
specialCard++;
|
||||
} else {
|
||||
@@ -78,12 +78,12 @@ public final class MonsterBook {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
if(qty < 5) {
|
||||
|
||||
if (qty < 5) {
|
||||
if (qty == 0) { // leveling system only accounts unique cards
|
||||
calculateLevel();
|
||||
}
|
||||
|
||||
|
||||
c.sendPacket(PacketCreator.addCard(false, cardid, qty + 1));
|
||||
c.sendPacket(PacketCreator.showGainCard());
|
||||
} else {
|
||||
@@ -95,13 +95,13 @@ public final class MonsterBook {
|
||||
lock.lock();
|
||||
try {
|
||||
int collectionExp = (normalCard + specialCard);
|
||||
|
||||
|
||||
int level = 0, expToNextlevel = 1;
|
||||
do {
|
||||
level++;
|
||||
expToNextlevel += level * 10;
|
||||
} while (collectionExp >= expToNextlevel);
|
||||
|
||||
|
||||
bookLevel = level; // thanks IxianMace for noticing book level differing between book UI and character info UI
|
||||
} finally {
|
||||
lock.unlock();
|
||||
@@ -183,16 +183,16 @@ public final class MonsterBook {
|
||||
private static int saveStringConcat(char[] data, int pos, Integer i) {
|
||||
return saveStringConcat(data, pos, i.toString());
|
||||
}
|
||||
|
||||
|
||||
private static int saveStringConcat(char[] data, int pos, String s) {
|
||||
int len = s.length();
|
||||
for(int j = 0; j < len; j++) {
|
||||
for (int j = 0; j < len; j++) {
|
||||
data[pos + j] = s.charAt(j);
|
||||
}
|
||||
|
||||
|
||||
return pos + len;
|
||||
}
|
||||
|
||||
|
||||
private static String getSaveString(Integer charid, Set<Entry<Integer, Integer>> cardSet) {
|
||||
semaphore.acquireUninterruptibly();
|
||||
try {
|
||||
@@ -210,13 +210,13 @@ public final class MonsterBook {
|
||||
i = saveStringConcat(save, i, all.getValue()); //1 char due to being 0 ~ 5
|
||||
i = saveStringConcat(save, i, "),");
|
||||
}
|
||||
|
||||
|
||||
return new String(save, 0, i - 1);
|
||||
} finally {
|
||||
semaphore.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void saveCards(final int charid) {
|
||||
Set<Entry<Integer, Integer>> cardSet = getCardSet();
|
||||
|
||||
@@ -237,7 +237,7 @@ public final class MonsterBook {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int[] getCardTierSize() {
|
||||
try (Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) FROM monstercarddata GROUP BY floor(cardid / 1000);", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
|
||||
@@ -28,11 +28,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Skill {
|
||||
private int id;
|
||||
private List<StatEffect> effects = new ArrayList<>();
|
||||
private final int id;
|
||||
private final List<StatEffect> effects = new ArrayList<>();
|
||||
private Element element;
|
||||
private int animationTime;
|
||||
private int job;
|
||||
private final int job;
|
||||
private boolean action;
|
||||
|
||||
public Skill(int id) {
|
||||
@@ -54,18 +54,18 @@ public class Skill {
|
||||
|
||||
public boolean isFourthJob() {
|
||||
if (job == 2212) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
if (id == 22170001 || id == 22171003 || id == 22171004 || id == 22181002 || id == 22181003) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
return job % 10 == 2;
|
||||
return job % 10 == 2;
|
||||
}
|
||||
|
||||
public void setElement(Element elem) {
|
||||
element = elem;
|
||||
}
|
||||
|
||||
|
||||
public Element getElement() {
|
||||
return element;
|
||||
}
|
||||
@@ -73,11 +73,11 @@ public class Skill {
|
||||
public int getAnimationTime() {
|
||||
return animationTime;
|
||||
}
|
||||
|
||||
|
||||
public void setAnimationTime(int time) {
|
||||
animationTime = time;
|
||||
}
|
||||
|
||||
|
||||
public void incAnimationTime(int time) {
|
||||
animationTime += time;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class Skill {
|
||||
public boolean isBeginnerSkill() {
|
||||
return id % 10000000 < 10000;
|
||||
}
|
||||
|
||||
|
||||
public void setAction(boolean act) {
|
||||
action = act;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class Skill {
|
||||
public boolean getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
public void addLevelEffect(StatEffect effect) {
|
||||
effects.add(effect);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SkillFactory {
|
||||
|
||||
skills = loadedSkills;
|
||||
}
|
||||
|
||||
|
||||
private static Skill loadFromData(int id, Data data) {
|
||||
Skill ret = new Skill(id);
|
||||
boolean isBuff = false;
|
||||
@@ -77,7 +77,7 @@ public class SkillFactory {
|
||||
} else {
|
||||
Data action_ = data.getChildByPath("action");
|
||||
boolean action = false;
|
||||
if (action_ == null) {
|
||||
if (action_ == null) {
|
||||
if (data.getChildByPath("prepare/action") != null) {
|
||||
action = true;
|
||||
} else {
|
||||
@@ -88,10 +88,10 @@ public class SkillFactory {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
action = true;
|
||||
}
|
||||
ret.setAction(action);
|
||||
} else {
|
||||
action = true;
|
||||
}
|
||||
ret.setAction(action);
|
||||
Data hit = data.getChildByPath("hit");
|
||||
Data ball = data.getChildByPath("ball");
|
||||
isBuff = effect != null && hit == null && ball == null;
|
||||
@@ -185,7 +185,7 @@ public class SkillFactory {
|
||||
case ILMage.SEAL:
|
||||
case ILWizard.SLOW:
|
||||
case ILMage.SPELL_BOOSTER:
|
||||
case ILArchMage.HEROS_WILL:
|
||||
case ILArchMage.HEROS_WILL:
|
||||
case ILArchMage.INFINITY:
|
||||
case ILArchMage.MANA_REFLECTION:
|
||||
case ILArchMage.MAPLE_WARRIOR:
|
||||
@@ -227,7 +227,7 @@ public class SkillFactory {
|
||||
case Bandit.DAGGER_BOOSTER:
|
||||
case Bandit.HASTE:
|
||||
case ChiefBandit.MESO_GUARD:
|
||||
case ChiefBandit.PICKPOCKET:
|
||||
case ChiefBandit.PICKPOCKET:
|
||||
case Shadower.HEROS_WILL:
|
||||
case Shadower.MAPLE_WARRIOR:
|
||||
case Shadower.NINJA_AMBUSH:
|
||||
@@ -339,8 +339,9 @@ public class SkillFactory {
|
||||
}
|
||||
if (data.getChildByPath(skill.toString()) != null) {
|
||||
for (Data skilldata : data.getChildByPath(skill.toString()).getChildren()) {
|
||||
if (skilldata.getName().equals("name"))
|
||||
if (skilldata.getName().equals("name")) {
|
||||
return DataTool.getString(skilldata, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ public class SkillMacro {
|
||||
private int skill1;
|
||||
private int skill2;
|
||||
private int skill3;
|
||||
private String name;
|
||||
private int shout;
|
||||
private int position;
|
||||
private final String name;
|
||||
private final int shout;
|
||||
private final int position;
|
||||
|
||||
public SkillMacro(int skill1, int skill2, int skill3, String name, int shout, int position) {
|
||||
this.skill1 = skill1;
|
||||
@@ -49,7 +49,7 @@ public class SkillMacro {
|
||||
public int getSkill3() {
|
||||
return skill3;
|
||||
}
|
||||
|
||||
|
||||
public void setSkill1(int skill) {
|
||||
skill1 = skill;
|
||||
}
|
||||
|
||||
@@ -30,75 +30,74 @@ import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
public enum AutobanFactory {
|
||||
MOB_COUNT,
|
||||
GENERAL,
|
||||
FIX_DAMAGE,
|
||||
DAMAGE_HACK(15, 60 * 1000),
|
||||
DISTANCE_HACK(10, 120 * 1000),
|
||||
PORTAL_DISTANCE(5, 30000),
|
||||
PACKET_EDIT,
|
||||
ACC_HACK,
|
||||
CREATION_GENERATOR,
|
||||
HIGH_HP_HEALING,
|
||||
FAST_HP_HEALING(15),
|
||||
FAST_MP_HEALING(20, 30000),
|
||||
GACHA_EXP,
|
||||
TUBI(20, 15000),
|
||||
SHORT_ITEM_VAC,
|
||||
ITEM_VAC,
|
||||
FAST_ITEM_PICKUP(5, 30000),
|
||||
FAST_ATTACK(10, 30000),
|
||||
MPCON(25, 30000);
|
||||
MOB_COUNT,
|
||||
GENERAL,
|
||||
FIX_DAMAGE,
|
||||
DAMAGE_HACK(15, 60 * 1000),
|
||||
DISTANCE_HACK(10, 120 * 1000),
|
||||
PORTAL_DISTANCE(5, 30000),
|
||||
PACKET_EDIT,
|
||||
ACC_HACK,
|
||||
CREATION_GENERATOR,
|
||||
HIGH_HP_HEALING,
|
||||
FAST_HP_HEALING(15),
|
||||
FAST_MP_HEALING(20, 30000),
|
||||
GACHA_EXP,
|
||||
TUBI(20, 15000),
|
||||
SHORT_ITEM_VAC,
|
||||
ITEM_VAC,
|
||||
FAST_ITEM_PICKUP(5, 30000),
|
||||
FAST_ATTACK(10, 30000),
|
||||
MPCON(25, 30000);
|
||||
|
||||
private int points;
|
||||
private long expiretime;
|
||||
private final int points;
|
||||
private final long expiretime;
|
||||
|
||||
private AutobanFactory() {
|
||||
this(1, -1);
|
||||
}
|
||||
AutobanFactory() {
|
||||
this(1, -1);
|
||||
}
|
||||
|
||||
private AutobanFactory(int points) {
|
||||
this.points = points;
|
||||
this.expiretime = -1;
|
||||
}
|
||||
AutobanFactory(int points) {
|
||||
this.points = points;
|
||||
this.expiretime = -1;
|
||||
}
|
||||
|
||||
private AutobanFactory(int points, long expire) {
|
||||
this.points = points;
|
||||
this.expiretime = expire;
|
||||
}
|
||||
AutobanFactory(int points, long expire) {
|
||||
this.points = points;
|
||||
this.expiretime = expire;
|
||||
}
|
||||
|
||||
public int getMaximum() {
|
||||
return points;
|
||||
}
|
||||
public int getMaximum() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public long getExpire() {
|
||||
return expiretime;
|
||||
}
|
||||
public long getExpire() {
|
||||
return expiretime;
|
||||
}
|
||||
|
||||
public void addPoint(AutobanManager ban, String reason) {
|
||||
ban.addPoint(this, reason);
|
||||
}
|
||||
|
||||
public void alert(Character chr, String reason) {
|
||||
if(YamlConfig.config.server.USE_AUTOBAN == true) {
|
||||
if (chr != null && MapleLogger.ignored.contains(chr.getId())){
|
||||
return;
|
||||
}
|
||||
Server.getInstance().broadcastGMMessage((chr != null ? chr.getWorld() : 0), PacketCreator.sendYellowTip((chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason));
|
||||
public void addPoint(AutobanManager ban, String reason) {
|
||||
ban.addPoint(this, reason);
|
||||
}
|
||||
|
||||
public void alert(Character chr, String reason) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN == true) {
|
||||
if (chr != null && MapleLogger.ignored.contains(chr.getId())) {
|
||||
return;
|
||||
}
|
||||
Server.getInstance().broadcastGMMessage((chr != null ? chr.getWorld() : 0), PacketCreator.sendYellowTip((chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason));
|
||||
}
|
||||
if (YamlConfig.config.server.USE_AUTOBAN_LOG) {
|
||||
FilePrinter.print(FilePrinter.AUTOBAN_WARNING, (chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason);
|
||||
}
|
||||
}
|
||||
|
||||
public void autoban(Character chr, String value) {
|
||||
if(YamlConfig.config.server.USE_AUTOBAN == true) {
|
||||
chr.autoban("Autobanned for (" + this.name() + ": " + value + ")");
|
||||
//chr.sendPolice("You will be disconnected for (" + this.name() + ": " + value + ")");
|
||||
}
|
||||
}
|
||||
FilePrinter.print(FilePrinter.AUTOBAN_WARNING, (chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason);
|
||||
}
|
||||
}
|
||||
|
||||
public void autoban(Character chr, String value) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN == true) {
|
||||
chr.autoban("Autobanned for (" + this.name() + ": " + value + ")");
|
||||
//chr.sendPolice("You will be disconnected for (" + this.name() + ": " + value + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,18 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevintjuh93
|
||||
*/
|
||||
public class AutobanManager {
|
||||
private Character chr;
|
||||
private Map<AutobanFactory, Integer> points = new HashMap<>();
|
||||
private Map<AutobanFactory, Long> lastTime = new HashMap<>();
|
||||
private final Character chr;
|
||||
private final Map<AutobanFactory, Integer> points = new HashMap<>();
|
||||
private final Map<AutobanFactory, Long> lastTime = new HashMap<>();
|
||||
private int misses = 0;
|
||||
private int lastmisses = 0;
|
||||
private int samemisscount = 0;
|
||||
private long[] spam = new long[20];
|
||||
private int[] timestamp = new int[20];
|
||||
private byte[] timestampcounter = new byte[20];
|
||||
private final long[] spam = new long[20];
|
||||
private final int[] timestamp = new int[20];
|
||||
private final byte[] timestampcounter = new byte[20];
|
||||
|
||||
|
||||
public AutobanManager(Character chr) {
|
||||
@@ -34,23 +33,25 @@ public class AutobanManager {
|
||||
}
|
||||
|
||||
public void addPoint(AutobanFactory fac, String reason) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
if (chr.isGM() || chr.isBanned()){
|
||||
return;
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
if (chr.isGM() || chr.isBanned()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (lastTime.containsKey(fac)) {
|
||||
if (lastTime.get(fac) < (Server.getInstance().getCurrentTime() - fac.getExpire())) {
|
||||
points.put(fac, points.get(fac) / 2); //So the points are not completely gone.
|
||||
}
|
||||
}
|
||||
if (fac.getExpire() != -1)
|
||||
if (fac.getExpire() != -1) {
|
||||
lastTime.put(fac, Server.getInstance().getCurrentTime());
|
||||
}
|
||||
|
||||
if (points.containsKey(fac)) {
|
||||
points.put(fac, points.get(fac) + 1);
|
||||
} else
|
||||
} else {
|
||||
points.put(fac, 1);
|
||||
}
|
||||
|
||||
if (points.get(fac) >= fac.getMaximum()) {
|
||||
chr.autoban(reason);
|
||||
@@ -70,20 +71,21 @@ public class AutobanManager {
|
||||
if (lastmisses == misses && misses > 6) {
|
||||
samemisscount++;
|
||||
}
|
||||
if (samemisscount > 4)
|
||||
chr.sendPolice("You will be disconnected for miss godmode.");
|
||||
//chr.autoban("Autobanned for : " + misses + " Miss godmode", 1);
|
||||
else if (samemisscount > 0)
|
||||
|
||||
this.lastmisses = misses;
|
||||
if (samemisscount > 4) {
|
||||
chr.sendPolice("You will be disconnected for miss godmode.");
|
||||
}
|
||||
//chr.autoban("Autobanned for : " + misses + " Miss godmode", 1);
|
||||
else if (samemisscount > 0) {
|
||||
this.lastmisses = misses;
|
||||
}
|
||||
this.misses = 0;
|
||||
}
|
||||
|
||||
|
||||
//Don't use the same type for more than 1 thing
|
||||
public void spam(int type) {
|
||||
this.spam[type] = Server.getInstance().getCurrentTime();
|
||||
}
|
||||
|
||||
|
||||
public void spam(int type, int timestamp) {
|
||||
this.spam[type] = timestamp;
|
||||
}
|
||||
@@ -95,7 +97,7 @@ public class AutobanManager {
|
||||
/**
|
||||
* Timestamp checker
|
||||
*
|
||||
* <code>type</code>:<br>
|
||||
* <code>type</code>:<br>
|
||||
* 1: Pet Food<br>
|
||||
* 2: InventoryMerge<br>
|
||||
* 3: InventorySort<br>
|
||||
@@ -110,13 +112,13 @@ public class AutobanManager {
|
||||
* @return Timestamp checker
|
||||
*/
|
||||
public void setTimestamp(int type, int time, int times) {
|
||||
if (this.timestamp[type] == time) {
|
||||
if (this.timestamp[type] == time) {
|
||||
this.timestampcounter[type]++;
|
||||
if (this.timestampcounter[type] >= times) {
|
||||
if (YamlConfig.config.server.USE_AUTOBAN) {
|
||||
chr.getClient().disconnect(false, false);
|
||||
}
|
||||
|
||||
|
||||
FilePrinter.print(FilePrinter.EXPLOITS, "Player " + chr + " was caught spamming TYPE " + type + " and has been disconnected.");
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class Command {
|
||||
protected void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public int getRank() {
|
||||
return rank;
|
||||
}
|
||||
|
||||
@@ -38,29 +38,29 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class CommandsExecutor {
|
||||
|
||||
|
||||
public static CommandsExecutor instance = new CommandsExecutor();
|
||||
|
||||
|
||||
public static CommandsExecutor getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
private static final char USER_HEADING = '@';
|
||||
private static final char GM_HEADING = '!';
|
||||
|
||||
public static boolean isCommand(Client client, String content){
|
||||
|
||||
public static boolean isCommand(Client client, String content) {
|
||||
char heading = content.charAt(0);
|
||||
if (client.getPlayer().isGM()){
|
||||
if (client.getPlayer().isGM()) {
|
||||
return heading == USER_HEADING || heading == GM_HEADING;
|
||||
}
|
||||
return heading == USER_HEADING;
|
||||
}
|
||||
|
||||
private HashMap<String, Command> registeredCommands = new HashMap<>();
|
||||
private final HashMap<String, Command> registeredCommands = new HashMap<>();
|
||||
private Pair<List<String>, List<String>> levelCommandsCursor;
|
||||
private List<Pair<List<String>, List<String>>> commandsNameDesc = new ArrayList<>();
|
||||
private final List<Pair<List<String>, List<String>>> commandsNameDesc = new ArrayList<>();
|
||||
|
||||
private CommandsExecutor(){
|
||||
private CommandsExecutor() {
|
||||
registerLv0Commands();
|
||||
registerLv1Commands();
|
||||
registerLv2Commands();
|
||||
@@ -73,8 +73,8 @@ public class CommandsExecutor {
|
||||
public List<Pair<List<String>, List<String>>> getGmCommands() {
|
||||
return commandsNameDesc;
|
||||
}
|
||||
|
||||
public void handle(Client client, String message){
|
||||
|
||||
public void handle(Client client, String message) {
|
||||
if (client.tryacquireClient()) {
|
||||
try {
|
||||
handleInternal(client, message);
|
||||
@@ -85,8 +85,8 @@ public class CommandsExecutor {
|
||||
client.getPlayer().dropMessage(5, "Try again in a while... Latest commands are currently being processed.");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleInternal(Client client, String message){
|
||||
|
||||
private void handleInternal(Client client, String message) {
|
||||
if (client.getPlayer().getMapId() == 300000012) {
|
||||
client.getPlayer().yellowMessage("You do not have permission to use commands while in jail.");
|
||||
return;
|
||||
@@ -96,17 +96,17 @@ public class CommandsExecutor {
|
||||
if (splitedMessage.length < 2) {
|
||||
splitedMessage = new String[]{splitedMessage[0], ""};
|
||||
}
|
||||
|
||||
|
||||
client.getPlayer().setLastCommandMessage(splitedMessage[1]); // thanks Tochi & Nulliphite for noticing string messages being marshalled lowercase
|
||||
final String commandName = splitedMessage[0].toLowerCase();
|
||||
final String[] lowercaseParams = splitedMessage[1].toLowerCase().split(splitRegex);
|
||||
|
||||
|
||||
final Command command = registeredCommands.get(commandName);
|
||||
if (command == null){
|
||||
if (command == null) {
|
||||
client.getPlayer().yellowMessage("Command '" + commandName + "' is not available. See @commands for a list of available commands.");
|
||||
return;
|
||||
}
|
||||
if (client.getPlayer().gmLevel() < command.getRank()){
|
||||
if (client.getPlayer().gmLevel() < command.getRank()) {
|
||||
client.getPlayer().yellowMessage("You do not have permission to use this command.");
|
||||
return;
|
||||
}
|
||||
@@ -116,12 +116,12 @@ public class CommandsExecutor {
|
||||
} else {
|
||||
params = new String[]{};
|
||||
}
|
||||
|
||||
|
||||
command.execute(client, params);
|
||||
writeLog(client, message);
|
||||
}
|
||||
|
||||
private void writeLog(Client client, String command){
|
||||
private void writeLog(Client client, String command) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm");
|
||||
FilePrinter.print(FilePrinter.USED_COMMANDS, client.getPlayer().getName() + " used: " + command + " on "
|
||||
+ sdf.format(Calendar.getInstance().getTime()));
|
||||
@@ -131,41 +131,42 @@ public class CommandsExecutor {
|
||||
try {
|
||||
levelCommandsCursor.getRight().add(commandClass.newInstance().getDescription());
|
||||
levelCommandsCursor.getLeft().add(name);
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void addCommand(String[] syntaxs, Class<? extends Command> commandClass){
|
||||
for (String syntax : syntaxs){
|
||||
|
||||
private void addCommand(String[] syntaxs, Class<? extends Command> commandClass) {
|
||||
for (String syntax : syntaxs) {
|
||||
addCommand(syntax, 0, commandClass);
|
||||
}
|
||||
}
|
||||
private void addCommand(String syntax, Class<? extends Command> commandClass){
|
||||
|
||||
private void addCommand(String syntax, Class<? extends Command> commandClass) {
|
||||
//for (String syntax : syntaxs){
|
||||
addCommand(syntax, 0, commandClass);
|
||||
addCommand(syntax, 0, commandClass);
|
||||
//}
|
||||
}
|
||||
|
||||
private void addCommand(String[] surtaxes, int rank, Class<? extends Command> commandClass){
|
||||
for (String syntax : surtaxes){
|
||||
private void addCommand(String[] surtaxes, int rank, Class<? extends Command> commandClass) {
|
||||
for (String syntax : surtaxes) {
|
||||
addCommand(syntax, rank, commandClass);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCommand(String syntax, int rank, Class<? extends Command> commandClass){
|
||||
if (registeredCommands.containsKey(syntax.toLowerCase())){
|
||||
private void addCommand(String syntax, int rank, Class<? extends Command> commandClass) {
|
||||
if (registeredCommands.containsKey(syntax.toLowerCase())) {
|
||||
System.out.println("Error on register command with name: " + syntax + ". Already exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String commandName = syntax.toLowerCase();
|
||||
addCommandInfo(commandName, commandClass);
|
||||
|
||||
|
||||
try {
|
||||
Command commandInstance = commandClass.newInstance(); // thanks Halcyon for noticing commands getting reinstanced every call
|
||||
commandInstance.setRank(rank);
|
||||
|
||||
|
||||
registeredCommands.put(commandName, commandInstance);
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
@@ -174,9 +175,9 @@ public class CommandsExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerLv0Commands(){
|
||||
private void registerLv0Commands() {
|
||||
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
|
||||
|
||||
|
||||
addCommand(new String[]{"help", "commands"}, HelpCommand.class);
|
||||
addCommand("droplimit", DropLimitCommand.class);
|
||||
addCommand("time", TimeCommand.class);
|
||||
@@ -186,7 +187,7 @@ public class CommandsExecutor {
|
||||
addCommand("gacha", GachaCommand.class);
|
||||
addCommand("dispose", DisposeCommand.class);
|
||||
addCommand("changel", ChangeLanguageCommand.class);
|
||||
addCommand("equiplv", EquipLvCommand.class);
|
||||
addCommand("equiplv", EquipLvCommand.class);
|
||||
addCommand("showrates", ShowRatesCommand.class);
|
||||
addCommand("rates", RatesCommand.class);
|
||||
addCommand("online", OnlineCommand.class);
|
||||
@@ -205,26 +206,26 @@ public class CommandsExecutor {
|
||||
addCommand("mylawn", MapOwnerClaimCommand.class);
|
||||
addCommand("bosshp", BossHpCommand.class);
|
||||
addCommand("mobhp", MobHpCommand.class);
|
||||
|
||||
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
}
|
||||
|
||||
|
||||
private void registerLv1Commands() {
|
||||
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
|
||||
|
||||
|
||||
addCommand("whatdropsfrom", 1, WhatDropsFromCommand.class);
|
||||
addCommand("whodrops", 1, WhoDropsCommand.class);
|
||||
addCommand("buffme", 1, BuffMeCommand.class);
|
||||
addCommand("goto", 1, GotoCommand.class);
|
||||
|
||||
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
}
|
||||
|
||||
|
||||
private void registerLv2Commands(){
|
||||
private void registerLv2Commands() {
|
||||
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
|
||||
|
||||
|
||||
addCommand("recharge", 2, RechargeCommand.class);
|
||||
addCommand("whereami", 2, WhereaMiCommand.class);
|
||||
addCommand("hide", 2, HideCommand.class);
|
||||
@@ -261,13 +262,13 @@ public class CommandsExecutor {
|
||||
addCommand("id", 2, IdCommand.class);
|
||||
addCommand("gachalist", GachaListCommand.class);
|
||||
addCommand("loot", LootCommand.class);
|
||||
|
||||
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
}
|
||||
|
||||
private void registerLv3Commands() {
|
||||
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
|
||||
|
||||
|
||||
addCommand("debuff", 3, DebuffCommand.class);
|
||||
addCommand("fly", 3, FlyCommand.class);
|
||||
addCommand("spawn", 3, SpawnCommand.class);
|
||||
@@ -331,9 +332,9 @@ public class CommandsExecutor {
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
}
|
||||
|
||||
private void registerLv4Commands(){
|
||||
private void registerLv4Commands() {
|
||||
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
|
||||
|
||||
|
||||
addCommand("servermessage", 4, ServerMessageCommand.class);
|
||||
addCommand("proitem", 4, ProItemCommand.class);
|
||||
addCommand("seteqstat", 4, SetEqStatCommand.class);
|
||||
@@ -358,26 +359,26 @@ public class CommandsExecutor {
|
||||
addCommand("pnpcremove", 4, PnpcRemoveCommand.class);
|
||||
addCommand("pmob", 4, PmobCommand.class);
|
||||
addCommand("pmobremove", 4, PmobRemoveCommand.class);
|
||||
|
||||
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
}
|
||||
|
||||
private void registerLv5Commands(){
|
||||
private void registerLv5Commands() {
|
||||
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
|
||||
|
||||
|
||||
addCommand("debug", 5, DebugCommand.class);
|
||||
addCommand("set", 5, SetCommand.class);
|
||||
addCommand("showpackets", 5, ShowPacketsCommand.class);
|
||||
addCommand("showmovelife", 5, ShowMoveLifeCommand.class);
|
||||
addCommand("showsessions", 5, ShowSessionsCommand.class);
|
||||
addCommand("iplist", 5, IpListCommand.class);
|
||||
|
||||
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
}
|
||||
|
||||
private void registerLv6Commands(){
|
||||
private void registerLv6Commands() {
|
||||
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
|
||||
|
||||
|
||||
addCommand("setgmlevel", 6, SetGmLevelCommand.class);
|
||||
addCommand("warpworld", 6, WarpWorldCommand.class);
|
||||
addCommand("saveall", 6, SaveAllCommand.class);
|
||||
@@ -394,7 +395,7 @@ public class CommandsExecutor {
|
||||
addCommand("addworld", 6, ServerAddWorldCommand.class);
|
||||
addCommand("removechannel", 6, ServerRemoveChannelCommand.class);
|
||||
addCommand("removeworld", 6, ServerRemoveWorldCommand.class);
|
||||
|
||||
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,14 +31,14 @@ public class BuyBackCommand extends Command {
|
||||
{
|
||||
setDescription("Revive yourself after a death.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
if (params.length < 1) {
|
||||
c.getPlayer().yellowMessage("Syntax: @buyback <info|now>");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (params[0].contentEquals("now")) {
|
||||
BuybackProcessor.processBuyback(c);
|
||||
} else {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class DisposeCommand extends Command {
|
||||
{
|
||||
setDescription("Dispose to fix NPC chat.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
NPCScriptManager.getInstance().dispose(c);
|
||||
|
||||
@@ -31,11 +31,11 @@ public class DropLimitCommand extends Command {
|
||||
{
|
||||
setDescription("Check drop limit of current map.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
int dropCount = c.getPlayer().getMap().getDroppedItemCount();
|
||||
if(((float) dropCount) / YamlConfig.config.server.ITEM_LIMIT_ON_MAP < 0.75f) {
|
||||
if (((float) dropCount) / YamlConfig.config.server.ITEM_LIMIT_ON_MAP < 0.75f) {
|
||||
c.getPlayer().showHint("Current drop count: #b" + dropCount + "#k / #e" + YamlConfig.config.server.ITEM_LIMIT_ON_MAP + "#n", 300);
|
||||
} else {
|
||||
c.getPlayer().showHint("Current drop count: #r" + dropCount + "#k / #e" + YamlConfig.config.server.ITEM_LIMIT_ON_MAP + "#n", 300);
|
||||
|
||||
@@ -38,29 +38,29 @@ public class GachaCommand extends Command {
|
||||
Gachapon.GachaponType gacha = null;
|
||||
String search = c.getPlayer().getLastCommandMessage();
|
||||
String gachaName = "";
|
||||
String [] names = {"Henesys", "Ellinia", "Perion", "Kerning City", "Sleepywood", "Mushroom Shrine", "Showa Spa Male", "Showa Spa Female", "New Leaf City", "Nautilus Harbor"};
|
||||
int [] ids = {9100100, 9100101, 9100102, 9100103, 9100104, 9100105, 9100106, 9100107, 9100109, 9100117};
|
||||
for (int i = 0; i < names.length; i++){
|
||||
if (search.equalsIgnoreCase(names[i])){
|
||||
String[] names = {"Henesys", "Ellinia", "Perion", "Kerning City", "Sleepywood", "Mushroom Shrine", "Showa Spa Male", "Showa Spa Female", "New Leaf City", "Nautilus Harbor"};
|
||||
int[] ids = {9100100, 9100101, 9100102, 9100103, 9100104, 9100105, 9100106, 9100107, 9100109, 9100117};
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
if (search.equalsIgnoreCase(names[i])) {
|
||||
gachaName = names[i];
|
||||
gacha = Gachapon.GachaponType.getByNpcId(ids[i]);
|
||||
}
|
||||
}
|
||||
if (gacha == null){
|
||||
if (gacha == null) {
|
||||
c.getPlayer().yellowMessage("Please use @gacha <name> where name corresponds to one of the below:");
|
||||
for (String name : names){
|
||||
for (String name : names) {
|
||||
c.getPlayer().yellowMessage(name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
String talkStr = "The #b" + gachaName + "#k Gachapon contains the following items.\r\n\r\n";
|
||||
for (int i = 0; i < 2; i++){
|
||||
for (int id : gacha.getItems(i)){
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int id : gacha.getItems(i)) {
|
||||
talkStr += "-" + ItemInformationProvider.getInstance().getName(id) + "\r\n";
|
||||
}
|
||||
}
|
||||
talkStr += "\r\nPlease keep in mind that there are items that are in all gachapons and are not listed here.";
|
||||
|
||||
|
||||
c.getAbstractPlayerInteraction().npcTalk(9010000, talkStr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,15 +37,16 @@ public class JoinEventCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
if(!FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
|
||||
if (!FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
|
||||
Event event = c.getChannelServer().getEvent();
|
||||
if(event != null) {
|
||||
if(event.getMapId() != player.getMapId()) {
|
||||
if(event.getLimit() > 0) {
|
||||
if (event != null) {
|
||||
if (event.getMapId() != player.getMapId()) {
|
||||
if (event.getLimit() > 0) {
|
||||
player.saveLocation("EVENT");
|
||||
|
||||
if(event.getMapId() == 109080000 || event.getMapId() == 109060001)
|
||||
if (event.getMapId() == 109080000 || event.getMapId() == 109060001) {
|
||||
player.setTeam(event.getLimit() % 2);
|
||||
}
|
||||
|
||||
event.minusLimit();
|
||||
|
||||
|
||||
@@ -36,19 +36,19 @@ public class LeaveEventCommand extends Command {
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
int returnMap = player.getSavedLocation("EVENT");
|
||||
if(returnMap != -1) {
|
||||
if(player.getOla() != null) {
|
||||
if (returnMap != -1) {
|
||||
if (player.getOla() != null) {
|
||||
player.getOla().resetTimes();
|
||||
player.setOla(null);
|
||||
}
|
||||
if(player.getFitness() != null) {
|
||||
if (player.getFitness() != null) {
|
||||
player.getFitness().resetTimes();
|
||||
player.setFitness(null);
|
||||
}
|
||||
|
||||
player.saveLocationOnWarp();
|
||||
player.changeMap(returnMap);
|
||||
if(c.getChannelServer().getEvent() != null) {
|
||||
if (c.getChannelServer().getEvent() != null) {
|
||||
c.getChannelServer().getEvent().addLimit();
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class MapOwnerClaimCommand extends Command {
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
Character chr = c.getPlayer();
|
||||
|
||||
|
||||
if (YamlConfig.config.server.USE_MAP_OWNERSHIP_SYSTEM) {
|
||||
if (chr.getEventInstance() == null) {
|
||||
MapleMap map = chr.getMap();
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RanksCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
|
||||
List<Pair<String, Integer>> worldRanking = Server.getInstance().getWorldPlayerRanking(player.getWorld());
|
||||
player.sendPacket(GuildPackets.showPlayerRanks(9010000, worldRanking));
|
||||
}
|
||||
|
||||
@@ -36,14 +36,16 @@ public class RatesCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
|
||||
// travel rates not applicable since it's intrinsically a server/environment rate rather than a character rate
|
||||
String showMsg_ = "#eCHARACTER RATES#n" + "\r\n\r\n";
|
||||
showMsg_ += "EXP Rate: #e#b" + player.getExpRate() + "x#k#n" + (player.hasNoviceExpRate() ? " - novice rate" : "") + "\r\n";
|
||||
showMsg_ += "MESO Rate: #e#b" + player.getMesoRate() + "x#k#n" + "\r\n";
|
||||
showMsg_ += "DROP Rate: #e#b" + player.getDropRate() + "x#k#n" + "\r\n";
|
||||
showMsg_ += "BOSS DROP Rate: #e#b" + player.getBossDropRate() + "x#k#n" + "\r\n";
|
||||
if(YamlConfig.config.server.USE_QUEST_RATE) showMsg_ += "QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n";
|
||||
if (YamlConfig.config.server.USE_QUEST_RATE) {
|
||||
showMsg_ += "QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n";
|
||||
}
|
||||
|
||||
player.showHint(showMsg_, 300);
|
||||
}
|
||||
|
||||
@@ -39,32 +39,40 @@ public class ShowRatesCommand extends Command {
|
||||
String showMsg = "#eEXP RATE#n" + "\r\n";
|
||||
showMsg += "World EXP Rate: #k" + c.getWorldServer().getExpRate() + "x#k" + "\r\n";
|
||||
showMsg += "Player EXP Rate: #k" + player.getRawExpRate() + "x#k" + "\r\n";
|
||||
if(player.getCouponExpRate() != 1) showMsg += "Coupon EXP Rate: #k" + player.getCouponExpRate() + "x#k" + "\r\n";
|
||||
if (player.getCouponExpRate() != 1) {
|
||||
showMsg += "Coupon EXP Rate: #k" + player.getCouponExpRate() + "x#k" + "\r\n";
|
||||
}
|
||||
showMsg += "EXP Rate: #e#b" + player.getExpRate() + "x#k#n" + (player.hasNoviceExpRate() ? " - novice rate" : "") + "\r\n";
|
||||
|
||||
showMsg += "\r\n" + "#eMESO RATE#n" + "\r\n";
|
||||
showMsg += "World MESO Rate: #k" + c.getWorldServer().getMesoRate() + "x#k" + "\r\n";
|
||||
showMsg += "Player MESO Rate: #k" + player.getRawMesoRate() + "x#k" + "\r\n";
|
||||
if(player.getCouponMesoRate() != 1) showMsg += "Coupon MESO Rate: #k" + player.getCouponMesoRate() + "x#k" + "\r\n";
|
||||
if (player.getCouponMesoRate() != 1) {
|
||||
showMsg += "Coupon MESO Rate: #k" + player.getCouponMesoRate() + "x#k" + "\r\n";
|
||||
}
|
||||
showMsg += "MESO Rate: #e#b" + player.getMesoRate() + "x#k#n" + "\r\n";
|
||||
|
||||
showMsg += "\r\n" + "#eDROP RATE#n" + "\r\n";
|
||||
showMsg += "World DROP Rate: #k" + c.getWorldServer().getDropRate() + "x#k" + "\r\n";
|
||||
showMsg += "Player DROP Rate: #k" + player.getRawDropRate() + "x#k" + "\r\n";
|
||||
if(player.getCouponDropRate() != 1) showMsg += "Coupon DROP Rate: #k" + player.getCouponDropRate() + "x#k" + "\r\n";
|
||||
if (player.getCouponDropRate() != 1) {
|
||||
showMsg += "Coupon DROP Rate: #k" + player.getCouponDropRate() + "x#k" + "\r\n";
|
||||
}
|
||||
showMsg += "DROP Rate: #e#b" + player.getDropRate() + "x#k#n" + "\r\n";
|
||||
|
||||
|
||||
showMsg += "\r\n" + "#eBOSS DROP RATE#n" + "\r\n";
|
||||
showMsg += "World BOSS DROP Rate: #k" + c.getWorldServer().getBossDropRate() + "x#k" + "\r\n";
|
||||
showMsg += "Player DROP Rate: #k" + player.getRawDropRate() + "x#k" + "\r\n";
|
||||
if(player.getCouponDropRate() != 1) showMsg += "Coupon DROP Rate: #k" + player.getCouponDropRate() + "x#k" + "\r\n";
|
||||
if (player.getCouponDropRate() != 1) {
|
||||
showMsg += "Coupon DROP Rate: #k" + player.getCouponDropRate() + "x#k" + "\r\n";
|
||||
}
|
||||
showMsg += "BOSS DROP Rate: #e#b" + player.getBossDropRate() + "x#k#n" + "\r\n";
|
||||
|
||||
if(YamlConfig.config.server.USE_QUEST_RATE) {
|
||||
if (YamlConfig.config.server.USE_QUEST_RATE) {
|
||||
showMsg += "\r\n" + "#eQUEST RATE#n" + "\r\n";
|
||||
showMsg += "World QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n";
|
||||
}
|
||||
|
||||
|
||||
showMsg += "\r\n";
|
||||
showMsg += "World TRAVEL Rate: #e#b" + c.getWorldServer().getTravelRate() + "x#k#n" + "\r\n";
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class StatStrCommand extends Command {
|
||||
} else {
|
||||
amount = Math.min(remainingAp, YamlConfig.config.server.MAX_AP - player.getStr());
|
||||
}
|
||||
|
||||
|
||||
if (!player.assignStr(Math.max(amount, 0))) {
|
||||
player.dropMessage("Please make sure your AP is not over " + YamlConfig.config.server.MAX_AP + " and you have enough to distribute.");
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TimeCommand extends Command {
|
||||
{
|
||||
setDescription("Show current server time.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Client client, String[] params) {
|
||||
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
@@ -35,10 +35,10 @@ public class UptimeCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
long milliseconds = System.currentTimeMillis() - Server.uptime;
|
||||
int seconds = (int) (milliseconds / 1000) % 60 ;
|
||||
int minutes = (int) ((milliseconds / (1000*60)) % 60);
|
||||
int hours = (int) ((milliseconds / (1000*60*60)) % 24);
|
||||
int days = (int) ((milliseconds / (1000*60*60*24)));
|
||||
int seconds = (int) (milliseconds / 1000) % 60;
|
||||
int minutes = (int) ((milliseconds / (1000 * 60)) % 60);
|
||||
int hours = (int) ((milliseconds / (1000 * 60 * 60)) % 24);
|
||||
int days = (int) ((milliseconds / (1000 * 60 * 60 * 24)));
|
||||
c.getPlayer().yellowMessage("Server has been online for " + days + " days " + hours + " hours " + minutes + " minutes and " + seconds + " seconds.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ public class BossHpCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
for(Monster monster : player.getMap().getAllMonsters()) {
|
||||
if(monster != null && monster.isBoss() && monster.getHp() > 0) {
|
||||
for (Monster monster : player.getMap().getAllMonsters()) {
|
||||
if (monster != null && monster.isBoss() && monster.getHp() > 0) {
|
||||
long percent = monster.getHp() * 100L / monster.getMaxHp();
|
||||
String bar = "[";
|
||||
for (int i = 0; i < 100; i++){
|
||||
for (int i = 0; i < 100; i++) {
|
||||
bar += i < percent ? "|" : ".";
|
||||
}
|
||||
bar += "]";
|
||||
|
||||
@@ -36,16 +36,16 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class GotoCommand extends Command {
|
||||
|
||||
|
||||
{
|
||||
setDescription("Warp to a predefined map.");
|
||||
|
||||
|
||||
List<Entry<String, Integer>> towns = new ArrayList<>(GameConstants.GOTO_TOWNS.entrySet());
|
||||
sortGotoEntries(towns);
|
||||
|
||||
|
||||
try {
|
||||
// thanks shavit for noticing goto areas getting loaded from wz needlessly only for the name retrieval
|
||||
|
||||
|
||||
for (Map.Entry<String, Integer> e : towns) {
|
||||
GOTO_TOWNS_INFO += ("'" + e.getKey() + "' - #b" + (MapFactory.loadPlaceName(e.getValue())) + "#k\r\n");
|
||||
}
|
||||
@@ -57,16 +57,16 @@ public class GotoCommand extends Command {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
|
||||
GOTO_TOWNS_INFO = "(none)";
|
||||
GOTO_AREAS_INFO = "(none)";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String GOTO_TOWNS_INFO = "";
|
||||
public static String GOTO_AREAS_INFO = "";
|
||||
|
||||
|
||||
private static void sortGotoEntries(List<Entry<String, Integer>> listEntries) {
|
||||
listEntries.sort((e1, e2) -> e1.getValue().compareTo(e2.getValue()));
|
||||
}
|
||||
@@ -74,16 +74,16 @@ public class GotoCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1){
|
||||
if (params.length < 1) {
|
||||
String sendStr = "Syntax: #b@goto <map name>#k. Available areas:\r\n\r\n#rTowns:#k\r\n" + GOTO_TOWNS_INFO;
|
||||
if (player.isGM()) {
|
||||
sendStr += ("\r\n#rAreas:#k\r\n" + GOTO_AREAS_INFO);
|
||||
}
|
||||
|
||||
|
||||
player.getAbstractPlayerInteraction().npcTalk(9000020, sendStr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!player.isAlive()) {
|
||||
player.dropMessage(1, "This command cannot be used when you're dead.");
|
||||
return;
|
||||
@@ -103,10 +103,10 @@ public class GotoCommand extends Command {
|
||||
} else {
|
||||
gotomaps = GameConstants.GOTO_TOWNS;
|
||||
}
|
||||
|
||||
|
||||
if (gotomaps.containsKey(params[0])) {
|
||||
MapleMap target = c.getChannelServer().getMapFactory().getMap(gotomaps.get(params[0]));
|
||||
|
||||
|
||||
// expedition issue with this command detected thanks to Masterrulax
|
||||
Portal targetPortal = target.getRandomPlayerSpawnpoint();
|
||||
player.saveLocationOnWarp();
|
||||
@@ -117,7 +117,7 @@ public class GotoCommand extends Command {
|
||||
if (player.isGM()) {
|
||||
sendStr += ("\r\n#rAreas:#k\r\n" + GOTO_AREAS_INFO);
|
||||
}
|
||||
|
||||
|
||||
player.getAbstractPlayerInteraction().npcTalk(9000020, sendStr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MobHpCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
for(Monster monster : player.getMap().getAllMonsters()) {
|
||||
for (Monster monster : player.getMap().getAllMonsters()) {
|
||||
if (monster != null && monster.getHp() > 0) {
|
||||
player.yellowMessage(monster.getName() + " (" + monster.getId() + ") has " + monster.getHp() + " / " + monster.getMaxHp() + " HP.");
|
||||
|
||||
|
||||
@@ -50,20 +50,20 @@ public class WhatDropsFromCommand extends Command {
|
||||
int limit = 3;
|
||||
Iterator<Pair<Integer, String>> listIterator = MonsterInformationProvider.getMobsIDsFromName(monsterName).iterator();
|
||||
for (int i = 0; i < limit; i++) {
|
||||
if(listIterator.hasNext()) {
|
||||
if (listIterator.hasNext()) {
|
||||
Pair<Integer, String> data = listIterator.next();
|
||||
int mobId = data.getLeft();
|
||||
String mobName = data.getRight();
|
||||
output += mobName + " drops the following items:\r\n\r\n";
|
||||
for (MonsterDropEntry drop : MonsterInformationProvider.getInstance().retrieveDrop(mobId)){
|
||||
for (MonsterDropEntry drop : MonsterInformationProvider.getInstance().retrieveDrop(mobId)) {
|
||||
try {
|
||||
String name = ItemInformationProvider.getInstance().getName(drop.itemId);
|
||||
if (name == null || name.equals("null") || drop.chance == 0){
|
||||
if (name == null || name.equals("null") || drop.chance == 0) {
|
||||
continue;
|
||||
}
|
||||
float chance = Math.max(1000000 / drop.chance / (!MonsterInformationProvider.getInstance().isBoss(mobId) ? player.getDropRate() : player.getBossDropRate()), 1);
|
||||
output += "- " + name + " (1/" + (int) chance + ")\r\n";
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class WhatDropsFromCommand extends Command {
|
||||
output += "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
c.getAbstractPlayerInteraction().npcTalk(9010000, output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,16 +43,22 @@ public class ApCommand extends Command {
|
||||
|
||||
if (params.length < 2) {
|
||||
int newAp = Integer.parseInt(params[0]);
|
||||
if (newAp < 0) newAp = 0;
|
||||
else if (newAp > YamlConfig.config.server.MAX_AP) newAp = YamlConfig.config.server.MAX_AP;
|
||||
if (newAp < 0) {
|
||||
newAp = 0;
|
||||
} else if (newAp > YamlConfig.config.server.MAX_AP) {
|
||||
newAp = YamlConfig.config.server.MAX_AP;
|
||||
}
|
||||
|
||||
player.changeRemainingAp(newAp, false);
|
||||
} else {
|
||||
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
if (victim != null) {
|
||||
int newAp = Integer.parseInt(params[1]);
|
||||
if (newAp < 0) newAp = 0;
|
||||
else if (newAp > YamlConfig.config.server.MAX_AP) newAp = YamlConfig.config.server.MAX_AP;
|
||||
if (newAp < 0) {
|
||||
newAp = 0;
|
||||
} else if (newAp > YamlConfig.config.server.MAX_AP) {
|
||||
newAp = YamlConfig.config.server.MAX_AP;
|
||||
}
|
||||
|
||||
victim.changeRemainingAp(newAp, false);
|
||||
} else {
|
||||
|
||||
@@ -44,6 +44,8 @@ public class BuffCommand extends Command {
|
||||
int skillid = Integer.parseInt(params[0]);
|
||||
|
||||
Skill skill = SkillFactory.getSkill(skillid);
|
||||
if (skill != null) skill.getEffect(skill.getMaxLevel()).applyTo(player);
|
||||
if (skill != null) {
|
||||
skill.getEffect(skill.getMaxLevel()).applyTo(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ClearSavedLocationsCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer(), victim;
|
||||
|
||||
|
||||
if (params.length > 0) {
|
||||
victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
if (victim == null) {
|
||||
@@ -46,11 +46,11 @@ public class ClearSavedLocationsCommand extends Command {
|
||||
} else {
|
||||
victim = c.getPlayer();
|
||||
}
|
||||
|
||||
|
||||
for (SavedLocationType type : SavedLocationType.values()) {
|
||||
victim.clearSavedLocation(type);
|
||||
}
|
||||
|
||||
|
||||
player.message("Cleared " + params[0] + "'s saved locations.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,32 +47,37 @@ public class ClearSlotCommand extends Command {
|
||||
case "all":
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.USE).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.USE, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.ETC).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.ETC, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.SETUP).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.CASH).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.CASH, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("All Slots Cleared.");
|
||||
@@ -80,8 +85,9 @@ public class ClearSlotCommand extends Command {
|
||||
case "equip":
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("Equipment Slot Cleared.");
|
||||
@@ -89,8 +95,9 @@ public class ClearSlotCommand extends Command {
|
||||
case "use":
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.USE).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.USE, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("Use Slot Cleared.");
|
||||
@@ -98,8 +105,9 @@ public class ClearSlotCommand extends Command {
|
||||
case "setup":
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.SETUP).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("Set-Up Slot Cleared.");
|
||||
@@ -107,8 +115,9 @@ public class ClearSlotCommand extends Command {
|
||||
case "etc":
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.ETC).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.ETC, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("ETC Slot Cleared.");
|
||||
@@ -116,8 +125,9 @@ public class ClearSlotCommand extends Command {
|
||||
case "cash":
|
||||
for (int i = 0; i < 101; i++) {
|
||||
Item tempItem = c.getPlayer().getInventory(InventoryType.CASH).getItem((byte) i);
|
||||
if (tempItem == null)
|
||||
if (tempItem == null) {
|
||||
continue;
|
||||
}
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.CASH, (byte) i, tempItem.getQuantity(), false, false);
|
||||
}
|
||||
player.yellowMessage("Cash Slot Cleared.");
|
||||
|
||||
@@ -23,7 +23,6 @@ import client.Client;
|
||||
import client.command.Command;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class GachaListCommand extends Command {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class IdCommand extends Command {
|
||||
|
||||
if (resultList.size() > 0) {
|
||||
int count = 0;
|
||||
for (Map.Entry<String, String> entry: resultList.entrySet()) {
|
||||
for (Map.Entry<String, String> entry : resultList.entrySet()) {
|
||||
sb.append(String.format("Id for %s is: #b%s#k", entry.getKey(), entry.getValue()) + "\r\n");
|
||||
if (++count > 100) {
|
||||
break;
|
||||
@@ -65,7 +65,7 @@ public class IdCommand extends Command {
|
||||
player.yellowMessage("Error reading file, please contact your administrator.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ThreadManager.getInstance().newTask(queryRunnable);
|
||||
}
|
||||
|
||||
@@ -85,16 +85,20 @@ public class IdCommand extends Command {
|
||||
}
|
||||
|
||||
private String joinStringArr(String[] arr, String separator) {
|
||||
if (null == arr || 0 == arr.length) return "";
|
||||
if (null == arr || 0 == arr.length) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
sb.append(arr[0]);
|
||||
for (int i = 1; i < arr.length; i++) sb.append(separator).append(arr[i]);
|
||||
for (int i = 1; i < arr.length; i++) {
|
||||
sb.append(separator).append(arr[i]);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private Map<String, String> fetchResults(Map<String, String> queryMap, String queryItem) {
|
||||
Map<String, String> results = new HashMap<>();
|
||||
for (String item: queryMap.keySet()) {
|
||||
for (String item : queryMap.keySet()) {
|
||||
if (item.indexOf(queryItem) != -1) {
|
||||
results.put(item, queryMap.get(item));
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ItemCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !item <itemid> <quantity>");
|
||||
return;
|
||||
@@ -49,13 +49,15 @@ public class ItemCommand extends Command {
|
||||
int itemId = Integer.parseInt(params[0]);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
if(ii.getName(itemId) == null) {
|
||||
if (ii.getName(itemId) == null) {
|
||||
player.yellowMessage("Item id '" + params[0] + "' does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
short quantity = 1;
|
||||
if(params.length >= 2) quantity = Short.parseShort(params[1]);
|
||||
if (params.length >= 2) {
|
||||
quantity = Short.parseShort(params[1]);
|
||||
}
|
||||
|
||||
if (YamlConfig.config.server.BLOCK_GENERATE_CASH_ITEM && ii.isCash(itemId)) {
|
||||
player.yellowMessage("You cannot create a cash item with this command.");
|
||||
@@ -63,26 +65,26 @@ public class ItemCommand extends Command {
|
||||
}
|
||||
|
||||
if (ItemConstants.isPet(itemId)) {
|
||||
if (params.length >= 2){ // thanks to istreety & TacoBell
|
||||
quantity = 1;
|
||||
long days = Math.max(1, Integer.parseInt(params[1]));
|
||||
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
|
||||
int petid = Pet.createPet(itemId);
|
||||
if (params.length >= 2) { // thanks to istreety & TacoBell
|
||||
quantity = 1;
|
||||
long days = Math.max(1, Integer.parseInt(params[1]));
|
||||
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
|
||||
int petid = Pet.createPet(itemId);
|
||||
|
||||
InventoryManipulator.addById(c, itemId, quantity, player.getName(), petid, expiration);
|
||||
return;
|
||||
} else {
|
||||
player.yellowMessage("Pet Syntax: !item <itemid> <expiration>");
|
||||
return;
|
||||
}
|
||||
InventoryManipulator.addById(c, itemId, quantity, player.getName(), petid, expiration);
|
||||
return;
|
||||
} else {
|
||||
player.yellowMessage("Pet Syntax: !item <itemid> <expiration>");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
short flag = 0;
|
||||
if(player.gmLevel() < 3) {
|
||||
flag |= ItemConstants.ACCOUNT_SHARING;
|
||||
flag |= ItemConstants.UNTRADEABLE;
|
||||
if (player.gmLevel() < 3) {
|
||||
flag |= ItemConstants.ACCOUNT_SHARING;
|
||||
flag |= ItemConstants.UNTRADEABLE;
|
||||
}
|
||||
|
||||
|
||||
InventoryManipulator.addById(c, itemId, quantity, player.getName(), -1, flag, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ItemDropCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !drop <itemid> <quantity>");
|
||||
return;
|
||||
@@ -50,13 +50,15 @@ public class ItemDropCommand extends Command {
|
||||
int itemId = Integer.parseInt(params[0]);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
if(ii.getName(itemId) == null) {
|
||||
if (ii.getName(itemId) == null) {
|
||||
player.yellowMessage("Item id '" + params[0] + "' does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
short quantity = 1;
|
||||
if(params.length >= 2) quantity = Short.parseShort(params[1]);
|
||||
if (params.length >= 2) {
|
||||
quantity = Short.parseShort(params[1]);
|
||||
}
|
||||
|
||||
if (YamlConfig.config.server.BLOCK_GENERATE_CASH_ITEM && ii.isCash(itemId)) {
|
||||
player.yellowMessage("You cannot create a cash item with this command.");
|
||||
@@ -64,7 +66,7 @@ public class ItemDropCommand extends Command {
|
||||
}
|
||||
|
||||
if (ItemConstants.isPet(itemId)) {
|
||||
if (params.length >= 2){ // thanks to istreety & TacoBell
|
||||
if (params.length >= 2) { // thanks to istreety & TacoBell
|
||||
quantity = 1;
|
||||
long days = Math.max(1, Integer.parseInt(params[1]));
|
||||
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
|
||||
@@ -74,12 +76,12 @@ public class ItemDropCommand extends Command {
|
||||
toDrop.setExpiration(expiration);
|
||||
|
||||
toDrop.setOwner("");
|
||||
if(player.gmLevel() < 3) {
|
||||
if (player.gmLevel() < 3) {
|
||||
short f = toDrop.getFlag();
|
||||
f |= ItemConstants.ACCOUNT_SHARING;
|
||||
f |= ItemConstants.UNTRADEABLE;
|
||||
f |= ItemConstants.SANDBOX;
|
||||
|
||||
|
||||
toDrop.setFlag(f);
|
||||
toDrop.setOwner("TRIAL-MODE");
|
||||
}
|
||||
@@ -89,10 +91,10 @@ public class ItemDropCommand extends Command {
|
||||
return;
|
||||
} else {
|
||||
player.yellowMessage("Pet Syntax: !drop <itemid> <expiration>");
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Item toDrop;
|
||||
if (ItemConstants.getInventoryType(itemId) == InventoryType.EQUIP) {
|
||||
toDrop = ii.getEquipById(itemId);
|
||||
@@ -101,7 +103,7 @@ public class ItemDropCommand extends Command {
|
||||
}
|
||||
|
||||
toDrop.setOwner(player.getName());
|
||||
if(player.gmLevel() < 3) {
|
||||
if (player.gmLevel() < 3) {
|
||||
short f = toDrop.getFlag();
|
||||
f |= ItemConstants.ACCOUNT_SHARING;
|
||||
f |= ItemConstants.UNTRADEABLE;
|
||||
|
||||
@@ -45,7 +45,9 @@ public class LevelCommand extends Command {
|
||||
player.setLevel(Math.min(Integer.parseInt(params[0]), player.getMaxClassLevel()) - 1);
|
||||
|
||||
player.resetPlayerRates();
|
||||
if (YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL) player.setPlayerRates();
|
||||
if (YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL) {
|
||||
player.setPlayerRates();
|
||||
}
|
||||
player.setWorldRates();
|
||||
|
||||
player.levelUp(false);
|
||||
|
||||
@@ -45,7 +45,8 @@ public class MaxSkillCommand extends Command {
|
||||
} catch (NumberFormatException nfe) {
|
||||
nfe.printStackTrace();
|
||||
break;
|
||||
} catch (NullPointerException npe) { }
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getJob().isA(Job.ARAN1) || player.getJob().isA(Job.LEGEND)) {
|
||||
|
||||
@@ -40,7 +40,9 @@ public class MaxStatCommand extends Command {
|
||||
player.loseExp(player.getExp(), false, false);
|
||||
player.setLevel(255);
|
||||
player.resetPlayerRates();
|
||||
if (YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL) player.setPlayerRates();
|
||||
if (YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL) {
|
||||
player.setPlayerRates();
|
||||
}
|
||||
player.setWorldRates();
|
||||
player.updateStrDexIntLuk(Short.MAX_VALUE);
|
||||
player.setFame(13337);
|
||||
|
||||
@@ -41,16 +41,16 @@ public class RechargeCommand extends Command {
|
||||
Character player = c.getPlayer();
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
for (Item torecharge : c.getPlayer().getInventory(InventoryType.USE).list()) {
|
||||
if (ItemConstants.isThrowingStar(torecharge.getItemId())){
|
||||
if (ItemConstants.isThrowingStar(torecharge.getItemId())) {
|
||||
torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
|
||||
c.getPlayer().forceUpdateItem(torecharge);
|
||||
} else if (ItemConstants.isArrow(torecharge.getItemId())){
|
||||
} else if (ItemConstants.isArrow(torecharge.getItemId())) {
|
||||
torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
|
||||
c.getPlayer().forceUpdateItem(torecharge);
|
||||
} else if (ItemConstants.isBullet(torecharge.getItemId())){
|
||||
} else if (ItemConstants.isBullet(torecharge.getItemId())) {
|
||||
torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
|
||||
c.getPlayer().forceUpdateItem(torecharge);
|
||||
} else if (ItemConstants.isConsumable(torecharge.getItemId())){
|
||||
} else if (ItemConstants.isConsumable(torecharge.getItemId())) {
|
||||
torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
|
||||
c.getPlayer().forceUpdateItem(torecharge);
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ public class SearchCommand extends Command {
|
||||
private static Data mobStringData;
|
||||
private static Data skillStringData;
|
||||
private static Data mapStringData;
|
||||
|
||||
|
||||
{
|
||||
setDescription("Search String.wz.");
|
||||
|
||||
|
||||
DataProvider dataProvider = DataProviderFactory.getDataProvider(WZFiles.STRING);
|
||||
npcStringData = dataProvider.getData("Npc.img");
|
||||
mobStringData = dataProvider.getData("Mob.img");
|
||||
@@ -60,12 +60,12 @@ public class SearchCommand extends Command {
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String search = joinStringFrom(params,1);
|
||||
String search = joinStringFrom(params, 1);
|
||||
long start = System.currentTimeMillis();//for the lulz
|
||||
Data data = null;
|
||||
if (!params[0].equalsIgnoreCase("ITEM")) {
|
||||
int searchType = 0;
|
||||
|
||||
|
||||
if (params[0].equalsIgnoreCase("NPC")) {
|
||||
data = npcStringData;
|
||||
} else if (params[0].equalsIgnoreCase("MOB") || params[0].equalsIgnoreCase("MONSTER")) {
|
||||
@@ -83,7 +83,7 @@ public class SearchCommand extends Command {
|
||||
}
|
||||
if (data != null) {
|
||||
String name;
|
||||
|
||||
|
||||
if (searchType == 0) {
|
||||
for (Data searchData : data.getChildren()) {
|
||||
name = DataTool.getString(searchData.getChildByPath("name"), "NO-NAME");
|
||||
@@ -93,12 +93,12 @@ public class SearchCommand extends Command {
|
||||
}
|
||||
} else if (searchType == 1) {
|
||||
String mapName, streetName;
|
||||
|
||||
|
||||
for (Data searchDataDir : data.getChildren()) {
|
||||
for (Data searchData : searchDataDir.getChildren()) {
|
||||
mapName = DataTool.getString(searchData.getChildByPath("mapName"), "NO-NAME");
|
||||
streetName = DataTool.getString(searchData.getChildByPath("streetName"), "NO-NAME");
|
||||
|
||||
|
||||
if (mapName.toLowerCase().contains(search.toLowerCase()) || streetName.toLowerCase().contains(search.toLowerCase())) {
|
||||
sb.append("#b").append(Integer.parseInt(searchData.getName())).append("#k - #r").append(streetName).append(" - ").append(mapName).append("\r\n");
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class SearchCommand extends Command {
|
||||
} else {
|
||||
for (Quest mq : Quest.getMatchedQuests(search)) {
|
||||
sb.append("#b").append(mq.getId()).append("#k - #r");
|
||||
|
||||
|
||||
String parentName = mq.getParentName();
|
||||
if (!parentName.isEmpty()) {
|
||||
sb.append(parentName).append(" - ");
|
||||
|
||||
@@ -39,17 +39,17 @@ public class SetSlotCommand extends Command {
|
||||
player.yellowMessage("Syntax: !setslot <newlevel>");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int slots = (Integer.parseInt(params[0]) / 4) * 4;
|
||||
for (int i = 1; i < 5; i++) {
|
||||
int curSlots = player.getSlots(i);
|
||||
if (slots <= -curSlots) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
player.gainSlots(i, slots - curSlots, true);
|
||||
}
|
||||
|
||||
|
||||
player.yellowMessage("Slots updated.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,14 @@ public class SetStatCommand extends Command {
|
||||
try {
|
||||
int x = Integer.parseInt(params[0]);
|
||||
|
||||
if (x > Short.MAX_VALUE) x = Short.MAX_VALUE;
|
||||
else if (x < 4) x = 4; // thanks Vcoc for pointing the minimal allowed stat value here
|
||||
if (x > Short.MAX_VALUE) {
|
||||
x = Short.MAX_VALUE;
|
||||
} else if (x < 4) {
|
||||
x = 4; // thanks Vcoc for pointing the minimal allowed stat value here
|
||||
}
|
||||
|
||||
player.updateStrDexIntLuk(x);
|
||||
} catch (NumberFormatException nfe) {}
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,16 +43,22 @@ public class SpCommand extends Command {
|
||||
|
||||
if (params.length == 1) {
|
||||
int newSp = Integer.parseInt(params[0]);
|
||||
if (newSp < 0) newSp = 0;
|
||||
else if (newSp > YamlConfig.config.server.MAX_AP) newSp = YamlConfig.config.server.MAX_AP;
|
||||
if (newSp < 0) {
|
||||
newSp = 0;
|
||||
} else if (newSp > YamlConfig.config.server.MAX_AP) {
|
||||
newSp = YamlConfig.config.server.MAX_AP;
|
||||
}
|
||||
|
||||
player.updateRemainingSp(newSp);
|
||||
} else {
|
||||
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
if (victim != null) {
|
||||
int newSp = Integer.parseInt(params[1]);
|
||||
if (newSp < 0) newSp = 0;
|
||||
else if (newSp > YamlConfig.config.server.MAX_AP) newSp = YamlConfig.config.server.MAX_AP;
|
||||
if (newSp < 0) {
|
||||
newSp = 0;
|
||||
} else if (newSp > YamlConfig.config.server.MAX_AP) {
|
||||
newSp = YamlConfig.config.server.MAX_AP;
|
||||
}
|
||||
|
||||
victim.updateRemainingSp(newSp);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class SummonCommand extends Command {
|
||||
Character victim = c.getChannelServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
if (victim == null) {
|
||||
//If victim isn't on current channel, loop all channels on current world.
|
||||
|
||||
|
||||
for (Channel ch : Server.getInstance().getChannelsFromWorld(c.getWorld())) {
|
||||
victim = ch.getPlayerStorage().getCharacterByName(params[0]);
|
||||
if (victim != null) {
|
||||
@@ -59,19 +59,22 @@ public class SummonCommand extends Command {
|
||||
player.dropMessage(6, "Player currently not logged in or unreachable.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (player.getClient().getChannel() != victim.getClient().getChannel()) {//And then change channel if needed.
|
||||
victim.dropMessage("Changing channel, please wait a moment.");
|
||||
victim.getClient().changeChannel(player.getClient().getChannel());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
for (int i = 0; i < 7; i++) { // poll for a while until the player reconnects
|
||||
if (victim.isLoggedinWorld()) break;
|
||||
if (victim.isLoggedinWorld()) {
|
||||
break;
|
||||
}
|
||||
Thread.sleep(1777);
|
||||
}
|
||||
} catch (InterruptedException e) {}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
MapleMap map = player.getMap();
|
||||
victim.saveLocationOnWarp();
|
||||
victim.forceChangeMap(map, map.findClosestPortal(player.getPosition()));
|
||||
|
||||
@@ -54,7 +54,7 @@ public class WarpAreaCommand extends Command {
|
||||
Point pos = player.getPosition();
|
||||
|
||||
Collection<Character> characters = player.getMap().getAllPlayers();
|
||||
|
||||
|
||||
for (Character victim : characters) {
|
||||
if (victim.getPosition().distanceSq(pos) <= 50000) {
|
||||
victim.saveLocationOnWarp();
|
||||
|
||||
@@ -49,19 +49,19 @@ public class WarpCommand extends Command {
|
||||
player.yellowMessage("Map ID " + params[0] + " is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!player.isAlive()) {
|
||||
player.dropMessage(1, "This command cannot be used when you're dead.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!player.isGM()) {
|
||||
if (player.getEventInstance() != null || MiniDungeonInfo.isDungeonMap(player.getMapId()) || FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
|
||||
player.dropMessage(1, "This command cannot be used in this map.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// expedition issue with this command detected thanks to Masterrulax
|
||||
player.saveLocationOnWarp();
|
||||
player.changeMap(target, target.getRandomPlayerSpawnpoint());
|
||||
|
||||
@@ -51,7 +51,7 @@ public class WarpMapCommand extends Command {
|
||||
}
|
||||
|
||||
Collection<Character> characters = player.getMap().getAllPlayers();
|
||||
|
||||
|
||||
for (Character victim : characters) {
|
||||
victim.saveLocationOnWarp();
|
||||
victim.changeMap(target, target.getRandomPlayerSpawnpoint());
|
||||
|
||||
@@ -41,12 +41,12 @@ public class WhereaMiCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
|
||||
HashSet<Character> chars = new HashSet<>();
|
||||
HashSet<NPC> npcs = new HashSet<>();
|
||||
HashSet<PlayerNPC> playernpcs = new HashSet<>();
|
||||
HashSet<Monster> mobs = new HashSet<>();
|
||||
|
||||
|
||||
for (MapObject mmo : player.getMap().getMapObjects()) {
|
||||
if (mmo instanceof NPC) {
|
||||
NPC npc = (NPC) mmo;
|
||||
@@ -64,28 +64,28 @@ public class WhereaMiCommand extends Command {
|
||||
playernpcs.add(npc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.yellowMessage("Map ID: " + player.getMap().getId());
|
||||
|
||||
|
||||
player.yellowMessage("Players on this map:");
|
||||
for (Character chr : chars) {
|
||||
player.dropMessage(5, ">> " + chr.getName() + " - " + chr.getId() + " - Oid: " + chr.getObjectId());
|
||||
}
|
||||
|
||||
|
||||
if (!playernpcs.isEmpty()) {
|
||||
player.yellowMessage("PlayerNPCs on this map:");
|
||||
for (PlayerNPC pnpc : playernpcs) {
|
||||
player.dropMessage(5, ">> " + pnpc.getName() + " - Scriptid: " + pnpc.getScriptId() + " - Oid: " + pnpc.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!npcs.isEmpty()) {
|
||||
player.yellowMessage("NPCs on this map:");
|
||||
for (NPC npc : npcs) {
|
||||
player.dropMessage(5, ">> " + npc.getName() + " - " + npc.getId() + " - Oid: " + npc.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!mobs.isEmpty()) {
|
||||
player.yellowMessage("Monsters on this map:");
|
||||
for (Monster mob : mobs) {
|
||||
|
||||
@@ -42,8 +42,12 @@ public class CheckDmgCommand extends Command {
|
||||
Integer watkBuff = victim.getBuffedValue(BuffStat.WATK);
|
||||
Integer matkBuff = victim.getBuffedValue(BuffStat.MATK);
|
||||
int blessing = victim.getSkillLevel(10000000 * player.getJobType() + 12);
|
||||
if (watkBuff == null) watkBuff = 0;
|
||||
if (matkBuff == null) matkBuff = 0;
|
||||
if (watkBuff == null) {
|
||||
watkBuff = 0;
|
||||
}
|
||||
if (matkBuff == null) {
|
||||
matkBuff = 0;
|
||||
}
|
||||
|
||||
player.dropMessage(5, "Cur Str: " + victim.getTotalStr() + " Cur Dex: " + victim.getTotalDex() + " Cur Int: " + victim.getTotalInt() + " Cur Luk: " + victim.getTotalLuk());
|
||||
player.dropMessage(5, "Cur WATK: " + victim.getTotalWatk() + " Cur MATK: " + victim.getTotalMagic());
|
||||
|
||||
@@ -46,12 +46,16 @@ public class FlyCommand extends Command {
|
||||
String sendStr = "";
|
||||
if (params[0].equalsIgnoreCase("on")) {
|
||||
sendStr += "Enabled Fly feature (F1). With fly active, you cannot attack.";
|
||||
if (!srv.canFly(accid)) sendStr += " Re-login to take effect.";
|
||||
if (!srv.canFly(accid)) {
|
||||
sendStr += " Re-login to take effect.";
|
||||
}
|
||||
|
||||
srv.changeFly(c.getAccID(), true);
|
||||
} else {
|
||||
sendStr += "Disabled Fly feature. You can now attack.";
|
||||
if (srv.canFly(accid)) sendStr += " Re-login to take effect.";
|
||||
if (srv.canFly(accid)) {
|
||||
sendStr += " Re-login to take effect.";
|
||||
}
|
||||
|
||||
srv.changeFly(c.getAccID(), false);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GiveMesosCommand extends Command {
|
||||
|
||||
String recv_, value_;
|
||||
long mesos_ = 0;
|
||||
|
||||
|
||||
if (params.length == 2) {
|
||||
recv_ = params[0];
|
||||
value_ = params[1];
|
||||
@@ -50,7 +50,7 @@ public class GiveMesosCommand extends Command {
|
||||
recv_ = c.getPlayer().getName();
|
||||
value_ = params[0];
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
mesos_ = Long.parseLong(value_);
|
||||
if (mesos_ > Integer.MAX_VALUE) {
|
||||
@@ -65,7 +65,7 @@ public class GiveMesosCommand extends Command {
|
||||
mesos_ = Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(recv_);
|
||||
if (victim != null) {
|
||||
victim.gainMeso((int) mesos_, true);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class GiveNxCommand extends Command {
|
||||
type = 1;
|
||||
}
|
||||
typeStr = params[0];
|
||||
|
||||
|
||||
if (params.length > 2) {
|
||||
recv = params[1];
|
||||
value = Integer.parseInt(params[2]);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class GiveRpCommand extends Command {
|
||||
if (victim != null) {
|
||||
victim.setRewardPoints(victim.getRewardPoints() + Integer.parseInt(params[1]));
|
||||
player.message("RP given. Player " + params[0] + " now has " + victim.getRewardPoints()
|
||||
+ " reward points." );
|
||||
+ " reward points.");
|
||||
} else {
|
||||
player.message("Player '" + params[0] + "' could not be found.");
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MaxHpMpCommand extends Command {
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
Character victim = player;
|
||||
|
||||
|
||||
int statUpdate = 1;
|
||||
if (params.length >= 2) {
|
||||
victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
@@ -46,7 +46,7 @@ public class MaxHpMpCommand extends Command {
|
||||
} else {
|
||||
player.yellowMessage("Syntax: !maxhpmp [<playername>] <value>");
|
||||
}
|
||||
|
||||
|
||||
if (victim != null) {
|
||||
int extraHp = victim.getCurrentMaxHp() - victim.getClientMaxHp();
|
||||
int extraMp = victim.getCurrentMaxMp() - victim.getClientMaxMp();
|
||||
|
||||
@@ -39,24 +39,24 @@ public class MusicCommand extends Command {
|
||||
for (String s : GameConstants.GAME_SONGS) {
|
||||
songList += (" " + s + "\r\n");
|
||||
}
|
||||
|
||||
|
||||
return songList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
|
||||
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
String sendMsg = "";
|
||||
|
||||
|
||||
sendMsg += "Syntax: #r!music <song>#k\r\n\r\n";
|
||||
sendMsg += getSongList();
|
||||
|
||||
|
||||
c.sendPacket(PacketCreator.getNPCTalk(1052015, (byte) 0, sendMsg, "00 00", (byte) 0));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String song = player.getLastCommandMessage();
|
||||
for (String s : GameConstants.GAME_SONGS) {
|
||||
if (s.equalsIgnoreCase(song)) { // thanks Masterrulax for finding an issue here
|
||||
@@ -65,11 +65,11 @@ public class MusicCommand extends Command {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String sendMsg = "";
|
||||
sendMsg += "Song not found, please enter a song below.\r\n\r\n";
|
||||
sendMsg += getSongList();
|
||||
|
||||
|
||||
c.sendPacket(PacketCreator.getNPCTalk(1052015, (byte) 0, sendMsg, "00 00", (byte) 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public class QuestCompleteCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
if (params.length < 1){
|
||||
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !completequest <questid>");
|
||||
return;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class QuestCompleteCommand extends Command {
|
||||
} else {
|
||||
c.getAbstractPlayerInteraction().forceCompleteQuest(questId);
|
||||
}
|
||||
|
||||
|
||||
player.dropMessage(5, "QUEST " + questId + " completed.");
|
||||
} else {
|
||||
player.dropMessage(5, "QUESTID " + questId + " not started or already completed.");
|
||||
|
||||
@@ -36,8 +36,8 @@ public class QuestResetCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
if (params.length < 1){
|
||||
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !resetquest <questid>");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public class QuestStartCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
if (params.length < 1){
|
||||
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !startquest <questid>");
|
||||
return;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class QuestStartCommand extends Command {
|
||||
} else {
|
||||
c.getAbstractPlayerInteraction().forceStartQuest(questid);
|
||||
}
|
||||
|
||||
|
||||
player.dropMessage(5, "QUEST " + questid + " started.");
|
||||
} else {
|
||||
player.dropMessage(5, "QUESTID " + questid + " already started/completed.");
|
||||
|
||||
@@ -42,12 +42,13 @@ public class ReloadMapCommand extends Command {
|
||||
int callerid = c.getPlayer().getId();
|
||||
|
||||
Collection<Character> characters = player.getMap().getAllPlayers();
|
||||
|
||||
|
||||
for (Character chr : characters) {
|
||||
chr.saveLocationOnWarp();
|
||||
chr.changeMap(newMap);
|
||||
if (chr.getId() != callerid)
|
||||
if (chr.getId() != callerid) {
|
||||
chr.dropMessage("You have been relocated due to map reloading. Sorry for the inconvenience.");
|
||||
}
|
||||
}
|
||||
newMap.respawn();
|
||||
}
|
||||
|
||||
@@ -39,8 +39,9 @@ public class StartEventCommand extends Command {
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
int players = 50;
|
||||
if (params.length > 1)
|
||||
if (params.length > 1) {
|
||||
players = Integer.parseInt(params[0]);
|
||||
}
|
||||
c.getChannelServer().setEvent(new Event(player.getMapId(), players));
|
||||
Server.getInstance().broadcastMessage(c.getWorld(), PacketCreator.earnTitleMessage(
|
||||
"[Event] An event has started on "
|
||||
|
||||
@@ -25,7 +25,6 @@ import client.command.Command;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class BossDropRateCommand extends Command {
|
||||
|
||||
@@ -50,7 +50,9 @@ public class ForceVacCommand extends Command {
|
||||
|
||||
mapItem.lockItem();
|
||||
try {
|
||||
if (mapItem.isPickedUp()) continue;
|
||||
if (mapItem.isPickedUp()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mapItem.getMeso() > 0) {
|
||||
player.gainMeso(mapItem.getMeso(), true);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PapCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
|
||||
// thanks Conrad for noticing mobid typo here
|
||||
player.getMap().spawnMonsterOnGroundBelow(LifeFactory.getMonster(8500001), player.getPosition());
|
||||
}
|
||||
|
||||
@@ -47,14 +47,14 @@ public class PnpcRemoveCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
|
||||
|
||||
int mapId = player.getMapId();
|
||||
int npcId = params.length > 0 ? Integer.parseInt(params[0]) : -1;
|
||||
|
||||
|
||||
Point pos = player.getPosition();
|
||||
int xpos = pos.x;
|
||||
int ypos = pos.y;
|
||||
|
||||
|
||||
List<Pair<Integer, Pair<Integer, Integer>>> toRemove = new LinkedList<>();
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
final PreparedStatement ps;
|
||||
@@ -76,7 +76,7 @@ public class PnpcRemoveCommand extends Command {
|
||||
ps.setInt(6, ypos - 50);
|
||||
ps.setInt(7, ypos + 50);
|
||||
}
|
||||
|
||||
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (true) {
|
||||
rs.beforeFirst();
|
||||
@@ -94,9 +94,9 @@ public class PnpcRemoveCommand extends Command {
|
||||
e.printStackTrace();
|
||||
player.dropMessage(5, "Failed to remove pNPC from the database.");
|
||||
}
|
||||
|
||||
|
||||
if (!toRemove.isEmpty()) {
|
||||
for (Channel ch: player.getWorldServer().getChannels()) {
|
||||
for (Channel ch : player.getWorldServer().getChannels()) {
|
||||
MapleMap map = ch.getMapFactory().getMap(mapId);
|
||||
|
||||
for (Pair<Integer, Pair<Integer, Integer>> r : toRemove) {
|
||||
@@ -104,7 +104,7 @@ public class PnpcRemoveCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.yellowMessage("Cleared " + toRemove.size() + " pNPC placements.");
|
||||
}
|
||||
}
|
||||
@@ -45,18 +45,18 @@ public class ProItemCommand extends Command {
|
||||
player.yellowMessage("Syntax: !proitem <itemid> <stat value> [<spdjmp value>]");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
int itemid = Integer.parseInt(params[0]);
|
||||
|
||||
if(ii.getName(itemid) == null) {
|
||||
|
||||
if (ii.getName(itemid) == null) {
|
||||
player.yellowMessage("Item id '" + params[0] + "' does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
short stat = (short) Math.max(0, Short.parseShort(params[1]));
|
||||
short spdjmp = params.length >= 3 ? (short) Math.max(0, Short.parseShort(params[2])) : 0;
|
||||
|
||||
|
||||
InventoryType type = ItemConstants.getInventoryType(itemid);
|
||||
if (type.equals(InventoryType.EQUIP)) {
|
||||
Item it = ii.getEquipById(itemid);
|
||||
@@ -68,6 +68,7 @@ public class ProItemCommand extends Command {
|
||||
player.dropMessage(6, "Make sure it's an equippable item.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void hardsetItemStats(Equip equip, short stat, short spdjmp) {
|
||||
equip.setStr(stat);
|
||||
equip.setDex(stat);
|
||||
|
||||
@@ -47,11 +47,13 @@ public class SetEqStatCommand extends Command {
|
||||
short newStat = (short) Math.max(0, Integer.parseInt(params[0]));
|
||||
short newSpdJmp = params.length >= 2 ? (short) Integer.parseInt(params[1]) : 0;
|
||||
Inventory equip = player.getInventory(InventoryType.EQUIP);
|
||||
|
||||
|
||||
for (byte i = 1; i <= equip.getSlotLimit(); i++) {
|
||||
try {
|
||||
Equip eq = (Equip) equip.getItem(i);
|
||||
if (eq == null) continue;
|
||||
if (eq == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
eq.setWdef(newStat);
|
||||
eq.setAcc(newStat);
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.util.List;
|
||||
|
||||
public class DebugCommand extends Command {
|
||||
private final static String[] debugTypes = {"monster", "packet", "portal", "spawnpoint", "pos", "map", "mobsp", "event", "areas", "reactors", "servercoupons", "playercoupons", "timer", "marriage", "buff", ""};
|
||||
|
||||
|
||||
{
|
||||
setDescription("Show a debug message.");
|
||||
}
|
||||
@@ -59,13 +59,13 @@ public class DebugCommand extends Command {
|
||||
case "type":
|
||||
case "help":
|
||||
String msgTypes = "Available #bdebug types#k:\r\n\r\n";
|
||||
for(int i = 0; i < debugTypes.length; i++) {
|
||||
for (int i = 0; i < debugTypes.length; i++) {
|
||||
msgTypes += ("#L" + i + "#" + debugTypes[i] + "#l\r\n");
|
||||
}
|
||||
|
||||
|
||||
c.getAbstractPlayerInteraction().npcTalk(9201143, msgTypes);
|
||||
break;
|
||||
|
||||
|
||||
case "monster":
|
||||
List<MapObject> monsters = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapObjectType.MONSTER));
|
||||
for (MapObject monstermo : monsters) {
|
||||
@@ -81,16 +81,20 @@ public class DebugCommand extends Command {
|
||||
|
||||
case "portal":
|
||||
Portal portal = player.getMap().findClosestPortal(player.getPosition());
|
||||
if (portal != null)
|
||||
if (portal != null) {
|
||||
player.dropMessage(6, "Closest portal: " + portal.getId() + " '" + portal.getName() + "' Type: " + portal.getType() + " --> toMap: " + portal.getTargetMapId() + " scriptname: '" + portal.getScriptName() + "' state: " + (portal.getPortalState() ? 1 : 0) + ".");
|
||||
else player.dropMessage(6, "There is no portal on this map.");
|
||||
} else {
|
||||
player.dropMessage(6, "There is no portal on this map.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "spawnpoint":
|
||||
SpawnPoint sp = player.getMap().findClosestSpawnpoint(player.getPosition());
|
||||
if (sp != null)
|
||||
if (sp != null) {
|
||||
player.dropMessage(6, "Closest mob spawn point: " + " Position: x " + sp.getPosition().getX() + " y " + sp.getPosition().getY() + " Spawns mobid: '" + sp.getMonsterId() + "' --> canSpawn: " + !sp.getDenySpawn() + " canSpawnRightNow: " + sp.shouldSpawn() + ".");
|
||||
else player.dropMessage(6, "There is no mob spawn point on this map.");
|
||||
} else {
|
||||
player.dropMessage(6, "There is no mob spawn point on this map.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "pos":
|
||||
@@ -106,8 +110,11 @@ public class DebugCommand extends Command {
|
||||
break;
|
||||
|
||||
case "event":
|
||||
if (player.getEventInstance() == null) player.dropMessage(6, "Player currently not in an event.");
|
||||
else player.dropMessage(6, "Current event name: " + player.getEventInstance().getName() + ".");
|
||||
if (player.getEventInstance() == null) {
|
||||
player.dropMessage(6, "Player currently not in an event.");
|
||||
} else {
|
||||
player.dropMessage(6, "Current event name: " + player.getEventInstance().getName() + ".");
|
||||
}
|
||||
break;
|
||||
|
||||
case "areas":
|
||||
@@ -156,7 +163,7 @@ public class DebugCommand extends Command {
|
||||
case "marriage":
|
||||
c.getChannelServer().debugMarriageStatus();
|
||||
break;
|
||||
|
||||
|
||||
case "buff":
|
||||
c.getPlayer().debugListAllBuffs();
|
||||
break;
|
||||
|
||||
@@ -29,7 +29,6 @@ import net.server.world.World;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Mist
|
||||
* @author Blood (Tochi)
|
||||
* @author Ronan
|
||||
@@ -42,20 +41,20 @@ public class IpListCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
String str = "Player-IP relation:";
|
||||
|
||||
|
||||
for (World w : Server.getInstance().getWorlds()) {
|
||||
Collection<Character> chars = w.getPlayerStorage().getAllCharacters();
|
||||
|
||||
|
||||
if (!chars.isEmpty()) {
|
||||
str += "\r\n" + GameConstants.WORLD_NAMES[w.getId()] + "\r\n";
|
||||
|
||||
|
||||
for (Character chr : chars) {
|
||||
str += " " + chr.getName() + " - " + chr.getClient().getRemoteAddress() + "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
c.getAbstractPlayerInteraction().npcTalk(22000, str);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import client.command.Command;
|
||||
import net.server.coordinator.session.SessionCoordinator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class ShowSessionsCommand extends Command {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ServerAddChannelCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
final Character player = c.getPlayer();
|
||||
|
||||
|
||||
if (params.length < 1) {
|
||||
player.dropMessage(5, "Syntax: @addchannel <worldid>");
|
||||
return;
|
||||
@@ -47,15 +47,15 @@ public class ServerAddChannelCommand extends Command {
|
||||
|
||||
ThreadManager.getInstance().newTask(() -> {
|
||||
int chid = Server.getInstance().addChannel(worldid);
|
||||
if(player.isLoggedinWorld()) {
|
||||
if(chid >= 0) {
|
||||
if (player.isLoggedinWorld()) {
|
||||
if (chid >= 0) {
|
||||
player.dropMessage(5, "NEW Channel " + chid + " successfully deployed on world " + worldid + ".");
|
||||
} else {
|
||||
if(chid == -3) {
|
||||
if (chid == -3) {
|
||||
player.dropMessage(5, "Invalid worldid detected. Channel creation aborted.");
|
||||
} else if(chid == -2) {
|
||||
} else if (chid == -2) {
|
||||
player.dropMessage(5, "Reached channel limit on worldid " + worldid + ". Channel creation aborted.");
|
||||
} else if(chid == -1) {
|
||||
} else if (chid == -1) {
|
||||
player.dropMessage(5, "Error detected when loading the 'world.ini' file. Channel creation aborted.");
|
||||
} else {
|
||||
player.dropMessage(5, "NEW Channel failed to be deployed. Check if the needed port is already in use or other limitations are taking place.");
|
||||
|
||||
@@ -37,15 +37,15 @@ public class ServerAddWorldCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
final Character player = c.getPlayer();
|
||||
|
||||
|
||||
ThreadManager.getInstance().newTask(() -> {
|
||||
int wid = Server.getInstance().addWorld();
|
||||
|
||||
if(player.isLoggedinWorld()) {
|
||||
if(wid >= 0) {
|
||||
if (player.isLoggedinWorld()) {
|
||||
if (wid >= 0) {
|
||||
player.dropMessage(5, "NEW World " + wid + " successfully deployed.");
|
||||
} else {
|
||||
if(wid == -2) {
|
||||
if (wid == -2) {
|
||||
player.dropMessage(5, "Error detected when loading the 'world.ini' file. World creation aborted.");
|
||||
} else {
|
||||
player.dropMessage(5, "NEW World failed to be deployed. Check if needed ports are already in use or maximum world count has been reached.");
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ServerRemoveChannelCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
final Character player = c.getPlayer();
|
||||
|
||||
|
||||
if (params.length < 1) {
|
||||
player.dropMessage(5, "Syntax: @removechannel <worldid>");
|
||||
return;
|
||||
@@ -45,12 +45,12 @@ public class ServerRemoveChannelCommand extends Command {
|
||||
|
||||
final int worldId = Integer.parseInt(params[0]);
|
||||
ThreadManager.getInstance().newTask(() -> {
|
||||
if(Server.getInstance().removeChannel(worldId)) {
|
||||
if(player.isLoggedinWorld()) {
|
||||
if (Server.getInstance().removeChannel(worldId)) {
|
||||
if (player.isLoggedinWorld()) {
|
||||
player.dropMessage(5, "Successfully removed a channel on World " + worldId + ". Current channel count: " + Server.getInstance().getWorld(worldId).getChannelsSize() + ".");
|
||||
}
|
||||
} else {
|
||||
if(player.isLoggedinWorld()) {
|
||||
if (player.isLoggedinWorld()) {
|
||||
player.dropMessage(5, "Failed to remove last Channel on world " + worldId + ". Check if either that world exists or there are people currently playing there.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,21 +37,21 @@ public class ServerRemoveWorldCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
final Character player = c.getPlayer();
|
||||
|
||||
|
||||
final int rwid = Server.getInstance().getWorldsSize() - 1;
|
||||
if(rwid <= 0) {
|
||||
if (rwid <= 0) {
|
||||
player.dropMessage(5, "Unable to remove world 0.");
|
||||
return;
|
||||
}
|
||||
|
||||
ThreadManager.getInstance().newTask(() -> {
|
||||
if(Server.getInstance().removeWorld()) {
|
||||
if(player.isLoggedinWorld()) {
|
||||
if (Server.getInstance().removeWorld()) {
|
||||
if (player.isLoggedinWorld()) {
|
||||
player.dropMessage(5, "Successfully removed a world. Current world count: " + Server.getInstance().getWorldsSize() + ".");
|
||||
}
|
||||
} else {
|
||||
if(player.isLoggedinWorld()) {
|
||||
if(rwid < 0) {
|
||||
if (player.isLoggedinWorld()) {
|
||||
if (rwid < 0) {
|
||||
player.dropMessage(5, "No registered worlds to remove.");
|
||||
} else {
|
||||
player.dropMessage(5, "Failed to remove world " + rwid + ". Check if there are people currently playing there.");
|
||||
|
||||
@@ -38,13 +38,13 @@ public class ShutdownCommand extends Command {
|
||||
@Override
|
||||
public void execute(Client c, String[] params) {
|
||||
Character player = c.getPlayer();
|
||||
if (params.length < 1){
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !shutdown [<time>|NOW]");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int time = 60000;
|
||||
if (params[0].equalsIgnoreCase("now")){
|
||||
if (params[0].equalsIgnoreCase("now")) {
|
||||
time = 1;
|
||||
} else {
|
||||
time *= Integer.parseInt(params[0]);
|
||||
@@ -57,8 +57,12 @@ public class ShutdownCommand extends Command {
|
||||
int days = (time / (1000 * 60 * 60 * 24));
|
||||
|
||||
String strTime = "";
|
||||
if (days > 0) strTime += days + " days, ";
|
||||
if (hours > 0) strTime += hours + " hours, ";
|
||||
if (days > 0) {
|
||||
strTime += days + " days, ";
|
||||
}
|
||||
if (hours > 0) {
|
||||
strTime += hours + " hours, ";
|
||||
}
|
||||
strTime += minutes + " minutes, ";
|
||||
strTime += seconds + " seconds";
|
||||
|
||||
@@ -68,7 +72,7 @@ public class ShutdownCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TimerManager.getInstance().schedule(Server.getInstance().shutdown(false), time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SupplyRateCouponCommand extends Command {
|
||||
player.dropMessage(5, "Syntax: !supplyratecoupon <yes|no>");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
YamlConfig.config.server.USE_SUPPLY_RATE_COUPONS = params[0].compareToIgnoreCase("no") != 0;
|
||||
player.dropMessage(5, "Rate coupons are now " + (YamlConfig.config.server.USE_SUPPLY_RATE_COUPONS ? "enabled" : "disabled") + " for purchase at the Cash Shop.");
|
||||
}
|
||||
|
||||
@@ -32,70 +32,69 @@ import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public abstract class CharacterFactory {
|
||||
|
||||
protected synchronized static int createNewCharacter(Client c, String name, int face, int hair, int skin, int gender, CharacterFactoryRecipe recipe) {
|
||||
if (YamlConfig.config.server.COLLECTIVE_CHARSLOT ? c.getAvailableCharacterSlots() <= 0 : c.getAvailableCharacterWorldSlots() <= 0) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (!Character.canCreateChar(name)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Character newchar = Character.getDefault(c);
|
||||
newchar.setWorld(c.getWorld());
|
||||
newchar.setSkinColor(SkinColor.getById(skin));
|
||||
newchar.setGender(gender);
|
||||
newchar.setName(name);
|
||||
newchar.setHair(hair);
|
||||
newchar.setFace(face);
|
||||
|
||||
newchar.setLevel(recipe.getLevel());
|
||||
newchar.setJob(recipe.getJob());
|
||||
newchar.setMapId(recipe.getMap());
|
||||
|
||||
Inventory equipped = newchar.getInventory(InventoryType.EQUIPPED);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
int top = recipe.getTop(), bottom = recipe.getBottom(), shoes = recipe.getShoes(), weapon = recipe.getWeapon();
|
||||
|
||||
if(top > 0) {
|
||||
Item eq_top = ii.getEquipById(top);
|
||||
eq_top.setPosition((byte) -5);
|
||||
equipped.addItemFromDB(eq_top);
|
||||
}
|
||||
|
||||
if(bottom > 0) {
|
||||
Item eq_bottom = ii.getEquipById(bottom);
|
||||
eq_bottom.setPosition((byte) -6);
|
||||
equipped.addItemFromDB(eq_bottom);
|
||||
}
|
||||
|
||||
if(shoes > 0) {
|
||||
Item eq_shoes = ii.getEquipById(shoes);
|
||||
eq_shoes.setPosition((byte) -7);
|
||||
equipped.addItemFromDB(eq_shoes);
|
||||
}
|
||||
|
||||
if(weapon > 0) {
|
||||
Item eq_weapon = ii.getEquipById(weapon);
|
||||
eq_weapon.setPosition((byte) -11);
|
||||
equipped.addItemFromDB(eq_weapon.copy());
|
||||
}
|
||||
|
||||
if (!newchar.insertNewChar(recipe)) {
|
||||
return -2;
|
||||
}
|
||||
c.sendPacket(PacketCreator.addNewCharEntry(newchar));
|
||||
|
||||
Server.getInstance().createCharacterEntry(newchar);
|
||||
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.sendYellowTip("[New Char]: " + c.getAccountName() + " has created a new character with IGN " + name));
|
||||
FilePrinter.print(FilePrinter.CREATED_CHAR + c.getAccountName() + ".txt", c.getAccountName() + " created character with IGN " + name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected synchronized static int createNewCharacter(Client c, String name, int face, int hair, int skin, int gender, CharacterFactoryRecipe recipe) {
|
||||
if (YamlConfig.config.server.COLLECTIVE_CHARSLOT ? c.getAvailableCharacterSlots() <= 0 : c.getAvailableCharacterWorldSlots() <= 0) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (!Character.canCreateChar(name)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Character newchar = Character.getDefault(c);
|
||||
newchar.setWorld(c.getWorld());
|
||||
newchar.setSkinColor(SkinColor.getById(skin));
|
||||
newchar.setGender(gender);
|
||||
newchar.setName(name);
|
||||
newchar.setHair(hair);
|
||||
newchar.setFace(face);
|
||||
|
||||
newchar.setLevel(recipe.getLevel());
|
||||
newchar.setJob(recipe.getJob());
|
||||
newchar.setMapId(recipe.getMap());
|
||||
|
||||
Inventory equipped = newchar.getInventory(InventoryType.EQUIPPED);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
int top = recipe.getTop(), bottom = recipe.getBottom(), shoes = recipe.getShoes(), weapon = recipe.getWeapon();
|
||||
|
||||
if (top > 0) {
|
||||
Item eq_top = ii.getEquipById(top);
|
||||
eq_top.setPosition((byte) -5);
|
||||
equipped.addItemFromDB(eq_top);
|
||||
}
|
||||
|
||||
if (bottom > 0) {
|
||||
Item eq_bottom = ii.getEquipById(bottom);
|
||||
eq_bottom.setPosition((byte) -6);
|
||||
equipped.addItemFromDB(eq_bottom);
|
||||
}
|
||||
|
||||
if (shoes > 0) {
|
||||
Item eq_shoes = ii.getEquipById(shoes);
|
||||
eq_shoes.setPosition((byte) -7);
|
||||
equipped.addItemFromDB(eq_shoes);
|
||||
}
|
||||
|
||||
if (weapon > 0) {
|
||||
Item eq_weapon = ii.getEquipById(weapon);
|
||||
eq_weapon.setPosition((byte) -11);
|
||||
equipped.addItemFromDB(eq_weapon.copy());
|
||||
}
|
||||
|
||||
if (!newchar.insertNewChar(recipe)) {
|
||||
return -2;
|
||||
}
|
||||
c.sendPacket(PacketCreator.addNewCharEntry(newchar));
|
||||
|
||||
Server.getInstance().createCharacterEntry(newchar);
|
||||
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.sendYellowTip("[New Char]: " + c.getAccountName() + " has created a new character with IGN " + name));
|
||||
FilePrinter.print(FilePrinter.CREATED_CHAR + c.getAccountName() + ".txt", c.getAccountName() + " created character with IGN " + name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,21 +33,25 @@ import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class CharacterFactoryRecipe {
|
||||
private Job job;
|
||||
private int level, map, top, bottom, shoes, weapon;
|
||||
private final Job job;
|
||||
private final int level;
|
||||
private final int map;
|
||||
private final int top;
|
||||
private final int bottom;
|
||||
private final int shoes;
|
||||
private final int weapon;
|
||||
private int str = 4, dex = 4, int_ = 4, luk = 4;
|
||||
private int maxHp = 50, maxMp = 5;
|
||||
private int ap = 0, sp = 0;
|
||||
private int meso = 0;
|
||||
private List<Pair<Skill, Integer>> skills = new LinkedList<>();
|
||||
|
||||
private List<Pair<Item, InventoryType>> itemsWithType = new LinkedList<>();
|
||||
private Map<InventoryType, AtomicInteger> runningTypePosition = new LinkedHashMap<>();
|
||||
|
||||
private final List<Pair<Skill, Integer>> skills = new LinkedList<>();
|
||||
|
||||
private final List<Pair<Item, InventoryType>> itemsWithType = new LinkedList<>();
|
||||
private final Map<InventoryType, AtomicInteger> runningTypePosition = new LinkedHashMap<>();
|
||||
|
||||
public CharacterFactoryRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
this.job = job;
|
||||
this.level = level;
|
||||
@@ -56,7 +60,7 @@ public class CharacterFactoryRecipe {
|
||||
this.bottom = bottom;
|
||||
this.shoes = shoes;
|
||||
this.weapon = weapon;
|
||||
|
||||
|
||||
if (!YamlConfig.config.server.USE_STARTING_AP_4) {
|
||||
if (YamlConfig.config.server.USE_AUTOASSIGN_STARTERS_AP) {
|
||||
str = 12;
|
||||
@@ -66,129 +70,129 @@ public class CharacterFactoryRecipe {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setStr(int v) {
|
||||
str = v;
|
||||
}
|
||||
|
||||
|
||||
public void setDex(int v) {
|
||||
dex = v;
|
||||
}
|
||||
|
||||
|
||||
public void setInt(int v) {
|
||||
int_ = v;
|
||||
}
|
||||
|
||||
|
||||
public void setLuk(int v) {
|
||||
luk = v;
|
||||
}
|
||||
|
||||
|
||||
public void setMaxHp(int v) {
|
||||
maxHp = v;
|
||||
}
|
||||
|
||||
|
||||
public void setMaxMp(int v) {
|
||||
maxMp = v;
|
||||
}
|
||||
|
||||
|
||||
public void setRemainingAp(int v) {
|
||||
ap = v;
|
||||
}
|
||||
|
||||
|
||||
public void setRemainingSp(int v) {
|
||||
sp = v;
|
||||
}
|
||||
|
||||
|
||||
public void setMeso(int v) {
|
||||
meso = v;
|
||||
}
|
||||
|
||||
|
||||
public void addStartingSkillLevel(Skill skill, int level) {
|
||||
skills.add(new Pair<>(skill, level));
|
||||
}
|
||||
|
||||
|
||||
public void addStartingEquipment(Item eqpItem) {
|
||||
itemsWithType.add(new Pair<>(eqpItem, InventoryType.EQUIP));
|
||||
}
|
||||
|
||||
|
||||
public void addStartingItem(int itemid, int quantity, InventoryType itemType) {
|
||||
AtomicInteger p = runningTypePosition.get(itemType);
|
||||
if(p == null) {
|
||||
if (p == null) {
|
||||
p = new AtomicInteger(0);
|
||||
runningTypePosition.put(itemType, p);
|
||||
}
|
||||
|
||||
|
||||
itemsWithType.add(new Pair<>(new Item(itemid, (short) p.getAndIncrement(), (short) quantity), itemType));
|
||||
}
|
||||
|
||||
|
||||
public Job getJob() {
|
||||
return job;
|
||||
}
|
||||
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
public int getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public int getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
|
||||
public int getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
|
||||
public int getShoes() {
|
||||
return shoes;
|
||||
}
|
||||
|
||||
|
||||
public int getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
|
||||
public int getStr() {
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
public int getDex() {
|
||||
return dex;
|
||||
}
|
||||
|
||||
|
||||
public int getInt() {
|
||||
return int_;
|
||||
}
|
||||
|
||||
|
||||
public int getLuk() {
|
||||
return luk;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxHp() {
|
||||
return maxHp;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxMp() {
|
||||
return maxMp;
|
||||
}
|
||||
|
||||
|
||||
public int getRemainingAp() {
|
||||
return ap;
|
||||
}
|
||||
|
||||
|
||||
public int getRemainingSp() {
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
||||
public int getMeso() {
|
||||
return meso;
|
||||
}
|
||||
|
||||
|
||||
public List<Pair<Skill, Integer>> getStartingSkillLevel() {
|
||||
return skills;
|
||||
}
|
||||
|
||||
|
||||
public List<Pair<Item, InventoryType>> getStartingItems() {
|
||||
return itemsWithType;
|
||||
}
|
||||
|
||||
@@ -26,23 +26,22 @@ import client.creator.CharacterFactoryRecipe;
|
||||
import client.inventory.InventoryType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class BeginnerCreator extends CharacterFactory {
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
giveItem(recipe, 4161001, 1, InventoryType.ETC);
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
|
||||
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BEGINNER, 1, 10000, top, bottom, shoes, weapon));
|
||||
return status;
|
||||
}
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
giveItem(recipe, 4161001, 1, InventoryType.ETC);
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
|
||||
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BEGINNER, 1, 10000, top, bottom, shoes, weapon));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,23 +26,22 @@ import client.creator.CharacterFactoryRecipe;
|
||||
import client.inventory.InventoryType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class LegendCreator extends CharacterFactory {
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
giveItem(recipe, 4161048, 1, InventoryType.ETC);
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
|
||||
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.LEGEND, 1, 914000000, top, bottom, shoes, weapon));
|
||||
return status;
|
||||
}
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
giveItem(recipe, 4161048, 1, InventoryType.ETC);
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
|
||||
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.LEGEND, 1, 914000000, top, bottom, shoes, weapon));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,23 +26,22 @@ import client.creator.CharacterFactoryRecipe;
|
||||
import client.inventory.InventoryType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class NoblesseCreator extends CharacterFactory {
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
giveItem(recipe, 4161047, 1, InventoryType.ETC);
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
|
||||
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.NOBLESSE, 1, 130030000, top, bottom, shoes, weapon));
|
||||
return status;
|
||||
}
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
giveItem(recipe, 4161047, 1, InventoryType.ETC);
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
|
||||
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.NOBLESSE, 1, 130030000, top, bottom, shoes, weapon));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,48 +28,47 @@ import client.inventory.Item;
|
||||
import server.ItemInformationProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class BowmanCreator extends CharacterFactory {
|
||||
private static int[] equips = {1040067, 1041054, 1060056, 1061050, 1072081};
|
||||
private static int[] weapons = {1452005, 1462000};
|
||||
private static int[] startingHpMp = {797, 404};
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
recipe.setDex(25);
|
||||
recipe.setRemainingAp(133);
|
||||
recipe.setRemainingSp(61);
|
||||
private static final int[] equips = {1040067, 1041054, 1060056, 1061050, 1072081};
|
||||
private static final int[] weapons = {1452005, 1462000};
|
||||
private static final int[] startingHpMp = {797, 404};
|
||||
|
||||
recipe.setMaxHp(startingHpMp[0]);
|
||||
recipe.setMaxMp(startingHpMp[1]);
|
||||
|
||||
recipe.setMeso(100000);
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
for(int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
recipe.setDex(25);
|
||||
recipe.setRemainingAp(133);
|
||||
recipe.setRemainingSp(61);
|
||||
|
||||
giveItem(recipe, 2000002, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000003, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BOWMAN, 30, 100000000, equips[gender], equips[2 + gender], equips[4], weapons[0]));
|
||||
recipe.setMaxHp(startingHpMp[0]);
|
||||
recipe.setMaxMp(startingHpMp[1]);
|
||||
|
||||
recipe.setMeso(100000);
|
||||
|
||||
for (int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
|
||||
giveItem(recipe, 2000002, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000003, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BOWMAN, 30, 100000000, equips[gender], equips[2 + gender], equips[4], weapons[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,68 +31,67 @@ import constants.skills.Magician;
|
||||
import server.ItemInformationProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class MagicianCreator extends CharacterFactory {
|
||||
private static int[] equips = {0, 1041041, 0, 1061034, 1072075};
|
||||
private static int[] weapons = {1372003, 1382017};
|
||||
private static int[] startingHpMp = {405, 729};
|
||||
private static int[] mpGain = {0, 40, 80, 118, 156, 194, 230, 266, 302, 336, 370};
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon, int gender, int improveSp) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
recipe.setInt(20);
|
||||
recipe.setRemainingAp(138);
|
||||
recipe.setRemainingSp(67);
|
||||
private static final int[] equips = {0, 1041041, 0, 1061034, 1072075};
|
||||
private static final int[] weapons = {1372003, 1382017};
|
||||
private static final int[] startingHpMp = {405, 729};
|
||||
private static final int[] mpGain = {0, 40, 80, 118, 156, 194, 230, 266, 302, 336, 370};
|
||||
|
||||
recipe.setMaxHp(startingHpMp[0]);
|
||||
recipe.setMaxMp(startingHpMp[1] + mpGain[improveSp]);
|
||||
|
||||
recipe.setMeso(100000);
|
||||
|
||||
if(gender == 0) {
|
||||
giveEquipment(recipe, ii, 1050003);
|
||||
}
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon, int gender, int improveSp) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
for(int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
recipe.setInt(20);
|
||||
recipe.setRemainingAp(138);
|
||||
recipe.setRemainingSp(67);
|
||||
|
||||
giveItem(recipe, 2000001, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000006, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
if(improveSp > 0) {
|
||||
improveSp += 5;
|
||||
recipe.setRemainingSp(recipe.getRemainingSp() - improveSp);
|
||||
recipe.setMaxHp(startingHpMp[0]);
|
||||
recipe.setMaxMp(startingHpMp[1] + mpGain[improveSp]);
|
||||
|
||||
int toUseSp = 5;
|
||||
Skill improveMpRec = SkillFactory.getSkill(Magician.IMPROVED_MP_RECOVERY);
|
||||
recipe.addStartingSkillLevel(improveMpRec, toUseSp);
|
||||
improveSp -= toUseSp;
|
||||
recipe.setMeso(100000);
|
||||
|
||||
if(improveSp > 0) {
|
||||
Skill improveMaxMp = SkillFactory.getSkill(Magician.IMPROVED_MAX_MP_INCREASE);
|
||||
recipe.addStartingSkillLevel(improveMaxMp, improveSp);
|
||||
}
|
||||
}
|
||||
|
||||
return recipe;
|
||||
if (gender == 0) {
|
||||
giveEquipment(recipe, ii, 1050003);
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
|
||||
for (int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.MAGICIAN, 30, 101000000, equips[gender], equips[2 + gender], equips[4], weapons[0], gender, improveSp));
|
||||
|
||||
giveItem(recipe, 2000001, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000006, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
if (improveSp > 0) {
|
||||
improveSp += 5;
|
||||
recipe.setRemainingSp(recipe.getRemainingSp() - improveSp);
|
||||
|
||||
int toUseSp = 5;
|
||||
Skill improveMpRec = SkillFactory.getSkill(Magician.IMPROVED_MP_RECOVERY);
|
||||
recipe.addStartingSkillLevel(improveMpRec, toUseSp);
|
||||
improveSp -= toUseSp;
|
||||
|
||||
if (improveSp > 0) {
|
||||
Skill improveMaxMp = SkillFactory.getSkill(Magician.IMPROVED_MAX_MP_INCREASE);
|
||||
recipe.addStartingSkillLevel(improveMaxMp, improveSp);
|
||||
}
|
||||
}
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.MAGICIAN, 30, 101000000, equips[gender], equips[2 + gender], equips[4], weapons[0], gender, improveSp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,52 +28,51 @@ import client.inventory.Item;
|
||||
import server.ItemInformationProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class PirateCreator extends CharacterFactory {
|
||||
private static int[] equips = {0, 0, 0, 0, 1072294};
|
||||
private static int[] weapons = {1482004, 1492004};
|
||||
private static int[] startingHpMp = {846, 503};
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
recipe.setDex(20);
|
||||
recipe.setRemainingAp(138);
|
||||
recipe.setRemainingSp(61);
|
||||
private static final int[] equips = {0, 0, 0, 0, 1072294};
|
||||
private static final int[] weapons = {1482004, 1492004};
|
||||
private static final int[] startingHpMp = {846, 503};
|
||||
|
||||
recipe.setMaxHp(startingHpMp[0]);
|
||||
recipe.setMaxMp(startingHpMp[1]);
|
||||
|
||||
recipe.setMeso(100000);
|
||||
|
||||
giveEquipment(recipe, ii, 1052107);
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
for(int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
|
||||
giveItem(recipe, 2330000, 800, InventoryType.USE);
|
||||
recipe.setDex(20);
|
||||
recipe.setRemainingAp(138);
|
||||
recipe.setRemainingSp(61);
|
||||
|
||||
giveItem(recipe, 2000002, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000003, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.PIRATE, 30, 120000000, equips[gender], equips[2 + gender], equips[4], weapons[0]));
|
||||
recipe.setMaxHp(startingHpMp[0]);
|
||||
recipe.setMaxMp(startingHpMp[1]);
|
||||
|
||||
recipe.setMeso(100000);
|
||||
|
||||
giveEquipment(recipe, ii, 1052107);
|
||||
|
||||
for (int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
|
||||
giveItem(recipe, 2330000, 800, InventoryType.USE);
|
||||
|
||||
giveItem(recipe, 2000002, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000003, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.PIRATE, 30, 120000000, equips[gender], equips[2 + gender], equips[4], weapons[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,50 +28,49 @@ import client.inventory.Item;
|
||||
import server.ItemInformationProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class ThiefCreator extends CharacterFactory {
|
||||
private static int[] equips = {1040057, 1041047, 1060043, 1061043, 1072032};
|
||||
private static int[] weapons = {1472008, 1332012};
|
||||
private static int[] startingHpMp = {794, 407};
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
recipe.setDex(25);
|
||||
recipe.setRemainingAp(133);
|
||||
recipe.setRemainingSp(61);
|
||||
private static final int[] equips = {1040057, 1041047, 1060043, 1061043, 1072032};
|
||||
private static final int[] weapons = {1472008, 1332012};
|
||||
private static final int[] startingHpMp = {794, 407};
|
||||
|
||||
recipe.setMaxHp(startingHpMp[0]);
|
||||
recipe.setMaxMp(startingHpMp[1]);
|
||||
|
||||
recipe.setMeso(100000);
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
for(int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
|
||||
giveItem(recipe, 2070000, 500, InventoryType.USE);
|
||||
recipe.setDex(25);
|
||||
recipe.setRemainingAp(133);
|
||||
recipe.setRemainingSp(61);
|
||||
|
||||
giveItem(recipe, 2000002, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000003, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.THIEF, 30, 103000000, equips[gender], equips[2 + gender], equips[4], weapons[0]));
|
||||
recipe.setMaxHp(startingHpMp[0]);
|
||||
recipe.setMaxMp(startingHpMp[1]);
|
||||
|
||||
recipe.setMeso(100000);
|
||||
|
||||
for (int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
|
||||
giveItem(recipe, 2070000, 500, InventoryType.USE);
|
||||
|
||||
giveItem(recipe, 2000002, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000003, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.THIEF, 30, 103000000, equips[gender], equips[2 + gender], equips[4], weapons[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,68 +31,67 @@ import constants.skills.Warrior;
|
||||
import server.ItemInformationProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class WarriorCreator extends CharacterFactory {
|
||||
private static int[] equips = {1040021, 0, 1060016, 0, 1072039};
|
||||
private static int[] weapons = {1302008, 1442001, 1422001, 1312005};
|
||||
private static int[] startingHpMp = {905, 208};
|
||||
private static int[] hpGain = {0, 72, 144, 212, 280, 348, 412, 476, 540, 600, 660};
|
||||
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon, int gender, int improveSp) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
recipe.setStr(35);
|
||||
recipe.setRemainingAp(123);
|
||||
recipe.setRemainingSp(61);
|
||||
private static final int[] equips = {1040021, 0, 1060016, 0, 1072039};
|
||||
private static final int[] weapons = {1302008, 1442001, 1422001, 1312005};
|
||||
private static final int[] startingHpMp = {905, 208};
|
||||
private static final int[] hpGain = {0, 72, 144, 212, 280, 348, 412, 476, 540, 600, 660};
|
||||
|
||||
recipe.setMaxHp(startingHpMp[0] + hpGain[improveSp]);
|
||||
recipe.setMaxMp(startingHpMp[1]);
|
||||
|
||||
recipe.setMeso(100000);
|
||||
|
||||
if(gender == 1) {
|
||||
giveEquipment(recipe, ii, 1051010);
|
||||
}
|
||||
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon, int gender, int improveSp) {
|
||||
CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
for(int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
|
||||
if(improveSp > 0) {
|
||||
improveSp += 5;
|
||||
recipe.setRemainingSp(recipe.getRemainingSp() - improveSp);
|
||||
recipe.setStr(35);
|
||||
recipe.setRemainingAp(123);
|
||||
recipe.setRemainingSp(61);
|
||||
|
||||
int toUseSp = 5;
|
||||
Skill improveHpRec = SkillFactory.getSkill(Warrior.IMPROVED_HPREC);
|
||||
recipe.addStartingSkillLevel(improveHpRec, toUseSp);
|
||||
improveSp -= toUseSp;
|
||||
recipe.setMaxHp(startingHpMp[0] + hpGain[improveSp]);
|
||||
recipe.setMaxMp(startingHpMp[1]);
|
||||
|
||||
if(improveSp > 0) {
|
||||
Skill improveMaxHp = SkillFactory.getSkill(Warrior.IMPROVED_MAXHP);
|
||||
recipe.addStartingSkillLevel(improveMaxHp, improveSp);
|
||||
}
|
||||
}
|
||||
recipe.setMeso(100000);
|
||||
|
||||
giveItem(recipe, 2000002, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000003, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
return recipe;
|
||||
if (gender == 1) {
|
||||
giveEquipment(recipe, ii, 1051010);
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
|
||||
for (int i = 1; i < weapons.length; i++) {
|
||||
giveEquipment(recipe, ii, weapons[i]);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.WARRIOR, 30, 102000000, equips[gender], equips[2 + gender], equips[4], weapons[0], gender, improveSp));
|
||||
|
||||
if (improveSp > 0) {
|
||||
improveSp += 5;
|
||||
recipe.setRemainingSp(recipe.getRemainingSp() - improveSp);
|
||||
|
||||
int toUseSp = 5;
|
||||
Skill improveHpRec = SkillFactory.getSkill(Warrior.IMPROVED_HPREC);
|
||||
recipe.addStartingSkillLevel(improveHpRec, toUseSp);
|
||||
improveSp -= toUseSp;
|
||||
|
||||
if (improveSp > 0) {
|
||||
Skill improveMaxHp = SkillFactory.getSkill(Warrior.IMPROVED_MAXHP);
|
||||
recipe.addStartingSkillLevel(improveMaxHp, improveSp);
|
||||
}
|
||||
}
|
||||
|
||||
giveItem(recipe, 2000002, 100, InventoryType.USE);
|
||||
giveItem(recipe, 2000003, 100, InventoryType.USE);
|
||||
giveItem(recipe, 3010000, 1, InventoryType.SETUP);
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
private static void giveEquipment(CharacterFactoryRecipe recipe, ItemInformationProvider ii, int equipid) {
|
||||
Item nEquip = ii.getEquipById(equipid);
|
||||
recipe.addStartingEquipment(nEquip);
|
||||
}
|
||||
|
||||
private static void giveItem(CharacterFactoryRecipe recipe, int itemid, int quantity, InventoryType itemType) {
|
||||
recipe.addStartingItem(itemid, quantity, itemType);
|
||||
}
|
||||
|
||||
public static int createCharacter(Client c, String name, int face, int hair, int skin, int gender, int improveSp) {
|
||||
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.WARRIOR, 30, 102000000, equips[gender], equips[2 + gender], equips[4], weapons[0], gender, improveSp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ import java.util.Map;
|
||||
|
||||
public class Equip extends Item {
|
||||
|
||||
public static enum ScrollResult {
|
||||
public enum ScrollResult {
|
||||
|
||||
FAIL(0), SUCCESS(1), CURSE(2);
|
||||
private int value = -1;
|
||||
|
||||
private ScrollResult(int value) {
|
||||
ScrollResult(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ public class Equip extends Item {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum StatUpgrade {
|
||||
|
||||
public enum StatUpgrade {
|
||||
|
||||
incDEX(0), incSTR(1), incINT(2), incLUK(3),
|
||||
incMHP(4), incMMP(5), incPAD(6), incMAD(7),
|
||||
@@ -59,11 +59,11 @@ public class Equip extends Item {
|
||||
incSpeed(12), incJump(13), incVicious(14), incSlot(15);
|
||||
private int value = -1;
|
||||
|
||||
private StatUpgrade(int value) {
|
||||
StatUpgrade(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private byte upgradeSlots;
|
||||
private byte level, itemLevel;
|
||||
private short flag;
|
||||
@@ -82,7 +82,7 @@ public class Equip extends Item {
|
||||
this.upgradeSlots = (byte) slots;
|
||||
this.itemExp = 0;
|
||||
this.itemLevel = 1;
|
||||
|
||||
|
||||
this.isElemental = (ItemInformationProvider.getInstance().getEquipLevel(id, false) > 1);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class Equip extends Item {
|
||||
public byte getItemType() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
public byte getUpgradeSlots() {
|
||||
return upgradeSlots;
|
||||
}
|
||||
@@ -279,108 +279,167 @@ public class Equip extends Item {
|
||||
|
||||
private static int getStatModifier(boolean isAttribute) {
|
||||
// each set of stat points grants a chance for a bonus stat point upgrade at equip level up.
|
||||
|
||||
if(YamlConfig.config.server.USE_EQUIPMNT_LVLUP_POWER) {
|
||||
if(isAttribute) return 2;
|
||||
else return 4;
|
||||
}
|
||||
else {
|
||||
if(isAttribute) return 4;
|
||||
else return 16;
|
||||
|
||||
if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_POWER) {
|
||||
if (isAttribute) {
|
||||
return 2;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
} else {
|
||||
if (isAttribute) {
|
||||
return 4;
|
||||
} else {
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static int randomizeStatUpgrade(int top) {
|
||||
int limit = Math.min(top, YamlConfig.config.server.MAX_EQUIPMNT_LVLUP_STAT_UP);
|
||||
|
||||
|
||||
int poolCount = (limit * (limit + 1) / 2) + limit;
|
||||
int rnd = Randomizer.rand(0, poolCount);
|
||||
|
||||
|
||||
int stat = 0;
|
||||
if(rnd >= limit) {
|
||||
if (rnd >= limit) {
|
||||
rnd -= limit;
|
||||
stat = 1 + (int)Math.floor((-1 + Math.sqrt((8 * rnd) + 1)) / 2); // optimized randomizeStatUpgrade author: David A.
|
||||
stat = 1 + (int) Math.floor((-1 + Math.sqrt((8 * rnd) + 1)) / 2); // optimized randomizeStatUpgrade author: David A.
|
||||
}
|
||||
|
||||
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isPhysicalWeapon(int itemid) {
|
||||
Equip eqp = (Equip) ItemInformationProvider.getInstance().getEquipById(itemid);
|
||||
return eqp.getWatk() >= eqp.getMatk();
|
||||
}
|
||||
|
||||
|
||||
private boolean isNotWeaponAffinity(StatUpgrade name) {
|
||||
// Vcoc's idea - WATK/MATK expected gains lessens outside of weapon affinity (physical/magic)
|
||||
|
||||
|
||||
if (ItemConstants.isWeapon(this.getItemId())) {
|
||||
if (name.equals(StatUpgrade.incPAD)) {
|
||||
if (!isPhysicalWeapon(this.getItemId())) {
|
||||
return true;
|
||||
}
|
||||
return !isPhysicalWeapon(this.getItemId());
|
||||
} else if (name.equals(StatUpgrade.incMAD)) {
|
||||
if (isPhysicalWeapon(this.getItemId())) {
|
||||
return true;
|
||||
}
|
||||
return isPhysicalWeapon(this.getItemId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void getUnitStatUpgrade(List<Pair<StatUpgrade, Integer>> stats, StatUpgrade name, int curStat, boolean isAttribute) {
|
||||
isUpgradeable = true;
|
||||
|
||||
int maxUpgrade = randomizeStatUpgrade((int)(1 + (curStat / (getStatModifier(isAttribute) * (isNotWeaponAffinity(name) ? 2.7 : 1)))));
|
||||
if(maxUpgrade == 0) return;
|
||||
|
||||
|
||||
int maxUpgrade = randomizeStatUpgrade((int) (1 + (curStat / (getStatModifier(isAttribute) * (isNotWeaponAffinity(name) ? 2.7 : 1)))));
|
||||
if (maxUpgrade == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
stats.add(new Pair<>(name, maxUpgrade));
|
||||
}
|
||||
|
||||
|
||||
private static void getUnitSlotUpgrade(List<Pair<StatUpgrade, Integer>> stats, StatUpgrade name) {
|
||||
if(Math.random() < 0.1) {
|
||||
if (Math.random() < 0.1) {
|
||||
stats.add(new Pair<>(name, 1)); // 10% success on getting a slot upgrade.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void improveDefaultStats(List<Pair<StatUpgrade, Integer>> stats) {
|
||||
if(dex > 0) getUnitStatUpgrade(stats, StatUpgrade.incDEX, dex, true);
|
||||
if(str > 0) getUnitStatUpgrade(stats, StatUpgrade.incSTR, str, true);
|
||||
if(_int > 0) getUnitStatUpgrade(stats, StatUpgrade.incINT,_int, true);
|
||||
if(luk > 0) getUnitStatUpgrade(stats, StatUpgrade.incLUK, luk, true);
|
||||
if(hp > 0) getUnitStatUpgrade(stats, StatUpgrade.incMHP, hp, false);
|
||||
if(mp > 0) getUnitStatUpgrade(stats, StatUpgrade.incMMP, mp, false);
|
||||
if(watk > 0) getUnitStatUpgrade(stats, StatUpgrade.incPAD, watk, false);
|
||||
if(matk > 0) getUnitStatUpgrade(stats, StatUpgrade.incMAD, matk, false);
|
||||
if(wdef > 0) getUnitStatUpgrade(stats, StatUpgrade.incPDD, wdef, false);
|
||||
if(mdef > 0) getUnitStatUpgrade(stats, StatUpgrade.incMDD, mdef, false);
|
||||
if(avoid > 0) getUnitStatUpgrade(stats, StatUpgrade.incEVA, avoid, false);
|
||||
if(acc > 0) getUnitStatUpgrade(stats, StatUpgrade.incACC, acc, false);
|
||||
if(speed > 0) getUnitStatUpgrade(stats, StatUpgrade.incSpeed, speed, false);
|
||||
if(jump > 0) getUnitStatUpgrade(stats, StatUpgrade.incJump, jump, false);
|
||||
if (dex > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incDEX, dex, true);
|
||||
}
|
||||
if (str > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incSTR, str, true);
|
||||
}
|
||||
if (_int > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incINT, _int, true);
|
||||
}
|
||||
if (luk > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incLUK, luk, true);
|
||||
}
|
||||
if (hp > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incMHP, hp, false);
|
||||
}
|
||||
if (mp > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incMMP, mp, false);
|
||||
}
|
||||
if (watk > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incPAD, watk, false);
|
||||
}
|
||||
if (matk > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incMAD, matk, false);
|
||||
}
|
||||
if (wdef > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incPDD, wdef, false);
|
||||
}
|
||||
if (mdef > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incMDD, mdef, false);
|
||||
}
|
||||
if (avoid > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incEVA, avoid, false);
|
||||
}
|
||||
if (acc > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incACC, acc, false);
|
||||
}
|
||||
if (speed > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incSpeed, speed, false);
|
||||
}
|
||||
if (jump > 0) {
|
||||
getUnitStatUpgrade(stats, StatUpgrade.incJump, jump, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Map<StatUpgrade, Short> getStats() {
|
||||
Map<StatUpgrade, Short> stats = new HashMap<>(5);
|
||||
|
||||
if(dex > 0) stats.put(StatUpgrade.incDEX, dex);
|
||||
if(str > 0) stats.put(StatUpgrade.incSTR, str);
|
||||
if(_int > 0) stats.put(StatUpgrade.incINT,_int);
|
||||
if(luk > 0) stats.put(StatUpgrade.incLUK, luk);
|
||||
if(hp > 0) stats.put(StatUpgrade.incMHP, hp);
|
||||
if(mp > 0) stats.put(StatUpgrade.incMMP, mp);
|
||||
if(watk > 0) stats.put(StatUpgrade.incPAD, watk);
|
||||
if(matk > 0) stats.put(StatUpgrade.incMAD, matk);
|
||||
if(wdef > 0) stats.put(StatUpgrade.incPDD, wdef);
|
||||
if(mdef > 0) stats.put(StatUpgrade.incMDD, mdef);
|
||||
if(avoid > 0) stats.put(StatUpgrade.incEVA, avoid);
|
||||
if(acc > 0) stats.put(StatUpgrade.incACC, acc);
|
||||
if(speed > 0) stats.put(StatUpgrade.incSpeed, speed);
|
||||
if(jump > 0) stats.put(StatUpgrade.incJump, jump);
|
||||
|
||||
|
||||
if (dex > 0) {
|
||||
stats.put(StatUpgrade.incDEX, dex);
|
||||
}
|
||||
if (str > 0) {
|
||||
stats.put(StatUpgrade.incSTR, str);
|
||||
}
|
||||
if (_int > 0) {
|
||||
stats.put(StatUpgrade.incINT, _int);
|
||||
}
|
||||
if (luk > 0) {
|
||||
stats.put(StatUpgrade.incLUK, luk);
|
||||
}
|
||||
if (hp > 0) {
|
||||
stats.put(StatUpgrade.incMHP, hp);
|
||||
}
|
||||
if (mp > 0) {
|
||||
stats.put(StatUpgrade.incMMP, mp);
|
||||
}
|
||||
if (watk > 0) {
|
||||
stats.put(StatUpgrade.incPAD, watk);
|
||||
}
|
||||
if (matk > 0) {
|
||||
stats.put(StatUpgrade.incMAD, matk);
|
||||
}
|
||||
if (wdef > 0) {
|
||||
stats.put(StatUpgrade.incPDD, wdef);
|
||||
}
|
||||
if (mdef > 0) {
|
||||
stats.put(StatUpgrade.incMDD, mdef);
|
||||
}
|
||||
if (avoid > 0) {
|
||||
stats.put(StatUpgrade.incEVA, avoid);
|
||||
}
|
||||
if (acc > 0) {
|
||||
stats.put(StatUpgrade.incACC, acc);
|
||||
}
|
||||
if (speed > 0) {
|
||||
stats.put(StatUpgrade.incSpeed, speed);
|
||||
}
|
||||
if (jump > 0) {
|
||||
stats.put(StatUpgrade.incJump, jump);
|
||||
}
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
|
||||
public Pair<String, Pair<Boolean, Boolean>> gainStats(List<Pair<StatUpgrade, Integer>> stats) {
|
||||
boolean gotSlot = false, gotVicious = false;
|
||||
String lvupStr = "";
|
||||
@@ -457,7 +516,7 @@ public class Equip extends Item {
|
||||
jump += statUp;
|
||||
lvupStr += "+" + statUp + "JUMP ";
|
||||
break;
|
||||
|
||||
|
||||
case incVicious:
|
||||
vicious -= stat.getRight();
|
||||
gotVicious = true;
|
||||
@@ -468,56 +527,64 @@ public class Equip extends Item {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new Pair<>(lvupStr, new Pair<>(gotSlot, gotVicious));
|
||||
}
|
||||
|
||||
|
||||
private void gainLevel(Client c) {
|
||||
List<Pair<StatUpgrade, Integer>> stats = new LinkedList<>();
|
||||
|
||||
if(isElemental) {
|
||||
|
||||
if (isElemental) {
|
||||
List<Pair<String, Integer>> elementalStats = ItemInformationProvider.getInstance().getItemLevelupStats(getItemId(), itemLevel);
|
||||
|
||||
for(Pair<String, Integer> p: elementalStats) {
|
||||
if(p.getRight() > 0) stats.add(new Pair<>(StatUpgrade.valueOf(p.getLeft()), p.getRight()));
|
||||
|
||||
for (Pair<String, Integer> p : elementalStats) {
|
||||
if (p.getRight() > 0) {
|
||||
stats.add(new Pair<>(StatUpgrade.valueOf(p.getLeft()), p.getRight()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!stats.isEmpty()) {
|
||||
if(YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) {
|
||||
if(vicious > 0) getUnitSlotUpgrade(stats, StatUpgrade.incVicious);
|
||||
|
||||
if (!stats.isEmpty()) {
|
||||
if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) {
|
||||
if (vicious > 0) {
|
||||
getUnitSlotUpgrade(stats, StatUpgrade.incVicious);
|
||||
}
|
||||
getUnitSlotUpgrade(stats, StatUpgrade.incSlot);
|
||||
}
|
||||
} else {
|
||||
isUpgradeable = false;
|
||||
|
||||
|
||||
improveDefaultStats(stats);
|
||||
if(YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) {
|
||||
if(vicious > 0) getUnitSlotUpgrade(stats, StatUpgrade.incVicious);
|
||||
if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) {
|
||||
if (vicious > 0) {
|
||||
getUnitSlotUpgrade(stats, StatUpgrade.incVicious);
|
||||
}
|
||||
getUnitSlotUpgrade(stats, StatUpgrade.incSlot);
|
||||
}
|
||||
|
||||
if(isUpgradeable) {
|
||||
while(stats.isEmpty()) {
|
||||
|
||||
if (isUpgradeable) {
|
||||
while (stats.isEmpty()) {
|
||||
improveDefaultStats(stats);
|
||||
if(YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) {
|
||||
if(vicious > 0) getUnitSlotUpgrade(stats, StatUpgrade.incVicious);
|
||||
if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) {
|
||||
if (vicious > 0) {
|
||||
getUnitSlotUpgrade(stats, StatUpgrade.incVicious);
|
||||
}
|
||||
getUnitSlotUpgrade(stats, StatUpgrade.incSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
itemLevel++;
|
||||
|
||||
|
||||
String lvupStr = "'" + ItemInformationProvider.getInstance().getName(this.getItemId()) + "' is now level " + itemLevel + "! ";
|
||||
String showStr = "#e'" + ItemInformationProvider.getInstance().getName(this.getItemId()) + "'#b is now #elevel #r" + itemLevel + "#k#b!";
|
||||
|
||||
|
||||
Pair<String, Pair<Boolean, Boolean>> res = this.gainStats(stats);
|
||||
lvupStr += res.getLeft();
|
||||
boolean gotSlot = res.getRight().getLeft();
|
||||
boolean gotVicious = res.getRight().getRight();
|
||||
|
||||
|
||||
if (gotVicious) {
|
||||
//c.getPlayer().dropMessage(6, "A new Vicious Hammer opportunity has been found on the '" + ItemInformationProvider.getInstance().getName(getItemId()) + "'!");
|
||||
lvupStr += "+VICIOUS ";
|
||||
@@ -526,12 +593,12 @@ public class Equip extends Item {
|
||||
//c.getPlayer().dropMessage(6, "A new upgrade slot has been found on the '" + ItemInformationProvider.getInstance().getName(getItemId()) + "'!");
|
||||
lvupStr += "+UPGSLOT ";
|
||||
}
|
||||
|
||||
|
||||
c.getPlayer().equipChanged();
|
||||
|
||||
|
||||
showLevelupMessage(showStr, c); // thanks to Polaris dev team !
|
||||
c.getPlayer().dropMessage(6, lvupStr);
|
||||
|
||||
|
||||
c.sendPacket(PacketCreator.showEquipmentLevelUp());
|
||||
c.getPlayer().getMap().broadcastPacket(c.getPlayer(), PacketCreator.showForeignEffect(c.getPlayer().getId(), 15));
|
||||
c.getPlayer().forceUpdateItem(this);
|
||||
@@ -540,89 +607,93 @@ public class Equip extends Item {
|
||||
public int getItemExp() {
|
||||
return (int) itemExp;
|
||||
}
|
||||
|
||||
|
||||
private static double normalizedMasteryExp(int reqLevel) {
|
||||
// Conversion factor between mob exp and equip exp gain. Through many calculations, the expected for equipment levelup
|
||||
// from level 1 to 2 is killing about 100~200 mobs of the same level range, on a 1x EXP rate scenario.
|
||||
|
||||
if(reqLevel < 5) {
|
||||
|
||||
if (reqLevel < 5) {
|
||||
return 42;
|
||||
} else if(reqLevel >= 78) {
|
||||
} else if (reqLevel >= 78) {
|
||||
return Math.max((10413.648 * Math.exp(reqLevel * 0.03275)), 15);
|
||||
} else if(reqLevel >= 38) {
|
||||
return Math.max(( 4985.818 * Math.exp(reqLevel * 0.02007)), 15);
|
||||
} else if(reqLevel >= 18) {
|
||||
return Math.max(( 248.219 * Math.exp(reqLevel * 0.11093)), 15);
|
||||
} else if (reqLevel >= 38) {
|
||||
return Math.max((4985.818 * Math.exp(reqLevel * 0.02007)), 15);
|
||||
} else if (reqLevel >= 18) {
|
||||
return Math.max((248.219 * Math.exp(reqLevel * 0.11093)), 15);
|
||||
} else {
|
||||
return Math.max(((1334.564 * Math.log(reqLevel)) - 1731.976), 15);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized void gainItemExp(Client c, int gain) { // Ronan's Equip Exp gain method
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
if(!ii.isUpgradeable(this.getItemId())) {
|
||||
if (!ii.isUpgradeable(this.getItemId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int equipMaxLevel = Math.min(30, Math.max(ii.getEquipLevel(this.getItemId(), true), YamlConfig.config.server.USE_EQUIPMNT_LVLUP));
|
||||
if (itemLevel >= equipMaxLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int reqLevel = ii.getEquipLevelReq(this.getItemId());
|
||||
|
||||
float masteryModifier = (float)(YamlConfig.config.server.EQUIP_EXP_RATE * ExpTable.getExpNeededForLevel(1)) / (float)normalizedMasteryExp(reqLevel);
|
||||
|
||||
float masteryModifier = (float) (YamlConfig.config.server.EQUIP_EXP_RATE * ExpTable.getExpNeededForLevel(1)) / (float) normalizedMasteryExp(reqLevel);
|
||||
float elementModifier = (isElemental) ? 0.85f : 0.6f;
|
||||
|
||||
|
||||
float baseExpGain = gain * elementModifier * masteryModifier;
|
||||
|
||||
|
||||
itemExp += baseExpGain;
|
||||
int expNeeded = ExpTable.getEquipExpNeededForLevel(itemLevel);
|
||||
|
||||
if(YamlConfig.config.server.USE_DEBUG_SHOW_INFO_EQPEXP) System.out.println("'" + ii.getName(this.getItemId()) + "' -> EXP Gain: " + gain + " Mastery: " + masteryModifier + " Base gain: " + baseExpGain + " exp: " + itemExp + " / " + expNeeded + ", Kills TNL: " + expNeeded / (baseExpGain / c.getPlayer().getExpRate()));
|
||||
|
||||
|
||||
if (YamlConfig.config.server.USE_DEBUG_SHOW_INFO_EQPEXP) {
|
||||
System.out.println("'" + ii.getName(this.getItemId()) + "' -> EXP Gain: " + gain + " Mastery: " + masteryModifier + " Base gain: " + baseExpGain + " exp: " + itemExp + " / " + expNeeded + ", Kills TNL: " + expNeeded / (baseExpGain / c.getPlayer().getExpRate()));
|
||||
}
|
||||
|
||||
if (itemExp >= expNeeded) {
|
||||
while(itemExp >= expNeeded) {
|
||||
while (itemExp >= expNeeded) {
|
||||
itemExp -= expNeeded;
|
||||
gainLevel(c);
|
||||
|
||||
if(itemLevel >= equipMaxLevel) {
|
||||
if (itemLevel >= equipMaxLevel) {
|
||||
itemExp = 0.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
expNeeded = ExpTable.getEquipExpNeededForLevel(itemLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
c.getPlayer().forceUpdateItem(this);
|
||||
//if(YamlConfig.config.server.USE_DEBUG) c.getPlayer().dropMessage("'" + ii.getName(this.getItemId()) + "': " + itemExp + " / " + expNeeded);
|
||||
}
|
||||
|
||||
|
||||
private boolean reachedMaxLevel() {
|
||||
if (isElemental) {
|
||||
if (itemLevel < ItemInformationProvider.getInstance().getEquipLevel(getItemId(), true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return itemLevel >= YamlConfig.config.server.USE_EQUIPMNT_LVLUP;
|
||||
}
|
||||
|
||||
|
||||
public String showEquipFeatures(Client c) {
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
if(!ii.isUpgradeable(this.getItemId())) return "";
|
||||
|
||||
if (!ii.isUpgradeable(this.getItemId())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
String eqpName = ii.getName(getItemId());
|
||||
String eqpInfo = reachedMaxLevel() ? " #e#rMAX LEVEL#k#n" : (" EXP: #e#b" + (int)itemExp + "#k#n / " + ExpTable.getEquipExpNeededForLevel(itemLevel));
|
||||
|
||||
String eqpInfo = reachedMaxLevel() ? " #e#rMAX LEVEL#k#n" : (" EXP: #e#b" + (int) itemExp + "#k#n / " + ExpTable.getEquipExpNeededForLevel(itemLevel));
|
||||
|
||||
return "'" + eqpName + "' -> LV: #e#b" + itemLevel + "#k#n " + eqpInfo + "\r\n";
|
||||
}
|
||||
|
||||
private static void showLevelupMessage(String msg, Client c) {
|
||||
c.getPlayer().showHint(msg, 300);
|
||||
}
|
||||
|
||||
|
||||
public void setItemExp(int exp) {
|
||||
this.itemExp = exp;
|
||||
}
|
||||
|
||||
@@ -32,9 +32,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Item implements Comparable<Item> {
|
||||
|
||||
private static AtomicInteger runningCashId = new AtomicInteger(777000000); // pets & rings shares cashid values
|
||||
|
||||
private int id, cashId, sn;
|
||||
private static final AtomicInteger runningCashId = new AtomicInteger(777000000); // pets & rings shares cashid values
|
||||
|
||||
private final int id;
|
||||
private int cashId;
|
||||
private int sn;
|
||||
private short position;
|
||||
private short quantity;
|
||||
private int petid = -1;
|
||||
@@ -79,7 +81,9 @@ public class Item implements Comparable<Item> {
|
||||
|
||||
public void setPosition(short position) {
|
||||
this.position = position;
|
||||
if (this.pet != null) this.pet.setPosition(position);
|
||||
if (this.pet != null) {
|
||||
this.pet.setPosition(position);
|
||||
}
|
||||
}
|
||||
|
||||
public void setQuantity(short quantity) {
|
||||
@@ -108,7 +112,7 @@ public class Item implements Comparable<Item> {
|
||||
public InventoryType getInventoryType() {
|
||||
return ItemConstants.getInventoryType(id);
|
||||
}
|
||||
|
||||
|
||||
public byte getItemType() { // 1: equip, 3: pet, 2: other
|
||||
if (getPetId() > -1) {
|
||||
return 3;
|
||||
@@ -127,7 +131,7 @@ public class Item implements Comparable<Item> {
|
||||
public int getPetId() {
|
||||
return petid;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(Item other) {
|
||||
if (this.id < other.getItemId()) {
|
||||
@@ -137,7 +141,7 @@ public class Item implements Comparable<Item> {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Item: " + id + " quantity: " + quantity;
|
||||
@@ -156,7 +160,7 @@ public class Item implements Comparable<Item> {
|
||||
if (ii.isAccountRestricted(id)) {
|
||||
b |= ItemConstants.ACCOUNT_SHARING; // thanks Shinigami15 for noticing ACCOUNT_SHARING flag not being applied properly to items server-side
|
||||
}
|
||||
|
||||
|
||||
this.flag = b;
|
||||
}
|
||||
|
||||
@@ -187,7 +191,7 @@ public class Item implements Comparable<Item> {
|
||||
public Pet getPet() {
|
||||
return pet;
|
||||
}
|
||||
|
||||
|
||||
public boolean isUntradeable() {
|
||||
return ((this.getFlag() & ItemConstants.UNTRADEABLE) == ItemConstants.UNTRADEABLE) || (ItemInformationProvider.getInstance().isDropRestricted(this.getItemId()) && !KarmaManipulator.hasKarmaFlag(this));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.List;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Flav
|
||||
*/
|
||||
public enum ItemFactory {
|
||||
@@ -47,17 +46,17 @@ public enum ItemFactory {
|
||||
DUEY(9, false);
|
||||
private final int value;
|
||||
private final boolean account;
|
||||
|
||||
|
||||
private static final int lockCount = 400;
|
||||
private static final Lock[] locks = new Lock[lockCount]; // thanks Masterrulax for pointing out a bottleneck issue here
|
||||
|
||||
|
||||
static {
|
||||
for (int i = 0; i < lockCount; i++) {
|
||||
locks[i] = MonitoredReentrantLockFactory.createLock(MonitoredLockType.ITEM, true);
|
||||
}
|
||||
}
|
||||
|
||||
private ItemFactory(int value, boolean account) {
|
||||
|
||||
ItemFactory(int value, boolean account) {
|
||||
this.value = value;
|
||||
this.account = account;
|
||||
}
|
||||
@@ -67,21 +66,27 @@ public enum ItemFactory {
|
||||
}
|
||||
|
||||
public List<Pair<Item, InventoryType>> loadItems(int id, boolean login) throws SQLException {
|
||||
if(value != 6) return loadItemsCommon(id, login);
|
||||
else return loadItemsMerchant(id, login);
|
||||
if (value != 6) {
|
||||
return loadItemsCommon(id, login);
|
||||
} else {
|
||||
return loadItemsMerchant(id, login);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void saveItems(List<Pair<Item, InventoryType>> items, int id, Connection con) throws SQLException {
|
||||
saveItems(items, null, id, con);
|
||||
}
|
||||
|
||||
|
||||
public void saveItems(List<Pair<Item, InventoryType>> items, List<Short> bundlesList, int id, Connection con) throws SQLException {
|
||||
// thanks Arufonsu, MedicOP, BHB for pointing a "synchronized" bottleneck here
|
||||
|
||||
if(value != 6) saveItemsCommon(items, id, con);
|
||||
else saveItemsMerchant(items, bundlesList, id, con);
|
||||
|
||||
if (value != 6) {
|
||||
saveItemsCommon(items, id, con);
|
||||
} else {
|
||||
saveItemsMerchant(items, bundlesList, id, con);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Equip loadEquipFromResultSet(ResultSet rs) throws SQLException {
|
||||
Equip equip = new Equip(rs.getInt("itemid"), (short) rs.getInt("position"));
|
||||
equip.setOwner(rs.getString("owner"));
|
||||
@@ -110,13 +115,13 @@ public enum ItemFactory {
|
||||
equip.setExpiration(rs.getLong("expiration"));
|
||||
equip.setGiftFrom(rs.getString("giftFrom"));
|
||||
equip.setRingId(rs.getInt("ringid"));
|
||||
|
||||
|
||||
return equip;
|
||||
}
|
||||
|
||||
|
||||
public static List<Pair<Item, Integer>> loadEquippedItems(int id, boolean isAccount, boolean login) throws SQLException {
|
||||
List<Pair<Item, Integer>> items = new ArrayList<>();
|
||||
|
||||
|
||||
StringBuilder query = new StringBuilder();
|
||||
query.append("SELECT * FROM ");
|
||||
query.append("(SELECT id, accountid FROM characters) AS accountterm ");
|
||||
@@ -127,11 +132,11 @@ public enum ItemFactory {
|
||||
query.append(isAccount ? "accountid" : "characterid");
|
||||
query.append("` = ?");
|
||||
query.append(login ? " AND `inventorytype` = " + InventoryType.EQUIPPED.getType() : "");
|
||||
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement(query.toString())) {
|
||||
ps.setInt(1, id);
|
||||
|
||||
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
Integer cid = rs.getInt("characterid");
|
||||
@@ -140,10 +145,10 @@ public enum ItemFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
private List<Pair<Item, InventoryType>> loadItemsCommon(int id, boolean login) throws SQLException {
|
||||
List<Pair<Item, InventoryType>> items = new ArrayList<>();
|
||||
|
||||
@@ -262,7 +267,7 @@ public enum ItemFactory {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<Pair<Item, InventoryType>> loadItemsMerchant(int id, boolean login) throws SQLException {
|
||||
List<Pair<Item, InventoryType>> items = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package client.inventory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevin
|
||||
*/
|
||||
public class ModifyInventory {
|
||||
|
||||
private int mode;
|
||||
private final int mode;
|
||||
private Item item;
|
||||
private short oldPos;
|
||||
|
||||
@@ -20,7 +19,7 @@ public class ModifyInventory {
|
||||
this.item = item.copy();
|
||||
this.oldPos = oldPos;
|
||||
}
|
||||
|
||||
|
||||
public final int getMode() {
|
||||
return mode;
|
||||
}
|
||||
@@ -36,7 +35,7 @@ public class ModifyInventory {
|
||||
public final short getOldPosition() {
|
||||
return oldPos;
|
||||
}
|
||||
|
||||
|
||||
public final short getQuantity() {
|
||||
return item.getQuantity();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,10 @@ package client.inventory;
|
||||
* @author Leifde
|
||||
*/
|
||||
public class PetCommand {
|
||||
private int petId, skillId, prob, inc;
|
||||
private final int petId;
|
||||
private final int skillId;
|
||||
private final int prob;
|
||||
private final int inc;
|
||||
|
||||
public PetCommand(int petId, int skillId, int prob, int inc) {
|
||||
this.petId = petId;
|
||||
|
||||
@@ -31,13 +31,12 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Danny (Leifde)
|
||||
*/
|
||||
public class PetDataFactory {
|
||||
private static DataProvider dataRoot = DataProviderFactory.getDataProvider(WZFiles.ITEM);
|
||||
private static Map<String, PetCommand> petCommands = new HashMap<>();
|
||||
private static Map<Integer, Integer> petHunger = new HashMap<>();
|
||||
private static final DataProvider dataRoot = DataProviderFactory.getDataProvider(WZFiles.ITEM);
|
||||
private static final Map<String, PetCommand> petCommands = new HashMap<>();
|
||||
private static final Map<Integer, Integer> petHunger = new HashMap<>();
|
||||
|
||||
public static PetCommand getPetCommand(int petId, int skillId) {
|
||||
PetCommand ret = petCommands.get(petId + "" + skillId);
|
||||
|
||||
@@ -678,10 +678,14 @@ public class InventoryManipulator {
|
||||
} else if (ii.isCash(it.getItemId())) {
|
||||
if (YamlConfig.config.server.USE_ENFORCE_UNMERCHABLE_CASH) { // thanks Ari for noticing cash drops not available server-side
|
||||
return true;
|
||||
} else return ItemConstants.isPet(it.getItemId()) && YamlConfig.config.server.USE_ENFORCE_UNMERCHABLE_PET;
|
||||
} else {
|
||||
return ItemConstants.isPet(it.getItemId()) && YamlConfig.config.server.USE_ENFORCE_UNMERCHABLE_PET;
|
||||
}
|
||||
} else if (isDroppedItemRestricted(it)) {
|
||||
return true;
|
||||
} else return ItemConstants.isWeddingRing(it.getItemId());
|
||||
} else {
|
||||
return ItemConstants.isWeddingRing(it.getItemId());
|
||||
}
|
||||
}
|
||||
|
||||
public static void drop(Client c, InventoryType type, short src, short quantity) {
|
||||
|
||||
@@ -34,103 +34,102 @@ import java.util.Set;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan - credits to Eric for showing the New Year opcodes and handler layout
|
||||
*/
|
||||
public class NewYearCardRecord {
|
||||
private int id;
|
||||
|
||||
private int senderId;
|
||||
private String senderName;
|
||||
private boolean senderDiscardCard;
|
||||
|
||||
private int receiverId;
|
||||
private String receiverName;
|
||||
private boolean receiverDiscardCard;
|
||||
|
||||
private final int senderId;
|
||||
private final String senderName;
|
||||
private boolean senderDiscardCard;
|
||||
|
||||
private final int receiverId;
|
||||
private final String receiverName;
|
||||
private boolean receiverDiscardCard;
|
||||
private boolean receiverReceivedCard;
|
||||
|
||||
private String stringContent;
|
||||
|
||||
private final String stringContent;
|
||||
private long dateSent = 0;
|
||||
private long dateReceived = 0;
|
||||
|
||||
|
||||
private ScheduledFuture<?> sendTask = null;
|
||||
|
||||
|
||||
public NewYearCardRecord(int senderid, String sender, int receiverid, String receiver, String message) {
|
||||
this.id = -1;
|
||||
|
||||
|
||||
this.senderId = senderid;
|
||||
this.senderName = sender;
|
||||
this.senderDiscardCard = false;
|
||||
|
||||
|
||||
this.receiverId = receiverid;
|
||||
this.receiverName = receiver;
|
||||
this.receiverDiscardCard = false;
|
||||
this.receiverReceivedCard = false;
|
||||
|
||||
|
||||
this.stringContent = message;
|
||||
|
||||
|
||||
this.dateSent = System.currentTimeMillis();
|
||||
this.dateReceived = 0;
|
||||
}
|
||||
|
||||
|
||||
private void setExtraNewYearCardRecord(int id, boolean senderDiscardCard, boolean receiverDiscardCard, boolean receiverReceivedCard, long dateSent, long dateReceived) {
|
||||
this.id = id;
|
||||
this.senderDiscardCard = senderDiscardCard;
|
||||
this.receiverDiscardCard = receiverDiscardCard;
|
||||
this.receiverReceivedCard = receiverReceivedCard;
|
||||
|
||||
|
||||
this.dateSent = dateSent;
|
||||
this.dateReceived = dateReceived;
|
||||
}
|
||||
|
||||
|
||||
public void setId(int cardid) {
|
||||
this.id = cardid;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public int getSenderId() {
|
||||
return senderId;
|
||||
}
|
||||
|
||||
|
||||
public String getSenderName() {
|
||||
return senderName;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSenderCardDiscarded() {
|
||||
return senderDiscardCard;
|
||||
}
|
||||
|
||||
|
||||
public int getReceiverId() {
|
||||
return receiverId;
|
||||
}
|
||||
|
||||
|
||||
public String getReceiverName() {
|
||||
return receiverName;
|
||||
}
|
||||
|
||||
|
||||
public boolean isReceiverCardDiscarded() {
|
||||
return receiverDiscardCard;
|
||||
}
|
||||
|
||||
|
||||
public boolean isReceiverCardReceived() {
|
||||
return receiverReceivedCard;
|
||||
}
|
||||
|
||||
|
||||
public String getMessage() {
|
||||
return stringContent;
|
||||
}
|
||||
|
||||
|
||||
public long getDateSent() {
|
||||
return dateSent;
|
||||
}
|
||||
|
||||
|
||||
public long getDateReceived() {
|
||||
return dateReceived;
|
||||
}
|
||||
|
||||
|
||||
public static void saveNewYearCard(NewYearCardRecord newyear) {
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement("INSERT INTO newyear VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
|
||||
@@ -138,47 +137,49 @@ public class NewYearCardRecord {
|
||||
ps.setString(2, newyear.senderName);
|
||||
ps.setInt(3, newyear.receiverId);
|
||||
ps.setString(4, newyear.receiverName);
|
||||
|
||||
|
||||
ps.setString(5, newyear.stringContent);
|
||||
|
||||
|
||||
ps.setBoolean(6, newyear.senderDiscardCard);
|
||||
ps.setBoolean(7, newyear.receiverDiscardCard);
|
||||
ps.setBoolean(8, newyear.receiverReceivedCard);
|
||||
|
||||
|
||||
ps.setLong(9, newyear.dateSent);
|
||||
ps.setLong(10, newyear.dateReceived);
|
||||
|
||||
|
||||
ps.executeUpdate();
|
||||
try (ResultSet rs = ps.getGeneratedKeys()) {
|
||||
rs.next();
|
||||
newyear.id = rs.getInt(1);
|
||||
}
|
||||
}
|
||||
} catch(SQLException sqle) {
|
||||
} catch (SQLException sqle) {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void updateNewYearCard(NewYearCardRecord newyear) {
|
||||
newyear.receiverReceivedCard = true;
|
||||
newyear.dateReceived = System.currentTimeMillis();
|
||||
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE newyear SET received=1, timereceived=? WHERE id=?")) {
|
||||
ps.setLong(1, newyear.dateReceived);
|
||||
ps.setInt(2, newyear.id);
|
||||
|
||||
|
||||
ps.executeUpdate();
|
||||
}
|
||||
} catch(SQLException sqle) {
|
||||
} catch (SQLException sqle) {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static NewYearCardRecord loadNewYearCard(int cardid) {
|
||||
NewYearCardRecord nyc = Server.getInstance().getNewYearCard(cardid);
|
||||
if(nyc != null) return nyc;
|
||||
|
||||
if (nyc != null) {
|
||||
return nyc;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM newyear WHERE id = ?")) {
|
||||
ps.setInt(1, cardid);
|
||||
@@ -186,19 +187,19 @@ public class NewYearCardRecord {
|
||||
if (rs.next()) {
|
||||
NewYearCardRecord newyear = new NewYearCardRecord(rs.getInt("senderid"), rs.getString("sendername"), rs.getInt("receiverid"), rs.getString("receivername"), rs.getString("message"));
|
||||
newyear.setExtraNewYearCardRecord(rs.getInt("id"), rs.getBoolean("senderdiscard"), rs.getBoolean("receiverdiscard"), rs.getBoolean("received"), rs.getLong("timesent"), rs.getLong("timereceived"));
|
||||
|
||||
|
||||
Server.getInstance().setNewYearCard(newyear);
|
||||
return newyear;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(SQLException sqle) {
|
||||
} catch (SQLException sqle) {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static void loadPlayerNewYearCards(Character chr) {
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM newyear WHERE senderid = ? OR receiverid = ?")) {
|
||||
@@ -208,47 +209,49 @@ public class NewYearCardRecord {
|
||||
while (rs.next()) {
|
||||
NewYearCardRecord newyear = new NewYearCardRecord(rs.getInt("senderid"), rs.getString("sendername"), rs.getInt("receiverid"), rs.getString("receivername"), rs.getString("message"));
|
||||
newyear.setExtraNewYearCardRecord(rs.getInt("id"), rs.getBoolean("senderdiscard"), rs.getBoolean("receiverdiscard"), rs.getBoolean("received"), rs.getLong("timesent"), rs.getLong("timereceived"));
|
||||
|
||||
|
||||
chr.addNewYearRecord(newyear);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(SQLException sqle) {
|
||||
} catch (SQLException sqle) {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void printNewYearRecords(Character chr) {
|
||||
chr.dropMessage(5, "New Years: " + chr.getNewYearRecords().size());
|
||||
|
||||
for(NewYearCardRecord nyc : chr.getNewYearRecords()) {
|
||||
|
||||
for (NewYearCardRecord nyc : chr.getNewYearRecords()) {
|
||||
chr.dropMessage(5, "-------------------------------");
|
||||
|
||||
|
||||
chr.dropMessage(5, "Id: " + nyc.id);
|
||||
|
||||
|
||||
chr.dropMessage(5, "Sender id: " + nyc.senderId);
|
||||
chr.dropMessage(5, "Sender name: " + nyc.senderName);
|
||||
chr.dropMessage(5, "Sender discard: " + nyc.senderDiscardCard);
|
||||
|
||||
|
||||
chr.dropMessage(5, "Receiver id: " + nyc.receiverId);
|
||||
chr.dropMessage(5, "Receiver name: " + nyc.receiverName);
|
||||
chr.dropMessage(5, "Receiver discard: " + nyc.receiverDiscardCard);
|
||||
chr.dropMessage(5, "Received: " + nyc.receiverReceivedCard);
|
||||
|
||||
|
||||
chr.dropMessage(5, "Message: " + nyc.stringContent);
|
||||
chr.dropMessage(5, "Date sent: " + nyc.dateSent);
|
||||
chr.dropMessage(5, "Date recv: " + nyc.dateReceived);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void startNewYearCardTask() {
|
||||
if(sendTask != null) return;
|
||||
|
||||
if (sendTask != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendTask = TimerManager.getInstance().register(() -> {
|
||||
Server server = Server.getInstance();
|
||||
|
||||
int world = server.getCharacterWorld(receiverId);
|
||||
if(world == -1) {
|
||||
if (world == -1) {
|
||||
sendTask.cancel(false);
|
||||
sendTask = null;
|
||||
|
||||
@@ -256,32 +259,32 @@ public class NewYearCardRecord {
|
||||
}
|
||||
|
||||
Character target = server.getWorld(world).getPlayerStorage().getCharacterById(receiverId);
|
||||
if(target != null && target.isLoggedinWorld()) {
|
||||
if (target != null && target.isLoggedinWorld()) {
|
||||
target.sendPacket(PacketCreator.onNewYearCardRes(target, NewYearCardRecord.this, 0xC, 0));
|
||||
}
|
||||
}, 1000 * 60 * 60); //1 Hour
|
||||
}
|
||||
|
||||
|
||||
public void stopNewYearCardTask() {
|
||||
if(sendTask != null) {
|
||||
if (sendTask != null) {
|
||||
sendTask.cancel(false);
|
||||
sendTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void deleteNewYearCard(int id) {
|
||||
Server.getInstance().removeNewYearCard(id);
|
||||
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM newyear WHERE id = ?")) {
|
||||
ps.setInt(1, id);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
} catch(SQLException sqle) {
|
||||
} catch (SQLException sqle) {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void removeAllNewYearCard(boolean send, Character chr) {
|
||||
int cid = chr.getId();
|
||||
|
||||
@@ -297,21 +300,21 @@ public class NewYearCardRecord {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Set<NewYearCardRecord> set = new HashSet<>(chr.getNewYearRecords());
|
||||
for(NewYearCardRecord nyc : set) {
|
||||
if(send) {
|
||||
if(nyc.senderId == cid) {
|
||||
for (NewYearCardRecord nyc : set) {
|
||||
if (send) {
|
||||
if (nyc.senderId == cid) {
|
||||
nyc.senderDiscardCard = true;
|
||||
nyc.receiverReceivedCard = false;
|
||||
|
||||
|
||||
chr.removeNewYearRecord(nyc);
|
||||
deleteNewYearCard(nyc.id);
|
||||
|
||||
|
||||
chr.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(chr, nyc, 0xE, 0));
|
||||
|
||||
Character other = chr.getClient().getWorldServer().getPlayerStorage().getCharacterById(nyc.getReceiverId());
|
||||
if(other != null && other.isLoggedinWorld()) {
|
||||
if (other != null && other.isLoggedinWorld()) {
|
||||
other.removeNewYearRecord(nyc);
|
||||
other.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(other, nyc, 0xE, 0));
|
||||
|
||||
@@ -319,17 +322,17 @@ public class NewYearCardRecord {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(nyc.receiverId == cid) {
|
||||
if (nyc.receiverId == cid) {
|
||||
nyc.receiverDiscardCard = true;
|
||||
nyc.receiverReceivedCard = false;
|
||||
|
||||
|
||||
chr.removeNewYearRecord(nyc);
|
||||
deleteNewYearCard(nyc.id);
|
||||
|
||||
|
||||
chr.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(chr, nyc, 0xE, 0));
|
||||
|
||||
Character other = chr.getClient().getWorldServer().getPlayerStorage().getCharacterById(nyc.getSenderId());
|
||||
if(other != null && other.isLoggedinWorld()) {
|
||||
if (other != null && other.isLoggedinWorld()) {
|
||||
other.removeNewYearRecord(nyc);
|
||||
other.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(other, nyc, 0xE, 0));
|
||||
|
||||
|
||||
@@ -25,15 +25,14 @@ import server.maps.MapleMap;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class BuybackProcessor {
|
||||
|
||||
|
||||
public static void processBuyback(Client c) {
|
||||
Character chr = c.getPlayer();
|
||||
boolean buyback;
|
||||
|
||||
|
||||
c.lockClient();
|
||||
try {
|
||||
buyback = !chr.isAlive() && chr.couldBuyback();
|
||||
@@ -43,7 +42,7 @@ public class BuybackProcessor {
|
||||
|
||||
if (buyback) {
|
||||
String jobString;
|
||||
switch(chr.getJobStyle()) {
|
||||
switch (chr.getJobStyle()) {
|
||||
case WARRIOR:
|
||||
jobString = "warrior";
|
||||
break;
|
||||
@@ -72,7 +71,7 @@ public class BuybackProcessor {
|
||||
chr.healHpMp();
|
||||
chr.purgeDebuffs();
|
||||
chr.broadcastStance(chr.isFacingLeft() ? 5 : 4);
|
||||
|
||||
|
||||
MapleMap map = chr.getMap();
|
||||
map.broadcastMessage(PacketCreator.playSound("Buyback/" + jobString));
|
||||
map.broadcastMessage(PacketCreator.earnTitleMessage(chr.getName() + " just bought back into the game!"));
|
||||
|
||||
@@ -42,12 +42,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MakerProcessor {
|
||||
|
||||
private static ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
private static final ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
public static void makerAction(InPacket p, Client c) {
|
||||
if (c.tryacquireClient()) {
|
||||
@@ -61,26 +60,26 @@ public class MakerProcessor {
|
||||
Map<Integer, Short> reagentids = new LinkedHashMap<>();
|
||||
int stimulantid = -1;
|
||||
|
||||
if(type == 3) { // building monster crystal
|
||||
if (type == 3) { // building monster crystal
|
||||
int fromLeftover = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromLeftover(toCreate);
|
||||
if(toCreate == -1) {
|
||||
if (toCreate == -1) {
|
||||
c.sendPacket(PacketCreator.serverNotice(1, ii.getName(fromLeftover) + " is unavailable for Monster Crystal conversion."));
|
||||
c.sendPacket(PacketCreator.makerEnableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
recipe = MakerItemFactory.generateLeftoverCrystalEntry(fromLeftover, toCreate);
|
||||
} else if(type == 4) { // disassembling
|
||||
} else if (type == 4) { // disassembling
|
||||
p.readInt(); // 1... probably inventory type
|
||||
pos = p.readInt();
|
||||
|
||||
Item it = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((short) pos);
|
||||
if(it != null && it.getItemId() == toCreate) {
|
||||
if (it != null && it.getItemId() == toCreate) {
|
||||
toDisassemble = toCreate;
|
||||
|
||||
|
||||
Pair<Integer, List<Pair<Integer, Integer>>> pair = generateDisassemblyInfo(toDisassemble);
|
||||
if(pair != null) {
|
||||
if (pair != null) {
|
||||
recipe = MakerItemFactory.generateDisassemblyCrystalEntry(toDisassemble, pair.getLeft(), pair.getRight());
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal disassembly."));
|
||||
@@ -93,20 +92,20 @@ public class MakerProcessor {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents
|
||||
if(p.readByte() != 0) { // stimulant
|
||||
if (ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents
|
||||
if (p.readByte() != 0) { // stimulant
|
||||
stimulantid = ii.getMakerStimulant(toCreate);
|
||||
if(!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
|
||||
if (!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
|
||||
stimulantid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int reagents = Math.min(p.readInt(), getMakerReagentSlots(toCreate));
|
||||
for(int i = 0; i < reagents; i++) { // crystals
|
||||
for (int i = 0; i < reagents; i++) { // crystals
|
||||
int reagentid = p.readInt();
|
||||
if(ItemConstants.isMakerReagent(reagentid)) {
|
||||
if (ItemConstants.isMakerReagent(reagentid)) {
|
||||
Short rs = reagentids.get(reagentid);
|
||||
if(rs == null) {
|
||||
if (rs == null) {
|
||||
reagentids.put(reagentid, (short) 1);
|
||||
} else {
|
||||
reagentids.put(reagentid, (short) (rs + 1));
|
||||
@@ -115,18 +114,18 @@ public class MakerProcessor {
|
||||
}
|
||||
|
||||
List<Pair<Integer, Short>> toUpdate = new LinkedList<>();
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
for (Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
int qty = c.getAbstractPlayerInteraction().getItemQuantity(r.getKey());
|
||||
|
||||
if(qty < r.getValue()) {
|
||||
if (qty < r.getValue()) {
|
||||
toUpdate.add(new Pair<>(r.getKey(), (short) qty));
|
||||
}
|
||||
}
|
||||
|
||||
// remove those not present on player inventory
|
||||
if(!toUpdate.isEmpty()) {
|
||||
for(Pair<Integer, Short> rp : toUpdate) {
|
||||
if(rp.getRight() > 0) {
|
||||
if (!toUpdate.isEmpty()) {
|
||||
for (Pair<Integer, Short> rp : toUpdate) {
|
||||
if (rp.getRight() > 0) {
|
||||
reagentids.put(rp.getLeft(), rp.getRight());
|
||||
} else {
|
||||
reagentids.remove(rp.getLeft());
|
||||
@@ -134,8 +133,8 @@ public class MakerProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
if(!reagentids.isEmpty()) {
|
||||
if(!removeOddMakerReagents(toCreate, reagentids)) {
|
||||
if (!reagentids.isEmpty()) {
|
||||
if (!removeOddMakerReagents(toCreate, reagentids)) {
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "You can only use WATK and MATK Strengthening Gems on weapon items."));
|
||||
c.sendPacket(PacketCreator.makerEnableActions());
|
||||
return;
|
||||
@@ -148,7 +147,7 @@ public class MakerProcessor {
|
||||
|
||||
short createStatus = getCreateStatus(c, recipe);
|
||||
|
||||
switch(createStatus) {
|
||||
switch (createStatus) {
|
||||
case -1:// non-available for Maker itemid has been tried to forge
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS, "Player " + c.getPlayer().getName() + " tried to craft itemid " + toCreate + " using the Maker skill.");
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "The requested item could not be crafted on this operation."));
|
||||
@@ -174,14 +173,14 @@ public class MakerProcessor {
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "You don't have enough Maker level to complete this operation."));
|
||||
c.sendPacket(PacketCreator.makerEnableActions());
|
||||
break;
|
||||
|
||||
|
||||
case 5: // inventory full
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "Your inventory is full."));
|
||||
c.sendPacket(PacketCreator.makerEnableActions());
|
||||
break;
|
||||
|
||||
default:
|
||||
if(toDisassemble != -1) {
|
||||
if (toDisassemble != -1) {
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (short) pos, (short) 1, false);
|
||||
} else {
|
||||
for (Pair<Integer, Integer> pair : recipe.getReqItems()) {
|
||||
@@ -190,9 +189,11 @@ public class MakerProcessor {
|
||||
}
|
||||
|
||||
int cost = recipe.getCost();
|
||||
if(stimulantid == -1 && reagentids.isEmpty()) {
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost, false);
|
||||
|
||||
if (stimulantid == -1 && reagentids.isEmpty()) {
|
||||
if (cost > 0) {
|
||||
c.getPlayer().gainMeso(-cost, false);
|
||||
}
|
||||
|
||||
for (Pair<Integer, Integer> pair : recipe.getGainItems()) {
|
||||
c.getPlayer().setCS(true);
|
||||
c.getAbstractPlayerInteraction().gainItem(pair.getLeft(), pair.getRight().shortValue(), false);
|
||||
@@ -200,15 +201,19 @@ public class MakerProcessor {
|
||||
}
|
||||
} else {
|
||||
toCreate = recipe.getGainItems().get(0).getLeft();
|
||||
|
||||
if(stimulantid != -1) c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1, false);
|
||||
if(!reagentids.isEmpty()) {
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
|
||||
if (stimulantid != -1) {
|
||||
c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1, false);
|
||||
}
|
||||
if (!reagentids.isEmpty()) {
|
||||
for (Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(r.getKey(), (short) (-1 * r.getValue()), false);
|
||||
}
|
||||
}
|
||||
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost, false);
|
||||
if (cost > 0) {
|
||||
c.getPlayer().gainMeso(-cost, false);
|
||||
}
|
||||
makerSucceeded = addBoostedMakerItem(c, toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
@@ -220,11 +225,11 @@ public class MakerProcessor {
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.makerResult(makerSucceeded, recipe.getGainItems().get(0).getLeft(), recipe.getGainItems().get(0).getRight(), recipe.getCost(), recipe.getReqItems(), stimulantid, new LinkedList<>(reagentids.keySet())));
|
||||
}
|
||||
|
||||
|
||||
c.sendPacket(PacketCreator.showMakerEffect(makerSucceeded));
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), PacketCreator.showForeignMakerEffect(c.getPlayer().getId(), makerSucceeded), false);
|
||||
|
||||
if(toCreate == 4260003 && type == 3 && c.getPlayer().getQuestStatus(6033) == 1) {
|
||||
if (toCreate == 4260003 && type == 3 && c.getPlayer().getQuestStatus(6033) == 1) {
|
||||
c.getAbstractPlayerInteraction().setQuestProgress(6033, 1);
|
||||
}
|
||||
}
|
||||
@@ -233,25 +238,25 @@ public class MakerProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// checks and prevents hackers from PE'ing Maker operations with invalid operations
|
||||
private static boolean removeOddMakerReagents(int toCreate, Map<Integer, Short> reagentids) {
|
||||
Map<Integer, Integer> reagentType = new LinkedHashMap<>();
|
||||
List<Integer> toRemove = new LinkedList<>();
|
||||
|
||||
|
||||
boolean isWeapon = ItemConstants.isWeapon(toCreate) || YamlConfig.config.server.USE_MAKER_PERMISSIVE_ATKUP; // thanks Vcoc for finding a case where a weapon wouldn't be counted as such due to a bounding on isWeapon
|
||||
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
|
||||
for (Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
int curRid = r.getKey();
|
||||
int type = r.getKey() / 100;
|
||||
|
||||
if(type < 42502 && !isWeapon) { // only weapons should gain w.att/m.att from these.
|
||||
|
||||
if (type < 42502 && !isWeapon) { // only weapons should gain w.att/m.att from these.
|
||||
return false; //toRemove.add(curRid);
|
||||
} else {
|
||||
Integer tableRid = reagentType.get(type);
|
||||
|
||||
if(tableRid != null) {
|
||||
if(tableRid < curRid) {
|
||||
|
||||
if (tableRid != null) {
|
||||
if (tableRid < curRid) {
|
||||
toRemove.add(tableRid);
|
||||
reagentType.put(type, curRid);
|
||||
} else {
|
||||
@@ -262,92 +267,92 @@ public class MakerProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// removing less effective gems of repeated type
|
||||
for(Integer i : toRemove) {
|
||||
for (Integer i : toRemove) {
|
||||
reagentids.remove(i);
|
||||
}
|
||||
|
||||
|
||||
// the Maker skill will use only one of each gem
|
||||
for(Integer i : reagentids.keySet()) {
|
||||
for (Integer i : reagentids.keySet()) {
|
||||
reagentids.put(i, (short) 1);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static int getMakerReagentSlots(int itemId) {
|
||||
try {
|
||||
int eqpLevel = ii.getEquipLevelReq(itemId);
|
||||
|
||||
if(eqpLevel < 78) {
|
||||
|
||||
if (eqpLevel < 78) {
|
||||
return 1;
|
||||
} else if(eqpLevel >= 78 && eqpLevel < 108) {
|
||||
} else if (eqpLevel >= 78 && eqpLevel < 108) {
|
||||
return 2;
|
||||
} else {
|
||||
return 3;
|
||||
}
|
||||
} catch(NullPointerException npe) {
|
||||
} catch (NullPointerException npe) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Pair<Integer, List<Pair<Integer, Integer>>> generateDisassemblyInfo(int itemId) {
|
||||
int recvFee = ii.getMakerDisassembledFee(itemId);
|
||||
if(recvFee > -1) {
|
||||
if (recvFee > -1) {
|
||||
List<Pair<Integer, Integer>> gains = ii.getMakerDisassembledItems(itemId);
|
||||
if(!gains.isEmpty()) {
|
||||
if (!gains.isEmpty()) {
|
||||
return new Pair<>(recvFee, gains);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static int getMakerSkillLevel(Character chr) {
|
||||
return chr.getSkillLevel((chr.getJob().getId() / 1000) * 10000000 + 1007);
|
||||
}
|
||||
|
||||
|
||||
private static short getCreateStatus(Client c, MakerItemCreateEntry recipe) {
|
||||
if(recipe.isInvalid()) {
|
||||
if (recipe.isInvalid()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!hasItems(c, recipe)) {
|
||||
|
||||
if (!hasItems(c, recipe)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(c.getPlayer().getMeso() < recipe.getCost()) {
|
||||
|
||||
if (c.getPlayer().getMeso() < recipe.getCost()) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(c.getPlayer().getLevel() < recipe.getReqLevel()) {
|
||||
|
||||
if (c.getPlayer().getLevel() < recipe.getReqLevel()) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if(getMakerSkillLevel(c.getPlayer()) < recipe.getReqSkillLevel()) {
|
||||
|
||||
if (getMakerSkillLevel(c.getPlayer()) < recipe.getReqSkillLevel()) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
List<Integer> addItemids = new LinkedList<>();
|
||||
List<Integer> addQuantity = new LinkedList<>();
|
||||
List<Integer> rmvItemids = new LinkedList<>();
|
||||
List<Integer> rmvQuantity = new LinkedList<>();
|
||||
|
||||
|
||||
for (Pair<Integer, Integer> p : recipe.getReqItems()) {
|
||||
rmvItemids.add(p.getLeft());
|
||||
rmvQuantity.add(p.getRight());
|
||||
}
|
||||
|
||||
|
||||
for (Pair<Integer, Integer> p : recipe.getGainItems()) {
|
||||
addItemids.add(p.getLeft());
|
||||
addQuantity.add(p.getRight());
|
||||
}
|
||||
|
||||
|
||||
if (!c.getAbstractPlayerInteraction().canHoldAllAfterRemoving(addItemids, addQuantity, rmvItemids, rmvQuantity)) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -360,58 +365,62 @@ public class MakerProcessor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static boolean addBoostedMakerItem(Client c, int itemid, int stimulantid, Map<Integer, Short> reagentids) {
|
||||
if(stimulantid != -1 && !ii.rollSuccessChance(90.0)) {
|
||||
if (stimulantid != -1 && !ItemInformationProvider.rollSuccessChance(90.0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Item item = ii.getEquipById(itemid);
|
||||
if(item == null) return false;
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Equip eqp = (Equip)item;
|
||||
if(ItemConstants.isAccessory(item.getItemId()) && eqp.getUpgradeSlots() <= 0) eqp.setUpgradeSlots(3);
|
||||
Equip eqp = (Equip) item;
|
||||
if (ItemConstants.isAccessory(item.getItemId()) && eqp.getUpgradeSlots() <= 0) {
|
||||
eqp.setUpgradeSlots(3);
|
||||
}
|
||||
|
||||
if(YamlConfig.config.server.USE_ENHANCED_CRAFTING == true) {
|
||||
if(!(c.getPlayer().isGM() && YamlConfig.config.server.USE_PERFECT_GM_SCROLL)) {
|
||||
eqp.setUpgradeSlots((byte)(eqp.getUpgradeSlots() + 1));
|
||||
if (YamlConfig.config.server.USE_ENHANCED_CRAFTING == true) {
|
||||
if (!(c.getPlayer().isGM() && YamlConfig.config.server.USE_PERFECT_GM_SCROLL)) {
|
||||
eqp.setUpgradeSlots((byte) (eqp.getUpgradeSlots() + 1));
|
||||
}
|
||||
item = ItemInformationProvider.getInstance().scrollEquipWithId(eqp, 2049100, true, 2049100, c.getPlayer().isGM());
|
||||
}
|
||||
|
||||
if(!reagentids.isEmpty()) {
|
||||
|
||||
if (!reagentids.isEmpty()) {
|
||||
Map<String, Integer> stats = new LinkedHashMap<>();
|
||||
List<Short> randOption = new LinkedList<>();
|
||||
List<Short> randStat = new LinkedList<>();
|
||||
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
|
||||
for (Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
Pair<String, Integer> reagentBuff = ii.getMakerReagentStatUpgrade(r.getKey());
|
||||
|
||||
if(reagentBuff != null) {
|
||||
|
||||
if (reagentBuff != null) {
|
||||
String s = reagentBuff.getLeft();
|
||||
|
||||
if(s.substring(0, 4).contains("rand")) {
|
||||
if(s.substring(4).equals("Stat")) {
|
||||
|
||||
if (s.substring(0, 4).contains("rand")) {
|
||||
if (s.substring(4).equals("Stat")) {
|
||||
randStat.add((short) (reagentBuff.getRight() * r.getValue()));
|
||||
} else {
|
||||
randOption.add((short) (reagentBuff.getRight() * r.getValue()));
|
||||
}
|
||||
} else {
|
||||
String stat = s.substring(3);
|
||||
|
||||
if(!stat.equals("ReqLevel")) { // improve req level... really?
|
||||
|
||||
if (!stat.equals("ReqLevel")) { // improve req level... really?
|
||||
switch (stat) {
|
||||
case "MaxHP":
|
||||
stat = "MHP";
|
||||
break;
|
||||
|
||||
|
||||
case "MaxMP":
|
||||
stat = "MMP";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Integer d = stats.get(stat);
|
||||
if(d == null) {
|
||||
if (d == null) {
|
||||
stats.put(stat, reagentBuff.getRight() * r.getValue());
|
||||
} else {
|
||||
stats.put(stat, d + (reagentBuff.getRight() * r.getValue()));
|
||||
@@ -420,22 +429,22 @@ public class MakerProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ii.improveEquipStats(eqp, stats);
|
||||
|
||||
for(Short sh : randStat) {
|
||||
|
||||
ItemInformationProvider.improveEquipStats(eqp, stats);
|
||||
|
||||
for (Short sh : randStat) {
|
||||
ii.scrollOptionEquipWithChaos(eqp, sh, false);
|
||||
}
|
||||
|
||||
for(Short sh : randOption) {
|
||||
|
||||
for (Short sh : randOption) {
|
||||
ii.scrollOptionEquipWithChaos(eqp, sh, true);
|
||||
}
|
||||
}
|
||||
|
||||
if(stimulantid != -1) {
|
||||
|
||||
if (stimulantid != -1) {
|
||||
eqp = ii.randomizeUpgradeStats(eqp);
|
||||
}
|
||||
|
||||
|
||||
InventoryManipulator.addFromDrop(c, item, false, -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,34 +35,33 @@ import tools.PacketCreator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan - multi-pot consumption feature
|
||||
*/
|
||||
public class PetAutopotProcessor {
|
||||
|
||||
|
||||
private static class AutopotAction {
|
||||
|
||||
private Client c;
|
||||
|
||||
private final Client c;
|
||||
private short slot;
|
||||
private int itemId;
|
||||
|
||||
private final int itemId;
|
||||
|
||||
private Item toUse;
|
||||
private List<Item> toUseList;
|
||||
|
||||
private boolean hasHpGain, hasMpGain;
|
||||
private int maxHp, maxMp, curHp, curMp;
|
||||
private double incHp, incMp;
|
||||
|
||||
|
||||
private boolean cursorOnNextAvailablePot(Character chr) {
|
||||
if(toUseList == null) {
|
||||
if (toUseList == null) {
|
||||
toUseList = chr.getInventory(InventoryType.USE).linkedListById(itemId);
|
||||
}
|
||||
|
||||
toUse = null;
|
||||
while(!toUseList.isEmpty()) {
|
||||
while (!toUseList.isEmpty()) {
|
||||
Item it = toUseList.remove(0);
|
||||
|
||||
if(it.getQuantity() > 0) {
|
||||
if (it.getQuantity() > 0) {
|
||||
toUse = it;
|
||||
slot = it.getPosition();
|
||||
|
||||
@@ -72,13 +71,13 @@ public class PetAutopotProcessor {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public AutopotAction(Client c, short slot, int itemId) {
|
||||
this.c = c;
|
||||
this.slot = slot;
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
Client c = this.c;
|
||||
Character chr = c.getPlayer();
|
||||
@@ -86,10 +85,10 @@ public class PetAutopotProcessor {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int useCount = 0, qtyCount = 0;
|
||||
StatEffect stat = null;
|
||||
|
||||
|
||||
maxHp = chr.getCurrentMaxHp();
|
||||
maxMp = chr.getCurrentMaxMp();
|
||||
|
||||
@@ -119,12 +118,16 @@ public class PetAutopotProcessor {
|
||||
stat = ItemInformationProvider.getInstance().getItemEffect(toUse.getItemId());
|
||||
hasHpGain = stat.getHp() > 0 || stat.getHpRate() > 0.0;
|
||||
hasMpGain = stat.getMp() > 0 || stat.getMpRate() > 0.0;
|
||||
|
||||
|
||||
incHp = stat.getHp();
|
||||
if(incHp <= 0 && hasHpGain) incHp = Math.ceil(maxHp * stat.getHpRate());
|
||||
if (incHp <= 0 && hasHpGain) {
|
||||
incHp = Math.ceil(maxHp * stat.getHpRate());
|
||||
}
|
||||
|
||||
incMp = stat.getMp();
|
||||
if(incMp <= 0 && hasMpGain) incMp = Math.ceil(maxMp * stat.getMpRate());
|
||||
if (incMp <= 0 && hasMpGain) {
|
||||
incMp = Math.ceil(maxMp * stat.getMpRate());
|
||||
}
|
||||
|
||||
if (YamlConfig.config.server.USE_COMPULSORY_AUTOPOT) {
|
||||
if (hasHpGain) {
|
||||
@@ -140,7 +143,7 @@ public class PetAutopotProcessor {
|
||||
qtyCount = Math.max(qtyCount, (int) Math.ceil(mpRatio / incMp));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (qtyCount < 0) { // thanks Flint, Kevs for noticing an issue where negative counts were getting achieved
|
||||
qtyCount = 0;
|
||||
}
|
||||
@@ -158,10 +161,10 @@ public class PetAutopotProcessor {
|
||||
useCount += qtyToUse;
|
||||
qtyCount -= qtyToUse;
|
||||
|
||||
if(toUse.getQuantity() == 0 && qtyCount > 0) {
|
||||
if (toUse.getQuantity() == 0 && qtyCount > 0) {
|
||||
// depleted out the current slot, fetch for more
|
||||
|
||||
if(!cursorOnNextAvailablePot(chr)) {
|
||||
if (!cursorOnNextAvailablePot(chr)) {
|
||||
break; // no more pots available
|
||||
}
|
||||
} else {
|
||||
@@ -182,10 +185,10 @@ public class PetAutopotProcessor {
|
||||
chr.sendPacket(PacketCreator.enableActions());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void runAutopotAction(Client c, short slot, int itemid) {
|
||||
AutopotAction action = new AutopotAction(c, slot, itemid);
|
||||
action.run();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user