Merge remote-tracking branch 'origin/clans-beta' into clans-beta
# Conflicts: # Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java
This commit is contained in:
commit
4183f0ce07
@ -14,6 +14,8 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
|
||||
public class UtilAlg
|
||||
{
|
||||
public static TreeSet<String> sortKey(Set<String> toSort)
|
||||
@ -496,4 +498,5 @@ public class UtilAlg
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,36 +12,36 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class UtilMath
|
||||
{
|
||||
public static double trim(int degree, double d)
|
||||
public static double trim(int degree, double d)
|
||||
{
|
||||
String format = "#.#";
|
||||
|
||||
for (int i=1 ; i<degree ; i++)
|
||||
for (int i = 1; i < degree; i++)
|
||||
format += "#";
|
||||
|
||||
|
||||
DecimalFormatSymbols symb = new DecimalFormatSymbols(Locale.US);
|
||||
DecimalFormat twoDForm = new DecimalFormat(format, symb);
|
||||
return Double.valueOf(twoDForm.format(d));
|
||||
}
|
||||
|
||||
|
||||
public static Random random = new Random();
|
||||
public static int r(int i)
|
||||
|
||||
public static int r(int i)
|
||||
{
|
||||
return random.nextInt(i);
|
||||
}
|
||||
|
||||
|
||||
public static int rRange(int min, int max)
|
||||
{
|
||||
return min + r(1 + max - min);
|
||||
}
|
||||
|
||||
public static double offset2d(Entity a, Entity b)
|
||||
public static double offset2d(Entity a, Entity b)
|
||||
{
|
||||
return offset2d(a.getLocation().toVector(), b.getLocation().toVector());
|
||||
}
|
||||
|
||||
public static double offset2d(Location a, Location b)
|
||||
public static double offset2d(Location a, Location b)
|
||||
{
|
||||
return offset2d(a.toVector(), b.toVector());
|
||||
}
|
||||
@ -53,12 +53,12 @@ public class UtilMath
|
||||
return a.subtract(b).length();
|
||||
}
|
||||
|
||||
public static double offset(Entity a, Entity b)
|
||||
public static double offset(Entity a, Entity b)
|
||||
{
|
||||
return offset(a.getLocation().toVector(), b.getLocation().toVector());
|
||||
}
|
||||
|
||||
public static double offset(Location a, Location b)
|
||||
public static double offset(Location a, Location b)
|
||||
{
|
||||
return offset(a.toVector(), b.toVector());
|
||||
}
|
||||
@ -67,41 +67,38 @@ public class UtilMath
|
||||
{
|
||||
return a.clone().subtract(b).length();
|
||||
}
|
||||
|
||||
|
||||
public static double offsetSquared(Entity a, Entity b)
|
||||
{
|
||||
return offsetSquared(a.getLocation(), b.getLocation());
|
||||
}
|
||||
|
||||
|
||||
public static double offsetSquared(Location a, Location b)
|
||||
{
|
||||
return offsetSquared(a.toVector(), b.toVector());
|
||||
}
|
||||
|
||||
|
||||
public static double offsetSquared(Vector a, Vector b)
|
||||
{
|
||||
return a.distanceSquared(b);
|
||||
}
|
||||
|
||||
|
||||
public static double rr(double d, boolean bidirectional)
|
||||
{
|
||||
if (bidirectional)
|
||||
return Math.random() * (2 * d) - d;
|
||||
if (bidirectional) return Math.random() * (2 * d) - d;
|
||||
|
||||
return Math.random() * d;
|
||||
}
|
||||
|
||||
public static <T> T randomElement(T[] array)
|
||||
{
|
||||
if (array.length == 0)
|
||||
return null;
|
||||
if (array.length == 0) return null;
|
||||
return array[random.nextInt(array.length)];
|
||||
}
|
||||
|
||||
public static <T> T randomElement(List<T> list)
|
||||
{
|
||||
if (list.isEmpty())
|
||||
return null;
|
||||
if (list.isEmpty()) return null;
|
||||
return list.get(random.nextInt(list.size()));
|
||||
}
|
||||
|
||||
@ -120,4 +117,3 @@ public class UtilMath
|
||||
return num < min ? min : (num > max ? max : num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,6 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PlayerConnection;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -27,6 +23,10 @@ import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.Packet;
|
||||
import net.minecraft.server.v1_8_R3.PlayerConnection;
|
||||
|
||||
public class UtilPlayer
|
||||
{
|
||||
private static Random RANDOM = new Random();
|
||||
@ -35,7 +35,7 @@ public class UtilPlayer
|
||||
private static Map<String, Long> _hotbarUpdates = new HashMap<String, Long>();
|
||||
|
||||
// The amount of time (in milliseconds) after changin hotbars that you can block
|
||||
public static final long BLOCKING_HOTBAR_DELAY = 100;
|
||||
public static final long BLOCKING_HOTBAR_DELAY = 100;
|
||||
|
||||
private static boolean hasIntersection(Vector3D p1, Vector3D p2, Vector3D min, Vector3D max)
|
||||
{
|
||||
|
@ -676,9 +676,9 @@ public class ClansDataAccessLayer
|
||||
* EnemyData iData = initiator.getEnemyData(); ClanInfo other = clan ==
|
||||
* initiator ? otherClan : clan; EnemyData oData = other.getEnemyData();
|
||||
* _repository.updateEnemy(initiator.getId(), other.getId(),
|
||||
* iData.getClanAScore(), oData.getClanAScore(), iData.getKills(), oData.getKills());
|
||||
* //Log _manager.log("Updated Enemy Data for [" + clan.getName() + ", " +
|
||||
* otherClan.getName() + "]"); }
|
||||
* iData.getClanAScore(), oData.getClanAScore(), iData.getKills(),
|
||||
* oData.getKills()); //Log _manager.log("Updated Enemy Data for [" +
|
||||
* clan.getName() + ", " + otherClan.getName() + "]"); }
|
||||
*/
|
||||
|
||||
public void updateGenerator(final ClanInfo clanInfo, final Callback<Boolean> callback)
|
||||
|
@ -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)
|
||||
@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)
|
||||
@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;
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
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,20 +440,19 @@ 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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mineplex.game.clans.clans;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
@ -24,6 +25,7 @@ import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
@ -271,6 +273,18 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
// Initialize default region factions and territory (spawn/fields/borderlands)
|
||||
_clanRegions = new ClansRegions(plugin, this);
|
||||
_clanRegions.initializeRegions();
|
||||
|
||||
// Disables beds from being crafted
|
||||
Iterator<Recipe> it = _plugin.getServer().recipeIterator();
|
||||
Recipe recipe;
|
||||
while(it.hasNext())
|
||||
{
|
||||
recipe = it.next();
|
||||
if (recipe != null && recipe.getResult().getType() == Material.BED)
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,7 +2,9 @@ package mineplex.game.clans.clans.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
@ -11,24 +13,21 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInput;
|
||||
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.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClanRole;
|
||||
import mineplex.game.clans.clans.ClansBlacklist;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ClansPlayer;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.ClientClan;
|
||||
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
|
||||
import mineplex.game.clans.tutorials.TutorialManager;
|
||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
|
||||
public class ClansCommand extends CommandBase<ClansManager>
|
||||
{
|
||||
@ -167,7 +166,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "help");
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
@ -675,12 +674,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "claim", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Plugin.getClanUtility().claim(caller);
|
||||
}
|
||||
|
||||
@ -828,6 +827,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
return;
|
||||
}
|
||||
|
||||
Location home = clan.getHome();
|
||||
|
||||
if (!(home.getBlock().getType().equals(Material.BED) && home.add(0,1,0).getBlock().getType().equals(Material.AIR)))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed."));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* CoreClient client = _plugin.getClientManager().Get(caller); for
|
||||
* (Player cur : clan.GetHome().getWorld().getPlayers()) if
|
||||
@ -838,7 +845,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
* }
|
||||
*/
|
||||
|
||||
if (!Recharge.Instance.use(caller, "Clans Teleport", "Clans Teleport", 300000, true, false, false, false)) return;
|
||||
// if (!Recharge.Instance.use(caller, "Clans Teleport", "Clans Teleport", 300000, true, false, false, false)) return;
|
||||
|
||||
// Do
|
||||
Plugin.getTeleport().TP(caller, clan.getHome());
|
||||
@ -875,6 +882,71 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
return;
|
||||
}
|
||||
|
||||
EnumDirection dir = EnumDirection.fromAngle(caller.getLocation().getYaw());
|
||||
|
||||
int xModif = 0;
|
||||
int zModif = 0;
|
||||
|
||||
int dirFlag = 0x2; // North as default
|
||||
|
||||
if (dir == EnumDirection.NORTH)
|
||||
{
|
||||
zModif = -1;
|
||||
dirFlag = 0x2;
|
||||
}
|
||||
|
||||
if (dir == EnumDirection.SOUTH)
|
||||
{
|
||||
zModif = 1;
|
||||
dirFlag = 0x0;
|
||||
}
|
||||
|
||||
if (dir == EnumDirection.WEST)
|
||||
{
|
||||
xModif = -1;
|
||||
dirFlag = 0x1;
|
||||
}
|
||||
|
||||
if (dir == EnumDirection.EAST)
|
||||
{
|
||||
xModif = 1;
|
||||
dirFlag = 0x3;
|
||||
}
|
||||
|
||||
BlockState bedBlock1 = caller.getLocation().getBlock().getState();
|
||||
BlockState bedBlock2 = caller.getLocation().add(xModif, 0, zModif).getBlock().getState();
|
||||
|
||||
// Check space
|
||||
if (!(bedBlock1.getType() == Material.AIR && bedBlock2.getType() == Material.AIR && bedBlock1.getLocation().add(0, 1, 0).getBlock().getType() == Material.AIR && bedBlock2.getLocation().add(0, 1, 0).getBlock().getType() == Material.AIR))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "There is not enough room here to place a bed."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Cleanup old
|
||||
if (clan.getHome() != null)
|
||||
{
|
||||
for (int x = -2; x < 2; x++)
|
||||
{
|
||||
for (int z = -2; z < 2; z++)
|
||||
{
|
||||
if (clan.getHome().clone().add(x, 0, z).getBlock().getType().equals(Material.BED_BLOCK))
|
||||
{
|
||||
clan.getHome().clone().add(x, 0, z).getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create new
|
||||
bedBlock1.setType(Material.BED_BLOCK);
|
||||
bedBlock2.setType(Material.BED_BLOCK);
|
||||
bedBlock1.setRawData((byte) (dirFlag));
|
||||
bedBlock2.setRawData((byte) (0x8 | dirFlag)); // 0x8 says that this is the bottom of the bed
|
||||
|
||||
bedBlock1.update(true, false);
|
||||
bedBlock2.update(true, false);
|
||||
|
||||
// Task
|
||||
Plugin.getClanDataAccess().home(clan, caller.getLocation(), caller.getName());
|
||||
|
||||
@ -893,7 +965,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "info", search);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
|
@ -10,7 +10,7 @@ public class WorldEventCommand extends MultiCommandBase<WorldEventManager>
|
||||
{
|
||||
public WorldEventCommand(WorldEventManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, new Rank[] { Rank.JNR_DEV }, "worldevent", "we", "event");
|
||||
super(plugin, Rank.ALL, "worldevent", "we", "event");
|
||||
|
||||
AddCommand(new StartCommand(Plugin));
|
||||
AddCommand(new ClearCommand(Plugin));
|
||||
|
@ -481,29 +481,29 @@ public class Gameplay extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
Location location = event.getBlock().getLocation();
|
||||
|
||||
if (_clansManager.getClanUtility().isNearAdminClaim(location))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot place blocks near admin territories!"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
Location location = event.getBlock().getLocation();
|
||||
|
||||
if (_clansManager.getClanUtility().isNearAdminClaim(location))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot break blocks near admin territories!"));
|
||||
}
|
||||
}
|
||||
// @EventHandler
|
||||
// public void onBlockPlace(BlockPlaceEvent event)
|
||||
// {
|
||||
// Location location = event.getBlock().getLocation();
|
||||
//
|
||||
// if (_clansManager.getClanUtility().isNearAdminClaim(location))
|
||||
// {
|
||||
// event.setCancelled(true);
|
||||
// UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot place blocks near admin territories!"));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @EventHandler
|
||||
// public void onBlockBreak(BlockBreakEvent event)
|
||||
// {
|
||||
// Location location = event.getBlock().getLocation();
|
||||
//
|
||||
// if (_clansManager.getClanUtility().isNearAdminClaim(location))
|
||||
// {
|
||||
// event.setCancelled(true);
|
||||
// UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot break blocks near admin territories!"));
|
||||
// }
|
||||
// }
|
||||
|
||||
/*
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
|
Loading…
Reference in New Issue
Block a user