1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Merge pull request #3 from TheBusyBiscuit/master

update to master
This commit is contained in:
dniym 2019-08-19 00:55:28 -04:00 committed by GitHub
commit 21f2eb9793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 567 additions and 549 deletions

View File

@ -112,7 +112,7 @@
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId> <artifactId>worldedit-bukkit</artifactId>
<version>7.0.0</version> <version>7.0.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -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<BlockFace> directions = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
private static final List<Material> blockblacklist = new ArrayList<>(); private static final List<Material> blockblacklist = new ArrayList<>();
static { static {
blockblacklist.add(Material.BEDROCK); blockblacklist.add(Material.BEDROCK);
blockblacklist.add(Material.BARRIER); 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) { 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")); 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) { if (allow) {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
@ -711,8 +714,10 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
Collection<ItemStack> drops = block.getDrops(); Collection<ItemStack> drops = block.getDrops();
if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) { if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) {
SlimefunItem item = BlockStorage.check(block); SlimefunItem item = BlockStorage.check(block);
if (item != null) { if (item != null) {
if (fits(b, item.getItem())) { return;
/*if (fits(b, item.getItem())) {
if (SlimefunItem.blockhandler.containsKey(item.getID())) { if (SlimefunItem.blockhandler.containsKey(item.getID())) {
if (SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG)) { if (SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG)) {
pushItems(b, BlockStorage.retrieve(block)); pushItems(b, BlockStorage.retrieve(block));
@ -721,9 +726,8 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
block.setType(Material.AIR); block.setType(Material.AIR);
} }
} }
} }*/
} } else {
else {
ItemStack[] items = drops.toArray(new ItemStack[drops.size()]); ItemStack[] items = drops.toArray(new ItemStack[drops.size()]);
if (fits(b, items)) { if (fits(b, items)) {
pushItems(b, items); pushItems(b, items);
@ -734,6 +738,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
} }
} }
private void movedig(Block b, BlockFace face, Block block) { private void movedig(Block b, BlockFace face, Block block) {
Collection<ItemStack> drops = block.getDrops(); Collection<ItemStack> drops = block.getDrops();
if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) { if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) {

View File

@ -1536,6 +1536,7 @@ public class SlimefunSetup {
@Override @Override
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.AUTO_SMELT_PICKAXE, true)) { 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; if (e.getBlock().getType().equals(Material.PLAYER_HEAD)) return true;
int j = -1; int j = -1;
@ -1838,17 +1839,18 @@ public class SlimefunSetup {
@Override @Override
public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.PICKAXE_OF_CONTAINMENT, true)) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.PICKAXE_OF_CONTAINMENT, true)) {
if (e.getBlock().getType() != Material.SPAWNER) return true; Block b = e.getBlock(); // Refactored it into this so we don't need to call e.getBlock() all the time.
BlockStorage.clearBlockInfo(e.getBlock()); 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(); ItemStack spawner = SlimefunItems.BROKEN_SPAWNER.clone();
ItemMeta im = spawner.getItemMeta(); ItemMeta im = spawner.getItemMeta();
List<String> lore = im.getLore(); List<String> lore = im.getLore();
for (int i = 0; i < lore.size(); i++) { 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); im.setLore(lore);
spawner.setItemMeta(im); spawner.setItemMeta(im);
e.getBlock().getLocation().getWorld().dropItemNaturally(e.getBlock().getLocation(), spawner); b.getLocation().getWorld().dropItemNaturally(b.getLocation(), spawner);
e.setExpToDrop(0); e.setExpToDrop(0);
return true; return true;
} }
@ -2179,7 +2181,7 @@ public class SlimefunSetup {
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++) {
Block b = e.getBlock().getRelative(x, y, 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 (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()); 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()); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());

View File

@ -2,12 +2,15 @@ package me.mrCookieSlime.Slimefun.listeners;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton; 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)) { if (!e.getEntity().getCanPickupItems() && Talisman.checkFor(e, SlimefunItem.getByID("HUNTER_TALISMAN")) && !(e.getEntity() instanceof Player)) {
List<ItemStack> newDrops = new ArrayList<ItemStack>(); List<ItemStack> newDrops = new ArrayList<ItemStack>();
for (ItemStack drop : e.getDrops()) { for (ItemStack drop : e.getDrops()) {
newDrops.add(drop); newDrops.add(drop);
@ -112,6 +116,13 @@ public class DamageListener implements Listener {
for (ItemStack drop : newDrops) { for (ItemStack drop : newDrops) {
e.getDrops().add(drop); 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()
}
} }
} }
} }