Merge branch 'development'

This commit is contained in:
Brianna 2020-06-17 18:24:54 -05:00
commit 1abb93d7d2
67 changed files with 1684 additions and 713 deletions

BIN
.DS_Store vendored

Binary file not shown.

16
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,16 @@
image: maven:latest
cache:
paths:
- .m2/repository/
- target/
build:
stage: build
script:
- mvn compile
test:
stage: test
script:
- mvn test

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId>
<version>2.2.16</version>
<version>2.3</version>
<packaging>jar</packaging>
<build>
<defaultGoal>clean install</defaultGoal>

BIN
src/.DS_Store vendored

Binary file not shown.

View File

@ -39,9 +39,9 @@ import com.songoda.skyblock.scoreboard.ScoreboardManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.structure.StructureManager;
import com.songoda.skyblock.tasks.MobNetherWaterTask;
import com.songoda.skyblock.upgrade.UpgradeManager;
import com.songoda.skyblock.usercache.UserCacheManager;
import com.songoda.skyblock.utils.SignMenuFactory;
import com.songoda.skyblock.visit.VisitManager;
import com.songoda.skyblock.visit.VisitTask;
import com.songoda.skyblock.world.WorldManager;
@ -81,6 +81,7 @@ public class SkyBlock extends SongodaPlugin {
private PlaceholderManager placeholderManager;
private MessageManager messageManager;
private HologramTask hologramTask;
private MobNetherWaterTask mobNetherWaterTask;
private LimitationInstanceHandler limitationHandler;
private LocalizationManager localizationManager;
private RewardManager rewardManager;
@ -110,8 +111,8 @@ public class SkyBlock extends SongodaPlugin {
// Load Holograms
com.songoda.core.hooks.HologramManager.load(this);
permissionManager = new PermissionManager(this);
fileManager = new FileManager(this);
permissionManager = new PermissionManager(this);
localizationManager = new LocalizationManager();
worldManager = new WorldManager(this);
userCacheManager = new UserCacheManager(this);
@ -162,6 +163,7 @@ public class SkyBlock extends SongodaPlugin {
// Start Tasks
hologramTask = HologramTask.startTask(this);
mobNetherWaterTask = MobNetherWaterTask.startTask(this);
PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(new Join(this), this);
@ -229,6 +231,10 @@ public class SkyBlock extends SongodaPlugin {
this.hologramTask.onDisable();
}
if (this.mobNetherWaterTask != null) {
this.mobNetherWaterTask.onDisable();
}
if (this.fabledChallenge != null) {
this.fabledChallenge.onDisable();
}
@ -342,6 +348,10 @@ public class SkyBlock extends SongodaPlugin {
return hologramTask;
}
public MobNetherWaterTask getMobNetherWaterTask() {
return mobNetherWaterTask;
}
public StackableManager getStackableManager() {
return stackableManager;
}

View File

@ -67,11 +67,11 @@ public class BankManager {
public List<String> getBalanceLore(Player player) {
List<String> result = new ArrayList<>();
result.add("Some error occurred while loading your balance!");
Island island = SkyBlock.getInstance().getIslandManager().getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
Island island = SkyBlock.getInstance().getIslandManager().getIsland(player);
result.add("If this is null then its a easy to fix bug: "+island.toString());
if (island != null) {
result.clear();
result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId()))));
result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(player)));
result.add(player.getDisplayName()+"'s island has "+EconomyManager.formatEconomy(island.getBankBalance()));
}
return result;

View File

@ -78,37 +78,37 @@ public class Challenge {
}
}
}
// GETTERS
public ChallengeCategory getCategory() {
return category;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getMaxTimes() {
return maxTimes;
}
public boolean isShowInChat() {
return showInChat;
}
public List<Peer<Type, Object>> getRequires() {
return requires;
}
public List<Peer<Type, Object>> getRewards() {
return rewards;
}
public ItemChallenge getItem() {
return item;
}
@ -151,14 +151,31 @@ public class Challenge {
// Check if player has specific item in his inventory
ItemStack is = (ItemStack) obj;
return p.getInventory().containsAtLeast(new ItemStack(is.getType()), is.getAmount());
// return p.getInventory().contains(is.getType(), is.getAmount());
}
@Override
public void executeRequire(Player p, Object obj) {
// Remove specific item in player's inventory
ItemStack is = (ItemStack) obj;
p.getInventory().removeItem(new ItemStack(is.getType(), is.getAmount()));
if(obj instanceof ItemStack){
// Remove specific item in player's inventory
ItemStack is = (ItemStack) obj;
//p.getInventory().removeItem(new ItemStack(is.getType(), is.getAmount()));
int toRemove = is.getAmount();
for(ItemStack jis : p.getInventory().getContents()) {
if(jis != null && jis.isSimilar(is)) {
if(jis.getAmount() <= toRemove) {
toRemove -= jis.getAmount();
jis.setAmount(0);
} else {
jis.setAmount(jis.getAmount() - toRemove);
toRemove = 0;
}
}
if(toRemove <= 0) {
p.updateInventory();
break;
}
}
}
// TODO LOG
}
@ -422,7 +439,7 @@ public class Challenge {
* <li>7 = lingering extended</li>
* <li>8 = lingering ++</li>
* </ul>
*
*
* @param is
* @param type
* @param data
@ -451,7 +468,7 @@ public class Challenge {
/**
* Try to convert the value to a useable object used later
*
*
* @param value
* The value to convert
* @return A useable object required
@ -460,7 +477,7 @@ public class Challenge {
/**
* Check if specific player has requirement for specific object
*
*
* @param p
* The player
* @param obj
@ -471,7 +488,7 @@ public class Challenge {
/**
* Execute an action associated with specific object for specific player
*
*
* @param p
* The player
* @param obj
@ -481,7 +498,7 @@ public class Challenge {
/**
* Give a reward to specific player for specific object
*
*
* @param p
* The player
* @param obj

View File

@ -61,8 +61,8 @@ public class ChallengeCategory {
Challenge c = new Challenge(this, id, name, maxTimes, showInChat, require, reward, ic);
challenges.put(id, c);
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("Exception at category " + this.name + "(" + this.id
+ ") at challenge " + name + "(" + id + "): " + ex.getMessage());
throw new IllegalArgumentException("Exception at category " + this.name.replace("&", "") + "(" + this.id
+ ") at challenge " + name.replace("&", "") + "(" + id + "): " + ex.getMessage());
}
}
Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + "Category " + name + ChatColor.GREEN

View File

@ -10,6 +10,7 @@ import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import com.songoda.skyblock.challenge.FabledChallenge;
@ -21,6 +22,7 @@ import com.songoda.skyblock.challenge.defaultinv.Item;
import com.songoda.skyblock.challenge.inventory.ClickableItem;
import com.songoda.skyblock.challenge.inventory.Inventory;
import com.songoda.skyblock.challenge.inventory.InventoryProvider;
import org.bukkit.inventory.meta.ItemMeta;
public class ChallengeInventory implements InventoryProvider {
public static final String CATEGORY = "ChallengeCategory";
@ -78,6 +80,10 @@ public class ChallengeInventory implements InventoryProvider {
// If challenge is done, add enchantment to show to player that it's done
if (count >= c.getMaxTimes())
is.addUnsafeEnchantment(Enchantment.OXYGEN, 1);
ItemMeta im = is.getItemMeta();
im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
is.setItemMeta(im);
Consumer<InventoryClickEvent> consumer = e -> {
// Count the new value
int count2 = done.getOrDefault(c, 0);
@ -97,6 +103,9 @@ public class ChallengeInventory implements InventoryProvider {
// If challenge is done, add enchantment to show to player that it's done
if (count2 >= c.getMaxTimes())
is2.addUnsafeEnchantment(Enchantment.OXYGEN, 1);
ItemMeta im2 = is2.getItemMeta();
im2.addItemFlags(ItemFlag.HIDE_ENCHANTS);
is2.setItemMeta(im2);
// Update
inv.updateItem(ic.getCol(), ic.getRow(), is2);
} else

View File

@ -7,6 +7,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import com.songoda.skyblock.island.Island;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
@ -22,19 +23,32 @@ import com.songoda.skyblock.config.FileManager.Config;
public class PlayerManager {
private SkyBlock skyblock;
private HashMap<UUID, HashMap<Challenge, Integer>> players;
private HashMap<UUID, HashMap<Challenge, Integer>> islands;
private File playersDirectory;
public PlayerManager(SkyBlock skyblock) {
this.skyblock = skyblock;
players = new HashMap<>();
islands = new HashMap<>();
playersDirectory = new File(skyblock.getDataFolder(), "challenge-data");
if (!playersDirectory.exists())
playersDirectory.mkdirs();
Bukkit.getScheduler().runTask(skyblock, () -> {
for(Player p : Bukkit.getServer().getOnlinePlayers()){
loadPlayer(p.getUniqueId());
}
});
}
public HashMap<Challenge, Integer> getPlayer(UUID uuid) {
return players.get(uuid);
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
uuid = is.getOwnerUUID();
}
}
return islands.get(uuid);
}
/**
@ -44,7 +58,15 @@ public class PlayerManager {
* The uuid of specific player
*/
public void loadPlayer(UUID uuid) {
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, uuid.toString() + ".yml"));
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
uuid = is.getOwnerUUID();
}
}
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory,
uuid.toString() + ".yml"));
FileConfiguration fileConfig = config.getFileConfiguration();
HashMap<Challenge, Integer> challenges = new HashMap<>();
ConfigurationSection section = fileConfig.getConfigurationSection("challenges");
@ -67,7 +89,7 @@ public class PlayerManager {
challenges.put(c, count);
}
}
players.put(uuid, challenges);
islands.put(uuid, challenges);
}
/**
@ -77,8 +99,16 @@ public class PlayerManager {
* The uuid of specific player
*/
public void unloadPlayer(UUID uuid) {
players.remove(uuid);
skyblock.getFileManager().unloadConfig(new File(playersDirectory, uuid.toString() + ".yml"));
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
uuid = is.getOwnerUUID();
}
}
islands.remove(uuid);
skyblock.getFileManager().unloadConfig(new File(playersDirectory,
uuid.toString() + ".yml"));
}
@ -95,11 +125,18 @@ public class PlayerManager {
if (c == null)
return false;
UUID uuid = p.getUniqueId();
HashMap<Challenge, Integer> done = players.get(uuid);
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
uuid = is.getOwnerUUID();
}
}
HashMap<Challenge, Integer> done = islands.get(uuid);
if (done == null) {
// Wtf ?
loadPlayer(uuid);
done = players.get(uuid);
done = islands.get(uuid);
}
int count = done.getOrDefault(c, 0);
if (c.getMaxTimes() != 0 && count >= c.getMaxTimes())
@ -124,7 +161,14 @@ public class PlayerManager {
if (!canDoChallenge(p, c))
return false;
UUID uuid = p.getUniqueId();
HashMap<Challenge, Integer> done = players.get(uuid);
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
uuid = is.getOwnerUUID();
}
}
HashMap<Challenge, Integer> done = islands.get(uuid);
int count = done.getOrDefault(c, 0);
done.put(c, count + 1);
addChallenge(uuid, c);
@ -146,7 +190,15 @@ public class PlayerManager {
}
public void addChallenge(UUID uuid, Challenge c) {
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, uuid.toString() + ".yml"));
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
uuid = is.getOwnerUUID();
}
}
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory,
uuid.toString() + ".yml"));
FileConfiguration fileConfig = config.getFileConfiguration();
int ccId = c.getCategory().getId();
int cId = c.getId();
@ -173,12 +225,21 @@ public class PlayerManager {
* @return The number of time specific challenge has been done by player
*/
public int getChallengeCount(UUID uuid, Challenge c) {
HashMap<Challenge, Integer> challenges = players.get(uuid);
HashMap<Challenge, Integer> challenges = islands.get(uuid);
if (challenges != null) {
return challenges.getOrDefault(c, 0);
} else {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = skyblock.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
uuid = is.getOwnerUUID();
}
}
// Not connected, check in file
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory, uuid.toString() + ".yml"));
Config config = skyblock.getFileManager().getConfig(new File(playersDirectory,
uuid.toString() + ".yml"));
FileConfiguration fileConfig = config.getFileConfiguration();
int ccId = c.getCategory().getId();
int cId = c.getId();

View File

@ -170,7 +170,7 @@ public class AcceptCommand extends SubCommand {
if (scoreboardManager != null) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Scoreboard.Island.Team.Displayname")));
configLoad.getString("Scoreboard.Island.Team.Displayname", "")));
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
scoreboard.setDisplayList(

View File

@ -63,6 +63,9 @@ public class BanCommand extends SubCommand {
if (targetPlayerUUID == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if((targetPlayer.hasPermission("fabledskyblock.bypass.ban") || targetPlayer.isOp())){
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Exempt"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Yourself.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);

View File

@ -3,6 +3,7 @@ package com.songoda.skyblock.command.commands.island;
import java.io.File;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.island.IslandManager;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@ -24,6 +25,7 @@ public class ChallengeCommand extends SubCommand {
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
FabledChallenge fabledChallenge = skyblock.getFabledChallenge();
IslandManager islandManager = skyblock.getIslandManager();
Config langConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
@ -36,6 +38,15 @@ public class ChallengeCommand extends SubCommand {
return;
}
if (args.length == 0) {
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland")){
if(islandManager.getIsland(player) == null){
messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.NoIsland.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
}
// Open challenge inventory
ChallengeCategory cc = fabledChallenge.getChallengeManager().getChallenge(1);
if (cc == null) {

View File

@ -1,22 +1,27 @@
package com.songoda.skyblock.command.commands.island;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent;
import com.songoda.skyblock.api.event.player.PlayerIslandChatSwitchEvent;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.PlaceholderManager;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.UUID;
public class ChatCommand extends SubCommand {
@ -26,6 +31,7 @@ public class ChatCommand extends SubCommand {
MessageManager messageManager = skyblock.getMessageManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
@ -33,32 +39,73 @@ public class ChatCommand extends SubCommand {
Island island = islandManager.getIsland(player);
PlayerData playerData = playerDataManager.getPlayerData(player);
if (playerData.isChat() && island != null) {
Bukkit.getServer().getPluginManager()
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), false));
playerData.setChat(false);
if(args.length == 0){
if (playerData.isChat() && island != null) {
Bukkit.getServer().getPluginManager()
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), false));
playerData.setChat(false);
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Untoggled.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F);
return;
}
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Untoggled.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F);
return;
}
if (island == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Owner.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()) == 0) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Team.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if ((islandManager.getMembersOnline(island).size() - 1) <= 0) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Offline.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
if (island == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Owner.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()) == 0) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Team.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if ((islandManager.getMembersOnline(island).size() - 1) <= 0) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Offline.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
Bukkit.getServer().getPluginManager()
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), true));
playerData.setChat(true);
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Toggled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
}
} else {
Bukkit.getServer().getPluginManager()
.callEvent(new PlayerIslandChatSwitchEvent(player, island.getAPIWrapper(), true));
playerData.setChat(true);
if (playerDataManager.hasPlayerData(player)) {
if (playerData.getOwner() != null) {
island = skyblock.getIslandManager().getIsland(player);
}
messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Toggled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
String islandRole = "";
if (island.hasRole(IslandRole.Member, player.getUniqueId())) {
islandRole = configLoad.getString("Island.Chat.Format.Role.Member");
} else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) {
islandRole = configLoad.getString("Island.Chat.Format.Role.Operator");
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
islandRole = configLoad.getString("Island.Chat.Format.Role.Owner");
}
Island finalIsland = island;
String finalIslandRole = islandRole;
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, finalIsland.getAPIWrapper(),
String.join(" ", args), configLoad.getString("Island.Chat.Format.Message"));
Bukkit.getServer().getPluginManager().callEvent(islandChatEvent);
if (!islandChatEvent.isCancelled()) {
for (UUID islandMembersOnlineList : islandManager.getMembersOnline(finalIsland)) {
Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer,
islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName())))
.replace("%message", islandChatEvent.getMessage());
targetPlayer.sendMessage(message);
}
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
messageManager.sendMessage(Bukkit.getConsoleSender(), islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName())
.replace("%message", islandChatEvent.getMessage()));
}
}
});
}
}
}

