Merge branch 'development'

This commit is contained in:
Brianna 2020-04-08 12:29:45 -04:00
commit 1bc17e6b2d
14 changed files with 334 additions and 546 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId> <artifactId>skyblock</artifactId>
<version>2.2.4</version> <version>2.2.5</version>
<build> <build>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>
<finalName>FabledSkyblock-${project.version}</finalName> <finalName>FabledSkyblock-${project.version}</finalName>

View File

@ -100,6 +100,9 @@ public class SkyBlock extends SongodaPlugin {
// Load Economy // Load Economy
EconomyManager.load(); EconomyManager.load();
// Load Holograms
com.songoda.core.hooks.HologramManager.load(this);
fileManager = new FileManager(this); fileManager = new FileManager(this);
localizationManager = new LocalizationManager(); localizationManager = new LocalizationManager();
worldManager = new WorldManager(this); worldManager = new WorldManager(this);

View File

@ -41,7 +41,7 @@ public class RefreshHologramsCommand extends SubCommand {
leaderboardManager.resetLeaderboard(); leaderboardManager.resetLeaderboard();
leaderboardManager.setupLeaderHeads(); leaderboardManager.setupLeaderHeads();
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().resetHologram()); Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().updateHologram());
}); });
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RefreshHolograms.Refreshed.Message")); messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RefreshHolograms.Refreshed.Message"));

View File

@ -93,7 +93,7 @@ public class ReloadCommand extends SubCommand {
leaderboardManager.resetLeaderboard(); leaderboardManager.resetLeaderboard();
leaderboardManager.setupLeaderHeads(); leaderboardManager.setupLeaderHeads();
Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().resetHologram()); Bukkit.getScheduler().runTask(skyblock, () -> skyblock.getHologramManager().updateHologram());
}); });
limitHandler.reloadAll(); limitHandler.reloadAll();

View File

@ -76,9 +76,8 @@ public class RemoveHologramCommand extends SubCommand {
HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase())); HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
Hologram hologram = hologramManager.getHologram(hologramType1); Hologram hologram = hologramManager.getHologram(hologramType1);
if (hologram != null) { if (hologram != null)
hologramManager.removeHologram(hologram); hologram.remove();
}
}); });
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message").replace("%type", hologramType.name())); messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message").replace("%type", hologramType.name()));

View File

@ -9,7 +9,6 @@ import com.songoda.skyblock.hologram.HologramManager;
import com.songoda.skyblock.hologram.HologramType; import com.songoda.skyblock.hologram.HologramType;
import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager; import com.songoda.skyblock.sound.SoundManager;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
@ -55,9 +54,8 @@ public class SetHologramCommand extends SubCommand {
.valueOf(WordUtils.capitalize(args[0].toLowerCase())); .valueOf(WordUtils.capitalize(args[0].toLowerCase()));
Hologram hologram = hologramManager.getHologram(hologramType1); Hologram hologram = hologramManager.getHologram(hologramType1);
if (hologram != null) { if (hologram != null)
hologramManager.removeHologram(hologram); hologram.remove();
}
hologramManager.spawnHologram(hologramType1); hologramManager.spawnHologram(hologramType1);
}); });

View File

@ -1,5 +1,6 @@
package com.songoda.skyblock.hologram; package com.songoda.skyblock.hologram;
import com.songoda.core.hooks.HologramManager;
import com.songoda.skyblock.utils.version.NMSUtil; import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -11,70 +12,30 @@ import java.util.List;
public class Hologram { public class Hologram {
private List<ArmorStand> holograms = new ArrayList<>();
private HologramType type; private HologramType type;
private Location location; private Location location;
public Hologram(HologramType type, Location location, List<String> lines) { public Hologram(HologramType type, Location location, List<String> lines) {
this.type = type; this.type = type;
this.location = location; this.location = location;
HologramManager.createHologram(location, lines);
for (String lineList : lines) {
addLine(lineList);
}
}
public void addLine(String text) {
ArmorStand as = (ArmorStand) location.getWorld().spawnEntity(
location.clone().add(0.0D, getHeight() + getHeightIncrement(), 0.0D), EntityType.ARMOR_STAND);
int NMSVersion = NMSUtil.getVersionNumber();
as.setVisible(false);
if (NMSVersion > 8)
as.setMarker(false);
as.setGravity(false);
as.setCustomName(ChatColor.translateAlternateColorCodes('&', text));
as.setCustomNameVisible(true);
holograms.add(as);
}
public void setLine(int index, String text) {
if (index < holograms.size()) {
ArmorStand as = holograms.get(index);
if (!as.isDead()) {
as.setCustomName(ChatColor.translateAlternateColorCodes('&', text));
as.setCustomNameVisible(true);
}
}
}
public void removeLine(int index) {
if (index < holograms.size()) {
ArmorStand as = holograms.get(index);
if (!as.isDead()) {
as.remove();
}
holograms.remove(index);
}
}
public double getHeight() {
return -2.0D + (holograms.size() * getHeightIncrement());
}
public double getHeightIncrement() {
return 0.35;
} }
public HologramType getType() { public HologramType getType() {
return type; return type;
} }
public List<ArmorStand> getHolograms() {
return holograms; public Location getLocation() {
return location;
}
public void remove() {
HologramManager.removeHologram(location);
}
public void update(List<String> lines) {
HologramManager.updateHologram(location, lines);
} }
} }

View File

