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

This commit is contained in:
Jonathan Williams 2014-11-07 16:04:14 -08:00
commit 0a874d0ee3
9 changed files with 125 additions and 62 deletions

View File

@ -5,7 +5,7 @@ import java.sql.Connection;
import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.BasicDataSource;
public class DBPool public final class DBPool
{ {
public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "root", "tAbechAk3wR7tuTh"); public static final DataSource ACCOUNT = openDataSource("jdbc:mysql://db.mineplex.com/Account", "root", "tAbechAk3wR7tuTh");
public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "root", "tAbechAk3wR7tuTh"); public static final DataSource QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "root", "tAbechAk3wR7tuTh");
@ -30,4 +30,9 @@ public class DBPool
return source; return source;
} }
private DBPool()
{
}
} }

View File

@ -18,6 +18,7 @@ import mineplex.core.punish.Tokens.PunishClientToken;
import mineplex.core.punish.Tokens.PunishmentToken; import mineplex.core.punish.Tokens.PunishmentToken;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson; import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -154,7 +155,7 @@ public class Punish extends MiniPlugin
} }
else if (banResult == PunishmentResponse.Punished) else if (banResult == PunishmentResponse.Punished)
{ {
final String durationString = F.time(UtilTime.convertString(finalDuration < 0 ? -1 : (long)(finalDuration * 3600000), 1, TimeUnit.FIT)); final String durationString = UtilTime.convertString(finalDuration < 0 ? -1 : (long)(finalDuration * 3600000), 1, TimeUnit.FIT);
if (sentence == PunishmentSentence.Ban) if (sentence == PunishmentSentence.Ban)
{ {
@ -178,7 +179,19 @@ public class Punish extends MiniPlugin
System.out.println(F.main(GetName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " muted " + F.elem(playerName) + " because of " + F.elem(reason) + " for " + System.out.println(F.main(GetName(), F.elem(caller == null ? "Mineplex Anti-Cheat" : caller.getName()) + " muted " + F.elem(playerName) + " because of " + F.elem(reason) + " for " +
durationString + ".")); durationString + "."));
UtilServer.broadcast(F.main(GetName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + playerName + " for " + durationString + ".")); //Warning
if (finalDuration == 0)
UtilServer.broadcast(F.main(GetName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " issued a warning to " + playerName + "."));
else
UtilServer.broadcast(F.main(GetName(), caller == null ? "Mineplex Anti-Cheat" : caller.getName() + " muted " + playerName + " for " + durationString + "."));
//Inform
Player target = UtilPlayer.searchExact(playerName);
if (target != null)
{
UtilPlayer.message(target, F.main("Punish", F.elem(C.cGray + C.Bold + "Reason: ") + reason));
target.playSound(target.getLocation(), Sound.CAT_MEOW, 1f, 1f);
}
_repository.LoadPunishClient(playerName, new Callback<PunishClientToken>() _repository.LoadPunishClient(playerName, new Callback<PunishClientToken>()
{ {

View File

@ -145,6 +145,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private ServerStatusManager _serverStatusManager; private ServerStatusManager _serverStatusManager;
private InventoryManager _inventoryManager; private InventoryManager _inventoryManager;
private CosmeticManager _cosmeticManager; private CosmeticManager _cosmeticManager;
private final IdleManager _idleManager;
private AchievementManager _achievementManager; private AchievementManager _achievementManager;
private StatsManager _statsManager; private StatsManager _statsManager;
@ -264,7 +265,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new GameLootManager(this, petManager); new GameLootManager(this, petManager);
_gameWorldManager = new GameWorldManager(this); _gameWorldManager = new GameWorldManager(this);
new MiscManager(this); new MiscManager(this);
new IdleManager(this); _idleManager = new IdleManager(this);
//new HalloweenManager(this); //new HalloweenManager(this);
_arcadeRepository = new ArcadeRepository(plugin); _arcadeRepository = new ArcadeRepository(plugin);
@ -1071,4 +1072,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{ {
_youtube.remove(event.getPlayer()); _youtube.remove(event.getPlayer());
} }
public IdleManager getIdleManager()
{
return _idleManager;
}
} }

View File

@ -1249,4 +1249,9 @@ public abstract class Game implements Listener
_statTrackers.clear(); _statTrackers.clear();
} }
public ArcadeManager getArcadeManager()
{
return Manager;
}
} }

View File

@ -125,6 +125,8 @@ public class Draw extends SoloGame
new KeenEyeStatTracker(this), new KeenEyeStatTracker(this),
new PureLuckStatTracker(this) new PureLuckStatTracker(this)
); );
getArcadeManager().getIdleManager().setEnabled(false);
} }
@Override @Override

View File

@ -102,6 +102,8 @@ public class UHC extends TeamGame
private boolean xrayDebug = false; private boolean xrayDebug = false;
private long lastInform = 0;
public UHC(ArcadeManager manager) public UHC(ArcadeManager manager)
{ {
super(manager, GameType.UHC, super(manager, GameType.UHC,
@ -1578,4 +1580,14 @@ public class UHC extends TeamGame
} }
} }
} }
public void informStartSoon()
{
if (UtilTime.elapsed(lastInform, 20000))
{
lastInform = System.currentTimeMillis();
Bukkit.broadcastMessage(C.cGray + "Countdown will start in " + UtilTime.MakeStr(150000 - (System.currentTimeMillis() - GetStateTime())) +"...");
}
}
} }

View File

