Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

Conflicts:
	Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java
This commit is contained in:
Jonathan Williams 2014-08-08 02:07:20 -05:00
commit e1be732202
17 changed files with 523 additions and 98 deletions

View File

@ -0,0 +1,58 @@
package mineplex.core.achievement;
public enum Achievement
{
GLOBAL_GEM_HUNTER("Gem Hunter", new String[] {"Global.GemsEarned"}, new int[] {10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000}),
GAME_SPLEEF_SMASHER("Spleef Smasher", new String[] {"Super Spleef.BlocksBroken"}, new int[] {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200});
private String _name;
private String[] _stats;
private int[] _levels;
Achievement(String name, String[] stats, int[] levels)
{
_name = name;
_stats = stats;
_levels = levels;
}
public String getName()
{
return _name;
}
public String[] getStats()
{
return _stats;
}
public int[] getLevels()
{
return _levels;
}
public int getMaxLevel()
{
return _levels.length;
}
public AchivementData getLevelData(int exp)
{
for (int i=0 ; i<_levels.length ; i++)
{
int req = _levels[i];
//Has Experience, Level Up!
if (exp >= req)
{
exp -= req;
continue;
}
return new AchivementData(i, exp, req);
}
return new AchivementData(getMaxLevel(), -1, -1);
}
}

View File

@ -0,0 +1,13 @@
package mineplex.core.achievement;
public class AchievementLog
{
public int Amount;
public boolean LevelUp;
public AchievementLog(int amount, boolean levelUp)
{
Amount = amount;
LevelUp = levelUp;
}
}

View File