View File

@ -5,6 +5,10 @@ import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.confirmation.Confirmation;
import com.songoda.skyblock.cooldown.Cooldown;
import com.songoda.skyblock.cooldown.CooldownManager;
import com.songoda.skyblock.cooldown.CooldownPlayer;
import com.songoda.skyblock.cooldown.CooldownType;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
@ -12,6 +16,7 @@ import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.ChatComponent;
import com.songoda.skyblock.utils.NumberUtil;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
@ -28,6 +33,7 @@ public class DeleteCommand extends SubCommand {
@Override
public void onCommandByPlayer(Player player, String[] args) {
CooldownManager cooldownManager = skyblock.getCooldownManager();
MessageManager messageManager = skyblock.getMessageManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
@ -44,6 +50,32 @@ public class DeleteCommand extends SubCommand {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Delete.Owner.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable")
&& cooldownManager.hasPlayer(CooldownType.Deletion, player)) {
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Deletion, player);
Cooldown cooldown = cooldownPlayer.getCooldown();
if (cooldown.getTime() < 60) {
messageManager.sendMessage(player,
config.getFileConfiguration().getString("Island.Deletion.Cooldown.Message") // TODO Add language.yml values
.replace("%time", cooldown.getTime() + " " + config.getFileConfiguration()
.getString("Island.Deletion.Cooldown.Word.Second")));
} else {
long[] durationTime = NumberUtil.getDuration(cooldown.getTime());
messageManager.sendMessage(player,
config.getFileConfiguration().getString("Island.Deletion.Cooldown.Message")
.replace("%time", durationTime[2] + " "
+ config.getFileConfiguration()
.getString("Island.Deletion.Cooldown.Word.Minute")
+ " " + durationTime[3] + " " + config.getFileConfiguration()
.getString("Island.Deletion.Cooldown.Word.Second")));
}
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return;
}
if (playerData.getConfirmationTime() > 0) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Delete.Confirmation.Pending.Message"));

View File

@ -49,7 +49,9 @@ public class KickAllCommand extends SubCommand {
for (UUID islandVisitorList : islandVisitors) {
Player targetPlayer = Bukkit.getServer().getPlayer(islandVisitorList);
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
if (targetPlayer != null &&
(targetPlayer.hasPermission("fabledskyblock.bypass.ban") ||
targetPlayer.hasPermission("fabledskyblock.bypass.kick")))
continue;
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),

View File

@ -72,7 +72,11 @@ public class KickCommand extends SubCommand {
targetPlayerName = targetPlayer.getName();
}
if (targetPlayerUUID.equals(player.getUniqueId())) {
assert targetPlayer != null;
if((targetPlayer.hasPermission("fabledskyblock.bypass.kick") || targetPlayer.isOp()) && islandVisitors.contains(targetPlayer.getUniqueId())){
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Exempt"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if (islandOperators.contains(player.getUniqueId()) && islandOperators.contains(targetPlayerUUID)) {
@ -138,7 +142,9 @@ public class KickCommand extends SubCommand {
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName()));
soundManager.playSound(targetPlayer, CompatibleSound.ENTITY_IRON_GOLEM_ATTACK.getSound(), 1.0F, 1.0F);
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
if (islandManager.isPlayerAtIsland(island, targetPlayer)
&& !targetPlayer.hasPermission("fabledskyblock.bypass.kick")
&& !targetPlayer.isOp()) {
LocationUtil.teleportPlayerToSpawn(targetPlayer);
}

View File

@ -11,9 +11,13 @@ import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.visit.Visit;
import com.songoda.skyblock.visit.VisitManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@ -36,7 +40,7 @@ public class TeleportCommand extends SubCommand {
if (args.length == 1) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
UUID islandOwnerUUID = null;
UUID islandOwnerUUID;
String targetPlayerName;
if (targetPlayer == null) {
@ -105,8 +109,13 @@ public class TeleportCommand extends SubCommand {
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
player.setFallDistance(0.0F);
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
LocationUtil.removeWaterFromLoc(skyblock, loc);
player.teleport(loc);
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
}
});
}
}

View File

@ -36,7 +36,7 @@ public class CooldownManager {
for (Player all : Bukkit.getOnlinePlayers()) {
CooldownPlayer cooldownPlayer = null;
if (cooldownTypeList == CooldownType.Biome || cooldownTypeList == CooldownType.Creation) {
if (cooldownTypeList == CooldownType.Biome || cooldownTypeList == CooldownType.Creation || cooldownTypeList == CooldownType.Deletion) {
cooldownPlayer = loadCooldownPlayer(cooldownTypeList, all);
} else if (cooldownTypeList == CooldownType.Levelling || cooldownTypeList == CooldownType.Ownership) {
Island island = islandManager.getIsland(all);
@ -69,7 +69,7 @@ public class CooldownManager {
}
public CooldownPlayer loadCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
Config config = skyblock.getFileManager()
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
@ -99,7 +99,7 @@ public class CooldownManager {
int time = 0;
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
time = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
@ -139,7 +139,7 @@ public class CooldownManager {
public void deletePlayer(CooldownType cooldownType, OfflinePlayer player) {
for (Iterator<CooldownPlayer> it = getCooldownPlayersOrEmptyList(cooldownType).iterator(); it.hasNext();) {
if (it.next().getUUID().equals(player.getUniqueId())) {
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
skyblock.getFileManager()
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
player.getUniqueId().toString() + ".yml"))
@ -197,7 +197,7 @@ public class CooldownManager {
public void setCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
for (CooldownPlayer cooldownPlayerList : getCooldownPlayersOrEmptyList(cooldownType)) {
if (cooldownPlayerList.getUUID().equals(player.getUniqueId())) {
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
skyblock.getFileManager()
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
player.getUniqueId().toString() + ".yml"))
@ -222,7 +222,7 @@ public class CooldownManager {
public void saveCooldownPlayer(CooldownType cooldownType, OfflinePlayer player) {
Config config = null;
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation) {
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
config = skyblock.getFileManager()
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), player.getUniqueId().toString() + ".yml"));
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {

View File

@ -8,6 +8,7 @@ public enum CooldownType {
Biome,
Creation,
Deletion,
Levelling,
Ownership,
Teleport;

View File

@ -1,19 +1,22 @@
package com.songoda.skyblock.generator;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.island.IslandWorld;
import java.util.List;
public class Generator {
private String name;
private IslandWorld isWorld;
private CompatibleMaterial materials;
private List<GeneratorMaterial> generatorMaterials;
private boolean permission;
public Generator(String name, CompatibleMaterial materials, List<GeneratorMaterial> generatorMaterials, boolean permission) {
public Generator(String name, IslandWorld isWorld, CompatibleMaterial materials, List<GeneratorMaterial> generatorMaterials, boolean permission) {
this.name = name;
this.isWorld = isWorld;
this.materials = materials;
this.generatorMaterials = generatorMaterials;
this.permission = permission;
@ -23,6 +26,10 @@ public class Generator {
return name;
}
public IslandWorld getIsWorld() {
return isWorld;
}
public CompatibleMaterial getMaterials() {
return materials;
}

View File

@ -4,7 +4,8 @@ import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -56,6 +57,7 @@ public class GeneratorManager {
}
generatorStorage.add(new Generator(configLoad.getString("Generators." + generatorList + ".Name"),
IslandWorld.valueOf(configLoad.getString("Generators." + generatorList + ".World", "Normal")),
oreMaterials[rnd.nextInt(oreMaterials.length)], generatorMaterials,
configLoad.getBoolean("Generators." + generatorList + ".Permission")));
}
@ -150,10 +152,10 @@ public class GeneratorManager {
return CompatibleMaterial.COBBLESTONE;
}
public void addGenerator(String name, List<GeneratorMaterial> generatorMaterials, boolean permission) {
public void addGenerator(String name, IslandWorld isWorld, List<GeneratorMaterial> generatorMaterials, boolean permission) {
CompatibleMaterial[] oreMaterials = new CompatibleMaterial[]{CompatibleMaterial.COAL, CompatibleMaterial.CHARCOAL, CompatibleMaterial.DIAMOND,
CompatibleMaterial.IRON_INGOT, CompatibleMaterial.GOLD_INGOT, CompatibleMaterial.EMERALD};
generatorStorage.add(new Generator(name, oreMaterials[new Random().nextInt(oreMaterials.length)],
generatorStorage.add(new Generator(name, isWorld, oreMaterials[new Random().nextInt(oreMaterials.length)],
generatorMaterials, permission));
}

View File

@ -52,7 +52,6 @@ public class Island {
this.skyblock = SkyBlock.getInstance();
FileManager fileManager = skyblock.getFileManager();
PermissionManager permissionManager = skyblock.getPermissionManager();
this.islandUUID = UUID.randomUUID();
this.ownerUUID = player.getUniqueId();
@ -113,7 +112,7 @@ public class Island {
}
if (configLoad.getString("Border") == null) {
configLoad.set("Border.Enable", true);
configLoad.set("Border.Enable", mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Default", false));
configLoad.set("Border.Color", WorldBorder.Color.Blue.name());
}
@ -162,10 +161,10 @@ public class Island {
}
for (IslandRole roleList : IslandRole.getRoles()) {
List<IslandPermission> permissions = new ArrayList<>();
for (BasicPermission permission : skyblock.getPermissionManager().getPermissions()) {
List<BasicPermission> allPermissions = skyblock.getPermissionManager().getPermissions();
List<IslandPermission> permissions = new ArrayList<>(allPermissions.size());
for (BasicPermission permission : allPermissions) {
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration()
.getString("Settings." + roleList.name() + "." + permission.getName()) == null) {
permissions.add(
@ -184,10 +183,10 @@ public class Island {
configLoad.set("UUID", islandUUID.toString());
configLoad.set("Visitor.Open", mainConfigLoad.getBoolean("Island.Visitor.Open"));
configLoad.set("Border.Enable", true);
configLoad.set("Border.Enable", mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Default", false));
configLoad.set("Border.Color", WorldBorder.Color.Blue.name());
configLoad.set("Biome.Type", mainConfigLoad.getString("Island.Biome.Default.Type").toUpperCase());
configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised"));
configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised")); // TODO: Synchronized
configLoad.set("Weather.Time", mainConfigLoad.getInt("Island.Weather.Default.Time"));
configLoad.set("Weather.Weather", mainConfigLoad.getString("Island.Weather.Default.Weather").toUpperCase());
configLoad.set("Ownership.Original", ownerUUID.toString());
@ -198,7 +197,8 @@ public class Island {
for (BasicPermission permission : allPermissions) {
permissions.add(
new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration().getBoolean("Settings." + roleList.name() + "." + permission, true)));
new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration()
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
}
islandPermissions.put(roleList, permissions);

View File

@ -114,7 +114,15 @@ public class IslandLevel {
division = 1;
}
return getPoints() / division;
long points = getPoints();
long subtract = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Subtract");
if(points >= subtract){
points -= subtract;
} else {
points = 0;
}
return points / division;
}
public void checkLevelUp() {

View File

@ -47,7 +47,6 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.IllegalPluginAccessException;
import java.io.File;
import java.io.IOException;
@ -61,7 +60,7 @@ public class IslandManager {
private List<IslandPosition> islandPositions = new ArrayList<>();
private Map<UUID, UUID> islandProxies = new HashMap<>();
private Map<UUID, Island> islandStorage = new HashMap<>();
private int offset = 1200;
private int offset;
private HashMap<IslandWorld, Integer> oldSystemIslands;
@ -71,6 +70,9 @@ public class IslandManager {
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "worlds.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
offset = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getInt("Island.Creation.Distance", 1200);
for (IslandWorld worldList : IslandWorld.values()) {
ConfigurationSection configSection = configLoad.getConfigurationSection("World." + worldList.name() + ".nextAvailableLocation");
islandPositions.add(new IslandPosition(worldList, configSection.getDouble("x"), configSection.getDouble("z")));
@ -241,6 +243,9 @@ public class IslandManager {
if (configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable") && !player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*")
&& !player.hasPermission("fabledskyblock.*"))
skyblock.getCooldownManager().createPlayer(CooldownType.Creation, player);
if (configLoad.getBoolean("Island.Deletion.Cooldown.Deletion.Enable") && !player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*")
&& !player.hasPermission("fabledskyblock.*"))
skyblock.getCooldownManager().createPlayer(CooldownType.Deletion, player);
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(island.getAPIWrapper(), player)));
@ -455,6 +460,16 @@ public class IslandManager {
fileManager.unloadConfig(newIslandDataFile);
oldIslandDataFile.renameTo(newIslandDataFile);
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)){
File oldChallengeDataFile = new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), uuid2.toString() + ".yml");
File newChallengeDataFile = new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), player.getUniqueId().toString() + ".yml");
fileManager.unloadConfig(oldChallengeDataFile);
fileManager.unloadConfig(newChallengeDataFile);
oldChallengeDataFile.renameTo(newChallengeDataFile);
}
skyblock.getVisitManager().transfer(uuid2, player.getUniqueId());
skyblock.getBanManager().transfer(uuid2, player.getUniqueId());
skyblock.getInviteManager().tranfer(uuid2, player.getUniqueId());
@ -509,8 +524,6 @@ public class IslandManager {
}
}
int j = 0;
public boolean deleteIsland(Island island, boolean force) {
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
@ -566,7 +579,8 @@ public class IslandManager {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
boolean cooldownEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable");
boolean cooldownCreationEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable");
boolean cooldownDeletionEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable");
config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
configLoad = config.getFileConfiguration();
@ -590,11 +604,26 @@ public class IslandManager {
LocationUtil.teleportPlayerToSpawn(all);
}
if (cooldownEnabled) {
// TODO - Find a way to delete also offline players
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Deletion.ClearInventory", false)){
all.getInventory().clear();
}
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Deletion.ClearEnderChest", false)){
all.getEnderChest().clear();
}
if (cooldownCreationEnabled) {
if (!all.hasPermission("fabledskyblock.bypass.cooldown") && !all.hasPermission("fabledskyblock.bypass.*") && !all.hasPermission("fabledskyblock.*")) {
skyblock.getCooldownManager().createPlayer(CooldownType.Creation, all);
}
}
if (cooldownDeletionEnabled) {
if (!all.hasPermission("fabledskyblock.bypass.cooldown") && !all.hasPermission("fabledskyblock.bypass.*") && !all.hasPermission("fabledskyblock.*")) {
skyblock.getCooldownManager().createPlayer(CooldownType.Deletion, all);
}
}
}
InviteManager inviteManager = skyblock.getInviteManager();
@ -612,6 +641,10 @@ public class IslandManager {
fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"), island.getOwnerUUID().toString() + ".yml"));
fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID().toString() + ".yml"));
fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml"));
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)){
fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID().toString() + ".yml"));
}
Bukkit.getServer().getPluginManager().callEvent(new IslandDeleteEvent(island.getAPIWrapper()));
@ -627,6 +660,10 @@ public class IslandManager {
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"));
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)){
fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/challenge-data", uuid.toString() + ".yml"));
}
}
public Island loadIsland(org.bukkit.OfflinePlayer player) {
@ -851,9 +888,16 @@ public class IslandManager {
fileManager.unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID() + ".yml"));
fileManager.unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), island.getOwnerUUID() + ".yml"));
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)){
fileManager.unloadConfig(new File(new File(skyblock.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID() + ".yml"));
}
islandStorage.remove(island.getOwnerUUID());
Bukkit.getServer().getPluginManager().callEvent(new IslandUnloadEvent(island.getAPIWrapper()));
Bukkit.getScheduler().runTask(skyblock, () -> {
Bukkit.getServer().getPluginManager().callEvent(new IslandUnloadEvent(island.getAPIWrapper()));
});
}
public void prepareIsland(Island island, IslandWorld world) {
@ -1033,8 +1077,17 @@ public class IslandManager {
FileConfiguration configLoad = languageConfig.getFileConfiguration();
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
player.setFallDistance(0.0F);
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
if(loc != null){
player.teleport(loc);
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Teleport.Unsafe.Message")));
}
} else {
if (scoreboardManager != null) {
int islandVisitors = getVisitorsAtIsland(island).size(), islandMembers = island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size() + 1;
@ -1052,8 +1105,6 @@ public class IslandManager {
} else {
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
}
scoreboard.run();
@ -1063,8 +1114,23 @@ public class IslandManager {
}
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
player.setFallDistance(0.0F);
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor);
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
loc = LocationUtil.getSafeLocation(loc);
}
if(loc != null){
player.teleport(loc);
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message")));
}
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
}
});
List<String> islandWelcomeMessage = island.getMessage(IslandMessage.Welcome);
@ -1429,7 +1495,7 @@ public class IslandManager {
}
for (Player all : getPlayersAtIsland(island)) {
WorldBorder.send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island));
WorldBorder.send(all, island.getBorderColor(), island.getSize()+2, island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island));
}
}
}

