This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..
Question
Williams
Hello i'm creating this code for the clan that take the castle.
created rewardClanWinner () method in Player.java , sure he rewards the winning clan.
method:
public Clan rewardClanWinner()
{
for (Player player : getClan().getOnlineMembers())
{
if (player.isClanLeader())
{
for (IntIntHolder reward : Config.LEADER_REWARD_WINNER_SIEGE_CLAN)
player.addItem("", reward.getId(), reward.getValue(), player, true);
}
else
{
for (IntIntHolder reward : Config.REWARD_WINNER_SIEGE_CLAN)
player.addItem("", reward.getId(), reward.getValue(), player, true);
}
}
return _clan;
}
After finishing the siege, I made a restriction of the same IP plus the 2 players of the same ip wins the item, what did I do wrong?
method created for SiegeEnd ()
// Reward Clan winner
getRewardClanWinner();
private static final Map<String, Integer> _playerIps = new ConcurrentHashMap<>();
public void getRewardClanWinner()
{
for (Player player : World.getInstance().getPlayers())
{
String pIp = player.getClient().getConnection().getInetAddress().getHostAddress();
if (!_playerIps.containsKey(pIp))
{
_playerIps.put(pIp, 1);
player.rewardClanWinner().setCastle(getCastle().getOwnerId());
}
else
{
int count = _playerIps.get(pIp);
if (count < 1)
{
_playerIps.remove(pIp);
_playerIps.put(pIp, count + 1);
player.rewardClanWinner().setCastle(getCastle().getOwnerId());
}
else
player.sendMessage("Already 1 character(s) of your ip have been rewarded, so this character won't be rewarded.");
}
}
}
It does not only reward one as I write in the code.
2 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now