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

Conflicts:
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java
This commit is contained in:
Chiss 2014-06-10 13:02:17 +10:00
commit 661a869116
24 changed files with 532 additions and 21 deletions

View File

@ -85,7 +85,7 @@ public class UtilInv
public static void Clear(Player player) public static void Clear(Player player)
{ {
player.getOpenInventory().close(); //player.getOpenInventory().close();
PlayerInventory inv = player.getInventory(); PlayerInventory inv = player.getInventory();

View File

@ -0,0 +1,64 @@
package mineplex.core.simpleStats;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class SimpleStats extends MiniPlugin
{
private static Object _transferLock = new Object();
private SimpleStatsRepository _repository = new SimpleStatsRepository();
private NautHashMap<String, String> _entries = new NautHashMap<String, String>();
public SimpleStats(JavaPlugin plugin)
{
super("SimpleStats", plugin);
_repository.initialize();
}
public NautHashMap<String, String> get_entries() {
return _entries;
}
@EventHandler
public void storeStatsUpdate(final UpdateEvent updateEvent)
{
if (updateEvent.getType() != UpdateType.SLOW)
return;
synchronized (_transferLock)
{
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
{
_entries = (_repository.retrieveStatRecords());
}
});
}
}
public void store(String statName, String statValue)
{
final String statNameFinal = statName;
final String statValueFinal = statValue;
synchronized (_transferLock)
{
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
{
_repository.storeStatValue(statNameFinal, statValueFinal);
}
});
}
}
}

View File

