# Added the option 'Island.Portal.Island' to the configuration file to teleport the player to the end or nether world rather than the island world when they enter a portal at their island.
# Added the option 'Island.Void.Teleport.Island' to the configuration file that teleports the player to either the main or island spawn point when the player falls into the void.
# Added the path 'Island.Portal.Destination.Message' to the configuration file that sends a message to the player if there's no world available when entering a portal.
# Added a check to the confirmation command when a player wants to delete their island that requires their island to be closed.
# Added the variable '%owner' for the player head display names in the leader board menu.
# Added the alias '/island upgrades' to the command '/island upgrade'.
# Fixed upgrades now being removed from a player when they die at an island and are teleported to the main spawn point rather than the island spawn point.
# Fixed players being able to place hanging entities at an island when the setting 'EntityPlacement' is enabled.
# Fixed TNT damaging players or entities when the 'Explosion Damage' setting is set to false.
# Fixed scoreboard glitching when deleting an island.
# Fixed TNT damage destroying hanging entities.
# Change the 'ArmorStandPlacement' setting to 'EntityPlacement'.
# Removed the check that prevents the main spawn point being set in an island world. Keep in mind this will cause issues if the island you have set the main spawn point at doesn't exist.
This commit is contained in:
SystemEncryption 2018-12-14 21:03:31 +00:00
parent 809520c861
commit 91f8f5cec5
32 changed files with 897 additions and 329 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>SkyBlock</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>46</version>
<version>48</version>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>

View File

@ -194,7 +194,7 @@ public class SkyBlockAPI {
*/
public static void removeUpgrades(Player player) {
Preconditions.checkArgument(player != null, "Cannot remove upgrades to null player");
implementation.getIslandManager().removeUpgrades(player);
implementation.getIslandManager().removeUpgrades(player, false);
}
/**

View File

@ -416,6 +416,28 @@ public class Island {
this.handle.setMessage(APIUtil.toImplementation(message), author, messageLines);
}
/**
* Set the Structure for the Island
*/
public void setStructure(String structure) {
Preconditions.checkArgument(structure != null, "Cannot set structure to null structure");
this.handle.setStructure(structure);
}
/**
* @return true of conditions met, false otherwise
*/
public boolean hasStructure() {
return this.handle.hasStructure();
}
/**
* @return The Structure name for the Island
*/
public String getStructure() {
return this.handle.getStructure();
}
/**
* @return The Visit implementation for the Island
*/

View File

@ -12,9 +12,13 @@ public interface Structure {
public void setMaterials(Materials materials);
public String getFile();
public String getOverworldFile();
public void setFile(String file);
public String getNetherFile();
public void setOverworldFile(String file);
public void setNetherFile(String file);
public String getDisplayname();
@ -31,4 +35,10 @@ public interface Structure {
public void addLine(String line);
public void removeLine(int index);
public List<String> getCommands();
public void addCommand(String command);
public void removeCommand(int index);
}

View File

@ -1,8 +1,6 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
@ -117,62 +115,65 @@ public class ConfirmCommand extends SubCommand {
playerData.setConfirmation(null);
playerData.setConfirmationTime(0);
} else if (confirmation == Confirmation.Deletion) {
playerData.setConfirmation(null);
playerData.setConfirmationTime(0);
if (island.isOpen()) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Confirmation.Deletion.Open.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
playerData.setConfirmation(null);
playerData.setConfirmationTime(0);
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Confirmation.Confirmed.Message"));
islandManager.deleteIsland(island);
boolean hasSpawnPoint = skyblock.getFileManager()
.getConfig(new File(skyblock.getDataFolder(), "locations.yml"))
.getFileConfiguration().getString("Location.Spawn") != null;
List<UUID> islandMembers = new ArrayList<>();
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Confirmation.Confirmed.Message"));
for (Player all : Bukkit.getOnlinePlayers()) {
if (island.hasRole(IslandRole.Member, all.getUniqueId())
|| island.hasRole(IslandRole.Operator, all.getUniqueId())
|| island.hasRole(IslandRole.Owner, all.getUniqueId())) {
if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Scoreboard.Tutorial.Displayname")));
scoreboard.setDisplayList(
configLoad.getStringList("Scoreboard.Tutorial.Displaylines"));
scoreboard.run();
}
boolean hasSpawnPoint = skyblock.getFileManager()
.getConfig(new File(skyblock.getDataFolder(), "locations.yml"))
.getFileConfiguration().getString("Location.Spawn") != null;
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(all.getLocation(),
island.getLocation(worldList, Location.Environment.Island),
island.getRadius())) {
if (hasSpawnPoint) {
LocationUtil.teleportPlayerToSpawn(all);
} else {
Bukkit.getServer().getLogger().log(Level.WARNING,
"SkyBlock | Error: A spawn point hasn't been set.");
for (Player all : Bukkit.getOnlinePlayers()) {
if (island.hasRole(IslandRole.Member, all.getUniqueId())
|| island.hasRole(IslandRole.Operator, all.getUniqueId())
|| island.hasRole(IslandRole.Owner, all.getUniqueId())) {
if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Scoreboard.Tutorial.Displayname")));
scoreboard.setDisplayList(
configLoad.getStringList("Scoreboard.Tutorial.Displaylines"));
scoreboard.run();
}
for (Location.World worldList : Location.World.values()) {
if (LocationUtil.isLocationAtLocationRadius(all.getLocation(),
island.getLocation(worldList, Location.Environment.Island),
island.getRadius())) {
if (hasSpawnPoint) {
LocationUtil.teleportPlayerToSpawn(all);
} else {
Bukkit.getServer().getLogger().log(Level.WARNING,
"SkyBlock | Error: A spawn point hasn't been set.");
}
break;
}
}
break;
if (!island.hasRole(IslandRole.Owner, all.getUniqueId())) {
all.sendMessage(ChatColor.translateAlternateColorCodes('&',
configLoad.getString(
"Command.Island.Confirmation.Deletion.Broadcast.Message")));
soundManager.playSound(all, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
}
}
if (!island.hasRole(IslandRole.Owner, all.getUniqueId())) {
all.sendMessage(
ChatColor.translateAlternateColorCodes('&', configLoad.getString(
"Command.Island.Confirmation.Deletion.Broadcast.Message")));
soundManager.playSound(all, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
}
islandMembers.add(all.getUniqueId());
}
messageManager.sendMessage(player, configLoad
.getString("Command.Island.Confirmation.Deletion.Sender.Message"));
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
}
islandManager.deleteIsland(island);
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Confirmation.Deletion.Sender.Message"));
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
}
} else {
messageManager.sendMessage(player,

View File

@ -60,9 +60,19 @@ public class CreateCommand extends SubCommand {
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
} else if (!fileManager.isFileExist(new File(
new File(skyblock.getDataFolder().toString() + "/structures"), structures.get(0).getFile()))) {
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.File.Message"));
} else if (!fileManager
.isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"),
structures.get(0).getOverworldFile()))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Creator.Selector.File.Overworld.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
} else if (!fileManager
.isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"),
structures.get(0).getNetherFile()))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Creator.Selector.File.Nether.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;

View File

@ -129,7 +129,6 @@ public class SetSpawnCommand extends SubCommand {
islandManager.removeSpawnProtection(
island.getLocation(worldList, locationEnvironment));
islandManager.setSpawnProtection(location);
}
}.runTask(skyblock);
} else {

View File

@ -74,7 +74,7 @@ public class UpgradeCommand extends SubCommand {
@Override
public String[] getAliases() {
return new String[0];
return new String[] { "upgrades" };
}
@Override

View File

@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import org.bukkit.World;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@ -13,7 +12,6 @@ import me.goodandevil.skyblock.command.SubCommand;
import me.goodandevil.skyblock.command.CommandManager.Type;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.island.Location;
import me.goodandevil.skyblock.message.MessageManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.version.Sounds;
@ -38,18 +36,6 @@ public class SetSpawnCommand extends SubCommand {
if (player.hasPermission("skyblock.admin.setspawn") || player.hasPermission("skyblock.admin.*")
|| player.hasPermission("skyblock.*")) {
for (Location.World worldList : Location.World.values()) {
World world = skyblock.getWorldManager().getWorld(worldList);
if (world.getName().equals(player.getWorld().getName())) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Admin.SetSpawn.World.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
}
fileManager.setLocation(fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")),
"Location.Spawn", player.getLocation(), true);
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSpawn.Set.Message"));

View File

@ -179,6 +179,14 @@ public class Island {
islandSettings.put(roleList, settings);
}
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
@Override
public void run() {
islandManager.removeSpawnProtection(islandNormalLocation);
islandManager.removeSpawnProtection(islandNetherLocation);
}
});
} else {
islandLocations.add(new Location(Location.World.Normal, Location.Environment.Main,
islandNormalLocation.clone().add(0.5D, 0.0D, 0.5D)));
@ -237,8 +245,6 @@ public class Island {
@Override
public void run() {
islandNormalLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE);
islandManager.setSpawnProtection(islandNormalLocation);
islandManager.setSpawnProtection(islandNetherLocation);
}
});
}

