Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ===========================================
- Index: config.java
- ==============================================
- + private static final String SIEGE = "./config/main/Siege.ini";
- + public static List<int[]> LEADER_REWARD_WINNER_SIEGE_CLAN = new ArrayList<>();
- + public static List<int[]> REWARD_WINNER_SIEGE_CLAN = new ArrayList<>();
- + public static void loadSiegeConfig()
- + {
- + final PropertiesParser Siege = new PropertiesParser(SIEGE);
- +
- + SIEGE_ENABLE_RENEWAL = Siege.getBoolean("EnableRenewal", true);
- +
- + if (SIEGE_ENABLE_RENEWAL)
- + {
- + String[] propertySplit = Siege.getString("LeaderRewardsID", "57,0").split(";");
- + for (String reward : propertySplit)
- + {
- + final String[] rewardSplit = reward.split(",");
- + if (rewardSplit.length != 2)
- + {
- + LOGGER.warning("LeaderRewardsID[Config.load()]: invalid config property -> LeaderRewardsID \"" + reward + "\"");
- + }
- + else
- + {
- + try
- + {
- + LEADER_REWARD_WINNER_SIEGE_CLAN.add(new int[]
- + {
- + Integer.parseInt(rewardSplit[0]),
- + Integer.parseInt(rewardSplit[1])
- + });
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!reward.isEmpty())
- + {
- + LOGGER.warning("LeaderRewardsID[Config.load()]: invalid config property -> LeaderRewardsID \"" + reward + "\"");
- + }
- + }
- + }
- + }
- + }
- +
- + if (SIEGE_ENABLE_RENEWAL)
- + {
- + String[] propertySplit1 = Siege.getString("MembersRewardsID", "57,0").split(";");
- + for (String reward : propertySplit1)
- + {
- + final String[] rewardSplit = reward.split(",");
- + if (rewardSplit.length != 2)
- + {
- + LOGGER.warning("MembersRewardsID[Config.load()]: invalid config property -> MembersRewardsID \"" + reward + "\"");
- + }
- + else
- + {
- + try
- + {
- + REWARD_WINNER_SIEGE_CLAN.add(new int[]
- + {
- + Integer.parseInt(rewardSplit[0]),
- + Integer.parseInt(rewardSplit[1])
- + });
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!reward.isEmpty())
- + {
- + LOGGER.warning("MembersRewardsID[Config.load()]: invalid config property -> MembersRewardsID \"" + reward + "\"");
- + }
- + }
- + }
- + }
- + }
- + }
- + loadSiegeConfig();
- ======================================================
- Index: gameserver.model.entity.siege.Siege.java
- ======================================================
- public void endSiege()
- {
- if (_isInProgress)
- {
- announceToPlayer("The siege of " + getCastle().getName() + " has finished!", false);
- final PlaySound sound = new PlaySound("systemmsg_e.18");
- for (PlayerInstance player : World.getInstance().getAllPlayers())
- {
- + // Renewal Leader / Memebers
- + checkRenewal(player);
- player.sendPacket(sound);
- }
- /**
- * Gets the siege guard manager.
- * @return the siege guard manager
- */
- public SiegeGuardManager getSiegeGuardManager()
- {
- if (_siegeGuardManager == null)
- {
- _siegeGuardManager = new SiegeGuardManager(getCastle());
- }
- return _siegeGuardManager;
- }
- + public static void checkRenewal(PlayerInstance activeChar)
- + {
- + PlayerInstance player = activeChar.getActingPlayer();
- + boolean _canReward = false;
- + HashMap<String, Integer> playerIps = new HashMap<>();
- +
- + if (player.isInParty())
- + {
- + List<PlayerInstance> party = player.getParty().getPartyMembers();
- +
- + for (PlayerInstance member : party)
- + {
- + String pIp = member.getClient().getConnection().getInetAddress().getHostAddress();
- +
- + if (!playerIps.containsKey(pIp))
- + {
- + playerIps.put(pIp, 1);
- + _canReward = true;
- + }
- + else
- + {
- + int count = playerIps.get(pIp);
- +
- + if (count < 1)
- + {
- + playerIps.remove(pIp);
- + playerIps.put(pIp, count + 1);
- + _canReward = true;
- + }
- + else
- + {
- + member.sendMessage("Already 1 member of your ip have been rewarded, so this character won't be rewarded.");
- + _canReward = false;
- + }
- + }
- + if (_canReward)
- + {
- + if (member.isInsideRadius(player, 1600, false, false))
- + {
- + if (Rnd.get(100) < 100)
- + {
- + if (Config.SIEGE_ENABLE_RENEWAL)
- + {
- +
- + if (activeChar.isClanLeader())
- + {
- + for (int[] reward : Config.LEADER_REWARD_WINNER_SIEGE_CLAN)
- + {
- + if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
- + {
- +
- + activeChar.addItem("Leader Renewal", reward[0], reward[1], null, true);
- + }
- +
- + }
- + }
- + else
- + {
- + for (int[] reward1 : Config.REWARD_WINNER_SIEGE_CLAN)
- + {
- + if (ItemTable.getInstance().createDummyItem(reward1[0]).isStackable())
- + {
- +
- + activeChar.addItem("Member Renewal", reward1[0], reward1[1], null, true);
- + }
- +
- + }
- +
- + }
- + player.broadcastPacket(new PlaySound("ItemSound.quest_finish"));
- + }
- + }
- +
- + }
- + else
- + {
- + member.sendMessage("You are too far to be rewarded.");
- + }
- + }
- + }
- + playerIps.clear();
- + }
- + else
- + {
- + if (Rnd.get(100) < 100)
- + {
- + if (Config.SIEGE_ENABLE_RENEWAL)
- + {
- +
- + if (activeChar.isClanLeader())
- + {
- + for (int[] reward : Config.LEADER_REWARD_WINNER_SIEGE_CLAN)
- + {
- + if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
- + {
- +
- + activeChar.addItem("Leader Renewal", reward[0], reward[1], null, true);
- + }
- +
- + }
- + }
- + else
- + {
- + for (int[] reward1 : Config.REWARD_WINNER_SIEGE_CLAN)
- + {
- + if (ItemTable.getInstance().createDummyItem(reward1[0]).isStackable())
- + {
- +
- + activeChar.addItem("Member Renewal", reward1[0], reward1[1], null, true);
- + }
- +
- + }
- +
- + }
- + player.broadcastPacket(new PlaySound("ItemSound.quest_finish"));
- + }
- + }
- + }
- +
- + }
- ==============================================
- Index: Config/main/Siege.ini
- # The minimum level for registration
- SiegeClanMinLevel = 4
- +EnableRenewal = True
- +#The End Siege Renewal
- +LeaderRewardsID = 57,1
- +MembersRewardsID = 57,2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement