↑ ↓

Адми команда для улучшения предметов v5.8

Тема в разделе "Скрипты, сайты, шаблоны и веб-обвязки для Aion", создана пользователем Dision, 21 июн 2018.

  1. TopicStarter Overlay
    Offline

    Dision Ефрейтор Команда форума VIP

    274
    62
    61
    Кредиты:
    $15.415,48
    Репутация:
    7
    Код:
    /*
     * M.O.G. Devs Team
     * www.mmorpg-onlinegames.ru
     * Teg's {/aiononline, /eveonline}
     */
    package admincommands;
    
    import com.mog.gameserver.configs.administration.CommandsConfig;
    import com.mog.gameserver.dao.ItemStoneListDAO;
    import com.mog.gameserver.dataholders.DataManager;
    import com.mog.gameserver.model.DescriptionId;
    import com.mog.gameserver.model.gameobjects.Creature;
    import com.mog.gameserver.model.gameobjects.Item;
    import com.mog.gameserver.model.gameobjects.PersistentState;
    import com.mog.gameserver.model.gameobjects.VisibleObject;
    import com.mog.gameserver.model.gameobjects.player.Player;
    import com.mog.gameserver.model.items.IdianInfo;
    import com.mog.gameserver.model.items.ManaStone;
    import com.mog.gameserver.model.items.RandomBonusResult;
    import com.mog.gameserver.model.stats.listeners.ItemEquipmentListener;
    import com.mog.gameserver.model.templates.item.ArmorType;
    import com.mog.gameserver.model.templates.item.GodstoneInfo;
    import com.mog.gameserver.model.templates.item.ItemTemplate;
    import com.mog.gameserver.model.templates.item.bonuses.StatBonusType;
    import com.mog.gameserver.network.aion.serverpackets.SM_STATS_INFO;
    import com.mog.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
    import com.mog.gameserver.services.item.ItemPacketService;
    import com.mog.gameserver.services.item.ItemSocketService;
    import com.mog.gameserver.utils.PacketSendUtility;
    import com.mog.gameserver.utils.Util;
    import com.mog.gameserver.utils.chathandlers.AdminCommand;
    import com.mog.gameserver.utils.commons.database.dao.DAOManager;
    import com.mog.gameserver.world.World;
    
    /**
     * @author Dision
     */
    public class Equip extends AdminCommand {
    
    	private static final String HELP = "help";
    	private static final String SOCKET = "so";
    	private static final String ENCHANT = "enchant";
    	private static final String GODSTONE = "god";
    	private static final String IDIANSTONE = "idian";
    	private static final String TEMPERING = "temp";
    	private static final String AMPLIFICATION = "amplif";
    	private static final String AMPLIFSKILL = "amplifskill";
    	private static final String SLOT = "slot";
    	private static final String LEVEL = "level";
    
    	public Equip() {
    		super("equip");
    	}
    
    	@Override
    	public void execute(Player admin, String... params) {
    		if (params.length == 0) {
    			showHelp(admin);
    			return;
    		}
    
    		VisibleObject target = admin.getTarget();
    		Player player = null;
    		player = World.getInstance().findPlayer(Util.convertName(params[0]));
    		if (target instanceof Player)
    			player = (Player) target;
    		else
    			player = admin;
    
    		if (target == null) {
    			PacketSendUtility.sendMessage(player, "No target selected");
    			return;
    		}
    		
    		if (!(target instanceof Creature)) {
    			PacketSendUtility.sendMessage(player, "Target has to be Creature!");
    			return;
    		}
    		
    		if (admin.getAccessLevel() < CommandsConfig.EQUIP) {
    			PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
    			return;
    		}
    		
    		if (HELP.equalsIgnoreCase(params[0])) {
    			showHelp(admin);
    		}
    		if (SOCKET.equalsIgnoreCase(params[0])) {
    			int manastone = 167000551; // test item
    			int count = 0;
    			manastone = Integer.parseInt(params[1]);
    			count = Integer.parseInt(params[2]);
    			socket(admin, player, manastone, count);
    		}
    		if (ENCHANT.equalsIgnoreCase(params[0])) {
    			int enchant = 0;
    			enchant = Integer.parseInt(params[1]);
    			enchant(admin, player, enchant);
    		}
    		if (GODSTONE.equalsIgnoreCase(params[0])) {
    			int godstone = 168000028; // test item
    			godstone = Integer.parseInt(params[1]);
    			godstone(admin, player, godstone);
    		}
    		if (IDIANSTONE.equalsIgnoreCase(params[0])) {
    			int idianstone = 166050005; // test item
    			int effectId = 0;
    			idianstone = Integer.parseInt(params[1]);
    			effectId = Integer.parseInt(params[2]);
    			idianstone(admin, player, idianstone, effectId);
    		}
    		if (TEMPERING.equalsIgnoreCase(params[0])) {
    			int tempering = 0;
    			tempering = Integer.parseInt(params[1]);
    			tempering(admin, player, tempering);
    		}
    		if (AMPLIFICATION.equalsIgnoreCase(params[0])) {
    			boolean amplif = false;
    			amplif = Boolean.parseBoolean(params[1]);
    			amplification(admin, player, amplif);
    		}
    		if (AMPLIFSKILL.equalsIgnoreCase(params[0])) {
    			int amplifskill = 0;
    			amplifskill = Integer.parseInt(params[1]);
    			amplificationSkill(admin, player, amplifskill);
    		}
    		if (SLOT.equalsIgnoreCase(params[0])) {
    			int count = 0;
    			count = Integer.parseInt(params[1]);
    			addManastoneSlot(admin, player, count);
    		}
    		if (LEVEL.equalsIgnoreCase(params[0])) {
    			int count = 0;
    			count = Integer.parseInt(params[1]);
    			if (count > 5)
    				count = 5;
    			
    			addHighLevel(admin, player, count);
    		}
    		return;
    	}
    
    	private void socket(Player admin, Player player, int manastone, int count) {
    		if (manastone != 0 && (manastone < 167000000 || manastone > 168000000)) {
    			PacketSendUtility.sendMessage(admin, "You are suposed to give the item id for a" + " Manastone or 0 to remove all manastones.");
    			return;
    		}
    		
    		for (Item targetItem : player.getEquipment().getEquippedItemsWithoutStigma()) {
    			if (isUpgradeble(targetItem) || isTempering(targetItem) || isWing(targetItem)) {
    				if (manastone == 0) {
    					ItemEquipmentListener.removeStoneStats(player, targetItem.getItemStones(), player.getGameStats());
    					ItemSocketService.removeAllManaStone(player, targetItem);
    				}
    				else {
    					for (int i = 0; i < targetItem.getItemTemplate().getManastoneSlots(); i++) {
    						ManaStone manaStone = ItemSocketService.addManaStone(targetItem, manastone);
    						ItemEquipmentListener.addStoneStats(player, targetItem, manaStone, player.getGameStats());
    					}
    					for (int i = 0; i < targetItem.getOptionalSocket(); i++) {
    						ManaStone manaStone = ItemSocketService.addManaStone(targetItem, manastone);
    						ItemEquipmentListener.addStoneStats(player, targetItem, manaStone, player.getGameStats());
    					}
    				}
    				
    				PacketSendUtility.sendPacket(player, new SM_STATS_INFO(player));
    				
    				if (targetItem.isEquipped())
    					player.getGameStats().updateStatsVisually();
    				
    				ItemPacketService.updateItemAfterInfoPacket(player, targetItem);
    			}
    		}
    		
    		if (manastone == 0) {
    			if (player == admin)
    				PacketSendUtility.sendMessage(player, "All Manastones removed from all equipped Items");
    			else {
    				PacketSendUtility.sendMessage(admin, "All Manastones removed from all equipped Items by the Player " + player.getName());
    				PacketSendUtility.sendMessage(player, "Admin " + admin.getName() + " removed all manastones from all your equipped Items");
    			}
    		}
    		else {
    			if (player == admin)
    				PacketSendUtility.sendMessage(player, count + "x [item: " + manastone + "] were added to free slots on all equipped items");
    			else {
    				PacketSendUtility.sendMessage(admin, count + "x [item: " + manastone + "] were added to free slots on all equipped items by the Player " + player.getName());
    				PacketSendUtility.sendMessage(player, "Admin " + admin.getName() + " added " + count + "x [item: " + manastone + "] to free slots on all your equipped items");
    			}
    		}
    	}
    
    	private void godstone(Player admin, Player player, int godstone) {
    		Item targetItem = player.getEquipment().getMainHandWeapon();
    		if (godstone < 168000028 && godstone > 168050022) {
    			PacketSendUtility.sendMessage(admin, "Wrong GodStone ItemID");
    			return;
    		}
    		else {
    			ItemTemplate itemTemplate = DataManager.ITEM_DATA.getItemTemplate(godstone);
    			GodstoneInfo godstoneInfo = itemTemplate.getGodstoneInfo();
    			if (godstoneInfo == null) {
    				PacketSendUtility.sendMessage(admin, "Wrong GodStone ItemID");
    				return;
    			}
    			
    			targetItem.addGodStone(godstone);
    			PacketSendUtility.sendPacket(player, new SM_STATS_INFO(player));
    			targetItem.getGodStone().onEquip(player);
    			
    			if (player == admin)
    				PacketSendUtility.sendMessage(admin, "GodStone install success");
    			else
    				PacketSendUtility.sendMessage(player, "GodStone install success");
    			
    			PacketSendUtility.sendPacket(player, new SM_STATS_INFO(player));
    			
    			if (targetItem.isEquipped())
    				player.getGameStats().updateStatsVisually();
    			
    			ItemPacketService.updateItemAfterInfoPacket(player, targetItem);
    		}
    	}
    
    	private void idianstone(Player admin, Player player, int idianstone, int effectId) {
    		if (idianstone < 166050005 && idianstone > 166050148) {
    			PacketSendUtility.sendMessage(admin, "Wrong IdianStone ItemID");
    			return;
    		}
    		else {
    			Item targetItem = player.getEquipment().getMainHandWeapon();
    			RandomBonusResult bonusId = DataManager.ITEM_RANDOM_BONUSES.getRandomModifiers(StatBonusType.POLISH, effectId);
    			if (bonusId == null) {
    				PacketSendUtility.sendMessage(admin, "Wrong IdianStone bonusId");
    				return;
    			}
    			
    			IdianInfo idianInfo = targetItem.getIdianInfo();
    			if (idianInfo != null) {
    				idianInfo.onUnEquip(player);
    				targetItem.setIdianInfo(null);
    				idianInfo.setPersistentState(PersistentState.DELETED);
    				DAOManager.getDAO(ItemStoneListDAO.class).storeIdianStones(idianInfo);
    			}
    			
    			idianInfo = new IdianInfo(idianstone, PersistentState.NEW, targetItem, bonusId.getTemplateNumber(), 1000000);
    			targetItem.setIdianInfo(idianInfo);
    			
    			PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_POLISH_SUCCEED(new DescriptionId(targetItem.getNameId())));
    			
    			if (player == admin)
    				PacketSendUtility.sendMessage(admin, "IdianStone install success");
    			else
    				PacketSendUtility.sendMessage(player, "IdianStone install success");
    			
    			PacketSendUtility.sendPacket(player, new SM_STATS_INFO(player));
    			if (targetItem.isEquipped())
    				player.getGameStats().updateStatsVisually();
    			
    			ItemPacketService.updateItemAfterInfoPacket(player, targetItem);
    		}
    	}
    
    	private void enchant(Player admin, Player player, int enchant) {
    		for (Item targetItem : player.getEquipment().getEquippedItemsWithoutStigma()) {
    			if (isUpgradeble(targetItem)) {
    				targetItem.setEnchantLevel(enchant);
    				
    				PacketSendUtility.sendPacket(player, new SM_STATS_INFO(player));
    				
    				if (targetItem.isEquipped())
    					player.getGameStats().updateStatsVisually();
    				
    				ItemPacketService.updateItemAfterInfoPacket(player, targetItem);
    			}
    		}
    		
    		if (player == admin)
    			PacketSendUtility.sendMessage(player, "All equipped items were enchanted to level " + enchant);
    		else {
    			PacketSendUtility.sendMessage(admin, "All equipped items by the Player " + player.getName() + " were enchanted to " + enchant);
    			PacketSendUtility.sendMessage(player, "Admin " + admin.getName() + " enchanted all your equipped items to level " + enchant);
    		}
    	}
    
    	private void tempering(Player admin, Player player, int tempering) {
    		for (Item targetItem : player.getEquipment().getEquippedItemsWithoutStigma()) {
    			if (isTempering(targetItem)) {
    				targetItem.setTempering(tempering);
    				
    				// Armlet
    				if (targetItem.getItemTemplate().isArmlet()) {
    					switch (targetItem.getTempering()) {
    						case 5:
    						case 6:
    							targetItem.setOptionalSocket(1);
    							break;
    						case 7:
    							targetItem.setOptionalSocket(2);
    							break;
    						case 8:
    							targetItem.setOptionalSocket(3);
    							break;
    						case 9:
    							targetItem.setOptionalSocket(4);
    							break;
    						case 10:
    							targetItem.setOptionalSocket(6);
    							break;
    						default:
    							targetItem.setOptionalSocket(0);
    							break;
    					}
    				}
    				
    				PacketSendUtility.sendPacket(player, new SM_STATS_INFO(player));
    				
    				if (targetItem.isEquipped())
    					player.getGameStats().updateStatsVisually();
    				
    				ItemPacketService.updateItemAfterInfoPacket(player, targetItem);
    			}
    		}
    		
    		if (player == admin)
    			PacketSendUtility.sendMessage(player, "All equipped items were tempering to level " + tempering);
    		else {
    			PacketSendUtility.sendMessage(admin, "All equipped items by the Player " + player.getName() + " were tempering to " + tempering);
    			PacketSendUtility.sendMessage(player, "Admin " + admin.getName() + " tempering all your equipped items to level " + tempering);
    		}
    	}
    
    	private void amplification(Player admin, Player player, boolean amplif) {
    		for (Item targetItem : player.getEquipment().getEquippedItemsWithoutStigma()) {
    			if (targetItem.getEnchantLevel() < targetItem.getItemTemplate().getMaxEnchantLevel() ||
    				targetItem.getItemTemplate().isItemAmplif() == false) {
    				PacketSendUtility.sendMessage(admin, "Item " + targetItem.getItemId() + " not max enchant level || not item amplification");
    				return;
    			}
    			else {
    				targetItem.setItemAmplif(amplif);
    				
    				PacketSendUtility.sendPacket(player, new SM_STATS_INFO(player));
    				
    				if (targetItem.isEquipped())
    					player.getGameStats().updateStatsVisually();
    				
    				ItemPacketService.updateItemAfterInfoPacket(player, targetItem);
    			}
    		}
    		
    		if (player == admin)
    			PacketSendUtility.sendMessage(player, "All equipmet set amplification");
    		else {
    			PacketSendUtility.sendMessage(admin, "All equipmet set amplification by the Player " + player.getName());
    			PacketSendUtility.sendMessage(player, "Admin " + admin.getName() + " amplification all your equipped items");
    		}
    	}
    
    	private void amplificationSkill(Player admin, Player player, int amplifSkill) {
    		for (Item targetItem : player.getEquipment().getEquippedItemsWithoutStigma()) {
    			if ((isUpgradeble(targetItem) || isWing(targetItem)) && targetItem.getEnchantLevel() > 19) {
    				targetItem.setItemAmplifSkill(amplifSkill);
    				
    				PacketSendUtility.sendPacket(player, new SM_STATS_INFO(player));
    				
    				if (targetItem.isEquipped())
    					player.getGameStats().updateStatsVisually();
    				
    				ItemPacketService.updateItemAfterInfoPacket(player, targetItem);
    			}
    			else {
    				PacketSendUtility.sendMessage(admin, "Item " + targetItem.getItemId() + " no amplification or upgrade 20+");
    				return;
    			}
    		}
    		
    		if (player == admin)
    			PacketSendUtility.sendMessage(player, "All equipmet set amplification skill");
    		else {
    			PacketSendUtility.sendMessage(admin, "All equipmet set amplification skill by the Player " + player.getName());
    			PacketSendUtility.sendMessage(player, "Admin " + admin.getName() + " amplification skill all your equipped items");
    		}
    	}
    	
    	private void addManastoneSlot(Player admin, Player player, int count) {
    		for (Item targetItem : player.getEquipment().getEquippedItemsWithoutStigma()) {
    			if (isUpgradeble(targetItem) || isTempering(targetItem) || isWing(targetItem)) {
    				ItemSocketService.removeAllManaStone(player, targetItem);
    				targetItem.setOptionalSocket(count);
    				
    				if (targetItem.isEquipped())
    					player.getGameStats().updateStatsVisually();
    				
    				ItemPacketService.updateItemAfterInfoPacket(player, targetItem);
    			}
    		}
    		
    		if (player == admin)
    			PacketSendUtility.sendMessage(player, "All equipmet set slot count: " + count);
    		else {
    			PacketSendUtility.sendMessage(admin, "All equipmet set amplification skill by the Player " + player.getName());
    			PacketSendUtility.sendMessage(player, "Admin " + admin.getName() + " slot count: " + count + " all your equipped items");
    		}
    	}
    	
    	private void addHighLevel(Player admin, Player player, int count) {
    		for (Item targetItem : player.getEquipment().getEquippedItemsWithoutStigma()) {
    			if (targetItem.getItemTemplate().isHighDeva() && (isUpgradeble(targetItem) || isWing(targetItem))) {
    				targetItem.setItemHighLevel(count);
    				
    				if (targetItem.isEquipped())
    					player.getGameStats().updateStatsVisually();
    				
    				ItemPacketService.updateItemAfterInfoPacket(player, targetItem);
    			}
    		}
    		
    		if (player == admin)
    			PacketSendUtility.sendMessage(player, "All equipmet set level count: " + count);
    		else {
    			PacketSendUtility.sendMessage(player, "Admin " + admin.getName() + " level count: " + count + " all your equipped items");
    		}
    	}
    
    	public static boolean isUpgradeble(Item item) {
    		if (item.getItemTemplate().isNoEnchant())
    			return false;
    		if (item.getItemTemplate().getMaxTempering() != 0)
    			return false;
    		if (item.getItemTemplate().isWeapon())
    			return true;
    		if (item.getItemTemplate().getArmorType().equals(ArmorType.WING))
    			return true;
    		if (item.getItemTemplate().isArmor()) {
    			int at = item.getItemTemplate().getItemSlot();
    			if (at == 1 || /* Main Hand */
    			at == 2 || /* Sub Hand */
    			at == 8 || /* Jacket */
    			at == 16 || /* Gloves */
    			at == 32 || /* Boots */
    			at == 2048 || /* Shoulder */
    			at == 4096 || /* Pants */
    			at == 131072 || /* Main Off Hand */
    			at == 262144) /* Sub Off Hand */
    				return true;
    		}
    		return false;
    	}
    
    	public static boolean isTempering(Item item) {
    		if (item.getItemTemplate().isNoEnchant())
    			return false;
    		if (item.getItemTemplate().getMaxEnchantLevel() != 0)
    			return false;
    		if (item.getItemTemplate().isWeapon())
    			return true;
    		if (item.getItemTemplate().isArmlet())
    			return true;
    		if (item.getItemTemplate().isArmor() || item.getItemTemplate().isPlume() || item.getItemTemplate().isAccessory()) {
    			int at = item.getItemTemplate().getItemSlot();
    			if (at == 1 || /* Main Hand */
    			at == 2 || /* Sub Hand */
    			at == 8 || /* Jacket */
    			at == 16 || /* Gloves */
    			at == 32 || /* Boots */
    			at == 2048 || /* Shoulder */
    			at == 4096 || /* Pants */
    			at == 131072 || /* Main Off Hand */
    			at == 262144 || /* Sub Off Hand */
    			at == 524288 || /* Plume */
    			at == 192 || /* Ear L Ear R */
    			at == 768 || /* Ring L Ring R */
    			at == 1024 || /* Neck */
    			at == 4 || /* Helmet */
    			at == 65536) /* Belt */
    				return true;
    		}
    		return false;
    	}
    	
    	public static boolean isWing(Item item) {
    		if (item.getItemTemplate().getItemSlot() == 32768)
    			return true;
    		return false;
    	}
    
    	/**
    	 * @param admin
    	 */
    	private void showHelp(Player admin) {
    		PacketSendUtility.sendMessage(admin, "Write //equip <so|enchant|god|idian|temp|amplif|amplifskill|slot|level>\n" + "(Socket) so <manastone id> <count>\n"
    			+ "(Enchant) enchant <number>\n" + "(GodStone) god <godstone id>\n" + "(IdianStone) idian <idianstone id> <effect id>\n"
    			+ "(Tempering) temp <number>\n" + "(Amplification) amplif <true/false>\n" + "(Amplification skill) amplifskill <Id Skill>");
    	}
    
    	@Override
    	public void onFail(Player player, String message) {
    		PacketSendUtility.sendMessage(player, "Write //equip <help>");
    	}
    }