Merge remote-tracking branch 'refs/remotes/origin/develop' into update/skywars-finalised
This commit is contained in:
commit
e2af4df44b
@ -73,7 +73,6 @@ import nautilus.game.arcade.command.GameCommand;
|
|||||||
import nautilus.game.arcade.command.KitUnlockCommand;
|
import nautilus.game.arcade.command.KitUnlockCommand;
|
||||||
import nautilus.game.arcade.command.RequiredRankCommand;
|
import nautilus.game.arcade.command.RequiredRankCommand;
|
||||||
import nautilus.game.arcade.command.WriteCommand;
|
import nautilus.game.arcade.command.WriteCommand;
|
||||||
import nautilus.game.arcade.command.*;
|
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.Game;
|
import nautilus.game.arcade.game.Game;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
@ -91,7 +90,6 @@ import org.bukkit.*;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
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.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -147,7 +145,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
|
|
||||||
// Managers
|
// Managers
|
||||||
private GameCreationManager _gameCreationManager;
|
private GameCreationManager _gameCreationManager;
|
||||||
private GameGemManager _gameGemManager;
|
private GameRewardManager _gameRewardManager;
|
||||||
private GameManager _gameManager;
|
private GameManager _gameManager;
|
||||||
private GameLobbyManager _gameLobbyManager;
|
private GameLobbyManager _gameLobbyManager;
|
||||||
private GamePlayerManager _gamePlayerManager;
|
private GamePlayerManager _gamePlayerManager;
|
||||||
@ -279,7 +277,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
// Managers
|
// Managers
|
||||||
_gameChatManager = new GameChatManager(this);
|
_gameChatManager = new GameChatManager(this);
|
||||||
_gameCreationManager = new GameCreationManager(this);
|
_gameCreationManager = new GameCreationManager(this);
|
||||||
_gameGemManager = new GameGemManager(this);
|
_gameRewardManager = new GameRewardManager(this);
|
||||||
_gameManager = new GameManager(this);
|
_gameManager = new GameManager(this);
|
||||||
_gameLobbyManager = new GameLobbyManager(this, packetHandler);
|
_gameLobbyManager = new GameLobbyManager(this, packetHandler);
|
||||||
_gameHostManager = new GameHostManager(this);
|
_gameHostManager = new GameHostManager(this);
|
||||||
@ -510,9 +508,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
|||||||
return _gameManager;
|
return _gameManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameGemManager GetGameGemManager()
|
public GameRewardManager GetGameGemManager()
|
||||||
{
|
{
|
||||||
return _gameGemManager;
|
return _gameRewardManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GamePlayerManager GetGamePlayerManager()
|
public GamePlayerManager GetGamePlayerManager()
|
||||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.managers;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
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 nautilus.game.arcade.game.GemData;
|
||||||
import net.minecraft.server.v1_8_R3.EntityHuman;
|
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;
|
ArcadeManager Manager;
|
||||||
|
|
||||||
boolean DoubleGem = false;
|
boolean DoubleGem = false;
|
||||||
boolean TimeReward = true;
|
boolean TimeReward = true;
|
||||||
|
|
||||||
public GameGemManager(ArcadeManager manager)
|
public GameRewardManager(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
Manager = manager;
|
Manager = manager;
|
||||||
|
|
||||||
@ -159,17 +163,22 @@ public class GameGemManager implements Listener
|
|||||||
if (gems == null)
|
if (gems == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int earned = 0;
|
final int baseGemsEarned;
|
||||||
|
int gemsToReward;
|
||||||
|
|
||||||
for (GemData data : gems.values())
|
// Calculate the base gems earned in this game
|
||||||
earned += (int)data.Gems;
|
{
|
||||||
|
int gemsEarned = 0;
|
||||||
|
|
||||||
if (earned <= 0)
|
for (GemData data : gems.values())
|
||||||
earned = 1;
|
gemsEarned += (int) data.Gems;
|
||||||
|
|
||||||
earned = (int) (earned * gameMult);
|
if (gemsEarned <= 0)
|
||||||
|
gemsEarned = 1;
|
||||||
|
|
||||||
int total = earned;
|
baseGemsEarned = (int) (gemsEarned * gameMult);
|
||||||
|
gemsToReward = baseGemsEarned;
|
||||||
|
}
|
||||||
|
|
||||||
String oldName = player.getName();
|
String oldName = player.getName();
|
||||||
|
|
||||||
@ -179,27 +188,28 @@ public class GameGemManager implements Listener
|
|||||||
System.out.println("Gems for " + Manager.GetClients().Get(player).GetPlayerName());
|
System.out.println("Gems for " + Manager.GetClients().Get(player).GetPlayerName());
|
||||||
}
|
}
|
||||||
|
|
||||||
final int baseShards = total;
|
// Award players shards equal to base gems, plus booster bonuses.
|
||||||
int shards = baseShards;
|
final int baseShardsEarned = baseGemsEarned;
|
||||||
|
int shardsToReward = baseShardsEarned;
|
||||||
|
|
||||||
//Gem Boooster
|
// Gem Boooster
|
||||||
Booster booster = Manager.getBoosterManager().getActiveBooster();
|
Booster booster = Manager.getBoosterManager().getActiveBooster();
|
||||||
if (game.GemBoosterEnabled && booster != null)
|
if (game.GemBoosterEnabled && booster != null)
|
||||||
{
|
{
|
||||||
shards += baseShards * booster.getMultiplier();
|
shardsToReward *= booster.getMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gem Finder
|
// Gem Finder
|
||||||
if (game.GemHunterEnabled)
|
if (game.GemHunterEnabled)
|
||||||
{
|
{
|
||||||
int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel();
|
int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel();
|
||||||
if (gemFinder > 0)
|
if (gemFinder > 0)
|
||||||
{
|
{
|
||||||
total += (int)(earned * (gemFinder * 0.25));
|
gemsToReward += (int)(baseGemsEarned * (gemFinder * 0.25));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Time Reward
|
// Time Reward
|
||||||
if (TimeReward)
|
if (TimeReward)
|
||||||
{
|
{
|
||||||
long timeOnline = Utility.currentTimeMillis() - Manager.GetClients().Get(player).getNetworkSessionLoginTime();
|
long timeOnline = Utility.currentTimeMillis() - Manager.GetClients().Get(player).getNetworkSessionLoginTime();
|
||||||
@ -211,34 +221,34 @@ public class GameGemManager implements Listener
|
|||||||
if (hoursOnline > 5)
|
if (hoursOnline > 5)
|
||||||
hoursOnline = 5;
|
hoursOnline = 5;
|
||||||
|
|
||||||
total += (int)(earned * (hoursOnline * 0.2));
|
gemsToReward += (int)(baseGemsEarned * (hoursOnline * 0.2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DoubleGem && game.GemDoubleEnabled)
|
if (DoubleGem && game.GemDoubleEnabled)
|
||||||
total += earned;
|
gemsToReward += baseGemsEarned;
|
||||||
|
|
||||||
Rank rank = Manager.GetClients().Get(player).GetRank();
|
Rank rank = Manager.GetClients().Get(player).GetRank();
|
||||||
int accountId = Manager.GetClients().getAccountId(player);
|
int accountId = Manager.GetClients().getAccountId(player);
|
||||||
|
|
||||||
if (rank == rank.ULTRA)
|
if (rank == rank.ULTRA)
|
||||||
shards += baseShards * 0.5;
|
shardsToReward += baseShardsEarned * 0.5;
|
||||||
else if (rank == rank.HERO)
|
else if (rank == rank.HERO)
|
||||||
shards += baseShards * 1;
|
shardsToReward += baseShardsEarned * 1;
|
||||||
else if (rank == rank.LEGEND)
|
else if (rank == rank.LEGEND)
|
||||||
shards += baseShards * 1.5;
|
shardsToReward += baseShardsEarned * 1.5;
|
||||||
else if (rank.has(Rank.TITAN))
|
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)
|
if (accountId != -1)
|
||||||
{
|
{
|
||||||
Manager.GetDonation().rewardCoinsUntilSuccess(null, "Earned", player.getName(), accountId, shards);
|
Manager.GetDonation().rewardCoinsUntilSuccess(null, "Earned", player.getName(), accountId, shardsToReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Stats
|
//Stats
|
||||||
Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", total);
|
Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", gemsToReward);
|
||||||
Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", total);
|
Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", gemsToReward);
|
||||||
|
|
||||||
if(Manager.GetClients().Get(player).getDisguisedAs() != null)
|
if(Manager.GetClients().Get(player).getDisguisedAs() != null)
|
||||||
{
|
{
|
||||||
@ -359,7 +369,7 @@ public class GameGemManager implements Listener
|
|||||||
totalGems += earnedGems;
|
totalGems += earnedGems;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int baseShards = totalGems;
|
final int baseShards = earnedGems;
|
||||||
int shards = baseShards;
|
int shards = baseShards;
|
||||||
double extraMult = 0;
|
double extraMult = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user