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

Conflicts:
	Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java
This commit is contained in:
Jonathan Williams 2013-12-17 11:10:11 -05:00
commit ab8013091d
8 changed files with 229 additions and 80 deletions

View File

@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
<classpathentry kind="lib" path="Z:/Mineplex/master/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -8,6 +8,7 @@ import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.EntityEnderDragon;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.EntityInsentient;
import net.minecraft.server.v1_6_R3.EntityLiving;
import net.minecraft.server.v1_6_R3.Navigation;
import net.minecraft.server.v1_6_R3.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_6_R3.PathfinderGoalMoveTowardsRestriction;
@ -20,12 +21,15 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftLivingEntity;import org.bukkit.entity.Creature;import org.bukkit.entity.Entity;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Giant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
public class UtilEnt
@ -487,8 +491,14 @@ public class UtilEnt
return false;
}
public static void CreatureMove(Creature ent, Location target, float speed)
public static void CreatureMove(Entity ent, Location target, float speed)
{
if (!(ent instanceof Creature))
return;
if (UtilMath.offset(ent.getLocation(), target) < 0.1)
return;
EntityCreature ec = ((CraftCreature)ent).getHandle();
Navigation nav = ec.getNavigation();
@ -505,4 +515,19 @@ public class UtilEnt
nav.a(target.getX(), target.getY(), target.getZ(), speed);
}
}
public static void CreatureMoveFast(Entity ent, Location target, float speed)
{
if (!(ent instanceof Creature))
return;
if (UtilMath.offset(ent.getLocation(), target) < 0.1)
return;
if (UtilMath.offset(ent.getLocation(), target) < 2)
speed = Math.min(speed, 1f);
EntityCreature ec = ((CraftCreature)ent).getHandle();
ec.getControllerMove().a(target.getX(), target.getY(), target.getZ(), speed);
}
}

View File

