more control over saplings
This commit is contained in:
parent
a377a09925
commit
c4bbeb2535
@ -46,22 +46,23 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
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.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
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.common.util.UtilTime;
|
||||
import mineplex.core.common.weight.Weight;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
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.core.common.weight.Weight;
|
||||
import mineplex.core.common.weight.WeightSet;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent;
|
||||
@ -164,7 +165,6 @@ public class Gameplay extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BucketEmpty(PlayerBucketEmptyEvent event)
|
||||
{
|
||||
@ -445,45 +445,94 @@ public class Gameplay extends MiniPlugin
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void replantTree(BlockBreakEvent event)
|
||||
public void disableSaplings(BlockPlaceEvent event)
|
||||
{
|
||||
final Block block = event.getBlock();
|
||||
|
||||
if (_clansManager.getClanUtility().getClaim(block.getLocation()) != null)
|
||||
if (event.getBlockReplacedState().getType().equals(Material.SAPLING))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilItem.isLog(block.getType()))
|
||||
Block block = event.getBlock();
|
||||
ClanInfo clan = _clansManager.getClanUtility().getClanByPlayer(event.getPlayer());
|
||||
|
||||
for (int cX = -32; cX < 32; cX++)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilItem.isLog(block.getRelative(BlockFace.DOWN).getType()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (UtilItem.isLeaf(block.getRelative(BlockFace.DOWN).getType()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.getRelative(BlockFace.DOWN).getType() != Material.DIRT && block.getRelative(BlockFace.DOWN).getType() != Material.GRASS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final byte data = block.getData();
|
||||
|
||||
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
|
||||
public void run()
|
||||
for (int cZ = -32; cZ < 32; cZ++)
|
||||
{
|
||||
block.setType(Material.SAPLING);
|
||||
block.setData(data);
|
||||
ClanTerritory claim = _clansManager.getClanUtility().getClaim(block.getLocation().add(cX, 0, cZ));
|
||||
|
||||
if (claim != null && (clan == null || !claim.Owner.equals(clan.getName())))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place saplings near other clan's claims."));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, 20 * 5);
|
||||
}
|
||||
|
||||
if (clan == null || (!clan.equals(_clansManager.getClanUtility().getOwner(block.getLocation()))))
|
||||
{
|
||||
if (UtilBlock.getInRadius(block, 10)
|
||||
.keySet()
|
||||
.stream()
|
||||
.filter(other -> other.getType().equals(Material.SAPLING))
|
||||
.filter(other -> !other.getLocation().equals(block.getLocation()))
|
||||
.toArray().length > 0)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You may not place this block close to any other saplings, unless in your territory."));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Recharge.Instance.use(event.getPlayer(), "Place Sapling", 1000, true, false))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @EventHandler(priority = EventPriority.LOWEST)
|
||||
// public void replantTree(BlockBreakEvent event)
|
||||
// {
|
||||
// final Block block = event.getBlock();
|
||||
//
|
||||
// if (_clansManager.getClanUtility().getClaim(block.getLocation()) != null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!UtilItem.isLog(block.getType()))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (UtilItem.isLog(block.getRelative(BlockFace.DOWN).getType()))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (UtilItem.isLeaf(block.getRelative(BlockFace.DOWN).getType()))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (block.getRelative(BlockFace.DOWN).getType() != Material.DIRT && block.getRelative(BlockFace.DOWN).getType() != Material.GRASS)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final byte data = block.getData();
|
||||
//
|
||||
// UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
|
||||
// public void run()
|
||||
// {
|
||||
// block.setType(Material.SAPLING);
|
||||
// block.setData(data);
|
||||
// }
|
||||
// }, 20 * 5);
|
||||
// }
|
||||
|
||||
@EventHandler
|
||||
public void killRain(WeatherChangeEvent event)
|
||||
|
Loading…
Reference in New Issue
Block a user