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;
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 QUEUE = openDataSource("jdbc:mysql://db.mineplex.com/Queue", "root", "tAbechAk3wR7tuTh");
@ -30,4 +30,9 @@ public class DBPool
return source;
}
private DBPool()
{
}
}

View File

@ -18,6 +18,7 @@ import mineplex.core.punish.Tokens.PunishClientToken;
import mineplex.core.punish.Tokens.PunishmentToken;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -154,7 +155,7 @@ public class Punish extends MiniPlugin
}
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)
{
@ -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 " +
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>()
{

View File

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

View File

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

View File

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

View File

@ -102,6 +102,8 @@ public class UHC extends TeamGame
private boolean xrayDebug = false;
private long lastInform = 0;
public UHC(ArcadeManager manager)
{
super(manager, GameType.UHC,
@ -120,7 +122,7 @@ public class UHC extends TeamGame
});
this.StrictAntiHack = true;
this.GameTimeout = 10800000;
this.DamagePvP = false;
@ -154,9 +156,9 @@ public class UHC extends TeamGame
this.CompassGiveItem = false;
this.WorldBoundaryKill = false;
this.TickPerTeleport = 3;
this.GemBoosterEnabled = false;
this.GemDoubleEnabled = false;
this.GemHunterEnabled = false;
@ -583,31 +585,31 @@ public class UHC extends TeamGame
event.getDrops().add(ItemStackFactory.Instance.CreateStack(Material.GOLD_INGOT, 1));
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void PlayerQuitDropItems(PlayerQuitEvent event)
{
Player player = event.getPlayer();
GameTeam team = GetTeam(player);
if (team == null) return;
if (!IsAlive(player))
return;
if (!QuitOut)
return;
//Drop Items
UtilInv.drop(player, true);
//Skull Drop
ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head");
SkullMeta meta = (SkullMeta)stack.getItemMeta();
meta.setOwner(player.getName());
stack.setItemMeta(meta);
event.getPlayer().getWorld().dropItemNaturally(player.getEyeLocation(), stack);
}
@ -621,11 +623,11 @@ public class UHC extends TeamGame
//Skull Drop
ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head");
SkullMeta meta = (SkullMeta)stack.getItemMeta();
meta.setOwner(player.getName());
stack.setItemMeta(meta);
event.getDrops().add(stack);
//Lightning
@ -896,16 +898,16 @@ public class UHC extends TeamGame
if (event.getItemInHand().getType() == Material.SKULL || event.getItemInHand().getType() == Material.SKULL_ITEM)
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.MONITOR)
public void HeadPickup(PlayerPickupItemEvent event)
{
if (!IsLive())
return;
if (event.isCancelled())
return;
if (event.getItem().getItemStack().getType() == Material.SKULL_ITEM)
{
UtilPlayer.message(event.getPlayer(), " ");
@ -915,7 +917,7 @@ public class UHC extends TeamGame
UtilPlayer.message(event.getPlayer(), " ");
}
}
/*
@EventHandler
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.REGENERATION, 200, 1)).apply(event.getPlayer());
event.getPlayer().setItemInHand(null);
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void DamageHealCancel(EntityDamageEvent event)
{
if (event.isCancelled())
return;
if (event.getEntity() instanceof Player)
{
Player player = (Player)event.getEntity();
player.removePotionEffect(PotionEffectType.REGENERATION);
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)
return;
if (!_ended)
if (_joinable)
return;
for (final Player player : UtilServer.getPlayers())
{
UtilPlayer.message(player, " ");
@ -1431,39 +1433,39 @@ public class UHC extends TeamGame
private ArrayList<Block> findOres(Block source, int range)
{
ArrayList<Block> ores = new ArrayList<Block>();
for (int x=-range ; x <= range ; x++)
for (int z=-range ; z <= range ; z++)
for (int y=-range ; y <= range ; y++)
{
Block block = source.getRelative(x, y, z);
findOreFromBlock(ores, block);
}
if (xrayDebug)
for (Block debug : ores)
System.out.println("Found " + debug.getType() + " at " + UtilWorld.locToStrClean(debug.getLocation()));
return ores;
}
public void findOreFromBlock(ArrayList<Block> ores, Block block)
{
if (ores.contains(block))
return;
if (isOre(block))
{
ores.add(block);
for (Block neighbour : UtilBlock.getSurrounding(block, true))
{
findOreFromBlock(ores, neighbour);
}
}
}
public boolean isOre(Block block)
{
return (block.getType() == Material.IRON_ORE ||
@ -1531,7 +1533,7 @@ public class UHC extends TeamGame
return veins;
}
private void removeNonAirVeins(ArrayList<ArrayList<Block>> oreVeins)
{
//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.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.stats.StatTracker;
import org.bukkit.ChatColor;
@ -200,8 +201,13 @@ public class GameManager implements Listener
public void StateCountdown(Game game, int timer, boolean force)
{
//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;
}

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.managers;
import java.util.HashMap;
import java.util.Map;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
@ -22,24 +23,26 @@ import org.bukkit.event.player.PlayerQuitEvent;
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)
{
Manager = manager;
_arcadeManager = manager;
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin());
Bukkit.getPluginManager().registerEvents(this, getArcadeManager().GetPlugin());
}
@EventHandler
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
public void run()
@ -50,15 +53,18 @@ public class IdleManager implements Listener
}
@EventHandler
public void KickIdlePlayers(UpdateEvent event)
public void kickIdlePlayers(UpdateEvent event)
{
if (!isEnabled())
return;
if (event.getType() != UpdateType.FAST)
return;
if (!Manager.IsPlayerKickIdle())
if (!getArcadeManager().IsPlayerKickIdle())
return;
if (Manager.GetGame() == null)
if (getArcadeManager().GetGame() == null)
return;
for (Player player : UtilServer.getPlayers())
@ -73,10 +79,10 @@ public class IdleManager implements Listener
{
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;
if (Manager.GetClients().Get(player).GetRank().Has(Rank.MODERATOR))
if (getArcadeManager().GetClients().Get(player).GetRank().Has(Rank.MODERATOR))
continue;
//Start Beeps
@ -92,7 +98,7 @@ public class IdleManager implements Listener
if (count == 0)
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f);
Manager.GetPortal().SendPlayerToServer(player, "Lobby");
getArcadeManager().GetPortal().SendPlayerToServer(player, "Lobby");
}
else
{
@ -120,10 +126,25 @@ public class IdleManager implements Listener
}
@EventHandler
public void Quit(PlayerQuitEvent event)
public void onPlayerQuit(PlayerQuitEvent event)
{
_yaw.remove(event.getPlayer());
_idle.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.game.Game;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.hideseek.forms.CreatureForm;
public class BadHiderStatTracker extends StatTracker<HideSeek>
{
@ -28,7 +29,8 @@ public class BadHiderStatTracker extends StatTracker<HideSeek>
if (getGame().GetState() != Game.GameState.Live)
return;
_disqualified.add(event.getPlayer().getUniqueId());
if (event.getForm() instanceof CreatureForm)
_disqualified.add(event.getPlayer().getUniqueId());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
@ -40,15 +42,6 @@ public class BadHiderStatTracker extends StatTracker<HideSeek>
_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)
public void onGameStateChange(GameStateChangeEvent event)
{