@ -0,0 +1,111 @@
package mineplex.core.achievement;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.stats.StatsManager;
import mineplex.core.stats.event.StatChangeEvent;
public class AchievementManager extends MiniPlugin
{
private StatsManager _statsManager;
private NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<String, NautHashMap<Achievement, AchievementLog>>();
public AchievementManager(StatsManager statsManager)
{
super("Achievement Manager", statsManager.GetPlugin());
_statsManager = statsManager;
}
public AchivementData get(Player player, Achievement type)
{
return get(player.getName(), type);
}
public AchivementData get(String playerName, Achievement type)
{
int exp = 0;
for (String stat : type.getStats())
{
exp += _statsManager.Get(playerName).getStat(stat);
}
return type.getLevelData(exp);
}
@EventHandler
public void informLevelUp(StatChangeEvent event)
{
Player player = UtilPlayer.searchExact(event.getPlayerName());
if (player == null)
return;
for (Achievement type : Achievement.values())
{
for (String stat : type.getStats())
{
if (stat.equalsIgnoreCase(event.getStatName()))
{
if (!_log.containsKey(player.getName()))
_log.put(player.getName(), new NautHashMap<Achievement, AchievementLog>());
//Record that achievement has leveled up
if (type.getLevelData(event.getValueAfter()).getLevel() > type.getLevelData(event.getValueBefore()).getLevel())
{
//Add new
if (!_log.get(player.getName()).containsKey(type))
{
_log.get(player.getName()).put(type, new AchievementLog(event.getValueAfter() - event.getValueBefore(), true));
}
//Edit previous
else
{
AchievementLog log = _log.get(player.getName()).get(type);
log.Amount += event.getValueAfter() - event.getValueBefore();
log.LevelUp = true;
}
}
//Record that there has been changes in this Achievement
else if (!_log.get(player.getName()).containsKey(type))
{
//Add new
if (!_log.get(player.getName()).containsKey(type))
{
_log.get(player.getName()).put(type, new AchievementLog(event.getValueAfter() - event.getValueBefore(), false));
}
//Edit previous
else
{
AchievementLog log = _log.get(player.getName()).get(type);
log.Amount += event.getValueAfter() - event.getValueBefore();
}
}
}
}
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_log.remove(event.getPlayer().getName());
}
public void clearLog(Player player)
{
_log.remove(player.getName());
}
public NautHashMap<Achievement, AchievementLog> getLog(Player player)
{
return _log.remove(player.getName());
}
}

View File

@ -0,0 +1,30 @@
package mineplex.core.achievement;
public class AchivementData
{
private int _level;
private int _expRemainder;
private int _expNextLevel;
public AchivementData(int level, int expRemainder, int expNextLevel)
{
_level = level;
_expRemainder = expRemainder;
_expNextLevel = expNextLevel;
}
public int getLevel()
{
return _level;
}
public int getExpRemainder()
{
return _expRemainder;
}
public int getExpNextLevel()
{
return _expNextLevel;
}
}

View File

@ -8,7 +8,7 @@ public class PlayerStats
{
private NautHashMap<String, Integer> _statHash = new NautHashMap<String, Integer>();
public void addStat(String statName, int value)
public int addStat(String statName, int value)
{
if (!_statHash.containsKey(statName))
{
@ -16,6 +16,8 @@ public class PlayerStats
}
_statHash.put(statName, _statHash.get(statName) + value);
return _statHash.get(statName);
}
public int getStat(String statName)

View File

@ -10,6 +10,8 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilServer;
import mineplex.core.stats.event.StatChangeEvent;
public class StatsManager extends MiniClientPlugin<PlayerStats>
{
@ -48,7 +50,12 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
public void incrementStat(Player player, final String statName, int value)
{
Get(player).addStat(statName, Get(player).getStat(statName) + value);
int newValue = Get(player).addStat(statName, Get(player).getStat(statName) + value);
System.out.println(player.getName() + " - " + statName + " - " + value + " ? " + newValue);
//Event
UtilServer.getServer().getPluginManager().callEvent(new StatChangeEvent(player.getName(), statName, newValue - value, newValue));
String uuidString = player.getUniqueId().toString();
@ -64,7 +71,7 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
_statUploadQueue.get(uuidString).put(statName, 0);
}
_statUploadQueue.get(uuidString).put(statName, _statUploadQueue.get(uuidString).get(statName) + value);
_statUploadQueue.get(uuidString).put(statName, value);
}
// Verify stat is in our local cache, if not add it remotely.

View File

@ -19,8 +19,7 @@ public class StatsRepository extends RepositoryBase
private static String CREATE_STAT_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountStats (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), UNIQUE INDEX accountStatIndex (accountId, statId));";
private static String RETRIEVE_PLAYER_STATS = "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = ?;";
private static String INSERT_PLAYER_STAT = "INSERT INTO accountStats (accountId, statId, value) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE value= value + VALUES(value);";
private static String INSERT_PLAYER_STAT = "INSERT INTO accountStats (accountId, statId, value) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE value=value+VALUES(value);";
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";

View File

@ -0,0 +1,54 @@
package mineplex.core.stats.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class StatChangeEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private String _player;
private String _statName;
private int _valueBefore;
private int _valueAfter;
public StatChangeEvent(String player, String statName, int valueBefore, int valueAfter)
{
_player = player;
_statName = statName;
_valueBefore = valueBefore;
_valueAfter = valueAfter;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public String getPlayerName()
{
return _player;
}
public String getStatName()
{
return _statName;
}
public int getValueBefore()
{
return _valueBefore;
}
public int getValueAfter()
{
return _valueAfter;
}
}

View File

@ -47,6 +47,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -551,7 +552,15 @@ public class HubManager extends MiniClientPlugin<HubClient>
{
if (event.isCancelled())
return;
//Dont Let Chat Near Spawn!
if (UtilMath.offset(GetSpawn(), event.getPlayer().getLocation()) < 4)
{
UtilPlayer.message(event.getPlayer(), F.main("Chat", "You must leave spawn before you can chat!"));
event.setCancelled(true);
return;
}
Player player = event.getPlayer();
Rank rank = GetClients().Get(player).GetRank();

View File

@ -52,6 +52,7 @@ import mineplex.minecraft.game.core.fire.Fire;
import mineplex.core.MiniPlugin;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antistack.AntiStack;
import mineplex.core.blockrestore.BlockRestore;
@ -102,10 +103,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private GameGemManager _gameGemManager;
private GameManager _gameManager;
private GameLobbyManager _gameLobbyManager;
private GameStatsManager _gameStatsManager;
private GameWorldManager _gameWorldManager;
private ServerStatusManager _serverStatusManager;
private AchievementManager _achievementManager;
private StatsManager _statsManager;
private ClassManager _classManager;
private SkillFactory _skillFactory;
@ -197,7 +198,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_eloManager = new EloManager(_plugin);
}
// _statsManager = new StatsManager(plugin);
_statsManager = new StatsManager(plugin);
_achievementManager = new AchievementManager(_statsManager);
_portal = portal;
@ -215,7 +217,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_gameLobbyManager = new GameLobbyManager(this, packetHandler);
new GameFlagManager(this);
new GamePlayerManager(this);
_gameStatsManager = new GameStatsManager(this);
new GameAchievementManager(this);
_gameWorldManager = new GameWorldManager(this);
_miscManager = new MiscManager(this);
new IdleManager(this);
@ -242,6 +244,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return GetServerConfig().GameList;
}
public AchievementManager GetAchievement()
{
return _achievementManager;
}
public AntiStack GetAntiStack()
{
@ -333,11 +340,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return _arcadeShop;
}
public GameStatsManager GetStats()
{
return _gameStatsManager;
}
public GameCreationManager GetGameCreationManager()
{
return _gameCreationManager;

View File

@ -94,8 +94,11 @@ public abstract class Game implements Listener
//Player Preferences
protected NautHashMap<Player, Kit> _playerKit = new NautHashMap<Player, Kit>();
private NautHashMap<GameTeam, ArrayList<Player>> _teamPreference = new NautHashMap<GameTeam, ArrayList<Player>>();
private NautHashMap<Player, HashMap<String,GemData>> _gemCount = new NautHashMap<Player, HashMap<String,GemData>>();
//Player Data
private NautHashMap<Player, HashMap<String,GemData>> _gemCount = new NautHashMap<Player, HashMap<String,GemData>>();
private NautHashMap<Player, HashMap<String,Integer>> _stats = new NautHashMap<Player, HashMap<String,Integer>>();
//Player Location Store
private NautHashMap<String, Location> _playerLocationStore = new NautHashMap<String, Location>();
@ -207,6 +210,8 @@ public abstract class Game implements Listener
public boolean EloRanking = false;
public int EloStart = 1000;
public ArrayList<String> GemBoosters = new ArrayList<String>();
public Game(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc)
{
@ -1040,4 +1045,55 @@ public abstract class Game implements Listener
{
SetState(GameState.End);
}
public void AddGemBooster(Player player)
{
if (GemBoosters.size() >= 4)
{
UtilPlayer.message(player, F.main("Game", "Games cannot have more than " + F.elem("4 Gem Boosters")) + ".");
return;
}
if (GemBoosters.contains(player.getName()))
{
UtilPlayer.message(player, F.main("Game", "You can only use " + F.elem("1 Gem Booster")) + " per game.");
return;
}
Announce(F.elem(player.getName()) + " used a " + F.elem(C.cGreen + "Gem Booster") + " for " + F.elem("+" + (100-(GemBoosters.size()*25)) + "% Gems") + "!");
GemBoosters.add(player.getName());
}
public double GetGemBoostAmount()
{
if (GemBoosters.size() == 1) return 1;
if (GemBoosters.size() == 2) return 1.75;
if (GemBoosters.size() == 3) return 2.25;
if (GemBoosters.size() == 4) return 2.5;
return 0;
}
public void AddStat(Player player, String stat, int amount, boolean global)
{
if (!_stats.containsKey(player))
_stats.put(player, new HashMap<String, Integer>());
if (global)
stat = "Global." + stat;
else
stat = GetName() + "." + stat;
int past = 0;
if (_stats.get(player).containsKey(stat))
past = _stats.get(player).get(stat);
_stats.get(player).put(stat, past + amount);
}
public NautHashMap<Player, HashMap<String, Integer>> GetStats()
{
return _stats;
}
}

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.spleef;
import java.lang.reflect.Field;
import java.util.HashMap;
import org.bukkit.Effect;
import org.bukkit.block.Block;
@ -133,6 +134,8 @@ public class Spleef extends SoloGame
public void BlockFade(Block block, Player player)
{
AddStat(player, "BlocksBroken", 1, false);
UtilPlayer.hunger(player, 1);
//Wool and Stained Clay

View File

@ -2,8 +2,9 @@ package nautilus.game.arcade.managers;
import java.util.HashMap;
import mineplex.core.common.Rank;
import mineplex.core.achievement.Achievement;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -29,13 +30,13 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class GameGemManager implements Listener
{
ArcadeManager Manager;
boolean DoubleGem = false;
public GameGemManager(ArcadeManager manager)
{
Manager = manager;
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin());
}
@ -44,13 +45,13 @@ public class GameGemManager implements Listener
{
if (Manager.IsTournamentServer())
return;
Game game = Manager.GetGame();
if (game == null) return;
if (!(event.GetEvent().getEntity() instanceof Player))
return;
Player killed = (Player)event.GetEvent().getEntity();
if (event.GetLog().GetKiller() != null)
@ -86,43 +87,43 @@ public class GameGemManager implements Listener
game.AddGems(assist, game.GetKillsGems(assist, killed, true), "Kill Assists", true);
}
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
if (Manager.IsTournamentServer())
return;
Game game = Manager.GetGame();
if (game == null) return;
RewardGems(game, event.getPlayer(), true);
}
@EventHandler(priority = EventPriority.MONITOR)
public void PlayerStateChange(PlayerStateChangeEvent event)
{
if (Manager.IsTournamentServer())
return;
if (event.GetState() != PlayerState.OUT)
return;
if (event.GetGame().GetType() == GameType.Paintball)
return;
RewardGems(event.GetGame(), event.GetPlayer(), false);
}
@EventHandler
@EventHandler(priority = EventPriority.MONITOR)
public void GameStateChange(GameStateChangeEvent event)
{
if (Manager.IsTournamentServer())
return;
if (event.GetState() != GameState.Dead)
return;
for (Player player : UtilServer.getPlayers())
RewardGems(event.GetGame(), player, true);
}
@ -131,63 +132,71 @@ public class GameGemManager implements Listener
{
if (Manager.IsTournamentServer())
return;
//Inform Gems
AnnounceGems(game, player, game.GetPlayerGems().get(player), give);
//Give Gems
if (give)
GiveGems(game, player, game.GetPlayerGems().remove(player), game.GemMultiplier);
}
public void GiveGems(Game game, Player player, HashMap<String,GemData> gems, double gameMult)
{
if (Manager.IsTournamentServer())
return;
if (gems == null)
return;
int total = 0;
int earned = 0;
for (GemData data : gems.values())
total += (int)data.Gems;
earned += (int)data.Gems;
if (total <= 0)
total = 1;
if (earned <= 0)
earned = 1;
/*
if (Manager.GetClients().Get(player).GetRank().Has(Rank.HERO))
total = total * 3;
else if (Manager.GetClients().Get(player).GetRank().Has(Rank.ULTRA) || Manager.GetDonation().Get(player.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"))
total = total * 2;
*/
earned = (int) (earned * gameMult);
int total = earned;
//Gem Boooster
total += (int)(earned * game.GetGemBoostAmount());
//Gem Finder
int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel();
if (gemFinder > 0)
{
total += (int)(earned * (gemFinder * 0.25));
}
if (DoubleGem)
total = total * 2;
total = (int) (total * gameMult);
total += earned;
Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), total);
//Stats
Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", total);
Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", total);
}
public void AnnounceGems(Game game, Player player, HashMap<String,GemData> gems, boolean give)
public void AnnounceGems(Game game, Player player, HashMap<String,GemData> gems, boolean give)
{
if (Manager.IsTournamentServer())
return;
if (gems == null)
return;
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
UtilPlayer.message(player, "");
UtilPlayer.message(player, ArcadeFormat.Line);
UtilPlayer.message(player, "§aGame - §f§l" + game.GetName());
UtilPlayer.message(player, "§f§lGems Earned");
UtilPlayer.message(player, "");
int earnedGems = 0;
for (String type : gems.keySet())
@ -197,7 +206,7 @@ public class GameGemManager implements Listener
gemCount = 1;
earnedGems += gemCount;
int amount = gems.get(type).Amount;
String amountStr = "";
if (amount > 0)
@ -205,43 +214,54 @@ public class GameGemManager implements Listener
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(gemCount * game.GemMultiplier) + " Gems") + " for " + F.elem(amountStr + type));
}
earnedGems = (int) (earnedGems * game.GemMultiplier);
//Hero / Ultra Boost
/*
if (Manager.GetClients().Get(player).GetRank().Has(Rank.HERO))
int totalGems = earnedGems;
//Gem Booster
if (game.GetGemBoostAmount() > 0)
{
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems*2) + " Gems") + " for " + F.elem(C.cPurple + "Hero Rank 3x Gems"));
earnedGems = earnedGems * 3;
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(earnedGems*game.GetGemBoostAmount()) + " Gems") + " for " +
F.elem(game.GemBoosters.size() + " Gem Boosters " + C.cGreen + "+" + (int)(game.GetGemBoostAmount()*100) + "%"));
totalGems += earnedGems * game.GetGemBoostAmount();
}
else if (Manager.GetClients().Get(player).GetRank().Has(Rank.ULTRA) || Manager.GetDonation().Get(player.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"))
//Gem Finder
int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel();
if (gemFinder > 0)
{
UtilPlayer.message(player, F.elem(C.cGreen + "+" + earnedGems + " Gems") + " for " + F.elem(C.cAqua + "Ultra Rank 2x Gems"));
earnedGems = earnedGems * 2;
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems*(gemFinder * 0.25) + " Gems") + " for " +
F.elem("Gem Finder " + gemFinder + " (+" + (gemFinder*25) + "%)")));
totalGems += earnedGems * (gemFinder * 0.25);
}
*/
//Double Gem
if (DoubleGem)
{
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Weekend"));
earnedGems = earnedGems * 2;
totalGems += earnedGems;
}
//Inform
UtilPlayer.message(player, "");
if (give)
{
UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " +
C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getName()).GetGems() + earnedGems) + " Gems"));
C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getName()).GetGems() + totalGems) + " Gems"));
}
else
{
UtilPlayer.message(player, F.elem(C.cWhite + "§lGame is still in progress..."));
UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + C.cGreen + C.Bold + "Gems" + C.cWhite + C.Bold + " when its completed."));
}
UtilPlayer.message(player, ArcadeFormat.Line);
}
}

