קוד PHP:
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.odinms.client.messages.commands;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import net.sf.odinms.client.ExpTable;
import net.sf.odinms.client.MapleCharacter;
import net.sf.odinms.client.MapleClient;
import net.sf.odinms.client.MapleJob;
import net.sf.odinms.net.world.remote.WorldChannelInterface;
import net.sf.odinms.client.MapleStat;
import net.sf.odinms.client.messages.Command;
import net.sf.odinms.client.messages.CommandDefinition;
import net.sf.odinms.client.messages.MessageCallback;
import net.sf.odinms.net.channel.ChannelServer;
import net.sf.odinms.database.DatabaseConnection;
import net.sf.odinms.scripting.npc.NPCScriptManager;
import net.sf.odinms.server.MapleInventoryManipulator;
import net.sf.odinms.server.maps.SavedLocationType;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.StringUtil;
public class PlayerCommands implements Command {
private ResultSet ranking(boolean gm) {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps;
if (!gm) {
ps = con.prepareStatement("SELECT reborns, level, name, job FROM characters WHERE gm < 3 ORDER BY reborns desc LIMIT 10");
} else {
ps = con.prepareStatement("SELECT name, gm FROM characters WHERE gm >= 3");
}
return ps.executeQuery();
} catch (SQLException ex) {
return null;
}
}
@Override
public void execute(MapleClient c, MessageCallback mc, String[] splitted) throws Exception {
splitted[0] = splitted[0].toLowerCase();
MapleCharacter player = c.getPlayer();
if (player.getMapId() != 980000404) {
if (splitted[0].equals("@str") || splitted[0].equals("@dex") || splitted[0].equals("@int") || splitted[0].equals("@luk") || splitted[0].equals("@hp") || splitted[0].equals("@mp")) {
int amount = Integer.parseInt(splitted[1]);
if (amount > 0 && amount <= player.getRemainingAp() && amount < 31997) {
if (splitted[0].equals("@str") && amount + player.getStr() < 32001) {
player.setStr(player.getStr() + amount);
player.updateSingleStat(MapleStat.STR, player.getStr());
} else if (splitted[0].equals("@int") && amount + player.getInt() < 32001) {
player.setInt(player.getInt() + amount);
player.updateSingleStat(MapleStat.INT, player.getInt());
} else if (splitted[0].equals("@luk") && amount + player.getLuk() < 32001) {
player.setLuk(player.getLuk() + amount);
player.updateSingleStat(MapleStat.LUK, player.getLuk());
} else if (splitted[0].equals("@dex") && amount + player.getDex() < 32001) {
player.setDex(player.getDex() + amount);
player.updateSingleStat(MapleStat.DEX, player.getDex());
} else {
mc.dropMessage("Make sure the stat you are trying to raise will not be over 32000.");
}
player.setRemainingAp(player.getRemainingAp() - amount);
player.updateSingleStat(MapleStat.AVAILABLEAP, player.getRemainingAp());
} else {
mc.dropMessage("Please make sure your AP is not over 32000 and you have enough to distribute.");
}
} else if (splitted[0].equalsIgnoreCase("@checkstats")) {
mc.dropMessage("Your stats are:");
mc.dropMessage("Str: " + player.getStr());
mc.dropMessage("Dex: " + player.getDex());
mc.dropMessage("Int: " + player.getInt());
mc.dropMessage("Luk: " + player.getLuk());
mc.dropMessage("Available AP: " + player.getRemainingAp());
mc.dropMessage("Rebirths: " + player.getReborns());
} else if (splitted[0].equalsIgnoreCase("@commands") || splitted[0].equalsIgnoreCase("@help")) {
mc.dropMessage("============================================================");
mc.dropMessage(" " + c.getChannelServer().getServerName() + " Commands");
mc.dropMessage("============================================================");
mc.dropMessage("@str/@dex/@int/@luk <number> ~ with these commands you will never have to add AP the slow way.");
mc.dropMessage("@buynx <number> ~ NX currency is currently 1000 mesos for 1 nx point.");
mc.dropMessage("@save ~ Basically saves.");
mc.dropMessage("@rank ~ shows top 10 people.");
mc.dropMessage("@dispose ~ Turn off seeing smegas / Turn on.");
mc.dropMessage("@togglesmega ~ Turn off seeing smegas / Turn on.");
mc.dropMessage("@decieve ~ Sets your fame to -1337");
mc.dropMessage("@expfix ~ Got negative EXP ? Type this");
mc.dropMessage("@gm <message> ~ Call a gm for help (: ?");
mc.dropMessage("@checkstat ~ Allows you to check what your stats are. Including rebirths");
mc.dropMessage("@go ~ Try it out, type @go");
mc.dropMessage("@revive ~ Revives anyone on the channel besides yourself.");
mc.dropMessage("@cody ~ Job Advancer.");
mc.dropMessage("@nana ~ Stats reseter.");
mc.dropMessage("@nimakin ~ Stylist for Females.");
mc.dropMessage("@kin ~ Stylist for Males.");
mc.dropMessage("@storage ~ The bank");
mc.dropMessage("@reward ~ Reward shop Nr.1 (Using Slimie erasers as currency)");
mc.dropMessage("@reward1 ~ Reward shop Nr.2 (Using Slimie erasers currency)");
mc.dropMessage("@shop ~ The Shop that sells your every day needs!");
mc.dropMessage("@slime ~ Accesses the shop that sells slime erasers for 15m each");
mc.dropMessage("@zombie ~ ALL in one NPC");
} else if (splitted[0].equalsIgnoreCase("@buynx")) {
if (splitted.length != 2) {
mc.dropMessage("Syntax: @buynx <number> Example: @buynx 1000");
return;
}
int nxamount;
try {
nxamount = Integer.parseInt(splitted[1]);
} catch (NumberFormatException asd) {
return;
}
int cost = nxamount * 1000;
if (nxamount > 0 && nxamount < 420000) {
if (player.getMeso() >= cost) {
player.gainMeso(-cost, true, true, true);
player.modifyCSPoints(1, nxamount);
mc.dropMessage("You spent " + cost + " mesos. You have gained " + nxamount + " nx.");
} else {
mc.dropMessage("Not enough mesos. Go get some money you poor hobo. 1 NX is 1000 mesos.");
}
} else {
mc.dropMessage("I cant let you do this, why would you want to do that.");
}
} else if (splitted[0].equalsIgnoreCase("@save")) {
if (!player.getCheatTracker().Spam(900000, 0)) { // 15 minutes
player.saveToDB(true, false);
mc.dropMessage("Saved. <3");
} else {
mc.dropMessage("You cannot save more than once every 15 minutes.");
}
} else if (splitted[0].equalsIgnoreCase("@expfix")) {
player.setExp(0);
player.updateSingleStat(MapleStat.EXP, player.getExp());
} else if (splitted[0].equalsIgnoreCase("@go")) {
HashMap<String, Integer> maps = new HashMap<String, Integer>();
maps.put("fm", 910000000);
maps.put("henesys", 100000000);
maps.put("ellinia", 101000000);
maps.put("perion", 102000000);
maps.put("kerning", 103000000);
maps.put("lith", 104000000);
maps.put("sleepywood", 105040300);
maps.put("florina", 110000000);
maps.put("orbis", 200000000);
maps.put("happy", 209000000);
maps.put("elnath", 211000000);
maps.put("ludi", 220000000);
maps.put("aqua", 230000000);
maps.put("leafre", 240000000);
maps.put("mulung", 250000000);
maps.put("herb", 251000000);
maps.put("omega", 221000000);
maps.put("korean", 222000000);
maps.put("nlc", 600000000);
maps.put("excavation", 990000000);
maps.put("mushmom", 100000005);
maps.put("showa", 801000000);
maps.put("guild", 200000301);
maps.put("shrine", 800000000);
maps.put("amoria", 680000000);
if (splitted.length != 2) {
StringBuilder builder = new StringBuilder("Syntax: @go <mapname>");
int i = 0;
for (String mapss : maps.keySet()) {
if (1 % 10 == 0) {// 10 maps per line
mc.dropMessage(builder.toString());
} else {
builder.append(mapss + ", ");
}
}
mc.dropMessage(builder.toString());
} else if (maps.containsKey(splitted[1])) {
int map = maps.get(splitted[1]);
if (map == 910000000) {
player.saveLocation(SavedLocationType.FREE_MARKET);
}
player.changeMap(map);
mc.dropMessage("Please feel free to suggest any more locations, Use the @gms commands or post suggestions on the forum.");
} else {
mc.dropMessage("I could not find the map that you requested, go get an eye test.");
}
maps.clear();
} else if (splitted[0].equalsIgnoreCase("@gm")) {
if (splitted.length < 2) {
return;
}
else
mc.dropMessage("Message sent.");
if (!player.getCheatTracker().Spam(60000, 1)) { // 5 minutes.
try {
c.getChannelServer().getWorldInterface().broadcastGMMessage(null, MaplePacketCreator.serverNotice(6, "Channel: " + c.getChannel() + " " + player.getName() + ": " + StringUtil.joinStringFrom(splitted, 1)).getBytes());
} catch (RemoteException ex) {
c.getChannelServer().reconnectWorld();
}
} else {
player.dropMessage(1, "Please don't flood GMs with your messages");
}
} else if (splitted[0].equalsIgnoreCase("@togglesmega")) {
if (player.getMeso() >= 10000000) {
player.setSmegaEnabled(!player.getSmegaEnabled());
String text = (!player.getSmegaEnabled() ? "I blinded you with enchanted dog shit :) ! Now you may not see Avatar smega's" : "You magically grew ears that can see smegas T___T oh god that line is lame.");
mc.dropMessage(text);
player.gainMeso(-10000000, true);
} else {
mc.dropMessage("Wheres the mesos you idiot ! I want 10,000,000 meso bitch!");
}
} else if (splitted[0].equalsIgnoreCase("@dispose")) {
NPCScriptManager.getInstance().dispose(c);
mc.dropMessage("You have been disposed.");
} else if (splitted[0].equals("@emo")) {
player.setHp(0);
player.updateSingleStat(MapleStat.HP, 0);
mc.dropMessage("Whaaa emo *cut* *cut*.");
} else if (splitted[0].equalsIgnoreCase("@rebirth")) {
int negexp;
if (player.getLevel() > 199) {
player.setLevel(2);
player.setExp(0);
player.setReborns(player.getReborns() + 1);
player.changeJob(MapleJob.getById(0));
negexp = player.getExp();
player.gainExp(-negexp, false, false);
player.updateSingleStat(MapleStat.LEVEL, player.getLevel());
player.updateSingleStat(MapleStat.EXP, player.getExp());
} else {
mc.dropMessage("You must be level 200.");
}
} else if (splitted[0].equalsIgnoreCase("@rank")) {
ResultSet rs = ranking(false);
mc.dropMessage("Top 10 Players: ");
int i = 1;
while (rs.next()) {
String job; // Should i make it so it shows the actual job ?
if (rs.getInt("job") >= 400 && rs.getInt("job") <= 422) {
job = "Thief";
} else if (rs.getInt("job") >= 300 && rs.getInt("job") <= 322) {
job = "Archer";
} else if (rs.getInt("job") >= 200 && rs.getInt("job") <= 232) {
job = "Mage";
} else if (rs.getInt("job") >= 100 && rs.getInt("job") <= 132) {
job = "Warrior";
} else if (rs.getInt("job") >= 500 && rs.getInt("job") <= 532) {
job = "Pirate";
} else {
job = "Beginner";
}
mc.dropMessage(i + ". " + rs.getString("name") + " || Job: " + job + " || Rebirths: " + rs.getInt("reborns") + " || Level: " + rs.getInt("level"));
i++;
}
} else if (splitted[0].equalsIgnoreCase("@servergms")) {
ResultSet rs = ranking(true);
String gmType;
while (rs.next()) {
int gmLevl = rs.getInt("gm");
if (gmLevl == 3) {
gmType = "GM Helper.";
} else if (gmLevl >= 4) {
gmType = "Monster GM :D.";
} else {
gmType = "Error";
}
mc.dropMessage(rs.getString("name") + " : " + gmType);
}
} else if (splitted[0].equalsIgnoreCase("@credits")) {
mc.dropMessage ("ZombieStory Repack");
} else if (splitted[0].equalsIgnoreCase("@revive")) {
if (splitted.length == 2) {
MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
if (player != victim) {
if (player.getMeso() >= 50000000) { // 50 mil
if (victim != null) {
if (!victim.isAlive()) {
victim.setHp(1);
player.gainMeso(-50000000);
victim.updateSingleStat(MapleStat.HP, 1);
mc.dropMessage("You have revived " + victim.getName() + ".");
} else {
mc.dropMessage(victim.getName() + "is not dead.");
}
} else {
mc.dropMessage("The player is not online.");
}
} else {
mc.dropMessage("You need 50 million mesos to do this.");
}
} else {
mc.dropMessage("You can't revive yourself.");
}
} else {
mc.dropMessage("Syntax: @revive <player name>");
}
} else if (splitted[0].equalsIgnoreCase("@banme")) {
c.getSession().write(MaplePacketCreator.sendGMPolice(0, "Being cool.", 1000000));
} else if (splitted[0].equalsIgnoreCase("@fakerelog") || splitted[0].equalsIgnoreCase("!fakerelog")) {
c.getSession().write(MaplePacketCreator.getCharInfo(player));
player.getMap().removePlayer(player);
player.getMap().addPlayer(player);
} else if (splitted[0].equalsIgnoreCase("@cody")) {
NPCScriptManager.getInstance().start(c, 9200000);
} else if (splitted[0].equalsIgnoreCase("@storage")) {
player.getStorage().sendStorage(c, 2080005);
} else if (splitted[0].equalsIgnoreCase("@news")) {
NPCScriptManager.getInstance().start(c, 9040011);
} else if (splitted[0].equalsIgnoreCase("@kin")) {
NPCScriptManager.getInstance().start(c, 9900000);
} else if (splitted[0].equalsIgnoreCase("@nimakin")) {
NPCScriptManager.getInstance().start(c, 9900001);
} else if (splitted[0].equalsIgnoreCase("@reward")) {
NPCScriptManager.getInstance().start(c, 2050019);
} else if (splitted[0].equalsIgnoreCase("@reward1")) {
NPCScriptManager.getInstance().start(c, 2020004);
} else if (splitted[0].equalsIgnoreCase("@fredrick")) {
NPCScriptManager.getInstance().start(c, 9030000);
} else if (splitted[0].equalsIgnoreCase("@spinel")) {
NPCScriptManager.getInstance().start(c, 9000020);
} else if (splitted[0].equalsIgnoreCase("@nana")) {
NPCScriptManager.getInstance().start(c, 9201001);
} else if (splitted[0].equalsIgnoreCase("@shop")) {
NPCScriptManager.getInstance().start(c, 9901003);
} else if (splitted[0].equalsIgnoreCase("@zombie")) {
NPCScriptManager.getInstance().start(c, 22000);
} else if (splitted[0].equalsIgnoreCase("@slime")) {
NPCScriptManager.getInstance().start(c, 2093002);
} else if (splitted[0].equalsIgnoreCase("@goafk")) {
player.setChalkboard("I'm afk ! drop me a message <3");
} else if (splitted[0].equalsIgnoreCase("@checkexp")) {
MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
if (victim == null) {
mc.dropMessage("Player was not found in this channel.");
} else {
mc.dropMessage("EXP: " + victim.getExp() + " " + victim.getExp() / ExpTable.getExpNeededForLevel(victim.getLevel() + 1) * 100 + " %");
}
}
} else {
mc.dropMessage(splitted[0] + " is not a valid command.");
}
}
@Override
public CommandDefinition[] getDefinition() {
return new CommandDefinition[]{
new CommandDefinition("str", 0),
new CommandDefinition("dex", 0),
new CommandDefinition("int", 0),
new CommandDefinition("luk", 0),
new CommandDefinition("hp", 0),
new CommandDefinition("mp", 0),
new CommandDefinition("checkstats", 0),
new CommandDefinition("commands", 0),
new CommandDefinition("help", 0),
new CommandDefinition("buynx", 0),
new CommandDefinition("save", 0),
new CommandDefinition("expfix", 0),
new CommandDefinition("go", 0),
new CommandDefinition("gm", 0),
new CommandDefinition("togglesmega", 0),
new CommandDefinition("deceive", 0),
new CommandDefinition("dispose", 0),
new CommandDefinition("rank", 0),
new CommandDefinition("servergms", 5),
new CommandDefinition("credits", 0),
new CommandDefinition("revive", 0),
new CommandDefinition("banme", 0),
new CommandDefinition("clan", 0),
new CommandDefinition("afk", 0),
new CommandDefinition("onlinetime", 0),
new CommandDefinition("emo", 0),
new CommandDefinition("rebirth", 0),
new CommandDefinition("reborn", 0),
new CommandDefinition("slime", 0),
new CommandDefinition("kin", 0),
new CommandDefinition("nimakin", 0),
new CommandDefinition("reward", 0),
new CommandDefinition("reward1", 0),
new CommandDefinition("cody", 0),
new CommandDefinition("storage", 0),
new CommandDefinition("fakerelog", 0),
new CommandDefinition("fredrick", 0),
new CommandDefinition("news", 0),
new CommandDefinition("spinel", 0),
new CommandDefinition("news", 0),
new CommandDefinition("goafk", 0),
new CommandDefinition("nana", 0),
new CommandDefinition("checkexp", 0),
new CommandDefinition("shop", 0),
new CommandDefinition("zombie", 0)
};
}
}