# Added the console or player command '/island admin addupgrade' to add an upgrade to a players island.
# Added the console or player command '/island admin removeupgrade' to remove an upgrade from a players island.
# Added the variable '%island_points' for the scoreboard.
# Fixed island-data not saving before transferring island ownership resulting in the islands data being removed.
# Fixed the command '/island admin setsize' setting the size of an island if the island data doesn't exist.
# Fixed IAE when saving a structure with an enderman entity.
This commit is contained in:
SystemEncryption 2018-12-11 22:50:40 +00:00
parent 3aca100530
commit 70655d04eb
18 changed files with 692 additions and 44 deletions

View File

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

View File

@ -56,9 +56,11 @@ import me.goodandevil.skyblock.command.commands.VisitCommand;
import me.goodandevil.skyblock.command.commands.VisitorsCommand;
import me.goodandevil.skyblock.command.commands.VoteCommand;
import me.goodandevil.skyblock.command.commands.WeatherCommand;
import me.goodandevil.skyblock.command.commands.admin.AddUpgradeCommand;
import me.goodandevil.skyblock.command.commands.admin.GeneratorCommand;
import me.goodandevil.skyblock.command.commands.admin.ReloadCommand;
import me.goodandevil.skyblock.command.commands.admin.RemoveHologramCommand;
import me.goodandevil.skyblock.command.commands.admin.RemoveUpgradeCommand;
import me.goodandevil.skyblock.command.commands.admin.SetHologramCommand;
import me.goodandevil.skyblock.command.commands.admin.SetSizeCommand;
import me.goodandevil.skyblock.command.commands.admin.StructureCommand;
@ -107,6 +109,8 @@ public class CommandManager implements CommandExecutor, TabCompleter {
configLoad.getString("Command.Island.Leaderboard.Info.Message"))));
subCommands.add(new CreateCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Command.Island.Create.Info.Message"))));
// subCommands.add(new
// ResetCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',configLoad.getString("Command.Island.Reset.Info.Message"))));
subCommands.add(new DeleteCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Command.Island.Delete.Info.Message"))));
subCommands.add(new TeleportCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',
@ -185,6 +189,10 @@ public class CommandManager implements CommandExecutor, TabCompleter {
configLoad.getString("Command.Island.Admin.RemoveHologram.Info.Message"))));
subCommands.add(new SetSizeCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Command.Island.Admin.SetSize.Info.Message"))));
subCommands.add(new AddUpgradeCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Command.Island.Admin.AddUpgrade.Info.Message"))));
subCommands.add(new RemoveUpgradeCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Info.Message"))));
subCommands.add(new me.goodandevil.skyblock.command.commands.admin.CreateCommand(skyblock).setInfo(ChatColor
.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Create.Info.Message"))));
subCommands.add(new me.goodandevil.skyblock.command.commands.admin.UpgradeCommand(skyblock).setInfo(ChatColor

View File

@ -61,7 +61,8 @@ public class ConfirmCommand extends SubCommand {
me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner());
Confirmation confirmation = playerData.getConfirmation();
if (confirmation == Confirmation.Ownership || confirmation == Confirmation.Deletion) {
if (confirmation == Confirmation.Ownership || confirmation == Confirmation.Reset
|| confirmation == Confirmation.Deletion) {
if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
if (confirmation == Confirmation.Ownership) {
UUID targetPlayerUUID = playerData.getOwnership();
@ -107,6 +108,9 @@ public class ConfirmCommand extends SubCommand {
.getString("Command.Island.Confirmation.Ownership.Member.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else if (confirmation == Confirmation.Reset) {
playerData.setConfirmation(null);
playerData.setConfirmationTime(0);
} else if (confirmation == Confirmation.Deletion) {
playerData.setConfirmation(null);
playerData.setConfirmationTime(0);
@ -188,6 +192,7 @@ public class ConfirmCommand extends SubCommand {
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
}
@Override

View File

@ -0,0 +1,122 @@
package me.goodandevil.skyblock.command.commands;
import java.io.File;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.command.CommandManager;
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.confirmation.Confirmation;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.IslandRole;
import me.goodandevil.skyblock.message.MessageManager;
import me.goodandevil.skyblock.playerdata.PlayerData;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.utils.ChatComponent;
import me.goodandevil.skyblock.utils.version.Sounds;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
public class ResetCommand extends SubCommand {
private final SkyBlock skyblock;
private String info;
public ResetCommand(SkyBlock skyblock) {
this.skyblock = skyblock;
}
@Override
public void onCommandByPlayer(Player player, String[] args) {
MessageManager messageManager = skyblock.getMessageManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (islandManager.hasIsland(player)) {
if (islandManager.getIsland(playerData.getOwner()).hasRole(IslandRole.Owner, player.getUniqueId())) {
if (playerData.getConfirmationTime() > 0) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Reset.Confirmation.Pending.Message"));
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
} else {
int confirmationTime = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getInt("Island.Confirmation.Timeout");
playerData.setConfirmation(Confirmation.Reset);
playerData.setConfirmationTime(confirmationTime);
player.spigot().sendMessage(new ChatComponent(
configLoad.getString("Command.Island.Reset.Confirmation.Confirm.Message").replace("%time",
"" + confirmationTime) + " ",
false, null, null, null)
.addExtra(new ChatComponent(configLoad
.getString("Command.Island.Reset.Confirmation.Confirm.Word.Confirm")
.toUpperCase(), true, ChatColor.RED,
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/island confirm"),
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(
ChatColor.translateAlternateColorCodes('&', configLoad.getString(
"Command.Island.Reset.Confirmation.Confirm.Word.Tutorial")))
.create()))));
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
}
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Reset.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Reset.Owner.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
}
@Override
public String getName() {
return "reset";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[0];
}
@Override
public String[] getArguments() {
return new String[0];
}
@Override
public Type getType() {
return CommandManager.Type.Default;
}
}

View File

@ -0,0 +1,192 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.command.CommandManager;
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.Island;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.message.MessageManager;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.upgrade.Upgrade;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
public class AddUpgradeCommand extends SubCommand {
private final SkyBlock skyblock;
private String info;
public AddUpgradeCommand(SkyBlock skyblock) {
this.skyblock = skyblock;
}
@Override
public void onCommandByPlayer(Player player, String[] args) {
onCommand(player, args);
}
@Override
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
onCommand(sender, args);
}
public void onCommand(CommandSender sender, String[] args) {
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
MessageManager messageManager = skyblock.getMessageManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (player == null || player.hasPermission("skyblock.admin.addupgrade")
|| player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
if (args.length == 2) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID islandOwnerUUID;
String targetPlayerName;
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
islandOwnerUUID = targetPlayerOffline.getOwner();
targetPlayerName = targetPlayerOffline.getName();
} else {
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
targetPlayerName = targetPlayer.getName();
}
Upgrade.Type upgrade = null;
for (Upgrade.Type upgradeList : Upgrade.Type.values()) {
if (upgradeList != Upgrade.Type.Size) {
if (args[1].toUpperCase().equals(upgradeList.name().toUpperCase())) {
upgrade = upgradeList;
break;
}
}
}
if (islandOwnerUUID == null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Island.Owner.Message"));
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else if (upgrade == null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Exist.Message"));
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else {
if (islandManager.containsIsland(islandOwnerUUID)) {
Island island = islandManager.getIsland(islandOwnerUUID);
if (island.hasUpgrade(upgrade)) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Already.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
island.setUpgrade(null, upgrade, true);
} else {
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
islandOwnerUUID.toString() + ".yml");
if (!fileManager.isFileExist(islandDataFile)) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Island.Data.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
FileConfiguration islandDataConfigLoad = YamlConfiguration.loadConfiguration(islandDataFile);
if (islandDataConfigLoad.getString("Upgrade." + upgrade.name()) != null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Upgrade.Already.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
islandDataConfigLoad.set("Upgrade." + upgrade.name(), true);
try {
islandDataConfigLoad.save(islandDataFile);
} catch (IOException e) {
e.printStackTrace();
}
}
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Added.Message")
.replace("%player", targetPlayerName).replace("%upgrade", upgrade.name()));
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
}
} else {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Invalid.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.AddUpgrade.Permission.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "addupgrade";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[0];
}
@Override
public String[] getArguments() {
return new String[0];
}
@Override
public Type getType() {
return CommandManager.Type.Admin;
}
}

View File

@ -0,0 +1,192 @@
package me.goodandevil.skyblock.command.commands.admin;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.command.CommandManager;
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.Island;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.message.MessageManager;
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
import me.goodandevil.skyblock.sound.SoundManager;
import me.goodandevil.skyblock.upgrade.Upgrade;
import me.goodandevil.skyblock.utils.OfflinePlayer;
import me.goodandevil.skyblock.utils.version.Sounds;
public class RemoveUpgradeCommand extends SubCommand {
private final SkyBlock skyblock;
private String info;
public RemoveUpgradeCommand(SkyBlock skyblock) {
this.skyblock = skyblock;
}
@Override
public void onCommandByPlayer(Player player, String[] args) {
onCommand(player, args);
}
@Override
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
onCommand(sender, args);
}
public void onCommand(CommandSender sender, String[] args) {
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
MessageManager messageManager = skyblock.getMessageManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (player == null || player.hasPermission("skyblock.admin.removeupgrade")
|| player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) {
if (args.length == 2) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID islandOwnerUUID;
String targetPlayerName;
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
islandOwnerUUID = targetPlayerOffline.getOwner();
targetPlayerName = targetPlayerOffline.getName();
} else {
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
targetPlayerName = targetPlayer.getName();
}
Upgrade.Type upgrade = null;
for (Upgrade.Type upgradeList : Upgrade.Type.values()) {
if (upgradeList != Upgrade.Type.Size) {
if (args[1].toUpperCase().equals(upgradeList.name().toUpperCase())) {
upgrade = upgradeList;
break;
}
}
}
if (islandOwnerUUID == null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Island.Owner.Message"));
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else if (upgrade == null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Upgrade.Exist.Message"));
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else {
if (islandManager.containsIsland(islandOwnerUUID)) {
Island island = islandManager.getIsland(islandOwnerUUID);
if (!island.hasUpgrade(upgrade)) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Upgrade.Missing.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
island.removeUpgrade(upgrade);
} else {
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
islandOwnerUUID.toString() + ".yml");
if (!fileManager.isFileExist(islandDataFile)) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Island.Data.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
FileConfiguration islandDataConfigLoad = YamlConfiguration.loadConfiguration(islandDataFile);
if (islandDataConfigLoad.getString("Upgrade." + upgrade.name()) == null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Upgrade.Missing.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
islandDataConfigLoad.set("Upgrade." + upgrade.name(), null);
try {
islandDataConfigLoad.save(islandDataFile);
} catch (IOException e) {
e.printStackTrace();
}
}
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Removed.Message")
.replace("%player", targetPlayerName).replace("%upgrade", upgrade.name()));
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
}
} else {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Invalid.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.RemoveUpgrade.Permission.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
}
@Override
public String getName() {
return "removeupgrade";
}
@Override
public String getInfo() {
return info;
}
@Override
public SubCommand setInfo(String info) {
this.info = info;
return this;
}
@Override
public String[] getAliases() {
return new String[0];
}
@Override
public String[] getArguments() {
return new String[0];
}
@Override
public Type getType() {
return CommandManager.Type.Admin;
}
}

View File

@ -82,7 +82,7 @@ public class SetSizeCommand extends SubCommand {
if (islandOwnerUUID == null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.SetSize.Island.Message"));
configLoad.getString("Command.Island.Admin.SetSize.Island.Owner.Message"));
soundManager.playSound(sender, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
} else if (size < 50) {
messageManager.sendMessage(sender,
@ -103,13 +103,23 @@ public class SetSizeCommand extends SubCommand {
islandManager.updateBorder(island);
}
} else {
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data",
File islandDataFile = new File(skyblock.getDataFolder().toString() + "/island-data",
islandOwnerUUID.toString() + ".yml");
FileConfiguration islandConfigLoad = YamlConfiguration.loadConfiguration(configFile);
islandConfigLoad.set("Size", size);
if (!fileManager.isFileExist(islandDataFile)) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.SetSize.Island.Data.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
FileConfiguration islandDataConfigLoad = YamlConfiguration
.loadConfiguration(islandDataFile);
islandDataConfigLoad.set("Size", size);
try {
islandConfigLoad.save(configFile);
islandDataConfigLoad.save(islandDataFile);
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -2,6 +2,6 @@ package me.goodandevil.skyblock.confirmation;
public enum Confirmation {
Ownership, Deletion;
Ownership, Reset, Deletion;
}

View File

@ -597,6 +597,12 @@ public class Island {
.callEvent(new IslandUpgradeEvent(getAPIWrapper(), player, APIUtil.fromImplementation(type)));
}
public void removeUpgrade(Upgrade.Type type) {
skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"))
.getFileConfiguration().set("Upgrade." + type.name(), null);
}
public boolean hasUpgrade(Upgrade.Type type) {
if (skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"))
@ -695,6 +701,26 @@ public class Island {
}
}
public void setStructure(String structure) {
skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"))
.getFileConfiguration().set("Structure", structure);
}
public boolean hasStructure() {
if (getStructure() != null) {
return true;
}
return false;
}
public String getStructure() {
return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"))
.getFileConfiguration().getString("Structure");
}
public Visit getVisit() {
return skyblock.getVisitManager().getIsland(getOwnerUUID());
}

View File

@ -294,8 +294,8 @@ public class IslandManager {
if (containsIsland(islandOwnerUUID)) {
Island island = getIsland(islandOwnerUUID);
island.setOwnerUUID(uuid);
island.save();
island.setOwnerUUID(uuid);
Level level = island.getLevel();
level.save();
@ -391,6 +391,7 @@ public class IslandManager {
} else {
PlayerData playerData = playerDataManager.getPlayerData(targetPlayer);
playerData.setOwner(uuid);
playerData.setIsland(uuid);
playerData.save();
}
}
@ -446,6 +447,21 @@ public class IslandManager {
islandStorage.remove(island.getOwnerUUID());
}
public void deleteIslandData(UUID uuid) {
FileManager fileManager = skyblock.getFileManager();
fileManager
.deleteConfig(new File(skyblock.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml"));
fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/ban-data", uuid.toString() + ".yml"));
fileManager
.deleteConfig(new File(skyblock.getDataFolder().toString() + "/coop-data", uuid.toString() + ".yml"));
fileManager
.deleteConfig(new File(skyblock.getDataFolder().toString() + "/level-data", uuid.toString() + ".yml"));
fileManager.deleteConfig(
new File(skyblock.getDataFolder().toString() + "/setting-data", uuid.toString() + ".yml"));
fileManager
.deleteConfig(new File(skyblock.getDataFolder().toString() + "/visit-data", uuid.toString() + ".yml"));
}
public void loadIsland(UUID uuid) {
WorldManager worldManager = skyblock.getWorldManager();
FileManager fileManager = skyblock.getFileManager();
@ -459,8 +475,8 @@ public class IslandManager {
if (isIslandExist(uuid)) {
if (configLoad.getString("Island.Owner") == null
|| !configLoad.getString("Island.Owner").equals(uuid.toString())) {
fileManager.deleteConfig(
new File(skyblock.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml"));
deleteIslandData(uuid);
configLoad.set("Island.Owner", null);
return;
}
@ -476,6 +492,13 @@ public class IslandManager {
config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data",
islandOwnerUUID.toString() + ".yml"));
if (config.getFileConfiguration().getString("Location") == null) {
deleteIslandData(islandOwnerUUID);
configLoad.set("Island.Owner", null);
return;
}
org.bukkit.Location islandNormalLocation = fileManager.getLocation(config, "Location.Normal.Island", true);
if (islandNormalLocation.getWorld() == null) {

View File

@ -203,16 +203,18 @@ public class Scoreboard {
islandRole = displayVariables.get("%member");
}
displayLine = displayLine.replace("%island_level", "" + NumberUtil.formatNumber(level.getLevel()))
displayLine = displayLine.replace("%island_points", "" + NumberUtil.formatNumber(level.getPoints()))
.replace("%island_level", "" + NumberUtil.formatNumber(level.getLevel()))
.replace("%island_members", "" + islandMembers).replace("%island_role", islandRole)
.replace("%island_visitors", "" + islandManager.getVisitorsAtIsland(island).size())
.replace("%island_size", "" + island.getSize())
.replace("%island_radius", "" + island.getRadius());
}
} else {
displayLine = displayLine.replace("%island_level", ChatColor.RED + "0")
.replace("%island_members", ChatColor.RED + "0").replace("%island_role", ChatColor.RED + "null")
.replace("%island_size", ChatColor.RED + "0").replace("%island_radius", ChatColor.RED + "0");
displayLine = displayLine.replace("%island_points", ChatColor.RED + "0")
.replace("%island_level", ChatColor.RED + "0").replace("%island_members", ChatColor.RED + "0")
.replace("%island_role", ChatColor.RED + "null").replace("%island_size", ChatColor.RED + "0")
.replace("%island_radius", ChatColor.RED + "0");
}
PlaceholderManager placeholderManager = skyblock.getPlaceholderManager();

View File

@ -37,4 +37,24 @@ public class MaterialUtil {
return material;
}
public static Material getMaterial(int NMSVersion, int blockVersion, String material, int data) {
if (NMSVersion > 12) {
if (blockVersion > 12) {
return Material.valueOf(material);
} else {
return Materials.requestMaterials(material, (byte) data).getPostMaterial();
}
} else {
try {
if (blockVersion > 12) {
return Materials.fromString(material).parseMaterial();
} else {
return Material.valueOf(material);
}
} catch (Exception e) {
return Material.STONE;
}
}
}
}

View File

@ -95,6 +95,7 @@ public class nInventoryUtil {
}
};
// TODO Check if listener is already registered
Bukkit.getPluginManager().registerEvents(listener, SkyBlock.getInstance());
}
}

View File

@ -253,7 +253,8 @@ public final class BlockUtil {
if (NMSVersion > 12 && blockData.getVersion() > 12 && blockData.getBlockData() != null) {
block.setBlockData(Bukkit.getServer().createBlockData(blockData.getBlockData()));
} else {
material = getMaterial(NMSVersion, blockData.getVersion(), blockData.getMaterial(), block.getData());
material = me.goodandevil.skyblock.utils.item.MaterialUtil.getMaterial(NMSVersion, blockData.getVersion(),
blockData.getMaterial(), block.getData());
setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), material, blockData.getData());
}
@ -398,7 +399,8 @@ public final class BlockUtil {
String[] flower = blockData.getFlower().split(":");
int materialData = Integer.parseInt(flower[1]);
material = getMaterial(NMSVersion, blockData.getVersion(), flower[0].toUpperCase(), materialData);
material = me.goodandevil.skyblock.utils.item.MaterialUtil.getMaterial(NMSVersion,
blockData.getVersion(), flower[0].toUpperCase(), materialData);
if (material != null) {
ItemStack is = new ItemStack(material, 1, (byte) materialData);
@ -519,24 +521,4 @@ public final class BlockUtil {
e.printStackTrace();
}
}
private static Material getMaterial(int NMSVersion, int blockVersion, String material, int data) {
if (NMSVersion > 12) {
if (blockVersion > 12) {
return Material.valueOf(material);
} else {
return Materials.requestMaterials(material, (byte) data).getPostMaterial();
}
} else {
try {
if (blockVersion > 12) {
return Materials.fromString(material).parseMaterial();
} else {
return Material.valueOf(material);
}
} catch (Exception e) {
return Material.STONE;
}
}
}
}

View File

@ -85,6 +85,8 @@ public class EntityData {
this.fireTicks = fireTicks;
this.ticksLived = ticksLived;
this.ai = true;
}
public String getEntityType() {

View File

@ -20,6 +20,7 @@ import org.bukkit.material.MaterialData;
import org.bukkit.util.EulerAngle;
import me.goodandevil.skyblock.utils.item.ItemStackUtil;
import me.goodandevil.skyblock.utils.item.MaterialUtil;
import me.goodandevil.skyblock.utils.version.NMSUtil;
import me.goodandevil.skyblock.utils.world.block.BlockDegreesType;
@ -371,10 +372,16 @@ public final class EntityUtil {
} else if (entity instanceof Creeper) {
((Creeper) entity).setPowered(entityData.isPowered());
} else if (entity instanceof Enderman) {
if (entityData.getCarryBlock().length() == 0) {
String[] material = entityData.getCarryBlock().split(":");
((Enderman) entity).setCarriedMaterial(
new MaterialData(Material.valueOf(material[0].toUpperCase()), Byte.parseByte(material[1])));
if (entityData.getCarryBlock() != null && !entityData.getCarryBlock().isEmpty()) {
String[] materialData = entityData.getCarryBlock().split(":");
byte data = Byte.parseByte(materialData[1]);
Material material = MaterialUtil.getMaterial(NMSVersion, entityData.getVersion(),
materialData[0].toUpperCase(), data);
if (material != null) {
((Enderman) entity).setCarriedMaterial(new MaterialData(material, data));
}
}
} else if (entity instanceof Horse) {
Horse horse = ((Horse) entity);

View File

@ -49,6 +49,21 @@ Command:
Message: "&f&oOpens the Island Creator menu."
Owner:
Message: "&bSkyBlock &8| &cError&8: &eYou are already an Island owner."
Reset:
Info:
Message: "&f&oResets your Island."
Owner:
Message: "&bSkyBlock &8| &cError&8: &eYou are not an Island owner."
Permission:
Message: "&bSkyBlock &8| &cError&8: &eYou do not have the right to reset your Island."
Confirmation:
Pending:
Message: "&bSkyBlock &8| &cError&8: &eYou currently have a pending confirmation. Please try again in a few seconds!"
Confirm:
Word:
Confirm: "confirm"
Tutorial: "&7Click to &f&oconfirm &r&7Island reset!"
Message: "&bSkyBlock &8| &aInfo&8: &eYou want to reset your Island. You have &c%time &eseconds to confirm."
Delete:
Info:
Message: "&f&oDeletes your Island."
@ -730,7 +745,7 @@ Command:
Permission:
Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to perform that command."
Invalid:
Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island admin setsize <player_name> <size>"
Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island admin setsize <player> <size>"
Numerical:
Message: "&bSkyBlock &8| &cError&8: &eYou must enter a numerical value."
Size:
@ -739,9 +754,50 @@ Command:
Less:
Message: "&bSkyBlock &8| &cError&8: &eThe size of the Island must be less than 1000."
Island:
Message: "&bSkyBlock &8| &cError&8: &eThat player is not a Member or owns an Island."
Owner:
Message: "&bSkyBlock &8| &cError&8: &eThat player is not a Member or owns an Island."
Data:
Message: "&bSkyBlock &8| &cError&8: &eThe island data for that players island does not exist."
Set:
Message: "&bSkyBlock &8| &aInfo&8: &eYou have set the player &d%player's &eIsland size to &d%size&e."
AddUpgrade:
Info:
Message: "&f&oAdd an upgrade to a players Island."
Permission:
Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to perform that command."
Invalid:
Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island admin addupgrade <player> <upgrade>"
Island:
Owner:
Message: "&bSkyBlock &8| &cError&8: &eThat player is not a Member or owns an Island."
Data:
Message: "&bSkyBlock &8| &cError&8: &eThe island data for that players island does not exist."
Upgrade:
Exist:
Message: "&bSkyBlock &8| &cError&8: &eAn upgrade by that name does not exist."
Already:
Message: "&bSkyBlock &8| &cError&8: &eThat players island already has that upgrade."
Added:
Message: "&bSkyBlock &8| &aInfo&8: &eYou have &a&lADDED the upgrade '&d%upgrade&e' to the player &d%player's &eIsland."
RemoveUpgrade:
Info:
Message: "&f&oRemove an upgrade to a players Island."
Permission:
Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to perform that command."
Invalid:
Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island admin removeupgrade <player> <upgrade>"
Island:
Owner:
Message: "&bSkyBlock &8| &cError&8: &eThat player is not a Member or owns an Island."
Data:
Message: "&bSkyBlock &8| &cError&8: &eThe island data for that players island does not exist."
Upgrade:
Exist:
Message: "&bSkyBlock &8| &cError&8: &eAn upgrade by that name does not exist."
Missing:
Message: "&bSkyBlock &8| &cError&8: &eThat players island does not have that upgrade."
Removed:
Message: "&bSkyBlock &8| &aInfo&8: &eYou have &c&lREMOVED &ethe upgrade '&d%upgrade&e' from the player &d%player's &eIsland."
Delete:
Info:
Message: "&f&oDelete a players Island permanently."

View File

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