View File

@ -29,7 +29,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
@ -41,12 +44,14 @@ import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilText.TextAlign;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.donation.Donor;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
@ -720,9 +725,9 @@ public class GameLobbyManager implements IPacketRunnable, Listener
if (_advertiseStage == 0)
{
WriteAdvertiseLine("MINEPLEX ULTRA RANK", 0, 159, (byte)4);
WriteAdvertiseLine("UNLOCKS EVERYTHING", 1, 159, (byte)15);
WriteAdvertiseLine("IN EVERY GAME", 2, 159, (byte)15);
WriteAdvertiseLine("GET MINEPLEX ULTRA", 0, 159, (byte)4);
WriteAdvertiseLine("FOR AMAZING", 1, 159, (byte)15);
WriteAdvertiseLine("FUN TIMES", 2, 159, (byte)15);
WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte)15);
}
@ -1104,4 +1109,64 @@ public class GameLobbyManager implements IPacketRunnable, Listener
}
}
}
@EventHandler
public void GemBoosterUpdate(UpdateEvent event)
{
if (Manager.IsTournamentServer())
return;
if (event.getType() != UpdateType.SEC)
return;
if (Manager.GetGame() == null)
return;
if (Manager.GetGame().GetState() != GameState.Recruit)
return;
for (Player player : UtilServer.getPlayers())
{
if (!player.getInventory().contains(Material.EMERALD))
{
player.getInventory().setItem(
7,
ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, (short) 0, C.cGreen
+ "Gem Booster", new String[] { "", ChatColor.RESET + "Boosts Gems earned for",
ChatColor.RESET + "everyone in the game." }));
}
for (int i : player.getInventory().all(Material.EMERALD).keySet())
{
ItemStack stack = player.getInventory().getItem(i);
ItemMeta itemMeta = stack.getItemMeta();
itemMeta.setDisplayName(C.cGreen + "Gem Booster" +
" " + C.cWhite + "Click for " + (100-Manager.GetGame().GemBoosters.size()*25) + "% Boost");
stack.setItemMeta(itemMeta);
player.getInventory().setItem(i, stack);
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void HubClockInteract(PlayerInteractEvent event)
{
if (Manager.IsTournamentServer())
return;
Player player = event.getPlayer();
if (player.getItemInHand() == null)
return;
if (player.getItemInHand().getType() != Material.EMERALD)
return;
if (Manager.GetGame() == null)
return;
Manager.GetGame().AddGemBooster(player);
}
}

View File

@ -249,6 +249,21 @@ public class GameManager implements Listener
event.GetGame().DeregisterKits();
}
@EventHandler
public void StatRegister(GameStateChangeEvent event)
{
if (event.GetState() != GameState.End)
return;
for (Player player : event.GetGame().GetStats().keySet())
{
for (String stat : event.GetGame().GetStats().get(player).keySet())
{
Manager.GetStatsManager().incrementStat(player, stat, event.GetGame().GetStats().get(player).get(stat));
}
}
}
@EventHandler(priority = EventPriority.LOWEST) //BEFORE PARSE DATA
public void TeamGeneration(GameStateChangeEvent event)

View File

@ -1,19 +0,0 @@
package nautilus.game.arcade.managers;
import nautilus.game.arcade.ArcadeManager;
import org.bukkit.event.Listener;
public class GameStatsManager implements Listener
{
ArcadeManager Manager;
public GameStatsManager(ArcadeManager manager)
{
Manager = manager;
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin());
}
}

View File

@ -17,7 +17,7 @@ import org.bukkit.event.world.ChunkUnloadEvent;
public class GameWorldManager implements Listener
{
ArcadeManager Manager;
private HashSet<WorldData> _worldLoader = new HashSet<WorldData>();
public GameWorldManager(ArcadeManager manager)
@ -32,7 +32,7 @@ public class GameWorldManager implements Listener
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<WorldData> worldIterator = _worldLoader.iterator();
long endTime = System.currentTimeMillis() + 25;