@SuppressWarnings("rawtypes") @Override public boolean useAdminCommand( Enum comm, String[] wordList, String fullString, Player activeChar) { Commands command = (Commands) comm; if (!activeChar.getPlayerAccess().CanEditCharAll) return false; switch (command) { case admin_quests: return ShowQuestList(getTargetChar(wordList, 1, activeChar), activeChar); case admin_quest: if (wordList.length < 2) { activeChar.sendMessage("USAGE: //quest id|name [SHOW|STATE|VAR|CLEAR] ..."); return true; } Quest _quest = QuestManager.getQuest2(wordList[1]); if (_quest == null) { activeChar.sendMessage("Quest " + wordList[1] + " undefined"); return true; } if (wordList.length < 3 || wordList[2].equalsIgnoreCase("SHOW")) return cmd_Show(_quest, wordList, activeChar); if (wordList[2].equalsIgnoreCase("STATE")) return cmd_State(_quest, wordList, activeChar); if (wordList[2].equalsIgnoreCase("VAR")) return cmd_Var(_quest, wordList, activeChar); if (wordList[2].equalsIgnoreCase("CLEAR")) return cmd_Clear(_quest, wordList, activeChar); return cmd_Show(_quest, wordList, activeChar); } return true; }
private void recallNPC(Player activeChar) { GameObject obj = activeChar.getTarget(); if (obj != null && obj.isNpc()) { obj.setLoc(activeChar.getLoc()); ((NpcInstance) obj).broadcastCharInfo(); activeChar.sendMessage( "You teleported npc " + obj.getName() + " to " + activeChar.getLoc().toString() + "."); } else activeChar.sendMessage("Target is't npc."); }
private void teleportTo(Player activeChar, Player target, Location loc, int ref) { if (!target.equals(activeChar)) target.sendMessage("Admin is teleporting you."); target.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); target.teleToLocation(loc, ref); if (target.equals(activeChar)) activeChar.sendMessage("You have been teleported to " + loc + ", reflection id: " + ref); }
public void NewAccount(String[] name) { Player player = getSelf(); if (player == null) return; if (player.getInventory().getCountOf(ACC_MOVE_ITEM) < ACC_MOVE_PRICE) { player.sendMessage( "У вас нету " + ACC_MOVE_PRICE + " " + ItemHolder.getInstance().getTemplate(ACC_MOVE_ITEM)); CharToAcc(); return; } String _name = name[0]; Connection con = null; Connection conGS = null; PreparedStatement offline = null; Statement statement = null; ResultSet rs = null; try { con = DatabaseFactory.getInstance().getConnection(); offline = con.prepareStatement("SELECT `login` FROM `accounts` WHERE `login` = ?"); offline.setString(1, _name); rs = offline.executeQuery(); if (rs.next()) { removeItem(player, ACC_MOVE_ITEM, ACC_MOVE_PRICE); conGS = DatabaseFactory.getInstance().getConnection(); statement = conGS.createStatement(); statement.executeUpdate( "UPDATE `characters` SET `account_name` = '" + _name + "' WHERE `char_name` = '" + player.getName() + "'"); player.sendMessage("Персонаж успешно перенесен."); player.logout(); } else { player.sendMessage("Введенный аккаунт не найден."); CharToAcc(); } } catch (Exception e) { e.printStackTrace(); return; } finally { DbUtils.closeQuietly(con, offline, rs); DbUtils.closeQuietly(conGS, statement); } }
private void teleportTo(Player activeChar, Player target, String Cords, int ref) { try { teleportTo(activeChar, target, Location.parseLoc(Cords), ref); } catch (IllegalArgumentException e) { activeChar.sendMessage("You must define 3 coordinates required to teleport"); return; } }
private void teleportToCharacter(Player activeChar, GameObject target) { if (target == null) return; activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); activeChar.teleToLocation(target.getLoc(), target.getReflectionId()); activeChar.sendMessage("You have teleported to " + target); }
private boolean cmd_Show(Quest _quest, String[] wordList, Player activeChar) { // quest id|name SHOW [target] Player targetChar = getTargetChar(wordList, 3, activeChar); QuestState qs = targetChar.getQuestState(_quest.getName()); if (qs == null) { activeChar.sendMessage( "Player " + targetChar.getName() + " havn't Quest [" + _quest.getName() + "]"); return false; } return ShowQuestState(qs, activeChar); }
public void startEvent() { Player player = getSelf(); if (!player.getPlayerAccess().IsEventGm) return; if (SetActive("TVTArena5", true)) { spawnEventManagers(); _log.info("Event: TVT Arena 5 started"); Announcements.getInstance().announceToAll("Начался евент TVT Arena 5"); } else player.sendMessage("Event: TVT Arena 5 already started"); show("admin/events/custom/custom.htm", player); }
private void teleportCharacter(Player activeChar, String Cords) { GameObject target = activeChar.getTarget(); if (target == null || !target.isPlayer()) { activeChar.sendPacket(Msg.INVALID_TARGET); return; } if (target.getObjectId() == activeChar.getObjectId()) { activeChar.sendMessage("You cannot teleport yourself."); return; } teleportTo(activeChar, (Player) target, Cords, activeChar.getReflectionId()); }
private boolean cmd_Clear(Quest _quest, String[] wordList, Player activeChar) { // quest id|name CLEAR [target] Player targetChar = getTargetChar(wordList, 3, activeChar); QuestState qs = targetChar.getQuestState(_quest.getName()); if (qs == null) { activeChar.sendMessage( "Player " + targetChar.getName() + " havn't Quest [" + _quest.getName() + "]"); return false; } qs.exitCurrentQuest(true); return ShowQuestList(targetChar, activeChar); }
private Player getTargetChar(String[] wordList, int wordListIndex, Player activeChar) { // цель задана аргументом if (wordListIndex >= 0 && wordList.length > wordListIndex) { Player player = World.getPlayer(wordList[wordListIndex]); if (player == null) activeChar.sendMessage("Can't find player: " + wordList[wordListIndex]); return player; } // цель задана текущим таргетом GameObject my_target = activeChar.getTarget(); if (my_target != null && my_target.isPlayer()) return (Player) my_target; // в качестве цели сам админ return activeChar; }
private boolean cmd_Var(Quest _quest, String[] wordList, Player activeChar) { if (wordList.length < 5) { activeChar.sendMessage("USAGE: //quest id|name VAR varname newvalue [target]"); return false; } Player targetChar = getTargetChar(wordList, 5, activeChar); QuestState qs = targetChar.getQuestState(_quest.getName()); if (qs == null) { activeChar.sendMessage( "Player " + targetChar.getName() + " havn't Quest [" + _quest.getName() + "], init quest by command:"); activeChar.sendMessage("//quest id|name STATE 1|2|3 [target]"); return false; } if (wordList[4].equalsIgnoreCase("~") || wordList[4].equalsIgnoreCase("#")) qs.unset(wordList[3]); else qs.set(wordList[3], wordList[4]); return ShowQuestState(qs, activeChar); }
public void stopEvent() { Player player = getSelf(); if (!player.getPlayerAccess().IsEventGm) return; if (SetActive("TVTArena5", false)) { ServerVariables.unset("TVTArena5"); unSpawnEventManagers(); stop(); _log.info("Event: TVT Arena 5 stopped"); Announcements.getInstance().announceToAll("Окончен евент TVT Arena 5"); } else player.sendMessage("Event: TVT Arena 5 not started"); show("admin/events/custom/custom.htm", player); }
private static boolean CheckCondition(Player player) { if (player == null) { return false; } if (player.isInOlympiadMode()) { if (player.isLangRus()) { player.sendMessage("Во время Олимпиады нельзя использовать данную функцию."); } else { player.sendMessage("During the Olympics you can not use this feature."); } return false; } if (player.getReflection().getId() != 0 && !Config.COMMUNITYBOARD_INSTANCE_ENABLED) { if (player.isLangRus()) { player.sendMessage("Сервис доступен только в обычном мире."); } else { player.sendMessage("Service is only available in the real world."); } return false; } return true; }
private boolean cmd_State(Quest _quest, String[] wordList, Player activeChar) { if (wordList.length < 4) { activeChar.sendMessage("USAGE: //quest id|name STATE 1|2|3 [target]"); return false; } int state = 0; try { state = Integer.parseInt(wordList[3]); } catch (Exception e) { activeChar.sendMessage("Wrong State ID: " + wordList[3]); return false; } Player targetChar = getTargetChar(wordList, 4, activeChar); QuestState qs = targetChar.getQuestState(_quest.getName()); if (qs == null) { activeChar.sendMessage("Init Quest [" + _quest.getName() + "] for " + targetChar.getName()); qs = _quest.newQuestState(targetChar, state); qs.set("cond", "1"); } else qs.setState(state); return ShowQuestState(qs, activeChar); }
public void get() { Player player = getSelf(); if (player.isNoble()) { return; } if (player.getSubLevel() < 75) { player.sendMessage("You must make sub class level 75 first."); return; } if (player .getInventory() .destroyItemByItemId( Config.SERVICES_NOBLESS_SELL_ITEM, Config.SERVICES_NOBLESS_SELL_PRICE)) { makeSubQuests(); becomeNoble(); } else if (Config.SERVICES_NOBLESS_SELL_ITEM == 57) { player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA); } else { player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT); } }
@SuppressWarnings("rawtypes") @Override public boolean useAdminCommand( Enum comm, String[] wordList, String fullString, Player activeChar) { Commands command = (Commands) comm; if (!activeChar.getPlayerAccess().CanTeleport) return false; switch (command) { case admin_show_moves: activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/teleports.htm")); break; case admin_show_moves_other: activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/tele/other.htm")); break; case admin_show_teleport: showTeleportCharWindow(activeChar); break; case admin_teleport_to_character: teleportToCharacter(activeChar, activeChar.getTarget()); break; case admin_teleport_to: case admin_teleportto: if (wordList.length < 2) { activeChar.sendMessage("USAGE: //teleportto charName"); return false; } String chaName = Util.joinStrings(" ", wordList, 1); Player cha = GameObjectsStorage.getPlayer(chaName); if (cha == null) { activeChar.sendMessage("Player '" + chaName + "' not found in world"); return false; } teleportToCharacter(activeChar, cha); break; case admin_move_to: case admin_moveto: case admin_teleport: if (wordList.length < 2) { activeChar.sendMessage("USAGE: //teleport x y z [ref]"); return false; } teleportTo( activeChar, activeChar, Util.joinStrings(" ", wordList, 1, 3), ArrayUtils.valid(wordList, 4) != null && !ArrayUtils.valid(wordList, 4).isEmpty() ? Integer.parseInt(wordList[4]) : 0); break; case admin_walk: if (wordList.length < 2) { activeChar.sendMessage("USAGE: //walk x y z"); return false; } try { activeChar.moveToLocation(Location.parseLoc(Util.joinStrings(" ", wordList, 1)), 0, true); } catch (IllegalArgumentException e) { activeChar.sendMessage("USAGE: //walk x y z"); return false; } break; case admin_gonorth: case admin_gosouth: case admin_goeast: case admin_gowest: case admin_goup: case admin_godown: int val = wordList.length < 2 ? 150 : Integer.parseInt(wordList[1]); int x = activeChar.getX(); int y = activeChar.getY(); int z = activeChar.getZ(); if (command == Commands.admin_goup) z += val; else if (command == Commands.admin_godown) z -= val; else if (command == Commands.admin_goeast) x += val; else if (command == Commands.admin_gowest) x -= val; else if (command == Commands.admin_gosouth) y += val; else if (command == Commands.admin_gonorth) y -= val; activeChar.teleToLocation(x, y, z); showTeleportWindow(activeChar); break; case admin_tele: showTeleportWindow(activeChar); break; case admin_teleto: case admin_tele_to: case admin_instant_move: if (wordList.length > 1 && wordList[1].equalsIgnoreCase("r")) activeChar.setTeleMode(2); else if (wordList.length > 1 && wordList[1].equalsIgnoreCase("end")) activeChar.setTeleMode(0); else activeChar.setTeleMode(1); break; case admin_tonpc: case admin_to_npc: if (wordList.length < 2) { activeChar.sendMessage("USAGE: //tonpc npcId|npcName"); return false; } String npcName = Util.joinStrings(" ", wordList, 1); NpcInstance npc; try { if ((npc = GameObjectsStorage.getByNpcId(Integer.parseInt(npcName))) != null) { teleportToCharacter(activeChar, npc); return true; } } catch (Exception e) { } if ((npc = GameObjectsStorage.getNpc(npcName)) != null) { teleportToCharacter(activeChar, npc); return true; } activeChar.sendMessage("Npc " + npcName + " not found"); break; case admin_toobject: if (wordList.length < 2) { activeChar.sendMessage("USAGE: //toobject objectId"); return false; } Integer target = Integer.parseInt(wordList[1]); GameObject obj; if ((obj = GameObjectsStorage.findObject(target)) != null) { teleportToCharacter(activeChar, obj); return true; } activeChar.sendMessage("Object " + target + " not found"); break; default: break; } if (!activeChar.getPlayerAccess().CanEditChar) return false; switch (command) { case admin_teleport_character: if (wordList.length < 2) { activeChar.sendMessage("USAGE: //teleport_character x y z"); return false; } teleportCharacter(activeChar, Util.joinStrings(" ", wordList, 1)); showTeleportCharWindow(activeChar); break; case admin_recall: if (wordList.length < 2) { activeChar.sendMessage("USAGE: //recall charName"); return false; } String targetName = Util.joinStrings(" ", wordList, 1); Player recall_player = GameObjectsStorage.getPlayer(targetName); if (recall_player != null) { teleportTo(activeChar, recall_player, activeChar.getLoc(), activeChar.getReflectionId()); return true; } int obj_id = CharacterDAO.getInstance().getObjectIdByName(targetName); if (obj_id > 0) { teleportCharacter_offline(obj_id, activeChar.getLoc()); activeChar.sendMessage(targetName + " is offline. Offline teleport used..."); } else activeChar.sendMessage("->" + targetName + "<- is incorrect."); break; case admin_setref: { if (wordList.length < 2) { activeChar.sendMessage("Usage: //setref <reflection>"); return false; } int ref_id = Integer.parseInt(wordList[1]); if (ref_id != 0 && ReflectionManager.getInstance().get(ref_id) == null) { activeChar.sendMessage("Reflection <" + ref_id + "> not found."); return false; } GameObject target = activeChar; GameObject obj = activeChar.getTarget(); if (obj != null) target = obj; target.setReflection(ref_id); target.decayMe(); target.spawnMe(); break; } case admin_getref: if (wordList.length < 2) { activeChar.sendMessage("Usage: //getref <char_name>"); return false; } Player cha = GameObjectsStorage.getPlayer(wordList[1]); if (cha == null) { activeChar.sendMessage("Player '" + wordList[1] + "' not found in world"); return false; } activeChar.sendMessage( "Player '" + wordList[1] + "' in reflection: " + activeChar.getReflectionId() + ", name: " + activeChar.getReflection().getName()); break; default: break; } if (!activeChar.getPlayerAccess().CanEditNPC) return false; switch (command) { case admin_recall_npc: recallNPC(activeChar); break; default: break; } return true; }