@ -1,5 +1,6 @@
package com.songoda.skyblock.hologram; package com.songoda.skyblock.hologram;
import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config; import com.songoda.skyblock.config.FileManager.Config;
@ -9,21 +10,14 @@ import com.songoda.skyblock.leaderboard.LeaderboardManager;
import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.utils.NumberUtil; import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer; import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.visit.Visit; import com.songoda.skyblock.visit.Visit;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
public class HologramManager { public class HologramManager {
@ -37,8 +31,6 @@ public class HologramManager {
FileManager fileManager = skyblock.getFileManager(); FileManager fileManager = skyblock.getFileManager();
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> { Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> {
removeWorldHolograms();
for (HologramType hologramTypeList : HologramType.values()) { for (HologramType hologramTypeList : HologramType.values()) {
if (hologramTypeList == HologramType.Votes) { if (hologramTypeList == HologramType.Votes) {
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")) if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
@ -61,143 +53,89 @@ public class HologramManager {
} }
public void spawnHologram(HologramType type) { public void spawnHologram(HologramType type) {
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
MessageManager messageManager = skyblock.getMessageManager();
FileManager fileManager = skyblock.getFileManager(); FileManager fileManager = skyblock.getFileManager();
Config locationsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")); Config locationsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml"));
FileConfiguration locationsConfigLoad = locationsConfig.getFileConfiguration(); FileConfiguration locationsConfigLoad = locationsConfig.getFileConfiguration();
if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + type) != null)
spawnHologram(type, skyblock.getFileManager().getLocation(locationsConfig,
"Location.Hologram.Leaderboard." + type, true), getHologramLines(type));
}
private List<String> getHologramLines(HologramType type) {
FileManager fileManager = skyblock.getFileManager();
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
MessageManager messageManager = skyblock.getMessageManager();
FileConfiguration languageConfigLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")) FileConfiguration languageConfigLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration(); .getFileConfiguration();
if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + type) != null) { List<String> hologramLines = new ArrayList<>();
List<String> hologramLines = new ArrayList<>(); Leaderboard.Type leaderboardType = null;
Leaderboard.Type leaderboardType = null;
switch (type) { switch (type) {
case Level: case Level:
leaderboardType = Leaderboard.Type.Level; leaderboardType = Leaderboard.Type.Level;
break; break;
case Bank: case Bank:
leaderboardType = Leaderboard.Type.Bank; leaderboardType = Leaderboard.Type.Bank;
break; break;
case Votes: case Votes:
leaderboardType = Leaderboard.Type.Votes; leaderboardType = Leaderboard.Type.Votes;
break; break;
}
hologramLines.add(messageManager.replaceMessage(null,
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Header")));
for (int i = 0; i < 10; i++) {
Leaderboard leaderboard = leaderboardManager.getLeaderboardFromPosition(leaderboardType, i);
if (leaderboard == null) {
hologramLines.add(messageManager.replaceMessage(null,
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Unclaimed")
.replace("%position", "" + (i + 1))));
} else {
Visit visit = leaderboard.getVisit();
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
if (type == HologramType.Level) {
IslandLevel level = visit.getLevel();
hologramLines.add(ChatColor.translateAlternateColorCodes('&',
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))
.replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints()))));
} else if (type == HologramType.Bank) {
hologramLines.add(ChatColor.translateAlternateColorCodes('&',
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%balance",
"" + NumberUtil.formatNumberByDecimal(visit.getBankBalance()))));
} else if (type == HologramType.Votes) {
hologramLines.add(ChatColor.translateAlternateColorCodes('&',
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%votes",
"" + NumberUtil.formatNumberByDecimal(visit.getVoters().size()))));
}
}
}
String hologramFooter = languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Footer");
if (!hologramFooter.isEmpty()) {
hologramLines.add(messageManager.replaceMessage(null, hologramFooter));
}
Collections.reverse(hologramLines);
spawnHologram(type, skyblock.getFileManager().getLocation(locationsConfig,
"Location.Hologram.Leaderboard." + type, true), hologramLines);
} }
}
public void removeHologram(Hologram hologram) { hologramLines.add(TextUtils.formatText(
if (hologramStorage.contains(hologram)) { languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Header")));
List<ArmorStand> holograms = hologram.getHolograms();
for (Iterator<ArmorStand> it = holograms.iterator(); it.hasNext(); ) { for (int i = 0; i < 10; i++) {
it.next().remove(); Leaderboard leaderboard = leaderboardManager.getLeaderboardFromPosition(leaderboardType, i);
if (leaderboard == null) continue;
Visit visit = leaderboard.getVisit();
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName = targetPlayer == null
? new OfflinePlayer(visit.getOwnerUUID()).getName() : targetPlayer.getName();
if (type == HologramType.Level) {
IslandLevel level = visit.getLevel();
hologramLines.add(TextUtils.formatText(
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))
.replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints()))));
} else if (type == HologramType.Bank) {
hologramLines.add(TextUtils.formatText(
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%balance",
"" + NumberUtil.formatNumberByDecimal(visit.getBankBalance()))));
} else if (type == HologramType.Votes) {
hologramLines.add(TextUtils.formatText(
languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%votes",
"" + NumberUtil.formatNumberByDecimal(visit.getVoters().size()))));
} }
hologramStorage.remove(hologram);
} }
String hologramFooter = languageConfigLoad.getString("Hologram.Leaderboard." + type.name() + ".Footer");
if (!hologramFooter.isEmpty())
hologramLines.add(TextUtils.formatText(hologramFooter));
return hologramLines;
} }
public void removeHolograms() { public void removeHolograms() {
for (Hologram hologramList : hologramStorage) { for (Hologram hologramList : hologramStorage) {
List<ArmorStand> holograms = hologramList.getHolograms(); hologramList.remove();
for (Iterator<ArmorStand> it = holograms.iterator(); it.hasNext(); ) {
it.next().remove();
}
}
}
public void removeWorldHolograms() {
FileManager fileManager = skyblock.getFileManager();
List<Location> locations = new ArrayList<>();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
for (HologramType hologramTypeList : HologramType.values()) {
if (configLoad.getString("Location.Hologram.Leaderboard." + hologramTypeList.name()) != null) {
locations.add(fileManager.getLocation(config,
"Location.Hologram.Leaderboard." + hologramTypeList.name(), true));
}
}
for (World worldList : Bukkit.getWorlds()) {
List<Entity> entities = worldList.getEntities();
for (Iterator<Entity> it = entities.iterator(); it.hasNext(); ) {
Entity entity = it.next();
if (entity instanceof ArmorStand) {
for (Location locationList : locations) {
if (LocationUtil.isLocationAtLocationRadius(entity.getLocation(), locationList, 1)) {
entity.remove();
}
}
}
}
} }
} }
@ -211,99 +149,9 @@ public class HologramManager {
return null; return null;
} }
public boolean hasHologram(HologramType type) { public void updateHologram() {
for (Hologram hologramList : hologramStorage) { for (Hologram hologramList : hologramStorage) {
if (hologramList.getType() == type) { hologramList.update(getHologramLines(hologramList.getType()));
return true;
}
}
return false;
}
public void resetHologram() {
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
MessageManager messageManager = skyblock.getMessageManager();
FileManager fileManager = skyblock.getFileManager();
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration();
for (HologramType hologramTypeList : HologramType.values()) {
if (hologramTypeList == HologramType.Votes) {
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Visitor.Vote")) {
continue;
}
}
Hologram hologram;
if (hasHologram(hologramTypeList)) {
hologram = getHologram(hologramTypeList);
} else {
continue;
}
Leaderboard.Type leaderboardType = null;
switch (hologramTypeList) {
case Level:
leaderboardType = Leaderboard.Type.Level;
break;
case Bank:
leaderboardType = Leaderboard.Type.Bank;
break;
case Votes:
leaderboardType = Leaderboard.Type.Votes;
break;
}
for (int i = 0; i < 10; i++) {
Leaderboard leaderboard = leaderboardManager.getLeaderboardFromPosition(leaderboardType, i);
int hologramLine = 10 - i;
if (leaderboard == null) {
hologram.setLine(hologramLine, messageManager.replaceMessage(null,
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Unclaimed")
.replace("%position", "" + (i + 1))));
} else {
Visit visit = leaderboard.getVisit();
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
String islandOwnerName;
if (targetPlayer == null) {
islandOwnerName = new OfflinePlayer(visit.getOwnerUUID()).getName();
} else {
islandOwnerName = targetPlayer.getName();
}
if (hologramTypeList == HologramType.Level) {
IslandLevel level = visit.getLevel();
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%level", NumberUtil.formatNumberByDecimal(level.getLevel()))
.replace("%points", NumberUtil.formatNumberByDecimal(level.getPoints()))));
} else if (hologramTypeList == HologramType.Bank) {
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%balance",
"" + NumberUtil.formatNumberByDecimal(visit.getBankBalance()))));
} else if (hologramTypeList == HologramType.Votes) {
hologram.setLine(hologramLine, ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Hologram.Leaderboard." + hologramTypeList.name() + ".Claimed")
.replace("%position", "" + (i + 1))
.replace("%player", islandOwnerName)
.replace("%votes",
"" + NumberUtil.formatNumberByDecimal(visit.getVoters().size()))));
}
}
}
} }
} }
} }

