auto-replanting trees
This commit is contained in:
parent
2adfef41ca
commit
9a8fba543d
@ -41,8 +41,8 @@ public class UtilItem
|
|||||||
_materials.put(Material.IRON_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON));
|
_materials.put(Material.IRON_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON));
|
||||||
_materials.put(Material.IRON_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON));
|
_materials.put(Material.IRON_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON));
|
||||||
_materials.put(Material.COAL_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON));
|
_materials.put(Material.COAL_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON));
|
||||||
_materials.put(Material.LOG, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD));
|
_materials.put(Material.LOG, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD, ItemCategory.LOG));
|
||||||
_materials.put(Material.LEAVES, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
|
_materials.put(Material.LEAVES, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LEAVES));
|
||||||
_materials.put(Material.SPONGE, EnumSet.of(ItemCategory.BLOCK));
|
_materials.put(Material.SPONGE, EnumSet.of(ItemCategory.BLOCK));
|
||||||
_materials.put(Material.GLASS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS));
|
_materials.put(Material.GLASS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS));
|
||||||
_materials.put(Material.LAPIS_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE));
|
_materials.put(Material.LAPIS_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE));
|
||||||
@ -185,8 +185,8 @@ public class UtilItem
|
|||||||
_materials.put(Material.DROPPER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI));
|
_materials.put(Material.DROPPER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI));
|
||||||
_materials.put(Material.STAINED_CLAY, EnumSet.of(ItemCategory.BLOCK));
|
_materials.put(Material.STAINED_CLAY, EnumSet.of(ItemCategory.BLOCK));
|
||||||
_materials.put(Material.STAINED_GLASS_PANE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS));
|
_materials.put(Material.STAINED_GLASS_PANE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS));
|
||||||
_materials.put(Material.LEAVES_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
|
_materials.put(Material.LEAVES_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LEAVES));
|
||||||
_materials.put(Material.LOG_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD));
|
_materials.put(Material.LOG_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD, ItemCategory.LOG));
|
||||||
_materials.put(Material.ACACIA_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
|
_materials.put(Material.ACACIA_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
|
||||||
_materials.put(Material.DARK_OAK_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
|
_materials.put(Material.DARK_OAK_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT));
|
||||||
_materials.put(Material.HAY_BLOCK, EnumSet.of(ItemCategory.BLOCK));
|
_materials.put(Material.HAY_BLOCK, EnumSet.of(ItemCategory.BLOCK));
|
||||||
@ -808,6 +808,26 @@ public class UtilItem
|
|||||||
return isItem(stack == null ? null : stack.getType());
|
return isItem(stack == null ? null : stack.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isLog(Material material)
|
||||||
|
{
|
||||||
|
return material == null ? false : (_materials.get(material).contains(ItemCategory.LOG));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLog(ItemStack stack)
|
||||||
|
{
|
||||||
|
return isLog(stack == null ? null : stack.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLeaf(Material material)
|
||||||
|
{
|
||||||
|
return material == null ? false : (_materials.get(material).contains(ItemCategory.LEAVES));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLeaf(ItemStack stack)
|
||||||
|
{
|
||||||
|
return isLeaf(stack == null ? null : stack.getType());
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isTool(Material material)
|
public static boolean isTool(Material material)
|
||||||
{
|
{
|
||||||
return material == null ? false : (_materials.get(material).contains(ItemCategory.TOOL));
|
return material == null ? false : (_materials.get(material).contains(ItemCategory.TOOL));
|
||||||
@ -970,7 +990,9 @@ public class UtilItem
|
|||||||
HOE,
|
HOE,
|
||||||
ITEM,
|
ITEM,
|
||||||
BLOCK,
|
BLOCK,
|
||||||
ITEM_BLOCK;
|
ITEM_BLOCK,
|
||||||
|
LOG,
|
||||||
|
LEAVES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ArmorMaterial
|
public enum ArmorMaterial
|
||||||
|
@ -31,7 +31,6 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|||||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
@ -44,10 +43,12 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.blockrestore.BlockRestore;
|
import mineplex.core.blockrestore.BlockRestore;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilEvent;
|
import mineplex.core.common.util.UtilEvent;
|
||||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||||
import mineplex.core.common.util.UtilGear;
|
import mineplex.core.common.util.UtilGear;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilItem;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
@ -69,7 +70,8 @@ public class Gameplay extends MiniPlugin
|
|||||||
private ClansManager _clansManager;
|
private ClansManager _clansManager;
|
||||||
private BlockRestore _blockRestore;
|
private BlockRestore _blockRestore;
|
||||||
private DamageManager _damageManager;
|
private DamageManager _damageManager;
|
||||||
private WeightSet<Boolean> _foodDecrease; // Weighted probability sets for food decrease event outcomes
|
private WeightSet<Boolean> _foodDecrease; // Weighted probability sets for
|
||||||
|
// food decrease event outcomes
|
||||||
|
|
||||||
private Map<Block, Long> _bucketWater = new HashMap<Block, Long>();
|
private Map<Block, Long> _bucketWater = new HashMap<Block, Long>();
|
||||||
|
|
||||||
@ -133,32 +135,35 @@ public class Gameplay extends MiniPlugin
|
|||||||
|
|
||||||
if (event.getBucket() == Material.WATER_BUCKET)
|
if (event.getBucket() == Material.WATER_BUCKET)
|
||||||
{
|
{
|
||||||
block.setTypeIdAndData(8, (byte)1, true);
|
block.setTypeIdAndData(8, (byte) 1, true);
|
||||||
_blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 8, (byte) 0, 1000);
|
_blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 8, (byte) 0, 1000);
|
||||||
_bucketWater.put(block, System.currentTimeMillis());
|
_bucketWater.put(block, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getBucket() == Material.LAVA_BUCKET)
|
if (event.getBucket() == Material.LAVA_BUCKET)
|
||||||
{
|
{
|
||||||
block.setTypeIdAndData(10, (byte)6, true);
|
block.setTypeIdAndData(10, (byte) 6, true);
|
||||||
_blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 10, (byte) 0, 2000);
|
_blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 10, (byte) 0, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.BUCKET));
|
event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.BUCKET));
|
||||||
UtilInv.Update(event.getPlayer());
|
UtilInv.Update(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decreases the hunger rate decrease speed by arbitrarily canceling a portion of decrease events.
|
* Decreases the hunger rate decrease speed by arbitrarily canceling a
|
||||||
|
* portion of decrease events.
|
||||||
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled=true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void foodChangeLevel(FoodLevelChangeEvent event)
|
public void foodChangeLevel(FoodLevelChangeEvent event)
|
||||||
{
|
{
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
|
|
||||||
if (event.getFoodLevel() < player.getFoodLevel()) // Hunger is decreasing for player
|
if (event.getFoodLevel() < player.getFoodLevel()) // Hunger is
|
||||||
|
// decreasing for
|
||||||
|
// player
|
||||||
{
|
{
|
||||||
event.setCancelled(_foodDecrease.generateRandom());
|
event.setCancelled(_foodDecrease.generateRandom());
|
||||||
}
|
}
|
||||||
@ -169,9 +174,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
if (event.getItemStack().getType() == Material.WATER_BUCKET)
|
if (event.getItemStack().getType() == Material.WATER_BUCKET) if (!_bucketWater.containsKey(event.getBlockClicked())) event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.WATER_BUCKET));
|
||||||
if (!_bucketWater.containsKey(event.getBlockClicked()))
|
|
||||||
event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.WATER_BUCKET));
|
|
||||||
|
|
||||||
UtilInv.Update(event.getPlayer());
|
UtilInv.Update(event.getPlayer());
|
||||||
}
|
}
|
||||||
@ -179,14 +182,12 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void BucketWaterExpire(UpdateEvent event)
|
public void BucketWaterExpire(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() != UpdateType.FAST)
|
if (event.getType() != UpdateType.FAST) return;
|
||||||
return;
|
|
||||||
|
|
||||||
HashSet<Block> remove = new HashSet<Block>();
|
HashSet<Block> remove = new HashSet<Block>();
|
||||||
|
|
||||||
for (Block cur : _bucketWater.keySet())
|
for (Block cur : _bucketWater.keySet())
|
||||||
if (UtilTime.elapsed(_bucketWater.get(cur), 2000))
|
if (UtilTime.elapsed(_bucketWater.get(cur), 2000)) remove.add(cur);
|
||||||
remove.add(cur);
|
|
||||||
|
|
||||||
for (Block cur : remove)
|
for (Block cur : remove)
|
||||||
_bucketWater.remove(cur);
|
_bucketWater.remove(cur);
|
||||||
@ -205,9 +206,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void CommandPlace(BlockPlaceEvent event)
|
public void CommandPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
if (event.getBlock().getType() == Material.COMMAND ||
|
if (event.getBlock().getType() == Material.COMMAND || event.getBlock().getType() == Material.NOTE_BLOCK || event.getBlock().getType() == Material.REDSTONE_LAMP_ON)
|
||||||
event.getBlock().getType() == Material.NOTE_BLOCK ||
|
|
||||||
event.getBlock().getType() == Material.REDSTONE_LAMP_ON)
|
|
||||||
{
|
{
|
||||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.item("Proximity Devices") + "."));
|
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.item("Proximity Devices") + "."));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -226,6 +225,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable all Piston related events in Clans
|
* Disable all Piston related events in Clans
|
||||||
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -236,6 +236,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable all Piston related events in Clans
|
* Disable all Piston related events in Clans
|
||||||
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -249,8 +250,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
{
|
{
|
||||||
Material material = event.getItem().getType();
|
Material material = event.getItem().getType();
|
||||||
|
|
||||||
if (material == Material.LAVA_BUCKET || material == Material.LAVA
|
if (material == Material.LAVA_BUCKET || material == Material.LAVA || material == Material.WATER_BUCKET || material == Material.WATER)
|
||||||
|| material == Material.WATER_BUCKET || material == Material.WATER)
|
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -259,25 +259,21 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void WebBreak(BlockDamageEvent event)
|
public void WebBreak(BlockDamageEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled())
|
if (event.isCancelled()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getBlock().getType() == Material.WEB)
|
if (event.getBlock().getType() == Material.WEB) event.setInstaBreak(true);
|
||||||
event.setInstaBreak(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void LapisPlace(BlockPlaceEvent event)
|
public void LapisPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled())
|
if (event.isCancelled()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getBlock().getType() != Material.LAPIS_BLOCK)
|
if (event.getBlock().getType() != Material.LAPIS_BLOCK) return;
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
UtilInv.remove(event.getPlayer(), Material.LAPIS_BLOCK, (byte)0, 1);
|
UtilInv.remove(event.getPlayer(), Material.LAPIS_BLOCK, (byte) 0, 1);
|
||||||
|
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
|
|
||||||
@ -286,7 +282,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
block.setType(Material.WATER);
|
block.setType(Material.WATER);
|
||||||
block.setData((byte)0);
|
block.setData((byte) 0);
|
||||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 8);
|
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 8);
|
||||||
block.getWorld().playSound(block.getLocation(), Sound.SPLASH, 2f, 1f);
|
block.getWorld().playSound(block.getLocation(), Sound.SPLASH, 2f, 1f);
|
||||||
}
|
}
|
||||||
@ -296,11 +292,9 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void EnderChestBreak(BlockBreakEvent event)
|
public void EnderChestBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled())
|
if (event.isCancelled()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getBlock().getType() != Material.ENDER_CHEST)
|
if (event.getBlock().getType() != Material.ENDER_CHEST) return;
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
@ -311,8 +305,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void disableEnderPearls(PlayerInteractEvent event)
|
public void disableEnderPearls(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (!isRightClick(event.getAction()))
|
if (!isRightClick(event.getAction())) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL)
|
if (event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL)
|
||||||
{
|
{
|
||||||
@ -324,8 +317,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void disableFlintNSteel(PlayerInteractEvent event)
|
public void disableFlintNSteel(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (!isRightClick(event.getAction()))
|
if (!isRightClick(event.getAction())) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.hasItem() && event.getItem().getType() == Material.FLINT_AND_STEEL)
|
if (event.hasItem() && event.getItem().getType() == Material.FLINT_AND_STEEL)
|
||||||
{
|
{
|
||||||
@ -342,33 +334,31 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void IronDoor(PlayerInteractEvent event)
|
public void IronDoor(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getClickedBlock().getTypeId() != 71)
|
if (event.getClickedBlock().getTypeId() != 71) return;
|
||||||
return;
|
|
||||||
|
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
|
|
||||||
//Knock
|
// Knock
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
{
|
{
|
||||||
if (!Recharge.Instance.use(event.getPlayer(), "Door Knock", 500, false, false))
|
if (!Recharge.Instance.use(event.getPlayer(), "Door Knock", 500, false, false)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
block.getWorld().playEffect(block.getLocation(), Effect.ZOMBIE_CHEW_WOODEN_DOOR, 0);
|
block.getWorld().playEffect(block.getLocation(), Effect.ZOMBIE_CHEW_WOODEN_DOOR, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Open
|
// Open
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (block.getData() >= 8)
|
if (block.getData() >= 8) block = block.getRelative(BlockFace.DOWN);
|
||||||
block = block.getRelative(BlockFace.DOWN);
|
|
||||||
|
|
||||||
if (block.getData() < 4) block.setData((byte)(block.getData()+4), true);
|
if (block.getData() < 4)
|
||||||
else block.setData((byte)(block.getData()-4), true);
|
block.setData((byte) (block.getData() + 4), true);
|
||||||
|
else
|
||||||
|
block.setData((byte) (block.getData() - 4), true);
|
||||||
|
|
||||||
//Effect
|
// Effect
|
||||||
block.getWorld().playEffect(block.getLocation(), Effect.DOOR_TOGGLE, 0);
|
block.getWorld().playEffect(block.getLocation(), Effect.DOOR_TOGGLE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,11 +366,9 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void BrewingDisable(PlayerInteractEvent event)
|
public void BrewingDisable(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getClickedBlock().getTypeId() != 117)
|
if (event.getClickedBlock().getTypeId() != 117) return;
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -390,8 +378,10 @@ public class Gameplay extends MiniPlugin
|
|||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return;
|
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||||
else if (event.getClickedBlock().getType() != Material.ANVIL) return;
|
return;
|
||||||
|
else if (event.getClickedBlock().getType() != Material.ANVIL)
|
||||||
|
return;
|
||||||
else if (player.isSneaking() && player.getItemInHand().getType() != Material.AIR) return;
|
else if (player.isSneaking() && player.getItemInHand().getType() != Material.AIR) return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -400,167 +390,171 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void BonemealCancel(PlayerInteractEvent event)
|
public void BonemealCancel(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (!UtilEvent.isAction(event, ActionType.R))
|
if (!UtilEvent.isAction(event, ActionType.R)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (player.getItemInHand() == null)
|
if (player.getItemInHand() == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (player.getItemInHand().getType() != Material.INK_SACK)
|
if (player.getItemInHand().getType() != Material.INK_SACK) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (player.getItemInHand().getData() == null)
|
if (player.getItemInHand().getData() == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (player.getItemInHand().getData().getData() != 15)
|
if (player.getItemInHand().getData().getData() != 15) return;
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void replantTree(BlockBreakEvent event){
|
public void replantTree(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
Block block = event.getBlock();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location saplingArea = null;
|
||||||
|
|
||||||
|
for (Block otherBlock : UtilBlock.getInRadius(event.getBlock().getLocation(), 4.5).keySet())
|
||||||
|
{
|
||||||
|
if (!otherBlock.equals(UtilBlock.getHighest(otherBlock.getLocation().getWorld(), otherBlock.getX(), otherBlock.getZ())))
|
||||||
|
{
|
||||||
|
saplingArea = otherBlock.getLocation();
|
||||||
|
if (Math.random() > .75)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saplingArea.add(0, 1, 0).getBlock().setType(Material.SAPLING);
|
||||||
|
saplingArea.getBlock().setData(block.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void WildfireSpread(BlockBurnEvent event)
|
public void WildfireSpread(BlockBurnEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled())
|
if (event.isCancelled()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
for (int x=-1 ; x<=1 ; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
for (int y=-1 ; y<=1 ; y++)
|
for (int y = -1; y <= 1; y++)
|
||||||
for (int z=-1 ; z<=1 ; z++)
|
for (int z = -1; z <= 1; z++)
|
||||||
{
|
{
|
||||||
//Self
|
// Self
|
||||||
if (x == 0 && y == 0 && z == 0)
|
if (x == 0 && y == 0 && z == 0)
|
||||||
{
|
{
|
||||||
event.getBlock().setType(Material.FIRE);
|
event.getBlock().setType(Material.FIRE);
|
||||||
|
|
||||||
if (event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.GRASS)
|
if (event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.GRASS) event.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT);
|
||||||
event.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = event.getBlock().getRelative(x, y, z);
|
Block block = event.getBlock().getRelative(x, y, z);
|
||||||
|
|
||||||
if (block.getRelative(BlockFace.DOWN).getType() == Material.GRASS)
|
if (block.getRelative(BlockFace.DOWN).getType() == Material.GRASS) block.getRelative(BlockFace.DOWN).setType(Material.DIRT);
|
||||||
block.getRelative(BlockFace.DOWN).setType(Material.DIRT);
|
|
||||||
|
|
||||||
//Surroundings
|
// Surroundings
|
||||||
if (!(
|
if (!((x == 0 && y == 0) || (x == 0 && z == 0) || (y == 0 && z == 0))) continue;
|
||||||
(x == 0 && y == 0) ||
|
|
||||||
(x == 0 && z == 0) ||
|
|
||||||
(y == 0 && z == 0)
|
|
||||||
))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (block.getTypeId() == 0)
|
if (block.getTypeId() == 0) block.setType(Material.FIRE);
|
||||||
block.setType(Material.FIRE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void WildfireDirt(BlockIgniteEvent event)
|
public void WildfireDirt(BlockIgniteEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled())
|
if (event.isCancelled()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.GRASS)
|
if (event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.GRASS) event.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT);
|
||||||
event.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void WildfireCancel(BlockIgniteEvent event)
|
public void WildfireCancel(BlockIgniteEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled())
|
if (event.isCancelled()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getBlock().getBiome() == Biome.JUNGLE || event.getBlock().getBiome() == Biome.JUNGLE_HILLS)
|
if (event.getBlock().getBiome() == Biome.JUNGLE || event.getBlock().getBiome() == Biome.JUNGLE_HILLS) if (event.getCause() == IgniteCause.SPREAD) event.setCancelled(true);
|
||||||
if (event.getCause() == IgniteCause.SPREAD)
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @EventHandler
|
// @EventHandler
|
||||||
// public void onBlockPlace(BlockPlaceEvent event)
|
// public void onBlockPlace(BlockPlaceEvent event)
|
||||||
// {
|
// {
|
||||||
// Location location = event.getBlock().getLocation();
|
// Location location = event.getBlock().getLocation();
|
||||||
//
|
//
|
||||||
// if (_clansManager.getClanUtility().isNearAdminClaim(location))
|
// if (_clansManager.getClanUtility().isNearAdminClaim(location))
|
||||||
// {
|
// {
|
||||||
// event.setCancelled(true);
|
// event.setCancelled(true);
|
||||||
// UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot place blocks near admin territories!"));
|
// UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot place
|
||||||
// }
|
// blocks near admin territories!"));
|
||||||
// }
|
// }
|
||||||
//
|
// }
|
||||||
// @EventHandler
|
//
|
||||||
// public void onBlockBreak(BlockBreakEvent event)
|
// @EventHandler
|
||||||
// {
|
// public void onBlockBreak(BlockBreakEvent event)
|
||||||
// Location location = event.getBlock().getLocation();
|
// {
|
||||||
//
|
// Location location = event.getBlock().getLocation();
|
||||||
// if (_clansManager.getClanUtility().isNearAdminClaim(location))
|
//
|
||||||
// {
|
// if (_clansManager.getClanUtility().isNearAdminClaim(location))
|
||||||
// event.setCancelled(true);
|
// {
|
||||||
// UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot break blocks near admin territories!"));
|
// event.setCancelled(true);
|
||||||
// }
|
// UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot break
|
||||||
// }
|
// blocks near admin territories!"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@EventHandler (priority = EventPriority.HIGHEST)
|
* @EventHandler (priority = EventPriority.HIGHEST) public void
|
||||||
public void MoneyLossSteal(CombatDeathEvent event)
|
* MoneyLossSteal(CombatDeathEvent event) { if
|
||||||
{
|
* (!(event.GetEvent().getEntity() instanceof Player)) return; Player player
|
||||||
if (!(event.GetEvent().getEntity() instanceof Player))
|
* = (Player)event.GetEvent().getEntity(); int balance =
|
||||||
return;
|
* Clients().Get(player).Game().GetEconomyBalance(); int lose = (int) (0.04
|
||||||
|
* * balance); //Balance
|
||||||
Player player = (Player)event.GetEvent().getEntity();
|
* Clients().Get(player).Game().SetEconomyBalance(balance - lose); CombatLog
|
||||||
|
* log = event.GetLog(); if (log.GetKiller() != null) { //Inform
|
||||||
int balance = Clients().Get(player).Game().GetEconomyBalance();
|
* UtilPlayer.message(UtilPlayer.searchExact(log.GetKiller().getName()),
|
||||||
|
* F.main("Death", "You stole " + F.count((lose) + " Coins") + " from " +
|
||||||
int lose = (int) (0.04 * balance);
|
* F.name(player.getName()) + ".")); //Inform UtilPlayer.message(player,
|
||||||
|
* F.main("Death", "You lost " + F.count((lose) + " Coins") + " to " +
|
||||||
//Balance
|
* F.name(log.GetKiller().getName()) + ".")); } else { //Inform
|
||||||
Clients().Get(player).Game().SetEconomyBalance(balance - lose);
|
* UtilPlayer.message(player, F.main("Death", "You lost " + F.count((lose) +
|
||||||
|
* " Coins") + " for dying.")); } }
|
||||||
CombatLog log = event.GetLog();
|
|
||||||
if (log.GetKiller() != null)
|
|
||||||
{
|
|
||||||
//Inform
|
|
||||||
UtilPlayer.message(UtilPlayer.searchExact(log.GetKiller().getName()), F.main("Death", "You stole " + F.count((lose) + " Coins") + " from " + F.name(player.getName()) + "."));
|
|
||||||
|
|
||||||
//Inform
|
|
||||||
UtilPlayer.message(player, F.main("Death", "You lost " + F.count((lose) + " Coins") + " to " + F.name(log.GetKiller().getName()) + "."));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Inform
|
|
||||||
UtilPlayer.message(player, F.main("Death", "You lost " + F.count((lose) + " Coins") + " for dying."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void SpawnDamage(CustomDamageEvent event)
|
public void SpawnDamage(CustomDamageEvent event)
|
||||||
{
|
{
|
||||||
if (event.IsCancelled())
|
if (event.IsCancelled()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.GetCause() != DamageCause.FALL)
|
if (event.GetCause() != DamageCause.FALL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (!_clansManager.getClanUtility().isSpecial(event.GetDamageeEntity().getLocation(), "Spawn"))
|
if (!_clansManager.getClanUtility().isSpecial(event.GetDamageeEntity().getLocation(), "Spawn")) return;
|
||||||
return;
|
|
||||||
|
|
||||||
event.SetCancelled("Spawn Fall");
|
event.SetCancelled("Spawn Fall");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel the spawning of all Witches.
|
* Cancel the spawning of all Witches.
|
||||||
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -577,11 +571,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (event.getClickedBlock() == null
|
if (event.getClickedBlock() == null || event.getClickedBlock().getType() != Material.ANVIL || !UtilEvent.isAction(event, ActionType.R_BLOCK) || player.isSneaking() || player.getItemInHand().getType() == Material.AIR)
|
||||||
|| event.getClickedBlock().getType() != Material.ANVIL
|
|
||||||
|| !UtilEvent.isAction(event, ActionType.R_BLOCK)
|
|
||||||
|| player.isSneaking()
|
|
||||||
|| player.getItemInHand().getType() == Material.AIR)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -619,8 +609,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
|
|
||||||
if (creator != null)
|
if (creator != null)
|
||||||
{
|
{
|
||||||
if (creator.length() > 2)
|
if (creator.length() > 2) creator = creator.substring(2, creator.length());
|
||||||
creator = creator.substring(2, creator.length());
|
|
||||||
|
|
||||||
if (!creator.equals(player.getName()))
|
if (!creator.equals(player.getName()))
|
||||||
{
|
{
|
||||||
@ -629,22 +618,21 @@ public class Gameplay extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Repair!
|
// Repair!
|
||||||
UtilPlayer.message(player, F.main("Repair", "You repaired " + F.item(item.getItemMeta().getDisplayName()) + "."));
|
UtilPlayer.message(player, F.main("Repair", "You repaired " + F.item(item.getItemMeta().getDisplayName()) + "."));
|
||||||
item.setDurability((short)0);
|
item.setDurability((short) 0);
|
||||||
UtilInv.Update(player);
|
UtilInv.Update(player);
|
||||||
|
|
||||||
//Break
|
// Break
|
||||||
if (Math.random() > 0.85)
|
if (Math.random() > 0.85) event.getClickedBlock().setData((byte) (event.getClickedBlock().getData() + 4));
|
||||||
event.getClickedBlock().setData((byte) (event.getClickedBlock().getData() + 4));
|
|
||||||
|
|
||||||
if (event.getClickedBlock().getData() >= 12)
|
if (event.getClickedBlock().getData() >= 12)
|
||||||
{
|
{
|
||||||
player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 145);
|
player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 145);
|
||||||
event.getClickedBlock().setTypeIdAndData(0, (byte)0, true);
|
event.getClickedBlock().setTypeIdAndData(0, (byte) 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Record
|
// Record
|
||||||
ItemStackFactory.Instance.SetLoreVar(item, "Repaired", (repairs + 1) + "");
|
ItemStackFactory.Instance.SetLoreVar(item, "Repaired", (repairs + 1) + "");
|
||||||
if (!canRepair(item))
|
if (!canRepair(item))
|
||||||
{
|
{
|
||||||
@ -653,7 +641,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Effect
|
// Effect
|
||||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, 1f, 1f);
|
player.playSound(player.getLocation(), Sound.ANVIL_USE, 1f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,8 +653,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
|
|
||||||
if (repairs >= 3 && gold)
|
if (repairs >= 3 && gold)
|
||||||
canRepair = false;
|
canRepair = false;
|
||||||
else if (repairs >= 2 && !gold)
|
else if (repairs >= 2 && !gold) canRepair = false;
|
||||||
canRepair = false;
|
|
||||||
|
|
||||||
return canRepair;
|
return canRepair;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user