@ -1,23 +1,28 @@
package mineplex.hub;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
@ -35,6 +40,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -45,6 +51,7 @@ import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseSlime;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.portal.Portal;
import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager;
@ -60,7 +67,7 @@ import mineplex.minecraft.game.core.condition.ConditionManager;
public class HubManager extends MiniClientPlugin<HubClient>
{
public String Mode = "Normal";
public String Mode = "Christmas";
private BlockRestore _blockRestore;
private CoreClientManager _clientManager;
@ -86,6 +93,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
private boolean _shuttingDown;
private HashMap<String, Long> _portalTime = new HashMap<String, Long>();
private int _slot = 7;
private HashSet<Player> _disabled = new HashSet<Player>();
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager)
{
@ -128,6 +138,77 @@ public class HubManager extends MiniClientPlugin<HubClient>
}
}
@EventHandler
public void BumpJoin(PlayerJoinEvent event)
{
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1,
C.cYellow + "Stacker" + C.cWhite + " - " + C.cGreen + "Enabled"));
}
@EventHandler
public void BumpQuit(PlayerQuitEvent event)
{
_disabled.remove(event.getPlayer());
}
public boolean BumpDisabled(Entity ent)
{
if (ent == null)
return false;
return _disabled.contains(ent);
}
@EventHandler
public void BumpToggle(PlayerInteractEvent event)
{
if (event.getAction() == Action.PHYSICAL)
return;
Player player = event.getPlayer();
if (player.getInventory().getHeldItemSlot() != _slot)
return;
event.setCancelled(true);
if (_disabled.remove(player))
{
UtilPlayer.message(player, F.main("Hub Games", "You are back in the Hub Games!"));
player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1,
C.cYellow + "Stacker" + C.cWhite + " - " + C.cGreen + "Enabled"));
}
else
{
_disabled.add(player);
UtilPlayer.message(player, F.main("Hub Games", "You are no longer partaking in Hub Games."));
player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.MAGMA_CREAM, (byte)0, 1,
C.cYellow + "Stacker" + C.cWhite + " - " + C.cRed + "Disabled"));
}
}
@EventHandler
public void orderThatItem(final PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.REDSTONE_TORCH_OFF || event.getItemDrop().getItemStack().getType() == Material.REDSTONE_TORCH_ON)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(event.getItemDrop().getItemStack().getType());
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(event.getItemDrop().getItemStack().getType(), (byte)0, 1, ChatColor.RESET + C.cYellow + "Stacker" + C.cWhite + (_disabled.contains(event.getPlayer()) ? C.cWhite + " - " + C.cRed + "Disabled" : " - " + C.cGreen + "Enabled")));
event.getPlayer().updateInventory();
}
}
});
}
}
@EventHandler
public void redirectStopCommand(PlayerCommandPreprocessEvent event)
{
@ -270,7 +351,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
*/
}
/*
/* XXX TOURNEY
@EventHandler(priority = EventPriority.HIGHEST)
public void TournamentWins(PlayerJoinEvent event)
{
@ -662,4 +743,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
}
}
}
}

View File

@ -6,14 +6,20 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.hub.HubManager;
import mineplex.hub.gadget.gadgets.Halloween2013_BatGun;
@ -25,6 +31,7 @@ import mineplex.hub.gadget.types.Gadget;
import mineplex.hub.gadget.types.ItemGadget;
import mineplex.hub.gadget.ui.GadgetShop;
import mineplex.hub.mount.MountManager;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class GadgetManager extends MiniPlugin
{
@ -134,4 +141,47 @@ public class GadgetManager extends MiniPlugin
}
}
}
@EventHandler
public void SnowballPickup(BlockDamageEvent event)
{
if (!Manager.Mode.equals("Christmas"))
return;
if (event.getBlock().getType() != Material.SNOW)
return;
Player player = event.getPlayer();
RemoveItem(player);
player.getInventory().setItem(4, new ItemStack(Material.SNOW_BALL, 16));
}
@EventHandler
public void SnowballHit(CustomDamageEvent event)
{
if (!Manager.Mode.equals("Christmas"))
return;
Projectile proj = event.GetProjectile();
if (proj == null) return;
if (!(proj instanceof Snowball))
return;
event.SetCancelled("Snowball Cancel");
if (Manager.BumpDisabled(event.GetDamageeEntity()))
return;
if (Manager.BumpDisabled(event.GetDamagerEntity(true)))
return;
UtilAction.velocity(event.GetDamageeEntity(), UtilAlg.getTrajectory2d(event.GetDamagerEntity(true), event.GetDamageeEntity()),
0.4, false, 0, 0.2, 1, false);
//No Portal
Manager.SetPortalDelay(event.GetDamageeEntity());
}
}

View File

@ -88,9 +88,10 @@ public class PaintballGun extends ItemGadget
public void Paint(ProjectileHitEvent event)
{
if (Manager.Manager.GetParkour().InParkour(event.getEntity()))
{
return;
}
if (!_balls.remove(event.getEntity()))
return;
Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity());
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 49);
@ -116,7 +117,10 @@ public class PaintballGun extends ItemGadget
if (!UtilBlock.solid(block))
continue;
Manager.Manager.GetBlockRestore().Add(block, 35, color, 4000);
if (block.getType() == Material.CARPET)
Manager.Manager.GetBlockRestore().Add(block, 171, color, 4000);
else
Manager.Manager.GetBlockRestore().Add(block, 35, color, 4000);
}
}

View File

@ -64,11 +64,11 @@ public abstract class ItemGadget extends Gadget
public void RemoveItem(Player player)
{
player.getInventory().setItem(4, null);
_active.remove(player);
UtilPlayer.message(player, F.main("Gadget", "You unequipped " + F.elem(GetName()) + "."));
if (_active.remove(player))
{
player.getInventory().setItem(4, null);
UtilPlayer.message(player, F.main("Gadget", "You unequipped " + F.elem(GetName()) + "."));
}
}
public boolean IsItem(Player player)

View File

@ -29,6 +29,7 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.itemstack.ItemStackFactory;
@ -44,10 +45,10 @@ public class StackerManager extends MiniPlugin implements IThrown
private ProjectileManager _projectileManager;
private HashSet<Player> _disabled = new HashSet<Player>();
private HashSet<Entity> _tempStackShift = new HashSet<Entity>();
private int _slot = 7;
public StackerManager(HubManager manager)
{
@ -58,76 +59,18 @@ public class StackerManager extends MiniPlugin implements IThrown
_projectileManager = new ProjectileManager(manager.GetPlugin());
}
@EventHandler
public void ToggleStacker(PlayerInteractEvent event)
{
if (event.getAction() == Action.PHYSICAL)
return;
Player player = event.getPlayer();
if (player.getInventory().getHeldItemSlot() != _slot)
return;
event.setCancelled(true);
if (_disabled.remove(player))
{
UtilPlayer.message(player, F.main("Stacker", "You are back in the stacking games! Squeeeee!"));
player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1,
C.cYellow + "Stacker" + C.cWhite + " - " + C.cGreen + "Enabled"));
}
else
{
_disabled.add(player);
UtilPlayer.message(player, F.main("Stacker", "You are no longer stackable... boring!"));
player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.MAGMA_CREAM, (byte)0, 1,
C.cYellow + "Stacker" + C.cWhite + " - " + C.cRed + "Disabled"));
}
}
@EventHandler
public void PlayerJoin(PlayerJoinEvent event)
{
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1,
C.cYellow + "Stacker" + C.cWhite + " - " + C.cGreen + "Enabled"));
}
@EventHandler
public void orderThatItem(final PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.REDSTONE_TORCH_OFF || event.getItemDrop().getItemStack().getType() == Material.REDSTONE_TORCH_ON)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(event.getItemDrop().getItemStack().getType());
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(event.getItemDrop().getItemStack().getType(), (byte)0, 1, ChatColor.RESET + C.cYellow + "Stacker" + C.cWhite + (_disabled.contains(event.getPlayer()) ? C.cWhite + " - " + C.cRed + "Disabled" : " - " + C.cGreen + "Enabled")));
event.getPlayer().updateInventory();
}
}
});
}
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
_disabled.remove(event.getPlayer());
_tempStackShift.remove(event.getPlayer());
}
public boolean CanStack(LivingEntity ent)
{
if (!(ent instanceof Player))
return true;
if (_disabled.contains(ent))
if (Manager.BumpDisabled(ent))
return false;
if (Manager.GetVisibility().IsHiding(ent))
@ -146,6 +89,9 @@ public class StackerManager extends MiniPlugin implements IThrown
if (stacker.getGameMode() != GameMode.SURVIVAL)
return;
if (UtilGear.isMat(stacker.getItemInHand(), Material.SNOW_BALL))
return;
//Parkour Disable
if (Manager.GetParkour().InParkour(stacker))

View File

@ -8,6 +8,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
@ -27,9 +28,11 @@ import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Snowman;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
@ -42,6 +45,9 @@ public class WorldManager extends MiniPlugin
public HubManager Manager;
private HashSet<LivingEntity> _mobs = new HashSet<LivingEntity>();
private boolean _christmasSnow = false;
private long _christSnowTime = 0;
public WorldManager(HubManager manager)
{
@ -99,6 +105,10 @@ public class WorldManager extends MiniPlugin
Manager.GetCondition().Factory().Invisible("Perm", ent, ent, 999999999, 0, false, false, true);
Manager.GetCondition().Factory().Slow("Perm", ent, ent, 999999999, 1, false, false, false, true);
}
else if (Manager.Mode.equals("Christmas"))
{
_mobs.add(loc.getWorld().spawn(loc, Snowman.class));
}
else
{
r = Math.random();
@ -191,7 +201,32 @@ public class WorldManager extends MiniPlugin
if (Manager.Mode.equals("Halloween")) world.setTime(16000);
else world.setTime(6000);
world.setStorm(false);
if (Manager.Mode.equals("Christmas"))
{
if (_christmasSnow)
{
world.setStorm(true);
if (UtilTime.elapsed(_christSnowTime, 60000))
{
_christSnowTime = System.currentTimeMillis();
_christmasSnow = false;
}
}
else
{
world.setStorm(false);
if (UtilTime.elapsed(_christSnowTime, 120000))
{
_christSnowTime = System.currentTimeMillis();
_christmasSnow = true;
}
}
}
else world.setStorm(false);
}
@EventHandler
@ -231,4 +266,10 @@ public class WorldManager extends MiniPlugin
}
}
}
@EventHandler
public void BlockForm(BlockFormEvent event)
{
event.setCancelled(true);
}
}