Merge remote-tracking branch 'origin/clans-beta' into clans-beta

# Conflicts:
#	Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java
This commit is contained in:
Shaun Bennett 2015-10-16 14:25:31 -04:00
commit 589c05f8c0
5 changed files with 104 additions and 2 deletions

View File

@ -300,6 +300,29 @@ public class ClansUtility
return null;
}
public boolean isNearAdminClaim(Location location)
{
for (int xOffset = -1; xOffset <= 1; xOffset++)
{
for (int zOffset = -1; zOffset <= 1; zOffset++)
{
if (xOffset == 0 && zOffset == 0) continue;
String other = UtilWorld.chunkToStr(location.getWorld().getChunkAt(
location.getChunk().getX()+xOffset, location.getChunk().getZ()+zOffset));
ClanInfo adjClan = getOwner(other);
if (adjClan != null && adjClan.isAdmin() && !adjClan.getName().equalsIgnoreCase("Wilderness"))
{
return true;
}
}
}
return false;
}
public ClanInfo getOwner(ClanTerritory claim)
{
return getClanByClanName(claim.Owner);

View File

@ -946,7 +946,13 @@ public class ClansCommand extends CommandBase<ClansManager>
return;
}
}
if (Plugin.getClanUtility().isNearAdminClaim(caller.getLocation()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot claim so close to administrative territory!"));
return;
}
//Not Next to Self
if (!selfAdj && !clan.getClaimSet().isEmpty())
{

View File

@ -49,6 +49,8 @@ import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -225,6 +227,26 @@ public class Gameplay extends MiniPlugin
}
}
/**
* Disable all Piston related events in Clans
* @param event
*/
@EventHandler
public void onPistonExtend(BlockPistonExtendEvent event)
{
event.setCancelled(true);
}
/**
* Disable all Piston related events in Clans
* @param event
*/
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent event)
{
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void DispenseLiquidCancel(BlockDispenseEvent event)
{
@ -463,6 +485,30 @@ 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 onBlockPlace(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)
public void MoneyLossSteal(CombatDeathEvent event)

View File

@ -40,7 +40,7 @@ import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory;
import mineplex.serverdata.servers.ServerManager;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSetSlot;
import net.minecraft.server.v1_7_R4.PacketPlayOutWindowItems;
import net.minecraft.server.v1_7_R4.PacketPlayOutWindowItems;
import net.minecraft.util.com.google.common.collect.Sets;
import org.bukkit.Bukkit;

View File

@ -2,7 +2,11 @@ package mineplex.game.clans.spawn.travel;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.Sets;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
@ -15,6 +19,8 @@ import mineplex.game.clans.spawn.Spawn;
public class TravelShop extends ShopBase<ClansManager>
{
public static final String[] TRAVEL_LOCATIONS = {"East Shop", "West Shop", "North Spawn", "South Spawn"};
public TravelShop(ClansManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Travel Hub");
@ -38,6 +44,27 @@ public class TravelShop extends ShopBase<ClansManager>
return super.attemptShopOpen(player);
}
/**
* Destroy lone instances of Travel buttons that are fetched into a non-shop inventory (via lag)
* @param event
*/
@EventHandler
public void onInventoryClickedd(InventoryClickEvent event)
{
ItemStack item = event.getCurrentItem();
if (item.getItemMeta() == null || item.getItemMeta().getDisplayName() == null) return;
else if (isPlayerInShop(event.getWhoClicked())) return;
String displayName = event.getCurrentItem().getItemMeta().getDisplayName();
for (String travelLocation : TRAVEL_LOCATIONS)
{
if (displayName.contains(travelLocation))
{
event.setCurrentItem(null);
}
}
}
private static void notify(Player player, String message)
{
UtilPlayer.message(player, F.main("Travel Hub", message));