View File

@ -47,7 +47,6 @@ import me.goodandevil.skyblock.upgrade.Upgrade;
import me.goodandevil.skyblock.upgrade.UpgradeManager;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.structure.StructureUtil;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.NMSUtil;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
@ -156,13 +155,21 @@ public class IslandManager {
Island island = new Island(player.getUniqueId(), prepareNextAvailableLocation(Location.World.Normal),
prepareNextAvailableLocation(Location.World.Nether));
island.setStructure(structure.getName());
islandStorage.put(player.getUniqueId(), island);
try {
File structureFile = new File(new File(skyblock.getDataFolder().toString() + "/structures"),
structure.getFile());
for (World worldList : World.values()) {
File structureFile;
if (worldList == World.Normal) {
structureFile = new File(new File(skyblock.getDataFolder().toString() + "/structures"),
structure.getOverworldFile());
} else {
structureFile = new File(new File(skyblock.getDataFolder().toString() + "/structures"),
structure.getNetherFile());
}
Float[] direction = StructureUtil.pasteStructure(StructureUtil.loadStructure(structureFile),
island.getLocation(worldList, Location.Environment.Island), BlockDegreesType.ROTATE_360);
org.bukkit.Location spawnLocation = island.getLocation(worldList, Location.Environment.Main).clone();
@ -237,28 +244,10 @@ public class IslandManager {
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
@Override
public void run() {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Island.Creation.Commands.Player") != null) {
List<String> commands = configLoad.getStringList("Island.Creation.Commands.Player");
if (commands != null) {
for (String commandList : commands) {
Bukkit.getServer().dispatchCommand(player,
commandList.replace("%player", player.getName()));
}
}
}
if (configLoad.getString("Island.Creation.Commands.Console") != null) {
List<String> commands = configLoad.getStringList("Island.Creation.Commands.Console");
if (commands != null) {
for (String commandList : commands) {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),
commandList.replace("%player", player.getName()));
}
if (structure.getCommands() != null) {
for (String commandList : structure.getCommands()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
commandList.replace("%player", player.getName()));
}
}
@ -861,12 +850,6 @@ public class IslandManager {
return false;
}
public void setSpawnProtection(org.bukkit.Location location) {
location.getBlock().setType(Materials.LEGACY_PISTON_MOVING_PIECE.getPostMaterial());
location.clone().add(0.0D, 1.0D, 0.0D).getBlock()
.setType(Materials.LEGACY_PISTON_MOVING_PIECE.getPostMaterial());
}
public void removeSpawnProtection(org.bukkit.Location location) {
location.getBlock().setType(Material.AIR);
location.clone().add(0.0D, 1.0D, 0.0D).getBlock().setType(Material.AIR);
@ -1024,10 +1007,10 @@ public class IslandManager {
}
}
public void removeUpgrades(Player player) {
public void removeUpgrades(Player player, boolean bypassIsland) {
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
if (playerDataManager.hasPlayerData(player)) {
if (!bypassIsland && playerDataManager.hasPlayerData(player)) {
PlayerData playerData = playerDataManager.getPlayerData(player);
if (playerData.getIsland() != null) {

View File

@ -92,13 +92,8 @@ public class Block implements Listener {
}
if (LocationUtil.isLocationLocation(event.getBlock().getLocation(),
island.getLocation(worldList, Location.Environment.Main))
|| LocationUtil.isLocationLocation(event.getBlock().getLocation(),
island.getLocation(worldList, Location.Environment.Main).clone().add(0.0D,
1.0D, 0.0D))
|| LocationUtil.isLocationLocation(event.getBlock().getLocation(),
island.getLocation(worldList, Location.Environment.Main).clone()
.subtract(0.0D, 1.0D, 0.0D))) {
island.getLocation(worldList, Location.Environment.Main).clone().subtract(0.0D,
1.0D, 0.0D))) {
if (skyblock.getFileManager()
.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Spawn.Protection")) {

View File

@ -7,9 +7,11 @@ import java.util.UUID;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
@ -19,6 +21,10 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityChangeBlockEvent;
@ -181,22 +187,31 @@ public class Entity implements Listener {
}
}
}
} else {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
} else if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (player.getWorld().getName()
.equals(skyblock.getWorldManager().getWorld(Location.World.Normal).getName())
|| player.getWorld().getName()
.equals(skyblock.getWorldManager().getWorld(Location.World.Nether).getName())) {
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Settings.Damage.Enable")) {
if (!skyblock.getIslandManager().hasSetting(player.getLocation(), IslandRole.Owner, "Damage")) {
event.setCancelled(true);
}
} else {
if (player.getWorld().getName().equals(skyblock.getWorldManager().getWorld(Location.World.Normal).getName())
|| player.getWorld().getName()
.equals(skyblock.getWorldManager().getWorld(Location.World.Nether).getName())) {
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Settings.Damage.Enable")) {
if (!skyblock.getIslandManager().hasSetting(player.getLocation(), IslandRole.Owner, "Damage")
|| (event.getDamager() instanceof TNTPrimed && !skyblock.getIslandManager()
.hasSetting(event.getEntity().getLocation(), IslandRole.Owner, "Explosions"))) {
event.setCancelled(true);
}
} else {
event.setCancelled(true);
}
}
} else if (event.getDamager() instanceof TNTPrimed) {
if (event.getEntity().getWorld().getName()
.equals(skyblock.getWorldManager().getWorld(Location.World.Normal).getName())
|| event.getEntity().getWorld().getName()
.equals(skyblock.getWorldManager().getWorld(Location.World.Nether).getName())) {
if (!skyblock.getIslandManager().hasSetting(event.getEntity().getLocation(), IslandRole.Owner,
"Explosions")) {
event.setCancelled(true);
}
}
}
@ -220,6 +235,64 @@ public class Entity implements Listener {
}
}
@EventHandler
public void onHangingPlace(HangingPlaceEvent event) {
Player player = event.getPlayer();
if (player.getWorld().getName().equals(skyblock.getWorldManager().getWorld(Location.World.Normal).getName())
|| player.getWorld().getName()
.equals(skyblock.getWorldManager().getWorld(Location.World.Nether).getName())) {
if (!skyblock.getIslandManager().hasPermission(player, "EntityPlacement")) {
event.setCancelled(true);
skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
}
@EventHandler
public void onHangingBreak(HangingBreakEvent event) {
Hanging hanging = event.getEntity();
if (hanging.getWorld().getName().equals(skyblock.getWorldManager().getWorld(Location.World.Normal).getName())
|| hanging.getWorld().getName()
.equals(skyblock.getWorldManager().getWorld(Location.World.Nether).getName())) {
if (event.getCause() == RemoveCause.EXPLOSION) {
if (!skyblock.getIslandManager().hasSetting(event.getEntity().getLocation(), IslandRole.Owner,
"Explosions")) {
event.setCancelled(true);
}
}
}
}
@EventHandler
public void onHangingBreak(HangingBreakByEntityEvent event) {
Hanging hanging = event.getEntity();
if (!(event.getRemover() instanceof Player)) {
return;
}
Player player = (Player) event.getRemover();
if (hanging.getWorld().getName().equals(skyblock.getWorldManager().getWorld(Location.World.Normal).getName())
|| hanging.getWorld().getName()
.equals(skyblock.getWorldManager().getWorld(Location.World.Nether).getName())) {
if (!skyblock.getIslandManager().hasPermission(player, "HangingDestroy")) {
event.setCancelled(true);
skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
}
@EventHandler
public void onEntityTaming(EntityTameEvent event) {
if (!(event.getOwner() instanceof Player)) {

View File

@ -410,7 +410,7 @@ public class Interact implements Listener {
player.updateInventory();
}
} else if (event.getItem().getType() == Material.ARMOR_STAND) {
if (!islandManager.hasPermission(player, "ArmorStandPlacement")) {
if (!islandManager.hasPermission(player, "EntityPlacement")) {
event.setCancelled(true);
messageManager.sendMessage(player,

View File

@ -178,14 +178,18 @@ public class Move implements Listener {
player.setFallDistance(0.0F);
if (island.getVisit().isVisitor(player.getUniqueId())) {
player.teleport(island.getLocation(
me.goodandevil.skyblock.island.Location.World.Normal,
me.goodandevil.skyblock.island.Location.Environment.Visitor));
if (configLoad.getBoolean("Island.Void.Teleport.Island")) {
if (island.getVisit().isVisitor(player.getUniqueId())) {
player.teleport(island.getLocation(
me.goodandevil.skyblock.island.Location.World.Normal,
me.goodandevil.skyblock.island.Location.Environment.Visitor));
} else {
player.teleport(island.getLocation(
me.goodandevil.skyblock.island.Location.World.Normal,
me.goodandevil.skyblock.island.Location.Environment.Main));
}
} else {
player.teleport(island.getLocation(
me.goodandevil.skyblock.island.Location.World.Normal,
me.goodandevil.skyblock.island.Location.Environment.Main));
LocationUtil.teleportPlayerToSpawn(player);
}
player.setFallDistance(0.0F);

View File

@ -3,6 +3,10 @@ package me.goodandevil.skyblock.listeners;
import java.io.File;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -10,11 +14,13 @@ import org.bukkit.event.entity.EntityPortalEnterEvent;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.config.FileManager;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.Location;
import me.goodandevil.skyblock.message.MessageManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.utils.version.Materials;
import me.goodandevil.skyblock.utils.version.Sounds;
import me.goodandevil.skyblock.utils.world.LocationUtil;
@ -43,13 +49,45 @@ public class Portal implements Listener {
for (UUID islandList : islandManager.getIslands().keySet()) {
Island island = islandManager.getIslands().get(islandList);
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(),
island.getLocation(Location.World.Normal, Location.Environment.Island), island.getRadius())) {
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.World.Nether.Enable")
if (configLoad.getBoolean("Island.World.Nether.Enable")
&& islandManager.hasPermission(player, "Portal")) {
player.teleport(island.getLocation(Location.World.Nether, Location.Environment.Main));
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
if (configLoad.getBoolean("Island.Portal.Island")) {
player.teleport(island.getLocation(Location.World.Nether, Location.Environment.Main));
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
} else if (event.getLocation().getBlock().getType() == Materials.NETHER_PORTAL.parseMaterial()
&& Bukkit.getServer().getAllowNether()) {
for (World worldList : Bukkit.getServer().getWorlds()) {
if (worldList.getEnvironment() == Environment.NETHER) {
player.teleport(LocationUtil.getRandomLocation(worldList, 5000, 5000, true, true));
break;
}
}
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
} else if (event.getLocation().getBlock().getType() == Materials.END_PORTAL.parseMaterial()
&& Bukkit.getServer().getAllowEnd()) {
for (World worldList : Bukkit.getServer().getWorlds()) {
if (worldList.getEnvironment() == Environment.THE_END) {
player.teleport(worldList.getSpawnLocation());
break;
}
}
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
} else {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main));
messageManager.sendMessage(player,
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Portal.Destination.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main));
messageManager.sendMessage(player,
@ -68,13 +106,45 @@ public class Portal implements Listener {
for (UUID islandList : islandManager.getIslands().keySet()) {
Island island = islandManager.getIslands().get(islandList);
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(),
island.getLocation(Location.World.Nether, Location.Environment.Island), island.getRadius())) {
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.World.Nether.Enable")
if (configLoad.getBoolean("Island.World.Nether.Enable")
&& islandManager.hasPermission(player, "Portal")) {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main));
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
if (configLoad.getBoolean("Island.Portal.Island")) {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main));
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
} else if (event.getLocation().getBlock().getType() == Materials.NETHER_PORTAL.parseMaterial()
&& Bukkit.getServer().getAllowNether()) {
for (World worldList : Bukkit.getServer().getWorlds()) {
if (worldList.getEnvironment() == Environment.NETHER) {
player.teleport(LocationUtil.getRandomLocation(worldList, 5000, 5000, true, true));
break;
}
}
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
} else if (event.getLocation().getBlock().getType() == Materials.END_PORTAL.parseMaterial()
&& Bukkit.getServer().getAllowEnd()) {
for (World worldList : Bukkit.getServer().getWorlds()) {
if (worldList.getEnvironment() == Environment.THE_END) {
player.teleport(worldList.getSpawnLocation());
break;
}
}
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
} else {
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main));
messageManager.sendMessage(player,
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Portal.Destination.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
player.teleport(island.getLocation(Location.World.Nether, Location.Environment.Main));
messageManager.sendMessage(player,

View File

@ -85,10 +85,10 @@ public class Respawn implements Listener {
"SkyBlock | Error: A spawn point hasn't been set.");
} else {
Location playerLocation = player.getLocation().clone(),
islandLocation = fileManager.getLocation(config, "Location.Spawn", true);
spawnLocation = fileManager.getLocation(config, "Location.Spawn", true);
Bukkit.getServer().getPluginManager()
.callEvent(new PlayerTeleportEvent(player, playerLocation, islandLocation));
event.setRespawnLocation(islandLocation);
.callEvent(new PlayerTeleportEvent(player, playerLocation, spawnLocation));
event.setRespawnLocation(spawnLocation);
}
break;

View File

@ -48,7 +48,7 @@ public class Teleport implements Listener {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
islandManager.removeUpgrades(player);
islandManager.removeUpgrades(player, false);
islandManager.loadPlayer(player);
if (player.getWorld().getName().equals(skyblock.getWorldManager().getWorld(Location.World.Normal).getName())

View File

@ -53,7 +53,8 @@ public class Creator {
for (Structure structureList : skyblock.getStructureManager().getStructures()) {
if (structureList.getDisplayname() == null || structureList.getDisplayname().isEmpty()
|| structureList.getFile() == null || structureList.getFile().isEmpty()) {
|| structureList.getOverworldFile() == null || structureList.getOverworldFile().isEmpty()
|| structureList.getNetherFile() == null || structureList.getNetherFile().isEmpty()) {
continue;
}
@ -133,9 +134,20 @@ public class Creator {
if (!fileManager.isFileExist(
new File(new File(skyblock.getDataFolder().toString() + "/structures"),
structureList.getFile()))) {
structureList.getOverworldFile()))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Creator.Selector.File.Message"));
configLoad.getString("Island.Creator.Selector.File.Overworld.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
return;
} else if (!fileManager.isFileExist(
new File(new File(skyblock.getDataFolder().toString() + "/structures"),
structureList.getNetherFile()))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Creator.Selector.File.Nether.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
event.setWillClose(false);

View File

@ -244,6 +244,8 @@ public class Leaderboard {
nInv.addItem(nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]),
configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Displayname")
.replace("%owner",
playerName)
.replace("%position", "" + (leaderboard.getPosition() + 1)),
itemLore,
nInv.createItemLoreVariable(new String[] { "%position#" + (leaderboard.getPosition() + 1),

View File

@ -519,16 +519,18 @@ public class Settings {
nInv.addItemStack(createItem(island, role, "DropperDispenser", new ItemStack(Material.DISPENSER)),
43);
nInv.addItemStack(createItem(island, role, "SpawnEgg", new ItemStack(Material.EGG)), 44);
nInv.addItemStack(createItem(island, role, "HangingDestroy", new ItemStack(Material.ITEM_FRAME)),
45);
nInv.addItemStack(createItem(island, role, "Cake", new ItemStack(Material.CAKE)), 46);
nInv.addItemStack(createItem(island, role, "DragonEggUse", new ItemStack(Material.DRAGON_EGG)), 47);
nInv.addItemStack(createItem(island, role, "MinecartBoat", new ItemStack(Material.MINECART)), 48);
nInv.addItemStack(createItem(island, role, "Portal", new ItemStack(Material.ENDER_PEARL)), 49);
nInv.addItemStack(createItem(island, role, "Hopper", new ItemStack(Material.HOPPER)), 50);
nInv.addItemStack(
createItem(island, role, "ArmorStandPlacement", new ItemStack(Material.ARMOR_STAND)), 51);
nInv.addItemStack(createItem(island, role, "Portal", new ItemStack(Material.ENDER_PEARL)), 50);
nInv.addItemStack(createItem(island, role, "Hopper", new ItemStack(Material.HOPPER)), 51);
nInv.addItemStack(createItem(island, role, "EntityPlacement", new ItemStack(Material.ARMOR_STAND)),
52);
nInv.addItemStack(
createItem(island, role, "ExperienceOrbPickup", Materials.EXPERIENCE_BOTTLE.parseItem()),
52);
53);
nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Settings." + role.name() + ".Title")));

View File

@ -134,7 +134,7 @@ public class Creator implements Listener {
configLoad.getString("Menu.Admin.Creator.Options.Item.Displayname.Displayname"),
configLoad.getStringList("Menu.Admin.Creator.Options.Item.Displayname.Lore"),
nInv.createItemLoreVariable(new String[] { "%displayname#" + displayName }), null, null),
2);
1);
List<String> descriptionLore = new ArrayList<>();
@ -160,9 +160,36 @@ public class Creator implements Listener {
}
}
nInv.addItem(nInv.createItem(new ItemStack(Material.BOOK),
nInv.addItem(nInv.createItem(new ItemStack(Material.ENCHANTED_BOOK),
configLoad.getString("Menu.Admin.Creator.Options.Item.Description.Displayname"), descriptionLore,
null, null, null), 3);
null, null, null), 2);
List<String> commandsLore = new ArrayList<>();
if (structure.getCommands() == null || structure.getCommands().size() == 0) {
for (String itemLore : configLoad
.getStringList("Menu.Admin.Creator.Options.Item.Commands.Unset.Lore")) {
if (itemLore.contains("%commands")) {
commandsLore.add(configLoad.getString("Menu.Admin.Creator.Options.Item.Word.Unset"));
} else {
commandsLore.add(itemLore);
}
}
} else {
for (String itemLore : configLoad.getStringList("Menu.Admin.Creator.Options.Item.Commands.Set.Lore")) {
if (itemLore.contains("%commands")) {
for (String commandList : structure.getCommands()) {
commandsLore.add(commandList);
}
} else {
commandsLore.add(itemLore);
}
}
}
nInv.addItem(nInv.createItem(new ItemStack(Material.BOOK),
configLoad.getString("Menu.Admin.Creator.Options.Item.Commands.Displayname"), commandsLore, null,
null, null), 3);
List<String> permissionLore = new ArrayList<>();
@ -178,16 +205,27 @@ public class Creator implements Listener {
null), 4);
String fileName = ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Creator.Options.Item.Word.Unset"));
configLoad.getString("Menu.Admin.Creator.Options.Item.Word.Unset")), overworldFileName,
netherFileName;
if (structure.getFile() != null && !structure.getFile().isEmpty()) {
fileName = ChatColor.translateAlternateColorCodes('&', structure.getFile());
if (structure.getOverworldFile() != null && !structure.getOverworldFile().isEmpty()) {
overworldFileName = structure.getOverworldFile();
} else {
overworldFileName = fileName;
}
if (structure.getNetherFile() != null && !structure.getNetherFile().isEmpty()) {
netherFileName = structure.getNetherFile();
} else {
netherFileName = fileName;
}
nInv.addItem(nInv.createItem(new ItemStack(Material.PAPER),
configLoad.getString("Menu.Admin.Creator.Options.Item.File.Displayname"),
configLoad.getStringList("Menu.Admin.Creator.Options.Item.File.Lore"),
nInv.createItemLoreVariable(new String[] { "%file#" + fileName }), null, null), 5);
nInv.createItemLoreVariable(
new String[] { "%overworld_file#" + overworldFileName, "%nether_file#" + netherFileName }),
null, null), 5);
nInv.addItem(nInv.createItem(new ItemStack(Material.DIAMOND),
configLoad.getString("Menu.Admin.Creator.Options.Item.Item.Displayname"),
configLoad.getStringList("Menu.Admin.Creator.Options.Item.Item.Lore"),
@ -291,8 +329,8 @@ public class Creator implements Listener {
configLoad.getString("Island.Admin.Creator.Characters.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
structureManager.addStructure(event1.getName(), Materials.GRASS_BLOCK, null, null,
false, new ArrayList<>());
structureManager.addStructure(event1.getName(), Materials.GRASS_BLOCK, null, null, null,
false, new ArrayList<>(), new ArrayList<>());
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Created.Message")
@ -479,7 +517,7 @@ public class Creator implements Listener {
}
return;
} else if ((event.getCurrentItem().getType() == Material.BOOK) && (is.hasItemMeta())
} else if ((event.getCurrentItem().getType() == Material.ENCHANTED_BOOK) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Creator.Options.Item.Description.Displayname"))))) {
if (playerData.getViewer() == null) {
@ -648,6 +686,176 @@ public class Creator implements Listener {
}
}
return;
} else if ((event.getCurrentItem().getType() == Material.BOOK) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Creator.Options.Item.Commands.Displayname"))))) {
if (playerData.getViewer() == null) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Selected.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
} else {
String name = ((Creator.Viewer) playerData.getViewer()).getName();
if (structureManager.containsStructure(name)) {
Structure structure = structureManager.getStructure(name);
if (structure.getCommands() != null && !structure.getCommands().isEmpty()) {
if (event.getClick() == ClickType.RIGHT) {
structure.removeCommand(structure.getCommands().size() - 1);
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, new Runnable() {
@Override
public void run() {
Config config = fileManager
.getConfig(new File(skyblock.getDataFolder(), "structures.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Structures." + structure.getName() + ".Commands",
structure.getCommands());
try {
configLoad.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
});
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
return;
} else if (event.getClick() != ClickType.LEFT) {
return;
}
}
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
AnvilGUI gui = new AnvilGUI(player, event1 -> {
if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
if (!(player.hasPermission("skyblock.admin.creator")
|| player.hasPermission("skyblock.admin.*")
|| player.hasPermission("skyblock.*"))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Permission.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (playerData.getViewer() == null) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Selected.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
} else if (!structureManager.containsStructure(name)) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Exist.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
} else {
structure.addCommand(event1.getName());
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
Config config = fileManager.getConfig(
new File(skyblock.getDataFolder(), "structures.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set(
"Structures." + structure.getName() + ".Commands",
structure.getCommands());
try {
configLoad.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
});
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
}
event1.setWillClose(true);
event1.setWillDestroy(true);
} else {
event1.setWillClose(false);
event1.setWillDestroy(false);
}
});
is = new ItemStack(Material.NAME_TAG);
ItemMeta im = is.getItemMeta();
im.setDisplayName(
configLoad.getString("Menu.Admin.Creator.Options.Item.Commands.Word.Enter"));
is.setItemMeta(im);
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, is);
gui.open();
} else {
playerData.setViewer(null);
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Exist.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
}
}
return;
} else if ((event.getCurrentItem().getType() == Materials.LEGACY_EMPTY_MAP.getPostMaterial())
&& (is.hasItemMeta())
@ -728,127 +936,10 @@ public class Creator implements Listener {
} else if ((event.getCurrentItem().getType() == Material.PAPER) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Creator.Options.Item.File.Displayname"))))) {
if (playerData.getViewer() == null) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Selected.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
} else {
String name = ((Creator.Viewer) playerData.getViewer()).getName();
if (structureManager.containsStructure(name)) {
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
AnvilGUI gui = new AnvilGUI(player, event1 -> {
if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
if (!(player.hasPermission("skyblock.admin.creator")
|| player.hasPermission("skyblock.admin.*")
|| player.hasPermission("skyblock.*"))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Permission.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (playerData.getViewer() == null) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Selected.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
} else if (!structureManager.containsStructure(name)) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Exist.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
} else {
if (fileManager.isFileExist(
new File(skyblock.getDataFolder().toString() + "/structures",
event1.getName()))) {
Structure structure = structureManager.getStructure(name);
structure.setFile(event1.getName());
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
Config config = fileManager.getConfig(new File(
skyblock.getDataFolder(), "structures.yml"));
FileConfiguration configLoad = config
.getFileConfiguration();
configLoad.set(
"Structures." + structure.getName() + ".File",
event1.getName());
try {
configLoad.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
});
} else {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.File.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
}
event1.setWillClose(true);
event1.setWillDestroy(true);
} else {
event1.setWillClose(false);
event1.setWillDestroy(false);
}
});
is = new ItemStack(Material.NAME_TAG);
ItemMeta im = is.getItemMeta();
im.setDisplayName(configLoad.getString("Menu.Admin.Creator.Options.Item.File.Word.Enter"));
is.setItemMeta(im);
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, is);
gui.open();
} else {
playerData.setViewer(null);
if (event.getClick() == ClickType.LEFT || event.getClick() == ClickType.RIGHT) {
if (playerData.getViewer() == null) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Exist.Message"));
configLoad.getString("Island.Admin.Creator.Selected.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
@ -859,6 +950,159 @@ public class Creator implements Listener {
open(player);
}
}, 1L);
} else {
String name = ((Creator.Viewer) playerData.getViewer()).getName();
if (structureManager.containsStructure(name)) {
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
AnvilGUI gui = new AnvilGUI(player, event1 -> {
if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
if (!(player.hasPermission("skyblock.admin.creator")
|| player.hasPermission("skyblock.admin.*")
|| player.hasPermission("skyblock.*"))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Permission.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else if (playerData.getViewer() == null) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Selected.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
} else if (!structureManager.containsStructure(name)) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Exist.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
} else {
if (fileManager.isFileExist(
new File(skyblock.getDataFolder().toString() + "/structures",
event1.getName()))) {
if (event.getClick() == ClickType.LEFT) {
Structure structure = structureManager.getStructure(name);
structure.setOverworldFile(event1.getName());
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(),
1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
Config config = fileManager.getConfig(
new File(skyblock.getDataFolder(),
"structures.yml"));
FileConfiguration configLoad = config
.getFileConfiguration();
configLoad.set(
"Structures." + structure.getName()
+ ".File.Overworld",
event1.getName());
try {
configLoad.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
});
} else {
Structure structure = structureManager.getStructure(name);
structure.setNetherFile(event1.getName());
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(),
1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
Config config = fileManager.getConfig(
new File(skyblock.getDataFolder(),
"structures.yml"));
FileConfiguration configLoad = config
.getFileConfiguration();
configLoad.set("Structures." + structure.getName()
+ ".File.Nether", event1.getName());
try {
configLoad.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
} else {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.File.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F,
1.0F);
}
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock,
new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
}
event1.setWillClose(true);
event1.setWillDestroy(true);
} else {
event1.setWillClose(false);
event1.setWillDestroy(false);
}
});
is = new ItemStack(Material.NAME_TAG);
ItemMeta im = is.getItemMeta();
im.setDisplayName(
configLoad.getString("Menu.Admin.Creator.Options.Item.File.Word.Enter"));
is.setItemMeta(im);
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, is);
gui.open();
} else {
playerData.setViewer(null);
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Exist.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
@Override
public void run() {
open(player);
}
}, 1L);
}
}
}

View File

@ -295,13 +295,14 @@ public class Settings {
nInv.addItemStack(createItem(role, "Fishing", new ItemStack(Material.FISHING_ROD)), 42);
nInv.addItemStack(createItem(role, "DropperDispenser", new ItemStack(Material.DISPENSER)), 43);
nInv.addItemStack(createItem(role, "SpawnEgg", new ItemStack(Material.EGG)), 44);
nInv.addItemStack(createItem(role, "HangingDestroy", new ItemStack(Material.ITEM_FRAME)), 45);
nInv.addItemStack(createItem(role, "Cake", new ItemStack(Material.CAKE)), 46);
nInv.addItemStack(createItem(role, "DragonEggUse", new ItemStack(Material.DRAGON_EGG)), 47);
nInv.addItemStack(createItem(role, "MinecartBoat", new ItemStack(Material.MINECART)), 48);
nInv.addItemStack(createItem(role, "Portal", new ItemStack(Material.ENDER_PEARL)), 49);
nInv.addItemStack(createItem(role, "Hopper", new ItemStack(Material.HOPPER)), 50);
nInv.addItemStack(createItem(role, "ArmorStandPlacement", new ItemStack(Material.ARMOR_STAND)), 51);
nInv.addItemStack(createItem(role, "ExperienceOrbPickup", Materials.EXPERIENCE_BOTTLE.parseItem()), 52);
nInv.addItemStack(createItem(role, "Portal", new ItemStack(Material.ENDER_PEARL)), 50);
nInv.addItemStack(createItem(role, "Hopper", new ItemStack(Material.HOPPER)), 51);
nInv.addItemStack(createItem(role, "EntityPlacement", new ItemStack(Material.ARMOR_STAND)), 52);
nInv.addItemStack(createItem(role, "ExperienceOrbPickup", Materials.EXPERIENCE_BOTTLE.parseItem()), 53);
nInv.setRows(6);
} else if (role == me.goodandevil.skyblock.island.IslandRole.Operator) {

View File

@ -161,13 +161,13 @@ public class ScoreboardManager {
}
public void unloadPlayer(Player player) {
if (hasScoreboard(player)) {
if (scoreboardStorage.containsKey(player.getUniqueId())) {
scoreboardStorage.remove(player.getUniqueId());
}
}
public Scoreboard getScoreboard(Player player) {
if (hasScoreboard(player)) {
if (scoreboardStorage.containsKey(player.getUniqueId())) {
return scoreboardStorage.get(player.getUniqueId());
}

View File

@ -10,21 +10,25 @@ public class Structure implements me.goodandevil.skyblock.api.structure.Structur
private Materials materials;
private String name;
private String file;
private String overworldFile;
private String netherFile;
private String displayName;
private boolean permission;
private List<String> description = new ArrayList<>();
private List<String> commands = new ArrayList<>();
public Structure(String name, Materials materials, String file, String displayName, boolean permission,
List<String> description) {
public Structure(String name, Materials materials, String overworldFile, String netherFile, String displayName,
boolean permission, List<String> description, List<String> commands) {
this.name = name;
this.materials = materials;
this.file = file;
this.overworldFile = overworldFile;
this.netherFile = netherFile;
this.displayName = displayName;
this.permission = permission;
this.description = description;
this.commands = commands;
}
public String getName() {
@ -39,12 +43,20 @@ public class Structure implements me.goodandevil.skyblock.api.structure.Structur
this.materials = materials;
}
public String getFile() {
return file;
public String getOverworldFile() {
return overworldFile;
}
public void setFile(String file) {
this.file = file;
public void setOverworldFile(String file) {
this.overworldFile = file;
}
public String getNetherFile() {
return netherFile;
}
public void setNetherFile(String file) {
this.netherFile = file;
}
public String getDisplayname() {
@ -78,4 +90,16 @@ public class Structure implements me.goodandevil.skyblock.api.structure.Structur
public void removeLine(int index) {
description.remove(index);
}
public List<String> getCommands() {
return commands;
}
public void addCommand(String command) {
commands.add(command);
}
public void removeCommand(int index) {
commands.remove(index);
}
}

View File

@ -33,18 +33,46 @@ public class StructureManager {
}
}
String structureFile = null, overworldFile = null, netherFile = null;
if (configLoad.getString("Structures." + structureList + ".File.Overworld") == null
&& configLoad.getString("Structures." + structureList + ".File.Nether") == null) {
if (configLoad.getString("Structures." + structureList + ".File") != null) {
structureFile = configLoad.getString("Structures." + structureList + ".File");
overworldFile = structureFile;
netherFile = structureFile;
}
} else {
if (configLoad.getString("Structures." + structureList + ".File.Overworld") != null) {
overworldFile = configLoad.getString("Structures." + structureList + ".File.Overworld");
}
if (configLoad.getString("Structures." + structureList + ".File.Nether") == null
&& overworldFile != null) {
netherFile = overworldFile;
} else {
netherFile = configLoad.getString("Structures." + structureList + ".File.Nether");
}
if (overworldFile == null && netherFile != null) {
overworldFile = netherFile;
}
}
structureStorage.add(new Structure(configLoad.getString("Structures." + structureList + ".Name"),
materials, configLoad.getString("Structures." + structureList + ".File"),
materials, overworldFile, netherFile,
configLoad.getString("Structures." + structureList + ".Displayname"),
configLoad.getBoolean("Structures." + structureList + ".Permission"),
configLoad.getStringList("Structures." + structureList + ".Description")));
configLoad.getStringList("Structures." + structureList + ".Description"),
configLoad.getStringList("Structures." + structureList + ".Commands")));
}
}
}
public void addStructure(String name, Materials materials, String fileName, String displayName, boolean permission,
List<String> description) {
structureStorage.add(new Structure(name, materials, fileName, displayName, permission, description));
public void addStructure(String name, Materials materials, String overworldFile, String netherFile,
String displayName, boolean permission, List<String> description, List<String> commands) {
structureStorage.add(new Structure(name, materials, overworldFile, netherFile, displayName, permission,
description, commands));
}
public void removeStructure(Structure structure) {

View File

@ -3,11 +3,15 @@ package me.goodandevil.skyblock.utils.world;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
@ -203,4 +207,49 @@ public final class LocationUtil {
});
}
}
public static Location getRandomLocation(World world, int xRange, int zRange, boolean loadChunk,
boolean ignoreLiquid) {
Random rnd = new Random();
int rndX = (int) rnd.nextInt(xRange);
int rndZ = (int) rnd.nextInt(zRange);
if (loadChunk) {
Chunk chunk = world.getChunkAt(new Location(world, rndX, 10, rndZ));
world.loadChunk(chunk);
}
double rndY = -1;
if (world.getEnvironment() == Environment.NETHER) {
for (int i = 120; i > 0; i--) {
Location rndLoc = new Location(world, rndX, i, rndZ);
if (rndLoc.getBlock().getType() != Material.AIR
&& rndLoc.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR
&& rndLoc.clone().add(0.0D, 2.0D, 0.0D).getBlock().getType() == Material.AIR
&& rndLoc.clone().add(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.AIR
&& rndLoc.clone().add(0.0D, 4.0D, 0.0D).getBlock().getType() == Material.AIR) {
rndY = i;
break;
}
}
if (rndY == -1) {
return getRandomLocation(world, xRange, zRange, loadChunk, ignoreLiquid);
}
} else {
rndY = world.getHighestBlockYAt(rndX, rndZ);
}
Location rndLoc = new Location(world, rndX, rndY, rndZ);
if (ignoreLiquid && rndLoc.getBlock().isLiquid() || rndLoc.getBlock().getRelative(BlockFace.DOWN).isLiquid()) {
return getRandomLocation(world, xRange, zRange, loadChunk, ignoreLiquid);
} else {
return rndLoc;
}
}
}

View File

@ -32,12 +32,6 @@ Island:
Deletion:
Enable: true
Time: 60
# Commands that are executed either by the player or the console on Island creation.
# [!] To add commands, create a list and remove the open and closed brackets.
# Use the variable %player to get the players name.
Commands:
Player: []
Console: []
World:
# [!] The Island height is 72 blocks.
# Delete the Island world when changing the liquid option.
@ -177,6 +171,8 @@ Island:
Teleport:
# Prevents players from being killed by the Void when at an Island.
Enable: true
# When disabled, players will teleport the the main spawn point rather than the Island.
Island: true
# The Y position that the player is teleported when reached.
Offset: 30
Obsidian:
@ -211,6 +207,11 @@ Island:
# When disabled, the hunger setting will be removed from the Island Settings menu.
Hunger:
Enable: false
Portal:
# When disabled, when a player enters a portal, they will teleport to the nether or
# end world rather than the island world.
# [!] Recommend to keep this enabled to prevent performance drop with chunk loading.
Island: true
Admin:
Structure:
# Item Material used to select positions for a structure.

View File

@ -547,6 +547,8 @@ Command:
Deletion:
Sender:
Message: "&bSkyBlock &8| &aInfo&8: &eYou are no longer an Island owner."
Open:
Message: "&bSkyBlock &8| &cError&8: &eYou must close your island before deleting it."
Broadcast:
Message: "&bSkyBlock &8| &aInfo&8: &eThe Island owner has disbanded the Island."
Confirmed:
@ -721,8 +723,6 @@ Command:
Message: "&f&oSets the spawn point to your location."
Permission:
Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to perform that command."
World:
Message: "&bSkyBlock &8| &cError&8: &eYou cannot set the spawn point in an Island world."
Set:
Message: "&bSkyBlock &8| &aInfo&8: &eThe spawn point has been set to your location."
SetHologram:
@ -846,7 +846,10 @@ Island:
Permission:
Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to use that Structure."
File:
Message: "&bSkyBlock &8| &cError&8: &eThe File for that Structure does not exist."
Overworld:
Message: "&bSkyBlock &8| &cError&8: &eThe structure file for the overworld does not exist."
Nether:
Message: "&bSkyBlock &8| &cError&8: &eThe structure file for the nether does not exist."
Cooldown:
Word:
Minute: "minute(s)"
@ -890,6 +893,9 @@ Island:
Signature:
Disabled:
Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to use that feature."
Portal:
Destination:
Message: "&bSkyBlock &8| &cError&8: &eThere is no destination to travel to going through that portal."
World:
Nether:
Message: "&bSkyBlock &8| &aInfo&8: &eYou have been teleported out of the nether because the nether is disabled."
@ -2108,6 +2114,8 @@ Menu:
Displayname: "&aDropper/Dispenser Use"
SpawnEgg:
Displayname: "&aSpawn Eggs"
HangingDestroy:
Displayname: "&aHanging Destroy"
Cake:
Displayname: "&aCake Consumption"
DragonEggUse:
@ -2118,8 +2126,8 @@ Menu:
Displayname: "&aPortal Use"
Hopper:
Displayname: "&aHopper Use"
ArmorStandPlacement:
Displayname: "&aArmorStand Placement"
EntityPlacement:
Displayname: "&aEntity Placement"
ExperienceOrbPickup:
Displayname: "&aExperience Orb Pickup"
Information:
@ -2745,23 +2753,56 @@ Menu:
Enter: "Enter file name"
Displayname: "&aStructure File"
Lore:
- "&7File&8:"
- "&f&o%file"
- "&7Overworld File&8:"
- "&f&o%overworld_file"
- ""
- "&eClick to set file!"
- "&7Nether File&8:"
- "&f&o%nether_file"
- ""
- "&eLeft-Click to set overworld file!"
- "&eRight-Click to set nether file!"
Item:
Displayname: "&aItem"
Lore:
- "&7Material&8:"
- "&f&o%material"
- ""
- "&7When clicked, select"
- "&7an item in your"
- "&7inventory or click"
- "&7this item again to"
- "&7cancel."
- "&c[!] When clicked,"
- "&cselect an item in"
- "&cyour inventory or"
- "&cclick this item"
- "&cagain to cancel."
- ""
- "&eClick to set item!"
Commands:
Word:
Enter: "Enter command"
Displayname: "&aCommands"
Unset:
Lore:
- "&7Commands&8:"
- "%commands"
- ""
- "&c[!] Commands performed on"
- "&cisland creation by the"
- "&cconsole."
- ""
- "&c[!] Use %player for player name."
- ""
- "&eClick to add a command!"
Set:
Lore:
- "&7Commands&8:"
- "%commands"
- ""
- "&c[!] Commands performed on"
- "&cisland creation by the"
- "&cconsole."
- ""
- "&c[!] Use %player for player name."
- ""
- "&eLeft-Click to add a command!"
- "&eRight-click to remove a command!"
Upgrade:
Upgrades:
Title: "&8Upgrade Editor"
@ -3180,6 +3221,8 @@ Menu:
Displayname: "&aDropper/Dispenser Use"
SpawnEgg:
Displayname: "&aSpawn Eggs"
HangingDestroy:
Displayname: "&aHanging Destroy"
Cake:
Displayname: "&aCake Consumption"
DragonEggUse:
@ -3190,7 +3233,7 @@ Menu:
Displayname: "&aPortal Use"
Hopper:
Displayname: "&aHopper Use"
ArmorStandPlacement:
Displayname: "&aArmorStand Placement"
EntityPlacement:
Displayname: "&aEntity Placement"
ExperienceOrbPickup:
Displayname: "&aExperience Orb Pickup"

View File

@ -1,6 +1,6 @@
name: SkyBlock
main: me.goodandevil.skyblock.SkyBlock
version: 46
version: 48
api-version: 1.13
description: A unique SkyBlock plugin
author: GoodAndEvil

View File

@ -36,12 +36,13 @@ Settings:
Fishing: false
DropperDispenser: false
SpawnEgg: false
HangingDestroy: false
Cake: false
DragonEggUse: false
MinecartBoat: false
Portal: false
Hopper: false
ArmorStandPlacement: false
EntityPlacement: false
ExperienceOrbPickup: false
Member:
Destroy: true
@ -81,11 +82,12 @@ Settings:
DropperDispenser: true
SpawnEgg: true
MinecartBoat: true
HangingDestroy: true
Cake: true
DragonEggUse: true
Portal: true
Hopper: true
ArmorStandPlacement: true
EntityPlacement: true
ExperienceOrbPickup: true
Operator:
Invite: true
@ -140,11 +142,12 @@ Settings:
DropperDispenser: true
SpawnEgg: true
MinecartBoat: true
HangingDestroy: true
Cake: true
DragonEggUse: true
Portal: true
Hopper: true
ArmorStandPlacement: true
EntityPlacement: true
ExperienceOrbPickup: true
Owner:
NaturalMobSpawning: true

View File