View File

@ -7,6 +7,8 @@ import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.limit.EnumLimitation;
import com.songoda.skyblock.utils.player.PlayerUtil;
import com.songoda.skyblock.utils.version.CompatibleSpawners;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
@ -54,13 +56,16 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
}
@SuppressWarnings("deprecation")
public long getBlockLimit(Player player, Block block) {
if (player == null || block == null) return -1;
return this.getBlockLimit(player, block.getType());
}
public long getBlockLimit(Player player, Material type) {
if (player == null || type == null) return -1;
if (player.hasPermission("fabledskyblock.limit.block.*")) return -1;
final CompatibleMaterial material = CompatibleMaterial.getMaterial(block.getType());
final CompatibleMaterial material = CompatibleMaterial.getMaterial(type);
if (material == null) return -1;
@ -69,19 +74,22 @@ public final class BlockLimitation extends EnumLimitation<CompatibleMaterial> {
return Math.max(getMap().getOrDefault(material, getDefault()), PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.block." + name, true, -1));
}
@SuppressWarnings("deprecation")
public boolean isBlockLimitExceeded(Block block, long limit) {
return this.isBlockLimitExceeded(block.getType(), block.getLocation(), limit);
}
public boolean isBlockLimitExceeded(Material type, Location loc, long limit) {
if (limit == -1) return false;
final IslandManager islandManager = SkyBlock.getInstance().getIslandManager();
final Island island = islandManager.getIslandAtLocation(block.getLocation());
final Island island = islandManager.getIslandAtLocation(loc);
final long totalPlaced;
if (block.getType() == CompatibleMaterial.SPAWNER.getBlockMaterial()) {
if (type == CompatibleMaterial.SPAWNER.getBlockMaterial()) {
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum();
} else {
totalPlaced = island.getLevel().getMaterialAmount(CompatibleMaterial.getMaterial(block.getType()).name());
totalPlaced = island.getLevel().getMaterialAmount(CompatibleMaterial.getMaterial(type).name());
}
return limit <= totalPlaced;

View File

@ -20,15 +20,13 @@ import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.entity.*;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -70,14 +68,14 @@ public class Block implements Listener {
}
// Check permissions.
if (!skyblock.getPermissionManager().processPermission(event, player, island)) {
if (!skyblock.getPermissionManager().processPermission(event, player, island) || event.isCancelled()) {
return;
}
if (stackableManager != null && stackableManager.isStacked(blockLocation)) {
Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getBlockMaterial(block.getType()));
Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getMaterial(block));
if (stackable != null) {
CompatibleMaterial material = CompatibleMaterial.getBlockMaterial(block.getType());
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
byte data = block.getData();
int droppedAmount = 0;
@ -192,6 +190,10 @@ public class Block implements Listener {
Island island = islandManager.getIslandAtLocation(blockLoc);
// Check permissions.
if (!skyblock.getPermissionManager().processPermission(event, player, island))
return;
if (island == null) {
event.setCancelled(true);
return;
@ -204,14 +206,34 @@ public class Block implements Listener {
return;
}
// Check permissions.
if (!skyblock.getPermissionManager().processPermission(event, player, island))
return;
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
if(!player.hasPermission("fabledskyblock.bypass.netherplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.Nether)){
for(String s : Objects.requireNonNull(configLoad.getConfigurationSection("Island.Restrict.NetherBlocks")).getKeys(false)){
if(s.equalsIgnoreCase(block.getType().toString())){
if(configLoad.getBoolean("Island.Restrict.NetherBlocks." + s)){
skyblock.getMessageManager().sendMessage(player, Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Unlock.NetherBlocksPlace.Message")));
event.setCancelled(true);
}
}
}
}
if(!player.hasPermission("fabledskyblock.bypass.endplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.End)){
for(String s : Objects.requireNonNull(configLoad.getConfigurationSection("Island.Restrict.EndBlocks")).getKeys(false)){
if(s.equalsIgnoreCase(block.getType().toString())){
if(configLoad.getBoolean("Island.Restrict.EndBlocks." + s)){
skyblock.getMessageManager().sendMessage(player, Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Unlock.EndBlocksPlace.Message")));
event.setCancelled(true);
}
}
}
}
if (configLoad.getBoolean("Island.WorldBorder.Block") && block.getType() == Material.DISPENSER) {
if (!islandManager.isLocationAtIsland(island, blockLoc, world)) {
event.setCancelled(true);
@ -296,6 +318,35 @@ public class Block implements Listener {
return;
}
// Nether mobs
if(configLoad.getBoolean("Island.Nether.WaterDoNotFlowNearNetherMobs", false) && worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether)){
Collection<Entity> entities = block.getWorld().getNearbyEntities(block.getLocation(), 1d, 1d, 1d);
if(entities.size() > 0){
for(Entity ent : entities){
boolean witherSkeleton;
if (NMSUtil.getVersionNumber() > 10) {
witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON);
} else {
witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER);
}
if (ent.getType().equals(EntityType.PIG_ZOMBIE) ||
ent.getType().equals(EntityType.BLAZE) ||
ent.getType().equals(EntityType.MAGMA_CUBE) ||
ent.getType().equals(EntityType.WITHER) ||
ent.getType().equals(EntityType.GHAST) ||
witherSkeleton) {
if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){
event.setCancelled(true);
event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f);
event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
}
break;
}
}
}
}
// Generators
if (NMSUtil.getVersionNumber() < 12) {
if (generatorManager != null && generatorManager.getGenerators().size() > 0 && generatorManager.isGenerator(block)) {
List<Generator> generators = new ArrayList<>(generatorManager.getGenerators());
@ -313,23 +364,25 @@ public class Block implements Listener {
// Find highest generator available
for (Generator generator : generators) {
for (Player p : possiblePlayers) {
if(generator.getIsWorld().equals(world)){
for (Player p : possiblePlayers) {
if (generator.isPermission() &&
!p.hasPermission(generator.getPermission()) &&
!p.hasPermission("fabledskyblock.generator.*") &&
!p.hasPermission("fabledskyblock.*")) {
continue;
if (generator.isPermission() &&
!p.hasPermission(generator.getPermission()) &&
!p.hasPermission("fabledskyblock.generator.*") &&
!p.hasPermission("fabledskyblock.*")) {
continue;
}
org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block);
org.bukkit.block.BlockState toBlockState = event.getToBlock().getState();
toBlockState.setData(genState.getData());
toBlockState.setType(genState.getType());
toBlockState.update();
updateLevel(island, genState.getLocation());
return;
}
org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block);
org.bukkit.block.BlockState toBlockState = event.getToBlock().getState();
toBlockState.setData(genState.getData());
toBlockState.setType(genState.getType());
toBlockState.update();
updateLevel(island, genState.getLocation());
return;
}
}
}
@ -534,7 +587,9 @@ public class Block implements Listener {
boolean isMember = island.hasRole(IslandRole.Owner, player.getUniqueId()) ||
island.hasRole(IslandRole.Member, player.getUniqueId()) ||
island.hasRole(IslandRole.Coop, player.getUniqueId()) ||
island.hasRole(IslandRole.Operator, player.getUniqueId());
island.hasRole(IslandRole.Operator, player.getUniqueId()) ||
(island.getVisit().getVisitors().contains(player.getUniqueId()) &&
player.hasPermission("fabledskyblock.generator.anywhere"));
if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) {
possiblePlayers.add(player);
@ -550,12 +605,14 @@ public class Block implements Listener {
}
}
org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block);
state.setType(genState.getType());
if(worldManager.getIslandWorld(event.getBlock().getWorld()).equals(generator.getIsWorld())){
org.bukkit.block.BlockState genState = generatorManager.generateBlock(generator, block);
state.setType(genState.getType());
if (NMSUtil.getVersionNumber() < 13) state.setData(genState.getData());
updateLevel(island, genState.getLocation());
return;
if (NMSUtil.getVersionNumber() < 13) state.setData(genState.getData());
updateLevel(island, genState.getLocation());
return;
}
}
}
}
@ -583,7 +640,7 @@ public class Block implements Listener {
// PortalCreateEvent.getBlocks() changed from ArrayList<Block> to
// ArrayList<BlockState> in 1.14.1
if (NMSUtil.getVersionNumber() > 13) {
List<BlockState> blocks = event.getBlocks();
List<BlockState> blocks = event.getBlocks(); // TODO 1.8
if (event.getBlocks().isEmpty()) return;
Island island = islandManager.getIslandAtLocation(event.getBlocks().get(0).getLocation());
@ -667,6 +724,7 @@ public class Block implements Listener {
// placed.
// This shouldn't cause any issues besides the task number being increased
// insanely fast.
// TODO Do this only in 1.8.8
Bukkit.getScheduler().runTask(skyblock, () -> {
org.bukkit.block.Block block = location.getBlock();
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);

View File

@ -2,6 +2,7 @@ package com.songoda.skyblock.listeners;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.*;
import com.songoda.skyblock.limit.impl.EntityLimitaton;
@ -26,6 +27,8 @@ import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
@ -54,22 +57,32 @@ public class Entity implements Listener {
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
if (!(event.getEntity() instanceof Player)) {
return;
}
if(event.getEntity() instanceof Blaze){
WorldManager worldManager = skyblock.getWorldManager();
Player player = (Player) event.getEntity();
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
// Check permissions.
skyblock.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()));
}
if(configLoad.getBoolean("Island.Nether.BlazeImmuneToWaterInNether", false) &&
worldManager.getIslandWorld(event.getEntity().getWorld()).equals(IslandWorld.Nether)){
if(event.getCause().equals(DamageCause.DROWNING)){
event.setCancelled(true);
}
}
} else if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if
// the shot entity isn't damaged
if (preventFireTicks.contains(player.getUniqueId()) && event.getCause() == DamageCause.FIRE_TICK) {
player.setFireTicks(0);
event.setCancelled(true);
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
// Check permissions.
skyblock.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()));
}
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if
// the shot entity isn't damaged
if (preventFireTicks.contains(player.getUniqueId()) && event.getCause() == DamageCause.FIRE_TICK) {
player.setFireTicks(0);
event.setCancelled(true);
}
}
}
@ -96,9 +109,9 @@ public class Entity implements Listener {
// Check permissions.
skyblock.getPermissionManager()
.processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()));
.processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()), true);
} else if (event.getDamager() instanceof TNTPrimed) {
} else { // Make it work with all the entities, not just TNT
org.bukkit.entity.Entity entity = event.getEntity();
// Check permissions.
@ -206,6 +219,7 @@ public class Entity implements Listener {
@EventHandler
public void onHangingBreak(HangingBreakEvent event) {
Hanging hanging = event.getEntity();
if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return;
IslandManager islandManager = skyblock.getIslandManager();
@ -218,14 +232,15 @@ public class Entity implements Listener {
public void onHangingBreak(HangingBreakByEntityEvent event) {
Hanging hanging = event.getEntity();
if (!(event.getRemover() instanceof Player))
return;
if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return;
IslandManager islandManager = skyblock.getIslandManager();
Player p = null;
if(event.getRemover() instanceof Player){
p = (Player) event.getRemover();
}
// Check permissions.
skyblock.getPermissionManager().processPermission(event, (Player) event.getRemover(),
skyblock.getPermissionManager().processPermission(event, p,
islandManager.getIslandAtLocation(hanging.getLocation()));
}
@ -311,9 +326,11 @@ public class Entity implements Listener {
event.setCancelled(true);
return;
}
// Check permissions.
skyblock.getPermissionManager().processPermission(event, null, island);
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Block.Level.Enable"))
return;
@ -362,10 +379,10 @@ public class Entity implements Listener {
if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
// Check permissions.
Island island = islandManager.getIslandAtLocation(entity.getLocation());
skyblock.getPermissionManager().processPermission(event, null, island);
if (!event.isCancelled()) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Block.Level.Enable")) {
for (org.bukkit.block.Block blockList : event.blockList()) {
@ -513,12 +530,20 @@ public class Entity implements Listener {
EntityType type = entity.getType();
if (limits.isBeingTracked(type)) {
long count = limits.getEntityCount(island, skyblock.getWorldManager().getIslandWorld(entityLocation.getWorld()), type);
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (limits.hasTooMuch(count + 1, type)) {
entity.remove();
event.setCancelled(true);
return;
boolean isSplit = event.getSpawnReason().equals(SpawnReason.SLIME_SPLIT);
boolean splitBypass = configLoad.getBoolean("Island.Challenge.PerIsland", true);
if(!isSplit || !splitBypass){
long count = limits.getEntityCount(island, skyblock.getWorldManager().getIslandWorld(entityLocation.getWorld()), type);
if (limits.hasTooMuch(count + 1, type)) {
entity.remove();
event.setCancelled(true);
return;
}
}
}
@ -544,6 +569,22 @@ public class Entity implements Listener {
event.setCancelled(true); // For other plugin API reasons.
}
@EventHandler
public void onDamageVehicle(VehicleDamageEvent event) {
if (!(event.getAttacker() instanceof Player)) {
IslandManager islandManager = skyblock.getIslandManager();
skyblock.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation()));
}
}
@EventHandler
public void onDestroyVehicle(VehicleDestroyEvent event) {
if (!(event.getAttacker() instanceof Player)) {
IslandManager islandManager = skyblock.getIslandManager();
skyblock.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation()));
}
}
private static SpawnReason getSpawnReason(String reason) {
try {
return SpawnReason.valueOf(reason);

View File

@ -18,11 +18,12 @@ import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.structure.StructureUtil;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.*;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -48,6 +49,87 @@ public class Interact implements Listener {
this.skyblock = skyblock;
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onWaterPlace(PlayerInteractEvent event){
if(event.getItem() == null) return;
Player player = event.getPlayer();
org.bukkit.block.Block block = event.getClickedBlock().getRelative(event.getBlockFace());
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
IslandLevelManager levellingManager = skyblock.getLevellingManager();
if (!worldManager.isIslandWorld(block.getWorld())) return;
if (event.getAction() == Action.RIGHT_CLICK_BLOCK &&
worldManager.getIslandWorld(block.getWorld()).equals(IslandWorld.Nether) &&
event.getItem().getType().equals(Material.WATER_BUCKET)){
Location blockLoc = block.getLocation();
Island island = islandManager.getIslandAtLocation(blockLoc);
// Check permissions.
if (!skyblock.getPermissionManager().processPermission(event, player, island))
return;
if (island == null) {
event.setCancelled(true);
return;
}
if (levellingManager.isScanning(island)) {
skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
event.setCancelled(true);
return;
}
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
// Check spawn protection
if (configLoad.getBoolean("Island.Spawn.Protection")) {
boolean isObstructing = false;
// Directly on the block
if (LocationUtil.isLocationAffectingIslandSpawn(blockLoc, island, world)) {
isObstructing = true;
}
if (isObstructing) {
skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Place.Message"));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setCancelled(true);
return;
}
}
BlockLimitation limits = skyblock.getLimitationHandler().getInstance(BlockLimitation.class);
long limit = limits.getBlockLimit(player, Material.WATER);
if (limits.isBlockLimitExceeded(event.getItem().getType(), block.getLocation(), limit)) {
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getItem().getType());
skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setCancelled(true);
return;
}
if(configLoad.getBoolean("Island.Nether.AllowNetherWater", false)){
event.setCancelled(true);
block.setType(Material.WATER, true);
block.getWorld().playSound(block.getLocation(), CompatibleSound.ITEM_BUCKET_EMPTY.getSound(), 1f, 1f);
if(!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)){
event.getItem().setType(Material.BUCKET);
}
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {

View File

@ -100,6 +100,7 @@ public class Join implements Listener {
cooldownManager.addCooldownPlayer(CooldownType.Biome, cooldownManager.loadCooldownPlayer(CooldownType.Biome, player));
cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player));
cooldownManager.addCooldownPlayer(CooldownType.Deletion, cooldownManager.loadCooldownPlayer(CooldownType.Deletion, player));
if (scoreboardManager != null) {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));

View File

@ -2,6 +2,7 @@ package com.songoda.skyblock.listeners;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.command.commands.island.TeleportCommand;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.*;
@ -13,9 +14,9 @@ import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -26,6 +27,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.potion.PotionEffect;
import java.io.File;
import java.util.Objects;
public class Move implements Listener {
@ -73,15 +75,7 @@ public class Move implements Listener {
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
if (island != null) {
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId())
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
} else {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
}
player.setFallDistance(0.0F);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
teleportPlayerToIslandSpawn(player, soundManager, island);
return;
}
@ -116,16 +110,7 @@ public class Move implements Listener {
if (to.getY() <= configLoad.getInt("Island.World." + world.name() + ".Liquid.Height")) {
if (keepItemsOnDeath && configLoad.getBoolean("Island.Liquid.Teleport.Enable")) {
player.setFallDistance(0.0F);
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId())
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
} else {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
}
player.setFallDistance(0.0F);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
teleportPlayerToIslandSpawn(player, soundManager, island);
}
return;
}
@ -139,7 +124,7 @@ public class Move implements Listener {
player.setExp(0.0F);
if (NMSUtil.getVersionNumber() > 8) {
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
player.setHealth(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue());
} else {
player.setHealth(player.getMaxHealth());
}
@ -150,16 +135,10 @@ public class Move implements Listener {
player.removePotionEffect(potionEffect.getType());
}
}
player.setFallDistance(0.0F);
if (configLoad.getBoolean("Island.Void.Teleport.Island")) {
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId())
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
} else {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
}
teleportPlayerToIslandSpawn(player, island);
} else {
LocationUtil.teleportPlayerToSpawn(player);
}
@ -169,14 +148,16 @@ public class Move implements Listener {
}
}
} else {
if (!LocationUtil.isLocationAtLocationRadius(island.getLocation(world, IslandEnvironment.Island), to, island.getRadius() + 0.5)) {
if (island.getVisit().isVisitor(player.getUniqueId())) {
player.teleport(island.getLocation(world, IslandEnvironment.Visitor));
} else {
player.teleport(island.getLocation(world, IslandEnvironment.Main));
if (!LocationUtil.isLocationAtLocationRadius(island.getLocation(world, IslandEnvironment.Island), to, island.getRadius())) {
teleportPlayerToIslandSpawn(player, world, island);
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
}
player.setFallDistance(0.0F);
messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
.getString("Island.WorldBorder.Outside.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
@ -188,12 +169,17 @@ public class Move implements Listener {
}
// Load the island they are now on if one exists
if (player.hasPermission("fabledskyblock.bypass")) {
Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation());
if (loadedIsland != null) {
Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation());
if (loadedIsland != null) {
if (player.hasPermission("fabledskyblock.bypass")) {
playerData.setIsland(loadedIsland.getOwnerUUID());
return;
}
if(loadedIsland.isOpen()){
loadedIsland.getVisit().addVisitor(player.getUniqueId());
return;
}
}
LocationUtil.teleportPlayerToSpawn(player);
@ -204,22 +190,66 @@ public class Move implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent e) {
private void teleportPlayerToIslandSpawn(Player player, IslandWorld world, Island island) {
Location loc;
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId())
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
loc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Main));
} else {
loc = island.getLocation(world, IslandEnvironment.Main);
LocationUtil.removeWaterFromLoc(skyblock, loc);
}
} else {
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
loc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor));
} else {
loc = island.getLocation(world, IslandEnvironment.Visitor);
}
}
if(loc != null){
player.teleport(loc);
} else {
LocationUtil.teleportPlayerToSpawn(player);
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message"))));
}
}
private void teleportPlayerToIslandSpawn(Player player, Island island) {
this.teleportPlayerToIslandSpawn(player, IslandWorld.Normal, island);
}
private void teleportPlayerToIslandSpawn(Player player, SoundManager soundManager, Island island) {
teleportPlayerToIslandSpawn(player, island);
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
}
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent e) { // TODO We should wait for the player island to be loaded in 1.8.8 - Fabrimat
final Player player = e.getPlayer();
final WorldManager worldManager = skyblock.getWorldManager();
if (e.getTo() == null ||
!worldManager.isIslandWorld(e.getTo().getWorld()) ||
skyblock.getIslandManager().getIslandAtLocation(e.getTo()) != null)
return;
e.setCancelled(true);
skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message"));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
if(e.getTo() != null && e.getTo().getWorld() != null){
e.getTo().getWorld().loadChunk(e.getTo().getChunk());
if(worldManager.isIslandWorld(e.getTo().getWorld())
&& (!e.getTo().getWorld().equals(e.getFrom().getWorld()) || e.getTo().distance(e.getFrom()) > 1.0d)){ // We should not care of self block tp
if(skyblock.getIslandManager().getIslandAtLocation(e.getTo()) == null){
e.setCancelled(true);
skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message"));
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
}
}
}
}
}

