Merge branch 'clans/beta' of ssh://184.154.0.242:7999/min/Mineplex into clans/beta

This commit is contained in:
NewGarbo 2016-01-12 07:12:18 +00:00
commit 7d858c72f3
4 changed files with 145 additions and 0 deletions

View File

@ -93,6 +93,7 @@ import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.regions.ClansRegions;
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
import mineplex.game.clans.clans.siege.SiegeManager;
import mineplex.game.clans.clans.stuck.StuckManager; import mineplex.game.clans.clans.stuck.StuckManager;
import mineplex.game.clans.clans.supplyDrop.SupplyDropManager; import mineplex.game.clans.clans.supplyDrop.SupplyDropManager;
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
@ -258,6 +259,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_itemMapManager = new ItemMapManager(this, _worldEvent); _itemMapManager = new ItemMapManager(this, _worldEvent);
new TntGeneratorManager(plugin, this); new TntGeneratorManager(plugin, this);
new SupplyDropManager(plugin, this); new SupplyDropManager(plugin, this);
new SiegeManager(plugin);
_explosion = new Explosion(plugin, blockRestore); _explosion = new Explosion(plugin, blockRestore);

View File

@ -0,0 +1,25 @@
package mineplex.game.clans.clans.siege;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.game.clans.clans.siege.cannon.Cannon;
public class SiegeManager extends MiniPlugin
{
public SiegeManager(JavaPlugin plugin)
{
super("Siege", plugin);
}
@EventHandler
public void debug(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().contains("cannon"))
{
Cannon.spawnCannon(getPlugin(), event.getPlayer().getLocation());
}
}
}

View File

@ -0,0 +1,90 @@
package mineplex.game.clans.clans.siege.cannon;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public class Cannon implements Listener
{
private Location _location;
private CannonState _state;
// Entity Information
private ArmorStand _armorStand;
private Cannon(Location location)
{
_location = location;
_state = CannonState.EMPTY;
updateEntities();
}
private void updateEntities()
{
if (_armorStand == null)
{
_armorStand = _location.getWorld().spawn(getArmorStandLocation(), ArmorStand.class);
}
_armorStand.teleport(getArmorStandLocation());
_armorStand.setVisible(false);
_armorStand.setGravity(false);
_armorStand.setHelmet(new ItemStack(_state.getMaterial(), 1, (short) 0, _state.getData()));
}
private Location getArmorStandLocation()
{
return _location.clone().add(0, -0.5, 0);
}
private void setState(CannonState state)
{
_state = state;
updateEntities();
}
/*
* Events
*/
@EventHandler
public void onInteract(PlayerArmorStandManipulateEvent event)
{
if (_armorStand != null && _armorStand.equals(event.getRightClicked()))
{
Entity passenger = _armorStand.getPassenger();
if (passenger == null)
{
_armorStand.setPassenger(event.getPlayer());
}
event.setCancelled(true);
}
}
@EventHandler
public void onDamage(EntityDamageEvent event)
{
if (_armorStand != null && _armorStand.equals(event.getEntity()))
{
event.setCancelled(true);
}
}
public static Cannon spawnCannon(JavaPlugin plugin, Location location)
{
System.out.println("Spawning Cannon at location " + location);
Cannon cannon = new Cannon(location);
plugin.getServer().getPluginManager().registerEvents(cannon, plugin);
return cannon;
}
}

View File

@ -0,0 +1,28 @@
package mineplex.game.clans.clans.siege.cannon;
import org.bukkit.Material;
public enum CannonState
{
EMPTY(Material.SPONGE, (byte) 0),
LOADED(Material.SPONGE, (byte) 1);
private Material _material;
private byte _data;
CannonState(Material material, byte data)
{
_material = material;
_data = data;
}
public byte getData()
{
return _data;
}
public Material getMaterial()
{
return _material;
}
}