Мало кто знает этот ивент. Никто не делал его. Официальная версия Не помню в какой версии появился но на v5.8 работает ЯДРО Добавляем в автозагрузку GameServer сервис Код: ThreesUpgradeService.getInstance().initThrees(); Код: /* * M.O.G. Devs Team * www.mmorpg-onlinegames.ru * Teg's {/aiononline, /eveonline} * * Lucky Game Service v5.31 */ package com.mog.gameserver.services.dlc.threesUpgrade; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.mog.gameserver.configs.main.CustomConfig; import com.mog.gameserver.dao.ThreesUpgradeDAO; import com.mog.gameserver.model.Race; import com.mog.gameserver.model.gameobjects.VisibleObject; import com.mog.gameserver.model.gameobjects.player.Player; import com.mog.gameserver.services.item.ItemService; import com.mog.gameserver.spawnengine.SpawnEngine; import com.mog.gameserver.utils.PacketSendUtility; import com.mog.gameserver.utils.commons.database.dao.DAOManager; import com.mog.gameserver.utils.commons.services.CronService; import com.mog.gameserver.world.World; import com.mog.gameserver.world.knownlist.Visitor; import javolution.util.FastMap; /** * @author Dision */ public class ThreesUpgradeService { private static final Logger log = LoggerFactory.getLogger(ThreesUpgradeService.class); private Map<Integer, ThreesUpgradeList> threesUpgrades = new HashMap<>(); public FastMap<Integer, VisibleObject> spawns = new FastMap<Integer, VisibleObject>(); public void initThrees() { if (!CustomConfig.THREES_UPGRADE_ENABLE) return; try { log.info("Initializing threes upgrades..."); for (int id = 1; id < 7; id++) threesUpgrades.put(id, DAOManager.getDAO(ThreesUpgradeDAO.class).loadThree(id)); log.info("Loaded " + threesUpgrades.size() + " threes upgrades."); // Update threes weekly CronService.getInstance().schedule(new Runnable() { @Override public void run() { for (Map.Entry<Integer, ThreesUpgradeList> entry : threesUpgrades.entrySet()) { ThreesUpgradeList three = entry.getValue(); switch (three.getId()) { case 1: entry.getValue().setThree(three.getId(), 0, 1, 833774); break; case 2: entry.getValue().setThree(three.getId(), 0, 1, 833775); break; case 3: entry.getValue().setThree(three.getId(), 0, 1, 833776); break; case 4: entry.getValue().setThree(three.getId(), 0, 1, 833774); break; case 5: entry.getValue().setThree(three.getId(), 0, 1, 833775); break; case 6: entry.getValue().setThree(three.getId(), 0, 1, 833776); break; } DAOManager.getDAO(ThreesUpgradeDAO.class).storeThree(three); } } }, "0 0 9 ? * MON"); for (Map.Entry<Integer, ThreesUpgradeList> entry : threesUpgrades.entrySet()) onLoadThree(1, DAOManager.getDAO(ThreesUpgradeDAO.class).loadThree(entry.getKey())); } catch (Exception ex) { log.error("Error in ThreesUpgradeService.initThrees", ex); } } public void onLoadThree(int type, ThreesUpgradeList three) { int level = 1; if (three.getExp() >= 51 && three.getExp() <= 99) level = 2; else if (three.getExp() >= 100) level = 3; int threeId = 0; switch (level) { case 1: if (type == 2) despawn(three.getId()); switch (three.getId()) { case 1: threeId = 833774; sp(1, 110010000, threeId, 1528.04f, 1502.61f, 565.98f); break; case 2: threeId = 833775; sp(2, 110010000, threeId, 1531.26f, 1521.35f, 565.99f); break; case 3: threeId = 833776; sp(3, 110010000, threeId, 1539.37f, 1509.66f, 565.98f); break; case 4: threeId = 833774; sp(4, 120010000, threeId, 1213.44f, 1402.53f, 208.23f); break; case 5: threeId = 833775; sp(5, 120010000, threeId, 1199.56f, 1388.95f, 208.23f); break; case 6: threeId = 833776; sp(6, 120010000, threeId, 1199.91f, 1403.30f, 208.22f); break; } break; case 2: if (type == 2) despawn(three.getId()); switch (three.getId()) { case 1: threeId = 833777; sp(1, 110010000, threeId, 1528.04f, 1502.61f, 565.98f); break; case 2: threeId = 833778; sp(2, 110010000, threeId, 1531.26f, 1521.35f, 565.99f); break; case 3: threeId = 833779; sp(3, 110010000, threeId, 1539.37f, 1509.66f, 565.98f); break; case 4: threeId = 833777; sp(4, 120010000, threeId, 1213.44f, 1402.53f, 208.23f); break; case 5: threeId = 833778; sp(5, 120010000, threeId, 1199.56f, 1388.95f, 208.23f); break; case 6: threeId = 833779; sp(6, 120010000, threeId, 1199.91f, 1403.30f, 208.22f); break; } break; case 3: if (type == 2) despawn(three.getId()); switch (three.getId()) { case 1: threeId = 833780; sp(1, 110010000, threeId, 1528.04f, 1502.61f, 565.98f); break; case 2: threeId = 833781; sp(2, 110010000, threeId, 1531.26f, 1521.35f, 565.99f); break; case 3: threeId = 833782; sp(3, 110010000, threeId, 1539.37f, 1509.66f, 565.98f); break; case 4: threeId = 833780; sp(4, 120010000, threeId, 1213.44f, 1402.53f, 208.23f); break; case 5: threeId = 833781; sp(5, 120010000, threeId, 1199.56f, 1388.95f, 208.23f); break; case 6: threeId = 833782; sp(6, 120010000, threeId, 1199.91f, 1403.30f, 208.22f); break; } break; } three.setThree(three.getId(), three.getExp(), level, threeId); DAOManager.getDAO(ThreesUpgradeDAO.class).storeThree(three); if (type == 2) threesUpgrades.replace(three.getId(), three, DAOManager.getDAO(ThreesUpgradeDAO.class).loadThree(three.getId())); } public void onUpgradeAct(Player player, int threeId) { if (!CustomConfig.THREES_UPGRADE_ENABLE) return; int id = 0; int itemId = 0; switch (threeId) { case 833774: // 1 case 833777: // 2 case 833780: // 3 id = !player.getRace().equals(Race.ASMODIANS) ? 1 : 4; itemId = 164002331; break; case 833775: // 1 case 833778: // 2 case 833781: // 3 id = !player.getRace().equals(Race.ASMODIANS) ? 2 : 5; itemId = 164002332; break; case 833776: // 1 case 833779: // 2 case 833782: // 3 id = !player.getRace().equals(Race.ASMODIANS) ? 3 : 6; itemId = 164002333; break; } if (!player.getInventory().decreaseByItemId(itemId, 1)) { PacketSendUtility.sendMessage(player, "[color:Древо;0 255 0][color: чуд;0 255 0][color:ес:;0 255 0] Нет удобрения для поливки древа."); return; } if (id != 0) { for (Map.Entry<Integer, ThreesUpgradeList> entry : threesUpgrades.entrySet()) { if (entry.getKey().equals(id)) { entry.getValue().setThree(id, entry.getValue().getExp() + CustomConfig.THREES_UPGRADE_RATE, entry.getValue().getLevel(), threeId); DAOManager.getDAO(ThreesUpgradeDAO.class).storeThree(entry.getValue()); PacketSendUtility.sendMessage(player, "[color:Древо;0 255 0][color: чуд;0 255 0][color:ес:;0 255 0] Вы полили древо. Общими усилиями расы набрано " + entry.getValue().getExp() + " энергии древа."); sendMsgByRace(player, entry.getKey(), entry.getValue().getExp() + CustomConfig.THREES_UPGRADE_RATE); int itemResultId = 0; switch (entry.getValue().getThreeId()) { case 833774: itemResultId = 188055122; break; case 833775: itemResultId = 188055126; break; case 833776: itemResultId = 188055130; break; case 833777: itemResultId = 188055123; break; case 833778: itemResultId = 188055127; break; case 833779: itemResultId = 188055131; break; case 833780: itemResultId = 188055125; break; case 833781: itemResultId = 188055129; break; case 833782: itemResultId = 188055133; break; } if (itemResultId != 0) { ItemService.addItem(player, itemResultId, 1); PacketSendUtility.sendMessage(player, "[color:Древо;0 255 0][color: чуд;0 255 0][color:ес:;0 255 0] Получен подарок " + entry.getValue().getLevel() + "-го уровня за поливку древа."); } onLoadThree(2, entry.getValue()); } } } } public Map<Integer, ThreesUpgradeList> getThrees() { return threesUpgrades; } public ThreesUpgradeList getThree(int id) { return threesUpgrades.get(id); } public void sp(int id, int worldId, int npcId, float x, float y, float z) { spawns.put(id, SpawnEngine.spawnObject(SpawnEngine.addNewSingleTimeSpawn(worldId, npcId, x, y, z, (byte) 0), 1)); log.info("ThreesUpgradeService spawn [key = " + id + "]"); } private void despawn(int id) { for (Entry<Integer, VisibleObject> entry : spawns.entrySet()) { if (entry.getKey().equals(id)) entry.getValue().getController().onDelete(); } spawns.remove(id); log.info("ThreesUpgradeService despawn [key = " + id + "]"); } protected void sendMsgByRace(Player player, int id, int exp) { World.getInstance().getWorldMap(!player.getRace().equals(Race.ASMODIANS) ? 110010000 : 120010000).getMainWorldMapInstance().doOnAllPlayers(new Visitor<Player>() { @Override public void visit(Player players) { if (player.getRace().equals(players.getRace())) PacketSendUtility.sendYellowLightMessageOnCenter(players, player.getName() + " полил древо №" + id + " удобрением. Энергия древа: " + exp + "%"); } }); } public static final ThreesUpgradeService getInstance() { return SingletonHolder.instance; } private static class SingletonHolder { protected static final ThreesUpgradeService instance = new ThreesUpgradeService(); } } Код: /* * M.O.G. Devs Team * www.mmorpg-onlinegames.ru * Teg's {/aiononline, /eveonline} */ package com.mog.gameserver.services.dlc.threesUpgrade; /** * @author Dision */ public class ThreesUpgradeList { private int id; private int exp; private int level; private int threeId; public ThreesUpgradeList() { } public ThreesUpgradeList(int id, int exp, int level, int threeId) { this.id = id; this.exp = exp; this.level = level; this.threeId = threeId; } public void setThree(int id, int exp, int level, int threeId) { setId(id); setExp(exp); setLevel(level); setThreeId(threeId); } public int getId() { return id; } public void setId(int id) { this.id = id; } public int getExp() { return exp; } public void setExp(int exp) { this.exp = exp; } public int getLevel() { return level; } public void setLevel(int level) { this.level = level; } public int getThreeId() { return threeId; } public void setThreeId(int threeId) { this.threeId = threeId; } } Код: /* * Threes upgrade */ package com.mog.gameserver.dao; import com.mog.gameserver.services.dlc.threesUpgrade.ThreesUpgradeList; import com.mog.gameserver.utils.commons.database.dao.DAO; /** * @author Dision */ public abstract class ThreesUpgradeDAO implements DAO { @Override public final String getClassName() { return ThreesUpgradeDAO.class.getName(); } public abstract ThreesUpgradeList loadThree(int id); public abstract boolean saveThree(ThreesUpgradeList threes); public abstract void storeThree(ThreesUpgradeList threes); public abstract boolean removeThree(int id); } SQL5 Код: /* * MySQL5ThreesUpgradeDAO */ package mysql5; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.mog.gameserver.dao.MySQL5DAOUtils; import com.mog.gameserver.dao.ThreesUpgradeDAO; import com.mog.gameserver.services.dlc.threesUpgrade.ThreesUpgradeList; import com.mog.gameserver.utils.commons.database.DB; import com.mog.gameserver.utils.commons.database.DatabaseFactory; import com.mog.gameserver.utils.commons.database.IUStH; /** * @author Dision */ public class MySQL5ThreesUpgradeDAO extends ThreesUpgradeDAO { private static final Logger log = LoggerFactory.getLogger(MySQL5ThreesUpgradeDAO.class); private static final String UPDATE_QUERY = "UPDATE threes_upgrade SET exp=?, level=?, threeId=? WHERE id=?"; public static final String DELETE_QUERY = "DELETE FROM `threes_upgrade` WHERE `id`=?"; /** * {@inheritDoc} */ @Override public ThreesUpgradeList loadThree(int id) { ThreesUpgradeList threes = null; PreparedStatement st = DB.prepareStatement("SELECT * FROM threes_upgrade WHERE `id` = ?"); try { st.setInt(1, id); ResultSet rs = st.executeQuery(); if (rs.next()) { threes = new ThreesUpgradeList(); threes.setId(id); threes.setExp(rs.getInt("exp")); threes.setLevel(rs.getInt("level")); threes.setThreeId(rs.getInt("threeId")); } } catch (Exception e) { log.error("Error in MySQL5ThreesUpgradeDAO.loadThree for id:" + id, e); } finally { DB.close(st); } return threes; } /** * {@inheritDoc} */ @Override public boolean saveThree(ThreesUpgradeList threes) { Connection con = null; try { con = DatabaseFactory.getConnection(); PreparedStatement preparedStatement = con.prepareStatement("INSERT INTO threes_upgrade (`id`, exp, level, threeId) " + "VALUES (?, ?, ?, ?)"); preparedStatement.setInt(1, threes.getId()); // Default preparedStatement.setInt(2, threes.getExp()); preparedStatement.setInt(3, threes.getLevel()); preparedStatement.setInt(4, threes.getThreeId()); preparedStatement.execute(); preparedStatement.close(); } catch (Exception e) { log.error("Error in MySQL5ThreesUpgradeDAO.saveThree", e); return false; } finally { DatabaseFactory.close(con); } return true; } @Override public void storeThree(final ThreesUpgradeList threes) { DB.insertUpdate(UPDATE_QUERY, new IUStH() { @Override public void handleInsertUpdate(PreparedStatement stmt) throws SQLException { stmt.setInt(1, threes.getExp()); stmt.setFloat(2, threes.getLevel()); stmt.setFloat(3, threes.getThreeId()); stmt.setInt(4, threes.getId()); // Default stmt.execute(); } }); } @Override public boolean removeThree(int id) { Connection con = null; try { con = DatabaseFactory.getConnection(); PreparedStatement stmt = con.prepareStatement(DELETE_QUERY); stmt.setInt(1, id); stmt.execute(); stmt.close(); } catch (Exception e) { log.error("Error in MySQL5PlayerInstanceExitPositionDAO.removeThree", e); return false; } finally { DatabaseFactory.close(con); } return true; } /** * {@inheritDoc} */ @Override public boolean supports(String database, int majorVersion, int minorVersion) { return MySQL5DAOUtils.supports(database, majorVersion, minorVersion); } } SQL Код: SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for threes_upgrade -- ---------------------------- DROP TABLE IF EXISTS `threes_upgrade`; CREATE TABLE `threes_upgrade` ( `id` int(11) NOT NULL, `exp` int(255) NOT NULL DEFAULT '0', `level` int(11) NOT NULL DEFAULT '1', `threeId` int(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unique_id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- ---------------------------- -- Records -- ---------------------------- INSERT INTO `threes_upgrade` VALUES ('1', '0', '1', '833774'); INSERT INTO `threes_upgrade` VALUES ('2', '0', '1', '833775'); INSERT INTO `threes_upgrade` VALUES ('3', '0', '1', '833776'); INSERT INTO `threes_upgrade` VALUES ('4', '0', '1', '833774'); INSERT INTO `threes_upgrade` VALUES ('5', '0', '1', '833775'); INSERT INTO `threes_upgrade` VALUES ('6', '0', '1', '833776'); AI Код: /* * Action Item Npc AI2 */ package com.mog.gameserver.ai2.handlers.general; import com.mog.gameserver.ai2.AI2Actions; import com.mog.gameserver.ai2.AIName; import com.mog.gameserver.ai2.NpcAI2; import com.mog.gameserver.controllers.observer.ItemUseObserver; import com.mog.gameserver.model.EmotionType; import com.mog.gameserver.model.TaskId; import com.mog.gameserver.model.gameobjects.Npc; import com.mog.gameserver.model.gameobjects.player.Player; import com.mog.gameserver.network.aion.serverpackets.SM_EMOTION; import com.mog.gameserver.network.aion.serverpackets.SM_USE_OBJECT; import com.mog.gameserver.services.SiegeService; import com.mog.gameserver.services.dlc.threesUpgrade.ThreesUpgradeService; import com.mog.gameserver.utils.PacketSendUtility; import com.mog.gameserver.utils.commons.network.util.ThreadPoolManager; /** * @author xTz * @modified Dision */ @AIName("useitem") public class ActionItemNpcAI2 extends NpcAI2 { protected int startBarAnimation = 1; protected int cancelBarAnimation = 2; @Override protected void handleDialogStart(Player player) { handleUseItemStart(player); } protected void handleUseItemStart(final Player player) { final int delay = getTalkDelay(); if (delay > 1) { final ItemUseObserver observer = new ItemUseObserver() { @Override public void abort() { player.getController().cancelTask(TaskId.ACTION_ITEM_NPC); PacketSendUtility.broadcastPacket(player, new SM_EMOTION(player, EmotionType.END_QUESTLOOT, 0, getObjectId()), true); PacketSendUtility.sendPacket(player, new SM_USE_OBJECT(player.getObjectId(), getObjectId(), 0, cancelBarAnimation)); player.getObserveController().removeObserver(this); } }; player.getObserveController().attach(observer); PacketSendUtility.sendPacket(player, new SM_USE_OBJECT(player.getObjectId(), getObjectId(), getTalkDelay(), startBarAnimation)); PacketSendUtility.broadcastPacket(player, new SM_EMOTION(player, EmotionType.START_QUESTLOOT, 0, getObjectId()), true); player.getController().addTask(TaskId.ACTION_ITEM_NPC, ThreadPoolManager.getInstance().schedule(new Runnable() { @Override public void run() { PacketSendUtility.broadcastPacket(player, new SM_EMOTION(player, EmotionType.END_QUESTLOOT, 0, getObjectId()), true); PacketSendUtility.sendPacket(player, new SM_USE_OBJECT(player.getObjectId(), getObjectId(), getTalkDelay(), cancelBarAnimation)); player.getObserveController().removeObserver(observer); handleUseItemFinish(player); } }, delay)); } else { handleUseItemFinish(player); } } protected void handleUseItemFinish(Player player) { if (getOwner().isInInstance()) AI2Actions.handleUseItemFinish(this, player); else { // Siege points SiegeService.getInstance().addSiegePointListener(player, getOwner(), 0); // Threes upgrade event if (getOwner().getNpcId() >= 833774 && getOwner().getNpcId() <= 833782) ThreesUpgradeService.getInstance().onUpgradeAct(player, getOwner().getNpcId()); } } protected void handleUseItemFinish(Player player, Npc npc) { if (getOwner().isInInstance()) AI2Actions.handleUseItemFinish(this, player); } protected int getTalkDelay() { return getObjectTemplate().getTalkDelay() * 1000; } }