Reformat and clean up "client" package

This commit is contained in:
P0nk
2021-09-09 23:21:39 +02:00
parent 07f55fa53c
commit 9bf1b68924
108 changed files with 1770 additions and 1543 deletions

View File

@@ -20,7 +20,6 @@
package client; package client;
/** /**
*
* @author Ronan * @author Ronan
*/ */
public interface AbstractCharacterListener { public interface AbstractCharacterListener {

View File

@@ -40,9 +40,10 @@ public class BuddyList {
public enum BuddyAddResult { public enum BuddyAddResult {
BUDDYLIST_FULL, ALREADY_ON_LIST, OK 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 int capacity;
private Deque<CharacterNameAndId> pendingRequests = new LinkedList<>(); private final Deque<CharacterNameAndId> pendingRequests = new LinkedList<>();
public BuddyList(int capacity) { public BuddyList(int capacity) {
this.capacity = capacity; this.capacity = capacity;

View File

@@ -22,14 +22,13 @@
package client; package client;
public class BuddylistEntry { public class BuddylistEntry {
private String name; private final String name;
private String group; private String group;
private int cid; private final int cid;
private int channel; private int channel;
private boolean visible; private boolean visible;
/** /**
*
* @param name * @param name
* @param characterId * @param characterId
* @param channel should be -1 if the buddy is offline * @param channel should be -1 if the buddy is offline
@@ -102,9 +101,6 @@ public class BuddylistEntry {
return false; return false;
} }
final BuddylistEntry other = (BuddylistEntry) obj; final BuddylistEntry other = (BuddylistEntry) obj;
if (cid != other.cid) { return cid == other.cid;
return false;
}
return true;
} }
} }

View File

@@ -22,8 +22,8 @@
package client; package client;
public class CharacterNameAndId { public class CharacterNameAndId {
private int id; private final int id;
private String name; private final String name;
public CharacterNameAndId(int id, String name) { public CharacterNameAndId(int id, String name) {
super(); super();

View File

@@ -447,7 +447,9 @@ public class FamilyEntry {
public synchronized boolean isJunior(FamilyEntry entry) { //require locking since result accuracy is vital public synchronized boolean isJunior(FamilyEntry entry) { //require locking since result accuracy is vital
if (juniors[0] == entry) { if (juniors[0] == entry) {
return true; return true;
} else return juniors[1] == entry; } else {
return juniors[1] == entry;
}
} }
public synchronized boolean removeJunior(FamilyEntry junior) { public synchronized boolean removeJunior(FamilyEntry junior) {

View File

@@ -41,8 +41,8 @@ public final class MonsterBook {
private int specialCard = 0; private int specialCard = 0;
private int normalCard = 0; private int normalCard = 0;
private int bookLevel = 1; private int bookLevel = 1;
private Map<Integer, Integer> cards = new LinkedHashMap<>(); private final Map<Integer, Integer> cards = new LinkedHashMap<>();
private Lock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.BOOK); private final Lock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.BOOK);
public Set<Entry<Integer, Integer>> getCardSet() { public Set<Entry<Integer, Integer>> getCardSet() {
lock.lock(); lock.lock();

View File

@@ -28,11 +28,11 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Skill { public class Skill {
private int id; private final int id;
private List<StatEffect> effects = new ArrayList<>(); private final List<StatEffect> effects = new ArrayList<>();
private Element element; private Element element;
private int animationTime; private int animationTime;
private int job; private final int job;
private boolean action; private boolean action;
public Skill(int id) { public Skill(int id) {

View File

@@ -339,10 +339,11 @@ public class SkillFactory {
} }
if (data.getChildByPath(skill.toString()) != null) { if (data.getChildByPath(skill.toString()) != null) {
for (Data skilldata : data.getChildByPath(skill.toString()).getChildren()) { for (Data skilldata : data.getChildByPath(skill.toString()).getChildren()) {
if (skilldata.getName().equals("name")) if (skilldata.getName().equals("name")) {
return DataTool.getString(skilldata, null); return DataTool.getString(skilldata, null);
} }
} }
}
return null; return null;
} }

View File

@@ -25,9 +25,9 @@ public class SkillMacro {
private int skill1; private int skill1;
private int skill2; private int skill2;
private int skill3; private int skill3;
private String name; private final String name;
private int shout; private final int shout;
private int position; private final int position;
public SkillMacro(int skill1, int skill2, int skill3, String name, int shout, int position) { public SkillMacro(int skill1, int skill2, int skill3, String name, int shout, int position) {
this.skill1 = skill1; this.skill1 = skill1;

View File

@@ -30,7 +30,6 @@ import tools.FilePrinter;
import tools.PacketCreator; import tools.PacketCreator;
/** /**
*
* @author kevintjuh93 * @author kevintjuh93
*/ */
public enum AutobanFactory { public enum AutobanFactory {
@@ -54,19 +53,19 @@ public enum AutobanFactory {
FAST_ATTACK(10, 30000), FAST_ATTACK(10, 30000),
MPCON(25, 30000); MPCON(25, 30000);
private int points; private final int points;
private long expiretime; private final long expiretime;
private AutobanFactory() { AutobanFactory() {
this(1, -1); this(1, -1);
} }
private AutobanFactory(int points) { AutobanFactory(int points) {
this.points = points; this.points = points;
this.expiretime = -1; this.expiretime = -1;
} }
private AutobanFactory(int points, long expire) { AutobanFactory(int points, long expire) {
this.points = points; this.points = points;
this.expiretime = expire; this.expiretime = expire;
} }

View File

@@ -14,19 +14,18 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
*
* @author kevintjuh93 * @author kevintjuh93
*/ */
public class AutobanManager { public class AutobanManager {
private Character chr; private final Character chr;
private Map<AutobanFactory, Integer> points = new HashMap<>(); private final Map<AutobanFactory, Integer> points = new HashMap<>();
private Map<AutobanFactory, Long> lastTime = new HashMap<>(); private final Map<AutobanFactory, Long> lastTime = new HashMap<>();
private int misses = 0; private int misses = 0;
private int lastmisses = 0; private int lastmisses = 0;
private int samemisscount = 0; private int samemisscount = 0;
private long[] spam = new long[20]; private final long[] spam = new long[20];
private int[] timestamp = new int[20]; private final int[] timestamp = new int[20];
private byte[] timestampcounter = new byte[20]; private final byte[] timestampcounter = new byte[20];
public AutobanManager(Character chr) { public AutobanManager(Character chr) {
@@ -44,13 +43,15 @@ public class AutobanManager {
points.put(fac, points.get(fac) / 2); //So the points are not completely gone. 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()); lastTime.put(fac, Server.getInstance().getCurrentTime());
}
if (points.containsKey(fac)) { if (points.containsKey(fac)) {
points.put(fac, points.get(fac) + 1); points.put(fac, points.get(fac) + 1);
} else } else {
points.put(fac, 1); points.put(fac, 1);
}
if (points.get(fac) >= fac.getMaximum()) { if (points.get(fac) >= fac.getMaximum()) {
chr.autoban(reason); chr.autoban(reason);
@@ -70,12 +71,13 @@ public class AutobanManager {
if (lastmisses == misses && misses > 6) { if (lastmisses == misses && misses > 6) {
samemisscount++; samemisscount++;
} }
if (samemisscount > 4) if (samemisscount > 4) {
chr.sendPolice("You will be disconnected for miss godmode."); chr.sendPolice("You will be disconnected for miss godmode.");
}
//chr.autoban("Autobanned for : " + misses + " Miss godmode", 1); //chr.autoban("Autobanned for : " + misses + " Miss godmode", 1);
else if (samemisscount > 0) else if (samemisscount > 0) {
this.lastmisses = misses; this.lastmisses = misses;
}
this.misses = 0; this.misses = 0;
} }

View File

@@ -56,9 +56,9 @@ public class CommandsExecutor {
return heading == USER_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 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(); registerLv0Commands();
@@ -141,6 +141,7 @@ public class CommandsExecutor {
addCommand(syntax, 0, commandClass); 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){ //for (String syntax : syntaxs){
addCommand(syntax, 0, commandClass); addCommand(syntax, 0, commandClass);

View File

@@ -44,8 +44,9 @@ public class JoinEventCommand extends Command {
if (event.getLimit() > 0) { if (event.getLimit() > 0) {
player.saveLocation("EVENT"); player.saveLocation("EVENT");
if(event.getMapId() == 109080000 || event.getMapId() == 109060001) if (event.getMapId() == 109080000 || event.getMapId() == 109060001) {
player.setTeam(event.getLimit() % 2); player.setTeam(event.getLimit() % 2);
}
event.minusLimit(); event.minusLimit();

View File

@@ -43,7 +43,9 @@ public class RatesCommand extends Command {
showMsg_ += "MESO Rate: #e#b" + player.getMesoRate() + "x#k#n" + "\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_ += "DROP Rate: #e#b" + player.getDropRate() + "x#k#n" + "\r\n";
showMsg_ += "BOSS DROP Rate: #e#b" + player.getBossDropRate() + "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); player.showHint(showMsg_, 300);
} }

View File

@@ -39,25 +39,33 @@ public class ShowRatesCommand extends Command {
String showMsg = "#eEXP RATE#n" + "\r\n"; String showMsg = "#eEXP RATE#n" + "\r\n";
showMsg += "World EXP Rate: #k" + c.getWorldServer().getExpRate() + "x#k" + "\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"; 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 += "EXP Rate: #e#b" + player.getExpRate() + "x#k#n" + (player.hasNoviceExpRate() ? " - novice rate" : "") + "\r\n";
showMsg += "\r\n" + "#eMESO RATE#n" + "\r\n"; showMsg += "\r\n" + "#eMESO RATE#n" + "\r\n";
showMsg += "World MESO Rate: #k" + c.getWorldServer().getMesoRate() + "x#k" + "\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"; 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 += "MESO Rate: #e#b" + player.getMesoRate() + "x#k#n" + "\r\n";
showMsg += "\r\n" + "#eDROP RATE#n" + "\r\n"; showMsg += "\r\n" + "#eDROP RATE#n" + "\r\n";
showMsg += "World DROP Rate: #k" + c.getWorldServer().getDropRate() + "x#k" + "\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"; 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 += "DROP Rate: #e#b" + player.getDropRate() + "x#k#n" + "\r\n";
showMsg += "\r\n" + "#eBOSS DROP RATE#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 += "World BOSS DROP Rate: #k" + c.getWorldServer().getBossDropRate() + "x#k" + "\r\n";
showMsg += "Player DROP Rate: #k" + player.getRawDropRate() + "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"; 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) {

View File

@@ -43,16 +43,22 @@ public class ApCommand extends Command {
if (params.length < 2) { if (params.length < 2) {
int newAp = Integer.parseInt(params[0]); int newAp = Integer.parseInt(params[0]);
if (newAp < 0) newAp = 0; if (newAp < 0) {
else if (newAp > YamlConfig.config.server.MAX_AP) newAp = YamlConfig.config.server.MAX_AP; newAp = 0;
} else if (newAp > YamlConfig.config.server.MAX_AP) {
newAp = YamlConfig.config.server.MAX_AP;
}
player.changeRemainingAp(newAp, false); player.changeRemainingAp(newAp, false);
} else { } else {
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]); Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
if (victim != null) { if (victim != null) {
int newAp = Integer.parseInt(params[1]); int newAp = Integer.parseInt(params[1]);
if (newAp < 0) newAp = 0; if (newAp < 0) {
else if (newAp > YamlConfig.config.server.MAX_AP) newAp = YamlConfig.config.server.MAX_AP; newAp = 0;
} else if (newAp > YamlConfig.config.server.MAX_AP) {
newAp = YamlConfig.config.server.MAX_AP;
}
victim.changeRemainingAp(newAp, false); victim.changeRemainingAp(newAp, false);
} else { } else {

View File

@@ -44,6 +44,8 @@ public class BuffCommand extends Command {
int skillid = Integer.parseInt(params[0]); int skillid = Integer.parseInt(params[0]);
Skill skill = SkillFactory.getSkill(skillid); Skill skill = SkillFactory.getSkill(skillid);
if (skill != null) skill.getEffect(skill.getMaxLevel()).applyTo(player); if (skill != null) {
skill.getEffect(skill.getMaxLevel()).applyTo(player);
}
} }
} }

View File

@@ -47,32 +47,37 @@ public class ClearSlotCommand extends Command {
case "all": case "all":
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, false);
} }
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.USE).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.USE).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.USE, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.USE, (byte) i, tempItem.getQuantity(), false, false);
} }
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.ETC).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.ETC).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.ETC, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.ETC, (byte) i, tempItem.getQuantity(), false, false);
} }
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.SETUP).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.SETUP).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, false);
} }
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.CASH).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.CASH).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.CASH, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.CASH, (byte) i, tempItem.getQuantity(), false, false);
} }
player.yellowMessage("All Slots Cleared."); player.yellowMessage("All Slots Cleared.");
@@ -80,8 +85,9 @@ public class ClearSlotCommand extends Command {
case "equip": case "equip":
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, false);
} }
player.yellowMessage("Equipment Slot Cleared."); player.yellowMessage("Equipment Slot Cleared.");
@@ -89,8 +95,9 @@ public class ClearSlotCommand extends Command {
case "use": case "use":
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.USE).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.USE).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.USE, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.USE, (byte) i, tempItem.getQuantity(), false, false);
} }
player.yellowMessage("Use Slot Cleared."); player.yellowMessage("Use Slot Cleared.");
@@ -98,8 +105,9 @@ public class ClearSlotCommand extends Command {
case "setup": case "setup":
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.SETUP).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.SETUP).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, false);
} }
player.yellowMessage("Set-Up Slot Cleared."); player.yellowMessage("Set-Up Slot Cleared.");
@@ -107,8 +115,9 @@ public class ClearSlotCommand extends Command {
case "etc": case "etc":
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.ETC).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.ETC).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.ETC, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.ETC, (byte) i, tempItem.getQuantity(), false, false);
} }
player.yellowMessage("ETC Slot Cleared."); player.yellowMessage("ETC Slot Cleared.");
@@ -116,8 +125,9 @@ public class ClearSlotCommand extends Command {
case "cash": case "cash":
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(InventoryType.CASH).getItem((byte) i); Item tempItem = c.getPlayer().getInventory(InventoryType.CASH).getItem((byte) i);
if (tempItem == null) if (tempItem == null) {
continue; continue;
}
InventoryManipulator.removeFromSlot(c, InventoryType.CASH, (byte) i, tempItem.getQuantity(), false, false); InventoryManipulator.removeFromSlot(c, InventoryType.CASH, (byte) i, tempItem.getQuantity(), false, false);
} }
player.yellowMessage("Cash Slot Cleared."); player.yellowMessage("Cash Slot Cleared.");

