Fix permission issue, add placeholder fabledskyblock_island_votes

This commit is contained in:
Esophose 2019-03-22 22:36:31 -06:00
parent d6c409cccc
commit 18ba514e3d
3 changed files with 76 additions and 67 deletions

View File

@ -34,71 +34,64 @@ public class TeleportCommand extends SubCommand {
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
if (player.hasPermission("fabledskyblock.teleport") || player.hasPermission("fabledskyblock.*")) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID islandOwnerUUID = null;
String targetPlayerName;
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID islandOwnerUUID = null;
String targetPlayerName;
if (targetPlayer == null) {
OfflinePlayer targetOfflinePlayer = new OfflinePlayer(args[0]);
islandOwnerUUID = targetOfflinePlayer.getOwner();
targetPlayerName = targetOfflinePlayer.getName();
} else {
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
targetPlayerName = targetPlayer.getName();
}
if (targetPlayer == null) {
OfflinePlayer targetOfflinePlayer = new OfflinePlayer(args[0]);
islandOwnerUUID = targetOfflinePlayer.getOwner();
targetPlayerName = targetOfflinePlayer.getName();
} else {
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
targetPlayerName = targetPlayer.getName();
}
if (islandOwnerUUID == null) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Teleport.Island.None.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
if (islandOwnerUUID == null) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Teleport.Island.None.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
} else if (!islandOwnerUUID.equals(playerDataManager.getPlayerData(player).getOwner())) {
if (visitManager.hasIsland(islandOwnerUUID)) {
me.goodandevil.skyblock.visit.Visit visit = visitManager.getIsland(islandOwnerUUID);
boolean isCoopPlayer = false;
return;
} else if (!islandOwnerUUID.equals(playerDataManager.getPlayerData(player).getOwner())) {
if (visitManager.hasIsland(islandOwnerUUID)) {
me.goodandevil.skyblock.visit.Visit visit = visitManager.getIsland(islandOwnerUUID);
boolean isCoopPlayer = false;
if (islandManager.containsIsland(islandOwnerUUID)) {
if (islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID))
.isCoopPlayer(player.getUniqueId())) {
isCoopPlayer = true;
}
if (islandManager.containsIsland(islandOwnerUUID)) {
if (islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID))
.isCoopPlayer(player.getUniqueId())) {
isCoopPlayer = true;
}
if (isCoopPlayer || player.hasPermission("fabledskyblock.bypass")
|| player.hasPermission("fabledskyblock.bypass.*") || player.hasPermission("fabledskyblock.*")
|| visit.isOpen()) {
if (!islandManager.containsIsland(islandOwnerUUID)) {
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
}
islandManager.visitIsland(player,
islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)));
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Teleport.Teleported.Other.Message")
.replace("%player", targetPlayerName));
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
return;
} else {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Teleport.Island.Closed.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
return;
}
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Teleport.Island.None.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
if (isCoopPlayer || player.hasPermission("fabledskyblock.bypass")
|| player.hasPermission("fabledskyblock.bypass.*") || player.hasPermission("fabledskyblock.*")
|| visit.isOpen()) {
if (!islandManager.containsIsland(islandOwnerUUID)) {
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
}
islandManager.visitIsland(player,
islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)));
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Teleport.Teleported.Other.Message")
.replace("%player", targetPlayerName));
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
return;
} else {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Teleport.Island.Closed.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
return;
}
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Permission.Message"));
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Teleport.Island.None.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;

View File

@ -1,24 +1,25 @@
package me.goodandevil.skyblock.placeholder;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.config.FileManager.Config;
import me.goodandevil.skyblock.invite.Invite;
import me.goodandevil.skyblock.island.Island;
import me.goodandevil.skyblock.island.IslandManager;
import me.goodandevil.skyblock.island.IslandRole;
import me.goodandevil.skyblock.leaderboard.Leaderboard;
import me.goodandevil.skyblock.utils.NumberUtil;
import me.goodandevil.skyblock.visit.VisitManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class PlaceholderManager {
@ -61,6 +62,7 @@ public class PlaceholderManager {
public String getPlaceholder(Player player, String placeholder) {
IslandManager islandManager = skyblock.getIslandManager();
VisitManager visitManager = skyblock.getVisitManager();
Island island = islandManager.getIsland(player);
@ -112,6 +114,15 @@ public class PlaceholderManager {
configLoad.getString("Placeholder.fabledskyblock_island_points.Non-empty.Message")
.replace("%placeholder", "" + island.getLevel().getPoints()));
}
} else if (placeholder.equalsIgnoreCase("fabledskyblock_island_votes")) {
if (island == null) {
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_island_votes.Empty.Message"));
} else {
return ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Placeholder.fabledskyblock_island_votes.Non-empty.Message")
.replace("%placeholder", "" + visitManager.getIslands().get(player.getUniqueId()).getVoters().size()));
}
} else if (placeholder.equalsIgnoreCase("fabledskyblock_island_role")) {
if (island == null) {
return ChatColor.translateAlternateColorCodes('&',

View File

@ -1115,6 +1115,11 @@ Placeholder:
Message: "&c0"
Non-empty:
Message: "&f%placeholder"
fabledskyblock_island_votes:
Empty:
Message: "&c0"
Non-empty:
Message: "&f%placeholder"
fabledskyblock_island_role:
Empty:
Message: "&f&oNone"