Merge remote-tracking branch 'refs/remotes/origin/develop' into update/skywars-finalised

This commit is contained in:
Sam 2016-07-16 21:22:57 +01:00
commit e2af4df44b
2 changed files with 42 additions and 34 deletions

View File

@ -73,7 +73,6 @@ import nautilus.game.arcade.command.GameCommand;
import nautilus.game.arcade.command.KitUnlockCommand;
import nautilus.game.arcade.command.RequiredRankCommand;
import nautilus.game.arcade.command.WriteCommand;
import nautilus.game.arcade.command.*;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
@ -91,7 +90,6 @@ import org.bukkit.*;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Chest;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
@ -147,7 +145,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Managers
private GameCreationManager _gameCreationManager;
private GameGemManager _gameGemManager;
private GameRewardManager _gameRewardManager;
private GameManager _gameManager;
private GameLobbyManager _gameLobbyManager;
private GamePlayerManager _gamePlayerManager;
@ -279,7 +277,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
// Managers
_gameChatManager = new GameChatManager(this);
_gameCreationManager = new GameCreationManager(this);
_gameGemManager = new GameGemManager(this);
_gameRewardManager = new GameRewardManager(this);
_gameManager = new GameManager(this);
_gameLobbyManager = new GameLobbyManager(this, packetHandler);
_gameHostManager = new GameHostManager(this);
@ -510,9 +508,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return _gameManager;
}
public GameGemManager GetGameGemManager()
public GameRewardManager GetGameGemManager()
{
return _gameGemManager;
return _gameRewardManager;
}
public GamePlayerManager GetGamePlayerManager()

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.managers;
import java.lang.reflect.Field;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
@ -37,14 +38,17 @@ import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.GemData;
import net.minecraft.server.v1_8_R3.EntityHuman;
public class GameGemManager implements Listener
/**
* This class is used to reward gems and shards at the end of a game, or when players leave the server.
*/
public class GameRewardManager implements Listener
{
ArcadeManager Manager;
boolean DoubleGem = false;
boolean TimeReward = true;
public GameGemManager(ArcadeManager manager)
public GameRewardManager(ArcadeManager manager)
{
Manager = manager;
@ -159,17 +163,22 @@ public class GameGemManager implements Listener
if (gems == null)
return;
int earned = 0;
final int baseGemsEarned;
int gemsToReward;
// Calculate the base gems earned in this game
{
int gemsEarned = 0;
for (GemData data : gems.values())
earned += (int)data.Gems;
gemsEarned += (int) data.Gems;
if (earned <= 0)
earned = 1;
if (gemsEarned <= 0)
gemsEarned = 1;
earned = (int) (earned * gameMult);
int total = earned;
baseGemsEarned = (int) (gemsEarned * gameMult);
gemsToReward = baseGemsEarned;
}
String oldName = player.getName();
@ -179,27 +188,28 @@ public class GameGemManager implements Listener
System.out.println("Gems for " + Manager.GetClients().Get(player).GetPlayerName());
}
final int baseShards = total;
int shards = baseShards;
// Award players shards equal to base gems, plus booster bonuses.
final int baseShardsEarned = baseGemsEarned;
int shardsToReward = baseShardsEarned;
//Gem Boooster
// Gem Boooster
Booster booster = Manager.getBoosterManager().getActiveBooster();
if (game.GemBoosterEnabled && booster != null)
{
shards += baseShards * booster.getMultiplier();
shardsToReward *= booster.getMultiplier();
}
//Gem Finder
// Gem Finder
if (game.GemHunterEnabled)
{
int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel();
if (gemFinder > 0)
{
total += (int)(earned * (gemFinder * 0.25));
gemsToReward += (int)(baseGemsEarned * (gemFinder * 0.25));
}
}
//Time Reward
// Time Reward
if (TimeReward)
{
long timeOnline = Utility.currentTimeMillis() - Manager.GetClients().Get(player).getNetworkSessionLoginTime();
@ -211,34 +221,34 @@ public class GameGemManager implements Listener
if (hoursOnline > 5)
hoursOnline = 5;
total += (int)(earned * (hoursOnline * 0.2));
gemsToReward += (int)(baseGemsEarned * (hoursOnline * 0.2));
}
}
if (DoubleGem && game.GemDoubleEnabled)
total += earned;
gemsToReward += baseGemsEarned;
Rank rank = Manager.GetClients().Get(player).GetRank();
int accountId = Manager.GetClients().getAccountId(player);
if (rank == rank.ULTRA)
shards += baseShards * 0.5;
shardsToReward += baseShardsEarned * 0.5;
else if (rank == rank.HERO)
shards += baseShards * 1;
shardsToReward += baseShardsEarned * 1;
else if (rank == rank.LEGEND)
shards += baseShards * 1.5;
shardsToReward += baseShardsEarned * 1.5;
else if (rank.has(Rank.TITAN))
shards += baseShards * 2;
shardsToReward += baseShardsEarned * 2;
Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), player.getUniqueId(), total);
Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), player.getUniqueId(), gemsToReward);
if (accountId != -1)
{
Manager.GetDonation().rewardCoinsUntilSuccess(null, "Earned", player.getName(), accountId, shards);
Manager.GetDonation().rewardCoinsUntilSuccess(null, "Earned", player.getName(), accountId, shardsToReward);
}
//Stats
Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", total);
Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", total);
Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", gemsToReward);
Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", gemsToReward);
if(Manager.GetClients().Get(player).getDisguisedAs() != null)
{
@ -359,7 +369,7 @@ public class GameGemManager implements Listener
totalGems += earnedGems;
}
final int baseShards = totalGems;
final int baseShards = earnedGems;
int shards = baseShards;
double extraMult = 0;