|
|
|
@ -27,6 +27,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
|
|
|
|
|
|
|
|
|
|
import mineplex.core.MiniPlugin;
|
|
|
|
|
import mineplex.core.blockrestore.BlockRestoreData;
|
|
|
|
@ -35,23 +36,25 @@ import mineplex.core.common.util.F;
|
|
|
|
|
import mineplex.core.common.util.UtilBlock;
|
|
|
|
|
import mineplex.core.common.util.UtilEvent;
|
|
|
|
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
|
|
|
|
import mineplex.core.common.util.UtilItem;
|
|
|
|
|
import mineplex.core.common.util.UtilGear;
|
|
|
|
|
import mineplex.core.common.util.UtilItem;
|
|
|
|
|
import mineplex.core.common.util.UtilMath;
|
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
|
|
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
|
|
|
|
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
|
|
|
|
import mineplex.game.clans.core.repository.ClanTerritory;
|
|
|
|
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
|
|
|
|
|
|
|
|
public class ClansGame extends MiniPlugin
|
|
|
|
|
{
|
|
|
|
|
private ClansManager Clans;
|
|
|
|
|
private ClansManager _clans;
|
|
|
|
|
|
|
|
|
|
public ClansGame(JavaPlugin plugin, ClansManager clans)
|
|
|
|
|
{
|
|
|
|
|
super("Clans Game", plugin);
|
|
|
|
|
|
|
|
|
|
Clans = clans;
|
|
|
|
|
_clans = clans;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler(ignoreCancelled = true)
|
|
|
|
@ -63,7 +66,7 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
{
|
|
|
|
|
if (!event.getPlayer().isSneaking() || !hasItem)
|
|
|
|
|
{
|
|
|
|
|
Clans.getClassShop().attemptShopOpen(event.getPlayer());
|
|
|
|
|
_clans.getClassShop().attemptShopOpen(event.getPlayer());
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -72,43 +75,37 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
|
public void BlockBurn(BlockBurnEvent event)
|
|
|
|
|
{
|
|
|
|
|
if (Clans.getClanUtility().isBorderlands(event.getBlock().getLocation()))
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
if (_clans.getClanUtility().isBorderlands(event.getBlock().getLocation())) event.setCancelled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
|
public void BlockSpread(BlockIgniteEvent event)
|
|
|
|
|
{
|
|
|
|
|
if (event.getCause() == IgniteCause.SPREAD)
|
|
|
|
|
if (Clans.getClanUtility().isBorderlands(event.getBlock().getLocation()))
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
if (event.getCause() == IgniteCause.SPREAD) if (_clans.getClanUtility().isBorderlands(event.getBlock().getLocation())) event.setCancelled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
|
public void BlockPlace(BlockPlaceEvent event)
|
|
|
|
|
{
|
|
|
|
|
if (event.isCancelled())
|
|
|
|
|
return;
|
|
|
|
|
if (event.isCancelled()) return;
|
|
|
|
|
|
|
|
|
|
if (event.getBlock().getType() != Material.LADDER)
|
|
|
|
|
return;
|
|
|
|
|
if (event.getBlock().getType() != Material.LADDER) return;
|
|
|
|
|
|
|
|
|
|
if (Clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF)
|
|
|
|
|
return;
|
|
|
|
|
if (_clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF) return;
|
|
|
|
|
|
|
|
|
|
final Block block = event.getBlock();
|
|
|
|
|
|
|
|
|
|
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Clans.getPlugin(), new Runnable()
|
|
|
|
|
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_clans.getPlugin(), new Runnable()
|
|
|
|
|
{
|
|
|
|
|
public void run()
|
|
|
|
|
{
|
|
|
|
|
Clans.getBlockRestore().add(block, 65, block.getData(), 30000);
|
|
|
|
|
_clans.getBlockRestore().add(block, 65, block.getData(), 30000);
|
|
|
|
|
|
|
|
|
|
BlockRestoreData data = Clans.getBlockRestore().getData(block);
|
|
|
|
|
BlockRestoreData data = _clans.getBlockRestore().getData(block);
|
|
|
|
|
if (data != null)
|
|
|
|
|
{
|
|
|
|
|
data.setFromId(0);
|
|
|
|
|
data.setFromData((byte)0);
|
|
|
|
|
data.setFromData((byte) 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, 0);
|
|
|
|
@ -123,11 +120,11 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
Player defender = (Player) event.getCaught();
|
|
|
|
|
Player attacker = event.getPlayer();
|
|
|
|
|
|
|
|
|
|
if (!Clans.getClanUtility().canHurt(defender, attacker))
|
|
|
|
|
if (!_clans.getClanUtility().canHurt(defender, attacker))
|
|
|
|
|
{
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
ClanRelation rel = Clans.getRelation(defender, attacker);
|
|
|
|
|
UtilPlayer.message(attacker, F.main("Clans", "You cannot harm " + Clans.getClanUtility().mRel(rel, defender.getName(), false) + "."));
|
|
|
|
|
ClanRelation rel = _clans.getRelation(defender, attacker);
|
|
|
|
|
UtilPlayer.message(attacker, F.main("Clans", "You cannot harm " + _clans.getClanUtility().mRel(rel, defender.getName(), false) + "."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -158,166 +155,142 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
@EventHandler
|
|
|
|
|
public final void onFoodLevelChangeEvent(FoodLevelChangeEvent event)
|
|
|
|
|
{
|
|
|
|
|
((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original food level changes
|
|
|
|
|
((Player) event.getEntity()).setSaturation(3.8F); // While not entirely
|
|
|
|
|
// accurate, this is
|
|
|
|
|
// a pretty good
|
|
|
|
|
// guess at original
|
|
|
|
|
// food level
|
|
|
|
|
// changes
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
|
|
|
|
public void BlockBreak(BlockBreakEvent event)
|
|
|
|
|
{
|
|
|
|
|
if (event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL || event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
|
|
|
|
return;
|
|
|
|
|
if (event.getPlayer().getWorld().getEnvironment() != Environment.NORMAL || event.getPlayer().getGameMode() == GameMode.CREATIVE) return;
|
|
|
|
|
|
|
|
|
|
String mimic = Clans.Get(event.getPlayer()).getMimic();
|
|
|
|
|
String mimic = _clans.Get(event.getPlayer()).getMimic();
|
|
|
|
|
|
|
|
|
|
if (mimic.length() != 0)
|
|
|
|
|
{
|
|
|
|
|
if (Clans.getClanUtility().searchClanPlayer(event.getPlayer(), mimic, false) != null)
|
|
|
|
|
if (_clans.getClanUtility().searchClanPlayer(event.getPlayer(), mimic, false) != null)
|
|
|
|
|
mimic = C.cGray + " You are currently mimicing " + C.cGold + mimic;
|
|
|
|
|
else
|
|
|
|
|
mimic = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Borderlands
|
|
|
|
|
if (Clans.getClanUtility().isBorderlands(event.getBlock().getLocation()) && event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
|
|
|
|
// Borderlands
|
|
|
|
|
if (_clans.getClanUtility().isBorderlands(event.getBlock().getLocation()) && event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
|
|
|
|
{
|
|
|
|
|
//Disallow
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
|
|
|
|
" in " +
|
|
|
|
|
F.elem("Borderlands") +
|
|
|
|
|
"."));
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break blocks in " + F.elem("Borderlands") + "."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Clans.getClanBlocks().canBreak(event.getBlock().getTypeId()))
|
|
|
|
|
return;
|
|
|
|
|
if (_clans.getClanBlocks().canBreak(event.getBlock().getTypeId())) return;
|
|
|
|
|
|
|
|
|
|
if (Clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF)
|
|
|
|
|
if (_clans.getClanUtility().getAccess(event.getPlayer(), event.getBlock().getLocation()) == ClanRelation.SELF)
|
|
|
|
|
{
|
|
|
|
|
//Disallow Shops
|
|
|
|
|
if (event.getBlock().getType() == Material.ENDER_CHEST || event.getBlock().getType() == Material.ENCHANTMENT_TABLE)
|
|
|
|
|
if (Clans.getClanUtility().isSafe(event.getBlock().getLocation()))
|
|
|
|
|
// Disallow Shops
|
|
|
|
|
if (event.getBlock().getType() == Material.ENDER_CHEST || event.getBlock().getType() == Material.ENCHANTMENT_TABLE) if (_clans.getClanUtility().isSafe(event.getBlock().getLocation()))
|
|
|
|
|
{
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) + "'s Territory."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Disallow Recruit Chest
|
|
|
|
|
if (_clans.getClanUtility().isClaimed(event.getBlock().getLocation())) if (event.getBlock().getTypeId() == 54)
|
|
|
|
|
{
|
|
|
|
|
if (_clans.getClanUtility().getRole(event.getPlayer()) == ClanRole.RECRUIT)
|
|
|
|
|
{
|
|
|
|
|
//Disallow
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
|
|
|
|
" in " +
|
|
|
|
|
Clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) +
|
|
|
|
|
"."));
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "Clan Recruits cannot break " + F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) + "."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Disallow Recruit Chest
|
|
|
|
|
if (Clans.getClanUtility().isClaimed(event.getBlock().getLocation()))
|
|
|
|
|
if (event.getBlock().getTypeId() == 54)
|
|
|
|
|
{
|
|
|
|
|
if (Clans.getClanUtility().getRole(event.getPlayer()) == ClanRole.RECRUIT)
|
|
|
|
|
{
|
|
|
|
|
//Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "Clan Recruits cannot break " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) + "."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Allow
|
|
|
|
|
// Allow
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Clans.getWarManager().allowFromInvade(event.getBlock().getLocation(), event.getPlayer()))
|
|
|
|
|
if (_clans.getWarManager().allowFromInvade(event.getBlock().getLocation(), event.getPlayer()))
|
|
|
|
|
{
|
|
|
|
|
// Allow because of invasion
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Disallow
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(event.getBlock(), true)) +
|
|
|
|
|
" in " +
|
|
|
|
|
Clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) +
|
|
|
|
|
"." +
|
|
|
|
|
mimic));
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) + "'s Territory." + mimic));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
|
public void Damage(CustomDamageEvent event)
|
|
|
|
|
{
|
|
|
|
|
if (event.IsCancelled())
|
|
|
|
|
return;
|
|
|
|
|
if (event.IsCancelled()) return;
|
|
|
|
|
|
|
|
|
|
Player damagee = event.GetDamageePlayer();
|
|
|
|
|
if (damagee == null) return;
|
|
|
|
|
if (damagee == null) return;
|
|
|
|
|
|
|
|
|
|
Player damager = event.GetDamagerPlayer(true);
|
|
|
|
|
if (damager == null) return;
|
|
|
|
|
if (damager == null) return;
|
|
|
|
|
|
|
|
|
|
if (!Clans.getClanUtility().canHurt(damagee, damager))
|
|
|
|
|
if (!_clans.getClanUtility().canHurt(damagee, damager))
|
|
|
|
|
{
|
|
|
|
|
//Cancel
|
|
|
|
|
// Cancel
|
|
|
|
|
event.SetCancelled("Clans Ally");
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
// Inform
|
|
|
|
|
if (damager != null)
|
|
|
|
|
{
|
|
|
|
|
ClanRelation rel = Clans.getRelation(damagee, damager);
|
|
|
|
|
UtilPlayer.message(damager, F.main("Clans",
|
|
|
|
|
"You cannot harm " + Clans.getClanUtility().mRel(rel, damagee.getName(), false) + "."));
|
|
|
|
|
ClanRelation rel = _clans.getRelation(damagee, damager);
|
|
|
|
|
UtilPlayer.message(damager, F.main("Clans", "You cannot harm " + _clans.getClanUtility().mRel(rel, damagee.getName(), false) + "."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Block Interact and Placement
|
|
|
|
|
// Block Interact and Placement
|
|
|
|
|
public void Interact(PlayerInteractEvent event)
|
|
|
|
|
{
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
|
|
if (player.getWorld().getEnvironment() != Environment.NORMAL)
|
|
|
|
|
return;
|
|
|
|
|
if (player.getWorld().getEnvironment() != Environment.NORMAL) return;
|
|
|
|
|
|
|
|
|
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
|
|
|
|
return;
|
|
|
|
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) return;
|
|
|
|
|
|
|
|
|
|
//Block Interaction
|
|
|
|
|
// Block Interaction
|
|
|
|
|
Location loc = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation();
|
|
|
|
|
if (UtilBlock.usable(event.getClickedBlock())) loc = event.getClickedBlock().getLocation();
|
|
|
|
|
if (UtilBlock.usable(event.getClickedBlock())) loc = event.getClickedBlock().getLocation();
|
|
|
|
|
|
|
|
|
|
if (Clans.getWarManager().allowFromInvade(loc, event.getPlayer()))
|
|
|
|
|
if (_clans.getWarManager().allowFromInvade(loc, event.getPlayer()))
|
|
|
|
|
{
|
|
|
|
|
// Allow because of invasion
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Borderlands
|
|
|
|
|
if ( player.getGameMode() != GameMode.CREATIVE &&
|
|
|
|
|
player.getItemInHand() != null &&
|
|
|
|
|
Clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) &&
|
|
|
|
|
Clans.getClanUtility().isBorderlands(event.getClickedBlock().getLocation()))
|
|
|
|
|
// Borderlands
|
|
|
|
|
if (player.getGameMode() != GameMode.CREATIVE && player.getItemInHand() != null && _clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) && _clans.getClanUtility().isBorderlands(event.getClickedBlock().getLocation()))
|
|
|
|
|
{
|
|
|
|
|
//Disallow
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot use/place " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
|
|
|
|
" in " +
|
|
|
|
|
F.elem("Borderlands") +
|
|
|
|
|
"."));
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot place blocks in " + F.elem("Borderlands") + "."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClanRelation access = Clans.getClanUtility().getAccess(player, loc);
|
|
|
|
|
ClanRelation access = _clans.getClanUtility().getAccess(player, loc);
|
|
|
|
|
|
|
|
|
|
//Hoe Return
|
|
|
|
|
// Hoe Return
|
|
|
|
|
if (access != ClanRelation.SELF && !UtilBlock.usable(event.getClickedBlock()))
|
|
|
|
|
{
|
|
|
|
|
if (UtilGear.isHoe(player.getItemInHand()))
|
|
|
|
@ -327,69 +300,52 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Full Access
|
|
|
|
|
// Full Access
|
|
|
|
|
if (access == ClanRelation.SELF)
|
|
|
|
|
{
|
|
|
|
|
//Recruits cannot open Chests // IN OWN CLAIMED LAND
|
|
|
|
|
if (event.getClickedBlock().getTypeId() == 54 && Clans.getClanUtility().getOwner(loc) != null)
|
|
|
|
|
// Recruits cannot open Chests // IN OWN CLAIMED LAND
|
|
|
|
|
if (event.getClickedBlock().getTypeId() == 54 && _clans.getClanUtility().getOwner(loc) != null)
|
|
|
|
|
{
|
|
|
|
|
if (Clans.getClanUtility().getRole(player) == ClanRole.RECRUIT)
|
|
|
|
|
if (_clans.getClanUtility().getRole(player) == ClanRole.RECRUIT)
|
|
|
|
|
{
|
|
|
|
|
//Disallow
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "Clan Recruits cannot access " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
|
|
|
|
"."));
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "Clan Recruits cannot access " + F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) + "."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Wilderness Adjacent
|
|
|
|
|
if ( event.getAction() == Action.RIGHT_CLICK_BLOCK &&
|
|
|
|
|
!UtilBlock.usable(event.getClickedBlock()) &&
|
|
|
|
|
player.getItemInHand() != null &&
|
|
|
|
|
Clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) &&
|
|
|
|
|
!Clans.getClanUtility().isClaimed(loc))
|
|
|
|
|
// Wilderness Adjacent
|
|
|
|
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && !UtilBlock.usable(event.getClickedBlock()) && player.getItemInHand() != null && _clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()) && !_clans.getClanUtility().isClaimed(loc))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
String enemy = null;
|
|
|
|
|
boolean self = false;
|
|
|
|
|
|
|
|
|
|
for (int x=-1 ; x<=1 ; x++)
|
|
|
|
|
for (int z=-1 ; z<=1 ; z++)
|
|
|
|
|
for (int x = -1; x <= 1; x++)
|
|
|
|
|
for (int z = -1; z <= 1; z++)
|
|
|
|
|
{
|
|
|
|
|
if (self)
|
|
|
|
|
continue;
|
|
|
|
|
if (self) continue;
|
|
|
|
|
|
|
|
|
|
if (x != 0 && z != 0 || x == 0 && z == 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (x != 0 && z != 0 || x == 0 && z == 0) continue;
|
|
|
|
|
|
|
|
|
|
Location sideLoc = new Location(loc.getWorld(), loc.getX()+x, loc.getY(), loc.getZ()+z);
|
|
|
|
|
Location sideLoc = new Location(loc.getWorld(), loc.getX() + x, loc.getY(), loc.getZ() + z);
|
|
|
|
|
|
|
|
|
|
if (Clans.getClanUtility().isSelf(player, sideLoc))
|
|
|
|
|
self = true;
|
|
|
|
|
if (_clans.getClanUtility().isSelf(player, sideLoc)) self = true;
|
|
|
|
|
|
|
|
|
|
if (enemy != null)
|
|
|
|
|
continue;
|
|
|
|
|
if (enemy != null) continue;
|
|
|
|
|
|
|
|
|
|
if (Clans.getClanUtility().getAccess(player, sideLoc) != ClanRelation.SELF)
|
|
|
|
|
enemy = Clans.getClanUtility().getOwnerStringRel(
|
|
|
|
|
new Location(loc.getWorld(), loc.getX()+x, loc.getY(), loc.getZ()+z),
|
|
|
|
|
player);
|
|
|
|
|
if (_clans.getClanUtility().getAccess(player, sideLoc) != ClanRelation.SELF) enemy = _clans.getClanUtility().getOwnerStringRel(new Location(loc.getWorld(), loc.getX() + x, loc.getY(), loc.getZ() + z), player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enemy != null && !self)
|
|
|
|
|
{
|
|
|
|
|
//Disallow
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot use/place " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(player.getItemInHand(), true)) +
|
|
|
|
|
" next to " +
|
|
|
|
|
enemy +
|
|
|
|
|
"."));
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot place blocks next to " + enemy + "."));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -398,78 +354,58 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String mimic = Clans.Get(player).getMimic();
|
|
|
|
|
String mimic = _clans.Get(player).getMimic();
|
|
|
|
|
|
|
|
|
|
if (mimic.length() != 0)
|
|
|
|
|
{
|
|
|
|
|
if (Clans.getClanUtility().searchClanPlayer(player, mimic, false) != null)
|
|
|
|
|
if (_clans.getClanUtility().searchClanPlayer(player, mimic, false) != null)
|
|
|
|
|
mimic = C.cGray + " You are currently mimicing " + C.cGold + mimic;
|
|
|
|
|
else
|
|
|
|
|
mimic = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Deny Interaction
|
|
|
|
|
if (Clans.getClanBlocks().denyInteract(event.getClickedBlock().getTypeId()))
|
|
|
|
|
// Deny Interaction
|
|
|
|
|
if (_clans.getClanBlocks().denyInteract(event.getClickedBlock().getTypeId()))
|
|
|
|
|
{
|
|
|
|
|
//Block Action
|
|
|
|
|
// Block Action
|
|
|
|
|
if (access == ClanRelation.NEUTRAL)
|
|
|
|
|
{
|
|
|
|
|
//Allow Field Chest
|
|
|
|
|
if (event.getClickedBlock().getTypeId() == 54)
|
|
|
|
|
if (Clans.getClanUtility().isSpecial(event.getClickedBlock().getLocation(), "Fields"))
|
|
|
|
|
return;
|
|
|
|
|
// Allow Field Chest
|
|
|
|
|
if (event.getClickedBlock().getTypeId() == 54) if (_clans.getClanUtility().isSpecial(event.getClickedBlock().getLocation(), "Fields")) return;
|
|
|
|
|
|
|
|
|
|
//Disallow
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot use " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
|
|
|
|
" in " +
|
|
|
|
|
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(),
|
|
|
|
|
player) +
|
|
|
|
|
"." +
|
|
|
|
|
mimic));
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot use items in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(), player) + "." + mimic));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//Block is not Trust Allowed
|
|
|
|
|
else if (!Clans.getClanBlocks().allowInteract(event.getClickedBlock().getTypeId()) || access != ClanRelation.ALLY_TRUST)
|
|
|
|
|
// Block is not Trust Allowed
|
|
|
|
|
else if (!_clans.getClanBlocks().allowInteract(event.getClickedBlock().getTypeId()) || access != ClanRelation.ALLY_TRUST)
|
|
|
|
|
{
|
|
|
|
|
//Disallow
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot use " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(event.getClickedBlock(), true)) +
|
|
|
|
|
" in " +
|
|
|
|
|
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(),
|
|
|
|
|
player) +
|
|
|
|
|
"." +
|
|
|
|
|
mimic));
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot use items in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getLocation(), player) + "." + mimic));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Block Placement
|
|
|
|
|
// Block Placement
|
|
|
|
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
|
|
|
|
{
|
|
|
|
|
if (player.getItemInHand().getType() != Material.AIR)
|
|
|
|
|
{
|
|
|
|
|
if (player.getGameMode() != GameMode.CREATIVE && Clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()))
|
|
|
|
|
if (player.getGameMode() != GameMode.CREATIVE && _clans.getClanBlocks().denyUsePlace(player.getItemInHand().getTypeId()))
|
|
|
|
|
{
|
|
|
|
|
//Disallow
|
|
|
|
|
// Disallow
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot use/place " +
|
|
|
|
|
F.elem(ItemStackFactory.Instance.GetName(player.getItemInHand(), true)) +
|
|
|
|
|
" in " +
|
|
|
|
|
Clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(),
|
|
|
|
|
player) +
|
|
|
|
|
"." +
|
|
|
|
|
mimic));
|
|
|
|
|
// Inform
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot place blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getClickedBlock().getRelative(event.getBlockFace()).getLocation(), player) + "." + mimic));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -480,25 +416,22 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
|
public void Piston(BlockPistonExtendEvent event)
|
|
|
|
|
{
|
|
|
|
|
ClanInfo pistonClan = Clans.getClanUtility().getOwner(event.getBlock().getLocation());
|
|
|
|
|
ClanInfo pistonClan = _clans.getClanUtility().getOwner(event.getBlock().getLocation());
|
|
|
|
|
|
|
|
|
|
Block push = event.getBlock();
|
|
|
|
|
for (int i=0 ; i<13 ; i++)
|
|
|
|
|
for (int i = 0; i < 13; i++)
|
|
|
|
|
{
|
|
|
|
|
push = push.getRelative(event.getDirection());
|
|
|
|
|
|
|
|
|
|
Block front = push.getRelative(event.getDirection()).getRelative(event.getDirection());
|
|
|
|
|
|
|
|
|
|
if (push.getType() == Material.AIR)
|
|
|
|
|
return;
|
|
|
|
|
if (push.getType() == Material.AIR) return;
|
|
|
|
|
|
|
|
|
|
ClanInfo pushClan = Clans.getClanUtility().getOwner(front.getLocation());
|
|
|
|
|
ClanInfo pushClan = _clans.getClanUtility().getOwner(front.getLocation());
|
|
|
|
|
|
|
|
|
|
if (pushClan == null)
|
|
|
|
|
continue;
|
|
|
|
|
if (pushClan == null) continue;
|
|
|
|
|
|
|
|
|
|
if (pushClan.isAdmin())
|
|
|
|
|
continue;
|
|
|
|
|
if (pushClan.isAdmin()) continue;
|
|
|
|
|
|
|
|
|
|
if (pistonClan == null)
|
|
|
|
|
{
|
|
|
|
@ -507,8 +440,7 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pistonClan.equals(pushClan))
|
|
|
|
|
continue;
|
|
|
|
|
if (pistonClan.equals(pushClan)) continue;
|
|
|
|
|
|
|
|
|
|
push.getWorld().playEffect(push.getLocation(), Effect.STEP_SOUND, push.getTypeId());
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
@ -519,8 +451,8 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void Quit(PlayerQuitEvent event)
|
|
|
|
|
{
|
|
|
|
|
ClanInfo clan = Clans.getClanUtility().getClanByPlayer(event.getPlayer());
|
|
|
|
|
if (clan == null) return;
|
|
|
|
|
ClanInfo clan = _clans.getClanUtility().getClanByPlayer(event.getPlayer());
|
|
|
|
|
if (clan == null) return;
|
|
|
|
|
|
|
|
|
|
clan.setLastOnline(new Timestamp(System.currentTimeMillis()));
|
|
|
|
|
}
|
|
|
|
@ -530,18 +462,17 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (event.getEntityType() != EntityType.PRIMED_TNT && event.getEntityType() != EntityType.MINECART_TNT)
|
|
|
|
|
return;
|
|
|
|
|
if (event.getEntityType() != EntityType.PRIMED_TNT && event.getEntityType() != EntityType.MINECART_TNT) return;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClanInfo clan = Clans.getClanUtility().getOwner(event.getEntity().getLocation());
|
|
|
|
|
if (clan == null) return;
|
|
|
|
|
ClanInfo clan = _clans.getClanUtility().getOwner(event.getEntity().getLocation());
|
|
|
|
|
if (clan == null) return;
|
|
|
|
|
|
|
|
|
|
if (Clans.getWarManager().isBeingInvaded(clan))
|
|
|
|
|
if (_clans.getWarManager().isBeingInvaded(clan))
|
|
|
|
|
{
|
|
|
|
|
// Allow because of invasion
|
|
|
|
|
return;
|
|
|
|
@ -552,4 +483,200 @@ public class ClansGame extends MiniPlugin
|
|
|
|
|
else
|
|
|
|
|
clan.inform(C.cRed + "Your Territory is under attack!", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void onClanHomeInteract(PlayerInteractEvent event)
|
|
|
|
|
{
|
|
|
|
|
if (!UtilEvent.isAction(event, ActionType.L_BLOCK) && !UtilEvent.isAction(event, ActionType.R_BLOCK))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClanInfo clan = _clans.getClan(event.getPlayer());
|
|
|
|
|
|
|
|
|
|
Block block = event.getClickedBlock();
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
|
|
if (clan == null)
|
|
|
|
|
{
|
|
|
|
|
for (String otherClanName : _clans.getClanNameSet())
|
|
|
|
|
{
|
|
|
|
|
boolean done = false;
|
|
|
|
|
ClanInfo otherClan = _clans.getClan(otherClanName);
|
|
|
|
|
|
|
|
|
|
if (otherClan.getHome() == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(UtilMath.offset(block.getLocation(), otherClan.getHome()) < 3))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int x = -2; x < 2; x++)
|
|
|
|
|
{
|
|
|
|
|
for (int z = -2; z < 2; z++)
|
|
|
|
|
{
|
|
|
|
|
Block otherBlock = event.getClickedBlock().getLocation().add(x, 0, z).getBlock();
|
|
|
|
|
if (otherBlock.getType().equals(Material.BED_BLOCK))
|
|
|
|
|
{
|
|
|
|
|
if (UtilEvent.isAction(event, ActionType.R_BLOCK))
|
|
|
|
|
{
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
done = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (done)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (done)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (clan.getHome() == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(UtilMath.offset(block.getLocation(), clan.getHome()) < 3))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int x = -2; x < 2; x++)
|
|
|
|
|
{
|
|
|
|
|
for (int z = -2; z < 2; z++)
|
|
|
|
|
{
|
|
|
|
|
Block otherBlock = event.getClickedBlock().getLocation().add(x, 0, z).getBlock();
|
|
|
|
|
if (otherBlock.getType().equals(Material.BED_BLOCK))
|
|
|
|
|
{
|
|
|
|
|
if (UtilEvent.isAction(event, ActionType.R_BLOCK))
|
|
|
|
|
{
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (clan.getMembers().get(player.getUniqueId()).getRole() == ClanRole.LEADER || clan.getMembers().get(player.getUniqueId()).getRole() == ClanRole.ADMIN)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "Only the Clan Leader and Admins can manage the Clan Home."));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void onPlaceBed(BlockPlaceEvent event)
|
|
|
|
|
{
|
|
|
|
|
if (event.getItemInHand().getType().equals(Material.BED) || event.getItemInHand().getType().equals(Material.BED_BLOCK))
|
|
|
|
|
{
|
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot manually place beds, to set your clan home, type " + F.elem("/c sethome") + "."));
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void onClanHomeDestroyed(BlockBreakEvent event)
|
|
|
|
|
{
|
|
|
|
|
ClanInfo userClan = _clans.getClan(event.getPlayer());
|
|
|
|
|
|
|
|
|
|
Block block = event.getBlock();
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
|
|
ClanInfo blockClan = null;
|
|
|
|
|
ClanTerritory claim = _clans.getClanUtility().getClaim(block.getLocation());
|
|
|
|
|
|
|
|
|
|
if (claim != null)
|
|
|
|
|
{
|
|
|
|
|
if (ClansBlacklist.isValidClanName(claim.Owner))
|
|
|
|
|
{
|
|
|
|
|
blockClan = _clans.getClan(claim.Owner);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (blockClan == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (blockClan.getHome() == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UtilMath.offset(block.getLocation(), blockClan.getHome()) > 3)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!block.getType().equals(Material.BED_BLOCK))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!blockClan.equals(userClan))
|
|
|
|
|
{
|
|
|
|
|
if (blockClan.isAlly(userClan))
|
|
|
|
|
{
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You cannot remove an Ally's Clan Home."));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You have destroyed " + F.elem(blockClan.getName()) + "'s Clan Home!"));
|
|
|
|
|
removeHome(userClan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (userClan.getMembers().get(player.getUniqueId()).getRole() == ClanRole.LEADER || userClan.getMembers().get(player.getUniqueId()).getRole() == ClanRole.ADMIN)
|
|
|
|
|
{
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
removeHome(userClan);
|
|
|
|
|
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "You have removed your Clan Home."));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
UtilPlayer.message(player, F.main("Clans", "Only the Clan Leader and Admins can remove the Clan Home."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void removeHome(ClanInfo clan)
|
|
|
|
|
{
|
|
|
|
|
clan.getHome().getBlock().setType(Material.AIR);
|
|
|
|
|
|
|
|
|
|
for (int x2 = -1; x2 < 1; x2++)
|
|
|
|
|
{
|
|
|
|
|
for (int z2 = -1; z2 < 1; z2++)
|
|
|
|
|
{
|
|
|
|
|
Block block = clan.getHome().clone().add(x2, 0, z2).getBlock();
|
|
|
|
|
if (block.getType().equals(Material.BED_BLOCK))
|
|
|
|
|
{
|
|
|
|
|
block.setType(Material.AIR);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clan.setHome(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|