mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
commit
21f2eb9793
2
pom.xml
2
pom.xml
@ -112,7 +112,7 @@
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.0.0</version>
|
||||
<version>7.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -75,6 +75,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
private static final List<BlockFace> directions = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
|
||||
private static final List<Material> blockblacklist = new ArrayList<>();
|
||||
|
||||
|
||||
static {
|
||||
blockblacklist.add(Material.BEDROCK);
|
||||
blockblacklist.add(Material.BARRIER);
|
||||
@ -215,6 +216,8 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
|
||||
boolean allow = reason.equals(UnregisterReason.PLAYER_BREAK) && (BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass"));
|
||||
|
||||
if (BlockStorage.hasBlockInfo(b)) return false;
|
||||
|
||||
if (allow) {
|
||||
BlockMenu inv = BlockStorage.getInventory(b);
|
||||
if (inv != null) {
|
||||
@ -711,8 +714,10 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
Collection<ItemStack> drops = block.getDrops();
|
||||
if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) {
|
||||
SlimefunItem item = BlockStorage.check(block);
|
||||
|
||||
if (item != null) {
|
||||
if (fits(b, item.getItem())) {
|
||||
return;
|
||||
/*if (fits(b, item.getItem())) {
|
||||
if (SlimefunItem.blockhandler.containsKey(item.getID())) {
|
||||
if (SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG)) {
|
||||
pushItems(b, BlockStorage.retrieve(block));
|
||||
@ -721,9 +726,8 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
}*/
|
||||
} else {
|
||||
ItemStack[] items = drops.toArray(new ItemStack[drops.size()]);
|
||||
if (fits(b, items)) {
|
||||
pushItems(b, items);
|
||||
@ -734,6 +738,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void movedig(Block b, BlockFace face, Block block) {
|
||||
Collection<ItemStack> drops = block.getDrops();
|
||||
if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) {
|
||||
|
@ -1536,6 +1536,7 @@ public class SlimefunSetup {
|
||||
@Override
|
||||
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.AUTO_SMELT_PICKAXE, true)) {
|
||||
if (BlockStorage.hasBlockInfo(e.getBlock())) return true;
|
||||
if (e.getBlock().getType().equals(Material.PLAYER_HEAD)) return true;
|
||||
|
||||
int j = -1;
|
||||
@ -1838,17 +1839,18 @@ public class SlimefunSetup {
|
||||
@Override
|
||||
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.PICKAXE_OF_CONTAINMENT, true)) {
|
||||
if (e.getBlock().getType() != Material.SPAWNER) return true;
|
||||
BlockStorage.clearBlockInfo(e.getBlock());
|
||||
Block b = e.getBlock(); // Refactored it into this so we don't need to call e.getBlock() all the time.
|
||||
if (b.getType() != Material.SPAWNER || BlockStorage.hasBlockInfo(b)) return true;
|
||||
// If the spawner's BlockStorage has BlockInfo, then it's not a vanilla spawner and shouldn't give a broken spawner.
|
||||
ItemStack spawner = SlimefunItems.BROKEN_SPAWNER.clone();
|
||||
ItemMeta im = spawner.getItemMeta();
|
||||
List<String> lore = im.getLore();
|
||||
for (int i = 0; i < lore.size(); i++) {
|
||||
if (lore.get(i).contains("<Type>")) lore.set(i, lore.get(i).replace("<Type>", StringUtils.format(((CreatureSpawner) e.getBlock().getState()).getSpawnedType().toString())));
|
||||
if (lore.get(i).contains("<Type>")) lore.set(i, lore.get(i).replace("<Type>", StringUtils.format(((CreatureSpawner) b.getState()).getSpawnedType().toString())));
|
||||
}
|
||||
im.setLore(lore);
|
||||
spawner.setItemMeta(im);
|
||||
e.getBlock().getLocation().getWorld().dropItemNaturally(e.getBlock().getLocation(), spawner);
|
||||
b.getLocation().getWorld().dropItemNaturally(b.getLocation(), spawner);
|
||||
e.setExpToDrop(0);
|
||||
return true;
|
||||
}
|
||||
@ -2179,7 +2181,7 @@ public class SlimefunSetup {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
Block b = e.getBlock().getRelative(x, y, z);
|
||||
if (b.getType() != Material.AIR && !StringUtils.equals(b.getType().toString(), explosiveblacklist)) {
|
||||
if (b.getType() != Material.AIR && !b.isLiquid() && !StringUtils.equals(b.getType().toString(), explosiveblacklist)) {
|
||||
if (CSCoreLib.getLib().getProtectionManager().canBuild(e.getPlayer().getUniqueId(), b)) {
|
||||
if (SlimefunStartup.instance.isCoreProtectInstalled()) SlimefunStartup.instance.getCoreProtectAPI().logRemoval(e.getPlayer().getName(), b.getLocation(), b.getType(), b.getBlockData());
|
||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
|
@ -2,12 +2,15 @@ package me.mrCookieSlime.Slimefun.listeners;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.ChestedHorse;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
@ -105,6 +108,7 @@ public class DamageListener implements Listener {
|
||||
}
|
||||
|
||||
if (!e.getEntity().getCanPickupItems() && Talisman.checkFor(e, SlimefunItem.getByID("HUNTER_TALISMAN")) && !(e.getEntity() instanceof Player)) {
|
||||
|
||||
List<ItemStack> newDrops = new ArrayList<ItemStack>();
|
||||
for (ItemStack drop : e.getDrops()) {
|
||||
newDrops.add(drop);
|
||||
@ -112,6 +116,13 @@ public class DamageListener implements Listener {
|
||||
for (ItemStack drop : newDrops) {
|
||||
e.getDrops().add(drop);
|
||||
}
|
||||
|
||||
if(e.getEntity() instanceof ChestedHorse) {
|
||||
for(ItemStack invItem : ((ChestedHorse) e.getEntity()).getInventory().getStorageContents()) {
|
||||
e.getDrops().remove(invItem);
|
||||
}
|
||||
e.getDrops().remove(new ItemStack(Material.CHEST)); //The chest is not included in getStorageContents()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user