View File

@ -18,6 +18,6 @@ public class LeaderboardTask extends BukkitRunnable {
leaderboardManager.resetLeaderboard(); leaderboardManager.resetLeaderboard();
leaderboardManager.setupLeaderHeads(); leaderboardManager.setupLeaderHeads();
skyblock.getHologramManager().resetHologram(); skyblock.getHologramManager().updateHologram();
} }
} }

View File

@ -140,7 +140,11 @@ public class Block implements Listener {
if (event.isCancelled() || !configLoad.getBoolean("Island.Block.Level.Enable")) return; if (event.isCancelled() || !configLoad.getBoolean("Island.Block.Level.Enable")) return;
if (CompatibleMaterial.getMaterial(block).isTall()) { CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
if (material == null) return;
if (material.isTall()) {
final org.bukkit.block.Block belowBlock = block.getRelative(BlockFace.DOWN); final org.bukkit.block.Block belowBlock = block.getRelative(BlockFace.DOWN);
@ -150,8 +154,6 @@ public class Block implements Listener {
} }
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
if (block.getType() == CompatibleMaterial.SPAWNER.getBlockMaterial()) { if (block.getType() == CompatibleMaterial.SPAWNER.getBlockMaterial()) {
CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType()); CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());

View File

@ -1,9 +1,26 @@
package com.songoda.skyblock.listeners; package com.songoda.skyblock.listeners;
import java.io.File; import com.songoda.core.compatibility.CompatibleHand;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound; import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandLevel;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
import com.songoda.skyblock.limit.impl.BlockLimitation;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.item.InventoryUtil;
import com.songoda.skyblock.utils.structure.StructureUtil;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.world.WorldManager;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -28,26 +45,11 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandLevel;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
import com.songoda.skyblock.limit.impl.BlockLimitation;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.item.InventoryUtil;
import com.songoda.skyblock.utils.structure.StructureUtil;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionAttachmentInfo;
import java.io.File;
import java.util.HashMap;
public class Interact implements Listener { public class Interact implements Listener {
private final SkyBlock skyblock; private final SkyBlock skyblock;
@ -84,8 +86,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -94,8 +96,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -104,8 +106,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -114,8 +116,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -123,33 +125,34 @@ public class Interact implements Listener {
} }
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) { if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) {
if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.EGG) { if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.EGG) {
if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) { if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} }
} }
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { CompatibleMaterial material = block == null ? null : CompatibleMaterial.getMaterial(block.getType());
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
final CompatibleMaterial blockType = CompatibleMaterial.getBlockMaterial(event.getClickedBlock().getType()); final CompatibleMaterial blockType = CompatibleMaterial.getBlockMaterial(event.getClickedBlock().getType());
final CompatibleMaterial heldType; final CompatibleMaterial heldType;
final ItemStack item = event.getItem(); final ItemStack item = event.getItem();
if (item != null && CompatibleMaterial.getMaterial(item.getType()) != CompatibleMaterial.AIR) { if (item != null && CompatibleMaterial.getMaterial(item.getType()) != CompatibleMaterial.AIR) {
heldType = CompatibleMaterial.getMaterial(event.getItem().getType()); heldType = CompatibleMaterial.getMaterial(event.getItem());
} else { } else {
heldType = CompatibleMaterial.AIR; heldType = CompatibleMaterial.AIR;
} }
if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType && !player.isSneaking() && islandManager if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType && !player.isSneaking() && islandManager
.hasPermission(player, block.getLocation(), "Place") .hasPermission(player, block.getLocation(), "Place")
&& (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission") && (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission")
|| player.hasPermission("fabledskyblock.stackable"))) { || player.hasPermission("fabledskyblock.stackable"))) {
if (NMSUtil.getVersionNumber() > 8) { if (NMSUtil.getVersionNumber() > 8) {
if (event.getHand() == EquipmentSlot.OFF_HAND) { if (event.getHand() == EquipmentSlot.OFF_HAND) {
return; return;
@ -158,7 +161,7 @@ public class Interact implements Listener {
if (levellingManager.isScanning(island)) { if (levellingManager.isScanning(island)) {
skyblock.getMessageManager().sendMessage(player, skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -168,12 +171,10 @@ public class Interact implements Listener {
long limit = limits.getBlockLimit(player, block); long limit = limits.getBlockLimit(player, block);
if (limits.isBlockLimitExceeded(block, limit)) { if (limits.isBlockLimitExceeded(block, limit)) {
CompatibleMaterial material = CompatibleMaterial.getBlockMaterial(block.getType());
skyblock.getMessageManager().sendMessage(player, skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message") skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit))); .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -188,13 +189,12 @@ public class Interact implements Listener {
if (configLoad.getBoolean("Island.Stackable.Limit.Enable")) { if (configLoad.getBoolean("Island.Stackable.Limit.Enable")) {
// Add block to stackable // Add block to stackable
CompatibleMaterial material = CompatibleMaterial.getBlockMaterial(block.getType());
int maxStackSize = getStackLimit(player, material); int maxStackSize = getStackLimit(player, material);
if (stackable == null) { if (stackable == null) {
stackableManager.addStack(stackable = new Stackable(location, blockType, maxStackSize)); stackableManager.addStack(stackable = new Stackable(location, blockType, maxStackSize));
stackable.setSize(itemAmount + 1); stackable.setSize(itemAmount + 1);
if(stackable.isMaxSize()){ if (stackable.isMaxSize()) {
stackable.setSize(stackable.getMaxSize()); stackable.setSize(stackable.getMaxSize());
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -202,7 +202,7 @@ public class Interact implements Listener {
} else { } else {
stackable.setMaxSize(maxStackSize); stackable.setMaxSize(maxStackSize);
stackable.setSize(stackable.getSize() + itemAmount); stackable.setSize(stackable.getSize() + itemAmount);
if(stackable.isMaxSize()){ if (stackable.isMaxSize()) {
stackable.setSize(stackable.getMaxSize()); stackable.setSize(stackable.getMaxSize());
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -231,7 +231,6 @@ public class Interact implements Listener {
long materialAmmount = 0; long materialAmmount = 0;
IslandLevel level = island.getLevel(); IslandLevel level = island.getLevel();
CompatibleMaterial material = CompatibleMaterial.getBlockMaterial(block.getType());
if (material == null) { if (material == null) {
return; return;
@ -255,255 +254,230 @@ public class Interact implements Listener {
return; return;
} }
if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.BONE_MEAL && !islandManager.hasPermission(player, block.getLocation(), "Place")) { if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BONE_MEAL && !islandManager.hasPermission(player, block.getLocation(), "Place")) {
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SWEET_BERRY_BUSH) { if (material == CompatibleMaterial.SWEET_BERRY_BUSH) {
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) { if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ANVIL) { } else if (material == CompatibleMaterial.ANVIL) {
if (!islandManager.hasPermission(player, block.getLocation(), "Anvil")) { if (!islandManager.hasPermission(player, block.getLocation(), "Anvil")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.WHITE_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ORANGE_BED } else if (material == CompatibleMaterial.WHITE_BED || material == CompatibleMaterial.ORANGE_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.MAGENTA_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_BLUE_BED || material == CompatibleMaterial.MAGENTA_BED || material == CompatibleMaterial.LIGHT_BLUE_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.YELLOW_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIME_BED || material == CompatibleMaterial.YELLOW_BED || material == CompatibleMaterial.LIME_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.PINK_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.GRAY_BED || material == CompatibleMaterial.PINK_BED || material == CompatibleMaterial.GRAY_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_GRAY_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CYAN_BED || material == CompatibleMaterial.LIGHT_GRAY_BED || material == CompatibleMaterial.CYAN_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CYAN_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.PURPLE_BED || material == CompatibleMaterial.CYAN_BED || material == CompatibleMaterial.PURPLE_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BLUE_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BROWN_BED || material == CompatibleMaterial.BLUE_BED || material == CompatibleMaterial.BROWN_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.GREEN_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.RED_BED || material == CompatibleMaterial.GREEN_BED || material == CompatibleMaterial.RED_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BLACK_BED || material == CompatibleMaterial.BLACK_BED
) { ) {
if (!islandManager.hasPermission(player, block.getLocation(), "Bed")) { if (!islandManager.hasPermission(player, block.getLocation(), "Bed")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BREWING_STAND) { } else if (material == CompatibleMaterial.BREWING_STAND) {
if (!islandManager.hasPermission(player, block.getLocation(), "Brewing")) { if (!islandManager.hasPermission(player, block.getLocation(), "Brewing")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CHEST || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.TRAPPED_CHEST } else if (material == CompatibleMaterial.CHEST || material == CompatibleMaterial.TRAPPED_CHEST
|| (NMSUtil.getVersionNumber() > 9 && (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SHULKER_BOX || (NMSUtil.getVersionNumber() > 9 && (material == CompatibleMaterial.SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BLACK_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BLUE_SHULKER_BOX || material == CompatibleMaterial.BLACK_SHULKER_BOX || material == CompatibleMaterial.BLUE_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BROWN_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CYAN_SHULKER_BOX || material == CompatibleMaterial.BROWN_SHULKER_BOX || material == CompatibleMaterial.CYAN_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.GRAY_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.GREEN_SHULKER_BOX || material == CompatibleMaterial.GRAY_SHULKER_BOX || material == CompatibleMaterial.GREEN_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_BLUE_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_GRAY_SHULKER_BOX || material == CompatibleMaterial.LIGHT_BLUE_SHULKER_BOX || material == CompatibleMaterial.LIGHT_GRAY_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIME_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.MAGENTA_SHULKER_BOX || material == CompatibleMaterial.LIME_SHULKER_BOX || material == CompatibleMaterial.MAGENTA_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ORANGE_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.PINK_SHULKER_BOX || material == CompatibleMaterial.ORANGE_SHULKER_BOX || material == CompatibleMaterial.PINK_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.PURPLE_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.RED_SHULKER_BOX || material == CompatibleMaterial.PURPLE_SHULKER_BOX || material == CompatibleMaterial.RED_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.WHITE_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.YELLOW_SHULKER_BOX))) { || material == CompatibleMaterial.WHITE_SHULKER_BOX || material == CompatibleMaterial.YELLOW_SHULKER_BOX))) {
if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) { if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CRAFTING_TABLE) { } else if (material == CompatibleMaterial.CRAFTING_TABLE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Workbench")) { if (!islandManager.hasPermission(player, block.getLocation(), "Workbench")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_DOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_DOOR } else if (material == CompatibleMaterial.BIRCH_DOOR || material == CompatibleMaterial.ACACIA_DOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_DOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_DOOR || material == CompatibleMaterial.DARK_OAK_DOOR || material == CompatibleMaterial.JUNGLE_DOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_DOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_DOOR) { || material == CompatibleMaterial.SPRUCE_DOOR || material == CompatibleMaterial.OAK_DOOR) {
if (!islandManager.hasPermission(player, block.getLocation(), "Door")) { if (!islandManager.hasPermission(player, block.getLocation(), "Door")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ENCHANTING_TABLE) { } else if (material == CompatibleMaterial.ENCHANTING_TABLE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Enchant")) { if (!islandManager.hasPermission(player, block.getLocation(), "Enchant")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.FURNACE) { } else if (material == CompatibleMaterial.FURNACE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Furnace")) { if (!islandManager.hasPermission(player, block.getLocation(), "Furnace")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.STONE_BUTTON || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_BUTTON || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_BUTTON } else if (material == CompatibleMaterial.STONE_BUTTON || material == CompatibleMaterial.OAK_BUTTON || material == CompatibleMaterial.SPRUCE_BUTTON
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_BUTTON|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_BUTTON || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_BUTTON || material == CompatibleMaterial.BIRCH_BUTTON || material == CompatibleMaterial.JUNGLE_BUTTON || material == CompatibleMaterial.ACACIA_BUTTON
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_BUTTON || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LEVER) { || material == CompatibleMaterial.DARK_OAK_BUTTON || material == CompatibleMaterial.LEVER) {
if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) { if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUKEBOX) { } else if (material == CompatibleMaterial.JUKEBOX) {
if (!islandManager.hasPermission(player, block.getLocation(), "Jukebox")) { if (!islandManager.hasPermission(player, block.getLocation(), "Jukebox")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return;
}
} else if (material == CompatibleMaterial.OAK_TRAPDOOR || material == CompatibleMaterial.SPRUCE_TRAPDOOR
|| material == CompatibleMaterial.BIRCH_TRAPDOOR || material == CompatibleMaterial.JUNGLE_TRAPDOOR
|| material == CompatibleMaterial.ACACIA_TRAPDOOR || material == CompatibleMaterial.DARK_OAK_TRAPDOOR
|| material == CompatibleMaterial.NOTE_BLOCK || material == CompatibleMaterial.HOPPER
|| material == CompatibleMaterial.COMPARATOR || material == CompatibleMaterial.REPEATER) {
if (material == CompatibleMaterial.HOPPER && !islandManager.hasPermission(player, block.getLocation(), "Hopper")) {
event.setCancelled(true);
messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_TRAPDOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_TRAPDOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_TRAPDOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_TRAPDOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_TRAPDOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_TRAPDOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.NOTE_BLOCK || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.HOPPER
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.COMPARATOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.REPEATER) {
if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) { if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_FENCE_GATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_FENCE_GATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_FENCE_GATE } else if (material == CompatibleMaterial.OAK_FENCE_GATE || material == CompatibleMaterial.ACACIA_FENCE_GATE || material == CompatibleMaterial.BIRCH_FENCE_GATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_FENCE_GATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_FENCE_GATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_FENCE_GATE) { || material == CompatibleMaterial.DARK_OAK_FENCE_GATE || material == CompatibleMaterial.JUNGLE_FENCE_GATE || material == CompatibleMaterial.SPRUCE_FENCE_GATE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Gate")) { if (!islandManager.hasPermission(player, block.getLocation(), "Gate")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if ((CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DROPPER || (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DISPENSER))) { } else if ((material == CompatibleMaterial.DROPPER || (material == CompatibleMaterial.DISPENSER))) {
if (!islandManager.hasPermission(player, block.getLocation(), "DropperDispenser")) { if (!islandManager.hasPermission(player, block.getLocation(), "DropperDispenser")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.TNT) { } else if (material == CompatibleMaterial.TNT) {
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) { if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CAKE) { } else if (material == CompatibleMaterial.CAKE) {
if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, block.getLocation(), "Cake")) { if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, block.getLocation(), "Cake")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.HOPPER) { } else if (player.getGameMode() == GameMode.SURVIVAL
if (!islandManager.hasPermission(player, block.getLocation(), "Hopper")) { && material == CompatibleMaterial.OBSIDIAN
event.setCancelled(true); && event.getItem() != null
&& CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR
messageManager.sendMessage(player, && CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BUCKET) {
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return;
}
} else if ((player.getGameMode() == GameMode.SURVIVAL)
&& (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OBSIDIAN) && (event.getItem() != null) && (CompatibleMaterial.getMaterial(event.getItem().getType()) != CompatibleMaterial.AIR)
&& (CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.BUCKET)) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable") if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable")
&& islandManager.hasPermission(player, block.getLocation(), "Bucket")) { && islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
int NMSVersion = NMSUtil.getVersionNumber();
boolean isInventoryFull = false;
if (NMSVersion > 8) { CompatibleSound.BLOCK_FIRE_EXTINGUISH.play(block.getWorld(), block.getLocation(), 1.0F, 1.0F);
isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 5, 1, CompatibleMaterial.BUCKET.getBlockMaterial());
} else {
isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 0, 1, CompatibleMaterial.BUCKET.getBlockMaterial());
}
soundManager.playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1.0F, 1.0F);
InventoryUtil.removeItem(player.getInventory(), 1, false, CompatibleMaterial.BUCKET.getBlockMaterial());
block.setType(CompatibleMaterial.AIR.getBlockMaterial()); block.setType(CompatibleMaterial.AIR.getBlockMaterial());
if (isInventoryFull) { ItemUtils.takeActiveItem(player, CompatibleHand.getHand(event));
player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(CompatibleMaterial.LAVA_BUCKET.getBlockMaterial())); HashMap<Integer, ItemStack> overflow = player.getInventory().addItem(CompatibleMaterial.LAVA_BUCKET.getItem());
} else { for (ItemStack i : overflow.values())
if (NMSVersion > 8) { block.getWorld().dropItemNaturally(block.getLocation(), i);
isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 5, 1, CompatibleMaterial.LAVA_BUCKET.getBlockMaterial());
} else {
isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 0, 1, CompatibleMaterial.LAVA_BUCKET.getBlockMaterial());
}
if (isInventoryFull) {
player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(CompatibleMaterial.LAVA_BUCKET.getBlockMaterial()));
} else {
player.getInventory().addItem(new ItemStack(CompatibleMaterial.LAVA_BUCKET.getBlockMaterial()));
}
}
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.END_PORTAL_FRAME) { } else if (material == CompatibleMaterial.END_PORTAL_FRAME) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable") if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
&& islandManager.hasPermission(player, block.getLocation(), "Destroy")) { && islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
if (NMSUtil.getVersionNumber() > 8 && event.getHand() == EquipmentSlot.OFF_HAND) {
return;
}
if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) { if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
if (com.songoda.epicanchors.EpicAnchors.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) { if (com.songoda.epicanchors.EpicAnchors.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
@ -512,11 +486,12 @@ public class Interact implements Listener {
} }
} }
if (CompatibleHand.getHand(event) == CompatibleHand.OFF_HAND) return;
ItemStack is = event.getPlayer().getItemInHand(); ItemStack is = event.getPlayer().getItemInHand();
boolean hasEye = ((block.getData() >> 2) & 1) == 1; boolean hasEye = ((block.getData() >> 2) & 1) == 1;
if (is == null || CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.AIR) { if (CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.AIR) {
int size = 1; int size = 1;
if (stackableManager != null && stackableManager.isStacked(block.getLocation())) { if (stackableManager != null && stackableManager.isStacked(block.getLocation())) {
@ -556,7 +531,7 @@ public class Interact implements Listener {
} }
} }
soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 10.0F, 10.0F); CompatibleSound.ENTITY_CHICKEN_EGG.play(player, 10.0F, 10.0F);
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -564,27 +539,27 @@ public class Interact implements Listener {
} }
} }
if ((event.getItem() != null) && (CompatibleMaterial.getMaterial(event.getItem().getType()) != CompatibleMaterial.AIR) && !event.isCancelled()) { if ((event.getItem() != null) && (CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR) && !event.isCancelled()) {
if (CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.BUCKET if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BUCKET
|| CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.WATER_BUCKET || CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.WATER_BUCKET
|| CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.LAVA_BUCKET) { || CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.LAVA_BUCKET) {
if (!islandManager.hasPermission(player, block.getLocation(), "Bucket")) { if (!islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
player.updateInventory(); player.updateInventory();
} }
} else if (CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.GLASS_BOTTLE) { } else if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.GLASS_BOTTLE) {
if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.WATER || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CAULDRON) { if (material == CompatibleMaterial.WATER || material == CompatibleMaterial.CAULDRON) {
if (!islandManager.hasPermission(player, block.getLocation(), "WaterCollection")) { if (!islandManager.hasPermission(player, block.getLocation(), "WaterCollection")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
player.updateInventory(); player.updateInventory();
} }
@ -594,18 +569,18 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
player.updateInventory(); player.updateInventory();
} }
} else if (CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.ARMOR_STAND || event.getItem().getType().name().contains("BOAT") || event.getItem().getType().name().contains("MINECART")) { } else if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.ARMOR_STAND || event.getItem().getType().name().contains("BOAT") || event.getItem().getType().name().contains("MINECART")) {
if (!islandManager.hasPermission(player, block.getLocation(), "EntityPlacement")) { if (!islandManager.hasPermission(player, block.getLocation(), "EntityPlacement")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
player.updateInventory(); player.updateInventory();
} }
@ -618,37 +593,37 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} }
} else if (event.getAction() == Action.PHYSICAL) { } else if (event.getAction() == Action.PHYSICAL) {
if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.TURTLE_EGG) { if (material == CompatibleMaterial.TURTLE_EGG) {
event.setCancelled(true); event.setCancelled(true);
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.FARMLAND) { } else if (material == CompatibleMaterial.FARMLAND) {
if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) { if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.STONE_PRESSURE_PLATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_PRESSURE_PLATE } else if (material == CompatibleMaterial.STONE_PRESSURE_PLATE || material == CompatibleMaterial.OAK_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_PRESSURE_PLATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_PRESSURE_PLATE || material == CompatibleMaterial.SPRUCE_PRESSURE_PLATE || material == CompatibleMaterial.BIRCH_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_PRESSURE_PLATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_PRESSURE_PLATE || material == CompatibleMaterial.JUNGLE_PRESSURE_PLATE || material == CompatibleMaterial.ACACIA_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_PRESSURE_PLATE || material == CompatibleMaterial.DARK_OAK_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_WEIGHTED_PRESSURE_PLATE || material == CompatibleMaterial.LIGHT_WEIGHTED_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE) { || material == CompatibleMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE) {
if (!islandManager.hasPermission(player, block.getLocation(), "PressurePlate")) { if (!islandManager.hasPermission(player, block.getLocation(), "PressurePlate")) {
event.setCancelled(true); event.setCancelled(true);
} }
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.TRIPWIRE) { } else if (material == CompatibleMaterial.TRIPWIRE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) { if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} }
} }
@ -680,17 +655,17 @@ public class Interact implements Listener {
ItemStack structureTool = StructureUtil.getTool(); ItemStack structureTool = StructureUtil.getTool();
if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName() if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName()
.equals(structureTool.getItemMeta().getDisplayName()))) { .equals(structureTool.getItemMeta().getDisplayName()))) {
if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player
.hasPermission("fabledskyblock.admin.*") .hasPermission("fabledskyblock.admin.*")
|| player.hasPermission("fabledskyblock.*")) { || player.hasPermission("fabledskyblock.*")) {
event.setCancelled(true); event.setCancelled(true);
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(1, event.getClickedBlock().getLocation()); skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(1, event.getClickedBlock().getLocation());
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message") skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message")
.replace("%position", "1")); .replace("%position", "1"));
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
} }
} }
@ -698,17 +673,17 @@ public class Interact implements Listener {
ItemStack structureTool = StructureUtil.getTool(); ItemStack structureTool = StructureUtil.getTool();
if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName() if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName()
.equals(structureTool.getItemMeta().getDisplayName()))) { .equals(structureTool.getItemMeta().getDisplayName()))) {
if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player
.hasPermission("fabledskyblock.admin.*") .hasPermission("fabledskyblock.admin.*")
|| player.hasPermission("fabledskyblock.*")) { || player.hasPermission("fabledskyblock.*")) {
event.setCancelled(true); event.setCancelled(true);
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(2, event.getClickedBlock().getLocation()); skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(2, event.getClickedBlock().getLocation());
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message") skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message")
.replace("%position", "2")); .replace("%position", "2"));
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
} }
} }
@ -737,8 +712,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -754,8 +729,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -764,8 +739,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -775,8 +750,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -785,15 +760,15 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "EntityPlacement")) { if (!islandManager.hasPermission(player, entity.getLocation(), "EntityPlacement")) {
event.setCancelled(true); event.setCancelled(true);
skyblock.getMessageManager().sendMessage(player, skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} else if (entity.getType().equals(EntityType.ITEM_FRAME)) { } else if (entity.getType().equals(EntityType.ITEM_FRAME)) {
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "Storage")) { if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "Storage")) {
event.setCancelled(true); event.setCancelled(true);
skyblock.getMessageManager().sendMessage(player, skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} else if (entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) { } else if (entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
if (CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.BUCKET) { if (CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.BUCKET) {
@ -801,8 +776,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -812,8 +787,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -822,8 +797,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -832,8 +807,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -842,8 +817,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return; return;
} }
@ -896,7 +871,7 @@ public class Interact implements Listener {
if (!(CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.COD if (!(CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.COD
|| CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.SALMON || CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.SALMON
|| CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.TROPICAL_FISH || CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.TROPICAL_FISH
|| CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.PUFFERFISH)) { || CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.PUFFERFISH)) {
return; return;
} }
} else if (entity.getType() == EntityType.RABBIT) { } else if (entity.getType() == EntityType.RABBIT) {
@ -933,8 +908,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
messageManager.sendMessage(player, messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} }
} }
@ -951,8 +926,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
skyblock.getMessageManager() skyblock.getMessageManager()
.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); .sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} }
@ -968,8 +943,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
skyblock.getMessageManager() skyblock.getMessageManager()
.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); .sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} }
@ -994,8 +969,8 @@ public class Interact implements Listener {
event.setCancelled(true); event.setCancelled(true);
skyblock.getMessageManager().sendMessage(player, skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} }
} }

