siege work
This commit is contained in:
parent
fb53e443e7
commit
595ab0d763
@ -1,27 +1,23 @@
|
||||
package mineplex.game.clans;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
import org.bukkit.inventory.CraftingInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.material.SmoothBrick;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
|
||||
public class Recipes extends MiniPlugin
|
||||
{
|
||||
public Recipes(JavaPlugin plugin)
|
||||
@ -41,7 +37,14 @@ public class Recipes extends MiniPlugin
|
||||
diamondAxe.setIngredient('M', Material.DIAMOND_BLOCK);
|
||||
diamondAxe.setIngredient('S', Material.STICK);
|
||||
UtilServer.getServer().addRecipe(diamondAxe);
|
||||
|
||||
|
||||
|
||||
ShapedRecipe bricks = new ShapedRecipe(new ItemStack(Material.SMOOTH_BRICK, 1));
|
||||
bricks.shape("XX", "XX");
|
||||
bricks.setIngredient('X', new SmoothBrick(Material.COBBLESTONE));
|
||||
UtilServer.getServer().addRecipe(bricks);
|
||||
|
||||
|
||||
ItemStack boosterSword = ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte) 0, 1, "Booster Sword", false);
|
||||
ShapedRecipe goldSword = new ShapedRecipe(boosterSword);
|
||||
goldSword.shape("M","M","S");
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
@ -18,14 +20,11 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -51,9 +50,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
|
||||
public class ClansGame extends MiniPlugin
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
@ -84,7 +85,6 @@ import mineplex.game.clans.clans.gui.ClanShop;
|
||||
import mineplex.game.clans.clans.loot.LootManager;
|
||||
import mineplex.game.clans.clans.map.ItemMapManager;
|
||||
import mineplex.game.clans.clans.observer.ObserverManager;
|
||||
import mineplex.game.clans.clans.outpost.OutpostManager;
|
||||
import mineplex.game.clans.clans.playtime.Playtime;
|
||||
import mineplex.game.clans.clans.potato.PotatoManager;
|
||||
import mineplex.game.clans.clans.pvptimer.PvpTimer;
|
||||
@ -212,11 +212,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
if (serverName.equals("GarboClans-1"))
|
||||
{
|
||||
new OutpostManager(this);
|
||||
}
|
||||
|
||||
_instance = this;
|
||||
|
||||
_punish = punish;
|
||||
@ -258,7 +253,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);
|
||||
new SiegeManager(plugin, this);
|
||||
|
||||
_explosion = new Explosion(plugin, blockRestore);
|
||||
|
||||
@ -383,25 +378,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
hologram.start();
|
||||
}
|
||||
|
||||
// Iterator<Recipe> it = _plugin.getServer().recipeIterator();
|
||||
// Recipe recipe;
|
||||
// while (it.hasNext())
|
||||
// {
|
||||
// recipe = it.next();
|
||||
// if (recipe != null)
|
||||
// {
|
||||
// if (recipe.getResult().getType() == Material.SMOOTH_BRICK)
|
||||
// {
|
||||
// it.remove();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// final ShapedRecipe brrecipe = new ShapedRecipe(new ItemStack(Material.SMOOTH_BRICK, 1));
|
||||
// brrecipe.shape("XX", "XX", "");
|
||||
// brrecipe.setIngredient('X', Material.STONE);
|
||||
// UtilServer.getServer().addRecipe(brrecipe);
|
||||
//
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,9 @@ public class Outpost implements Listener
|
||||
private Location _origin;
|
||||
private Location _endCorner;
|
||||
|
||||
private Location _siegeAreaStart;
|
||||
private Location _siegeAreaEnd;
|
||||
|
||||
private Location _forceFieldStart;
|
||||
private Location _forceFieldEnd;
|
||||
|
||||
@ -105,6 +108,9 @@ public class Outpost implements Listener
|
||||
_forceFieldStart = _startCorner.clone().subtract(3, 0, 3);
|
||||
_forceFieldEnd = _endCorner.clone().add(3, 0, 3);
|
||||
|
||||
_siegeAreaStart = _startCorner.clone().subtract(7, 0, 7);
|
||||
_siegeAreaEnd = _endCorner.clone().add(7, 0, 7);
|
||||
|
||||
_origin = location.clone();
|
||||
|
||||
_type = type;
|
||||
@ -480,4 +486,10 @@ public class Outpost implements Listener
|
||||
{
|
||||
_removalQueue.add(builder);
|
||||
}
|
||||
|
||||
// AREA IN WHICH CANNONS AND OTHER SIEGE WEAPONS CAN BE PLACED
|
||||
public boolean isInSiegeArea(Location location)
|
||||
{
|
||||
return UtilAlg.inBoundingBox(location, _siegeAreaStart.clone().subtract(.9, 0, .9), _siegeAreaEnd);
|
||||
}
|
||||
}
|
||||
|
@ -210,4 +210,14 @@ public class OutpostManager extends MiniPlugin
|
||||
{
|
||||
_removalQueue.add(name);
|
||||
}
|
||||
|
||||
public boolean isInOutpostSiegeArea(Location location, ClanInfo clan)
|
||||
{
|
||||
if (!_outposts.containsKey(clan.getName().toLowerCase()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _outposts.get(clan.getName().toLowerCase()).isInSiegeArea(location);
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,39 @@
|
||||
package mineplex.game.clans.clans.siege;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.outpost.OutpostManager;
|
||||
import mineplex.game.clans.clans.siege.cannon.Cannon;
|
||||
|
||||
public class SiegeManager extends MiniPlugin
|
||||
{
|
||||
public static final ItemStack CANNON_ITEM = new ItemBuilder(Material.IRON_BLOCK, 1).setRawTitle(C.cBlue + "Cannon").setLore(C.cWhite + "BOOM BABY!").build();
|
||||
|
||||
public SiegeManager(JavaPlugin plugin)
|
||||
private ClansManager _clans;
|
||||
|
||||
private OutpostManager _outpostManager;
|
||||
|
||||
public SiegeManager(JavaPlugin plugin, ClansManager clans)
|
||||
{
|
||||
super("Siege", plugin);
|
||||
|
||||
_clans = clans;
|
||||
|
||||
_outpostManager = new OutpostManager(clans);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -27,16 +41,27 @@ public class SiegeManager extends MiniPlugin
|
||||
{
|
||||
if (event.getItemInHand().isSimilar(CANNON_ITEM))
|
||||
{
|
||||
Cannon.spawnCannon(getPlugin(), event.getPlayer().getLocation());
|
||||
if (!spawnCannon(event.getPlayer(), event.getBlock().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void debug(PlayerCommandPreprocessEvent event)
|
||||
public boolean spawnCannon(Player player, Location location)
|
||||
{
|
||||
if (event.getMessage().contains("cannon"))
|
||||
if (!_clans.isInClan(player))
|
||||
{
|
||||
Cannon.spawnCannon(getPlugin(), event.getPlayer().getLocation());
|
||||
UtilPlayer.message(player, F.main("Clans", "You must be in a Clan to place a cannon."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_outpostManager.isInOutpostSiegeArea(location, _clans.getClan(player)))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Clans", "A cannon must be placed in your own Clan's Outpost."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package mineplex.game.clans.clans.siege.cannon;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -51,10 +52,6 @@ public class Cannon implements Listener
|
||||
updateEntities();
|
||||
}
|
||||
|
||||
/*
|
||||
* Events
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerArmorStandManipulateEvent event)
|
||||
{
|
||||
@ -78,13 +75,4 @@ public class Cannon implements Listener
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user