Cannon work
This commit is contained in:
parent
677e95a7fd
commit
6c2b40d63a
@ -23,7 +23,7 @@
|
||||
</profile>
|
||||
<profile default="false" name="Annotation profile for bungee" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target\generated-test-sources\test-annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
|
@ -86,6 +86,7 @@ import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
|
||||
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
|
||||
import mineplex.game.clans.clans.regions.ClansRegions;
|
||||
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.supplyDrop.SupplyDropManager;
|
||||
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
|
||||
@ -246,6 +247,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
_itemMapManager = new ItemMapManager(this, _worldEvent);
|
||||
new TntGeneratorManager(plugin, this);
|
||||
new SupplyDropManager(plugin, this);
|
||||
new SiegeManager(plugin);
|
||||
|
||||
_explosion = new Explosion(plugin, blockRestore);
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user