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,
@ -120,7 +122,7 @@ public class UHC extends TeamGame
}); });
this.StrictAntiHack = true; this.StrictAntiHack = true;
this.GameTimeout = 10800000; this.GameTimeout = 10800000;
this.DamagePvP = false; this.DamagePvP = false;
@ -154,9 +156,9 @@ public class UHC extends TeamGame
this.CompassGiveItem = false; this.CompassGiveItem = false;
this.WorldBoundaryKill = false; this.WorldBoundaryKill = false;
this.TickPerTeleport = 3; this.TickPerTeleport = 3;
this.GemBoosterEnabled = false; this.GemBoosterEnabled = false;
this.GemDoubleEnabled = false; this.GemDoubleEnabled = false;
this.GemHunterEnabled = false; this.GemHunterEnabled = false;
@ -583,31 +585,31 @@ public class UHC extends TeamGame
event.getDrops().add(ItemStackFactory.Instance.CreateStack(Material.GOLD_INGOT, 1)); event.getDrops().add(ItemStackFactory.Instance.CreateStack(Material.GOLD_INGOT, 1));
} }
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void PlayerQuitDropItems(PlayerQuitEvent event) public void PlayerQuitDropItems(PlayerQuitEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
GameTeam team = GetTeam(player); GameTeam team = GetTeam(player);
if (team == null) return; if (team == null) return;
if (!IsAlive(player)) if (!IsAlive(player))
return; return;
if (!QuitOut) if (!QuitOut)
return; return;
//Drop Items //Drop Items
UtilInv.drop(player, true); UtilInv.drop(player, true);
//Skull Drop //Skull Drop
ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head"); ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head");
SkullMeta meta = (SkullMeta)stack.getItemMeta(); SkullMeta meta = (SkullMeta)stack.getItemMeta();
meta.setOwner(player.getName()); meta.setOwner(player.getName());
stack.setItemMeta(meta); stack.setItemMeta(meta);
event.getPlayer().getWorld().dropItemNaturally(player.getEyeLocation(), stack); event.getPlayer().getWorld().dropItemNaturally(player.getEyeLocation(), stack);
} }
@ -621,11 +623,11 @@ public class UHC extends TeamGame
//Skull Drop //Skull Drop
ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head"); ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head");
SkullMeta meta = (SkullMeta)stack.getItemMeta(); SkullMeta meta = (SkullMeta)stack.getItemMeta();
meta.setOwner(player.getName()); meta.setOwner(player.getName());
stack.setItemMeta(meta); stack.setItemMeta(meta);
event.getDrops().add(stack); event.getDrops().add(stack);
//Lightning //Lightning
@ -896,16 +898,16 @@ public class UHC extends TeamGame
if (event.getItemInHand().getType() == Material.SKULL || event.getItemInHand().getType() == Material.SKULL_ITEM) if (event.getItemInHand().getType() == Material.SKULL || event.getItemInHand().getType() == Material.SKULL_ITEM)
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void HeadPickup(PlayerPickupItemEvent event) public void HeadPickup(PlayerPickupItemEvent event)
{ {
if (!IsLive()) if (!IsLive())
return; return;
if (event.isCancelled()) if (event.isCancelled())
return; return;
if (event.getItem().getItemStack().getType() == Material.SKULL_ITEM) if (event.getItem().getItemStack().getType() == Material.SKULL_ITEM)
{ {
UtilPlayer.message(event.getPlayer(), " "); UtilPlayer.message(event.getPlayer(), " ");
@ -915,7 +917,7 @@ public class UHC extends TeamGame
UtilPlayer.message(event.getPlayer(), " "); UtilPlayer.message(event.getPlayer(), " ");
} }
} }
/* /*
@EventHandler @EventHandler
public void HeadEat(PlayerInteractEvent event) public void HeadEat(PlayerInteractEvent event)
@ -926,23 +928,23 @@ public class UHC extends TeamGame
(new PotionEffect(PotionEffectType.ABSORPTION, 2400, 0)).apply(event.getPlayer()); (new PotionEffect(PotionEffectType.ABSORPTION, 2400, 0)).apply(event.getPlayer());
(new PotionEffect(PotionEffectType.REGENERATION, 200, 1)).apply(event.getPlayer()); (new PotionEffect(PotionEffectType.REGENERATION, 200, 1)).apply(event.getPlayer());
event.getPlayer().setItemInHand(null); event.getPlayer().setItemInHand(null);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void DamageHealCancel(EntityDamageEvent event) public void DamageHealCancel(EntityDamageEvent event)
{ {
if (event.isCancelled()) if (event.isCancelled())
return; return;
if (event.getEntity() instanceof Player) if (event.getEntity() instanceof Player)
{ {
Player player = (Player)event.getEntity(); Player player = (Player)event.getEntity();
player.removePotionEffect(PotionEffectType.REGENERATION); player.removePotionEffect(PotionEffectType.REGENERATION);
UtilPlayer.message(player, "You took damage and lost " + F.elem(C.cGreen + "Regeneration") + ChatColor.RESET + "."); UtilPlayer.message(player, "You took damage and lost " + F.elem(C.cGreen + "Regeneration") + ChatColor.RESET + ".");
} }
}*/ }*/
@ -1238,11 +1240,11 @@ public class UHC extends TeamGame
{ {
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
return; return;
if (!_ended) if (!_ended)
if (_joinable) if (_joinable)
return; return;
for (final Player player : UtilServer.getPlayers()) for (final Player player : UtilServer.getPlayers())
{ {
UtilPlayer.message(player, " "); UtilPlayer.message(player, " ");
@ -1431,39 +1433,39 @@ public class UHC extends TeamGame
private ArrayList<Block> findOres(Block source, int range) private ArrayList<Block> findOres(Block source, int range)
{ {
ArrayList<Block> ores = new ArrayList<Block>(); ArrayList<Block> ores = new ArrayList<Block>();
for (int x=-range ; x <= range ; x++) for (int x=-range ; x <= range ; x++)
for (int z=-range ; z <= range ; z++) for (int z=-range ; z <= range ; z++)
for (int y=-range ; y <= range ; y++) for (int y=-range ; y <= range ; y++)
{ {
Block block = source.getRelative(x, y, z); Block block = source.getRelative(x, y, z);
findOreFromBlock(ores, block); findOreFromBlock(ores, block);
} }
if (xrayDebug) if (xrayDebug)
for (Block debug : ores) for (Block debug : ores)
System.out.println("Found " + debug.getType() + " at " + UtilWorld.locToStrClean(debug.getLocation())); System.out.println("Found " + debug.getType() + " at " + UtilWorld.locToStrClean(debug.getLocation()));
return ores; return ores;
} }
public void findOreFromBlock(ArrayList<Block> ores, Block block) public void findOreFromBlock(ArrayList<Block> ores, Block block)
{ {
if (ores.contains(block)) if (ores.contains(block))
return; return;
if (isOre(block)) if (isOre(block))
{ {
ores.add(block); ores.add(block);
for (Block neighbour : UtilBlock.getSurrounding(block, true)) for (Block neighbour : UtilBlock.getSurrounding(block, true))
{ {
findOreFromBlock(ores, neighbour); findOreFromBlock(ores, neighbour);
} }
} }
} }
public boolean isOre(Block block) public boolean isOre(Block block)
{ {
return (block.getType() == Material.IRON_ORE || return (block.getType() == Material.IRON_ORE ||
@ -1531,7 +1533,7 @@ public class UHC extends TeamGame
return veins; return veins;
} }
private void removeNonAirVeins(ArrayList<ArrayList<Block>> oreVeins) private void removeNonAirVeins(ArrayList<ArrayList<Block>> oreVeins)
{ {
//Remove Non-Aired Veins //Remove Non-Aired Veins
@ -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 final Map<Player, Long> _idle = new HashMap<>();
private final Map<Player, Integer> _beep = new HashMap<>();
private boolean _enabled = true;
private HashMap<Player, Float> _yaw = new HashMap<Player, Float>();
private HashMap<Player, Long> _idle = new HashMap<Player, Long>();
private HashMap<Player, Integer> _beep = new HashMap<Player, Integer>();
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)
{ {