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

This commit is contained in:
Mini-Chiss 2015-08-28 23:27:35 -07:00
commit 5ae01f95a8
9 changed files with 66 additions and 72 deletions

View File

@ -54,12 +54,13 @@ public class MotdManager implements Listener, Runnable
Region.ALL, GlobalMotd.class, "globalMotd");
//String motdLine = "§f§l◄ §c§lMaintenance§f§l ►";
String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
//String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►";
String motdLine = " §b§l◄§f§lNEW GAME§b§l► §f§l◄§b§lEVOLUTION§f§l► §b§l◄§f§lNEW GAME§b§l►";
//String motdLine = " §f§l◄ §a§lCarl the Creeper§f§l ▬ §c§l75% OFF SALE§f§l ►";
//String motdLine = " §d§lRank Sale §a§l40% Off");
//String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", motdLine);
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", motdLine);
System.out.println("Updated Bungee MOTD");
}
}
@ -97,23 +98,7 @@ public class MotdManager implements Listener, Runnable
public void updateMainMotd(String headline, String motdLine)
{
List<String> motdLines = new ArrayList<String>();
String colorStripped = ChatColor.stripColor(motdLine);
if (colorStripped.trim().length() > 45)
motdLine = motdLine.trim().substring(0, 45);
else
{
String trimmed = colorStripped.trim();
int count = trimmed.length();
int marker = 0;
while ((45 - count) / 2 * 1.55 > marker)
{
motdLine = " " + motdLine;
marker++;
}
}
motdLines.add(motdLine);
_repository.addElement(new GlobalMotd("MainMotd", headline, motdLines));

View File

@ -78,11 +78,10 @@ public class PlayerStats implements Listener, Runnable
}
else
playerInfo = updatedPlayerInfo;
PlayerCache.getInstance().addPlayer(playerInfo);
}
playerInfo.setSessionId(_repository.updatePlayerStats(playerInfo.getId(), ipInfo.id));
playerInfo.updateLoginTime();
PlayerCache.getInstance().addPlayer(playerInfo);
}
finally

View File

@ -1,5 +1,6 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7

View File

@ -1,12 +1,14 @@
package mineplex.core.account;
import mineplex.core.common.Rank;
import mineplex.serverdata.Utility;
import org.bukkit.entity.Player;
public class CoreClient
{
private int _accountId = -1;
private long _networkSessionLoginTime;
private String _name;
private String _disguisedAs;
private Player _player;
@ -18,6 +20,7 @@ public class CoreClient
{
_player = player;
_name = player.getName();
_networkSessionLoginTime = Utility.currentTimeMillis();
}
public CoreClient(String name)
@ -65,6 +68,11 @@ public class CoreClient
{
_rank = rank;
}
public long getNetworkSessionLoginTime()
{
return _networkSessionLoginTime;
}
public String getDisguisedAs()
{
@ -95,4 +103,9 @@ public class CoreClient
public void setDisguised(boolean disguised) {
this._disguised = disguised;
}
public void setNetworkSessionLoginTime(long loginTime)
{
_networkSessionLoginTime = loginTime;
}
}

View File

@ -324,14 +324,13 @@ public class CoreClientManager extends MiniPlugin
TimingManager.stop(client.GetPlayerName() + " LoadClient Total.");
System.out.println(client.GetPlayerName() + "'s account id = " + client.getAccountId());
if (client.getAccountId() > 0)
{
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
if (playerInfo != null)
{
client.setNetworkSessionLoginTime(playerInfo.getLoginTime());
playerInfo.setAccountId(client.getAccountId());
PlayerCache.getInstance().addPlayer(playerInfo);
}

View File

@ -459,7 +459,7 @@ public class GadgetManager extends MiniPlugin
{
if (!event.getPlayer().isSneaking())
{
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CAT_MEOW, 1f, 1f);
event.getPlayer().kickPlayer("Don't meow ever again.");
}
}
}

View File

@ -2,6 +2,7 @@ package mineplex.playerCache;
import java.util.UUID;
import mineplex.serverdata.Utility;
import mineplex.serverdata.data.Data;
public class PlayerInfo implements Data
@ -94,4 +95,9 @@ public class PlayerInfo implements Data
{
_accountId = accountId;
}
public void updateLoginTime()
{
_loginTime = Utility.currentTimeMillis();
}
}

View File

@ -19,7 +19,9 @@ import com.google.gson.GsonBuilder;
*/
public class Utility
{
private static boolean _retrievedRedisTime = false;
private static long _millisTimeDifference;
// The Gson instance used to serialize/deserialize objects in JSON form.
private static Gson _gson = new GsonBuilder().create();
public static Gson getGson() { return _gson; }
@ -74,29 +76,10 @@ public class Utility
*/
public static long currentTimeSeconds()
{
long currentTime = 0;
JedisPool pool = getPool(false);
Jedis jedis = pool.getResource();
try
{
currentTime = Long.parseLong(jedis.time().get(0));
}
catch (JedisConnectionException exception)
{
exception.printStackTrace();
pool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (pool != null)
{
pool.returnResource(jedis);
}
}
return currentTime;
if (!_retrievedRedisTime)
setTimeDifference();
return (System.currentTimeMillis() + _millisTimeDifference) / 1000;
}
/**
@ -105,29 +88,10 @@ public class Utility
*/
public static long currentTimeMillis()
{
long currentTime = 0;
JedisPool pool = getPool(false);
Jedis jedis = pool.getResource();
if (!_retrievedRedisTime)
setTimeDifference();
try
{
currentTime = Long.parseLong(jedis.time().get(0));
}
catch (JedisConnectionException exception)
{
exception.printStackTrace();
pool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (pool != null)
{
pool.returnResource(jedis);
}
}
return currentTime * 1000;
return System.currentTimeMillis() + _millisTimeDifference;
}
/**
@ -188,4 +152,30 @@ public class Utility
return connData.getHost() + ":" + connData.getPort();
}
private static void setTimeDifference()
{
long currentTime = 0;
JedisPool pool = getPool(false);
Jedis jedis = pool.getResource();
try
{
currentTime = Long.parseLong(jedis.time().get(0));
}
catch (JedisConnectionException exception)
{
exception.printStackTrace();
pool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (pool != null)
{
pool.returnResource(jedis);
}
}
_millisTimeDifference = (currentTime * 1000) - System.currentTimeMillis();
}
}

View File

@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.serverdata.Utility;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
@ -190,7 +191,7 @@ public class GameGemManager implements Listener
//Time Reward
if (TimeReward)
{
long timeOnline = 7980000;
long timeOnline = Utility.currentTimeMillis() - Manager.GetClients().Get(player).getNetworkSessionLoginTime();
double hoursOnline = timeOnline/3600000d;
@ -308,7 +309,7 @@ public class GameGemManager implements Listener
//Time Reward
if (TimeReward)
{
long timeOnline = 7980000;
long timeOnline = Utility.currentTimeMillis() - Manager.GetClients().Get(player).getNetworkSessionLoginTime();
double hoursOnline = timeOnline/3600000d;