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,23 +40,24 @@ 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;
} }
public boolean contains(int characterId) { public boolean contains(int characterId) {
synchronized(buddies) { synchronized (buddies) {
return buddies.containsKey(characterId); return buddies.containsKey(characterId);
} }
} }
public boolean containsVisible(int characterId) { public boolean containsVisible(int characterId) {
BuddylistEntry ble; BuddylistEntry ble;
synchronized(buddies) { synchronized (buddies) {
ble = buddies.get(characterId); ble = buddies.get(characterId);
} }
@@ -76,7 +77,7 @@ public class BuddyList {
} }
public BuddylistEntry get(int characterId) { public BuddylistEntry get(int characterId) {
synchronized(buddies) { synchronized (buddies) {
return buddies.get(characterId); return buddies.get(characterId);
} }
} }
@@ -93,31 +94,31 @@ public class BuddyList {
} }
public void put(BuddylistEntry entry) { public void put(BuddylistEntry entry) {
synchronized(buddies) { synchronized (buddies) {
buddies.put(entry.getCharacterId(), entry); buddies.put(entry.getCharacterId(), entry);
} }
} }
public void remove(int characterId) { public void remove(int characterId) {
synchronized(buddies) { synchronized (buddies) {
buddies.remove(characterId); buddies.remove(characterId);
} }
} }
public Collection<BuddylistEntry> getBuddies() { public Collection<BuddylistEntry> getBuddies() {
synchronized(buddies) { synchronized (buddies) {
return Collections.unmodifiableCollection(buddies.values()); return Collections.unmodifiableCollection(buddies.values());
} }
} }
public boolean isFull() { public boolean isFull() {
synchronized(buddies) { synchronized (buddies) {
return buddies.size() >= capacity; return buddies.size() >= capacity;
} }
} }
public int[] getBuddyIds() { public int[] getBuddyIds() {
synchronized(buddies) { synchronized (buddies) {
int[] buddyIds = new int[buddies.size()]; int[] buddyIds = new int[buddies.size()];
int i = 0; int i = 0;
for (BuddylistEntry ble : buddies.values()) { for (BuddylistEntry ble : buddies.values()) {
@@ -128,10 +129,10 @@ public class BuddyList {
} }
public void broadcast(Packet packet, PlayerStorage pstorage) { public void broadcast(Packet packet, PlayerStorage pstorage) {
for(int bid : getBuddyIds()) { for (int bid : getBuddyIds()) {
Character chr = pstorage.getCharacterById(bid); Character chr = pstorage.getCharacterById(bid);
if(chr != null && chr.isLoggedinWorld()) { if (chr != null && chr.isLoggedinWorld()) {
chr.sendPacket(packet); chr.sendPacket(packet);
} }
} }

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

@@ -153,7 +153,7 @@ public class Client extends ChannelInboundHandlerAdapter {
} }
public static Client createMock() { public static Client createMock() {
return new Client(null, -1,null, null, -123, -123); return new Client(null, -1, null, null, -123, -123);
} }
@Override @Override

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();
@@ -61,8 +61,8 @@ public final class MonsterBook {
try { try {
qty = cards.get(cardid); qty = cards.get(cardid);
if(qty != null) { if (qty != null) {
if(qty < 5) { if (qty < 5) {
cards.put(cardid, qty + 1); cards.put(cardid, qty + 1);
} }
} else { } else {
@@ -79,7 +79,7 @@ public final class MonsterBook {
lock.unlock(); lock.unlock();
} }
if(qty < 5) { if (qty < 5) {
if (qty == 0) { // leveling system only accounts unique cards if (qty == 0) { // leveling system only accounts unique cards
calculateLevel(); calculateLevel();
} }
@@ -186,7 +186,7 @@ public final class MonsterBook {
private static int saveStringConcat(char[] data, int pos, String s) { private static int saveStringConcat(char[] data, int pos, String s) {
int len = s.length(); int len = s.length();
for(int j = 0; j < len; j++) { for (int j = 0; j < len; j++) {
data[pos + j] = s.charAt(j); data[pos + j] = s.charAt(j);
} }

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;
} }
@@ -84,8 +83,8 @@ public enum AutobanFactory {
} }
public void alert(Character chr, String reason) { public void alert(Character chr, String reason) {
if(YamlConfig.config.server.USE_AUTOBAN == true) { if (YamlConfig.config.server.USE_AUTOBAN == true) {
if (chr != null && MapleLogger.ignored.contains(chr.getId())){ if (chr != null && MapleLogger.ignored.contains(chr.getId())) {
return; return;
} }
Server.getInstance().broadcastGMMessage((chr != null ? chr.getWorld() : 0), PacketCreator.sendYellowTip((chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason)); Server.getInstance().broadcastGMMessage((chr != null ? chr.getWorld() : 0), PacketCreator.sendYellowTip((chr != null ? Character.makeMapleReadable(chr.getName()) : "") + " caused " + this.name() + " " + reason));
@@ -96,7 +95,7 @@ public enum AutobanFactory {
} }
public void autoban(Character chr, String value) { public void autoban(Character chr, String value) {
if(YamlConfig.config.server.USE_AUTOBAN == true) { if (YamlConfig.config.server.USE_AUTOBAN == true) {
chr.autoban("Autobanned for (" + this.name() + ": " + value + ")"); chr.autoban("Autobanned for (" + this.name() + ": " + value + ")");
//chr.sendPolice("You will be disconnected for (" + this.name() + ": " + value + ")"); //chr.sendPolice("You will be disconnected for (" + this.name() + ": " + value + ")");
} }

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) {
@@ -35,7 +34,7 @@ public class AutobanManager {
public void addPoint(AutobanFactory fac, String reason) { public void addPoint(AutobanFactory fac, String reason) {
if (YamlConfig.config.server.USE_AUTOBAN) { if (YamlConfig.config.server.USE_AUTOBAN) {
if (chr.isGM() || chr.isBanned()){ if (chr.isGM() || chr.isBanned()) {
return; return;
} }
@@ -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

@@ -48,19 +48,19 @@ public class CommandsExecutor {
private static final char USER_HEADING = '@'; private static final char USER_HEADING = '@';
private static final char GM_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); char heading = content.charAt(0);
if (client.getPlayer().isGM()){ if (client.getPlayer().isGM()) {
return heading == USER_HEADING || heading == GM_HEADING; return heading == USER_HEADING || heading == GM_HEADING;
} }
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();
registerLv1Commands(); registerLv1Commands();
registerLv2Commands(); registerLv2Commands();
@@ -74,7 +74,7 @@ public class CommandsExecutor {
return commandsNameDesc; return commandsNameDesc;
} }
public void handle(Client client, String message){ public void handle(Client client, String message) {
if (client.tryacquireClient()) { if (client.tryacquireClient()) {
try { try {
handleInternal(client, message); handleInternal(client, message);
@@ -86,7 +86,7 @@ public class CommandsExecutor {
} }
} }
private void handleInternal(Client client, String message){ private void handleInternal(Client client, String message) {
if (client.getPlayer().getMapId() == 300000012) { if (client.getPlayer().getMapId() == 300000012) {
client.getPlayer().yellowMessage("You do not have permission to use commands while in jail."); client.getPlayer().yellowMessage("You do not have permission to use commands while in jail.");
return; return;
@@ -102,11 +102,11 @@ public class CommandsExecutor {
final String[] lowercaseParams = splitedMessage[1].toLowerCase().split(splitRegex); final String[] lowercaseParams = splitedMessage[1].toLowerCase().split(splitRegex);
final Command command = registeredCommands.get(commandName); 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."); client.getPlayer().yellowMessage("Command '" + commandName + "' is not available. See @commands for a list of available commands.");
return; 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."); client.getPlayer().yellowMessage("You do not have permission to use this command.");
return; return;
} }
@@ -121,7 +121,7 @@ public class CommandsExecutor {
writeLog(client, message); 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"); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm");
FilePrinter.print(FilePrinter.USED_COMMANDS, client.getPlayer().getName() + " used: " + command + " on " FilePrinter.print(FilePrinter.USED_COMMANDS, client.getPlayer().getName() + " used: " + command + " on "
+ sdf.format(Calendar.getInstance().getTime())); + sdf.format(Calendar.getInstance().getTime()));
@@ -131,30 +131,31 @@ public class CommandsExecutor {
try { try {
levelCommandsCursor.getRight().add(commandClass.newInstance().getDescription()); levelCommandsCursor.getRight().add(commandClass.newInstance().getDescription());
levelCommandsCursor.getLeft().add(name); levelCommandsCursor.getLeft().add(name);
} catch(Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private void addCommand(String[] syntaxs, Class<? extends Command> commandClass){ private void addCommand(String[] syntaxs, Class<? extends Command> commandClass) {
for (String syntax : syntaxs){ for (String syntax : syntaxs) {
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);
//} //}
} }
private void addCommand(String[] surtaxes, int rank, Class<? extends Command> commandClass){ private void addCommand(String[] surtaxes, int rank, Class<? extends Command> commandClass) {
for (String syntax : surtaxes){ for (String syntax : surtaxes) {
addCommand(syntax, rank, commandClass); addCommand(syntax, rank, commandClass);
} }
} }
private void addCommand(String syntax, int rank, Class<? extends Command> commandClass){ private void addCommand(String syntax, int rank, Class<? extends Command> commandClass) {
if (registeredCommands.containsKey(syntax.toLowerCase())){ if (registeredCommands.containsKey(syntax.toLowerCase())) {
System.out.println("Error on register command with name: " + syntax + ". Already exists."); System.out.println("Error on register command with name: " + syntax + ". Already exists.");
return; return;
} }
@@ -174,7 +175,7 @@ public class CommandsExecutor {
} }
} }
private void registerLv0Commands(){ private void registerLv0Commands() {
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>()); levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
addCommand(new String[]{"help", "commands"}, HelpCommand.class); addCommand(new String[]{"help", "commands"}, HelpCommand.class);
@@ -222,7 +223,7 @@ public class CommandsExecutor {
} }
private void registerLv2Commands(){ private void registerLv2Commands() {
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>()); levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
addCommand("recharge", 2, RechargeCommand.class); addCommand("recharge", 2, RechargeCommand.class);
@@ -331,7 +332,7 @@ public class CommandsExecutor {
commandsNameDesc.add(levelCommandsCursor); commandsNameDesc.add(levelCommandsCursor);
} }
private void registerLv4Commands(){ private void registerLv4Commands() {
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>()); levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
addCommand("servermessage", 4, ServerMessageCommand.class); addCommand("servermessage", 4, ServerMessageCommand.class);
@@ -362,7 +363,7 @@ public class CommandsExecutor {
commandsNameDesc.add(levelCommandsCursor); commandsNameDesc.add(levelCommandsCursor);
} }
private void registerLv5Commands(){ private void registerLv5Commands() {
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>()); levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
addCommand("debug", 5, DebugCommand.class); addCommand("debug", 5, DebugCommand.class);
@@ -375,7 +376,7 @@ public class CommandsExecutor {
commandsNameDesc.add(levelCommandsCursor); commandsNameDesc.add(levelCommandsCursor);
} }
private void registerLv6Commands(){ private void registerLv6Commands() {
levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>()); levelCommandsCursor = new Pair<>(new ArrayList<String>(), new ArrayList<String>());
addCommand("setgmlevel", 6, SetGmLevelCommand.class); addCommand("setgmlevel", 6, SetGmLevelCommand.class);

View File

@@ -35,7 +35,7 @@ public class DropLimitCommand extends Command {
@Override @Override
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
int dropCount = c.getPlayer().getMap().getDroppedItemCount(); 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); c.getPlayer().showHint("Current drop count: #b" + dropCount + "#k / #e" + YamlConfig.config.server.ITEM_LIMIT_ON_MAP + "#n", 300);
} else { } else {
c.getPlayer().showHint("Current drop count: #r" + dropCount + "#k / #e" + YamlConfig.config.server.ITEM_LIMIT_ON_MAP + "#n", 300); c.getPlayer().showHint("Current drop count: #r" + dropCount + "#k / #e" + YamlConfig.config.server.ITEM_LIMIT_ON_MAP + "#n", 300);

View File

@@ -38,24 +38,24 @@ public class GachaCommand extends Command {
Gachapon.GachaponType gacha = null; Gachapon.GachaponType gacha = null;
String search = c.getPlayer().getLastCommandMessage(); String search = c.getPlayer().getLastCommandMessage();
String gachaName = ""; String gachaName = "";
String [] names = {"Henesys", "Ellinia", "Perion", "Kerning City", "Sleepywood", "Mushroom Shrine", "Showa Spa Male", "Showa Spa Female", "New Leaf City", "Nautilus Harbor"}; 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}; int[] ids = {9100100, 9100101, 9100102, 9100103, 9100104, 9100105, 9100106, 9100107, 9100109, 9100117};
for (int i = 0; i < names.length; i++){ for (int i = 0; i < names.length; i++) {
if (search.equalsIgnoreCase(names[i])){ if (search.equalsIgnoreCase(names[i])) {
gachaName = names[i]; gachaName = names[i];
gacha = Gachapon.GachaponType.getByNpcId(ids[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:"); 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); c.getPlayer().yellowMessage(name);
} }
return; return;
} }
String talkStr = "The #b" + gachaName + "#k Gachapon contains the following items.\r\n\r\n"; String talkStr = "The #b" + gachaName + "#k Gachapon contains the following items.\r\n\r\n";
for (int i = 0; i < 2; i++){ for (int i = 0; i < 2; i++) {
for (int id : gacha.getItems(i)){ for (int id : gacha.getItems(i)) {
talkStr += "-" + ItemInformationProvider.getInstance().getName(id) + "\r\n"; talkStr += "-" + ItemInformationProvider.getInstance().getName(id) + "\r\n";
} }
} }

View File

@@ -37,15 +37,16 @@ public class JoinEventCommand extends Command {
@Override @Override
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
Character player = c.getPlayer(); Character player = c.getPlayer();
if(!FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) { if (!FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
Event event = c.getChannelServer().getEvent(); Event event = c.getChannelServer().getEvent();
if(event != null) { if (event != null) {
if(event.getMapId() != player.getMapId()) { if (event.getMapId() != player.getMapId()) {
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

@@ -36,19 +36,19 @@ public class LeaveEventCommand 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 returnMap = player.getSavedLocation("EVENT"); int returnMap = player.getSavedLocation("EVENT");
if(returnMap != -1) { if (returnMap != -1) {
if(player.getOla() != null) { if (player.getOla() != null) {
player.getOla().resetTimes(); player.getOla().resetTimes();
player.setOla(null); player.setOla(null);
} }
if(player.getFitness() != null) { if (player.getFitness() != null) {
player.getFitness().resetTimes(); player.getFitness().resetTimes();
player.setFitness(null); player.setFitness(null);
} }
player.saveLocationOnWarp(); player.saveLocationOnWarp();
player.changeMap(returnMap); player.changeMap(returnMap);
if(c.getChannelServer().getEvent() != null) { if (c.getChannelServer().getEvent() != null) {
c.getChannelServer().getEvent().addLimit(); c.getChannelServer().getEvent().addLimit();
} }
} else { } else {

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,28 +39,36 @@ 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) {
showMsg += "\r\n" + "#eQUEST RATE#n" + "\r\n"; showMsg += "\r\n" + "#eQUEST RATE#n" + "\r\n";
showMsg += "World QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n"; showMsg += "World QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n";
} }

View File

@@ -35,10 +35,10 @@ public class UptimeCommand extends Command {
@Override @Override
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
long milliseconds = System.currentTimeMillis() - Server.uptime; long milliseconds = System.currentTimeMillis() - Server.uptime;
int seconds = (int) (milliseconds / 1000) % 60 ; int seconds = (int) (milliseconds / 1000) % 60;
int minutes = (int) ((milliseconds / (1000*60)) % 60); int minutes = (int) ((milliseconds / (1000 * 60)) % 60);
int hours = (int) ((milliseconds / (1000*60*60)) % 24); int hours = (int) ((milliseconds / (1000 * 60 * 60)) % 24);
int days = (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."); c.getPlayer().yellowMessage("Server has been online for " + days + " days " + hours + " hours " + minutes + " minutes and " + seconds + " seconds.");
} }
} }

View File

@@ -36,11 +36,11 @@ public class BossHpCommand extends Command {
@Override @Override
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
Character player = c.getPlayer(); Character player = c.getPlayer();
for(Monster monster : player.getMap().getAllMonsters()) { for (Monster monster : player.getMap().getAllMonsters()) {
if(monster != null && monster.isBoss() && monster.getHp() > 0) { if (monster != null && monster.isBoss() && monster.getHp() > 0) {
long percent = monster.getHp() * 100L / monster.getMaxHp(); long percent = monster.getHp() * 100L / monster.getMaxHp();
String bar = "["; String bar = "[";
for (int i = 0; i < 100; i++){ for (int i = 0; i < 100; i++) {
bar += i < percent ? "|" : "."; bar += i < percent ? "|" : ".";
} }
bar += "]"; bar += "]";

View File

@@ -74,7 +74,7 @@ public class GotoCommand extends Command {
@Override @Override
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
Character player = c.getPlayer(); 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; String sendStr = "Syntax: #b@goto <map name>#k. Available areas:\r\n\r\n#rTowns:#k\r\n" + GOTO_TOWNS_INFO;
if (player.isGM()) { if (player.isGM()) {
sendStr += ("\r\n#rAreas:#k\r\n" + GOTO_AREAS_INFO); sendStr += ("\r\n#rAreas:#k\r\n" + GOTO_AREAS_INFO);

View File

@@ -36,7 +36,7 @@ public class MobHpCommand extends Command {
@Override @Override
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
Character player = c.getPlayer(); Character player = c.getPlayer();
for(Monster monster : player.getMap().getAllMonsters()) { for (Monster monster : player.getMap().getAllMonsters()) {
if (monster != null && monster.getHp() > 0) { if (monster != null && monster.getHp() > 0) {
player.yellowMessage(monster.getName() + " (" + monster.getId() + ") has " + monster.getHp() + " / " + monster.getMaxHp() + " HP."); player.yellowMessage(monster.getName() + " (" + monster.getId() + ") has " + monster.getHp() + " / " + monster.getMaxHp() + " HP.");

View File

@@ -50,20 +50,20 @@ public class WhatDropsFromCommand extends Command {
int limit = 3; int limit = 3;
Iterator<Pair<Integer, String>> listIterator = MonsterInformationProvider.getMobsIDsFromName(monsterName).iterator(); Iterator<Pair<Integer, String>> listIterator = MonsterInformationProvider.getMobsIDsFromName(monsterName).iterator();
for (int i = 0; i < limit; i++) { for (int i = 0; i < limit; i++) {
if(listIterator.hasNext()) { if (listIterator.hasNext()) {
Pair<Integer, String> data = listIterator.next(); Pair<Integer, String> data = listIterator.next();
int mobId = data.getLeft(); int mobId = data.getLeft();
String mobName = data.getRight(); String mobName = data.getRight();
output += mobName + " drops the following items:\r\n\r\n"; 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 { try {
String name = ItemInformationProvider.getInstance().getName(drop.itemId); 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; continue;
} }
float chance = Math.max(1000000 / drop.chance / (!MonsterInformationProvider.getInstance().isBoss(mobId) ? player.getDropRate() : player.getBossDropRate()), 1); float chance = Math.max(1000000 / drop.chance / (!MonsterInformationProvider.getInstance().isBoss(mobId) ? player.getDropRate() : player.getBossDropRate()), 1);
output += "- " + name + " (1/" + (int) chance + ")\r\n"; output += "- " + name + " (1/" + (int) chance + ")\r\n";
} catch (Exception ex){ } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
continue; continue;
} }

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

@@ -47,7 +47,7 @@ public class IdCommand extends Command {
if (resultList.size() > 0) { if (resultList.size() > 0) {
int count = 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"); sb.append(String.format("Id for %s is: #b%s#k", entry.getKey(), entry.getValue()) + "\r\n");
if (++count > 100) { if (++count > 100) {
break; break;
@@ -85,16 +85,20 @@ 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();
} }
private Map<String, String> fetchResults(Map<String, String> queryMap, String queryItem) { private Map<String, String> fetchResults(Map<String, String> queryMap, String queryItem) {
Map<String, String> results = new HashMap<>(); Map<String, String> results = new HashMap<>();
for (String item: queryMap.keySet()) { for (String item : queryMap.keySet()) {
if (item.indexOf(queryItem) != -1) { if (item.indexOf(queryItem) != -1) {
results.put(item, queryMap.get(item)); results.put(item, queryMap.get(item));
} }

View File

@@ -49,13 +49,15 @@ public class ItemCommand extends Command {
int itemId = Integer.parseInt(params[0]); int itemId = Integer.parseInt(params[0]);
ItemInformationProvider ii = ItemInformationProvider.getInstance(); ItemInformationProvider ii = ItemInformationProvider.getInstance();
if(ii.getName(itemId) == null) { if (ii.getName(itemId) == null) {
player.yellowMessage("Item id '" + params[0] + "' does not exist."); player.yellowMessage("Item id '" + params[0] + "' does not exist.");
return; return;
} }
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.");
@@ -63,7 +65,7 @@ public class ItemCommand extends Command {
} }
if (ItemConstants.isPet(itemId)) { if (ItemConstants.isPet(itemId)) {
if (params.length >= 2){ // thanks to istreety & TacoBell if (params.length >= 2) { // thanks to istreety & TacoBell
quantity = 1; quantity = 1;
long days = Math.max(1, Integer.parseInt(params[1])); long days = Math.max(1, Integer.parseInt(params[1]));
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000); long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
@@ -78,7 +80,7 @@ public class ItemCommand extends Command {
} }
short flag = 0; short flag = 0;
if(player.gmLevel() < 3) { if (player.gmLevel() < 3) {
flag |= ItemConstants.ACCOUNT_SHARING; flag |= ItemConstants.ACCOUNT_SHARING;
flag |= ItemConstants.UNTRADEABLE; flag |= ItemConstants.UNTRADEABLE;
} }

View File

@@ -50,13 +50,15 @@ public class ItemDropCommand extends Command {
int itemId = Integer.parseInt(params[0]); int itemId = Integer.parseInt(params[0]);
ItemInformationProvider ii = ItemInformationProvider.getInstance(); ItemInformationProvider ii = ItemInformationProvider.getInstance();
if(ii.getName(itemId) == null) { if (ii.getName(itemId) == null) {
player.yellowMessage("Item id '" + params[0] + "' does not exist."); player.yellowMessage("Item id '" + params[0] + "' does not exist.");
return; return;
} }
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.");
@@ -64,7 +66,7 @@ public class ItemDropCommand extends Command {
} }
if (ItemConstants.isPet(itemId)) { if (ItemConstants.isPet(itemId)) {
if (params.length >= 2){ // thanks to istreety & TacoBell if (params.length >= 2) { // thanks to istreety & TacoBell
quantity = 1; quantity = 1;
long days = Math.max(1, Integer.parseInt(params[1])); long days = Math.max(1, Integer.parseInt(params[1]));
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000); long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
@@ -74,7 +76,7 @@ public class ItemDropCommand extends Command {
toDrop.setExpiration(expiration); toDrop.setExpiration(expiration);
toDrop.setOwner(""); toDrop.setOwner("");
if(player.gmLevel() < 3) { if (player.gmLevel() < 3) {
short f = toDrop.getFlag(); short f = toDrop.getFlag();
f |= ItemConstants.ACCOUNT_SHARING; f |= ItemConstants.ACCOUNT_SHARING;
f |= ItemConstants.UNTRADEABLE; f |= ItemConstants.UNTRADEABLE;
@@ -101,7 +103,7 @@ public class ItemDropCommand extends Command {
} }
toDrop.setOwner(player.getName()); toDrop.setOwner(player.getName());
if(player.gmLevel() < 3) { if (player.gmLevel() < 3) {
short f = toDrop.getFlag(); short f = toDrop.getFlag();
f |= ItemConstants.ACCOUNT_SHARING; f |= ItemConstants.ACCOUNT_SHARING;
f |= ItemConstants.UNTRADEABLE; f |= ItemConstants.UNTRADEABLE;

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

@@ -41,16 +41,16 @@ public class RechargeCommand extends Command {
Character player = c.getPlayer(); Character player = c.getPlayer();
ItemInformationProvider ii = ItemInformationProvider.getInstance(); ItemInformationProvider ii = ItemInformationProvider.getInstance();
for (Item torecharge : c.getPlayer().getInventory(InventoryType.USE).list()) { 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())); torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
c.getPlayer().forceUpdateItem(torecharge); c.getPlayer().forceUpdateItem(torecharge);
} else if (ItemConstants.isArrow(torecharge.getItemId())){ } else if (ItemConstants.isArrow(torecharge.getItemId())) {
torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId())); torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
c.getPlayer().forceUpdateItem(torecharge); c.getPlayer().forceUpdateItem(torecharge);
} else if (ItemConstants.isBullet(torecharge.getItemId())){ } else if (ItemConstants.isBullet(torecharge.getItemId())) {
torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId())); torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
c.getPlayer().forceUpdateItem(torecharge); c.getPlayer().forceUpdateItem(torecharge);
} else if (ItemConstants.isConsumable(torecharge.getItemId())){ } else if (ItemConstants.isConsumable(torecharge.getItemId())) {
torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId())); torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
c.getPlayer().forceUpdateItem(torecharge); c.getPlayer().forceUpdateItem(torecharge);
} }

View File

@@ -60,7 +60,7 @@ public class SearchCommand extends Command {
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String search = joinStringFrom(params,1); String search = joinStringFrom(params, 1);
long start = System.currentTimeMillis();//for the lulz long start = System.currentTimeMillis();//for the lulz
Data data = null; Data data = null;
if (!params[0].equalsIgnoreCase("ITEM")) { if (!params[0].equalsIgnoreCase("ITEM")) {

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

@@ -21,7 +21,7 @@ public class GiveRpCommand extends Command {
if (victim != null) { if (victim != null) {
victim.setRewardPoints(victim.getRewardPoints() + Integer.parseInt(params[1])); victim.setRewardPoints(victim.getRewardPoints() + Integer.parseInt(params[1]));
player.message("RP given. Player " + params[0] + " now has " + victim.getRewardPoints() player.message("RP given. Player " + params[0] + " now has " + victim.getRewardPoints()
+ " reward points." ); + " reward points.");
} else { } else {
player.message("Player '" + params[0] + "' could not be found."); player.message("Player '" + params[0] + "' could not be found.");
} }

View File

@@ -37,7 +37,7 @@ public class QuestCompleteCommand extends Command {
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
Character player = c.getPlayer(); Character player = c.getPlayer();
if (params.length < 1){ if (params.length < 1) {
player.yellowMessage("Syntax: !completequest <questid>"); player.yellowMessage("Syntax: !completequest <questid>");
return; return;
} }

View File

@@ -37,7 +37,7 @@ public class QuestResetCommand extends Command {
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
Character player = c.getPlayer(); Character player = c.getPlayer();
if (params.length < 1){ if (params.length < 1) {
player.yellowMessage("Syntax: !resetquest <questid>"); player.yellowMessage("Syntax: !resetquest <questid>");
return; return;
} }

View File

@@ -37,7 +37,7 @@ public class QuestStartCommand extends Command {
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
Character player = c.getPlayer(); Character player = c.getPlayer();
if (params.length < 1){ if (params.length < 1) {
player.yellowMessage("Syntax: !startquest <questid>"); player.yellowMessage("Syntax: !startquest <questid>");
return; return;
} }

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

@@ -96,7 +96,7 @@ public class PnpcRemoveCommand extends Command {
} }
if (!toRemove.isEmpty()) { if (!toRemove.isEmpty()) {
for (Channel ch: player.getWorldServer().getChannels()) { for (Channel ch : player.getWorldServer().getChannels()) {
MapleMap map = ch.getMapFactory().getMap(mapId); MapleMap map = ch.getMapFactory().getMap(mapId);
for (Pair<Integer, Pair<Integer, Integer>> r : toRemove) { for (Pair<Integer, Pair<Integer, Integer>> r : toRemove) {

View File

@@ -49,7 +49,7 @@ public class ProItemCommand extends Command {
ItemInformationProvider ii = ItemInformationProvider.getInstance(); ItemInformationProvider ii = ItemInformationProvider.getInstance();
int itemid = Integer.parseInt(params[0]); 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."); player.yellowMessage("Item id '" + params[0] + "' does not exist.");
return; return;
} }
@@ -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

@@ -59,7 +59,7 @@ public class DebugCommand extends Command {
case "type": case "type":
case "help": case "help":
String msgTypes = "Available #bdebug types#k:\r\n\r\n"; 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"); msgTypes += ("#L" + i + "#" + debugTypes[i] + "#l\r\n");
} }
@@ -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

@@ -47,15 +47,15 @@ public class ServerAddChannelCommand extends Command {
ThreadManager.getInstance().newTask(() -> { ThreadManager.getInstance().newTask(() -> {
int chid = Server.getInstance().addChannel(worldid); int chid = Server.getInstance().addChannel(worldid);
if(player.isLoggedinWorld()) { if (player.isLoggedinWorld()) {
if(chid >= 0) { if (chid >= 0) {
player.dropMessage(5, "NEW Channel " + chid + " successfully deployed on world " + worldid + "."); player.dropMessage(5, "NEW Channel " + chid + " successfully deployed on world " + worldid + ".");
} else { } else {
if(chid == -3) { if (chid == -3) {
player.dropMessage(5, "Invalid worldid detected. Channel creation aborted."); 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."); 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."); player.dropMessage(5, "Error detected when loading the 'world.ini' file. Channel creation aborted.");
} else { } 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."); player.dropMessage(5, "NEW Channel failed to be deployed. Check if the needed port is already in use or other limitations are taking place.");

View File

@@ -41,11 +41,11 @@ public class ServerAddWorldCommand extends Command {
ThreadManager.getInstance().newTask(() -> { ThreadManager.getInstance().newTask(() -> {
int wid = Server.getInstance().addWorld(); int wid = Server.getInstance().addWorld();
if(player.isLoggedinWorld()) { if (player.isLoggedinWorld()) {
if(wid >= 0) { if (wid >= 0) {
player.dropMessage(5, "NEW World " + wid + " successfully deployed."); player.dropMessage(5, "NEW World " + wid + " successfully deployed.");
} else { } else {
if(wid == -2) { if (wid == -2) {
player.dropMessage(5, "Error detected when loading the 'world.ini' file. World creation aborted."); player.dropMessage(5, "Error detected when loading the 'world.ini' file. World creation aborted.");
} else { } 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."); player.dropMessage(5, "NEW World failed to be deployed. Check if needed ports are already in use or maximum world count has been reached.");

View File

@@ -45,12 +45,12 @@ public class ServerRemoveChannelCommand extends Command {
final int worldId = Integer.parseInt(params[0]); final int worldId = Integer.parseInt(params[0]);
ThreadManager.getInstance().newTask(() -> { ThreadManager.getInstance().newTask(() -> {
if(Server.getInstance().removeChannel(worldId)) { if (Server.getInstance().removeChannel(worldId)) {
if(player.isLoggedinWorld()) { if (player.isLoggedinWorld()) {
player.dropMessage(5, "Successfully removed a channel on World " + worldId + ". Current channel count: " + Server.getInstance().getWorld(worldId).getChannelsSize() + "."); player.dropMessage(5, "Successfully removed a channel on World " + worldId + ". Current channel count: " + Server.getInstance().getWorld(worldId).getChannelsSize() + ".");
} }
} else { } 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."); player.dropMessage(5, "Failed to remove last Channel on world " + worldId + ". Check if either that world exists or there are people currently playing there.");
} }
} }

View File

@@ -39,19 +39,19 @@ public class ServerRemoveWorldCommand extends Command {
final Character player = c.getPlayer(); final Character player = c.getPlayer();
final int rwid = Server.getInstance().getWorldsSize() - 1; final int rwid = Server.getInstance().getWorldsSize() - 1;
if(rwid <= 0) { if (rwid <= 0) {
player.dropMessage(5, "Unable to remove world 0."); player.dropMessage(5, "Unable to remove world 0.");
return; return;
} }
ThreadManager.getInstance().newTask(() -> { ThreadManager.getInstance().newTask(() -> {
if(Server.getInstance().removeWorld()) { if (Server.getInstance().removeWorld()) {
if(player.isLoggedinWorld()) { if (player.isLoggedinWorld()) {
player.dropMessage(5, "Successfully removed a world. Current world count: " + Server.getInstance().getWorldsSize() + "."); player.dropMessage(5, "Successfully removed a world. Current world count: " + Server.getInstance().getWorldsSize() + ".");
} }
} else { } else {
if(player.isLoggedinWorld()) { if (player.isLoggedinWorld()) {
if(rwid < 0) { if (rwid < 0) {
player.dropMessage(5, "No registered worlds to remove."); player.dropMessage(5, "No registered worlds to remove.");
} else { } else {
player.dropMessage(5, "Failed to remove world " + rwid + ". Check if there are people currently playing there."); player.dropMessage(5, "Failed to remove world " + rwid + ". Check if there are people currently playing there.");

View File

@@ -38,13 +38,13 @@ public class ShutdownCommand extends Command {
@Override @Override
public void execute(Client c, String[] params) { public void execute(Client c, String[] params) {
Character player = c.getPlayer(); Character player = c.getPlayer();
if (params.length < 1){ if (params.length < 1) {
player.yellowMessage("Syntax: !shutdown [<time>|NOW]"); player.yellowMessage("Syntax: !shutdown [<time>|NOW]");
return; return;
} }
int time = 60000; int time = 60000;
if (params[0].equalsIgnoreCase("now")){ if (params[0].equalsIgnoreCase("now")) {
time = 1; time = 1;
} else { } else {
time *= Integer.parseInt(params[0]); time *= Integer.parseInt(params[0]);
@@ -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 {
@@ -63,25 +62,25 @@ public abstract class CharacterFactory {
int top = recipe.getTop(), bottom = recipe.getBottom(), shoes = recipe.getShoes(), weapon = recipe.getWeapon(); int top = recipe.getTop(), bottom = recipe.getBottom(), shoes = recipe.getShoes(), weapon = recipe.getWeapon();
if(top > 0) { if (top > 0) {
Item eq_top = ii.getEquipById(top); Item eq_top = ii.getEquipById(top);
eq_top.setPosition((byte) -5); eq_top.setPosition((byte) -5);
equipped.addItemFromDB(eq_top); equipped.addItemFromDB(eq_top);
} }
if(bottom > 0) { if (bottom > 0) {
Item eq_bottom = ii.getEquipById(bottom); Item eq_bottom = ii.getEquipById(bottom);
eq_bottom.setPosition((byte) -6); eq_bottom.setPosition((byte) -6);
equipped.addItemFromDB(eq_bottom); equipped.addItemFromDB(eq_bottom);
} }
if(shoes > 0) { if (shoes > 0) {
Item eq_shoes = ii.getEquipById(shoes); Item eq_shoes = ii.getEquipById(shoes);
eq_shoes.setPosition((byte) -7); eq_shoes.setPosition((byte) -7);
equipped.addItemFromDB(eq_shoes); equipped.addItemFromDB(eq_shoes);
} }
if(weapon > 0) { if (weapon > 0) {
Item eq_weapon = ii.getEquipById(weapon); Item eq_weapon = ii.getEquipById(weapon);
eq_weapon.setPosition((byte) -11); eq_weapon.setPosition((byte) -11);
equipped.addItemFromDB(eq_weapon.copy()); equipped.addItemFromDB(eq_weapon.copy());

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;
@@ -113,7 +117,7 @@ public class CharacterFactoryRecipe {
public void addStartingItem(int itemid, int quantity, InventoryType itemType) { public void addStartingItem(int itemid, int quantity, InventoryType itemType) {
AtomicInteger p = runningTypePosition.get(itemType); AtomicInteger p = runningTypePosition.get(itemType);
if(p == null) { if (p == null) {
p = new AtomicInteger(0); p = new AtomicInteger(0);
runningTypePosition.put(itemType, p); runningTypePosition.put(itemType, p);
} }

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);
@@ -49,7 +48,7 @@ public class BowmanCreator extends CharacterFactory {
recipe.setMeso(100000); recipe.setMeso(100000);
for(int i = 1; i < weapons.length; i++) { for (int i = 1; i < weapons.length; i++) {
giveEquipment(recipe, ii, weapons[i]); giveEquipment(recipe, ii, weapons[i]);
} }

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);
@@ -53,11 +52,11 @@ public class MagicianCreator extends CharacterFactory {
recipe.setMeso(100000); recipe.setMeso(100000);
if(gender == 0) { if (gender == 0) {
giveEquipment(recipe, ii, 1050003); giveEquipment(recipe, ii, 1050003);
} }
for(int i = 1; i < weapons.length; i++) { for (int i = 1; i < weapons.length; i++) {
giveEquipment(recipe, ii, weapons[i]); giveEquipment(recipe, ii, weapons[i]);
} }
@@ -65,7 +64,7 @@ public class MagicianCreator extends CharacterFactory {
giveItem(recipe, 2000006, 100, InventoryType.USE); giveItem(recipe, 2000006, 100, InventoryType.USE);
giveItem(recipe, 3010000, 1, InventoryType.SETUP); giveItem(recipe, 3010000, 1, InventoryType.SETUP);
if(improveSp > 0) { if (improveSp > 0) {
improveSp += 5; improveSp += 5;
recipe.setRemainingSp(recipe.getRemainingSp() - improveSp); recipe.setRemainingSp(recipe.getRemainingSp() - improveSp);
@@ -74,7 +73,7 @@ public class MagicianCreator extends CharacterFactory {
recipe.addStartingSkillLevel(improveMpRec, toUseSp); recipe.addStartingSkillLevel(improveMpRec, toUseSp);
improveSp -= toUseSp; improveSp -= toUseSp;
if(improveSp > 0) { if (improveSp > 0) {
Skill improveMaxMp = SkillFactory.getSkill(Magician.IMPROVED_MAX_MP_INCREASE); Skill improveMaxMp = SkillFactory.getSkill(Magician.IMPROVED_MAX_MP_INCREASE);
recipe.addStartingSkillLevel(improveMaxMp, improveSp); recipe.addStartingSkillLevel(improveMaxMp, improveSp);
} }

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);
@@ -51,7 +50,7 @@ public class PirateCreator extends CharacterFactory {
giveEquipment(recipe, ii, 1052107); giveEquipment(recipe, ii, 1052107);
for(int i = 1; i < weapons.length; i++) { for (int i = 1; i < weapons.length; i++) {
giveEquipment(recipe, ii, weapons[i]); giveEquipment(recipe, ii, weapons[i]);
} }

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);
@@ -49,7 +48,7 @@ public class ThiefCreator extends CharacterFactory {
recipe.setMeso(100000); recipe.setMeso(100000);
for(int i = 1; i < weapons.length; i++) { for (int i = 1; i < weapons.length; i++) {
giveEquipment(recipe, ii, weapons[i]); giveEquipment(recipe, ii, weapons[i]);
} }

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);
@@ -53,15 +52,15 @@ public class WarriorCreator extends CharacterFactory {
recipe.setMeso(100000); recipe.setMeso(100000);
if(gender == 1) { if (gender == 1) {
giveEquipment(recipe, ii, 1051010); giveEquipment(recipe, ii, 1051010);
} }
for(int i = 1; i < weapons.length; i++) { for (int i = 1; i < weapons.length; i++) {
giveEquipment(recipe, ii, weapons[i]); giveEquipment(recipe, ii, weapons[i]);
} }
if(improveSp > 0) { if (improveSp > 0) {
improveSp += 5; improveSp += 5;
recipe.setRemainingSp(recipe.getRemainingSp() - improveSp); recipe.setRemainingSp(recipe.getRemainingSp() - improveSp);
@@ -70,7 +69,7 @@ public class WarriorCreator extends CharacterFactory {
recipe.addStartingSkillLevel(improveHpRec, toUseSp); recipe.addStartingSkillLevel(improveHpRec, toUseSp);
improveSp -= toUseSp; improveSp -= toUseSp;
if(improveSp > 0) { if (improveSp > 0) {
Skill improveMaxHp = SkillFactory.getSkill(Warrior.IMPROVED_MAXHP); Skill improveMaxHp = SkillFactory.getSkill(Warrior.IMPROVED_MAXHP);
recipe.addStartingSkillLevel(improveMaxHp, improveSp); recipe.addStartingSkillLevel(improveMaxHp, improveSp);
} }

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;
} }
} }
@@ -280,13 +280,18 @@ public class Equip extends Item {
private static int getStatModifier(boolean isAttribute) { private static int getStatModifier(boolean isAttribute) {
// 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;
} }
} }
@@ -297,9 +302,9 @@ public class Equip extends Item {
int rnd = Randomizer.rand(0, poolCount); int rnd = Randomizer.rand(0, poolCount);
int stat = 0; int stat = 0;
if(rnd >= limit) { if (rnd >= limit) {
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; return stat;
@@ -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;
}
} }
} }
@@ -331,52 +332,110 @@ public class Equip extends Item {
private void getUnitStatUpgrade(List<Pair<StatUpgrade, Integer>> stats, StatUpgrade name, int curStat, boolean isAttribute) { private void getUnitStatUpgrade(List<Pair<StatUpgrade, Integer>> stats, StatUpgrade name, int curStat, boolean isAttribute) {
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));
} }
private static void getUnitSlotUpgrade(List<Pair<StatUpgrade, Integer>> stats, StatUpgrade name) { 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. stats.add(new Pair<>(name, 1)); // 10% success on getting a slot upgrade.
} }
} }
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;
} }
@@ -475,33 +534,41 @@ public class Equip extends Item {
private void gainLevel(Client c) { private void gainLevel(Client c) {
List<Pair<StatUpgrade, Integer>> stats = new LinkedList<>(); List<Pair<StatUpgrade, Integer>> stats = new LinkedList<>();
if(isElemental) { if (isElemental) {
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 {
isUpgradeable = false; isUpgradeable = false;
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);
} }
if(isUpgradeable) { if (isUpgradeable) {
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);
} }
} }
@@ -545,14 +612,14 @@ public class Equip extends Item {
// Conversion factor between mob exp and equip exp gain. Through many calculations, the expected for equipment levelup // 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. // 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; return 42;
} else if(reqLevel >= 78) { } else if (reqLevel >= 78) {
return Math.max((10413.648 * Math.exp(reqLevel * 0.03275)), 15); return Math.max((10413.648 * Math.exp(reqLevel * 0.03275)), 15);
} else if(reqLevel >= 38) { } else if (reqLevel >= 38) {
return Math.max(( 4985.818 * Math.exp(reqLevel * 0.02007)), 15); return Math.max((4985.818 * Math.exp(reqLevel * 0.02007)), 15);
} else if(reqLevel >= 18) { } else if (reqLevel >= 18) {
return Math.max(( 248.219 * Math.exp(reqLevel * 0.11093)), 15); return Math.max((248.219 * Math.exp(reqLevel * 0.11093)), 15);
} else { } else {
return Math.max(((1334.564 * Math.log(reqLevel)) - 1731.976), 15); return Math.max(((1334.564 * Math.log(reqLevel)) - 1731.976), 15);
} }
@@ -560,7 +627,7 @@ public class Equip extends Item {
public synchronized void gainItemExp(Client c, int gain) { // Ronan's Equip Exp gain method public synchronized void gainItemExp(Client c, int gain) { // Ronan's Equip Exp gain method
ItemInformationProvider ii = ItemInformationProvider.getInstance(); ItemInformationProvider ii = ItemInformationProvider.getInstance();
if(!ii.isUpgradeable(this.getItemId())) { if (!ii.isUpgradeable(this.getItemId())) {
return; return;
} }
@@ -571,7 +638,7 @@ public class Equip extends Item {
int reqLevel = ii.getEquipLevelReq(this.getItemId()); 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 elementModifier = (isElemental) ? 0.85f : 0.6f;
float baseExpGain = gain * elementModifier * masteryModifier; float baseExpGain = gain * elementModifier * masteryModifier;
@@ -579,14 +646,16 @@ 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) {
itemExp -= expNeeded; itemExp -= expNeeded;
gainLevel(c); gainLevel(c);
if(itemLevel >= equipMaxLevel) { if (itemLevel >= equipMaxLevel) {
itemExp = 0.0f; itemExp = 0.0f;
break; break;
} }
@@ -611,10 +680,12 @@ 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));
return "'" + eqpName + "' -> LV: #e#b" + itemLevel + "#k#n " + eqpInfo + "\r\n"; return "'" + eqpName + "' -> LV: #e#b" + itemLevel + "#k#n " + eqpInfo + "\r\n";
} }

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;
@@ -154,7 +153,7 @@ public class NewYearCardRecord {
newyear.id = rs.getInt(1); newyear.id = rs.getInt(1);
} }
} }
} catch(SQLException sqle) { } catch (SQLException sqle) {
sqle.printStackTrace(); sqle.printStackTrace();
} }
} }
@@ -170,14 +169,16 @@ public class NewYearCardRecord {
ps.executeUpdate(); ps.executeUpdate();
} }
} catch(SQLException sqle) { } catch (SQLException sqle) {
sqle.printStackTrace(); sqle.printStackTrace();
} }
} }
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 = ?")) {
@@ -192,7 +193,7 @@ public class NewYearCardRecord {
} }
} }
} }
} catch(SQLException sqle) { } catch (SQLException sqle) {
sqle.printStackTrace(); sqle.printStackTrace();
} }
@@ -213,7 +214,7 @@ public class NewYearCardRecord {
} }
} }
} }
} catch(SQLException sqle) { } catch (SQLException sqle) {
sqle.printStackTrace(); sqle.printStackTrace();
} }
} }
@@ -221,7 +222,7 @@ public class NewYearCardRecord {
public static void printNewYearRecords(Character chr) { public static void printNewYearRecords(Character chr) {
chr.dropMessage(5, "New Years: " + chr.getNewYearRecords().size()); chr.dropMessage(5, "New Years: " + chr.getNewYearRecords().size());
for(NewYearCardRecord nyc : chr.getNewYearRecords()) { for (NewYearCardRecord nyc : chr.getNewYearRecords()) {
chr.dropMessage(5, "-------------------------------"); chr.dropMessage(5, "-------------------------------");
chr.dropMessage(5, "Id: " + nyc.id); chr.dropMessage(5, "Id: " + nyc.id);
@@ -242,13 +243,15 @@ 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();
int world = server.getCharacterWorld(receiverId); int world = server.getCharacterWorld(receiverId);
if(world == -1) { if (world == -1) {
sendTask.cancel(false); sendTask.cancel(false);
sendTask = null; sendTask = null;
@@ -256,14 +259,14 @@ public class NewYearCardRecord {
} }
Character target = server.getWorld(world).getPlayerStorage().getCharacterById(receiverId); 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)); target.sendPacket(PacketCreator.onNewYearCardRes(target, NewYearCardRecord.this, 0xC, 0));
} }
}, 1000 * 60 * 60); //1 Hour }, 1000 * 60 * 60); //1 Hour
} }
public void stopNewYearCardTask() { public void stopNewYearCardTask() {
if(sendTask != null) { if (sendTask != null) {
sendTask.cancel(false); sendTask.cancel(false);
sendTask = null; sendTask = null;
} }
@@ -277,7 +280,7 @@ public class NewYearCardRecord {
ps.setInt(1, id); ps.setInt(1, id);
ps.executeUpdate(); ps.executeUpdate();
} }
} catch(SQLException sqle) { } catch (SQLException sqle) {
sqle.printStackTrace(); sqle.printStackTrace();
} }
} }
@@ -299,9 +302,9 @@ public class NewYearCardRecord {
*/ */
Set<NewYearCardRecord> set = new HashSet<>(chr.getNewYearRecords()); Set<NewYearCardRecord> set = new HashSet<>(chr.getNewYearRecords());
for(NewYearCardRecord nyc : set) { for (NewYearCardRecord nyc : set) {
if(send) { if (send) {
if(nyc.senderId == cid) { if (nyc.senderId == cid) {
nyc.senderDiscardCard = true; nyc.senderDiscardCard = true;
nyc.receiverReceivedCard = false; nyc.receiverReceivedCard = false;
@@ -311,7 +314,7 @@ public class NewYearCardRecord {
chr.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(chr, nyc, 0xE, 0)); chr.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(chr, nyc, 0xE, 0));
Character other = chr.getClient().getWorldServer().getPlayerStorage().getCharacterById(nyc.getReceiverId()); Character other = chr.getClient().getWorldServer().getPlayerStorage().getCharacterById(nyc.getReceiverId());
if(other != null && other.isLoggedinWorld()) { if (other != null && other.isLoggedinWorld()) {
other.removeNewYearRecord(nyc); other.removeNewYearRecord(nyc);
other.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(other, nyc, 0xE, 0)); other.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(other, nyc, 0xE, 0));
@@ -319,7 +322,7 @@ public class NewYearCardRecord {
} }
} }
} else { } else {
if(nyc.receiverId == cid) { if (nyc.receiverId == cid) {
nyc.receiverDiscardCard = true; nyc.receiverDiscardCard = true;
nyc.receiverReceivedCard = false; nyc.receiverReceivedCard = false;
@@ -329,7 +332,7 @@ public class NewYearCardRecord {
chr.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(chr, nyc, 0xE, 0)); chr.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(chr, nyc, 0xE, 0));
Character other = chr.getClient().getWorldServer().getPlayerStorage().getCharacterById(nyc.getSenderId()); Character other = chr.getClient().getWorldServer().getPlayerStorage().getCharacterById(nyc.getSenderId());
if(other != null && other.isLoggedinWorld()) { if (other != null && other.isLoggedinWorld()) {
other.removeNewYearRecord(nyc); other.removeNewYearRecord(nyc);
other.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(other, nyc, 0xE, 0)); other.getMap().broadcastMessage(PacketCreator.onNewYearCardRes(other, nyc, 0xE, 0));

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 {
@@ -43,7 +42,7 @@ public class BuybackProcessor {
if (buyback) { if (buyback) {
String jobString; String jobString;
switch(chr.getJobStyle()) { switch (chr.getJobStyle()) {
case WARRIOR: case WARRIOR:
jobString = "warrior"; jobString = "warrior";
break; break;

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()) {
@@ -61,26 +60,26 @@ public class MakerProcessor {
Map<Integer, Short> reagentids = new LinkedHashMap<>(); Map<Integer, Short> reagentids = new LinkedHashMap<>();
int stimulantid = -1; int stimulantid = -1;
if(type == 3) { // building monster crystal if (type == 3) { // building monster crystal
int fromLeftover = toCreate; int fromLeftover = toCreate;
toCreate = ii.getMakerCrystalFromLeftover(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.serverNotice(1, ii.getName(fromLeftover) + " is unavailable for Monster Crystal conversion."));
c.sendPacket(PacketCreator.makerEnableActions()); c.sendPacket(PacketCreator.makerEnableActions());
return; return;
} }
recipe = MakerItemFactory.generateLeftoverCrystalEntry(fromLeftover, toCreate); recipe = MakerItemFactory.generateLeftoverCrystalEntry(fromLeftover, toCreate);
} else if(type == 4) { // disassembling } else if (type == 4) { // disassembling
p.readInt(); // 1... probably inventory type p.readInt(); // 1... probably inventory type
pos = p.readInt(); pos = p.readInt();
Item it = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((short) pos); Item it = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((short) pos);
if(it != null && it.getItemId() == toCreate) { if (it != null && it.getItemId() == toCreate) {
toDisassemble = toCreate; toDisassemble = toCreate;
Pair<Integer, List<Pair<Integer, Integer>>> pair = generateDisassemblyInfo(toDisassemble); Pair<Integer, List<Pair<Integer, Integer>>> pair = generateDisassemblyInfo(toDisassemble);
if(pair != null) { if (pair != null) {
recipe = MakerItemFactory.generateDisassemblyCrystalEntry(toDisassemble, pair.getLeft(), pair.getRight()); recipe = MakerItemFactory.generateDisassemblyCrystalEntry(toDisassemble, pair.getLeft(), pair.getRight());
} else { } else {
c.sendPacket(PacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal disassembly.")); c.sendPacket(PacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal disassembly."));
@@ -93,20 +92,20 @@ public class MakerProcessor {
return; return;
} }
} else { } else {
if(ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents if (ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents
if(p.readByte() != 0) { // stimulant if (p.readByte() != 0) { // stimulant
stimulantid = ii.getMakerStimulant(toCreate); stimulantid = ii.getMakerStimulant(toCreate);
if(!c.getAbstractPlayerInteraction().haveItem(stimulantid)) { if (!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
stimulantid = -1; stimulantid = -1;
} }
} }
int reagents = Math.min(p.readInt(), getMakerReagentSlots(toCreate)); 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(); int reagentid = p.readInt();
if(ItemConstants.isMakerReagent(reagentid)) { if (ItemConstants.isMakerReagent(reagentid)) {
Short rs = reagentids.get(reagentid); Short rs = reagentids.get(reagentid);
if(rs == null) { if (rs == null) {
reagentids.put(reagentid, (short) 1); reagentids.put(reagentid, (short) 1);
} else { } else {
reagentids.put(reagentid, (short) (rs + 1)); reagentids.put(reagentid, (short) (rs + 1));
@@ -115,18 +114,18 @@ public class MakerProcessor {
} }
List<Pair<Integer, Short>> toUpdate = new LinkedList<>(); 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()); int qty = c.getAbstractPlayerInteraction().getItemQuantity(r.getKey());
if(qty < r.getValue()) { if (qty < r.getValue()) {
toUpdate.add(new Pair<>(r.getKey(), (short) qty)); toUpdate.add(new Pair<>(r.getKey(), (short) qty));
} }
} }
// remove those not present on player inventory // remove those not present on player inventory
if(!toUpdate.isEmpty()) { if (!toUpdate.isEmpty()) {
for(Pair<Integer, Short> rp : toUpdate) { for (Pair<Integer, Short> rp : toUpdate) {
if(rp.getRight() > 0) { if (rp.getRight() > 0) {
reagentids.put(rp.getLeft(), rp.getRight()); reagentids.put(rp.getLeft(), rp.getRight());
} else { } else {
reagentids.remove(rp.getLeft()); reagentids.remove(rp.getLeft());
@@ -134,8 +133,8 @@ public class MakerProcessor {
} }
} }
if(!reagentids.isEmpty()) { if (!reagentids.isEmpty()) {
if(!removeOddMakerReagents(toCreate, reagentids)) { if (!removeOddMakerReagents(toCreate, reagentids)) {
c.sendPacket(PacketCreator.serverNotice(1, "You can only use WATK and MATK Strengthening Gems on weapon items.")); c.sendPacket(PacketCreator.serverNotice(1, "You can only use WATK and MATK Strengthening Gems on weapon items."));
c.sendPacket(PacketCreator.makerEnableActions()); c.sendPacket(PacketCreator.makerEnableActions());
return; return;
@@ -148,7 +147,7 @@ public class MakerProcessor {
short createStatus = getCreateStatus(c, recipe); short createStatus = getCreateStatus(c, recipe);
switch(createStatus) { switch (createStatus) {
case -1:// non-available for Maker itemid has been tried to forge 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."); 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.")); c.sendPacket(PacketCreator.serverNotice(1, "The requested item could not be crafted on this operation."));
@@ -181,7 +180,7 @@ public class MakerProcessor {
break; break;
default: default:
if(toDisassemble != -1) { if (toDisassemble != -1) {
InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (short) pos, (short) 1, false); InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (short) pos, (short) 1, false);
} else { } else {
for (Pair<Integer, Integer> pair : recipe.getReqItems()) { for (Pair<Integer, Integer> pair : recipe.getReqItems()) {
@@ -190,8 +189,10 @@ 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) {
if(!reagentids.isEmpty()) { c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1, false);
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) { }
if (!reagentids.isEmpty()) {
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);
} }
@@ -224,7 +229,7 @@ public class MakerProcessor {
c.sendPacket(PacketCreator.showMakerEffect(makerSucceeded)); c.sendPacket(PacketCreator.showMakerEffect(makerSucceeded));
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), PacketCreator.showForeignMakerEffect(c.getPlayer().getId(), makerSucceeded), false); 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); c.getAbstractPlayerInteraction().setQuestProgress(6033, 1);
} }
} }
@@ -241,17 +246,17 @@ public class MakerProcessor {
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 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 curRid = r.getKey();
int type = r.getKey() / 100; 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); return false; //toRemove.add(curRid);
} else { } else {
Integer tableRid = reagentType.get(type); Integer tableRid = reagentType.get(type);
if(tableRid != null) { if (tableRid != null) {
if(tableRid < curRid) { if (tableRid < curRid) {
toRemove.add(tableRid); toRemove.add(tableRid);
reagentType.put(type, curRid); reagentType.put(type, curRid);
} else { } else {
@@ -264,12 +269,12 @@ public class MakerProcessor {
} }
// removing less effective gems of repeated type // removing less effective gems of repeated type
for(Integer i : toRemove) { for (Integer i : toRemove) {
reagentids.remove(i); reagentids.remove(i);
} }
// the Maker skill will use only one of each gem // 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); reagentids.put(i, (short) 1);
} }
@@ -280,23 +285,23 @@ public class MakerProcessor {
try { try {
int eqpLevel = ii.getEquipLevelReq(itemId); int eqpLevel = ii.getEquipLevelReq(itemId);
if(eqpLevel < 78) { if (eqpLevel < 78) {
return 1; return 1;
} else if(eqpLevel >= 78 && eqpLevel < 108) { } else if (eqpLevel >= 78 && eqpLevel < 108) {
return 2; return 2;
} else { } else {
return 3; return 3;
} }
} catch(NullPointerException npe) { } catch (NullPointerException npe) {
return 0; return 0;
} }
} }
private static Pair<Integer, List<Pair<Integer, Integer>>> generateDisassemblyInfo(int itemId) { private static Pair<Integer, List<Pair<Integer, Integer>>> generateDisassemblyInfo(int itemId) {
int recvFee = ii.getMakerDisassembledFee(itemId); int recvFee = ii.getMakerDisassembledFee(itemId);
if(recvFee > -1) { if (recvFee > -1) {
List<Pair<Integer, Integer>> gains = ii.getMakerDisassembledItems(itemId); List<Pair<Integer, Integer>> gains = ii.getMakerDisassembledItems(itemId);
if(!gains.isEmpty()) { if (!gains.isEmpty()) {
return new Pair<>(recvFee, gains); return new Pair<>(recvFee, gains);
} }
} }
@@ -309,23 +314,23 @@ public class MakerProcessor {
} }
private static short getCreateStatus(Client c, MakerItemCreateEntry recipe) { private static short getCreateStatus(Client c, MakerItemCreateEntry recipe) {
if(recipe.isInvalid()) { if (recipe.isInvalid()) {
return -1; return -1;
} }
if(!hasItems(c, recipe)) { if (!hasItems(c, recipe)) {
return 1; return 1;
} }
if(c.getPlayer().getMeso() < recipe.getCost()) { if (c.getPlayer().getMeso() < recipe.getCost()) {
return 2; return 2;
} }
if(c.getPlayer().getLevel() < recipe.getReqLevel()) { if (c.getPlayer().getLevel() < recipe.getReqLevel()) {
return 3; return 3;
} }
if(getMakerSkillLevel(c.getPlayer()) < recipe.getReqSkillLevel()) { if (getMakerSkillLevel(c.getPlayer()) < recipe.getReqSkillLevel()) {
return 4; return 4;
} }
@@ -362,36 +367,40 @@ 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)) {
eqp.setUpgradeSlots((byte)(eqp.getUpgradeSlots() + 1)); eqp.setUpgradeSlots((byte) (eqp.getUpgradeSlots() + 1));
} }
item = ItemInformationProvider.getInstance().scrollEquipWithId(eqp, 2049100, true, 2049100, c.getPlayer().isGM()); item = ItemInformationProvider.getInstance().scrollEquipWithId(eqp, 2049100, true, 2049100, c.getPlayer().isGM());
} }
if(!reagentids.isEmpty()) { if (!reagentids.isEmpty()) {
Map<String, Integer> stats = new LinkedHashMap<>(); Map<String, Integer> stats = new LinkedHashMap<>();
List<Short> randOption = new LinkedList<>(); List<Short> randOption = new LinkedList<>();
List<Short> randStat = 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()); Pair<String, Integer> reagentBuff = ii.getMakerReagentStatUpgrade(r.getKey());
if(reagentBuff != null) { if (reagentBuff != null) {
String s = reagentBuff.getLeft(); String s = reagentBuff.getLeft();
if(s.substring(0, 4).contains("rand")) { if (s.substring(0, 4).contains("rand")) {
if(s.substring(4).equals("Stat")) { if (s.substring(4).equals("Stat")) {
randStat.add((short) (reagentBuff.getRight() * r.getValue())); randStat.add((short) (reagentBuff.getRight() * r.getValue()));
} else { } else {
randOption.add((short) (reagentBuff.getRight() * r.getValue())); randOption.add((short) (reagentBuff.getRight() * r.getValue()));
@@ -399,7 +408,7 @@ public class MakerProcessor {
} else { } else {
String stat = s.substring(3); String stat = s.substring(3);
if(!stat.equals("ReqLevel")) { // improve req level... really? if (!stat.equals("ReqLevel")) { // improve req level... really?
switch (stat) { switch (stat) {
case "MaxHP": case "MaxHP":
stat = "MHP"; stat = "MHP";
@@ -411,7 +420,7 @@ public class MakerProcessor {
} }
Integer d = stats.get(stat); Integer d = stats.get(stat);
if(d == null) { if (d == null) {
stats.put(stat, reagentBuff.getRight() * r.getValue()); stats.put(stat, reagentBuff.getRight() * r.getValue());
} else { } else {
stats.put(stat, d + (reagentBuff.getRight() * r.getValue())); stats.put(stat, d + (reagentBuff.getRight() * r.getValue()));
@@ -421,18 +430,18 @@ 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);
} }
for(Short sh : randOption) { for (Short sh : randOption) {
ii.scrollOptionEquipWithChaos(eqp, sh, true); ii.scrollOptionEquipWithChaos(eqp, sh, true);
} }
} }
if(stimulantid != -1) { if (stimulantid != -1) {
eqp = ii.randomizeUpgradeStats(eqp); eqp = ii.randomizeUpgradeStats(eqp);
} }

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;
@@ -54,15 +53,15 @@ public class PetAutopotProcessor {
private double incHp, incMp; private double incHp, incMp;
private boolean cursorOnNextAvailablePot(Character chr) { private boolean cursorOnNextAvailablePot(Character chr) {
if(toUseList == null) { if (toUseList == null) {
toUseList = chr.getInventory(InventoryType.USE).linkedListById(itemId); toUseList = chr.getInventory(InventoryType.USE).linkedListById(itemId);
} }
toUse = null; toUse = null;
while(!toUseList.isEmpty()) { while (!toUseList.isEmpty()) {
Item it = toUseList.remove(0); Item it = toUseList.remove(0);
if(it.getQuantity() > 0) { if (it.getQuantity() > 0) {
toUse = it; toUse = it;
slot = it.getPosition(); slot = it.getPosition();
@@ -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) {
@@ -158,10 +161,10 @@ public class PetAutopotProcessor {
useCount += qtyToUse; useCount += qtyToUse;
qtyCount -= qtyToUse; qtyCount -= qtyToUse;
if(toUse.getQuantity() == 0 && qtyCount > 0) { if (toUse.getQuantity() == 0 && qtyCount > 0) {
// depleted out the current slot, fetch for more // depleted out the current slot, fetch for more
if(!cursorOnNextAvailablePot(chr)) { if (!cursorOnNextAvailablePot(chr)) {
break; // no more pots available break; // no more pots available
} }
} else { } else {

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

@@ -468,7 +468,7 @@ public class DueyProcessor {
c.add(Calendar.DATE, -30); c.add(Calendar.DATE, -30);
final Timestamp ts = new Timestamp(c.getTime().getTime()); final Timestamp ts = new Timestamp(c.getTime().getTime());
try (Connection con = DatabaseConnection.getConnection()){ try (Connection con = DatabaseConnection.getConnection()) {
List<Integer> toRemove = new LinkedList<>(); List<Integer> toRemove = new LinkedList<>();
try (PreparedStatement ps = con.prepareStatement("SELECT `PackageId` FROM dueypackages WHERE `TimeStamp` < ?")) { try (PreparedStatement ps = con.prepareStatement("SELECT `PackageId` FROM dueypackages WHERE `TimeStamp` < ?")) {
ps.setTimestamp(1, ts); ps.setTimestamp(1, ts);

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
*/ */
@@ -50,7 +49,7 @@ public class StorageProcessor {
Storage storage = chr.getStorage(); Storage storage = chr.getStorage();
byte mode = p.readByte(); byte mode = p.readByte();
if (chr.getLevel() < 15){ if (chr.getLevel() < 15) {
chr.dropMessage(1, "You may only use the storage once you have reached level 15."); chr.dropMessage(1, "You may only use the storage once you have reached level 15.");
c.sendPacket(PacketCreator.enableActions()); c.sendPacket(PacketCreator.enableActions());
return; return;
@@ -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,12 +57,15 @@ 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);
if(YamlConfig.config.server.USE_SERVER_AUTOASSIGNER) { if (YamlConfig.config.server.USE_SERVER_AUTOASSIGNER) {
// --------- Ronan Lana's AUTOASSIGNER --------- // --------- Ronan Lana's AUTOASSIGNER ---------
// This method excels for assigning APs in such a way to cover all equipments AP requirements. // This method excels for assigning APs in such a way to cover all equipments AP requirements.
byte opt = inPacket.readByte(); // useful for pirate autoassigning byte opt = inPacket.readByte(); // useful for pirate autoassigning
@@ -74,14 +78,20 @@ public class AssignAPProcessor {
Equip nEquip; Equip nEquip;
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,25 +118,33 @@ 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;
scStat -= temp; scStat -= temp;
prStat += temp; prStat += temp;
@@ -141,18 +159,24 @@ 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;
scStat -= temp; scStat -= temp;
prStat += temp; prStat += temp;
@@ -167,18 +191,24 @@ 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;
scStat -= temp; scStat -= temp;
prStat += temp; prStat += temp;
@@ -193,9 +223,11 @@ public class AssignAPProcessor {
CAP = 160; CAP = 160;
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,16 +235,20 @@ 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;
// thieves will upgrade STR as well only if a level-based threshold is reached. // thieves will upgrade STR as well only if a level-based threshold is reached.
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;
@@ -232,12 +270,12 @@ public class AssignAPProcessor {
str = trStat; str = trStat;
int_ = 0; int_ = 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;
scStat -= temp; scStat -= temp;
prStat += temp; prStat += temp;
} }
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;
trStat -= temp; trStat -= temp;
prStat += temp; prStat += temp;
@@ -265,11 +303,13 @@ public class AssignAPProcessor {
} }
// other classes will start favoring more DEX only if a level-based threshold is reached. // other classes will start favoring more DEX only if a level-based threshold is reached.
if(!highDex) { if (!highDex) {
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,23 +317,29 @@ 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;
} else { } else {
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);
tempAp -= scStat; tempAp -= scStat;
} }
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,9 +348,10 @@ 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;
scStat -= temp; scStat -= temp;
prStat += temp; prStat += temp;
@@ -322,7 +369,7 @@ public class AssignAPProcessor {
extras = gainStatByType(secondary, statGain, scStat + extras, statUpdate); extras = gainStatByType(secondary, statGain, scStat + extras, statUpdate);
extras = gainStatByType(tertiary, statGain, trStat + extras, statUpdate); extras = gainStatByType(tertiary, statGain, trStat + extras, statUpdate);
if(extras > 0) { //redistribute surplus in priority order if (extras > 0) { //redistribute surplus in priority order
extras = gainStatByType(primary, statGain, extras, statUpdate); extras = gainStatByType(primary, statGain, extras, statUpdate);
extras = gainStatByType(secondary, statGain, extras, statUpdate); extras = gainStatByType(secondary, statGain, extras, statUpdate);
extras = gainStatByType(tertiary, statGain, extras, statUpdate); extras = gainStatByType(tertiary, statGain, extras, statUpdate);
@@ -336,7 +383,7 @@ public class AssignAPProcessor {
c.sendPacket(PacketCreator.serverNotice(1, "Better AP applications detected:\r\nSTR: +" + statGain[0] + "\r\nDEX: +" + statGain[1] + "\r\nINT: +" + statGain[3] + "\r\nLUK: +" + statGain[2])); c.sendPacket(PacketCreator.serverNotice(1, "Better AP applications detected:\r\nSTR: +" + statGain[0] + "\r\nDEX: +" + statGain[1] + "\r\nINT: +" + statGain[3] + "\r\nLUK: +" + statGain[2]));
} else { } else {
if(inPacket.available() < 16) { if (inPacket.available() < 16) {
AutobanFactory.PACKET_EDIT.alert(chr, "Didn't send full packet for Auto Assign."); AutobanFactory.PACKET_EDIT.alert(chr, "Didn't send full packet for Auto Assign.");
c.disconnect(true, false); c.disconnect(true, false);
@@ -362,11 +409,13 @@ public class AssignAPProcessor {
} }
private static int getNthHighestStat(List<Short> statList, short rank) { // ranks from 0 private static int getNthHighestStat(List<Short> statList, short rank) { // ranks from 0
return(statList.size() <= rank ? 0 : statList.get(rank)); return (statList.size() <= rank ? 0 : statList.get(rank));
} }
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;
} }
@@ -473,7 +524,7 @@ public class AssignAPProcessor {
} }
break; break;
case 2048: // HP case 2048: // HP
if(YamlConfig.config.server.USE_ENFORCE_HPMP_SWAP) { if (YamlConfig.config.server.USE_ENFORCE_HPMP_SWAP) {
if (APTo != 8192) { if (APTo != 8192) {
player.message("You can only swap HP ability points to MP."); player.message("You can only swap HP ability points to MP.");
c.sendPacket(PacketCreator.enableActions()); c.sendPacket(PacketCreator.enableActions());
@@ -504,7 +555,7 @@ public class AssignAPProcessor {
break; break;
case 8192: // MP case 8192: // MP
if(YamlConfig.config.server.USE_ENFORCE_HPMP_SWAP) { if (YamlConfig.config.server.USE_ENFORCE_HPMP_SWAP) {
if (APTo != 2048) { if (APTo != 2048) {
player.message("You can only swap MP ability points to HP."); player.message("You can only swap MP ability points to HP.");
c.sendPacket(PacketCreator.enableActions()); c.sendPacket(PacketCreator.enableActions());
@@ -623,15 +674,16 @@ public class AssignAPProcessor {
int MaxHP = 0; int MaxHP = 0;
if (job.isA(Job.WARRIOR) || job.isA(Job.DAWNWARRIOR1)) { if (job.isA(Job.WARRIOR) || job.isA(Job.DAWNWARRIOR1)) {
if(!usedAPReset) { if (!usedAPReset) {
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) {
MaxHP += 20; MaxHP += 20;
} else { } else {
@@ -640,8 +692,8 @@ public class AssignAPProcessor {
} else { } else {
MaxHP += 20; MaxHP += 20;
} }
} else if(job.isA(Job.ARAN1)) { } else if (job.isA(Job.ARAN1)) {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) { if (usedAPReset) {
MaxHP += 20; MaxHP += 20;
} else { } else {
@@ -651,7 +703,7 @@ public class AssignAPProcessor {
MaxHP += 28; MaxHP += 28;
} }
} else if (job.isA(Job.MAGICIAN) || job.isA(Job.BLAZEWIZARD1)) { } else if (job.isA(Job.MAGICIAN) || job.isA(Job.BLAZEWIZARD1)) {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) { if (usedAPReset) {
MaxHP += 6; MaxHP += 6;
} else { } else {
@@ -661,7 +713,7 @@ public class AssignAPProcessor {
MaxHP += 6; MaxHP += 6;
} }
} else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) { } else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) { if (usedAPReset) {
MaxHP += 16; MaxHP += 16;
} else { } else {
@@ -670,8 +722,8 @@ public class AssignAPProcessor {
} else { } else {
MaxHP += 16; MaxHP += 16;
} }
} else if(job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) { } else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) { if (usedAPReset) {
MaxHP += 16; MaxHP += 16;
} else { } else {
@@ -681,15 +733,16 @@ public class AssignAPProcessor {
MaxHP += 16; MaxHP += 16;
} }
} else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) { } else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) {
if(!usedAPReset) { if (!usedAPReset) {
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) {
MaxHP += 18; MaxHP += 18;
} else { } else {
@@ -701,7 +754,7 @@ public class AssignAPProcessor {
} else if (usedAPReset) { } else if (usedAPReset) {
MaxHP += 8; MaxHP += 8;
} else { } else {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
MaxHP += Randomizer.rand(8, 12); MaxHP += Randomizer.rand(8, 12);
} else { } else {
MaxHP += 10; MaxHP += 10;
@@ -716,8 +769,8 @@ public class AssignAPProcessor {
int MaxMP = 0; int MaxMP = 0;
if (job.isA(Job.WARRIOR) || job.isA(Job.DAWNWARRIOR1) || job.isA(Job.ARAN1)) { if (job.isA(Job.WARRIOR) || job.isA(Job.DAWNWARRIOR1) || job.isA(Job.ARAN1)) {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if(!usedAPReset) { if (!usedAPReset) {
MaxMP += (Randomizer.rand(2, 4) + (player.getInt() / 10)); MaxMP += (Randomizer.rand(2, 4) + (player.getInt() / 10));
} else { } else {
MaxMP += 2; MaxMP += 2;
@@ -726,16 +779,17 @@ public class AssignAPProcessor {
MaxMP += 3; MaxMP += 3;
} }
} else if (job.isA(Job.MAGICIAN) || job.isA(Job.BLAZEWIZARD1)) { } else if (job.isA(Job.MAGICIAN) || job.isA(Job.BLAZEWIZARD1)) {
if(!usedAPReset) { if (!usedAPReset) {
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) {
MaxMP += (Randomizer.rand(12, 16) + (player.getInt() / 20)); MaxMP += (Randomizer.rand(12, 16) + (player.getInt() / 20));
} else { } else {
MaxMP += 18; MaxMP += 18;
@@ -744,8 +798,8 @@ public class AssignAPProcessor {
MaxMP += 18; MaxMP += 18;
} }
} else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) { } else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if(!usedAPReset) { if (!usedAPReset) {
MaxMP += (Randomizer.rand(6, 8) + (player.getInt() / 10)); MaxMP += (Randomizer.rand(6, 8) + (player.getInt() / 10));
} else { } else {
MaxMP += 10; MaxMP += 10;
@@ -753,9 +807,9 @@ public class AssignAPProcessor {
} else { } else {
MaxMP += 10; MaxMP += 10;
} }
} else if(job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) { } else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if(!usedAPReset) { if (!usedAPReset) {
MaxMP += (Randomizer.rand(6, 8) + (player.getInt() / 10)); MaxMP += (Randomizer.rand(6, 8) + (player.getInt() / 10));
} else { } else {
MaxMP += 10; MaxMP += 10;
@@ -764,8 +818,8 @@ public class AssignAPProcessor {
MaxMP += 10; MaxMP += 10;
} }
} else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) { } else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if(!usedAPReset) { if (!usedAPReset) {
MaxMP += (Randomizer.rand(7, 9) + (player.getInt() / 10)); MaxMP += (Randomizer.rand(7, 9) + (player.getInt() / 10));
} else { } else {
MaxMP += 14; MaxMP += 14;
@@ -774,8 +828,8 @@ public class AssignAPProcessor {
MaxMP += 14; MaxMP += 14;
} }
} else { } else {
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) { if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
if(!usedAPReset) { if (!usedAPReset) {
MaxMP += (Randomizer.rand(4, 6) + (player.getInt() / 10)); MaxMP += (Randomizer.rand(4, 6) + (player.getInt() / 10));
} else { } else {
MaxMP += 6; MaxMP += 6;
@@ -797,7 +851,7 @@ public class AssignAPProcessor {
MaxHP += 10; MaxHP += 10;
} else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) { } else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
MaxHP += 20; MaxHP += 20;
} else if(job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) { } else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
MaxHP += 20; MaxHP += 20;
} else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) { } else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) {
MaxHP += 42; MaxHP += 42;
@@ -817,7 +871,7 @@ public class AssignAPProcessor {
MaxMP += 31; MaxMP += 31;
} else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) { } else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
MaxMP += 12; MaxMP += 12;
} else if(job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) { } else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
MaxMP += 12; MaxMP += 12;
} else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) { } else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) {
MaxMP += 16; MaxMP += 16;

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 {
@@ -65,7 +64,7 @@ public class AssignSPProcessor {
} }
Character player = c.getPlayer(); Character player = c.getPlayer();
int remainingSp = player.getRemainingSps()[GameConstants.getSkillBook(skillid/10000)]; int remainingSp = player.getRemainingSps()[GameConstants.getSkillBook(skillid / 10000)];
boolean isBeginnerSkill = false; boolean isBeginnerSkill = false;
if (skillid % 10000000 > 999 && skillid % 10000000 < 1003) { if (skillid % 10000000 > 999 && skillid % 10000000 < 1003) {
@@ -80,7 +79,7 @@ public class AssignSPProcessor {
int curLevel = player.getSkillLevel(skill); int curLevel = player.getSkillLevel(skill);
if ((remainingSp > 0 && curLevel + 1 <= (skill.isFourthJob() ? player.getMasterLevel(skill) : skill.getMaxLevel()))) { if ((remainingSp > 0 && curLevel + 1 <= (skill.isFourthJob() ? player.getMasterLevel(skill) : skill.getMaxLevel()))) {
if (!isBeginnerSkill) { if (!isBeginnerSkill) {
player.gainSp(-1, GameConstants.getSkillBook(skillid/10000), false); player.gainSp(-1, GameConstants.getSkillBook(skillid / 10000), false);
} else { } else {
player.sendPacket(PacketCreator.enableActions()); player.sendPacket(PacketCreator.enableActions());
} }

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