View File

@@ -23,7 +23,6 @@ import client.Client;
import client.command.Command; import client.command.Command;
/** /**
*
* @author Ronan * @author Ronan
*/ */
public class GachaListCommand extends Command { public class GachaListCommand extends Command {

View File

@@ -85,10 +85,14 @@ public class IdCommand extends Command {
} }
private String joinStringArr(String[] arr, String separator) { 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); StringBuilder sb = new StringBuilder(256);
sb.append(arr[0]); 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(); return sb.toString();
} }

View File

@@ -55,7 +55,9 @@ public class ItemCommand extends Command {
} }
short quantity = 1; 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)) { if (YamlConfig.config.server.BLOCK_GENERATE_CASH_ITEM && ii.isCash(itemId)) {
player.yellowMessage("You cannot create a cash item with this command."); player.yellowMessage("You cannot create a cash item with this command.");

View File

@@ -56,7 +56,9 @@ public class ItemDropCommand extends Command {
} }
short quantity = 1; 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)) { if (YamlConfig.config.server.BLOCK_GENERATE_CASH_ITEM && ii.isCash(itemId)) {
player.yellowMessage("You cannot create a cash item with this command."); player.yellowMessage("You cannot create a cash item with this command.");

View File

@@ -45,7 +45,9 @@ public class LevelCommand extends Command {
player.setLevel(Math.min(Integer.parseInt(params[0]), player.getMaxClassLevel()) - 1); player.setLevel(Math.min(Integer.parseInt(params[0]), player.getMaxClassLevel()) - 1);
player.resetPlayerRates(); 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.setWorldRates();
player.levelUp(false); player.levelUp(false);

View File

@@ -45,7 +45,8 @@ public class MaxSkillCommand extends Command {
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
nfe.printStackTrace(); nfe.printStackTrace();
break; break;
} catch (NullPointerException npe) { } } catch (NullPointerException npe) {
}
} }
if (player.getJob().isA(Job.ARAN1) || player.getJob().isA(Job.LEGEND)) { if (player.getJob().isA(Job.ARAN1) || player.getJob().isA(Job.LEGEND)) {

View File

@@ -40,7 +40,9 @@ public class MaxStatCommand extends Command {
player.loseExp(player.getExp(), false, false); player.loseExp(player.getExp(), false, false);
player.setLevel(255); player.setLevel(255);
player.resetPlayerRates(); 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.setWorldRates();
player.updateStrDexIntLuk(Short.MAX_VALUE); player.updateStrDexIntLuk(Short.MAX_VALUE);
player.setFame(13337); player.setFame(13337);

View File

@@ -43,10 +43,14 @@ public class SetStatCommand extends Command {
try { try {
int x = Integer.parseInt(params[0]); int x = Integer.parseInt(params[0]);
if (x > Short.MAX_VALUE) x = Short.MAX_VALUE; if (x > Short.MAX_VALUE) {
else if (x < 4) x = 4; // thanks Vcoc for pointing the minimal allowed stat value here x = Short.MAX_VALUE;
} else if (x < 4) {
x = 4; // thanks Vcoc for pointing the minimal allowed stat value here
}
player.updateStrDexIntLuk(x); player.updateStrDexIntLuk(x);
} catch (NumberFormatException nfe) {} } catch (NumberFormatException nfe) {
}
} }
} }

View File