View File

@ -2,6 +2,7 @@ package com.songoda.skyblock.listeners;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.utils.LocationUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
@ -15,6 +16,7 @@ import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -79,9 +81,10 @@ public class Portal implements Listener {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat
// Check permissions.
if (!skyblock.getPermissionManager().processPermission(new PlayerEnterPortalEvent(player, player.getLocation()),
player, island))
if (!skyblock.getPermissionManager().processPermission(playerEnterPortalEvent,
player, island) || playerEnterPortalEvent.isCancelled())
return;
IslandEnvironment spawnEnvironment;
@ -131,21 +134,13 @@ public class Portal implements Listener {
switch (toWorld) {
case Nether:
if (configLoad.getBoolean("Island.World.Nether.Enable") && island.isRegionUnlocked(player, "Nether")) {
IslandWorld toWorldF = toWorld;
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
player.setFallDistance(0.0F);
tick.setTick(1);
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
}
break;
case End:
if (configLoad.getBoolean("Island.World.End.Enable") && island.isRegionUnlocked(player, "End")) {
IslandWorld toWorldF = toWorld;
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
player.setFallDistance(0.0F);
tick.setTick(1);
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
}
break;
@ -160,6 +155,21 @@ public class Portal implements Listener {
}
private void teleportPlayerToWorld(Player player, SoundManager soundManager, Island island, IslandEnvironment spawnEnvironment, Tick tick, IslandWorld toWorld) {
IslandWorld toWorldF = toWorld;
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> {
Location loc = island.getLocation(toWorldF, spawnEnvironment);
Location safeLoc = LocationUtil.getSafeLocation(loc);
if(safeLoc != null){
loc = safeLoc;
}
player.teleport(loc);
}, 1L);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
player.setFallDistance(0.0F);
tick.setTick(1);
}
public static class Tick {
private int tick = 1;
private long last = System.currentTimeMillis() - 1001;

View File

@ -2,6 +2,8 @@ package com.songoda.skyblock.listeners;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.challenge.challenge.ChallengeManager;
import com.songoda.skyblock.challenge.player.PlayerManager;
import com.songoda.skyblock.cooldown.CooldownManager;
import com.songoda.skyblock.cooldown.CooldownType;
import com.songoda.skyblock.invite.Invite;
@ -44,6 +46,7 @@ public class Quit implements Listener {
MessageManager messageManager = skyblock.getMessageManager();
InviteManager inviteManager = skyblock.getInviteManager();
IslandManager islandManager = skyblock.getIslandManager();
PlayerManager challengePlayerManager = skyblock.getFabledChallenge().getPlayerManager();
PlayerData playerData = playerDataManager.getPlayerData(player);
@ -91,9 +94,42 @@ public class Quit implements Listener {
cooldownManager.setCooldownPlayer(CooldownType.Creation, player);
cooldownManager.removeCooldownPlayer(CooldownType.Creation, player);
cooldownManager.setCooldownPlayer(CooldownType.Deletion, player);
cooldownManager.removeCooldownPlayer(CooldownType.Deletion, player);
playerDataManager.savePlayerData(player);
playerDataManager.unloadPlayerData(player);
boolean offline = true;
if(island != null && skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Challenge.PerIsland", false)){
if(island.getRole(IslandRole.Member) != null){
for(UUID uuid : island.getRole(IslandRole.Member)){
if(Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline()){
offline = false;
}
}
}
if(offline && island.getRole(IslandRole.Operator) != null){
for(UUID uuid : island.getRole(IslandRole.Operator)){
if(Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline()){
offline = false;
}
}
}
if(offline && island.getRole(IslandRole.Owner) != null){
for(UUID uuid : island.getRole(IslandRole.Owner)){
if(Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline()){
offline = false;
}
}
}
}
if(offline){
challengePlayerManager.unloadPlayer(player.getUniqueId());
}
for (Island islandList : islandManager.getCoopIslands(player)) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Coop.Unload") || islandList.getCoopType(player.getUniqueId()) == IslandCoop.TEMP) {
@ -129,6 +165,6 @@ public class Quit implements Listener {
}
});
// Unload Challenge
SkyBlock.getInstance().getFabledChallenge().getPlayerManager().loadPlayer(event.getPlayer().getUniqueId());
SkyBlock.getInstance().getFabledChallenge().getPlayerManager().unloadPlayer(event.getPlayer().getUniqueId());
}
}

View File

@ -1,10 +1,9 @@
package com.songoda.skyblock.menus;
import be.maximvdw.placeholderapi.internal.utils.ListUtils;
import com.google.common.collect.Lists;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.hooks.EconomyManager;
import com.songoda.core.input.ChatPrompt;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.bank.BankManager;
import com.songoda.skyblock.bank.Transaction;
@ -15,7 +14,6 @@ import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.SignMenuFactory;
import com.songoda.skyblock.utils.item.MenuClickRegistry;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import org.bukkit.Bukkit;
@ -24,7 +22,8 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.*;
import java.util.Calendar;
import java.util.Objects;
public class Bank {
@ -34,7 +33,9 @@ public class Bank {
private IslandManager islandManager;
public static Bank getInstance() {return instance == null ? instance = new Bank() : instance;}
public static Bank getInstance() {
return instance == null ? instance = new Bank() : instance;
}
public Bank() {
SkyBlock skyblock = SkyBlock.getInstance();
@ -65,31 +66,27 @@ public class Bank {
//Deposit money
Island island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
if (island != null) {
Island finalIsland = island;
SelectInputMethod.getInstance().open(player,"Deposit", (action) -> {
SelectInputMethod.getInstance().open(player, "Deposit", (action) -> {
if (action == InputMethodSelectlistener.InputMethod.CANCELED) {
Bukkit.getScheduler().runTask(skyblock,() -> {this.open(player);});
return;
Bukkit.getScheduler().runTask(skyblock, () ->
this.open(player));
} else if (action == InputMethodSelectlistener.InputMethod.ALL) {
deposit(player,finalIsland,EconomyManager.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())));
deposit(player, island, EconomyManager.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())));
} else {
Bukkit.getScheduler().runTaskLater(SkyBlock.getInstance(), () ->
SignMenuFactory.getInstance().newMenu().reopenIfFail()
.response((player1, lines) -> {
if (lines[0] == "") {
return true;
}
double amount;
try {
amount = Double.parseDouble(lines[0]);
} catch (NumberFormatException e1) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short4.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return false;
}
deposit(player,finalIsland,amount);
return true;
}).open(player),10);
ChatPrompt.showPrompt(skyblock, player, (event) -> {
if (event.getMessage().equals(""))
return;
double amount;
try {
amount = Double.parseDouble(event.getMessage());
} catch (NumberFormatException e1) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short4.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
deposit(player, island, amount);
});
}
});
}
@ -103,30 +100,27 @@ public class Bank {
island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
if (island != null) {
Island finalIsland = island;
SelectInputMethod.getInstance().open(player,"Withdraw", (action) -> {
SelectInputMethod.getInstance().open(player, "Withdraw", (action) -> {
if (action == InputMethodSelectlistener.InputMethod.CANCELED) {
Bukkit.getScheduler().runTask(skyblock,() -> {this.open(player);});
Bukkit.getScheduler().runTask(skyblock, () -> {
this.open(player);
});
return;
} else if (action == InputMethodSelectlistener.InputMethod.ALL) {
withdraw(player,finalIsland,finalIsland.getBankBalance());
withdraw(player, finalIsland, finalIsland.getBankBalance());
} else {
Bukkit.getScheduler().runTaskLater(SkyBlock.getInstance(), () ->
SignMenuFactory.getInstance().newMenu().reopenIfFail()
.response((player1, lines) -> {
if (lines[0] == "") {
return true;
}
double amount;
ChatPrompt.showPrompt(skyblock, player, (event) -> {
if (event.getMessage().equals(""))
return;
double amount = 0;
try {
amount = Double.parseDouble(lines[0]);
amount = Double.parseDouble(event.getMessage());
} catch (NumberFormatException e1) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short4.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return false;
}
withdraw(player,finalIsland,amount);
return true;
}).open(player),10);
withdraw(player, finalIsland, amount);
});
}
});
}
@ -147,8 +141,7 @@ public class Bank {
public void open(Player player) {
Island island;
island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
island = islandManager.getIsland(player);
SkyBlock skyblock = SkyBlock.getInstance();
@ -158,16 +151,16 @@ public class Bank {
if (island == null) {
skyblock.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
skyblock.getMessageManager().sendMessage(player,configLoad.getString("Command.Bank.Unknown"));
skyblock.getMessageManager().sendMessage(player, configLoad.getString("Command.Bank.Unknown"));
return;
}
// Glass panes barriers
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), configLoad.getString("Menu.Bank.Item.Barrier.Displayname"), null, null, null, null), 0, 2, 5, 8,
1, 2, 3, 5,6,7,9,11,12,14,15,17);
1, 2, 3, 5, 6, 7, 9, 11, 12, 14, 15, 17);
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Bank.Item.Exit.Displayname"),
configLoad.getStringList("Menu.Bank.Item.Exit.Lore"), null, null, null), 0,8);
configLoad.getStringList("Menu.Bank.Item.Exit.Lore"), null, null, null), 0, 8);
nInv.addItem(nInv.createItem(CompatibleMaterial.BOOK.getItem(), configLoad.getString("Menu.Bank.Item.Log.Displayname"),
bankManager.getTransactions(player), null, null, null), 4);

