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

@@ -31,14 +31,14 @@ public class BuyBackCommand extends Command {
{
setDescription("Revive yourself after a death.");
}
@Override
public void execute(Client c, String[] params) {
if (params.length < 1) {
c.getPlayer().yellowMessage("Syntax: @buyback <info|now>");
return;
}
if (params[0].contentEquals("now")) {
BuybackProcessor.processBuyback(c);
} else {

View File

@@ -33,7 +33,7 @@ public class DisposeCommand extends Command {
{
setDescription("Dispose to fix NPC chat.");
}
@Override
public void execute(Client c, String[] params) {
NPCScriptManager.getInstance().dispose(c);

View File

@@ -31,11 +31,11 @@ public class DropLimitCommand extends Command {
{
setDescription("Check drop limit of current map.");
}
@Override
public void execute(Client c, String[] params) {
int dropCount = c.getPlayer().getMap().getDroppedItemCount();
if(((float) dropCount) / YamlConfig.config.server.ITEM_LIMIT_ON_MAP < 0.75f) {
if (((float) dropCount) / YamlConfig.config.server.ITEM_LIMIT_ON_MAP < 0.75f) {
c.getPlayer().showHint("Current drop count: #b" + dropCount + "#k / #e" + YamlConfig.config.server.ITEM_LIMIT_ON_MAP + "#n", 300);
} else {
c.getPlayer().showHint("Current drop count: #r" + dropCount + "#k / #e" + YamlConfig.config.server.ITEM_LIMIT_ON_MAP + "#n", 300);

View File

@@ -38,29 +38,29 @@ public class GachaCommand extends Command {
Gachapon.GachaponType gacha = null;
String search = c.getPlayer().getLastCommandMessage();
String gachaName = "";
String [] names = {"Henesys", "Ellinia", "Perion", "Kerning City", "Sleepywood", "Mushroom Shrine", "Showa Spa Male", "Showa Spa Female", "New Leaf City", "Nautilus Harbor"};
int [] ids = {9100100, 9100101, 9100102, 9100103, 9100104, 9100105, 9100106, 9100107, 9100109, 9100117};
for (int i = 0; i < names.length; i++){
if (search.equalsIgnoreCase(names[i])){
String[] names = {"Henesys", "Ellinia", "Perion", "Kerning City", "Sleepywood", "Mushroom Shrine", "Showa Spa Male", "Showa Spa Female", "New Leaf City", "Nautilus Harbor"};
int[] ids = {9100100, 9100101, 9100102, 9100103, 9100104, 9100105, 9100106, 9100107, 9100109, 9100117};
for (int i = 0; i < names.length; i++) {
if (search.equalsIgnoreCase(names[i])) {
gachaName = names[i];
gacha = Gachapon.GachaponType.getByNpcId(ids[i]);
}
}
if (gacha == null){
if (gacha == null) {
c.getPlayer().yellowMessage("Please use @gacha <name> where name corresponds to one of the below:");
for (String name : names){
for (String name : names) {
c.getPlayer().yellowMessage(name);
}
return;
}
String talkStr = "The #b" + gachaName + "#k Gachapon contains the following items.\r\n\r\n";
for (int i = 0; i < 2; i++){
for (int id : gacha.getItems(i)){
for (int i = 0; i < 2; i++) {
for (int id : gacha.getItems(i)) {
talkStr += "-" + ItemInformationProvider.getInstance().getName(id) + "\r\n";
}
}
talkStr += "\r\nPlease keep in mind that there are items that are in all gachapons and are not listed here.";
c.getAbstractPlayerInteraction().npcTalk(9010000, talkStr);
}
}

View File

@@ -37,15 +37,16 @@ public class JoinEventCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
if(!FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
if (!FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
Event event = c.getChannelServer().getEvent();
if(event != null) {
if(event.getMapId() != player.getMapId()) {
if(event.getLimit() > 0) {
if (event != null) {
if (event.getMapId() != player.getMapId()) {
if (event.getLimit() > 0) {
player.saveLocation("EVENT");
if(event.getMapId() == 109080000 || event.getMapId() == 109060001)
if (event.getMapId() == 109080000 || event.getMapId() == 109060001) {
player.setTeam(event.getLimit() % 2);
}
event.minusLimit();

View File

@@ -36,19 +36,19 @@ public class LeaveEventCommand extends Command {
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
int returnMap = player.getSavedLocation("EVENT");
if(returnMap != -1) {
if(player.getOla() != null) {
if (returnMap != -1) {
if (player.getOla() != null) {
player.getOla().resetTimes();
player.setOla(null);
}
if(player.getFitness() != null) {
if (player.getFitness() != null) {
player.getFitness().resetTimes();
player.setFitness(null);
}
player.saveLocationOnWarp();
player.changeMap(returnMap);
if(c.getChannelServer().getEvent() != null) {
if (c.getChannelServer().getEvent() != null) {
c.getChannelServer().getEvent().addLimit();
}
} else {

View File

@@ -39,7 +39,7 @@ public class MapOwnerClaimCommand extends Command {
if (c.tryacquireClient()) {
try {
Character chr = c.getPlayer();
if (YamlConfig.config.server.USE_MAP_OWNERSHIP_SYSTEM) {
if (chr.getEventInstance() == null) {
MapleMap map = chr.getMap();

View File

@@ -40,7 +40,7 @@ public class RanksCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
List<Pair<String, Integer>> worldRanking = Server.getInstance().getWorldPlayerRanking(player.getWorld());
player.sendPacket(GuildPackets.showPlayerRanks(9010000, worldRanking));
}

View File

@@ -36,14 +36,16 @@ public class RatesCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
// travel rates not applicable since it's intrinsically a server/environment rate rather than a character rate
String showMsg_ = "#eCHARACTER RATES#n" + "\r\n\r\n";
showMsg_ += "EXP Rate: #e#b" + player.getExpRate() + "x#k#n" + (player.hasNoviceExpRate() ? " - novice rate" : "") + "\r\n";
showMsg_ += "MESO Rate: #e#b" + player.getMesoRate() + "x#k#n" + "\r\n";
showMsg_ += "DROP Rate: #e#b" + player.getDropRate() + "x#k#n" + "\r\n";
showMsg_ += "BOSS DROP Rate: #e#b" + player.getBossDropRate() + "x#k#n" + "\r\n";
if(YamlConfig.config.server.USE_QUEST_RATE) showMsg_ += "QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n";
if (YamlConfig.config.server.USE_QUEST_RATE) {
showMsg_ += "QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n";
}
player.showHint(showMsg_, 300);
}

View File

@@ -39,32 +39,40 @@ public class ShowRatesCommand extends Command {
String showMsg = "#eEXP RATE#n" + "\r\n";
showMsg += "World EXP Rate: #k" + c.getWorldServer().getExpRate() + "x#k" + "\r\n";
showMsg += "Player EXP Rate: #k" + player.getRawExpRate() + "x#k" + "\r\n";
if(player.getCouponExpRate() != 1) showMsg += "Coupon EXP Rate: #k" + player.getCouponExpRate() + "x#k" + "\r\n";
if (player.getCouponExpRate() != 1) {
showMsg += "Coupon EXP Rate: #k" + player.getCouponExpRate() + "x#k" + "\r\n";
}
showMsg += "EXP Rate: #e#b" + player.getExpRate() + "x#k#n" + (player.hasNoviceExpRate() ? " - novice rate" : "") + "\r\n";
showMsg += "\r\n" + "#eMESO RATE#n" + "\r\n";
showMsg += "World MESO Rate: #k" + c.getWorldServer().getMesoRate() + "x#k" + "\r\n";
showMsg += "Player MESO Rate: #k" + player.getRawMesoRate() + "x#k" + "\r\n";
if(player.getCouponMesoRate() != 1) showMsg += "Coupon MESO Rate: #k" + player.getCouponMesoRate() + "x#k" + "\r\n";
if (player.getCouponMesoRate() != 1) {
showMsg += "Coupon MESO Rate: #k" + player.getCouponMesoRate() + "x#k" + "\r\n";
}
showMsg += "MESO Rate: #e#b" + player.getMesoRate() + "x#k#n" + "\r\n";
showMsg += "\r\n" + "#eDROP RATE#n" + "\r\n";
showMsg += "World DROP Rate: #k" + c.getWorldServer().getDropRate() + "x#k" + "\r\n";
showMsg += "Player DROP Rate: #k" + player.getRawDropRate() + "x#k" + "\r\n";
if(player.getCouponDropRate() != 1) showMsg += "Coupon DROP Rate: #k" + player.getCouponDropRate() + "x#k" + "\r\n";
if (player.getCouponDropRate() != 1) {
showMsg += "Coupon DROP Rate: #k" + player.getCouponDropRate() + "x#k" + "\r\n";
}
showMsg += "DROP Rate: #e#b" + player.getDropRate() + "x#k#n" + "\r\n";
showMsg += "\r\n" + "#eBOSS DROP RATE#n" + "\r\n";
showMsg += "World BOSS DROP Rate: #k" + c.getWorldServer().getBossDropRate() + "x#k" + "\r\n";
showMsg += "Player DROP Rate: #k" + player.getRawDropRate() + "x#k" + "\r\n";
if(player.getCouponDropRate() != 1) showMsg += "Coupon DROP Rate: #k" + player.getCouponDropRate() + "x#k" + "\r\n";
if (player.getCouponDropRate() != 1) {
showMsg += "Coupon DROP Rate: #k" + player.getCouponDropRate() + "x#k" + "\r\n";
}
showMsg += "BOSS DROP Rate: #e#b" + player.getBossDropRate() + "x#k#n" + "\r\n";
if(YamlConfig.config.server.USE_QUEST_RATE) {
if (YamlConfig.config.server.USE_QUEST_RATE) {
showMsg += "\r\n" + "#eQUEST RATE#n" + "\r\n";
showMsg += "World QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n";
}
showMsg += "\r\n";
showMsg += "World TRAVEL Rate: #e#b" + c.getWorldServer().getTravelRate() + "x#k#n" + "\r\n";

View File

@@ -48,7 +48,7 @@ public class StatStrCommand extends Command {
} else {
amount = Math.min(remainingAp, YamlConfig.config.server.MAX_AP - player.getStr());
}
if (!player.assignStr(Math.max(amount, 0))) {
player.dropMessage("Please make sure your AP is not over " + YamlConfig.config.server.MAX_AP + " and you have enough to distribute.");
}

View File

@@ -35,7 +35,7 @@ public class TimeCommand extends Command {
{
setDescription("Show current server time.");
}
@Override
public void execute(Client client, String[] params) {
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

View File

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

View File

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

View File

@@ -36,16 +36,16 @@ import java.util.Map;
import java.util.Map.Entry;
public class GotoCommand extends Command {
{
setDescription("Warp to a predefined map.");
List<Entry<String, Integer>> towns = new ArrayList<>(GameConstants.GOTO_TOWNS.entrySet());
sortGotoEntries(towns);
try {
// thanks shavit for noticing goto areas getting loaded from wz needlessly only for the name retrieval
for (Map.Entry<String, Integer> e : towns) {
GOTO_TOWNS_INFO += ("'" + e.getKey() + "' - #b" + (MapFactory.loadPlaceName(e.getValue())) + "#k\r\n");
}
@@ -57,16 +57,16 @@ public class GotoCommand extends Command {
}
} catch (Exception e) {
e.printStackTrace();
GOTO_TOWNS_INFO = "(none)";
GOTO_AREAS_INFO = "(none)";
}
}
public static String GOTO_TOWNS_INFO = "";
public static String GOTO_AREAS_INFO = "";
private static void sortGotoEntries(List<Entry<String, Integer>> listEntries) {
listEntries.sort((e1, e2) -> e1.getValue().compareTo(e2.getValue()));
}
@@ -74,16 +74,16 @@ public class GotoCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
if (params.length < 1){
if (params.length < 1) {
String sendStr = "Syntax: #b@goto <map name>#k. Available areas:\r\n\r\n#rTowns:#k\r\n" + GOTO_TOWNS_INFO;
if (player.isGM()) {
sendStr += ("\r\n#rAreas:#k\r\n" + GOTO_AREAS_INFO);
}
player.getAbstractPlayerInteraction().npcTalk(9000020, sendStr);
return;
}
if (!player.isAlive()) {
player.dropMessage(1, "This command cannot be used when you're dead.");
return;
@@ -103,10 +103,10 @@ public class GotoCommand extends Command {
} else {
gotomaps = GameConstants.GOTO_TOWNS;
}
if (gotomaps.containsKey(params[0])) {
MapleMap target = c.getChannelServer().getMapFactory().getMap(gotomaps.get(params[0]));
// expedition issue with this command detected thanks to Masterrulax
Portal targetPortal = target.getRandomPlayerSpawnpoint();
player.saveLocationOnWarp();
@@ -117,7 +117,7 @@ public class GotoCommand extends Command {
if (player.isGM()) {
sendStr += ("\r\n#rAreas:#k\r\n" + GOTO_AREAS_INFO);
}
player.getAbstractPlayerInteraction().npcTalk(9000020, sendStr);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -36,7 +36,7 @@ public class ClearSavedLocationsCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer(), victim;
if (params.length > 0) {
victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
if (victim == null) {
@@ -46,11 +46,11 @@ public class ClearSavedLocationsCommand extends Command {
} else {
victim = c.getPlayer();
}
for (SavedLocationType type : SavedLocationType.values()) {
victim.clearSavedLocation(type);
}
player.message("Cleared " + params[0] + "'s saved locations.");
}
}

View File

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

View File

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

View File

@@ -47,7 +47,7 @@ public class IdCommand extends Command {
if (resultList.size() > 0) {
int count = 0;
for (Map.Entry<String, String> entry: resultList.entrySet()) {
for (Map.Entry<String, String> entry : resultList.entrySet()) {
sb.append(String.format("Id for %s is: #b%s#k", entry.getKey(), entry.getValue()) + "\r\n");
if (++count > 100) {
break;
@@ -65,7 +65,7 @@ public class IdCommand extends Command {
player.yellowMessage("Error reading file, please contact your administrator.");
}
};
ThreadManager.getInstance().newTask(queryRunnable);
}
@@ -85,16 +85,20 @@ public class IdCommand extends Command {
}
private String joinStringArr(String[] arr, String separator) {
if (null == arr || 0 == arr.length) return "";
if (null == arr || 0 == arr.length) {
return "";
}
StringBuilder sb = new StringBuilder(256);
sb.append(arr[0]);
for (int i = 1; i < arr.length; i++) sb.append(separator).append(arr[i]);
for (int i = 1; i < arr.length; i++) {
sb.append(separator).append(arr[i]);
}
return sb.toString();
}
private Map<String, String> fetchResults(Map<String, String> queryMap, String queryItem) {
Map<String, String> results = new HashMap<>();
for (String item: queryMap.keySet()) {
for (String item : queryMap.keySet()) {
if (item.indexOf(queryItem) != -1) {
results.put(item, queryMap.get(item));
}

View File

@@ -40,7 +40,7 @@ public class ItemCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
if (params.length < 1) {
player.yellowMessage("Syntax: !item <itemid> <quantity>");
return;
@@ -49,13 +49,15 @@ public class ItemCommand extends Command {
int itemId = Integer.parseInt(params[0]);
ItemInformationProvider ii = ItemInformationProvider.getInstance();
if(ii.getName(itemId) == null) {
if (ii.getName(itemId) == null) {
player.yellowMessage("Item id '" + params[0] + "' does not exist.");
return;
}
short quantity = 1;
if(params.length >= 2) quantity = Short.parseShort(params[1]);
if (params.length >= 2) {
quantity = Short.parseShort(params[1]);
}
if (YamlConfig.config.server.BLOCK_GENERATE_CASH_ITEM && ii.isCash(itemId)) {
player.yellowMessage("You cannot create a cash item with this command.");
@@ -63,26 +65,26 @@ public class ItemCommand extends Command {
}
if (ItemConstants.isPet(itemId)) {
if (params.length >= 2){ // thanks to istreety & TacoBell
quantity = 1;
long days = Math.max(1, Integer.parseInt(params[1]));
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
int petid = Pet.createPet(itemId);
if (params.length >= 2) { // thanks to istreety & TacoBell
quantity = 1;
long days = Math.max(1, Integer.parseInt(params[1]));
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
int petid = Pet.createPet(itemId);
InventoryManipulator.addById(c, itemId, quantity, player.getName(), petid, expiration);
return;
} else {
player.yellowMessage("Pet Syntax: !item <itemid> <expiration>");
return;
}
InventoryManipulator.addById(c, itemId, quantity, player.getName(), petid, expiration);
return;
} else {
player.yellowMessage("Pet Syntax: !item <itemid> <expiration>");
return;
}
}
short flag = 0;
if(player.gmLevel() < 3) {
flag |= ItemConstants.ACCOUNT_SHARING;
flag |= ItemConstants.UNTRADEABLE;
if (player.gmLevel() < 3) {
flag |= ItemConstants.ACCOUNT_SHARING;
flag |= ItemConstants.UNTRADEABLE;
}
InventoryManipulator.addById(c, itemId, quantity, player.getName(), -1, flag, -1);
}
}

View File

@@ -41,7 +41,7 @@ public class ItemDropCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
if (params.length < 1) {
player.yellowMessage("Syntax: !drop <itemid> <quantity>");
return;
@@ -50,13 +50,15 @@ public class ItemDropCommand extends Command {
int itemId = Integer.parseInt(params[0]);
ItemInformationProvider ii = ItemInformationProvider.getInstance();
if(ii.getName(itemId) == null) {
if (ii.getName(itemId) == null) {
player.yellowMessage("Item id '" + params[0] + "' does not exist.");
return;
}
short quantity = 1;
if(params.length >= 2) quantity = Short.parseShort(params[1]);
if (params.length >= 2) {
quantity = Short.parseShort(params[1]);
}
if (YamlConfig.config.server.BLOCK_GENERATE_CASH_ITEM && ii.isCash(itemId)) {
player.yellowMessage("You cannot create a cash item with this command.");
@@ -64,7 +66,7 @@ public class ItemDropCommand extends Command {
}
if (ItemConstants.isPet(itemId)) {
if (params.length >= 2){ // thanks to istreety & TacoBell
if (params.length >= 2) { // thanks to istreety & TacoBell
quantity = 1;
long days = Math.max(1, Integer.parseInt(params[1]));
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
@@ -74,12 +76,12 @@ public class ItemDropCommand extends Command {
toDrop.setExpiration(expiration);
toDrop.setOwner("");
if(player.gmLevel() < 3) {
if (player.gmLevel() < 3) {
short f = toDrop.getFlag();
f |= ItemConstants.ACCOUNT_SHARING;
f |= ItemConstants.UNTRADEABLE;
f |= ItemConstants.SANDBOX;
toDrop.setFlag(f);
toDrop.setOwner("TRIAL-MODE");
}
@@ -89,10 +91,10 @@ public class ItemDropCommand extends Command {
return;
} else {
player.yellowMessage("Pet Syntax: !drop <itemid> <expiration>");
return;
return;
}
}
Item toDrop;
if (ItemConstants.getInventoryType(itemId) == InventoryType.EQUIP) {
toDrop = ii.getEquipById(itemId);
@@ -101,7 +103,7 @@ public class ItemDropCommand extends Command {
}
toDrop.setOwner(player.getName());
if(player.gmLevel() < 3) {
if (player.gmLevel() < 3) {
short f = toDrop.getFlag();
f |= ItemConstants.ACCOUNT_SHARING;
f |= ItemConstants.UNTRADEABLE;

View File

@@ -45,7 +45,9 @@ public class LevelCommand extends Command {
player.setLevel(Math.min(Integer.parseInt(params[0]), player.getMaxClassLevel()) - 1);
player.resetPlayerRates();
if (YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL) player.setPlayerRates();
if (YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL) {
player.setPlayerRates();
}
player.setWorldRates();
player.levelUp(false);

View File

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

View File

@@ -40,7 +40,9 @@ public class MaxStatCommand extends Command {
player.loseExp(player.getExp(), false, false);
player.setLevel(255);
player.resetPlayerRates();
if (YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL) player.setPlayerRates();
if (YamlConfig.config.server.USE_ADD_RATES_BY_LEVEL) {
player.setPlayerRates();
}
player.setWorldRates();
player.updateStrDexIntLuk(Short.MAX_VALUE);
player.setFame(13337);

View File

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

View File

@@ -40,10 +40,10 @@ public class SearchCommand extends Command {
private static Data mobStringData;
private static Data skillStringData;
private static Data mapStringData;
{
setDescription("Search String.wz.");
DataProvider dataProvider = DataProviderFactory.getDataProvider(WZFiles.STRING);
npcStringData = dataProvider.getData("Npc.img");
mobStringData = dataProvider.getData("Mob.img");
@@ -60,12 +60,12 @@ public class SearchCommand extends Command {
}
StringBuilder sb = new StringBuilder();
String search = joinStringFrom(params,1);
String search = joinStringFrom(params, 1);
long start = System.currentTimeMillis();//for the lulz
Data data = null;
if (!params[0].equalsIgnoreCase("ITEM")) {
int searchType = 0;
if (params[0].equalsIgnoreCase("NPC")) {
data = npcStringData;
} else if (params[0].equalsIgnoreCase("MOB") || params[0].equalsIgnoreCase("MONSTER")) {
@@ -83,7 +83,7 @@ public class SearchCommand extends Command {
}
if (data != null) {
String name;
if (searchType == 0) {
for (Data searchData : data.getChildren()) {
name = DataTool.getString(searchData.getChildByPath("name"), "NO-NAME");
@@ -93,12 +93,12 @@ public class SearchCommand extends Command {
}
} else if (searchType == 1) {
String mapName, streetName;
for (Data searchDataDir : data.getChildren()) {
for (Data searchData : searchDataDir.getChildren()) {
mapName = DataTool.getString(searchData.getChildByPath("mapName"), "NO-NAME");
streetName = DataTool.getString(searchData.getChildByPath("streetName"), "NO-NAME");
if (mapName.toLowerCase().contains(search.toLowerCase()) || streetName.toLowerCase().contains(search.toLowerCase())) {
sb.append("#b").append(Integer.parseInt(searchData.getName())).append("#k - #r").append(streetName).append(" - ").append(mapName).append("\r\n");
}
@@ -107,7 +107,7 @@ public class SearchCommand extends Command {
} else {
for (Quest mq : Quest.getMatchedQuests(search)) {
sb.append("#b").append(mq.getId()).append("#k - #r");
String parentName = mq.getParentName();
if (!parentName.isEmpty()) {
sb.append(parentName).append(" - ");

View File

@@ -39,17 +39,17 @@ public class SetSlotCommand extends Command {
player.yellowMessage("Syntax: !setslot <newlevel>");
return;
}
int slots = (Integer.parseInt(params[0]) / 4) * 4;
for (int i = 1; i < 5; i++) {
int curSlots = player.getSlots(i);
if (slots <= -curSlots) {
continue;
}
player.gainSlots(i, slots - curSlots, true);
}
player.yellowMessage("Slots updated.");
}
}

View File

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

View File

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

View File

@@ -46,7 +46,7 @@ public class SummonCommand extends Command {
Character victim = c.getChannelServer().getPlayerStorage().getCharacterByName(params[0]);
if (victim == null) {
//If victim isn't on current channel, loop all channels on current world.
for (Channel ch : Server.getInstance().getChannelsFromWorld(c.getWorld())) {
victim = ch.getPlayerStorage().getCharacterByName(params[0]);
if (victim != null) {
@@ -59,19 +59,22 @@ public class SummonCommand extends Command {
player.dropMessage(6, "Player currently not logged in or unreachable.");
return;
}
if (player.getClient().getChannel() != victim.getClient().getChannel()) {//And then change channel if needed.
victim.dropMessage("Changing channel, please wait a moment.");
victim.getClient().changeChannel(player.getClient().getChannel());
}
try {
for (int i = 0; i < 7; i++) { // poll for a while until the player reconnects
if (victim.isLoggedinWorld()) break;
if (victim.isLoggedinWorld()) {
break;
}
Thread.sleep(1777);
}
} catch (InterruptedException e) {}
} catch (InterruptedException e) {
}
MapleMap map = player.getMap();
victim.saveLocationOnWarp();
victim.forceChangeMap(map, map.findClosestPortal(player.getPosition()));

View File

@@ -54,7 +54,7 @@ public class WarpAreaCommand extends Command {
Point pos = player.getPosition();
Collection<Character> characters = player.getMap().getAllPlayers();
for (Character victim : characters) {
if (victim.getPosition().distanceSq(pos) <= 50000) {
victim.saveLocationOnWarp();

View File

@@ -49,19 +49,19 @@ public class WarpCommand extends Command {
player.yellowMessage("Map ID " + params[0] + " is invalid.");
return;
}
if (!player.isAlive()) {
player.dropMessage(1, "This command cannot be used when you're dead.");
return;
}
if (!player.isGM()) {
if (player.getEventInstance() != null || MiniDungeonInfo.isDungeonMap(player.getMapId()) || FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
player.dropMessage(1, "This command cannot be used in this map.");
return;
}
}
// expedition issue with this command detected thanks to Masterrulax
player.saveLocationOnWarp();
player.changeMap(target, target.getRandomPlayerSpawnpoint());

View File

@@ -51,7 +51,7 @@ public class WarpMapCommand extends Command {
}
Collection<Character> characters = player.getMap().getAllPlayers();
for (Character victim : characters) {
victim.saveLocationOnWarp();
victim.changeMap(target, target.getRandomPlayerSpawnpoint());

View File

@@ -41,12 +41,12 @@ public class WhereaMiCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
HashSet<Character> chars = new HashSet<>();
HashSet<NPC> npcs = new HashSet<>();
HashSet<PlayerNPC> playernpcs = new HashSet<>();
HashSet<Monster> mobs = new HashSet<>();
for (MapObject mmo : player.getMap().getMapObjects()) {
if (mmo instanceof NPC) {
NPC npc = (NPC) mmo;
@@ -64,28 +64,28 @@ public class WhereaMiCommand extends Command {
playernpcs.add(npc);
}
}
player.yellowMessage("Map ID: " + player.getMap().getId());
player.yellowMessage("Players on this map:");
for (Character chr : chars) {
player.dropMessage(5, ">> " + chr.getName() + " - " + chr.getId() + " - Oid: " + chr.getObjectId());
}
if (!playernpcs.isEmpty()) {
player.yellowMessage("PlayerNPCs on this map:");
for (PlayerNPC pnpc : playernpcs) {
player.dropMessage(5, ">> " + pnpc.getName() + " - Scriptid: " + pnpc.getScriptId() + " - Oid: " + pnpc.getObjectId());
}
}
if (!npcs.isEmpty()) {
player.yellowMessage("NPCs on this map:");
for (NPC npc : npcs) {
player.dropMessage(5, ">> " + npc.getName() + " - " + npc.getId() + " - Oid: " + npc.getObjectId());
}
}
if (!mobs.isEmpty()) {
player.yellowMessage("Monsters on this map:");
for (Monster mob : mobs) {

View File

@@ -42,8 +42,12 @@ public class CheckDmgCommand extends Command {
Integer watkBuff = victim.getBuffedValue(BuffStat.WATK);
Integer matkBuff = victim.getBuffedValue(BuffStat.MATK);
int blessing = victim.getSkillLevel(10000000 * player.getJobType() + 12);
if (watkBuff == null) watkBuff = 0;
if (matkBuff == null) matkBuff = 0;
if (watkBuff == null) {
watkBuff = 0;
}
if (matkBuff == null) {
matkBuff = 0;
}
player.dropMessage(5, "Cur Str: " + victim.getTotalStr() + " Cur Dex: " + victim.getTotalDex() + " Cur Int: " + victim.getTotalInt() + " Cur Luk: " + victim.getTotalLuk());
player.dropMessage(5, "Cur WATK: " + victim.getTotalWatk() + " Cur MATK: " + victim.getTotalMagic());

View File

@@ -46,12 +46,16 @@ public class FlyCommand extends Command {
String sendStr = "";
if (params[0].equalsIgnoreCase("on")) {
sendStr += "Enabled Fly feature (F1). With fly active, you cannot attack.";
if (!srv.canFly(accid)) sendStr += " Re-login to take effect.";
if (!srv.canFly(accid)) {
sendStr += " Re-login to take effect.";
}
srv.changeFly(c.getAccID(), true);
} else {
sendStr += "Disabled Fly feature. You can now attack.";
if (srv.canFly(accid)) sendStr += " Re-login to take effect.";
if (srv.canFly(accid)) {
sendStr += " Re-login to take effect.";
}
srv.changeFly(c.getAccID(), false);
}

View File

@@ -42,7 +42,7 @@ public class GiveMesosCommand extends Command {
String recv_, value_;
long mesos_ = 0;
if (params.length == 2) {
recv_ = params[0];
value_ = params[1];
@@ -50,7 +50,7 @@ public class GiveMesosCommand extends Command {
recv_ = c.getPlayer().getName();
value_ = params[0];
}
try {
mesos_ = Long.parseLong(value_);
if (mesos_ > Integer.MAX_VALUE) {
@@ -65,7 +65,7 @@ public class GiveMesosCommand extends Command {
mesos_ = Integer.MIN_VALUE;
}
}
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(recv_);
if (victim != null) {
victim.gainMeso((int) mesos_, true);

View File

@@ -55,7 +55,7 @@ public class GiveNxCommand extends Command {
type = 1;
}
typeStr = params[0];
if (params.length > 2) {
recv = params[1];
value = Integer.parseInt(params[2]);

View File

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

View File

@@ -36,7 +36,7 @@ public class MaxHpMpCommand extends Command {
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
Character victim = player;
int statUpdate = 1;
if (params.length >= 2) {
victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
@@ -46,7 +46,7 @@ public class MaxHpMpCommand extends Command {
} else {
player.yellowMessage("Syntax: !maxhpmp [<playername>] <value>");
}
if (victim != null) {
int extraHp = victim.getCurrentMaxHp() - victim.getClientMaxHp();
int extraMp = victim.getCurrentMaxMp() - victim.getClientMaxMp();

View File

@@ -39,24 +39,24 @@ public class MusicCommand extends Command {
for (String s : GameConstants.GAME_SONGS) {
songList += (" " + s + "\r\n");
}
return songList;
}
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
if (params.length < 1) {
String sendMsg = "";
sendMsg += "Syntax: #r!music <song>#k\r\n\r\n";
sendMsg += getSongList();
c.sendPacket(PacketCreator.getNPCTalk(1052015, (byte) 0, sendMsg, "00 00", (byte) 0));
return;
}
String song = player.getLastCommandMessage();
for (String s : GameConstants.GAME_SONGS) {
if (s.equalsIgnoreCase(song)) { // thanks Masterrulax for finding an issue here
@@ -65,11 +65,11 @@ public class MusicCommand extends Command {
return;
}
}
String sendMsg = "";
sendMsg += "Song not found, please enter a song below.\r\n\r\n";
sendMsg += getSongList();
c.sendPacket(PacketCreator.getNPCTalk(1052015, (byte) 0, sendMsg, "00 00", (byte) 0));
}
}

View File

@@ -36,8 +36,8 @@ public class QuestCompleteCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
if (params.length < 1){
if (params.length < 1) {
player.yellowMessage("Syntax: !completequest <questid>");
return;
}
@@ -51,7 +51,7 @@ public class QuestCompleteCommand extends Command {
} else {
c.getAbstractPlayerInteraction().forceCompleteQuest(questId);
}
player.dropMessage(5, "QUEST " + questId + " completed.");
} else {
player.dropMessage(5, "QUESTID " + questId + " not started or already completed.");

View File

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

View File

@@ -36,8 +36,8 @@ public class QuestStartCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
if (params.length < 1){
if (params.length < 1) {
player.yellowMessage("Syntax: !startquest <questid>");
return;
}
@@ -51,7 +51,7 @@ public class QuestStartCommand extends Command {
} else {
c.getAbstractPlayerInteraction().forceStartQuest(questid);
}
player.dropMessage(5, "QUEST " + questid + " started.");
} else {
player.dropMessage(5, "QUESTID " + questid + " already started/completed.");

View File

@@ -42,12 +42,13 @@ public class ReloadMapCommand extends Command {
int callerid = c.getPlayer().getId();
Collection<Character> characters = player.getMap().getAllPlayers();
for (Character chr : characters) {
chr.saveLocationOnWarp();
chr.changeMap(newMap);
if (chr.getId() != callerid)
if (chr.getId() != callerid) {
chr.dropMessage("You have been relocated due to map reloading. Sorry for the inconvenience.");
}
}
newMap.respawn();
}

View File

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

View File

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

View File

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

View File

@@ -36,7 +36,7 @@ public class PapCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
// thanks Conrad for noticing mobid typo here
player.getMap().spawnMonsterOnGroundBelow(LifeFactory.getMonster(8500001), player.getPosition());
}

View File

@@ -47,14 +47,14 @@ public class PnpcRemoveCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
int mapId = player.getMapId();
int npcId = params.length > 0 ? Integer.parseInt(params[0]) : -1;
Point pos = player.getPosition();
int xpos = pos.x;
int ypos = pos.y;
List<Pair<Integer, Pair<Integer, Integer>>> toRemove = new LinkedList<>();
try (Connection con = DatabaseConnection.getConnection()) {
final PreparedStatement ps;
@@ -76,7 +76,7 @@ public class PnpcRemoveCommand extends Command {
ps.setInt(6, ypos - 50);
ps.setInt(7, ypos + 50);
}
try (ResultSet rs = ps.executeQuery()) {
while (true) {
rs.beforeFirst();
@@ -94,9 +94,9 @@ public class PnpcRemoveCommand extends Command {
e.printStackTrace();
player.dropMessage(5, "Failed to remove pNPC from the database.");
}
if (!toRemove.isEmpty()) {
for (Channel ch: player.getWorldServer().getChannels()) {
for (Channel ch : player.getWorldServer().getChannels()) {
MapleMap map = ch.getMapFactory().getMap(mapId);
for (Pair<Integer, Pair<Integer, Integer>> r : toRemove) {
@@ -104,7 +104,7 @@ public class PnpcRemoveCommand extends Command {
}
}
}
player.yellowMessage("Cleared " + toRemove.size() + " pNPC placements.");
}
}

View File

@@ -45,18 +45,18 @@ public class ProItemCommand extends Command {
player.yellowMessage("Syntax: !proitem <itemid> <stat value> [<spdjmp value>]");
return;
}
ItemInformationProvider ii = ItemInformationProvider.getInstance();
int itemid = Integer.parseInt(params[0]);
if(ii.getName(itemid) == null) {
if (ii.getName(itemid) == null) {
player.yellowMessage("Item id '" + params[0] + "' does not exist.");
return;
}
short stat = (short) Math.max(0, Short.parseShort(params[1]));
short spdjmp = params.length >= 3 ? (short) Math.max(0, Short.parseShort(params[2])) : 0;
InventoryType type = ItemConstants.getInventoryType(itemid);
if (type.equals(InventoryType.EQUIP)) {
Item it = ii.getEquipById(itemid);
@@ -68,6 +68,7 @@ public class ProItemCommand extends Command {
player.dropMessage(6, "Make sure it's an equippable item.");
}
}
private static void hardsetItemStats(Equip equip, short stat, short spdjmp) {
equip.setStr(stat);
equip.setDex(stat);

View File

@@ -47,11 +47,13 @@ public class SetEqStatCommand extends Command {
short newStat = (short) Math.max(0, Integer.parseInt(params[0]));
short newSpdJmp = params.length >= 2 ? (short) Integer.parseInt(params[1]) : 0;
Inventory equip = player.getInventory(InventoryType.EQUIP);
for (byte i = 1; i <= equip.getSlotLimit(); i++) {
try {
Equip eq = (Equip) equip.getItem(i);
if (eq == null) continue;
if (eq == null) {
continue;
}
eq.setWdef(newStat);
eq.setAcc(newStat);

View File

@@ -41,7 +41,7 @@ import java.util.List;
public class DebugCommand extends Command {
private final static String[] debugTypes = {"monster", "packet", "portal", "spawnpoint", "pos", "map", "mobsp", "event", "areas", "reactors", "servercoupons", "playercoupons", "timer", "marriage", "buff", ""};
{
setDescription("Show a debug message.");
}
@@ -59,13 +59,13 @@ public class DebugCommand extends Command {
case "type":
case "help":
String msgTypes = "Available #bdebug types#k:\r\n\r\n";
for(int i = 0; i < debugTypes.length; i++) {
for (int i = 0; i < debugTypes.length; i++) {
msgTypes += ("#L" + i + "#" + debugTypes[i] + "#l\r\n");
}
c.getAbstractPlayerInteraction().npcTalk(9201143, msgTypes);
break;
case "monster":
List<MapObject> monsters = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapObjectType.MONSTER));
for (MapObject monstermo : monsters) {
@@ -81,16 +81,20 @@ public class DebugCommand extends Command {
case "portal":
Portal portal = player.getMap().findClosestPortal(player.getPosition());
if (portal != null)
if (portal != null) {
player.dropMessage(6, "Closest portal: " + portal.getId() + " '" + portal.getName() + "' Type: " + portal.getType() + " --> toMap: " + portal.getTargetMapId() + " scriptname: '" + portal.getScriptName() + "' state: " + (portal.getPortalState() ? 1 : 0) + ".");
else player.dropMessage(6, "There is no portal on this map.");
} else {
player.dropMessage(6, "There is no portal on this map.");
}
break;
case "spawnpoint":
SpawnPoint sp = player.getMap().findClosestSpawnpoint(player.getPosition());
if (sp != null)
if (sp != null) {
player.dropMessage(6, "Closest mob spawn point: " + " Position: x " + sp.getPosition().getX() + " y " + sp.getPosition().getY() + " Spawns mobid: '" + sp.getMonsterId() + "' --> canSpawn: " + !sp.getDenySpawn() + " canSpawnRightNow: " + sp.shouldSpawn() + ".");
else player.dropMessage(6, "There is no mob spawn point on this map.");
} else {
player.dropMessage(6, "There is no mob spawn point on this map.");
}
break;
case "pos":
@@ -106,8 +110,11 @@ public class DebugCommand extends Command {
break;
case "event":
if (player.getEventInstance() == null) player.dropMessage(6, "Player currently not in an event.");
else player.dropMessage(6, "Current event name: " + player.getEventInstance().getName() + ".");
if (player.getEventInstance() == null) {
player.dropMessage(6, "Player currently not in an event.");
} else {
player.dropMessage(6, "Current event name: " + player.getEventInstance().getName() + ".");
}
break;
case "areas":
@@ -156,7 +163,7 @@ public class DebugCommand extends Command {
case "marriage":
c.getChannelServer().debugMarriageStatus();
break;
case "buff":
c.getPlayer().debugListAllBuffs();
break;

View File

@@ -29,7 +29,6 @@ import net.server.world.World;
import java.util.Collection;
/**
*
* @author Mist
* @author Blood (Tochi)
* @author Ronan
@@ -42,20 +41,20 @@ public class IpListCommand extends Command {
@Override
public void execute(Client c, String[] params) {
String str = "Player-IP relation:";
for (World w : Server.getInstance().getWorlds()) {
Collection<Character> chars = w.getPlayerStorage().getAllCharacters();
if (!chars.isEmpty()) {
str += "\r\n" + GameConstants.WORLD_NAMES[w.getId()] + "\r\n";
for (Character chr : chars) {
str += " " + chr.getName() + " - " + chr.getClient().getRemoteAddress() + "\r\n";
}
}
}
c.getAbstractPlayerInteraction().npcTalk(22000, str);
}
}

View File

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

View File

@@ -37,7 +37,7 @@ public class ServerAddChannelCommand extends Command {
@Override
public void execute(Client c, String[] params) {
final Character player = c.getPlayer();
if (params.length < 1) {
player.dropMessage(5, "Syntax: @addchannel <worldid>");
return;
@@ -47,15 +47,15 @@ public class ServerAddChannelCommand extends Command {
ThreadManager.getInstance().newTask(() -> {
int chid = Server.getInstance().addChannel(worldid);
if(player.isLoggedinWorld()) {
if(chid >= 0) {
if (player.isLoggedinWorld()) {
if (chid >= 0) {
player.dropMessage(5, "NEW Channel " + chid + " successfully deployed on world " + worldid + ".");
} else {
if(chid == -3) {
if (chid == -3) {
player.dropMessage(5, "Invalid worldid detected. Channel creation aborted.");
} else if(chid == -2) {
} else if (chid == -2) {
player.dropMessage(5, "Reached channel limit on worldid " + worldid + ". Channel creation aborted.");
} else if(chid == -1) {
} else if (chid == -1) {
player.dropMessage(5, "Error detected when loading the 'world.ini' file. Channel creation aborted.");
} else {
player.dropMessage(5, "NEW Channel failed to be deployed. Check if the needed port is already in use or other limitations are taking place.");

View File

@@ -37,15 +37,15 @@ public class ServerAddWorldCommand extends Command {
@Override
public void execute(Client c, String[] params) {
final Character player = c.getPlayer();
ThreadManager.getInstance().newTask(() -> {
int wid = Server.getInstance().addWorld();
if(player.isLoggedinWorld()) {
if(wid >= 0) {
if (player.isLoggedinWorld()) {
if (wid >= 0) {
player.dropMessage(5, "NEW World " + wid + " successfully deployed.");
} else {
if(wid == -2) {
if (wid == -2) {
player.dropMessage(5, "Error detected when loading the 'world.ini' file. World creation aborted.");
} else {
player.dropMessage(5, "NEW World failed to be deployed. Check if needed ports are already in use or maximum world count has been reached.");

View File

@@ -37,7 +37,7 @@ public class ServerRemoveChannelCommand extends Command {
@Override
public void execute(Client c, String[] params) {
final Character player = c.getPlayer();
if (params.length < 1) {
player.dropMessage(5, "Syntax: @removechannel <worldid>");
return;
@@ -45,12 +45,12 @@ public class ServerRemoveChannelCommand extends Command {
final int worldId = Integer.parseInt(params[0]);
ThreadManager.getInstance().newTask(() -> {
if(Server.getInstance().removeChannel(worldId)) {
if(player.isLoggedinWorld()) {
if (Server.getInstance().removeChannel(worldId)) {
if (player.isLoggedinWorld()) {
player.dropMessage(5, "Successfully removed a channel on World " + worldId + ". Current channel count: " + Server.getInstance().getWorld(worldId).getChannelsSize() + ".");
}
} else {
if(player.isLoggedinWorld()) {
if (player.isLoggedinWorld()) {
player.dropMessage(5, "Failed to remove last Channel on world " + worldId + ". Check if either that world exists or there are people currently playing there.");
}
}

View File

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

View File

@@ -38,13 +38,13 @@ public class ShutdownCommand extends Command {
@Override
public void execute(Client c, String[] params) {
Character player = c.getPlayer();
if (params.length < 1){
if (params.length < 1) {
player.yellowMessage("Syntax: !shutdown [<time>|NOW]");
return;
}
int time = 60000;
if (params[0].equalsIgnoreCase("now")){
if (params[0].equalsIgnoreCase("now")) {
time = 1;
} else {
time *= Integer.parseInt(params[0]);
@@ -57,8 +57,12 @@ public class ShutdownCommand extends Command {
int days = (time / (1000 * 60 * 60 * 24));
String strTime = "";
if (days > 0) strTime += days + " days, ";
if (hours > 0) strTime += hours + " hours, ";
if (days > 0) {
strTime += days + " days, ";
}
if (hours > 0) {
strTime += hours + " hours, ";
}
strTime += minutes + " minutes, ";
strTime += seconds + " seconds";
@@ -68,7 +72,7 @@ public class ShutdownCommand extends Command {
}
}
}
TimerManager.getInstance().schedule(Server.getInstance().shutdown(false), time);
}
}

View File

@@ -36,7 +36,7 @@ public class SupplyRateCouponCommand extends Command {
player.dropMessage(5, "Syntax: !supplyratecoupon <yes|no>");
return;
}
YamlConfig.config.server.USE_SUPPLY_RATE_COUPONS = params[0].compareToIgnoreCase("no") != 0;
player.dropMessage(5, "Rate coupons are now " + (YamlConfig.config.server.USE_SUPPLY_RATE_COUPONS ? "enabled" : "disabled") + " for purchase at the Cash Shop.");
}