@@ -43,16 +43,22 @@ public class SpCommand extends Command {
if (params.length == 1) { if (params.length == 1) {
int newSp = Integer.parseInt(params[0]); int newSp = Integer.parseInt(params[0]);
if (newSp < 0) newSp = 0; if (newSp < 0) {
else if (newSp > YamlConfig.config.server.MAX_AP) newSp = YamlConfig.config.server.MAX_AP; newSp = 0;
} else if (newSp > YamlConfig.config.server.MAX_AP) {
newSp = YamlConfig.config.server.MAX_AP;
}
player.updateRemainingSp(newSp); player.updateRemainingSp(newSp);
} else { } else {
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]); Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
if (victim != null) { if (victim != null) {
int newSp = Integer.parseInt(params[1]); int newSp = Integer.parseInt(params[1]);
if (newSp < 0) newSp = 0; if (newSp < 0) {
else if (newSp > YamlConfig.config.server.MAX_AP) newSp = YamlConfig.config.server.MAX_AP; newSp = 0;
} else if (newSp > YamlConfig.config.server.MAX_AP) {
newSp = YamlConfig.config.server.MAX_AP;
}
victim.updateRemainingSp(newSp); victim.updateRemainingSp(newSp);

View File

@@ -67,10 +67,13 @@ public class SummonCommand extends Command {
try { try {
for (int i = 0; i < 7; i++) { // poll for a while until the player reconnects 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); Thread.sleep(1777);
} }
} catch (InterruptedException e) {} } catch (InterruptedException e) {
}
MapleMap map = player.getMap(); MapleMap map = player.getMap();
victim.saveLocationOnWarp(); victim.saveLocationOnWarp();

View File

@@ -42,8 +42,12 @@ public class CheckDmgCommand extends Command {
Integer watkBuff = victim.getBuffedValue(BuffStat.WATK); Integer watkBuff = victim.getBuffedValue(BuffStat.WATK);
Integer matkBuff = victim.getBuffedValue(BuffStat.MATK); Integer matkBuff = victim.getBuffedValue(BuffStat.MATK);
int blessing = victim.getSkillLevel(10000000 * player.getJobType() + 12); int blessing = victim.getSkillLevel(10000000 * player.getJobType() + 12);
if (watkBuff == null) watkBuff = 0; if (watkBuff == null) {
if (matkBuff == null) matkBuff = 0; 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 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()); player.dropMessage(5, "Cur WATK: " + victim.getTotalWatk() + " Cur MATK: " + victim.getTotalMagic());

View File

@@ -46,12 +46,16 @@ public class FlyCommand extends Command {
String sendStr = ""; String sendStr = "";
if (params[0].equalsIgnoreCase("on")) { if (params[0].equalsIgnoreCase("on")) {
sendStr += "Enabled Fly feature (F1). With fly active, you cannot attack."; 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); srv.changeFly(c.getAccID(), true);
} else { } else {
sendStr += "Disabled Fly feature. You can now attack."; 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); srv.changeFly(c.getAccID(), false);
} }

View File

@@ -46,9 +46,10 @@ public class ReloadMapCommand extends Command {
for (Character chr : characters) { for (Character chr : characters) {
chr.saveLocationOnWarp(); chr.saveLocationOnWarp();
chr.changeMap(newMap); 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."); chr.dropMessage("You have been relocated due to map reloading. Sorry for the inconvenience.");
} }
}
newMap.respawn(); newMap.respawn();
} }
} }

View File

