Merge branch 'master' of ssh://dev1.mineplex.com:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2014-05-06 22:38:50 -07:00
commit b72bcadbf4
3 changed files with 54 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.stats.column.Column;
import mineplex.core.stats.column.ColumnInt;
import mineplex.core.stats.column.ColumnUuid;
import mineplex.core.stats.column.ColumnVarChar;
public class StatsManager extends MiniPlugin
@ -53,6 +54,7 @@ public class StatsManager extends MiniPlugin
{
if (!_tables.containsKey(tableName))
{
// Change
ColumnVarChar playerColumn = new ColumnVarChar("playerName", 16);
List<Column<?>> columnList = new ArrayList<Column<?>>();
columnList.add(playerColumn);
@ -79,9 +81,11 @@ public class StatsManager extends MiniPlugin
public void addStat(Player player, String table, String statName, int value)
{
// getName -> getUniqueId
addStat(player.getName(), table, statName, value);
}
// playerName -> uuid
public void addStat(String playerName, String table, String statName, int value)
{
if (!_playerStatList.containsKey(table))
@ -95,6 +99,7 @@ public class StatsManager extends MiniPlugin
Row row = _tables.get(table).createRow();
// bad playername!
((ColumnVarChar)row.Columns.get("playerName")).Value = playerName;
_playerStatList.get(table).put(playerName, row);
@ -133,10 +138,13 @@ public class StatsManager extends MiniPlugin
try
{
// playerName -> column name of UUID or uuid or UniqueID, whichever you choose
// and event.getPlayerName() is still in this event, but so is getUniqueId
List<Column<?>> columnList = new ArrayList<Column<?>>();
columnList.add(new ColumnVarChar("playerName", 16, event.getPlayerName()));
columnList.add(new ColumnUuid("playerUuid", 256, event.getUniqueId()));
List<Row> rows = table.retrieve(columnList);
// Same here.
Row row = table.createRow();
((ColumnVarChar)row.Columns.get("playerName")).Value = event.getPlayerName();

View File

@ -0,0 +1,41 @@
package mineplex.core.stats.column;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
public class ColumnUuid extends Column<String>
{
public int Length = 256;
public UUID Value = UUID.fromString("");
public ColumnUuid(String name, int length)
{
this(name, length, UUID.fromString(""));
}
public ColumnUuid(String name, int length, UUID value)
{
super(name);
Length = length;
Value = value;
}
public String getCreateString()
{
return Name + " VARCHAR(" + Length + ")";
}
@Override
public String getValue(ResultSet resultSet) throws SQLException
{
return resultSet.getString(Name);
}
@Override
public ColumnUuid clone()
{
return new ColumnUuid(Name, Length, Value);
}
}

View File

@ -87,6 +87,10 @@ public class SuperSmash extends SoloGame
this.SpawnDistanceRequirement = 16;
this.InventoryOpen = false;
// Add stat table here
// Example
//Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses");
}
@EventHandler(priority = EventPriority.HIGH)