View File

@ -128,13 +128,13 @@ public class Bans {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Bans.Item.Previous.Displayname")))) {
playerData1.setPage(playerData1.getPage() - 1);
playerData1.setPage(MenuType.BANS, playerData1.getPage(MenuType.BANS) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
'&', configLoad.getString("Menu.Bans.Item.Next.Displayname")))) {
playerData1.setPage(playerData1.getPage() + 1);
playerData1.setPage(MenuType.BANS, playerData1.getPage(MenuType.BANS) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -173,7 +173,7 @@ public class Bans {
configLoad.getString("Menu.Bans.Item.Barrier.Displayname"), null, null, null, null),
9, 10, 11, 12, 13, 14, 15, 16, 17);
int playerMenuPage = playerData.getPage(), nextEndIndex = islandBans.size() - playerMenuPage * 36;
int playerMenuPage = playerData.getPage(MenuType.BANS), nextEndIndex = islandBans.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(

View File

@ -165,54 +165,67 @@ public class Border {
configLoad.getStringList("Menu.Border.Item.Toggle.Lore"),
new Placeholder[]{new Placeholder("%toggle", borderToggle)}, null, null), 1);
if (borderColor == WorldBorder.Color.Blue) {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIGHT_BLUE_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Blue")),
configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"),
new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Blue"))},
null, null), 2);
if(player.hasPermission("fabledskyblock.island.border.blue")){
if (borderColor == WorldBorder.Color.Blue) {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIGHT_BLUE_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Blue")),
configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"),
new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Blue"))},
null, null), 2);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIGHT_BLUE_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Blue")),
configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"),
new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Blue"))},
null, null), 2);
}
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIGHT_BLUE_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Blue")),
configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"),
new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Blue"))},
null, null), 2);
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
"", null, null, null, null), 2);
}
if (borderColor == WorldBorder.Color.Green) {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIME_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Green")),
configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"),
new Placeholder[]{
new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Green"))},
null, null), 3);
if(player.hasPermission("fabledskyblock.island.border.green")){
if (borderColor == WorldBorder.Color.Green) {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIME_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Green")),
configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"),
new Placeholder[]{
new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Green"))},
null, null), 3);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIME_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Green")),
configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"),
new Placeholder[]{
new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Green"))},
null, null), 3);
}
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIME_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Green")),
configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"),
new Placeholder[]{
new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Green"))},
null, null), 3);
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
"", null, null, null, null), 3);
}
if (borderColor == WorldBorder.Color.Red) {
nInv.addItem(nInv.createItem(CompatibleMaterial.RED_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Red")),
configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"),
new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Red"))},
null, null), 4);
if(player.hasPermission("fabledskyblock.island.border.red")){
if (borderColor == WorldBorder.Color.Red) {
nInv.addItem(nInv.createItem(CompatibleMaterial.RED_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Red")),
configLoad.getStringList("Menu.Border.Item.Color.Selected.Lore"),
new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Red"))},
null, null), 4);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.RED_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Red")),
configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"),
new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Red"))},
null, null), 4);
}
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.RED_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Red")),
configLoad.getStringList("Menu.Border.Item.Color.Unselected.Lore"),
new Placeholder[]{new Placeholder("%color", configLoad.getString("Menu.Border.Item.Word.Red"))},
null, null), 4);
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
"", null, null, null, null), 4);
}
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Border.Title")));

View File

@ -93,34 +93,85 @@ public final class ControlPanel {
});
// Teleport to island and open/close island
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_DOOR.getItem(), configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Teleport.Lore"), null, null, null), 1);
nInv.addItem(nInv.createItem(CompatibleMaterial.IRON_DOOR.getItem(), configLoad.getString("Menu.ControlPanel.Item.Lock.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Lock.Lore"), null, null, null), 10);
if(player.hasPermission("fabledskyblock.island.teleport")){
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_DOOR.getItem(), configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Teleport.Lore"), null, null, null), 1);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 1);
}
if(player.hasPermission("fabledskyblock.island.close")){
nInv.addItem(nInv.createItem(CompatibleMaterial.IRON_DOOR.getItem(), configLoad.getString("Menu.ControlPanel.Item.Lock.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Lock.Lore"), null, null, null), 10);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 10);
}
// Glass panes barriers
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 0, 2, 5, 8,
9, 11, 14, 17);
// 4 Items at the left
nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.EXPERIENCE_BOTTLE.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Level.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Level.Lore"), null, null, null), 3);
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG), configLoad.getString("Menu.ControlPanel.Item.Settings.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Settings.Lore"), null, null, null), 4);
nInv.addItem(nInv.createItem(CompatibleMaterial.CLOCK.getItem(), configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Weather.Lore"), null, null, null), 12);
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_SAPLING.getItem(), configLoad.getString("Menu.ControlPanel.Item.Biome.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Biome.Lore"), null, null, null), 13);
if(player.hasPermission("fabledskyblock.island.level")){
nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.EXPERIENCE_BOTTLE.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Level.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Level.Lore"), null, null, null), 3);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 3);
}
if(player.hasPermission("fabledskyblock.island.settings")){
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG), configLoad.getString("Menu.ControlPanel.Item.Settings.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Settings.Lore"), null, null, null), 4);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 4);
}
if(player.hasPermission("fabledskyblock.island.weather")){
nInv.addItem(nInv.createItem(CompatibleMaterial.CLOCK.getItem(), configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Weather.Lore"), null, null, null), 12);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 12);
}
if(player.hasPermission("fabledskyblock.island.biome")){
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_SAPLING.getItem(), configLoad.getString("Menu.ControlPanel.Item.Biome.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Biome.Lore"), null, null, null), 13);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 13);
}
// 4 Items at the right
nInv.addItem(nInv.createItem(new ItemStack(Material.ITEM_FRAME), configLoad.getString("Menu.ControlPanel.Item.Members.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Members.Lore"), null, null, null), 16);
nInv.addItem(nInv.createItem(new ItemStack(Material.IRON_AXE), configLoad.getString("Menu.ControlPanel.Item.Bans.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Bans.Lore"), null, null, new ItemFlag[] { ItemFlag.HIDE_ATTRIBUTES }), 6);
nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Visitors.Lore"), null, null, null), 7);
nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.ANVIL.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Upgrades.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Upgrades.Lore"), null, null, null), 15);
if(player.hasPermission("fabledskyblock.island.members")){
nInv.addItem(nInv.createItem(new ItemStack(Material.ITEM_FRAME), configLoad.getString("Menu.ControlPanel.Item.Members.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Members.Lore"), null, null, null), 16);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 16);
}
if(player.hasPermission("fabledskyblock.island.bans")){
nInv.addItem(nInv.createItem(new ItemStack(Material.IRON_AXE), configLoad.getString("Menu.ControlPanel.Item.Bans.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Bans.Lore"), null, null, new ItemFlag[] { ItemFlag.HIDE_ATTRIBUTES }), 6);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 6);
}
if(player.hasPermission("fabledskyblock.island.visitors")){
nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Visitors.Lore"), null, null, null), 7);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 7);
}
if(player.hasPermission("fabledskyblock.island.upgrade")){
nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.ANVIL.getMaterial()), configLoad.getString("Menu.ControlPanel.Item.Upgrades.Displayname"),
configLoad.getStringList("Menu.ControlPanel.Item.Upgrades.Lore"), null, null, null), 15);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 15);
}
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Title")));
nInv.setRows(2);

View File

