stop players from placing water in outposts
This commit is contained in:
parent
bcd4480f23
commit
41e140d5ca
@ -11,6 +11,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@ -97,4 +98,9 @@ public class UtilServer
|
||||
{
|
||||
return getServer().getPluginManager();
|
||||
}
|
||||
|
||||
public static void callEvent(Event event)
|
||||
{
|
||||
getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package mineplex.game.clans.clans.event;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class ClansWaterPlaceEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private Block _block;
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public ClansWaterPlaceEvent(Player player, Block block)
|
||||
{
|
||||
_player = player;
|
||||
_block = block;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public Block getBlock()
|
||||
{
|
||||
return _block;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled)
|
||||
{
|
||||
_cancelled = cancelled;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -10,10 +10,7 @@ import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -21,18 +18,14 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.ColorFader;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.LoopIterator;
|
||||
import mineplex.core.common.util.NonFinalInteger;
|
||||
import mineplex.core.common.util.RGBData;
|
||||
@ -42,7 +35,6 @@ import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilColor;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
@ -51,20 +43,17 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansBlacklist;
|
||||
import mineplex.game.clans.clans.event.ClansWaterPlaceEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
|
||||
import mineplex.game.clans.clans.siege.events.SiegeWeaponExplodeEvent;
|
||||
import mineplex.game.clans.clans.siege.outpost.build.OutpostBlock;
|
||||
import mineplex.game.clans.clans.siege.repository.tokens.OutpostToken;
|
||||
import mineplex.game.clans.clans.siege.weapon.SiegeWeapon;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
|
||||
@ -340,10 +329,23 @@ public class Outpost implements Listener
|
||||
};
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWaterPlace(ClansWaterPlaceEvent event)
|
||||
{
|
||||
if (UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place water in Outposts."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilAlg.inBoundingBox(event.getBlock().getLocation(), _startCorner.clone().subtract(.5, 0, .5), _endCorner))
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.weight.Weight;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
@ -65,7 +66,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.siege.outpost.Outpost;
|
||||
import mineplex.game.clans.clans.event.ClansWaterPlaceEvent;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||
@ -334,12 +335,27 @@ public class Gameplay extends MiniPlugin
|
||||
@EventHandler
|
||||
public void LapisPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getBlock().getType() != Material.LAPIS_BLOCK) return;
|
||||
if (event.getBlock().getType() != Material.LAPIS_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
ClansWaterPlaceEvent placeEvent = new ClansWaterPlaceEvent(event.getPlayer(), event.getBlock());
|
||||
|
||||
UtilServer.callEvent(placeEvent);
|
||||
|
||||
if (placeEvent.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UtilInv.remove(event.getPlayer(), Material.LAPIS_BLOCK, (byte) 0, 1);
|
||||
|
||||
final Block block = event.getBlock();
|
||||
|
Loading…
Reference in New Issue
Block a user