02-07-2013, 11:53 AM
приветствую. с толкнулся с проблемой добавлением гм команд в сборку 1.9
есть готовые файлы, но сервер после их заливки выдает ошибку на них..подскажите в чем может быть проблема
что в этой команде не так?
есть готовые файлы, но сервер после их заливки выдает ошибку на них..подскажите в чем может быть проблема
1
package admincommands;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.gameserver.configs.administration.AdminConfig;
import org.gameserver.model.gameobjects.VisibleObject;
import org.gameserver.model.gameobjects.player.Player;
import org.gameserver.model.gameobjects.stats.modifiers.Executor;
import org.gameserver.model.items.ItemCooldown;
import org.gameserver.network.aion.serverpackets.SM_ITEM_COOLDOWN;
import org.gameserver.network.aion.serverpackets.SM_SKILL_COOLDOWN;
import org.gameserver.utils.PacketSendUtility;
import org.gameserver.utils.chathandlers.AdminCommand;
import org.gameserver.world.World;
/**
@author kecimis
*/
public class RemoveCd extends AdminCommand {
public RemoveCd() {
super("rcd");
}
@Override
public void executeCommand(Player admin, String[] params) {
if (admin.getAccessLevel() < AdminConfig.COMMAND_REMOVECD) {
PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
return;
}
VisibleObject target = admin.getTarget();
if (target == null || target.getClass() != Player.class) {
target = admin;
}
if (target instanceof Player) {
Player player = (Player) target;
if (params.length == 0) {
List<Integer> delayIds = new ArrayList<Integer>();
if (player.getSkillCoolDowns() != null) {
for (Entry<Integer, Long> en : player.getSkillCoolDowns().entrySet()) {
delayIds.add(en.getKey());
}
for (Integer delayId : delayIds) {
player.setSkillCoolDown(delayId, 0);
}
delayIds.clear();
PacketSendUtility.sendPacket(player, new SM_SKILL_COOLDOWN(player.getSkillCoolDowns()));
}
if (player.getItemCoolDowns() != null) {
for (Entry<Integer, ItemCooldown> en : player.getItemCoolDowns().entrySet()) {
delayIds.add(en.getKey());
}
for (Integer delayId : delayIds) {
player.addItemCoolDown(delayId, 0, 0);
}
delayIds.clear();
PacketSendUtility.sendPacket(player, new SM_ITEM_COOLDOWN(player.getItemCoolDowns()));
}
if (player.getSummon() != null) {
for (Entry<Integer, Long> en : player.getSummon().getSkillCoolDowns().entrySet()) {
delayIds.add(en.getKey());
}
for (Integer delayId : delayIds) {
player.getSummon().setSkillCoolDown(delayId, 0);
}
delayIds.clear();
PacketSendUtility.sendPacket(player, new SM_SKILL_COOLDOWN(player.getSkillCoolDowns()));
}
if (params.length > 0) {
if (params.length == 1 && params[0].equals("instance")
&& player.getInstanceCDs() != null && player.getInstanceCDs().size() > 0) {
player.getInstanceCDs().clear();
} else if (params.length == 2 && params[0].equals("instance") && params[1].equals("all")) {
World.getInstance().doOnAllPlayers(new Executor<Player>() {
@Override
public boolean run(Player rPlayer) {
if (rPlayer != null && rPlayer.getInstanceCDs() != null && rPlayer.getInstanceCDs().size() > 0) {
rPlayer.getInstanceCDs().clear();
PacketSendUtility.sendMessage(rPlayer, "Intance CDs were removed by an admin");
}
return true;
}
});
} else {
PacketSendUtility.sendMessage(player, "Syntax: //removecd instance [all]");
}
}
if (player.equals(admin)) {
PacketSendUtility.sendMessage(admin, "Your cooldowns were removed");
} else {
PacketSendUtility.sendMessage(admin, "You have removed cooldowns of player: " + player.getName());
PacketSendUtility.sendMessage(player, "Your cooldowns were removed by admin");
}
} else if (params[0].equals("instance")) {
if (player.getPortalCooldownList() == null || player.getPortalCooldownList().getPortalCoolDowns() == null) {
return;
}
if (params.length >= 2) {
if (params[1].equalsIgnoreCase("all")) {
List<Integer> mapIds = new ArrayList<Integer>();
for (Entry<Integer, Long> mapId : player.getPortalCooldownList().getPortalCoolDowns().entrySet()) {
mapIds.add(mapId.getKey());
}
for (Integer id : mapIds) {
player.getPortalCooldownList().addPortalCooldown(id, 0);
}
mapIds.clear();
if (player.equals(admin)) {
PacketSendUtility.sendMessage(admin, "Your instance cooldowns were removed");
} else {
PacketSendUtility.sendMessage(admin, "You have removed instance cooldowns of player: " + player.getName());
PacketSendUtility.sendMessage(player, "Your instance cooldowns were removed by admin");
}
} else {
int worldId = 0;
try {
worldId = Integer.parseInt(params[1]);
} catch (NumberFormatException e) {
PacketSendUtility.sendMessage(admin, "WorldId has to be integer or use \"all\"");
return;
}
if (player.getPortalCooldownList().isPortalUseDisabled(worldId)) {
player.getPortalCooldownList().addPortalCooldown(worldId, 0);
if (player.equals(admin)) {
PacketSendUtility.sendMessage(admin, "Your instance cooldown worldId: " + worldId + " was removed");
} else {
PacketSendUtility.sendMessage(admin, "You have removed instance cooldown worldId: " + worldId + " of player: " + player.getName());
PacketSendUtility.sendMessage(player, "Your instance cooldown worldId: " + worldId + " was removed by admin");
}
} else {
PacketSendUtility.sendMessage(admin, "You or your target can enter given instance");
}
}
} else {
PacketSendUtility.sendMessage(admin, "syntax: //removecd instance <all|worldId>");
}
}
} else {
PacketSendUtility.sendMessage(admin, "Only players are allowed as target");
}
}
}
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import org.gameserver.configs.administration.AdminConfig;
import org.gameserver.model.gameobjects.VisibleObject;
import org.gameserver.model.gameobjects.player.Player;
import org.gameserver.model.gameobjects.stats.modifiers.Executor;
import org.gameserver.model.items.ItemCooldown;
import org.gameserver.network.aion.serverpackets.SM_ITEM_COOLDOWN;
import org.gameserver.network.aion.serverpackets.SM_SKILL_COOLDOWN;
import org.gameserver.utils.PacketSendUtility;
import org.gameserver.utils.chathandlers.AdminCommand;
import org.gameserver.world.World;
/**
@author kecimis
*/
public class RemoveCd extends AdminCommand {
public RemoveCd() {
super("rcd");
}
@Override
public void executeCommand(Player admin, String[] params) {
if (admin.getAccessLevel() < AdminConfig.COMMAND_REMOVECD) {
PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
return;
}
VisibleObject target = admin.getTarget();
if (target == null || target.getClass() != Player.class) {
target = admin;
}
if (target instanceof Player) {
Player player = (Player) target;
if (params.length == 0) {
List<Integer> delayIds = new ArrayList<Integer>();
if (player.getSkillCoolDowns() != null) {
for (Entry<Integer, Long> en : player.getSkillCoolDowns().entrySet()) {
delayIds.add(en.getKey());
}
for (Integer delayId : delayIds) {
player.setSkillCoolDown(delayId, 0);
}
delayIds.clear();
PacketSendUtility.sendPacket(player, new SM_SKILL_COOLDOWN(player.getSkillCoolDowns()));
}
if (player.getItemCoolDowns() != null) {
for (Entry<Integer, ItemCooldown> en : player.getItemCoolDowns().entrySet()) {
delayIds.add(en.getKey());
}
for (Integer delayId : delayIds) {
player.addItemCoolDown(delayId, 0, 0);
}
delayIds.clear();
PacketSendUtility.sendPacket(player, new SM_ITEM_COOLDOWN(player.getItemCoolDowns()));
}
if (player.getSummon() != null) {
for (Entry<Integer, Long> en : player.getSummon().getSkillCoolDowns().entrySet()) {
delayIds.add(en.getKey());
}
for (Integer delayId : delayIds) {
player.getSummon().setSkillCoolDown(delayId, 0);
}
delayIds.clear();
PacketSendUtility.sendPacket(player, new SM_SKILL_COOLDOWN(player.getSkillCoolDowns()));
}
if (params.length > 0) {
if (params.length == 1 && params[0].equals("instance")
&& player.getInstanceCDs() != null && player.getInstanceCDs().size() > 0) {
player.getInstanceCDs().clear();
} else if (params.length == 2 && params[0].equals("instance") && params[1].equals("all")) {
World.getInstance().doOnAllPlayers(new Executor<Player>() {
@Override
public boolean run(Player rPlayer) {
if (rPlayer != null && rPlayer.getInstanceCDs() != null && rPlayer.getInstanceCDs().size() > 0) {
rPlayer.getInstanceCDs().clear();
PacketSendUtility.sendMessage(rPlayer, "Intance CDs were removed by an admin");
}
return true;
}
});
} else {
PacketSendUtility.sendMessage(player, "Syntax: //removecd instance [all]");
}
}
if (player.equals(admin)) {
PacketSendUtility.sendMessage(admin, "Your cooldowns were removed");
} else {
PacketSendUtility.sendMessage(admin, "You have removed cooldowns of player: " + player.getName());
PacketSendUtility.sendMessage(player, "Your cooldowns were removed by admin");
}
} else if (params[0].equals("instance")) {
if (player.getPortalCooldownList() == null || player.getPortalCooldownList().getPortalCoolDowns() == null) {
return;
}
if (params.length >= 2) {
if (params[1].equalsIgnoreCase("all")) {
List<Integer> mapIds = new ArrayList<Integer>();
for (Entry<Integer, Long> mapId : player.getPortalCooldownList().getPortalCoolDowns().entrySet()) {
mapIds.add(mapId.getKey());
}
for (Integer id : mapIds) {
player.getPortalCooldownList().addPortalCooldown(id, 0);
}
mapIds.clear();
if (player.equals(admin)) {
PacketSendUtility.sendMessage(admin, "Your instance cooldowns were removed");
} else {
PacketSendUtility.sendMessage(admin, "You have removed instance cooldowns of player: " + player.getName());
PacketSendUtility.sendMessage(player, "Your instance cooldowns were removed by admin");
}
} else {
int worldId = 0;
try {
worldId = Integer.parseInt(params[1]);
} catch (NumberFormatException e) {
PacketSendUtility.sendMessage(admin, "WorldId has to be integer or use \"all\"");
return;
}
if (player.getPortalCooldownList().isPortalUseDisabled(worldId)) {
player.getPortalCooldownList().addPortalCooldown(worldId, 0);
if (player.equals(admin)) {
PacketSendUtility.sendMessage(admin, "Your instance cooldown worldId: " + worldId + " was removed");
} else {
PacketSendUtility.sendMessage(admin, "You have removed instance cooldown worldId: " + worldId + " of player: " + player.getName());
PacketSendUtility.sendMessage(player, "Your instance cooldown worldId: " + worldId + " was removed by admin");
}
} else {
PacketSendUtility.sendMessage(admin, "You or your target can enter given instance");
}
}
} else {
PacketSendUtility.sendMessage(admin, "syntax: //removecd instance <all|worldId>");
}
}
} else {
PacketSendUtility.sendMessage(admin, "Only players are allowed as target");
}
}
}
что в этой команде не так?