@ -151,13 +151,13 @@ public class Coop {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Coop.Item.Previous.Displayname")))) {
playerData.setPage(playerData.getPage() - 1);
playerData.setPage(MenuType.COOP, playerData.getPage(MenuType.COOP) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
'&', configLoad.getString("Menu.Coop.Item.Next.Displayname")))) {
playerData.setPage(playerData.getPage() + 1);
playerData.setPage(MenuType.COOP, playerData.getPage(MenuType.COOP) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -194,7 +194,7 @@ public class Coop {
Map<UUID, IslandCoop> coopPlayers = island.getCoopPlayers();
int playerMenuPage = playerData.getPage(), nextEndIndex = coopPlayers.size() - playerMenuPage * 36;
int playerMenuPage = playerData.getPage(MenuType.COOP), nextEndIndex = coopPlayers.size() - playerMenuPage * 36;
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Coop.Item.Exit.Displayname"), null, null, null, null), 0, 8);

View File

@ -303,7 +303,7 @@ public class Information {
if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
"Menu.Information.Members.Item.Previous.Displayname")))) {
playerData1.setPage(playerData1.getPage() - 1);
playerData1.setPage(MenuType.INFORMATION, playerData1.getPage(MenuType.INFORMATION) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock,
@ -311,7 +311,7 @@ public class Information {
} else if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad
.getString("Menu.Information.Members.Item.Next.Displayname")))) {
playerData1.setPage(playerData1.getPage() + 1);
playerData1.setPage(MenuType.INFORMATION, playerData1.getPage(MenuType.INFORMATION) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock,
@ -358,7 +358,7 @@ public class Information {
configLoad.getString("Menu.Information.Members.Item.Barrier.Displayname"), null, null, null,
null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
int playerMenuPage = playerData.getPage(),
int playerMenuPage = playerData.getPage(MenuType.INFORMATION),
nextEndIndex = displayedMembers.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
@ -464,7 +464,7 @@ public class Information {
if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
"Menu.Information.Visitors.Item.Previous.Displayname")))) {
playerData12.setPage(playerData12.getPage() - 1);
playerData12.setPage(MenuType.INFORMATION, playerData12.getPage(MenuType.INFORMATION) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock,
@ -472,7 +472,7 @@ public class Information {
} else if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad
.getString("Menu.Information.Visitors.Item.Next.Displayname")))) {
playerData12.setPage(playerData12.getPage() + 1);
playerData12.setPage(MenuType.INFORMATION, playerData12.getPage(MenuType.INFORMATION) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock,
@ -503,7 +503,7 @@ public class Information {
configLoad.getString("Menu.Information.Visitors.Item.Barrier.Displayname"), null, null,
null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
int playerMenuPage = playerData.getPage(),
int playerMenuPage = playerData.getPage(MenuType.INFORMATION),
nextEndIndex = displayedVisitors.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {

View File

@ -109,16 +109,22 @@ public class Leaderboard {
new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.Level.name())}, null,
null),
1);
nInv.addItem(
nInv.createItem(new ItemStack(Material.GOLD_INGOT), configLoad
.getString(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.Bank.name()),
configLoad.getStringList(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"),
new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.Bank.name())}, null,
null),
2);
if(fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")){
nInv.addItem(
nInv.createItem(new ItemStack(Material.GOLD_INGOT), configLoad
.getString(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname")
.replace("%leaderboard", Viewer.Type.Bank.name()),
configLoad.getStringList(
"Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"),
new Placeholder[]{new Placeholder("%leaderboard", Viewer.Type.Bank.name())}, null,
null),
2);
} else {
nInv.addItem(
nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), "", null, null, null, null), 2);
}
nInv.addItem(
nInv.createItem(new ItemStack(Material.EMERALD), configLoad
.getString(

View File

@ -146,12 +146,12 @@ public class Levelling {
PlayerData playerData1 = skyblock.getPlayerDataManager().getPlayerData(player);
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Previous.Displayname")))) {
playerData1.setPage(playerData1.getPage() - 1);
playerData1.setPage(MenuType.LEVELLING, playerData1.getPage(MenuType.LEVELLING) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Next.Displayname")))) {
playerData1.setPage(playerData1.getPage() + 1);
playerData1.setPage(MenuType.LEVELLING, playerData1.getPage(MenuType.LEVELLING) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -208,7 +208,7 @@ public class Levelling {
}
}
int playerMenuPage = playerData.getPage(), nextEndIndex = islandMaterials.size() - playerMenuPage * 36;
int playerMenuPage = playerData.getPage(MenuType.LEVELLING), nextEndIndex = islandMaterials.size() - playerMenuPage * 36;
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(), configLoad.getString("Menu.Levelling.Item.Exit.Displayname"), null, null, null, null), 0, 8);
nInv.addItem(nInv.createItem(CompatibleMaterial.FIREWORK_STAR.getItem(), configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Rescan.Lore"), null, null,

View File

@ -130,14 +130,14 @@ public class Members {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Members.Item.Previous.Displayname")))) {
playerData.setPage(playerData.getPage() - 1);
playerData.setPage(MenuType.MEMBERS, playerData.getPage(MenuType.MEMBERS) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(),
(Sort) playerData.getSort()), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
'&', configLoad.getString("Menu.Members.Item.Next.Displayname")))) {
playerData.setPage(playerData.getPage() + 1);
playerData.setPage(MenuType.MEMBERS, playerData.getPage(MenuType.MEMBERS) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(),
@ -319,7 +319,7 @@ public class Members {
}
}
int playerMenuPage = playerData.getPage(), nextEndIndex = displayedMembers.size() - playerMenuPage * 36;
int playerMenuPage = playerData.getPage(MenuType.MEMBERS), nextEndIndex = displayedMembers.size() - playerMenuPage * 36;
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Members.Item.Exit.Displayname"), null, null, null, null), 0, 8);

View File

@ -0,0 +1,14 @@
package com.songoda.skyblock.menus;
public enum MenuType {
ADMIN_LEVELLING,
ADMIN_CREATOR,
ADMIN_GENERATOR,
INFORMATION,
COOP,
LEVELLING,
MEMBERS,
BANS,
VISIT,
VISITORS
}

View File

@ -120,13 +120,13 @@ public class Visit {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Visit.Item.Previous.Displayname")))) {
playerData.setPage(playerData.getPage() - 1);
playerData.setPage(MenuType.VISIT, playerData.getPage(MenuType.VISIT) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Visit.Item.Next.Displayname")))) {
playerData.setPage(playerData.getPage() + 1);
playerData.setPage(MenuType.VISIT, playerData.getPage(MenuType.VISIT) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, (Type) playerData.getType(), (Sort) playerData.getSort()), 1L);
@ -330,7 +330,7 @@ public class Visit {
});
}
int playerMenuPage = playerDataManager.getPlayerData(player).getPage(),
int playerMenuPage = playerDataManager.getPlayerData(player).getPage(MenuType.VISIT),
nextEndIndex = visitIslands.size() - playerMenuPage * 36,
totalIslands = visitManager.getIslands().size();

View File

@ -95,13 +95,13 @@ public class Visitors {
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Visitors.Item.Previous.Displayname")))) {
playerData.setPage(playerData.getPage() - 1);
playerData.setPage(MenuType.VISITORS, playerData.getPage(MenuType.VISITORS) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
'&', configLoad.getString("Menu.Visitors.Item.Next.Displayname")))) {
playerData.setPage(playerData.getPage() + 1);
playerData.setPage(MenuType.VISITORS, playerData.getPage(MenuType.VISITORS) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -134,7 +134,7 @@ public class Visitors {
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
}
} else {
if (banningEnabled && ((isOperator && canBan) || isOwner)) {
if (banningEnabled && ((isOperator && canBan))) {
Bukkit.getServer().dispatchCommand(player, "island ban " + playerName);
} else {
soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F,
@ -159,24 +159,28 @@ public class Visitors {
Set<UUID> islandVisitors = islandManager.getVisitorsAtIsland(island);
Map<Integer, UUID> sortedIslandVisitors = new TreeMap<>();
for (UUID islandVisitorList : islandVisitors) {
Player targetPlayer = Bukkit.getPlayer(islandVisitorList);
if(targetPlayer != null && player.canSee(targetPlayer)){ // Remove vanished players
sortedIslandVisitors.put(
playerDataManager.getPlayerData(targetPlayer).getVisitTime(),
islandVisitorList);
}
}
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Visitors.Item.Exit.Displayname"), null, null, null, null), 0, 8);
nInv.addItem(
nInv.createItem(new ItemStack(Material.PAINTING),
configLoad.getString("Menu.Visitors.Item.Statistics.Displayname"),
configLoad.getStringList("Menu.Visitors.Item.Statistics.Lore"),
new Placeholder[]{new Placeholder("%visitors", "" + islandVisitors.size())}, null, null),
new Placeholder[]{new Placeholder("%visitors", "" + sortedIslandVisitors.size())}, null, null),
4);
nInv.addItem(
nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
configLoad.getString("Menu.Visitors.Item.Barrier.Displayname"), null, null, null, null),
9, 10, 11, 12, 13, 14, 15, 16, 17);
for (UUID islandVisitorList : islandVisitors) {
sortedIslandVisitors.put(
playerDataManager.getPlayerData(Bukkit.getServer().getPlayer(islandVisitorList)).getVisitTime(),
islandVisitorList);
}
islandVisitors.clear();
@ -184,7 +188,7 @@ public class Visitors {
islandVisitors.add(sortedIslandVisitors.get(sortedIslandVisitorList));
}
int playerMenuPage = playerData.getPage(), nextEndIndex = sortedIslandVisitors.size() - playerMenuPage * 36;
int playerMenuPage = playerData.getPage(MenuType.VISITORS), nextEndIndex = sortedIslandVisitors.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(

View File

@ -5,6 +5,7 @@ import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.menus.MenuType;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData;
@ -75,7 +76,7 @@ public class Creator implements Listener {
configLoad.getString("Menu.Admin.Creator.Browse.Item.Barrier.Displayname"), null, null, null, null),
9, 10, 11, 12, 13, 14, 15, 16, 17);
int playerMenuPage = playerData.getPage(), nextEndIndex = structures.size() - playerMenuPage * 36;
int playerMenuPage = playerData.getPage(MenuType.ADMIN_CREATOR), nextEndIndex = structures.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(

View File

@ -7,6 +7,8 @@ import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.generator.GeneratorManager;
import com.songoda.skyblock.generator.GeneratorMaterial;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.menus.MenuType;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData;
@ -74,7 +76,7 @@ public class Generator implements Listener {
configLoad.getString("Menu.Admin.Generator.Browse.Item.Barrier.Displayname"), null, null, null,
null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
int playerMenuPage = playerData.getPage(), nextEndIndex = generators.size() - playerMenuPage * 36;
int playerMenuPage = playerData.getPage(MenuType.ADMIN_GENERATOR), nextEndIndex = generators.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
@ -277,7 +279,7 @@ public class Generator implements Listener {
configLoad.getString("Island.Admin.Generator.Characters.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
generatorManager.addGenerator(event1.getName(), new ArrayList<>(), false);
generatorManager.addGenerator(event1.getName(), IslandWorld.Normal, new ArrayList<>(), false);
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Generator.Created.Message")
@ -393,7 +395,7 @@ public class Generator implements Listener {
&& (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Generator.Browse.Item.Previous.Displayname")))) {
playerData.setPage(playerData.getPage() - 1);
playerData.setPage(MenuType.ADMIN_GENERATOR, playerData.getPage(MenuType.ADMIN_GENERATOR) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
player.closeInventory();
@ -403,7 +405,7 @@ public class Generator implements Listener {
return;
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Generator.Browse.Item.Next.Displayname")))) {
playerData.setPage(playerData.getPage() + 1);
playerData.setPage(MenuType.ADMIN_GENERATOR, playerData.getPage(MenuType.ADMIN_GENERATOR) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
player.closeInventory();

View File

@ -7,6 +7,7 @@ import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
import com.songoda.skyblock.levelling.rework.LevellingMaterial;
import com.songoda.skyblock.menus.MenuType;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData;
@ -96,7 +97,7 @@ public class Levelling implements Listener {
configLoad.getString("Menu.Admin.Levelling.Item.Barrier.Displayname"), null, null, null, null),
9, 10, 11, 12, 13, 14, 15, 16, 17);
int playerMenuPage = playerData.getPage(), nextEndIndex = levellingMaterials.size() - playerMenuPage * 36;
int playerMenuPage = playerData.getPage(MenuType.ADMIN_LEVELLING), nextEndIndex = levellingMaterials.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
@ -178,6 +179,7 @@ public class Levelling implements Listener {
}
if (inventoryName.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Levelling.Title")))) {
event.setCancelled(true);
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
if (!(player.hasPermission("fabledskyblock.admin.level") || player.hasPermission("fabledskyblock.admin.*")
@ -185,7 +187,6 @@ public class Levelling implements Listener {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Levelling.Permission.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
event.setCancelled(true);
return;
}
@ -193,7 +194,6 @@ public class Levelling implements Listener {
&& (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Barrier.Displayname"))))) {
event.setCancelled(true);
soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
return;
@ -201,7 +201,6 @@ public class Levelling implements Listener {
&& (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Exit.Displayname"))))) {
event.setCancelled(true);
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
player.closeInventory();
@ -209,7 +208,6 @@ public class Levelling implements Listener {
} else if ((event.getCurrentItem().getType() == CompatibleMaterial.OAK_SIGN.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Information.Displayname"))))) {
event.setCancelled(true);
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
@ -271,7 +269,6 @@ public class Levelling implements Listener {
} else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Nothing.Displayname"))))) {
event.setCancelled(true);
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
@ -279,10 +276,9 @@ public class Levelling implements Listener {
&& (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Previous.Displayname")))) {
event.setCancelled(true);
player.closeInventory();
playerData.setPage(playerData.getPage() - 1);
playerData.setPage(MenuType.ADMIN_LEVELLING, playerData.getPage(MenuType.ADMIN_LEVELLING) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -290,10 +286,9 @@ public class Levelling implements Listener {
return;
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Next.Displayname")))) {
event.setCancelled(true);
player.closeInventory();
playerData.setPage(playerData.getPage() + 1);
playerData.setPage(MenuType.ADMIN_LEVELLING, playerData.getPage(MenuType.ADMIN_LEVELLING) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
@ -306,9 +301,9 @@ public class Levelling implements Listener {
for (LevellingMaterial materialList : levellingManager.getWorthsAsLevelingMaterials()) {
CompatibleMaterial materials = materialList.getMaterials();
if (event.getCurrentItem().getType() == CompatibleMaterial.getMaterial(materials.getMaterial()).getMaterial()
if (CompatibleMaterial.getMaterial(materials.getMaterial()) != null
&& event.getCurrentItem().getType().equals(CompatibleMaterial.getMaterial(materials.getMaterial()).getMaterial())
&& ChatColor.stripColor(is.getItemMeta().getDisplayName()).equals(materials.name())) {
event.setCancelled(true);
if (event.getClick() == ClickType.LEFT) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@ -411,8 +406,6 @@ public class Levelling implements Listener {
}
}
event.setCancelled(true);
CompatibleMaterial materials = CompatibleMaterial.getMaterial(event.getCurrentItem().getType());
if (NMSUtil.getVersionNumber() < 13) {

View File

@ -60,15 +60,6 @@ public abstract class BasicPermission {
return is;
}
/**
* Use this to check additional perms.
*
* @return
*/
public boolean overridingCheck() {
return true;
}
public String getName() {
return name;
}

View File

@ -81,6 +81,10 @@ public abstract class ListeningPermission extends BasicPermission {
public void onBlockIgnite(BlockIgniteEvent event) {}
protected void noPermsMessage(Player player, SkyBlock plugin, MessageManager messageManager) {
if(messageManager == null){ // TODO Check why this is null - Fabrimat
messageManager = SkyBlock.getInstance().getMessageManager();
}
messageManager.sendMessage(player,
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Settings.Permission.Message"));

View File

@ -1,6 +1,7 @@
package com.songoda.skyblock.permission;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.permission.event.Stoppable;
@ -8,9 +9,11 @@ import com.songoda.skyblock.permission.permissions.basic.*;
import com.songoda.skyblock.permission.permissions.listening.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
@ -26,86 +29,88 @@ public class PermissionManager {
public PermissionManager(SkyBlock plugin) {
this.plugin = plugin;
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> {
// Load default permissions.
registerPermissions(
//Listening
new StoragePermission(plugin),
new DragonEggUsePermission(plugin),
new BeaconPermission(plugin),
new ProjectilePermission(plugin),
new DestroyPermission(plugin),
new AnvilPermission(plugin),
new BedPermission(plugin),
new BrewingPermission(plugin),
new WorkbenchPermission(plugin),
new DoorPermission(plugin),
new EnchantPermission(plugin),
new FurnacePermission(plugin),
new LeverButtonPermission(plugin),
new JukeboxPermission(plugin),
new HopperPermission(plugin),
new NoteblockPermission(plugin),
new RedstonePermission(plugin),
new GatePermission(plugin),
new DropperDispenserPermission(plugin),
new BucketPermission(plugin),
new WaterCollectionPermission(plugin),
new SpawnEggPermission(plugin),
new EntityPlacementPermission(plugin),
new FirePermission(plugin),
new TramplePermission(plugin),
new PressurePlatePermission(plugin),
new CakePermission(plugin),
new PlacePermission(plugin),
new LeashPermission(plugin),
new AnimalBreedingPermission(plugin),
new MinecartPermission(plugin),
new BoatPermission(plugin),
new TradingPermission(plugin),
new MilkingPermission(plugin),
new ShearingPermission(plugin),
new MobRidingPermission(plugin),
new HorseInventoryPermission(plugin),
new MobHurtingPermission(plugin),
new ArmorStandUsePermission(plugin),
new MonsterHurtingPermission(plugin),
new PvpPermission(plugin),
new HangingDestroyPermission(plugin),
new DamagePermission(plugin),
new ExplosionsPermission(plugin),
new MobTamingPermission(plugin),
new MobGriefingPermission(plugin),
new ExperienceOrbPickupPermission(plugin),
new NaturalMobSpawningPermission(),
new HungerPermission(plugin),
new PortalPermission(plugin),
new ItemPickupPermission(),
new ItemDropPermission(),
new FishingPermission(plugin),
// Load default permissions.
registerPermissions( // TODO Reload them with /is admin reload - Fabrimat
//Listening
new StoragePermission(plugin),
new DragonEggUsePermission(plugin),
new BeaconPermission(plugin),
new ProjectilePermission(plugin),
new DestroyPermission(plugin),
new AnvilPermission(plugin),
new BedPermission(plugin),
new BrewingPermission(plugin),
new WorkbenchPermission(plugin),
new DoorPermission(plugin),
new EnchantPermission(plugin),
new FurnacePermission(plugin),
new LeverButtonPermission(plugin),
new JukeboxPermission(plugin),
new HopperPermission(plugin),
new NoteblockPermission(plugin),
new RedstonePermission(plugin),
new GatePermission(plugin),
new DropperDispenserPermission(plugin),
new BucketPermission(plugin),
new WaterCollectionPermission(plugin),
new SpawnEggPermission(plugin),
new EntityPlacementPermission(plugin),
new FirePermission(plugin),
new TramplePermission(plugin),
new PressurePlatePermission(plugin),
new CakePermission(plugin),
new PlacePermission(plugin),
new LeashPermission(plugin),
new AnimalBreedingPermission(plugin),
new MinecartPermission(plugin),
new BoatPermission(plugin),
new TradingPermission(plugin),
new MilkingPermission(plugin),
new ShearingPermission(plugin),
new MobRidingPermission(plugin),
new HorseInventoryPermission(plugin),
new MobHurtingPermission(plugin),
new ArmorStandUsePermission(plugin),
new MonsterHurtingPermission(plugin),
new PvpPermission(plugin),
new HangingDestroyPermission(plugin),
new DamagePermission(plugin),
new ExplosionsPermission(plugin),
new MobTamingPermission(plugin),
new MobGriefingPermission(plugin),
new ExperienceOrbPickupPermission(plugin),
new NaturalMobSpawningPermission(),
new PortalPermission(plugin),
new ItemPickupPermission(),
new ItemDropPermission(),
new FishingPermission(plugin),
// Basic
new MemberPermission(),
new VisitorPermission(),
new KickPermission(),
new BiomePermission(),
new KeepItemsOnDeathPermission(),
new UnbanPermission(),
new BanPermission(),
new BorderPermission(),
new FireSpreadPermission(),
new CoopPlayersPermission(),
new IslandPermission(),
new LeafDecayPermission(),
new WeatherPermission(),
new MainSpawnPermission(),
new VisitorSpawnPermission());
// Basic
new MemberPermission(),
new VisitorPermission(),
new KickPermission(),
new BiomePermission(),
new KeepItemsOnDeathPermission(),
new UnbanPermission(),
new BanPermission(),
new BorderPermission(),
new FireSpreadPermission(),
new CoopPlayersPermission(),
new IslandPermission(),
new LeafDecayPermission(),
new WeatherPermission(),
new MainSpawnPermission(),
new VisitorSpawnPermission());
registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> {
final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class);
return permissionHandler.priority().ordinal();
})).collect(Collectors.toList());
}, 20L);
if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")){
registerPermission(new HungerPermission(plugin));
}
registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> {
final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class);
return permissionHandler.priority().ordinal();
})).collect(Collectors.toList());
}
public boolean registerPermission(BasicPermission permission) {
@ -143,6 +148,10 @@ public class PermissionManager {
}
public boolean processPermission(Cancellable cancellable, Player player, Island island) {
return processPermission(cancellable, player, island, false);
}
public boolean processPermission(Cancellable cancellable, Player player, Island island, boolean reversePermission) {
if (island == null) return true;
for (HandlerWrapper wrapper : registeredHandlers) {
@ -154,7 +163,7 @@ public class PermissionManager {
BasicPermission permission = wrapper.getPermission();
if (permission.overridingCheck() || hasPermission(player, island, permission))
if (hasPermission(player, island, permission, reversePermission))
continue;
try {
@ -166,20 +175,37 @@ public class PermissionManager {
return true;
}
public boolean hasPermission(Player player, Island island, BasicPermission permission) {
public boolean hasPermission(Player player, Island island, BasicPermission permission, boolean reversePermission){
if (player == null)
return island.hasPermission(IslandRole.Owner, permission);
if (player.hasPermission("fabledskyblock.bypass." + permission.getName().toLowerCase()))
return true;
return !reversePermission;
if (island.hasPermission(island.getRole(player), permission))
return true;
FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (island.isCoopPlayer(player.getUniqueId()) && island.hasPermission(IslandRole.Coop, permission))
return true;
switch(island.getRole(player)){
case Owner:
if(!configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){
return island.hasPermission(IslandRole.Owner, permission);
}
case Operator:
if(!configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){
return island.hasPermission(IslandRole.Operator, permission);
}
case Member:
return island.hasPermission(IslandRole.Member, permission);
case Coop:
return island.hasPermission(IslandRole.Coop, permission);
case Visitor:
return island.hasPermission(IslandRole.Visitor, permission);
}
return false;
}
return island.hasPermission(IslandRole.Visitor, permission);
public boolean hasPermission(Player player, Island island, BasicPermission permission) {
return this.hasPermission(player, island, permission, false);
}
public boolean hasPermission(Location location, String permission, IslandRole islandRole) {

View File

@ -7,6 +7,7 @@ import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType;
import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -52,10 +53,10 @@ public class DamagePermission extends ListeningPermission {
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Settings.Damage.Enable"))
event.setCancelled(true);
else if (!configLoad.getBoolean("Island.Damage.Enable"))
if (configLoad.getBoolean("Island.Settings.Damage.Enable", false)
|| !configLoad.getBoolean("Island.Damage.Enable", false)) {
event.setCancelled(true);
}
}
@PermissionHandler
@ -67,9 +68,8 @@ public class DamagePermission extends ListeningPermission {
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Settings.Damage.Enable")) {
event.setCancelled(true);
} else if (!configLoad.getBoolean("Island.Damage.Enable")) {
if (configLoad.getBoolean("Island.Settings.Damage.Enable", false)
|| !configLoad.getBoolean("Island.Damage.Enable", false)) {
event.setCancelled(true);
}
}

View File

@ -1,53 +1,89 @@
package com.songoda.skyblock.permission.permissions.listening;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.Bukkit;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent;
public class ExplosionsPermission extends ListeningPermission {
private SkyBlock plugin;
public ExplosionsPermission(SkyBlock plugin) {
super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.GENERIC);
super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.ISLAND);
this.plugin = plugin;
}
@PermissionHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
public void onBlockExplode(BlockExplodeEvent event) {
event.setCancelled(true);
}
if (event.getDamager() instanceof TNTPrimed)
@PermissionHandler
public void onEntityExplode(EntityExplodeEvent event) {
event.setCancelled(true);
}
@PermissionHandler
public void onVehicleDamage(VehicleDamageEvent event) {
if (event.getAttacker() instanceof TNTPrimed
|| event.getAttacker() instanceof ExplosiveMinecart
|| event.getAttacker() instanceof Creeper)
event.setCancelled(true);
if (entity.getType() == EntityType.PLAYER
&& event.getDamager() instanceof TNTPrimed)
}
@PermissionHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
if (event.getAttacker() instanceof TNTPrimed
|| event.getAttacker() instanceof ExplosiveMinecart
|| event.getAttacker() instanceof Creeper)
event.setCancelled(true);
}
@PermissionHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_EXPLOSION)
|| event.getCause().equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)
|| event.getDamager() instanceof TNTPrimed
|| event.getDamager() instanceof ExplosiveMinecart
|| event.getDamager() instanceof Creeper)
event.setCancelled(true);
}
@PermissionHandler
public void onHangingBreak(HangingBreakEvent event) {
if (event.getCause() != HangingBreakEvent.RemoveCause.EXPLOSION)
return;
event.setCancelled(true);
if (event.getCause().equals(HangingBreakEvent.RemoveCause.EXPLOSION)) {
event.setCancelled(true);
}
}
@PermissionHandler
public void onBlockInteract(PlayerInteractEvent event) {
if (CompatibleMaterial.getMaterial(event.getPlayer().getItemInHand()) != CompatibleMaterial.FLINT_AND_STEEL)
return;
public void onHangingBreak(HangingBreakByEntityEvent event) {
if(event.getCause().equals(HangingBreakEvent.RemoveCause.EXPLOSION)){
event.setCancelled(true);
}
}
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
if (material == CompatibleMaterial.TNT)
@PermissionHandler
public void onTNTInteract(PlayerInteractEvent event) {
if(event.getItem().getType().equals(CompatibleMaterial.FLINT_AND_STEEL.getMaterial())
&& event.getClickedBlock().getType().equals(CompatibleMaterial.TNT.getBlockMaterial())){
cancelAndMessage(event, event.getPlayer(), plugin, plugin.getMessageManager());
}
}
}

View File

@ -21,12 +21,6 @@ public class HungerPermission extends ListeningPermission {
this.messageManager = plugin.getMessageManager();
}
@Override
public boolean overridingCheck() {
return plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable");
}
@PermissionHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
event.setCancelled(true);

View File

@ -2,43 +2,79 @@ package com.songoda.skyblock.permission.permissions.listening;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType;
import org.bukkit.entity.*;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent;
public class MobGriefingPermission extends ListeningPermission {
private final SkyBlock plugin;
private final MessageManager messageManager;
public MobGriefingPermission(SkyBlock plugin) {
super("MobGriefing", CompatibleMaterial.IRON_SHOVEL, PermissionType.ISLAND);
this.plugin = plugin;
this.messageManager = plugin.getMessageManager();
}
@PermissionHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof Player)
&& (!(event.getEntity() instanceof org.bukkit.entity.Projectile)
|| !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player))
&& !(event.getEntity() instanceof TNTPrimed)
&& !(event.getEntity() instanceof ExplosiveMinecart)) {
event.setCancelled(true);
}
}
@PermissionHandler
public void onVehicleDamage(VehicleDamageEvent event) {
Player player = (Player) event.getAttacker();
cancelAndMessage(event, player, plugin, messageManager);
if (!(event.getAttacker() instanceof Player)
&& (!(event.getAttacker() instanceof org.bukkit.entity.Projectile)
|| !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player))
&& !(event.getAttacker() instanceof TNTPrimed)
&& !(event.getAttacker() instanceof ExplosiveMinecart)) {
event.setCancelled(true);
}
}
@PermissionHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
Player player = (Player) event.getAttacker();
cancelAndMessage(event, player, plugin, messageManager);
if (!(event.getAttacker() instanceof Player)
&& (!(event.getAttacker() instanceof org.bukkit.entity.Projectile)
|| !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player))
&& !(event.getAttacker() instanceof TNTPrimed)
&& !(event.getAttacker() instanceof ExplosiveMinecart)) {
event.setCancelled(true);
}
}
@PermissionHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof Player)
&& (!(event.getDamager() instanceof org.bukkit.entity.Projectile)
|| !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player))
&& !(event.getDamager() instanceof TNTPrimed)
&& !(event.getDamager() instanceof ExplosiveMinecart)) {
event.setCancelled(true);
}
}
@PermissionHandler
public void onHangingBreak(HangingBreakByEntityEvent event) {
if(!(event.getRemover() instanceof Player)){
event.setCancelled(true);
}
}
/*@PermissionHandler // TODO ? - Fabrimat
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
EntityType type = event.getEntityType();
@ -53,6 +89,6 @@ public class MobGriefingPermission extends ListeningPermission {
else return;
cancelAndMessage(event, player, plugin, messageManager);
}
}*/
}

View File

@ -3,12 +3,16 @@ package com.songoda.skyblock.permission.permissions.listening;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.island.*;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType;
import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
import com.songoda.skyblock.utils.world.LocationUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
@ -26,29 +30,45 @@ public class PortalPermission extends ListeningPermission {
@PermissionHandler
public void onPortalEnter(PlayerEnterPortalEvent event) {
Player player = (Player) event.getEntity();
if(event.getEntity() instanceof Player){
Player player = (Player) event.getEntity();
cancelAndMessage(event, player, plugin, messageManager);
}
@PermissionHandler
public void onMove(PlayerMoveEvent event) {
CompatibleMaterial toMaterial = CompatibleMaterial.getMaterial(event.getTo().getBlock().getType());
if (toMaterial == CompatibleMaterial.NETHER_BRICK || toMaterial == CompatibleMaterial.END_PORTAL) {
event.setTo(LocationUtil.getRandomLocation(event.getFrom().getWorld(), 5000, 5000, true, true));
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
cancelAndMessage(event, player, plugin, messageManager);
Bukkit.getScheduler().runTask(plugin, () -> {
player.teleport(getToLocation(event.getLocation(), player));
});
}
}
@PermissionHandler
public void onTeleport(PlayerTeleportEvent event) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL
|| event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL
|| event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL
|| ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) &&
event.getCause() == PlayerTeleportEvent.TeleportCause.END_GATEWAY)
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL)
|| event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)
|| event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)
|| (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)
&& event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_GATEWAY))){
event.getPlayer().teleport(getToLocation(event.getFrom(), event.getPlayer()));
Location to = getToLocation(event.getFrom(), event.getPlayer());
Bukkit.getScheduler().runTask(plugin, () -> {
event.getPlayer().teleport(to);
});
event.setTo(to);
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
}
}
private Location getToLocation(Location from, Player player) {
IslandManager islandManager = plugin.getIslandManager();
Island island = islandManager.getIslandAtLocation(from);
Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){
to = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
if(to == null){
to = LocationUtil.getSpawnLocation();
}
}
return to;
}
}

View File

@ -0,0 +1,25 @@
package com.songoda.skyblock.playerdata;
import com.songoda.skyblock.menus.MenuType;
public class MenuPage {
MenuType type;
int page;
public MenuPage(MenuType type, int page){
this.type = type;
this.page = page;
}
public void setPage(int page){
this.page = page;
}
public MenuType getType(){
return type;
}
public int getPage(){
return page;
}
}

View File

@ -6,6 +6,7 @@ import com.songoda.skyblock.bank.Transaction;
import com.songoda.skyblock.bank.Type;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.confirmation.Confirmation;
import com.songoda.skyblock.menus.MenuType;
import com.songoda.skyblock.utils.structure.Area;
import org.bukkit.Bukkit;
@ -22,7 +23,7 @@ public class PlayerData {
private UUID islandOwnerUUID;
private UUID ownershipUUID;
private int page;
private List<MenuPage> pages;
private int playTime;
private int visitTime;
private int confirmationTime;
@ -45,7 +46,8 @@ public class PlayerData {
uuid = player.getUniqueId();
islandOwnerUUID = null;
page = 1;
pages = new ArrayList<>();
confirmationTime = 0;
playTime = getConfig().getFileConfiguration().getInt("Statistics.Island.Playtime");
@ -67,12 +69,23 @@ public class PlayerData {
}
}
public int getPage() {
return page;
public int getPage(MenuType type) {
for(MenuPage menu : pages){
if(menu.getType().equals(type)){
return menu.getPage();
}
}
return 1;
}
public void setPage(int page) {
this.page = page;
public void setPage(MenuType type, int page) {
for(MenuPage menu : pages){
if(menu.getType().equals(type)){
menu.setPage(page);
return;
}
}
pages.add(new MenuPage(type, page));
}
public Object getType() {

View File

@ -0,0 +1,93 @@
package com.songoda.skyblock.tasks;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.hologram.Hologram;
import com.songoda.skyblock.hologram.HologramType;
import com.songoda.skyblock.island.IslandLevel;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.leaderboard.Leaderboard;
import com.songoda.skyblock.leaderboard.LeaderboardManager;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.visit.Visit;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class MobNetherWaterTask extends BukkitRunnable {
private static MobNetherWaterTask instance;
private static SkyBlock plugin;
public MobNetherWaterTask(SkyBlock plug) {
plugin = plug;
}
public static MobNetherWaterTask startTask(SkyBlock plug) {
plugin = plug;
if (instance == null) {
instance = new MobNetherWaterTask(plugin);
instance.runTaskTimer(plugin, 0, 2L);
}
return instance;
}
@Override
public void run() {
FileManager fileManager = plugin.getFileManager();
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Nether.WaterDisappearWithNetherMobs", false)){
for(World world : Bukkit.getServer().getWorlds()){
if(plugin.getWorldManager().isIslandWorld(world) && plugin.getWorldManager().getIslandWorld(world).equals(IslandWorld.Nether)){
for(Entity ent : world.getEntities()) {
boolean witherSkeleton;
if (NMSUtil.getVersionNumber() > 10) {
witherSkeleton = ent.getType().equals(EntityType.WITHER_SKELETON);
} else {
witherSkeleton = ent instanceof Skeleton && ((Skeleton) ent).getSkeletonType().equals(Skeleton.SkeletonType.WITHER);
}
if (ent.getType().equals(EntityType.PIG_ZOMBIE) ||
ent.getType().equals(EntityType.BLAZE) ||
ent.getType().equals(EntityType.MAGMA_CUBE) ||
ent.getType().equals(EntityType.WITHER) ||
ent.getType().equals(EntityType.GHAST) ||
witherSkeleton) {
Block block = ent.getLocation().getBlock();
removeWater(world, block);
removeWater(world, block.getRelative(BlockFace.UP));
}
}
}
}
}
}
private void removeWater(World world, Block block) {
if (block.getType().equals(Material.WATER)) {
block.setType(Material.AIR, true);
block.getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f);
world.playEffect(block.getLocation(), Effect.SMOKE, 1);
}
}
public void onDisable() {
}
}

View File

@ -1,142 +0,0 @@
package com.songoda.skyblock.utils;
import com.google.common.collect.Lists;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.utils.NMSUtils;
import com.songoda.skyblock.SkyBlock;
import io.netty.channel.Channel;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.function.BiPredicate;
public final class SignMenuFactory {
private final Plugin plugin;
private static SignMenuFactory instance;
private Class signPacket = NMSUtils.getNMSClass("PacketPlayInUpdateSign");
private SignMenuFactory(Plugin plugin) {
this.plugin = plugin;
}
public static SignMenuFactory getInstance() {
return instance == null ? instance = new SignMenuFactory(SkyBlock.getInstance()) : instance;
}
public Menu newMenu() {
return new Menu(Lists.newArrayList("","","",""));
}
private void injectPlayer(Player player,Menu m) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException {
ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler(){
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg.getClass().equals(signPacket)) {
String[] lines;
Method getLines = msg.getClass().getMethod("c");
if (getLines == null) {
return;
}
lines = (String[])getLines.invoke(msg);
player.sendBlockChange(m.position, Material.AIR.createBlockData());
boolean success = m.response.test(player, lines);
if (!success && m.opensOnFail()) {
Bukkit.getScheduler().runTaskLater(plugin, () -> m.open(player), 2L);
}
removePlayer(player);
}
super.channelRead(ctx, msg);
}
};
Object handle = NMSUtils.getCraftClass("entity.CraftPlayer").getMethod("getHandle").invoke(player);
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
Object networkManager = playerConnection.getClass().getField("networkManager").get(playerConnection);
Channel channel = (Channel) networkManager.getClass().getField("channel").get(networkManager);
ChannelPipeline pipeline = channel.pipeline();
pipeline.addBefore("packet_handler",player.getName(),channelDuplexHandler);
}
private void removePlayer(Player player) throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
Object handle = NMSUtils.getCraftClass("entity.CraftPlayer").getMethod("getHandle").invoke(player);
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
Object networkManager = playerConnection.getClass().getField("networkManager").get(playerConnection);
Channel channel = (Channel) networkManager.getClass().getField("channel").get(networkManager);
ChannelPipeline pipeline = channel.pipeline();
channel.eventLoop().submit(() -> {
pipeline.remove(player.getName());
});
}
public class Menu {
private final List<String> text;
private BiPredicate<Player, String[]> response;
private boolean reopenIfFail;
private Location position;
Menu(List<String> text) {
this.text = text;
}
boolean opensOnFail() {
return this.reopenIfFail;
}
public Menu reopenIfFail() {
this.reopenIfFail = true;
return this;
}
public Menu response(BiPredicate<Player, String[]> response) {
this.response = response;
return this;
}
public void open(Player player) {
Objects.requireNonNull(player, "player");
this.position = player.getLocation().getBlock().getLocation();
player.sendBlockChange(this.position, CompatibleMaterial.OAK_SIGN.getBlockMaterial().createBlockData());
Class openSign = NMSUtils.getNMSClass("PacketPlayOutOpenSignEditor");
Class blockPosition = NMSUtils.getNMSClass("BlockPosition");
Object openSignPacket = null;
try {
Object blockPos = blockPosition.getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(position.getBlockX(), position.getBlockY(), position.getBlockZ());
openSignPacket = openSign.getConstructor(blockPosition).newInstance(blockPos);
}catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
e.printStackTrace();
}
NMSUtils.sendPacket(player,openSignPacket);
try {
injectPlayer(player,this);
} catch (NoSuchMethodException | IllegalAccessException | NoSuchFieldException | InvocationTargetException e) {
e.printStackTrace();
}
}
public List<String> getText() {
return text;
}
}
}

View File

@ -9,6 +9,7 @@ import com.songoda.skyblock.island.IslandEnvironment;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.utils.math.VectorUtil;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.*;
@ -25,6 +26,98 @@ import java.util.logging.Level;
public final class LocationUtil {
public static void removeWaterFromLoc(SkyBlock plugin, Location loc) {
if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Teleport.RemoveWater", false)){
Location tempLoc = LocationUtil.getDefinitiveLocation(loc);
if(tempLoc.getBlock().getType().equals(Material.WATER)){
tempLoc.getBlock().setType(Material.AIR);
} else if(NMSUtil.getVersionNumber() > 13){
LocationUtil113.removeWaterLoggedFromLocation(tempLoc);
}
}
}
public static Location getSafeLocation(Location loc){
boolean found = false;
Location locChecked = loc.clone();
loc.getWorld().loadChunk(loc.getWorld().getChunkAt(loc));
for(int i=loc.getBlockY(); i>=0 && !found; i--){
locChecked = locChecked.subtract(0d, 1d, 0d);
found = checkBlock(locChecked);
}
if(!found){
for(int i=loc.getBlockY(); i<256 && !found; i++){
locChecked = locChecked.add(0d, 1d, 0d);
found = checkBlock(locChecked);
}
}
if (found) {
locChecked = locChecked.add(0d,1d,0d);
} else {
locChecked = null;
}
return locChecked;
}
public static Location getDefinitiveLocation(Location loc){
Location locWorking = loc.clone();
for(int i=locWorking.getBlockY(); i>=0; i--){
if(!locWorking.getBlock().isEmpty()){
if(locWorking.getBlock().getType().equals(CompatibleMaterial.WATER.getMaterial()) ||
(NMSUtil.getVersionNumber() > 13 && locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
loc = locWorking;
}
break;
}
}
return loc;
}
private static boolean checkBlock(Location locChecked) {
boolean safe = false;
if(!locChecked.getBlock().isEmpty() &&
!locChecked.getBlock().isLiquid() &&
locChecked.getBlock().getType().isSolid() &&
locChecked.getBlock().getType().isBlock() &&
locChecked.add(0d,1d,0d).getBlock().getType().equals(CompatibleMaterial.AIR.getMaterial()) &&
locChecked.add(0d,2d,0d).getBlock().getType().equals(CompatibleMaterial.AIR.getMaterial()) &&
!(NMSUtil.getVersionNumber() >= 13 && locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
safe = true;
switch(CompatibleMaterial.getMaterial(locChecked.getBlock())){
case ACACIA_DOOR: // <= 1.8.8
case ACACIA_FENCE_GATE:
case BIRCH_DOOR:
case BIRCH_FENCE_GATE:
case CACTUS:
case CAKE:
case DARK_OAK_DOOR:
case DARK_OAK_FENCE_GATE:
case IRON_TRAPDOOR:
case JUNGLE_DOOR:
case JUNGLE_FENCE_GATE:
case LADDER:
case SPRUCE_DOOR:
case SPRUCE_FENCE_GATE:
case ACACIA_BUTTON:
case ACACIA_TRAPDOOR:
case BIRCH_TRAPDOOR:
case CAMPFIRE:
case COBWEB:
case DARK_OAK_TRAPDOOR:
case JUNGLE_TRAPDOOR:
case MAGMA_BLOCK:
case NETHER_PORTAL:
case OAK_DOOR:
case OAK_FENCE_GATE:
safe = false;
break;
}
}
return safe;
}
public static boolean isLocationLocation(Location location1, Location location2) {
return location1.getBlockX() == location2.getBlockX() && location1.getBlockY() == location2.getBlockY() && location1.getBlockZ() == location2.getBlockZ();
}

View File

@ -0,0 +1,13 @@
package com.songoda.skyblock.utils.world;
import org.bukkit.Location;
public class LocationUtil113 {
public static void removeWaterLoggedFromLocation(Location loc){
if(loc.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged){
org.bukkit.block.data.Waterlogged blockData = (org.bukkit.block.data.Waterlogged) loc.getBlock().getBlockData();
blockData.setWaterlogged(false);
loc.getBlock().setBlockData(blockData);
}
}
}

View File

@ -498,7 +498,10 @@ public final class EntityUtil {
}
public static boolean isMonster(EntityType type) {
switch (type) {
if (NMSUtil.getVersionNumber() > 10) {
if(type.equals(EntityType.WITHER_SKELETON)) return true; // TODO In < 11 we have SkeletonType.Wither
}
switch (type) { // TODO Check server versions
case BAT:
case BLAZE:
case CAVE_SPIDER:
@ -525,7 +528,6 @@ public final class EntityUtil {
case VINDICATOR:
case WITCH:
case WITHER:
case WITHER_SKELETON:
case ZOMBIE:
case ZOMBIE_VILLAGER:
return true;

View File

@ -32,10 +32,25 @@ Island:
# When enabled cooldown will start when a player deletes their Island.
Deletion:
Enable: true
# Time until player can create another island.
# Time in seconds until player can create another island.
Time: 60
# [!] How many seconds to wait before teleporting to a newly created island
TeleportTimeout: 1
# The distance between the islands EXPERIMENTAL!
Distance: 1200
Deletion:
# [!] You are adviced to keep these options both enabled to prevent any issues.
Cooldown:
# When enabled cooldown will start when a player creates an Island.
Creation:
Enable: true
# When enabled cooldown will start when a player deletes their Island.
Deletion:
Enable: true
# Time in seconds until player can delete their island.
Time: 60
ClearInventory: false
ClearEnderChest: false
World:
# Delete the Island world when changing the liquid option.
# If lava disabled, the world will be a water world.
@ -87,6 +102,8 @@ Island:
# Prevent blocks being placed that would go outside of the Island border
# Pistons | Dispensers | Liquid Flow
Block: true
# Enabled/Disabled by default
Default: false
Spawn:
# Prevents blocks being placed inside the location where players spawn on
# an Island. When setting the spawn points, this option when enabled will
@ -191,6 +208,8 @@ Island:
IncludeEmptyPointsInList: true
# Island Level Points divided by value
Division: 100
# Points to subtract to Island Level Points
Subtract: 1000
Cooldown:
# Time until Island level rescan expires
Time: 60
@ -280,6 +299,9 @@ Island:
Enable: true
Hunger:
Enable: false
# If owners and operators should have same permission of members
# It should be left to false as it could be changed soon
OwnersAndOperatorsAsMembers: false
Portal:
# When disabled, when a player enters a portal, they will teleport to the nether or
# end world rather than the island world.
@ -308,3 +330,60 @@ Island:
Challenge:
# Enable or disable challenges. Configuration for challenges are in challenges.yml file
Enable: true
# Disabling this will make challenges per player
PerIsland: true
Teleport:
# Enable or disable Fall damage
FallDamage: true
RemoveWater: true
Limits:
# Should slime split bypass limits.yml
AllowSlimeSplit: true
Nether:
# Allow placing water in the Nether
AllowNetherWater: false
# Water disappear when a nether mob walks into it
WaterDisappearWithNetherMobs: false
# Block water from flowing near nether mobs EXPERIMENTAL!
WaterDoNotFlowNearNetherMobs: false
# Make blaze immune from water in the Nether
BlazeImmuneToWaterInNether: false
Restrict:
# Blocks that can be placed only if the island has nether unlocked
NetherBlocks:
NETHERRACK: true
SOUL_SAND: true
GLOWSTONE: true
NETHER_BRICKS: true
NETHER_BRICK_STAIRS: true
NETHER_BRICK_SLAB: true
NETHER_QUARTZ_ORE: true
QUARTZ_BLOCK: true
QUARTZ_PILLAR: true
CHISELED_QUARTZ_BLOCK: true
QUARTZ_STAIRS: true
NETHER_BRICK_WALL: true
NETHER_BRICK_FENCE: true
RED_NETHER_BRICKS: true
RED_NETHER_BRICK_STAIRS: true
RED_NETHER_BRICK_SLAB: true
RED_NETHER_BRICK_WALL: true
NETHER_WART: true
NETHER_WART_BLOCK: true
WITHER_SKELETON_SKULL: true
WITHER_ROSE: true
# Blocks that can be placed only if the island has The End unlocked
EndBlocks:
END_STONE: true
END_STONE_BRICKS: true
END_STONE_BRICK_WALL: true
END_STONE_BRICK_STAIRS: true
END_STONE_BRICK_SLAB: true
PURPUR_BLOCK: true
PURPUR_SLAB: true
PURPUR_PILLAR: true
PURPUR_STAIRS: true
END_ROD: true
END_CRYSTAL: true
CHORUS_FLOWER: true
CHORUS_PLANT: true

View File

@ -1,6 +1,7 @@
Generators:
Default:
Name: Default
Normal:
Name: Normal
World: Normal
Permission: false
Materials:
COBBLESTONE:
@ -14,4 +15,22 @@ Generators:
EMERALD_ORE:
Chance: 5.5
DIAMOND_ORE:
Chance: 2.5
Chance: 2.5
Nether:
Name: Nether
World: Nether
Permission: false
Materials:
NETHERRACK:
Chance: 80
GLOWSTONE:
Chance: 10.0
QUARTZ_ORE:
Chance: 10.0
End:
Name: End
World: End
Permission: false
Materials:
END_STONE:
Chance: 100.0

View File

@ -433,6 +433,8 @@ Command:
Permission:
Message: '&bSkyBlock &8| &cError&8: &eYou do not have the right to delete your Island.'
Kick:
Bypass:
Message: '&bSkyBlock &8| &cError&8: &cYou can''t kick this user!'
Invalid:
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island kick <player>'
Role:
@ -766,6 +768,8 @@ Command:
Message: '&bSkyBlock &8| &aInfo&8: &eYou have banned the player &c%player &efrom the Island.'
Target:
Message: '&bSkyBlock &8| &aInfo&8: &eYou have been banned from the Island.'
Bypass:
Message: '&bSkyBlock &8| &cError&8: &cYou can''t ban this user!'
Already:
Message: '&bSkyBlock &8| &cError&8: &eThat player is already banned from the Island.'
Owner:
@ -905,6 +909,8 @@ Command:
Message: '&bSkyBlock &8| &aInfo&8: &eYou have been teleported to your Island.'
Other:
Message: '&bSkyBlock &8| &aInfo&8: &eYou have been teleported to &a%player''s &eIsland.'
Unsafe:
Message: '&bSkyBlock &8| &cError&8: &eNo safe position found'
Create:
Owner:
Message: '&bSkyBlock &8| &cError&8: &eYou are already an Island Owner.'
@ -988,6 +994,8 @@ Command:
Message: '&bSkyBlock &8| &cError&8: &eCategory not found.'
ChallengeNotFound:
Message: '&bSkyBlock &8| &cError&8: &eChallenge not found.'
NoIsland:
Message: '&bSkyBlock &8| &cError&8: &eYou don''t have an island.'
Preview:
Info:
Message: '&f&oAllows you to preview island before choosing'
@ -3462,6 +3470,12 @@ Island:
Message: '&bSkyBlock &8| &cError&8: &eThat Structure does not exist.'
File:
Message: '&bSkyBlock &8| &cError&8: &eThat file does not exist in the Structures directory.'
Deletion:
Cooldown:
Word:
Minute: minute(s)
Second: second(s)
Message: '&bSkyBlock &8| &cError&8: &eYou must wait &c&o%time &ebefore deleting an Island.'
Creator:
Selector:
Created:
@ -3578,6 +3592,10 @@ Island:
Message: '&bSkyBlock &8| &cError&8: &eYou need to pay to unlock the Nether. To do that use &7/island unlock nether&e This will cost ''&7$%cost%&e''.'
End:
Message: '&bSkyBlock &8| &cError&8: &eYou need to pay to unlock The End. To do that use &7/island unlock end&e This will cost ''&7$%cost%&e''.'
NetherBlocksPlace:
Message: '&bSkyBlock &8| &cError&8: &eYou need to pay to unlock the Nether in order to place this block.'
EndBlocksPlace:
Message: '&bSkyBlock &8| &cError&8: &eYou need to pay to unlock The End in order to place this block.'
Settings:
Visitor:
Welcome:

View File

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