@ -0,0 +1,158 @@
package mineplex.core.simpleStats;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import mineplex.core.common.util.NautHashMap;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class SimpleStatsRepository
{
private static Object _connectionLock = new Object();
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/Queue?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh"; //try to obfuscate this in the future!
private static String CREATE_STATS_TABLE = "CREATE TABLE IF NOT EXISTS simpleStats (id INT NOT NULL AUTO_INCREMENT, statName VARCHAR(64), statValue VARCHAR(64), PRIMARY KEY (id));";
private static String RETRIEVE_STATS_RECORDS = "SELECT statName.*, statValue.* FROM simpleStats;";
private static String STORE_STATS_RECORD = "INSERT INTO simpleStats (statName,statValue) VALUES(";
private Connection _connection = null;
public void initialize()
{
PreparedStatement preparedStatement = null;
try
{
Class.forName("com.mysql.jdbc.Driver");
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
// Create table
preparedStatement = _connection.prepareStatement(CREATE_STATS_TABLE);
preparedStatement.execute();
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
public NautHashMap<String, String> retrieveStatRecords()
{
ResultSet resultSet = null;
PreparedStatement preparedStatement = null;
NautHashMap<String, String> statRecords = new NautHashMap<String, String>();
try
{
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(RETRIEVE_STATS_RECORDS);
resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
statRecords.put(resultSet.getString(1), resultSet.getString(2));
}
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
if (resultSet != null)
{
try
{
resultSet.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
return statRecords;
}
public void storeStatValue(String statName, String statValue)
{
PreparedStatement preparedStatement = null;
try
{
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
}
preparedStatement = _connection.prepareStatement(STORE_STATS_RECORD + statName + "," + statValue + ");");
preparedStatement.executeUpdate();
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
}

View File

@ -169,7 +169,7 @@ public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
itemLore.add(C.cBlack); itemLore.add(C.cBlack);
itemLore.addAll(Arrays.asList(gadget.GetDescription())); itemLore.addAll(Arrays.asList(gadget.GetDescription()));
if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(gadget.GetName())) if (gadget.GetCost(CurrencyType.Gems) == -1 || DonationManager.Get(Player.getName()).OwnsUnknownPackage(gadget.GetName()))
{ {
if (gadget.GetActive().contains(Player)) if (gadget.GetActive().contains(Player))
{ {

View File

@ -9,8 +9,8 @@ import mineplex.core.donation.DonationManager;
import mineplex.hub.gadget.GadgetManager; import mineplex.hub.gadget.GadgetManager;
import mineplex.hub.pet.Pet; import mineplex.hub.pet.Pet;
import mineplex.hub.pet.PetExtra; import mineplex.hub.pet.PetExtra;
import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.hub.pet.repository.token.PetChangeToken;
import mineplex.core.pet.repository.token.PetToken; import mineplex.hub.pet.repository.token.PetToken;
import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ConfirmationPage;
import mineplex.core.shop.page.ShopPageBase; import mineplex.core.shop.page.ShopPageBase;
import net.minecraft.server.v1_7_R3.ItemStack; import net.minecraft.server.v1_7_R3.ItemStack;

View File

@ -1,9 +1,9 @@
package mineplex.hub.pet; package mineplex.hub.pet;
import mineplex.core.common.CurrencyType; import mineplex.core.common.CurrencyType;
import mineplex.core.pet.repository.token.PetSalesToken;
import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageBase;
import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.item.ShopItem;
import mineplex.hub.pet.repository.token.PetSalesToken;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;

View File

@ -3,8 +3,8 @@ package mineplex.hub.pet;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.pet.repository.token.ClientPetToken; import mineplex.hub.pet.repository.token.ClientPetToken;
import mineplex.core.pet.repository.token.PetToken; import mineplex.hub.pet.repository.token.PetToken;
public class PetClient public class PetClient
{ {

View File

@ -2,8 +2,8 @@ package mineplex.hub.pet;
import mineplex.core.common.CurrencyType; import mineplex.core.common.CurrencyType;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.pet.repository.token.PetExtraToken;
import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageBase;
import mineplex.hub.pet.repository.token.PetExtraToken;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -5,9 +5,9 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.pet.repository.token.PetExtraToken;
import mineplex.core.pet.repository.token.PetSalesToken;
import mineplex.hub.pet.repository.PetRepository; import mineplex.hub.pet.repository.PetRepository;
import mineplex.hub.pet.repository.token.PetExtraToken;
import mineplex.hub.pet.repository.token.PetSalesToken;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;

View File

@ -5,7 +5,6 @@ import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.MiniClientPlugin; import mineplex.core.MiniClientPlugin;
import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
@ -17,6 +16,7 @@ import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.hub.pet.repository.PetRepository; import mineplex.hub.pet.repository.PetRepository;
import mineplex.hub.pet.repository.token.ClientPetTokenWrapper;
import net.minecraft.server.v1_7_R3.EntityCreature; import net.minecraft.server.v1_7_R3.EntityCreature;
import net.minecraft.server.v1_7_R3.EntityHuman; import net.minecraft.server.v1_7_R3.EntityHuman;
import net.minecraft.server.v1_7_R3.EntityInsentient; import net.minecraft.server.v1_7_R3.EntityInsentient;
@ -30,6 +30,7 @@ import net.minecraft.server.v1_7_R3.PathfinderGoalSelector;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -4,11 +4,11 @@ import java.util.List;
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken; import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
import mineplex.core.pet.repository.token.PetChangeToken;
import mineplex.core.pet.repository.token.PetExtraToken;
import mineplex.core.pet.repository.token.PetSalesToken;
import mineplex.core.server.remotecall.AsyncJsonWebCall; import mineplex.core.server.remotecall.AsyncJsonWebCall;
import mineplex.core.server.remotecall.JsonWebCall; import mineplex.core.server.remotecall.JsonWebCall;
import mineplex.hub.pet.repository.token.PetChangeToken;
import mineplex.hub.pet.repository.token.PetExtraToken;
import mineplex.hub.pet.repository.token.PetSalesToken;
public class PetRepository public class PetRepository
{ {

View File

@ -1,4 +1,4 @@
package mineplex.core.pet.repository.token; package mineplex.hub.pet.repository.token;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package mineplex.core.pet.repository.token; package mineplex.hub.pet.repository.token;
public class ClientPetTokenWrapper public class ClientPetTokenWrapper
{ {

View File

@ -1,4 +1,4 @@
package mineplex.core.pet.repository.token; package mineplex.hub.pet.repository.token;
public class PetChangeToken public class PetChangeToken
{ {

View File

@ -1,4 +1,4 @@
package mineplex.core.pet.repository.token; package mineplex.hub.pet.repository.token;
public class PetExtraToken public class PetExtraToken
{ {

View File

@ -1,4 +1,4 @@
package mineplex.core.pet.repository.token; package mineplex.hub.pet.repository.token;
public class PetSalesToken public class PetSalesToken
{ {

View File

@ -1,4 +1,4 @@
package mineplex.core.pet.repository.token; package mineplex.hub.pet.repository.token;
public class PetToken public class PetToken
{ {

View File

@ -77,8 +77,13 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
_donationManager = new DonationManager(this, GetWebServerAddress()); _donationManager = new DonationManager(this, GetWebServerAddress());
<<<<<<< HEAD
PreferencesManager preferences = new PreferencesManager(this, _clientManager, _donationManager); PreferencesManager preferences = new PreferencesManager(this, _clientManager, _donationManager);
new MessageManager(this, _clientManager, preferences); new MessageManager(this, _clientManager, preferences);
=======
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
new MessageManager(this, _clientManager, preferenceManager);
>>>>>>> 0bf702902e17516316ac3453297110af4cfdec5f
AntiStack antistack = new AntiStack(this); AntiStack antistack = new AntiStack(this);
@ -98,7 +103,11 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
AntiHack.Initialize(this, punish, portal); AntiHack.Initialize(this, punish, portal);
//Arcade Manager //Arcade Manager
<<<<<<< HEAD
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferences, GetWebServerAddress()); _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferences, GetWebServerAddress());
=======
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferenceManager, GetWebServerAddress());
>>>>>>> 0bf702902e17516316ac3453297110af4cfdec5f
new MemoryFix(this); new MemoryFix(this);

View File

@ -52,7 +52,7 @@ public class ChampionsDominate extends Domination
Manager.GetDamage().UseSimpleWeaponDamage = false; Manager.GetDamage().UseSimpleWeaponDamage = false;
EloRanking = true; EloRanking = false;
EloStart = 1000; EloStart = 1000;
} }
@ -64,6 +64,7 @@ public class ChampionsDominate extends Domination
{ {
SetKit(player, GetKits()[2], true); SetKit(player, GetKits()[2], true);
player.closeInventory(); player.closeInventory();
System.out.println("Closing inventory from validate kit");
} }
} }

View File

@ -330,6 +330,7 @@ public class Domination extends TeamGame
{ {
event.setCancelled(true); event.setCancelled(true);
event.getWhoClicked().closeInventory(); event.getWhoClicked().closeInventory();
System.out.println("Closing inventory from crafting in Domination");
} }
} }

View File

@ -0,0 +1,180 @@
package nautilus.game.arcade.scoreboard;
import java.util.ArrayList;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
public class GameScoreboard
{
private Game Game;
private Scoreboard _scoreboard;
private Objective _sideObjective;
private ArrayList<ScoreboardElement> _elements = new ArrayList<ScoreboardElement>();
private String _space = " ";
public GameScoreboard(Game game)
{
Game = game;
//Scoreboard
_scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
_sideObjective = _scoreboard.registerNewObjective("Obj"+UtilMath.r(999999999), "dummy");
_sideObjective.setDisplaySlot(DisplaySlot.SIDEBAR);
_sideObjective.setDisplayName(C.Bold + game.GetName());
}
public Scoreboard GetScoreboard()
{
return _scoreboard;
}
public Objective GetObjectiveSide()
{
return _sideObjective;
}
public void CreateTeams()
{
System.out.println("Creating Scoreboard Teams.");
//Base Groups
for (Rank rank : Rank.values())
{
//Spectator
if (rank == Rank.ALL)
{
_scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(ChatColor.GRAY + "");
}
else
{
_scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(ChatColor.GRAY + "");
//_scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + ChatColor.GRAY);
}
}
//Team Groups
for (GameTeam team : Game.GetTeamList())
{
for (Rank rank : Rank.values())
{
if (rank == Rank.ALL)
{
_scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + "");
}
else
{
//_scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + team.GetColor());
_scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + "");
}
}
}
}
public void SetPlayerTeam(Player player, String teamName)
{
for (Team team : _scoreboard.getTeams())
team.removePlayer(player);
if (teamName == null)
teamName = "";
_scoreboard.getTeam(Game.Manager.GetClients().Get(player).GetRank().Name + teamName).addPlayer(player);
}
public void ResetScore(String line)
{
_scoreboard.resetScores(line);
}
public void Reset()
{
for (ScoreboardElement elem : _elements)
{
for (String line : elem.GetLines())
{
ResetScore(line);
}
}
_elements.clear();
_space = " ";
}
public String Clean(String line)
{
if (line.length() >= 16)
line = line.substring(0, 15);
return line;
}
public void Write(String line)
{
line = Clean(line);
_elements.add(new ScoreboardElementText(line));
}
public void WriteOrdered(String key, String line, int value, boolean prependScore)
{
if (prependScore)
line = value + " " + line;
line = Clean(line);
for (ScoreboardElement elem : _elements)
{
if (elem instanceof ScoreboardElementScores)
{
ScoreboardElementScores scores = (ScoreboardElementScores)elem;
if (scores.IsKey(key))
{
scores.AddScore(line, value);
return;
}
}
}
_elements.add(new ScoreboardElementScores(key, line, value, true));
}
public void WriteBlank()
{
_elements.add(new ScoreboardElementText(_space));
_space += " ";
}
public void Draw()
{
int i = 15;
for (ScoreboardElement elem : _elements)
{
for (String line : elem.GetLines())
{
GetObjectiveSide().getScore(line).setScore(i--);
}
if (i <= 0)
break;
}
}
}

View File

@ -0,0 +1,8 @@
package nautilus.game.arcade.scoreboard;
import java.util.ArrayList;
public abstract class ScoreboardElement
{
public abstract ArrayList<String> GetLines();
}

View File

@ -0,0 +1,65 @@
package nautilus.game.arcade.scoreboard;
import java.util.ArrayList;
import java.util.HashMap;
public class ScoreboardElementScores extends ScoreboardElement
{
private String _key;
private HashMap<String, Integer> _scores;
private boolean _higherIsBetter;
public ScoreboardElementScores(String key, String line, int value, boolean higherIsBetter)
{
_scores = new HashMap<String, Integer>();
_key = key;
AddScore(line, value);
_higherIsBetter = higherIsBetter;
}
@Override
public ArrayList<String> GetLines()
{
ArrayList<String> orderedScores = new ArrayList<String>();
//Order Scores
while (orderedScores.size() < _scores.size())
{
String bestKey = null;
int bestScore = 0;
for (String key : _scores.keySet())
{
if (orderedScores.contains(key))
continue;
if (bestKey == null ||
(_higherIsBetter && _scores.get(key) >= bestScore) ||
(!_higherIsBetter && _scores.get(key) <= bestScore))
{
bestKey = key;
bestScore = _scores.get(key);
}
}
orderedScores.add(bestKey);
}
return orderedScores;
}
public boolean IsKey(String key)
{
return _key.equals(key);
}
public void AddScore(String line, int value)
{
_scores.put(line, value);
}
}

View File

@ -0,0 +1,24 @@
package nautilus.game.arcade.scoreboard;
import java.util.ArrayList;
public class ScoreboardElementText extends ScoreboardElement
{
private String _line;
public ScoreboardElementText(String line)
{
_line = line;
}
@Override
public ArrayList<String> GetLines()
{
ArrayList<String> orderedScores = new ArrayList<String>();
orderedScores.add(_line);
return orderedScores;
}
}