@ -29,6 +29,7 @@ import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.stats.StatTracker; import nautilus.game.arcade.stats.StatTracker;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -200,8 +201,13 @@ public class GameManager implements Listener
public void StateCountdown(Game game, int timer, boolean force) public void StateCountdown(Game game, int timer, boolean force)
{ {
//Always give time to pick team. //Always give time to pick team.
if (!game.GetCountdownForce() && !force && !UtilTime.elapsed(game.GetStateTime(), 15000)) if (!game.GetCountdownForce() && !force && !UtilTime.elapsed(game.GetStateTime(), game.GetType() == GameType.UHC ? 150000 : 15000))
{ {
if (game.GetType() == GameType.UHC)
{
((UHC)game).informStartSoon();
}
return; return;
} }

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.managers; package nautilus.game.arcade.managers;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -22,24 +23,26 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class IdleManager implements Listener public class IdleManager implements Listener
{ {
ArcadeManager Manager; private final ArcadeManager _arcadeManager;
private final Map<Player, Float> _yaw = new HashMap<>();
private HashMap<Player, Float> _yaw = new HashMap<Player, Float>(); private final Map<Player, Long> _idle = new HashMap<>();
private HashMap<Player, Long> _idle = new HashMap<Player, Long>(); private final Map<Player, Integer> _beep = new HashMap<>();
private HashMap<Player, Integer> _beep = new HashMap<Player, Integer>(); private boolean _enabled = true;
public IdleManager(ArcadeManager manager) public IdleManager(ArcadeManager manager)
{ {
Manager = manager; _arcadeManager = manager;
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin()); Bukkit.getPluginManager().registerEvents(this, getArcadeManager().GetPlugin());
} }
@EventHandler @EventHandler
public void ChatIdle(final AsyncPlayerChatEvent event) public void ChatIdle(final AsyncPlayerChatEvent event)
{ {
Bukkit.getServer().getScheduler().runTaskLater(Manager.GetPlugin(), new Runnable() if (!isEnabled())
return;
Bukkit.getServer().getScheduler().runTaskLater(getArcadeManager().GetPlugin(), new Runnable()
{ {
@Override @Override
public void run() public void run()
@ -50,15 +53,18 @@ public class IdleManager implements Listener
} }
@EventHandler @EventHandler
public void KickIdlePlayers(UpdateEvent event) public void kickIdlePlayers(UpdateEvent event)
{ {
if (!isEnabled())
return;
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
return; return;
if (!Manager.IsPlayerKickIdle()) if (!getArcadeManager().IsPlayerKickIdle())
return; return;
if (Manager.GetGame() == null) if (getArcadeManager().GetGame() == null)
return; return;
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
@ -73,10 +79,10 @@ public class IdleManager implements Listener
{ {
if (UtilTime.elapsed(_idle.get(player), 120000)) if (UtilTime.elapsed(_idle.get(player), 120000))
{ {
if (Manager.GetGame().GetState() != GameState.Recruit && !Manager.GetGame().IsAlive(player)) if (getArcadeManager().GetGame().GetState() != GameState.Recruit && !getArcadeManager().GetGame().IsAlive(player))
continue; continue;
if (Manager.GetClients().Get(player).GetRank().Has(Rank.MODERATOR)) if (getArcadeManager().GetClients().Get(player).GetRank().Has(Rank.MODERATOR))
continue; continue;
//Start Beeps //Start Beeps
@ -92,7 +98,7 @@ public class IdleManager implements Listener
if (count == 0) if (count == 0)
{ {
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f);
Manager.GetPortal().SendPlayerToServer(player, "Lobby"); getArcadeManager().GetPortal().SendPlayerToServer(player, "Lobby");
} }
else else
{ {
@ -120,10 +126,25 @@ public class IdleManager implements Listener
} }
@EventHandler @EventHandler
public void Quit(PlayerQuitEvent event) public void onPlayerQuit(PlayerQuitEvent event)
{ {
_yaw.remove(event.getPlayer()); _yaw.remove(event.getPlayer());
_idle.remove(event.getPlayer()); _idle.remove(event.getPlayer());
_beep.remove(event.getPlayer()); _beep.remove(event.getPlayer());
} }
public boolean isEnabled()
{
return _enabled;
}
public void setEnabled(boolean enabled)
{
_enabled = enabled;
}
public ArcadeManager getArcadeManager()
{
return _arcadeManager;
}
} }

View File

@ -12,6 +12,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
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.games.hideseek.HideSeek; import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.hideseek.forms.CreatureForm;
public class BadHiderStatTracker extends StatTracker<HideSeek> public class BadHiderStatTracker extends StatTracker<HideSeek>
{ {
@ -28,7 +29,8 @@ public class BadHiderStatTracker extends StatTracker<HideSeek>
if (getGame().GetState() != Game.GameState.Live) if (getGame().GetState() != Game.GameState.Live)
return; return;
_disqualified.add(event.getPlayer().getUniqueId()); if (event.getForm() instanceof CreatureForm)
_disqualified.add(event.getPlayer().getUniqueId());
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
@ -40,15 +42,6 @@ public class BadHiderStatTracker extends StatTracker<HideSeek>
_disqualified.add(event.getEntity().getUniqueId()); _disqualified.add(event.getEntity().getUniqueId());
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerSolidify(HideSeek.PlayerSolidifyEvent event)
{
if (getGame().GetState() != Game.GameState.Live)
return;
_disqualified.add(event.getPlayer().getUniqueId());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event) public void onGameStateChange(GameStateChangeEvent event)
{ {