Merge branch 'development'

This commit is contained in:
Brianna 2020-10-15 17:29:48 -05:00
commit 8ce5959753
3 changed files with 50 additions and 43 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId>
<version>2.3.13</version>
<version>2.3.14</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -493,47 +493,48 @@ public class EntityListeners implements Listener {
IslandManager islandManager = plugin.getIslandManager();
if (plugin.getWorldManager().isIslandWorld(livingEntity.getWorld())) {
Island island = islandManager.getIslandAtLocation(livingEntity.getLocation());
if (!plugin.getWorldManager().isIslandWorld(livingEntity.getWorld())) return;
if (island != null) {
List<Upgrade> upgrades = plugin.getUpgradeManager().getUpgrades(Upgrade.Type.Drops);
Island island = islandManager.getIslandAtLocation(livingEntity.getLocation());
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled() && island.isUpgrade(Upgrade.Type.Drops)) {
Set<ItemStack> dontMultiply = new HashSet<>();
if (island == null) return;
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) {
EntityEquipment equipment = livingEntity.getEquipment();
if (equipment != null) {
for (ItemStack item : event.getDrops()) {
if (item.equals(equipment.getHelmet()) || item.equals(equipment.getChestplate())
|| item.equals(equipment.getLeggings()) || item.equals(equipment.getBoots())
|| item.equals(equipment.getItemInMainHand()) || item.equals(equipment.getItemInOffHand())) {
dontMultiply.add(item);
}
}
}
List<Upgrade> upgrades = plugin.getUpgradeManager().getUpgrades(Upgrade.Type.Drops);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
if (livingEntity instanceof Steerable) {
Steerable steerable = (Steerable) livingEntity;
if (steerable.hasSaddle())
dontMultiply.add(new ItemStack(CompatibleMaterial.SADDLE.getMaterial(), 1));
}
} else {
if (livingEntity instanceof Pig) {
Pig pig = (Pig) livingEntity;
if (pig.hasSaddle())
dontMultiply.add(new ItemStack(CompatibleMaterial.SADDLE.getMaterial(), 1));
}
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled() && island.isUpgrade(Upgrade.Type.Drops)) {
Set<ItemStack> dontMultiply = new HashSet<>();
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_8)) {
EntityEquipment equipment = livingEntity.getEquipment();
if (equipment != null) {
for (ItemStack item : event.getDrops()) {
if (item.equals(equipment.getHelmet()) || item.equals(equipment.getChestplate())
|| item.equals(equipment.getLeggings()) || item.equals(equipment.getBoots())
|| item.equals(equipment.getItemInMainHand()) || item.equals(equipment.getItemInOffHand())) {
dontMultiply.add(item);
}
}
}
for (ItemStack is : event.getDrops())
if (!dontMultiply.contains(is))
livingEntity.getWorld().dropItemNaturally(livingEntity.getLocation(), is);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
if (livingEntity instanceof Steerable) {
Steerable steerable = (Steerable) livingEntity;
if (steerable.hasSaddle())
dontMultiply.add(new ItemStack(CompatibleMaterial.SADDLE.getMaterial(), 1));
}
} else {
if (livingEntity instanceof Pig) {
Pig pig = (Pig) livingEntity;
if (pig.hasSaddle())
dontMultiply.add(new ItemStack(CompatibleMaterial.SADDLE.getMaterial(), 1));
}
}
}
for (ItemStack is : event.getDrops())
for (ItemStack is2 : dontMultiply)
if (!is2.isSimilar(is))
livingEntity.getWorld().dropItemNaturally(livingEntity.getLocation(), is);
}
}

View File

@ -26,6 +26,7 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.Levelled;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -62,9 +63,13 @@ public class InteractListeners implements Listener {
IslandLevelManager levellingManager = plugin.getLevellingManager();
if (!worldManager.isIslandWorld(block.getWorld())) return;
if (event.getAction() == Action.RIGHT_CLICK_BLOCK &&
worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether) &&
event.getItem().getType().equals(Material.WATER_BUCKET)) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK
&& worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether)
&& (event.getItem().getType().equals(Material.WATER_BUCKET)
|| event.getItem().getType().equals(Material.TROPICAL_FISH_BUCKET)
|| event.getItem().getType().equals(Material.COD_BUCKET)
|| event.getItem().getType().equals(Material.SALMON_BUCKET)
|| event.getItem().getType().equals(Material.PUFFERFISH_BUCKET))) {
Location blockLoc = block.getLocation();
Island island = islandManager.getIslandAtLocation(blockLoc);
@ -85,6 +90,13 @@ public class InteractListeners implements Listener {
return;
}
CompatibleMaterial type = CompatibleMaterial.getMaterial(block);
if (type.name().contains("SLAB")) {
event.setCancelled(true);
return;
}
FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
@ -121,14 +133,8 @@ public class InteractListeners implements Listener {
return;
}
if (configLoad.getBoolean("Island.Nether.AllowNetherWater", false)) {
event.setCancelled(true);
if (configLoad.getBoolean("Island.Nether.AllowNetherWater", false))
block.setType(Material.WATER, true);
block.getWorld().playSound(block.getLocation(), CompatibleSound.ITEM_BUCKET_EMPTY.getSound(), 1f, 1f);
if (!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
event.getItem().setType(Material.BUCKET);
}
}
}
}