@@ -39,8 +39,9 @@ public class StartEventCommand extends Command {
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
Character player = c.getPlayer(); Character player = c.getPlayer();
int players = 50; int players = 50;
if (params.length > 1) if (params.length > 1) {
players = Integer.parseInt(params[0]); players = Integer.parseInt(params[0]);
}
c.getChannelServer().setEvent(new Event(player.getMapId(), players)); c.getChannelServer().setEvent(new Event(player.getMapId(), players));
Server.getInstance().broadcastMessage(c.getWorld(), PacketCreator.earnTitleMessage( Server.getInstance().broadcastMessage(c.getWorld(), PacketCreator.earnTitleMessage(
"[Event] An event has started on " "[Event] An event has started on "

View File

@@ -25,7 +25,6 @@ import client.command.Command;
import tools.PacketCreator; import tools.PacketCreator;
/** /**
*
* @author Ronan * @author Ronan
*/ */
public class BossDropRateCommand extends Command { public class BossDropRateCommand extends Command {

View File

@@ -50,7 +50,9 @@ public class ForceVacCommand extends Command {
mapItem.lockItem(); mapItem.lockItem();
try { try {
if (mapItem.isPickedUp()) continue; if (mapItem.isPickedUp()) {
continue;
}
if (mapItem.getMeso() > 0) { if (mapItem.getMeso() > 0) {
player.gainMeso(mapItem.getMeso(), true); player.gainMeso(mapItem.getMeso(), true);

View File

@@ -68,6 +68,7 @@ public class ProItemCommand extends Command {
player.dropMessage(6, "Make sure it's an equippable item."); player.dropMessage(6, "Make sure it's an equippable item.");
} }
} }
private static void hardsetItemStats(Equip equip, short stat, short spdjmp) { private static void hardsetItemStats(Equip equip, short stat, short spdjmp) {
equip.setStr(stat); equip.setStr(stat);
equip.setDex(stat); equip.setDex(stat);

View File

@@ -51,7 +51,9 @@ public class SetEqStatCommand extends Command {
for (byte i = 1; i <= equip.getSlotLimit(); i++) { for (byte i = 1; i <= equip.getSlotLimit(); i++) {
try { try {
Equip eq = (Equip) equip.getItem(i); Equip eq = (Equip) equip.getItem(i);
if (eq == null) continue; if (eq == null) {
continue;
}
eq.setWdef(newStat); eq.setWdef(newStat);
eq.setAcc(newStat); eq.setAcc(newStat);

View File

@@ -81,16 +81,20 @@ public class DebugCommand extends Command {
case "portal": case "portal":
Portal portal = player.getMap().findClosestPortal(player.getPosition()); 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) + "."); 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; break;
case "spawnpoint": case "spawnpoint":
SpawnPoint sp = player.getMap().findClosestSpawnpoint(player.getPosition()); 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() + "."); 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; break;
case "pos": case "pos":
@@ -106,8 +110,11 @@ public class DebugCommand extends Command {
break; break;
case "event": case "event":
if (player.getEventInstance() == null) player.dropMessage(6, "Player currently not in an event."); if (player.getEventInstance() == null) {
else player.dropMessage(6, "Current event name: " + player.getEventInstance().getName() + "."); player.dropMessage(6, "Player currently not in an event.");
} else {
player.dropMessage(6, "Current event name: " + player.getEventInstance().getName() + ".");
}
break; break;
case "areas": case "areas":

View File

@@ -29,7 +29,6 @@ import net.server.world.World;
import java.util.Collection; import java.util.Collection;
/** /**
*
* @author Mist * @author Mist
* @author Blood (Tochi) * @author Blood (Tochi)
* @author Ronan * @author Ronan

View File

@@ -24,7 +24,6 @@ import client.command.Command;
import net.server.coordinator.session.SessionCoordinator; import net.server.coordinator.session.SessionCoordinator;
/** /**
*
* @author Ronan * @author Ronan
*/ */
public class ShowSessionsCommand extends Command { public class ShowSessionsCommand extends Command {

View File

@@ -57,8 +57,12 @@ public class ShutdownCommand extends Command {
int days = (time / (1000 * 60 * 60 * 24)); int days = (time / (1000 * 60 * 60 * 24));
String strTime = ""; String strTime = "";
if (days > 0) strTime += days + " days, "; if (days > 0) {
if (hours > 0) strTime += hours + " hours, "; strTime += days + " days, ";
}
if (hours > 0) {
strTime += hours + " hours, ";
}
strTime += minutes + " minutes, "; strTime += minutes + " minutes, ";
strTime += seconds + " seconds"; strTime += seconds + " seconds";

View File

@@ -32,7 +32,6 @@ import tools.FilePrinter;
import tools.PacketCreator; import tools.PacketCreator;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public abstract class CharacterFactory { public abstract class CharacterFactory {

View File

@@ -33,20 +33,24 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class CharacterFactoryRecipe { public class CharacterFactoryRecipe {
private Job job; private final Job job;
private int level, map, top, bottom, shoes, weapon; 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 str = 4, dex = 4, int_ = 4, luk = 4;
private int maxHp = 50, maxMp = 5; private int maxHp = 50, maxMp = 5;
private int ap = 0, sp = 0; private int ap = 0, sp = 0;
private int meso = 0; private int meso = 0;
private List<Pair<Skill, Integer>> skills = new LinkedList<>(); private final List<Pair<Skill, Integer>> skills = new LinkedList<>();
private List<Pair<Item, InventoryType>> itemsWithType = new LinkedList<>(); private final List<Pair<Item, InventoryType>> itemsWithType = new LinkedList<>();
private Map<InventoryType, AtomicInteger> runningTypePosition = new LinkedHashMap<>(); private final Map<InventoryType, AtomicInteger> runningTypePosition = new LinkedHashMap<>();
public CharacterFactoryRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) { public CharacterFactoryRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) {
this.job = job; this.job = job;

View File

@@ -26,7 +26,6 @@ import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType; import client.inventory.InventoryType;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class BeginnerCreator extends CharacterFactory { public class BeginnerCreator extends CharacterFactory {

View File

@@ -26,7 +26,6 @@ import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType; import client.inventory.InventoryType;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class LegendCreator extends CharacterFactory { public class LegendCreator extends CharacterFactory {

View File

@@ -26,7 +26,6 @@ import client.creator.CharacterFactoryRecipe;
import client.inventory.InventoryType; import client.inventory.InventoryType;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class NoblesseCreator extends CharacterFactory { public class NoblesseCreator extends CharacterFactory {

View File

@@ -28,13 +28,12 @@ import client.inventory.Item;
import server.ItemInformationProvider; import server.ItemInformationProvider;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class BowmanCreator extends CharacterFactory { public class BowmanCreator extends CharacterFactory {
private static int[] equips = {1040067, 1041054, 1060056, 1061050, 1072081}; private static final int[] equips = {1040067, 1041054, 1060056, 1061050, 1072081};
private static int[] weapons = {1452005, 1462000}; private static final int[] weapons = {1452005, 1462000};
private static int[] startingHpMp = {797, 404}; private static final int[] startingHpMp = {797, 404};
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) { 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); CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);

View File

@@ -31,14 +31,13 @@ import constants.skills.Magician;
import server.ItemInformationProvider; import server.ItemInformationProvider;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class MagicianCreator extends CharacterFactory { public class MagicianCreator extends CharacterFactory {
private static int[] equips = {0, 1041041, 0, 1061034, 1072075}; private static final int[] equips = {0, 1041041, 0, 1061034, 1072075};
private static int[] weapons = {1372003, 1382017}; private static final int[] weapons = {1372003, 1382017};
private static int[] startingHpMp = {405, 729}; private static final int[] startingHpMp = {405, 729};
private static int[] mpGain = {0, 40, 80, 118, 156, 194, 230, 266, 302, 336, 370}; private static final 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) { 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); CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);

View File

@@ -28,13 +28,12 @@ import client.inventory.Item;
import server.ItemInformationProvider; import server.ItemInformationProvider;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class PirateCreator extends CharacterFactory { public class PirateCreator extends CharacterFactory {
private static int[] equips = {0, 0, 0, 0, 1072294}; private static final int[] equips = {0, 0, 0, 0, 1072294};
private static int[] weapons = {1482004, 1492004}; private static final int[] weapons = {1482004, 1492004};
private static int[] startingHpMp = {846, 503}; private static final int[] startingHpMp = {846, 503};
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) { 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); CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);

View File

@@ -28,13 +28,12 @@ import client.inventory.Item;
import server.ItemInformationProvider; import server.ItemInformationProvider;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class ThiefCreator extends CharacterFactory { public class ThiefCreator extends CharacterFactory {
private static int[] equips = {1040057, 1041047, 1060043, 1061043, 1072032}; private static final int[] equips = {1040057, 1041047, 1060043, 1061043, 1072032};
private static int[] weapons = {1472008, 1332012}; private static final int[] weapons = {1472008, 1332012};
private static int[] startingHpMp = {794, 407}; private static final int[] startingHpMp = {794, 407};
private static CharacterFactoryRecipe createRecipe(Job job, int level, int map, int top, int bottom, int shoes, int weapon) { 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); CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);

View File

@@ -31,14 +31,13 @@ import constants.skills.Warrior;
import server.ItemInformationProvider; import server.ItemInformationProvider;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class WarriorCreator extends CharacterFactory { public class WarriorCreator extends CharacterFactory {
private static int[] equips = {1040021, 0, 1060016, 0, 1072039}; private static final int[] equips = {1040021, 0, 1060016, 0, 1072039};
private static int[] weapons = {1302008, 1442001, 1422001, 1312005}; private static final int[] weapons = {1302008, 1442001, 1422001, 1312005};
private static int[] startingHpMp = {905, 208}; private static final int[] startingHpMp = {905, 208};
private static int[] hpGain = {0, 72, 144, 212, 280, 348, 412, 476, 540, 600, 660}; private static final 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) { 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); CharacterFactoryRecipe recipe = new CharacterFactoryRecipe(job, level, map, top, bottom, shoes, weapon);

View File

@@ -37,12 +37,12 @@ import java.util.Map;
public class Equip extends Item { public class Equip extends Item {
public static enum ScrollResult { public enum ScrollResult {
FAIL(0), SUCCESS(1), CURSE(2); FAIL(0), SUCCESS(1), CURSE(2);
private int value = -1; private int value = -1;
private ScrollResult(int value) { ScrollResult(int value) {
this.value = value; this.value = value;
} }
@@ -51,7 +51,7 @@ public class Equip extends Item {
} }
} }
public static enum StatUpgrade { public enum StatUpgrade {
incDEX(0), incSTR(1), incINT(2), incLUK(3), incDEX(0), incSTR(1), incINT(2), incLUK(3),
incMHP(4), incMMP(5), incPAD(6), incMAD(7), incMHP(4), incMMP(5), incPAD(6), incMAD(7),
@@ -59,7 +59,7 @@ public class Equip extends Item {
incSpeed(12), incJump(13), incVicious(14), incSlot(15); incSpeed(12), incJump(13), incVicious(14), incSlot(15);
private int value = -1; private int value = -1;
private StatUpgrade(int value) { StatUpgrade(int value) {
this.value = value; this.value = value;
} }
} }
@@ -281,12 +281,17 @@ public class Equip extends Item {
// each set of stat points grants a chance for a bonus stat point upgrade at equip level up. // 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 (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_POWER) {
if(isAttribute) return 2; if (isAttribute) {
else return 4; return 2;
} else {
return 4;
}
} else {
if (isAttribute) {
return 4;
} else {
return 16;
} }
else {
if(isAttribute) return 4;
else return 16;
} }
} }
@@ -315,13 +320,9 @@ public class Equip extends Item {
if (ItemConstants.isWeapon(this.getItemId())) { if (ItemConstants.isWeapon(this.getItemId())) {
if (name.equals(StatUpgrade.incPAD)) { if (name.equals(StatUpgrade.incPAD)) {
if (!isPhysicalWeapon(this.getItemId())) { return !isPhysicalWeapon(this.getItemId());
return true;
}
} else if (name.equals(StatUpgrade.incMAD)) { } else if (name.equals(StatUpgrade.incMAD)) {
if (isPhysicalWeapon(this.getItemId())) { return isPhysicalWeapon(this.getItemId());
return true;
}
} }
} }
@@ -332,7 +333,9 @@ public class Equip extends Item {
isUpgradeable = true; isUpgradeable = true;
int maxUpgrade = randomizeStatUpgrade((int) (1 + (curStat / (getStatModifier(isAttribute) * (isNotWeaponAffinity(name) ? 2.7 : 1))))); int maxUpgrade = randomizeStatUpgrade((int) (1 + (curStat / (getStatModifier(isAttribute) * (isNotWeaponAffinity(name) ? 2.7 : 1)))));
if(maxUpgrade == 0) return; if (maxUpgrade == 0) {
return;
}
stats.add(new Pair<>(name, maxUpgrade)); stats.add(new Pair<>(name, maxUpgrade));
} }
@@ -344,39 +347,95 @@ public class Equip extends Item {
} }
private void improveDefaultStats(List<Pair<StatUpgrade, Integer>> stats) { private void improveDefaultStats(List<Pair<StatUpgrade, Integer>> stats) {
if(dex > 0) getUnitStatUpgrade(stats, StatUpgrade.incDEX, dex, true); if (dex > 0) {
if(str > 0) getUnitStatUpgrade(stats, StatUpgrade.incSTR, str, true); getUnitStatUpgrade(stats, StatUpgrade.incDEX, dex, true);
if(_int > 0) getUnitStatUpgrade(stats, StatUpgrade.incINT,_int, true); }
if(luk > 0) getUnitStatUpgrade(stats, StatUpgrade.incLUK, luk, true); if (str > 0) {
if(hp > 0) getUnitStatUpgrade(stats, StatUpgrade.incMHP, hp, false); getUnitStatUpgrade(stats, StatUpgrade.incSTR, str, true);
if(mp > 0) getUnitStatUpgrade(stats, StatUpgrade.incMMP, mp, false); }
if(watk > 0) getUnitStatUpgrade(stats, StatUpgrade.incPAD, watk, false); if (_int > 0) {
if(matk > 0) getUnitStatUpgrade(stats, StatUpgrade.incMAD, matk, false); getUnitStatUpgrade(stats, StatUpgrade.incINT, _int, true);
if(wdef > 0) getUnitStatUpgrade(stats, StatUpgrade.incPDD, wdef, false); }
if(mdef > 0) getUnitStatUpgrade(stats, StatUpgrade.incMDD, mdef, false); if (luk > 0) {
if(avoid > 0) getUnitStatUpgrade(stats, StatUpgrade.incEVA, avoid, false); getUnitStatUpgrade(stats, StatUpgrade.incLUK, luk, true);
if(acc > 0) getUnitStatUpgrade(stats, StatUpgrade.incACC, acc, false); }
if(speed > 0) getUnitStatUpgrade(stats, StatUpgrade.incSpeed, speed, false); if (hp > 0) {
if(jump > 0) getUnitStatUpgrade(stats, StatUpgrade.incJump, jump, false); 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() { public Map<StatUpgrade, Short> getStats() {
Map<StatUpgrade, Short> stats = new HashMap<>(5); Map<StatUpgrade, Short> stats = new HashMap<>(5);
if(dex > 0) stats.put(StatUpgrade.incDEX, dex); if (dex > 0) {
if(str > 0) stats.put(StatUpgrade.incSTR, str); stats.put(StatUpgrade.incDEX, dex);
if(_int > 0) stats.put(StatUpgrade.incINT,_int); }
if(luk > 0) stats.put(StatUpgrade.incLUK, luk); if (str > 0) {
if(hp > 0) stats.put(StatUpgrade.incMHP, hp); stats.put(StatUpgrade.incSTR, str);
if(mp > 0) stats.put(StatUpgrade.incMMP, mp); }
if(watk > 0) stats.put(StatUpgrade.incPAD, watk); if (_int > 0) {
if(matk > 0) stats.put(StatUpgrade.incMAD, matk); stats.put(StatUpgrade.incINT, _int);
if(wdef > 0) stats.put(StatUpgrade.incPDD, wdef); }
if(mdef > 0) stats.put(StatUpgrade.incMDD, mdef); if (luk > 0) {
if(avoid > 0) stats.put(StatUpgrade.incEVA, avoid); stats.put(StatUpgrade.incLUK, luk);
if(acc > 0) stats.put(StatUpgrade.incACC, acc); }
if(speed > 0) stats.put(StatUpgrade.incSpeed, speed); if (hp > 0) {
if(jump > 0) stats.put(StatUpgrade.incJump, jump); 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; return stats;
} }
@@ -479,13 +538,17 @@ public class Equip extends Item {
List<Pair<String, Integer>> elementalStats = ItemInformationProvider.getInstance().getItemLevelupStats(getItemId(), itemLevel); List<Pair<String, Integer>> elementalStats = ItemInformationProvider.getInstance().getItemLevelupStats(getItemId(), itemLevel);
for (Pair<String, Integer> p : elementalStats) { for (Pair<String, Integer> p : elementalStats) {
if(p.getRight() > 0) stats.add(new Pair<>(StatUpgrade.valueOf(p.getLeft()), p.getRight())); if (p.getRight() > 0) {
stats.add(new Pair<>(StatUpgrade.valueOf(p.getLeft()), p.getRight()));
}
} }
} }
if (!stats.isEmpty()) { if (!stats.isEmpty()) {
if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) { if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) {
if(vicious > 0) getUnitSlotUpgrade(stats, StatUpgrade.incVicious); if (vicious > 0) {
getUnitSlotUpgrade(stats, StatUpgrade.incVicious);
}
getUnitSlotUpgrade(stats, StatUpgrade.incSlot); getUnitSlotUpgrade(stats, StatUpgrade.incSlot);
} }
} else { } else {
@@ -493,7 +556,9 @@ public class Equip extends Item {
improveDefaultStats(stats); improveDefaultStats(stats);
if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) { if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) {
if(vicious > 0) getUnitSlotUpgrade(stats, StatUpgrade.incVicious); if (vicious > 0) {
getUnitSlotUpgrade(stats, StatUpgrade.incVicious);
}
getUnitSlotUpgrade(stats, StatUpgrade.incSlot); getUnitSlotUpgrade(stats, StatUpgrade.incSlot);
} }
@@ -501,7 +566,9 @@ public class Equip extends Item {
while (stats.isEmpty()) { while (stats.isEmpty()) {
improveDefaultStats(stats); improveDefaultStats(stats);
if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) { if (YamlConfig.config.server.USE_EQUIPMNT_LVLUP_SLOTS) {
if(vicious > 0) getUnitSlotUpgrade(stats, StatUpgrade.incVicious); if (vicious > 0) {
getUnitSlotUpgrade(stats, StatUpgrade.incVicious);
}
getUnitSlotUpgrade(stats, StatUpgrade.incSlot); getUnitSlotUpgrade(stats, StatUpgrade.incSlot);
} }
} }
@@ -579,7 +646,9 @@ public class Equip extends Item {
itemExp += baseExpGain; itemExp += baseExpGain;
int expNeeded = ExpTable.getEquipExpNeededForLevel(itemLevel); 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) { if (itemExp >= expNeeded) {
while (itemExp >= expNeeded) { while (itemExp >= expNeeded) {
@@ -611,7 +680,9 @@ public class Equip extends Item {
public String showEquipFeatures(Client c) { public String showEquipFeatures(Client c) {
ItemInformationProvider ii = ItemInformationProvider.getInstance(); ItemInformationProvider ii = ItemInformationProvider.getInstance();
if(!ii.isUpgradeable(this.getItemId())) return ""; if (!ii.isUpgradeable(this.getItemId())) {
return "";
}
String eqpName = ii.getName(getItemId()); 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));

View File

@@ -32,9 +32,11 @@ import java.util.concurrent.atomic.AtomicInteger;
public class Item implements Comparable<Item> { public class Item implements Comparable<Item> {
private static AtomicInteger runningCashId = new AtomicInteger(777000000); // pets & rings shares cashid values private static final AtomicInteger runningCashId = new AtomicInteger(777000000); // pets & rings shares cashid values
private int id, cashId, sn; private final int id;
private int cashId;
private int sn;
private short position; private short position;
private short quantity; private short quantity;
private int petid = -1; private int petid = -1;
@@ -79,7 +81,9 @@ public class Item implements Comparable<Item> {
public void setPosition(short position) { public void setPosition(short position) {
this.position = 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) { public void setQuantity(short quantity) {

View File

@@ -31,7 +31,6 @@ import java.util.List;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
/** /**
*
* @author Flav * @author Flav
*/ */
public enum ItemFactory { public enum ItemFactory {
@@ -57,7 +56,7 @@ public enum ItemFactory {
} }
} }
private ItemFactory(int value, boolean account) { ItemFactory(int value, boolean account) {
this.value = value; this.value = value;
this.account = account; this.account = account;
} }
@@ -67,8 +66,11 @@ public enum ItemFactory {
} }
public List<Pair<Item, InventoryType>> loadItems(int id, boolean login) throws SQLException { public List<Pair<Item, InventoryType>> loadItems(int id, boolean login) throws SQLException {
if(value != 6) return loadItemsCommon(id, login); if (value != 6) {
else return loadItemsMerchant(id, login); return loadItemsCommon(id, login);
} else {
return loadItemsMerchant(id, login);
}
} }
public void saveItems(List<Pair<Item, InventoryType>> items, int id, Connection con) throws SQLException { public void saveItems(List<Pair<Item, InventoryType>> items, int id, Connection con) throws SQLException {
@@ -78,8 +80,11 @@ public enum ItemFactory {
public void saveItems(List<Pair<Item, InventoryType>> items, List<Short> bundlesList, int id, Connection con) throws SQLException { 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 // thanks Arufonsu, MedicOP, BHB for pointing a "synchronized" bottleneck here
if(value != 6) saveItemsCommon(items, id, con); if (value != 6) {
else saveItemsMerchant(items, bundlesList, id, con); saveItemsCommon(items, id, con);
} else {
saveItemsMerchant(items, bundlesList, id, con);
}
} }
private static Equip loadEquipFromResultSet(ResultSet rs) throws SQLException { private static Equip loadEquipFromResultSet(ResultSet rs) throws SQLException {

View File

@@ -1,12 +1,11 @@
package client.inventory; package client.inventory;
/** /**
*
* @author kevin * @author kevin
*/ */
public class ModifyInventory { public class ModifyInventory {
private int mode; private final int mode;
private Item item; private Item item;
private short oldPos; private short oldPos;

View File

@@ -25,7 +25,10 @@ package client.inventory;
* @author Leifde * @author Leifde
*/ */
public class PetCommand { 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) { public PetCommand(int petId, int skillId, int prob, int inc) {
this.petId = petId; this.petId = petId;

View File

@@ -31,13 +31,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
*
* @author Danny (Leifde) * @author Danny (Leifde)
*/ */
public class PetDataFactory { public class PetDataFactory {
private static DataProvider dataRoot = DataProviderFactory.getDataProvider(WZFiles.ITEM); private static final DataProvider dataRoot = DataProviderFactory.getDataProvider(WZFiles.ITEM);
private static Map<String, PetCommand> petCommands = new HashMap<>(); private static final Map<String, PetCommand> petCommands = new HashMap<>();
private static Map<Integer, Integer> petHunger = new HashMap<>(); private static final Map<Integer, Integer> petHunger = new HashMap<>();
public static PetCommand getPetCommand(int petId, int skillId) { public static PetCommand getPetCommand(int petId, int skillId) {
PetCommand ret = petCommands.get(petId + "" + skillId); PetCommand ret = petCommands.get(petId + "" + skillId);

View File

@@ -678,10 +678,14 @@ public class InventoryManipulator {
} else if (ii.isCash(it.getItemId())) { } else if (ii.isCash(it.getItemId())) {
if (YamlConfig.config.server.USE_ENFORCE_UNMERCHABLE_CASH) { // thanks Ari for noticing cash drops not available server-side if (YamlConfig.config.server.USE_ENFORCE_UNMERCHABLE_CASH) { // thanks Ari for noticing cash drops not available server-side
return true; 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)) { } else if (isDroppedItemRestricted(it)) {
return true; 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) { public static void drop(Client c, InventoryType type, short src, short quantity) {

View File

@@ -34,22 +34,21 @@ import java.util.Set;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
/** /**
*
* @author Ronan - credits to Eric for showing the New Year opcodes and handler layout * @author Ronan - credits to Eric for showing the New Year opcodes and handler layout
*/ */
public class NewYearCardRecord { public class NewYearCardRecord {
private int id; private int id;
private int senderId; private final int senderId;
private String senderName; private final String senderName;
private boolean senderDiscardCard; private boolean senderDiscardCard;
private int receiverId; private final int receiverId;
private String receiverName; private final String receiverName;
private boolean receiverDiscardCard; private boolean receiverDiscardCard;
private boolean receiverReceivedCard; private boolean receiverReceivedCard;
private String stringContent; private final String stringContent;
private long dateSent = 0; private long dateSent = 0;
private long dateReceived = 0; private long dateReceived = 0;
@@ -177,7 +176,9 @@ public class NewYearCardRecord {
public static NewYearCardRecord loadNewYearCard(int cardid) { public static NewYearCardRecord loadNewYearCard(int cardid) {
NewYearCardRecord nyc = Server.getInstance().getNewYearCard(cardid); NewYearCardRecord nyc = Server.getInstance().getNewYearCard(cardid);
if(nyc != null) return nyc; if (nyc != null) {
return nyc;
}
try (Connection con = DatabaseConnection.getConnection()) { try (Connection con = DatabaseConnection.getConnection()) {
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM newyear WHERE id = ?")) { try (PreparedStatement ps = con.prepareStatement("SELECT * FROM newyear WHERE id = ?")) {
@@ -242,7 +243,9 @@ public class NewYearCardRecord {
} }
public void startNewYearCardTask() { public void startNewYearCardTask() {
if(sendTask != null) return; if (sendTask != null) {
return;
}
sendTask = TimerManager.getInstance().register(() -> { sendTask = TimerManager.getInstance().register(() -> {
Server server = Server.getInstance(); Server server = Server.getInstance();

View File

@@ -25,7 +25,6 @@ import server.maps.MapleMap;
import tools.PacketCreator; import tools.PacketCreator;
/** /**
*
* @author RonanLana * @author RonanLana
*/ */
public class BuybackProcessor { public class BuybackProcessor {

View File

@@ -42,12 +42,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
*
* @author Ronan * @author Ronan
*/ */
public class MakerProcessor { public class MakerProcessor {
private static ItemInformationProvider ii = ItemInformationProvider.getInstance(); private static final ItemInformationProvider ii = ItemInformationProvider.getInstance();
public static void makerAction(InPacket p, Client c) { public static void makerAction(InPacket p, Client c) {
if (c.tryacquireClient()) { if (c.tryacquireClient()) {
@@ -191,7 +190,9 @@ public class MakerProcessor {
int cost = recipe.getCost(); int cost = recipe.getCost();
if (stimulantid == -1 && reagentids.isEmpty()) { if (stimulantid == -1 && reagentids.isEmpty()) {
if(cost > 0) c.getPlayer().gainMeso(-cost, false); if (cost > 0) {
c.getPlayer().gainMeso(-cost, false);
}
for (Pair<Integer, Integer> pair : recipe.getGainItems()) { for (Pair<Integer, Integer> pair : recipe.getGainItems()) {
c.getPlayer().setCS(true); c.getPlayer().setCS(true);
@@ -201,14 +202,18 @@ public class MakerProcessor {
} else { } else {
toCreate = recipe.getGainItems().get(0).getLeft(); toCreate = recipe.getGainItems().get(0).getLeft();
if(stimulantid != -1) c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1, false); if (stimulantid != -1) {
c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1, false);
}
if (!reagentids.isEmpty()) { if (!reagentids.isEmpty()) {
for (Map.Entry<Integer, Short> r : reagentids.entrySet()) { for (Map.Entry<Integer, Short> r : reagentids.entrySet()) {
c.getAbstractPlayerInteraction().gainItem(r.getKey(), (short) (-1 * r.getValue()), false); 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); makerSucceeded = addBoostedMakerItem(c, toCreate, stimulantid, reagentids);
} }
@@ -362,15 +367,19 @@ public class MakerProcessor {
} }
private static boolean addBoostedMakerItem(Client c, int itemid, int stimulantid, Map<Integer, Short> reagentids) { 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; return false;
} }
Item item = ii.getEquipById(itemid); Item item = ii.getEquipById(itemid);
if(item == null) return false; if (item == null) {
return false;
}
Equip eqp = (Equip) item; Equip eqp = (Equip) item;
if(ItemConstants.isAccessory(item.getItemId()) && eqp.getUpgradeSlots() <= 0) eqp.setUpgradeSlots(3); if (ItemConstants.isAccessory(item.getItemId()) && eqp.getUpgradeSlots() <= 0) {
eqp.setUpgradeSlots(3);
}
if (YamlConfig.config.server.USE_ENHANCED_CRAFTING == true) { if (YamlConfig.config.server.USE_ENHANCED_CRAFTING == true) {
if (!(c.getPlayer().isGM() && YamlConfig.config.server.USE_PERFECT_GM_SCROLL)) { if (!(c.getPlayer().isGM() && YamlConfig.config.server.USE_PERFECT_GM_SCROLL)) {
@@ -421,7 +430,7 @@ public class MakerProcessor {
} }
} }
ii.improveEquipStats(eqp, stats); ItemInformationProvider.improveEquipStats(eqp, stats);
for (Short sh : randStat) { for (Short sh : randStat) {
ii.scrollOptionEquipWithChaos(eqp, sh, false); ii.scrollOptionEquipWithChaos(eqp, sh, false);

View File

@@ -35,16 +35,15 @@ import tools.PacketCreator;
import java.util.List; import java.util.List;
/** /**
*
* @author Ronan - multi-pot consumption feature * @author Ronan - multi-pot consumption feature
*/ */
public class PetAutopotProcessor { public class PetAutopotProcessor {
private static class AutopotAction { private static class AutopotAction {
private Client c; private final Client c;
private short slot; private short slot;
private int itemId; private final int itemId;
private Item toUse; private Item toUse;
private List<Item> toUseList; private List<Item> toUseList;
@@ -121,10 +120,14 @@ public class PetAutopotProcessor {
hasMpGain = stat.getMp() > 0 || stat.getMpRate() > 0.0; hasMpGain = stat.getMp() > 0 || stat.getMpRate() > 0.0;
incHp = stat.getHp(); 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(); 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 (YamlConfig.config.server.USE_COMPULSORY_AUTOPOT) {
if (hasHpGain) { if (hasHpGain) {

View File

@@ -34,7 +34,6 @@ import tools.PacketCreator;
import java.awt.*; import java.awt.*;
/** /**
*
* @author RonanLana - just added locking on OdinMS' SpawnPetHandler method body * @author RonanLana - just added locking on OdinMS' SpawnPetHandler method body
*/ */
public class SpawnPetProcessor { public class SpawnPetProcessor {
@@ -45,7 +44,9 @@ public class SpawnPetProcessor {
try { try {
Character chr = c.getPlayer(); Character chr = c.getPlayer();
Pet pet = chr.getInventory(InventoryType.CASH).getItem(slot).getPet(); Pet pet = chr.getInventory(InventoryType.CASH).getItem(slot).getPet();
if (pet == null) return; if (pet == null) {
return;
}
int petid = pet.getItemId(); int petid = pet.getItemId();
if (petid == 5000028 || petid == 5000047) //Handles Dragon AND Robos if (petid == 5000028 || petid == 5000047) //Handles Dragon AND Robos

View File

@@ -45,12 +45,11 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
/** /**
*
* @author RonanLana - synchronization of Fredrick modules and operation results * @author RonanLana - synchronization of Fredrick modules and operation results
*/ */
public class FredrickProcessor { public class FredrickProcessor {
private static int[] dailyReminders = new int[]{2, 5, 10, 15, 30, 60, 90, Integer.MAX_VALUE}; private static final int[] dailyReminders = new int[]{2, 5, 10, 15, 30, 60, 90, Integer.MAX_VALUE};
private static byte canRetrieveFromFredrick(Character chr, List<Pair<Item, InventoryType>> items) { private static byte canRetrieveFromFredrick(Character chr, List<Pair<Item, InventoryType>> items) {
if (!Inventory.checkSpotsAndOwnership(chr, items)) { if (!Inventory.checkSpotsAndOwnership(chr, items)) {
@@ -284,8 +283,9 @@ public class FredrickProcessor {
if (deleteFredrickItems(chr.getId())) { if (deleteFredrickItems(chr.getId())) {
HiredMerchant merchant = chr.getHiredMerchant(); HiredMerchant merchant = chr.getHiredMerchant();
if(merchant != null) if (merchant != null) {
merchant.clearItems(); merchant.clearItems();
}
for (Pair<Item, InventoryType> it : items) { for (Pair<Item, InventoryType> it : items) {
Item item = it.getLeft(); Item item = it.getLeft();

View File

@@ -38,7 +38,6 @@ import tools.FilePrinter;
import tools.PacketCreator; import tools.PacketCreator;
/** /**
*
* @author Matze * @author Matze
* @author Ronan - inventory concurrency protection on storing items * @author Ronan - inventory concurrency protection on storing items
*/ */
@@ -167,7 +166,9 @@ public class StorageProcessor {
storage.sendStored(c, ItemConstants.getInventoryType(itemId)); storage.sendStored(c, ItemConstants.getInventoryType(itemId));
} }
} else if (mode == 6) { // arrange items } else if (mode == 6) { // arrange items
if(YamlConfig.config.server.USE_STORAGE_ITEM_SORT) storage.arrangeItems(c); if (YamlConfig.config.server.USE_STORAGE_ITEM_SORT) {
storage.arrangeItems(c);
}
c.sendPacket(PacketCreator.enableActions()); c.sendPacket(PacketCreator.enableActions());
} else if (mode == 7) { // meso } else if (mode == 7) { // meso
int meso = p.readInt(); int meso = p.readInt();

View File

@@ -41,14 +41,15 @@ import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
*
* @author RonanLana - synchronization of AP transaction modules * @author RonanLana - synchronization of AP transaction modules
*/ */
public class AssignAPProcessor { public class AssignAPProcessor {
public static void APAutoAssignAction(InPacket inPacket, Client c) { public static void APAutoAssignAction(InPacket inPacket, Client c) {
Character chr = c.getPlayer(); Character chr = c.getPlayer();
if (chr.getRemainingAp() < 1) return; if (chr.getRemainingAp() < 1) {
return;
}
Collection<Item> equippedC = chr.getInventory(InventoryType.EQUIPPED).list(); Collection<Item> equippedC = chr.getInventory(InventoryType.EQUIPPED).list();
@@ -56,7 +57,10 @@ public class AssignAPProcessor {
try { try {
int[] statGain = new int[4]; int[] statGain = new int[4];
int[] statUpdate = new int[4]; int[] statUpdate = new int[4];
statGain[0] = 0; statGain[1] = 0; statGain[2] = 0; statGain[3] = 0; statGain[0] = 0;
statGain[1] = 0;
statGain[2] = 0;
statGain[3] = 0;
int remainingAp = chr.getRemainingAp(); int remainingAp = chr.getRemainingAp();
inPacket.skip(8); inPacket.skip(8);
@@ -75,13 +79,19 @@ public class AssignAPProcessor {
for (Item item : equippedC) { //selecting the biggest AP value of each stat from each equipped item. for (Item item : equippedC) { //selecting the biggest AP value of each stat from each equipped item.
nEquip = (Equip) item; nEquip = (Equip) item;
if(nEquip.getStr() > 0) eqpStrList.add(nEquip.getStr()); if (nEquip.getStr() > 0) {
eqpStrList.add(nEquip.getStr());
}
str += nEquip.getStr(); str += nEquip.getStr();
if(nEquip.getDex() > 0) eqpDexList.add(nEquip.getDex()); if (nEquip.getDex() > 0) {
eqpDexList.add(nEquip.getDex());
}
dex += nEquip.getDex(); dex += nEquip.getDex();
if(nEquip.getLuk() > 0) eqpLukList.add(nEquip.getLuk()); if (nEquip.getLuk() > 0) {
eqpLukList.add(nEquip.getLuk());
}
luk += nEquip.getLuk(); luk += nEquip.getLuk();
//if(nEquip.getInt() > 0) eqpIntList.add(nEquip.getInt()); //not needed... //if(nEquip.getInt() > 0) eqpIntList.add(nEquip.getInt()); //not needed...
@@ -108,23 +118,31 @@ public class AssignAPProcessor {
Job stance = c.getPlayer().getJobStyle(opt); Job stance = c.getPlayer().getJobStyle(opt);
int prStat = 0, scStat = 0, trStat = 0, temp, tempAp = remainingAp, CAP; int prStat = 0, scStat = 0, trStat = 0, temp, tempAp = remainingAp, CAP;
if (tempAp < 1) return; if (tempAp < 1) {
return;
}
Stat primary, secondary, tertiary = Stat.LUK; Stat primary, secondary, tertiary = Stat.LUK;
switch (stance) { switch (stance) {
case MAGICIAN: case MAGICIAN:
CAP = 165; CAP = 165;
scStat = (chr.getLevel() + 3) - (chr.getLuk() + luk - eqpLuk); scStat = (chr.getLevel() + 3) - (chr.getLuk() + luk - eqpLuk);
if(scStat < 0) scStat = 0; if (scStat < 0) {
scStat = 0;
}
scStat = Math.min(scStat, tempAp); scStat = Math.min(scStat, tempAp);
if(tempAp > scStat) tempAp -= scStat; if (tempAp > scStat) {
else tempAp = 0; tempAp -= scStat;
} else {
tempAp = 0;
}
prStat = tempAp; prStat = tempAp;
int_ = prStat; int_ = prStat;
luk = scStat; luk = scStat;
str = 0; dex = 0; str = 0;
dex = 0;
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && luk + chr.getLuk() > CAP) { if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && luk + chr.getLuk() > CAP) {
temp = luk + chr.getLuk() - CAP; temp = luk + chr.getLuk() - CAP;
@@ -141,16 +159,22 @@ public class AssignAPProcessor {
case BOWMAN: case BOWMAN:
CAP = 125; CAP = 125;
scStat = (chr.getLevel() + 5) - (chr.getStr() + str - eqpStr); scStat = (chr.getLevel() + 5) - (chr.getStr() + str - eqpStr);
if(scStat < 0) scStat = 0; if (scStat < 0) {
scStat = 0;
}
scStat = Math.min(scStat, tempAp); scStat = Math.min(scStat, tempAp);
if(tempAp > scStat) tempAp -= scStat; if (tempAp > scStat) {
else tempAp = 0; tempAp -= scStat;
} else {
tempAp = 0;
}
prStat = tempAp; prStat = tempAp;
dex = prStat; dex = prStat;
str = scStat; str = scStat;
int_ = 0; luk = 0; int_ = 0;
luk = 0;
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) { if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) {
temp = str + chr.getStr() - CAP; temp = str + chr.getStr() - CAP;
@@ -167,16 +191,22 @@ public class AssignAPProcessor {
case CROSSBOWMAN: case CROSSBOWMAN:
CAP = 120; CAP = 120;
scStat = chr.getLevel() - (chr.getStr() + str - eqpStr); scStat = chr.getLevel() - (chr.getStr() + str - eqpStr);
if(scStat < 0) scStat = 0; if (scStat < 0) {
scStat = 0;
}
scStat = Math.min(scStat, tempAp); scStat = Math.min(scStat, tempAp);
if(tempAp > scStat) tempAp -= scStat; if (tempAp > scStat) {
else tempAp = 0; tempAp -= scStat;
} else {
tempAp = 0;
}
prStat = tempAp; prStat = tempAp;
dex = prStat; dex = prStat;
str = scStat; str = scStat;
int_ = 0; luk = 0; int_ = 0;
luk = 0;
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) { if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) {
temp = str + chr.getStr() - CAP; temp = str + chr.getStr() - CAP;
@@ -195,7 +225,9 @@ public class AssignAPProcessor {
scStat = 0; scStat = 0;
if (chr.getDex() < 80) { if (chr.getDex() < 80) {
scStat = (2 * chr.getLevel()) - (chr.getDex() + dex - eqpDex); scStat = (2 * chr.getLevel()) - (chr.getDex() + dex - eqpDex);
if(scStat < 0) scStat = 0; if (scStat < 0) {
scStat = 0;
}
scStat = Math.min(80 - chr.getDex(), scStat); scStat = Math.min(80 - chr.getDex(), scStat);
scStat = Math.min(tempAp, scStat); scStat = Math.min(tempAp, scStat);
@@ -203,7 +235,9 @@ public class AssignAPProcessor {
} }
temp = (chr.getLevel() + 40) - Math.max(80, scStat + chr.getDex() + dex - eqpDex); temp = (chr.getLevel() + 40) - Math.max(80, scStat + chr.getDex() + dex - eqpDex);
if(temp < 0) temp = 0; if (temp < 0) {
temp = 0;
}
temp = Math.min(tempAp, temp); temp = Math.min(tempAp, temp);
scStat += temp; scStat += temp;
tempAp -= temp; tempAp -= temp;
@@ -212,7 +246,9 @@ public class AssignAPProcessor {
if (chr.getStr() >= Math.max(13, (int) (0.4 * chr.getLevel()))) { if (chr.getStr() >= Math.max(13, (int) (0.4 * chr.getLevel()))) {
if (chr.getStr() < 50) { if (chr.getStr() < 50) {
trStat = (chr.getLevel() - 10) - (chr.getStr() + str - eqpStr); trStat = (chr.getLevel() - 10) - (chr.getStr() + str - eqpStr);
if(trStat < 0) trStat = 0; if (trStat < 0) {
trStat = 0;
}
trStat = Math.min(50 - chr.getStr(), trStat); trStat = Math.min(50 - chr.getStr(), trStat);
trStat = Math.min(tempAp, trStat); trStat = Math.min(tempAp, trStat);
@@ -220,7 +256,9 @@ public class AssignAPProcessor {
} }
temp = (20 + (chr.getLevel() / 2)) - Math.max(50, trStat + chr.getStr() + str - eqpStr); temp = (20 + (chr.getLevel() / 2)) - Math.max(50, trStat + chr.getStr() + str - eqpStr);
if(temp < 0) temp = 0; if (temp < 0) {
temp = 0;
}
temp = Math.min(tempAp, temp); temp = Math.min(tempAp, temp);
trStat += temp; trStat += temp;
tempAp -= temp; tempAp -= temp;
@@ -269,7 +307,9 @@ public class AssignAPProcessor {
scStat = 0; scStat = 0;
if (chr.getDex() < 80) { if (chr.getDex() < 80) {
scStat = (2 * chr.getLevel()) - (chr.getDex() + dex - eqpDex); scStat = (2 * chr.getLevel()) - (chr.getDex() + dex - eqpDex);
if(scStat < 0) scStat = 0; if (scStat < 0) {
scStat = 0;
}
scStat = Math.min(80 - chr.getDex(), scStat); scStat = Math.min(80 - chr.getDex(), scStat);
scStat = Math.min(tempAp, scStat); scStat = Math.min(tempAp, scStat);
@@ -277,7 +317,9 @@ public class AssignAPProcessor {
} }
temp = (chr.getLevel() + 40) - Math.max(80, scStat + chr.getDex() + dex - eqpDex); temp = (chr.getLevel() + 40) - Math.max(80, scStat + chr.getDex() + dex - eqpDex);
if(temp < 0) temp = 0; if (temp < 0) {
temp = 0;
}
temp = Math.min(tempAp, temp); temp = Math.min(tempAp, temp);
scStat += temp; scStat += temp;
tempAp -= temp; tempAp -= temp;
@@ -285,7 +327,9 @@ public class AssignAPProcessor {
scStat = 0; scStat = 0;
if (chr.getDex() < 96) { if (chr.getDex() < 96) {
scStat = (int) (2.4 * chr.getLevel()) - (chr.getDex() + dex - eqpDex); scStat = (int) (2.4 * chr.getLevel()) - (chr.getDex() + dex - eqpDex);
if(scStat < 0) scStat = 0; if (scStat < 0) {
scStat = 0;
}
scStat = Math.min(96 - chr.getDex(), scStat); scStat = Math.min(96 - chr.getDex(), scStat);
scStat = Math.min(tempAp, scStat); scStat = Math.min(tempAp, scStat);
@@ -293,7 +337,9 @@ public class AssignAPProcessor {
} }
temp = 96 + (int) (1.2 * (chr.getLevel() - 40)) - Math.max(96, scStat + chr.getDex() + dex - eqpDex); temp = 96 + (int) (1.2 * (chr.getLevel() - 40)) - Math.max(96, scStat + chr.getDex() + dex - eqpDex);
if(temp < 0) temp = 0; if (temp < 0) {
temp = 0;
}
temp = Math.min(tempAp, temp); temp = Math.min(tempAp, temp);
scStat += temp; scStat += temp;
tempAp -= temp; tempAp -= temp;
@@ -302,7 +348,8 @@ public class AssignAPProcessor {
prStat = tempAp; prStat = tempAp;
str = prStat; str = prStat;
dex = scStat; dex = scStat;
int_ = 0; luk = 0; int_ = 0;
luk = 0;
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && dex + chr.getDex() > CAP) { if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && dex + chr.getDex() > CAP) {
temp = dex + chr.getDex() - CAP; temp = dex + chr.getDex() - CAP;
@@ -366,7 +413,9 @@ public class AssignAPProcessor {
} }
private static int gainStatByType(Stat type, int[] statGain, int gain, int[] statUpdate) { private static int gainStatByType(Stat type, int[] statGain, int gain, int[] statUpdate) {
if(gain <= 0) return 0; if (gain <= 0) {
return 0;
}
int newVal = 0; int newVal = 0;
if (type.equals(Stat.STR)) { if (type.equals(Stat.STR)) {
@@ -414,7 +463,9 @@ public class AssignAPProcessor {
} }
private static Stat getQuaternaryStat(Job stance) { private static Stat getQuaternaryStat(Job stance) {
if(stance != Job.MAGICIAN) return Stat.INT; if (stance != Job.MAGICIAN) {
return Stat.INT;
}
return Stat.STR; return Stat.STR;
} }
@@ -627,9 +678,10 @@ public class AssignAPProcessor {
Skill increaseHP = SkillFactory.getSkill(job.isA(Job.DAWNWARRIOR1) ? DawnWarrior.MAX_HP_INCREASE : Warrior.IMPROVED_MAXHP); Skill increaseHP = SkillFactory.getSkill(job.isA(Job.DAWNWARRIOR1) ? DawnWarrior.MAX_HP_INCREASE : Warrior.IMPROVED_MAXHP);
int sLvl = player.getSkillLevel(increaseHP); int sLvl = player.getSkillLevel(increaseHP);
if(sLvl > 0) if (sLvl > 0) {
MaxHP += increaseHP.getEffect(sLvl).getY(); MaxHP += increaseHP.getEffect(sLvl).getY();
} }
}
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) { if (usedAPReset) {
@@ -685,9 +737,10 @@ public class AssignAPProcessor {
Skill increaseHP = SkillFactory.getSkill(job.isA(Job.PIRATE) ? Brawler.IMPROVE_MAX_HP : ThunderBreaker.IMPROVE_MAX_HP); Skill increaseHP = SkillFactory.getSkill(job.isA(Job.PIRATE) ? Brawler.IMPROVE_MAX_HP : ThunderBreaker.IMPROVE_MAX_HP);
int sLvl = player.getSkillLevel(increaseHP); int sLvl = player.getSkillLevel(increaseHP);
if(sLvl > 0) if (sLvl > 0) {
MaxHP += increaseHP.getEffect(sLvl).getY(); MaxHP += increaseHP.getEffect(sLvl).getY();
} }
}
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) { if (usedAPReset) {
@@ -730,9 +783,10 @@ public class AssignAPProcessor {
Skill increaseMP = SkillFactory.getSkill(job.isA(Job.BLAZEWIZARD1) ? BlazeWizard.INCREASING_MAX_MP : Magician.IMPROVED_MAX_MP_INCREASE); Skill increaseMP = SkillFactory.getSkill(job.isA(Job.BLAZEWIZARD1) ? BlazeWizard.INCREASING_MAX_MP : Magician.IMPROVED_MAX_MP_INCREASE);
int sLvl = player.getSkillLevel(increaseMP); int sLvl = player.getSkillLevel(increaseMP);
if(sLvl > 0) if (sLvl > 0) {
MaxMP += increaseMP.getEffect(sLvl).getY(); MaxMP += increaseMP.getEffect(sLvl).getY();
} }
}
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if (!usedAPReset) { if (!usedAPReset) {

View File

@@ -34,7 +34,6 @@ import tools.FilePrinter;
import tools.PacketCreator; import tools.PacketCreator;
/** /**
*
* @author RonanLana - synchronization of SP transaction modules * @author RonanLana - synchronization of SP transaction modules
*/ */
public class AssignSPProcessor { public class AssignSPProcessor {

View File

@@ -57,12 +57,12 @@ public enum MonsterStatus {
private final int i; private final int i;
private final boolean first; private final boolean first;
private MonsterStatus(int i) { MonsterStatus(int i) {
this.i = i; this.i = i;
this.first = false; this.first = false;
} }
private MonsterStatus(int i, boolean first) { MonsterStatus(int i, boolean first) {
this.i = i; this.i = i;
this.first = first; this.first = first;
} }

View File

@@ -29,10 +29,10 @@ import java.util.concurrent.ConcurrentHashMap;
public class MonsterStatusEffect { public class MonsterStatusEffect {
private Map<MonsterStatus, Integer> stati; private final Map<MonsterStatus, Integer> stati;
private Skill skill; private final Skill skill;
private MobSkill mobskill; private final MobSkill mobskill;
private boolean monsterSkill; private final boolean monsterSkill;
public MonsterStatusEffect(Map<MonsterStatus, Integer> stati, Skill skillId, MobSkill mobskill, boolean monsterSkill) { public MonsterStatusEffect(Map<MonsterStatus, Integer> stati, Skill skillId, MobSkill mobskill, boolean monsterSkill) {
this.stati = new ConcurrentHashMap<>(stati); this.stati = new ConcurrentHashMap<>(stati);