View File

@ -247,10 +247,12 @@ public final class BlockUtil extends BlockUtils {
public static void convertBlockDataToBlock(Block block, BlockData blockData) { public static void convertBlockDataToBlock(Block block, BlockData blockData) {
int NMSVersion = NMSUtil.getVersionNumber(); int NMSVersion = NMSUtil.getVersionNumber();
String material = blockData.getMaterial(); String materialStr = blockData.getMaterial();
if (material == null) return; if (materialStr == null) return;
Material material = Material.valueOf(materialStr);
if (material == Material.AIR) return;
setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.valueOf(material), blockData.getData()); setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), material, blockData.getData());
// TODO Create a class to support biome changes // TODO Create a class to support biome changes
// block.setBiome(Biome.valueOf(blockData.getBiome().toUpperCase())); // block.setBiome(Biome.valueOf(blockData.getBiome().toUpperCase()));
@ -425,10 +427,10 @@ public final class BlockUtil extends BlockUtils {
String[] flower = blockData.getFlower().split(":"); String[] flower = blockData.getFlower().split(":");
int materialData = Integer.parseInt(flower[1]); int materialData = Integer.parseInt(flower[1]);
material = flower[0].toUpperCase(); materialStr = flower[0].toUpperCase();
if (material != null) { if (materialStr != null) {
ItemStack is = new ItemStack(Material.getMaterial(material), 1, (byte) materialData); ItemStack is = new ItemStack(Material.getMaterial(materialStr), 1, (byte) materialData);
World world = block.getWorld(); World world = block.getWorld();
@ -459,20 +461,20 @@ public final class BlockUtil extends BlockUtils {
if (blockData.getFlower() != null && !blockData.getFlower().isEmpty()) { if (blockData.getFlower() != null && !blockData.getFlower().isEmpty()) {
org.bukkit.material.FlowerPot flowerPot = (org.bukkit.material.FlowerPot) state.getData(); org.bukkit.material.FlowerPot flowerPot = (org.bukkit.material.FlowerPot) state.getData();
String[] flower = blockData.getFlower().split(":"); String[] flower = blockData.getFlower().split(":");
material = null; materialStr = null;
if (blockData.getVersion() > 12) { if (blockData.getVersion() > 12) {
if (NMSVersion > 12) { if (NMSVersion > 12) {
material = flower[0].toUpperCase(); materialStr = flower[0].toUpperCase();
} }
} else { } else {
if (NMSVersion < 13) { if (NMSVersion < 13) {
material = flower[0].toUpperCase(); materialStr = flower[0].toUpperCase();
} }
} }
if (material != null) { if (materialStr != null) {
flowerPot.setContents(new MaterialData(Material.getMaterial(material), (byte) Integer.parseInt(flower[1]))); flowerPot.setContents(new MaterialData(Material.getMaterial(materialStr), (byte) Integer.parseInt(flower[1])));
} }
state.setData(flowerPot); state.setData(flowerPot);
@ -480,7 +482,7 @@ public final class BlockUtil extends BlockUtils {
} }
} }
if (material.equals("DOUBLE_PLANT")) { if (materialStr.equals("DOUBLE_PLANT")) {
Block topBlock = block.getLocation().add(0.0D, 1.0D, 0.0D).getBlock(); Block topBlock = block.getLocation().add(0.0D, 1.0D, 0.0D).getBlock();
Block bottomBlock = block.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock(); Block bottomBlock = block.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();

View File

@ -295,7 +295,7 @@ Command:
Set: Set:
Message: '&bSkyBlock &8| &aInfo&8: &eThe ''&b%type&e'' hologram has been set to your location.' Message: '&bSkyBlock &8| &aInfo&8: &eThe ''&b%type&e'' hologram has been set to your location.'
Invalid: Invalid:
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin sethologram <Level|Votes>' Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin sethologram <Level|Votes|Bank>'
Info: Info:
Message: '&f&oSets the location of a hologram.' Message: '&f&oSets the location of a hologram.'
Settings: Settings:
@ -316,7 +316,7 @@ Command:
Message: '&f&oManage generators for cobblestone generators.' Message: '&f&oManage generators for cobblestone generators.'
RemoveHologram: RemoveHologram:
Invalid: Invalid:
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin removehologram <Level|Votes>' Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin removehologram <Level|Votes|Bank>'
Set: Set:
Message: '&bSkyBlock &8| &cError&8: &eA location for that hologram has not been set.' Message: '&bSkyBlock &8| &cError&8: &eA location for that hologram has not been set.'
Info: Info:

View File

@ -4,7 +4,7 @@ version: maven-version-number
api-version: 1.13 api-version: 1.13
description: A unique SkyBlock plugin description: A unique SkyBlock plugin
author: Songoda author: Songoda
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit] softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit]
loadbefore: [Multiverse-Core] loadbefore: [Multiverse-Core]
commands: commands:
island: island: