Merge branch 'master' into dev-upgrades

This commit is contained in:
Fabrizio La Rosa 2020-06-20 21:57:11 +02:00
commit 80ced31cc8
72 changed files with 1591 additions and 1611 deletions

View File

@ -5,12 +5,13 @@ Forked from [FabledSkyBlock](https://gitlab.com/Songoda/fabledskyblock)
This fork contains bug fixes, features and improvements:
- Added option to check location security when using `/is visit`
- Added option to remove water from Island Spawn
- Added an option to toggle fall damage in certain conditions like when using `/is home`
- Added option to have Members, Operators and Owners all responding to Members settings as a temporary fix to Operators and Owners settings not being editable via GUI
- Added option to toggle fall damage in certain conditions like when using `/is home`
- Added per-world generator (editable only from generators.yml, GUI not supported yet)
- Added a "subtract" value to levels in order to have all the new islands to level 0
- Added option to set default WorldBorder status
- Added permissions for WorldBorder colors
- Added permission to bypass `/is kick`
- Added permissions to bypass kick and ban
- Added water in Nether mechanics!
- Added option to let slime splitting bypass limits.yml
- Added option to define distance between islands
@ -19,8 +20,17 @@ This fork contains bug fixes, features and improvements:
- Fixed bugs in Challenges that didn't remove all the items
- Fixed WorldBorder size not reflecting real island size
- Fixed bugs in island settings that prevented the from loading correctly
- Fixed mob grief setting
- Fixed explosion setting
- Fixed damage setting
- Fixed use portal setting
- Fixed bank that couldn't be opened from Members
- Fixed message telling that island disappeared on login
- Fixed GUI menus that had used the same page variable
- Fixed stackable bypassing break setting
- Now you can use `/is chat <message>` to send messages to island chat
- Now Challenges can be per-island too
- Now hunger setting works as intended
- Hide options in control panel if missing the permission
- Hide vanished players from visitors list
- Hide bank from leaderboard if disabled

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId>
<version>2.2.16-LaborPatch-0.0.3</version>
<version>2.3.3-DEV</version>
<packaging>jar</packaging>
<build>
<defaultGoal>clean install</defaultGoal>
@ -190,5 +190,11 @@
<version>LATEST</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.Zrips</groupId>
<artifactId>Residence</artifactId>
<scope>provided</scope>
<version>4.9.0.6</version>
</dependency>
</dependencies>
</project>

View File

@ -42,7 +42,6 @@ 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;
@ -112,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);
@ -277,6 +276,10 @@ public class SkyBlock extends SongodaPlugin {
return banManager;
}
public BankManager getBankManager() {
return bankManager;
}
public IslandManager getIslandManager() {
return islandManager;
}

View File

@ -459,7 +459,8 @@ public class Island {
*/
public void load() {
if (this.handle == null) {
this.handle = SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player);
SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player);
this.handle = SkyBlockAPI.getImplementation().getIslandManager().getIsland(player);
}
}

View File

@ -1,25 +1,29 @@
package com.songoda.skyblock.bank;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.hooks.EconomyManager;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
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 org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
public class BankManager {
private static BankManager instance;
public static BankManager getInstance() {return instance == null ? instance = new BankManager() : instance;}
private HashMap<UUID, List<Transaction>> log;
private final HashMap<UUID, List<Transaction>> log;
public FileConfiguration lang;
@ -31,14 +35,15 @@ public class BankManager {
loadTransactions();
}
public List<String> getTransactions(Player player) {
/*public List<String> getTransactions(Player player) {
if (log.containsKey(player.getUniqueId())&&log.get(player.getUniqueId())!=null&&!log.get(player.getUniqueId()).isEmpty()) {
List<String> lore = new ArrayList<>();
List<Transaction> transactions = log.get(player.getUniqueId());
int size = transactions.size()>10 ? 10 : transactions.size();
for (int i = 0;i<size;i++) {
Transaction t = transactions.get((transactions.size()-1)-i);
lore.add("#" + (i+1) + " " + t.timestamp.toString() +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
SimpleDateFormat formatDate = new SimpleDateFormat("dd/MM/yyyy HH:mm");
lore.add("#" + (i+1) + " " + formatDate.format(t.timestamp) +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
}
return lore;
}else {
@ -46,6 +51,20 @@ public class BankManager {
lore.add(lang.getString("Menu.Bank.Item.Log.Empty"));
return lore;
}
}*/
public List<Transaction> getTransactions(Player player) {
return getTransactions(player.getUniqueId());
}
public List<Transaction> getTransactions(UUID uuid) {
if (log.containsKey(uuid)
&& log.get(uuid) != null
&& !log.get(uuid).isEmpty()) {
return new ArrayList<>(log.get(uuid));
}else {
return new ArrayList<>();
}
}
public void addTransaction(Player p, Transaction transaction) {
@ -67,17 +86,100 @@ 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;
}
public List<Transaction> getTransactionList(Player player) {
return log.get(player.getUniqueId());
return getTransactionList(player.getUniqueId());
}
public List<Transaction> getTransactionList(UUID uuid) {
return log.get(uuid);
}
public BankResponse deposit(Player player, Island island, double amt, boolean admin) {
SkyBlock skyblock = SkyBlock.getInstance();
FileManager fileManager = skyblock.getFileManager();
// Make sure the amount is positive
if (amt <= 0) {
return BankResponse.NEGATIVE_AMOUNT;
}
// If decimals aren't allowed, check for them
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
int intAmt = (int) amt;
if (intAmt != amt) {
return BankResponse.DECIMALS_NOT_ALLOWED;
}
}
if(!admin) {
if (!EconomyManager.hasBalance(player, amt)) {
return BankResponse.NOT_ENOUGH_MONEY;
}
EconomyManager.withdrawBalance(player, amt);
}
island.addToBank(amt);
Transaction t = new Transaction();
t.player = player;
t.amount = (float) amt;
t.timestamp = Calendar.getInstance().getTime();
t.action = Transaction.Type.DEPOSIT;
t.visibility = admin ? Transaction.Visibility.ADMIN : Transaction.Visibility.USER;
this.addTransaction(player, t);
return BankResponse.SUCCESS;
}
public BankResponse withdraw(Player player, Island island, double amt, boolean admin) {
SkyBlock skyblock = SkyBlock.getInstance();
FileManager fileManager = skyblock.getFileManager();
// Make sure the amount is positive
if (amt <= 0) {
return BankResponse.NEGATIVE_AMOUNT;
}
// If decimals aren't allowed, check for them
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
int intAmt = (int) amt;
if (intAmt != amt) {
return BankResponse.DECIMALS_NOT_ALLOWED;
}
}
if(!admin){
if (amt > island.getBankBalance()) {
return BankResponse.NOT_ENOUGH_MONEY;
}
EconomyManager.deposit(player, amt);
}
island.removeFromBank(amt);
Transaction t = new Transaction();
t.player = player;
t.amount = (float) amt;
t.timestamp = Calendar.getInstance().getTime();
t.action = Transaction.Type.WITHDRAW;
t.visibility = admin ? Transaction.Visibility.ADMIN : Transaction.Visibility.USER;
this.addTransaction(player, t);
return BankResponse.SUCCESS;
}
public enum BankResponse{
NOT_ENOUGH_MONEY,
DECIMALS_NOT_ALLOWED,
NEGATIVE_AMOUNT,
SUCCESS
}
}

View File

@ -1,5 +1,6 @@
package com.songoda.skyblock.bank;
import com.songoda.skyblock.menus.Ownership;
import org.bukkit.OfflinePlayer;
import java.util.Date;
@ -7,7 +8,18 @@ import java.util.Date;
public class Transaction {
public OfflinePlayer player;
public float ammount;
public float amount;
public Date timestamp;
public Type action;
public Visibility visibility;
public enum Type {
WITHDRAW,
DEPOSIT
}
public enum Visibility {
ADMIN,
USER
}
}

View File

@ -1,6 +0,0 @@
package com.songoda.skyblock.bank;
public enum Type {
WITHDRAW,
DEPOSIT
}

View File

@ -6,6 +6,8 @@ import java.util.List;
import java.util.regex.Pattern;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.island.Island;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
@ -18,7 +20,6 @@ import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import com.songoda.skyblock.api.SkyBlockAPI;
import com.songoda.skyblock.api.island.Island;
public class Challenge {
private ChallengeCategory category;
@ -240,11 +241,12 @@ public class Challenge {
public boolean has(Player p, Object obj) {
// Check if the level of player's island is greater or equals to the required
// level
Island is = SkyBlockAPI.getIslandManager().getIsland(p);
Island is = SkyBlock.getInstance().getIslandManager().getIsland(p);
// Player doesn't have an island
if (is == null)
return false;
return is.getLevel().getLevel() >= (Integer) obj;
if (is != null && obj instanceof Number) {
return is.getLevel().getLevel() >= ((Number) obj).longValue();
}
return false;
}
@Override

View File

@ -4,10 +4,13 @@ import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.hooks.EconomyManager;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.gui.bank.GuiBank;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
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 org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
@ -15,15 +18,16 @@ import org.bukkit.entity.Player;
import java.io.File;
import java.util.Objects;
import java.util.UUID;
public class AdminBank extends SubCommand {
@Override
public void onCommandByPlayer(Player player, String[] args) {
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
MessageManager messageManager = skyblock.getMessageManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
@ -33,28 +37,21 @@ public class AdminBank extends SubCommand {
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
return;
}
if (args.length < 1) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.Short01.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true));
return;
}
if (island == null && args.length <2) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.NullIsland.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
switch (args[0]) {
switch (args[0].toLowerCase()) {
case "balance":
if (args.length <2) {
messageManager.sendMessage(player, Objects.requireNonNull(configLoad.getString("Command.Island.Admin.Bank.Balance.Message")).replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1])))));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(args[1])))));
}else {
messageManager.sendMessage(player, Objects.requireNonNull(configLoad.getString("Command.Island.Admin.Bank.Balance.Message")).replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID())))));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Balance.Message").replace("%player%", args[1]).replace("%bal%", "" + EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(island.getOwnerUUID())))));
}
return;
case "deposit":
@ -62,7 +59,7 @@ public class AdminBank extends SubCommand {
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Objects.requireNonNull(Bukkit.getPlayer(args[1])).getUniqueId())).addToBank(Double.parseDouble(args[2]));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message"));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
}
return;
case "withdraw":
@ -70,12 +67,33 @@ public class AdminBank extends SubCommand {
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message"));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
}
return;
case "open":
if(args.length == 2){
Player targetPlayer = Bukkit.getServer().getPlayer(args[1]);
UUID islandOwnerUUID;
if (targetPlayer == null) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[1]);
islandOwnerUUID = targetPlayerOffline.getOwner();
} else {
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
}
island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
}
if (island != null){
skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, true));
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.NullIsland.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
}
break;
default:
configLoad.getString("Command.Island.admin.Bank.Unexpected.Message");
return;
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.Unexpected.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
}
}
@ -101,7 +119,7 @@ public class AdminBank extends SubCommand {
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(sender, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message"));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
}
return;
case "withdraw":
@ -109,12 +127,11 @@ public class AdminBank extends SubCommand {
islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",EconomyManager.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(sender, configLoad.getString("Command.Island.admin.Bank.ByConsole.Message"));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
}
return;
default:
configLoad.getString("Command.Island.admin.Bank.Unexpected.Message");
return;
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.Unexpected.Message"));
}
}

View File

@ -68,7 +68,8 @@ public class DeleteCommand extends SubCommand {
configLoad.getString("Command.Island.Admin.Delete.Owner.Message"));
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
Island island = islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
Location spawnLocation = LocationUtil.getSpawnLocation();
if (spawnLocation != null && islandManager.isLocationAtIsland(island, spawnLocation)) {

View File

@ -8,6 +8,7 @@ import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
@ -39,9 +40,10 @@ public class ProxyCommand extends SubCommand {
if (args.length == 1) {
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
UUID islandOwnerUUID = targetPlayerOffline.getOwner();
if (islandManager.containsIsland(islandOwnerUUID)) {
if (islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID)) != null) {
if (islandManager.isPlayerProxyingAnotherPlayer(((Player)sender).getUniqueId())) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.Proxy.IsOffPlayer.Message")

View File

@ -79,7 +79,8 @@ public class SetBiomeCommand extends SubCommand {
biomeManager.setBiome(island, biome.getBiome());
island.setBiome(biome.getBiome());
} else {
Island island = islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
Island island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
if (island == null) {
messageManager.sendMessage(sender,
configLoad.getString("Command.Island.Admin.SetBiome.Island.Data.Message"));

View File

@ -2,7 +2,7 @@ package com.songoda.skyblock.command.commands.admin;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.menus.admin.Settings;
import com.songoda.skyblock.gui.permissions.GuiPermissionsSelector;
import com.songoda.skyblock.sound.SoundManager;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ public class SettingsCommand extends SubCommand {
public void onCommandByPlayer(Player player, String[] args) {
SoundManager soundManager = skyblock.getSoundManager();
Settings.getInstance().open(player, Settings.Type.Categories, null);
skyblock.getGuiManager().showGUI(player, new GuiPermissionsSelector(skyblock, null, null));
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
}

View File

@ -62,8 +62,8 @@ public class AcceptCommand extends SubCommand {
island = islandManager
.getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
} else {
island = islandManager
.loadIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
unloadIsland = true;
}
@ -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

@ -1,17 +1,14 @@
package com.songoda.skyblock.command.commands.island;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.hooks.EconomyManager;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.gui.bank.GuiBank;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.menus.Bank;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.NumberUtil;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@ -23,8 +20,8 @@ public class BankCommand extends SubCommand {
@Override
public void onCommandByPlayer(Player player, String[] args) {
MessageManager messageManager = skyblock.getMessageManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
IslandManager islandManager = skyblock.getIslandManager();
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
@ -36,7 +33,16 @@ public class BankCommand extends SubCommand {
return;
}
Bank.getInstance().open(player);
Island island;
island = islandManager.getIsland(player);
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"));
return;
}
skyblock.getGuiManager().showGUI(player, new GuiBank(skyblock, island, null, false));
}
@Override

View File

@ -72,10 +72,8 @@ public class KickCommand extends SubCommand {
targetPlayerName = targetPlayer.getName();
}
assert targetPlayer != null;
if(targetPlayer.hasPermission("fabledskyblock.bypass.kick") && islandVisitors.contains(targetPlayer.getUniqueId())){
// messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Exempt")); // TODO
messageManager.sendMessage(player, "&cNon puoi cacciare questo utente!");
if(targetPlayer != null && (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"));
@ -86,7 +84,7 @@ public class KickCommand extends SubCommand {
} else if (island.getOwnerUUID().equals(targetPlayerUUID)) {
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) {
} else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID)) {
if (island.isCoopPlayer(targetPlayerUUID)) {
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Cooped.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
@ -143,7 +141,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

@ -3,14 +3,11 @@ package com.songoda.skyblock.command.commands.island;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.gui.GuiPermissions;
import com.songoda.skyblock.gui.GuiPermissionsSelector;
import com.songoda.skyblock.gui.permissions.GuiPermissionsSelector;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.menus.Settings;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionManager;
import com.songoda.skyblock.sound.SoundManager;
import org.bukkit.command.ConsoleCommandSender;

View File

@ -40,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) {

View File

@ -98,7 +98,7 @@ public class FileManager {
}
if (configFile.exists()) {
if (fileName.equals("config.yml") || fileName.equals("language.yml") || fileName.equals("settings.yml") || fileName.equals("worlds.yml")) {
if (fileName.equals("config.yml") || fileName.equals("language.yml") || fileName.equals("worlds.yml")) {
FileChecker fileChecker;
if (fileName.equals("config.yml")) {

View File

@ -0,0 +1,206 @@
package com.songoda.skyblock.gui.bank;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.gui.AnvilGui;
import com.songoda.core.gui.Gui;
import com.songoda.core.gui.GuiManager;
import com.songoda.core.gui.GuiUtils;
import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.bank.BankManager;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.gui.GuiSignatureEditor;
import com.songoda.skyblock.gui.GuiWelcomeEditor;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandMessage;
import com.songoda.skyblock.island.IslandPermission;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.BasicPermission;
import com.songoda.skyblock.permission.PermissionManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.visit.Visit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class GuiBank extends Gui {
private final SkyBlock plugin;
private final BankManager bankManager;
private final PermissionManager permissionManager;
private final Island island;
private final FileConfiguration languageLoad;
private final FileConfiguration config;
private final Gui returnGui;
private final boolean admin;
public GuiBank(SkyBlock plugin, Island island, Gui returnGui, boolean admin) {
super(2, returnGui);
this.plugin = plugin;;
this.bankManager = plugin.getBankManager();
this.permissionManager = plugin.getPermissionManager();
this.island = island;
this.returnGui = returnGui;
this.admin = admin;
this.languageLoad = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
setTitle(TextUtils.formatText("Bank"));
paint();
}
@Override
public void onOpen(GuiManager manager, Player player) {
updateItem(13, // Balance
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Displayname")),
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Lore")
.replace("%balance", String.valueOf(island.getBankBalance()))));
super.onOpen(manager, player);
}
public void paint() {
if (inventory != null)
inventory.clear();
setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
setActionForRange(0, 0, 1, 8, null);
setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> {
CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player);
event.player.closeInventory();
});
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> {
CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player);
event.player.closeInventory();
});
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.BOOK, // Transaction log
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Log.Displayname"))), (event) -> {
guiManager.showGUI(event.player, new GuiBankTransaction(plugin, island, this, admin));
});
setButton(10, GuiUtils.createButtonItem(CompatibleMaterial.RED_DYE, // Deposit
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Deposit.Displayname"))), (event -> {
AnvilGui gui = new AnvilGui(event.player, this);
gui.setAction((e -> {
MessageManager messageManager = plugin.getMessageManager();
double amount;
try {
amount = Double.parseDouble(gui.getInputText().trim());
} catch (NumberFormatException e1) {
messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short4.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(e.player);
return;
}
BankManager.BankResponse response = bankManager.deposit(e.player, island, amount, admin);
switch(response){
case NOT_ENOUGH_MONEY:
messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short2.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(e.player);
break;
case DECIMALS_NOT_ALLOWED:
messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short6.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(e.player);
break;
case NEGATIVE_AMOUNT:
messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short5.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(e.player);
break;
case SUCCESS:
CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(e.player);
messageManager.sendMessage(e.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank.Deposit.Message")).replace(
"%amount%", NumberUtil.formatNumberByDecimal(amount)));
break;
}
e.player.closeInventory();
// paint();
guiManager.showGUI(event.player, this);
}));
ItemStack input = CompatibleMaterial.PAPER.getItem();
ItemMeta im = input.getItemMeta();
if(im != null){
im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Amount")));
input.setItemMeta(im);
}
gui.setInput(input);
gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Deposit")));
guiManager.showGUI(event.player, gui);
}));
setItem(13, GuiUtils.createButtonItem(CompatibleMaterial.GOLD_INGOT, // Balance
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Displayname")),
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Balance.Lore")
.replace("%balance", String.valueOf(island.getBankBalance())))));
setButton(16, GuiUtils.createButtonItem(CompatibleMaterial.GREEN_DYE, // WithDraw
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Withdraw.Displayname"))), (event) -> {
AnvilGui gui = new AnvilGui(event.player, this);
gui.setAction((e -> {
MessageManager messageManager = plugin.getMessageManager();
double amount;
try {
amount = Double.parseDouble(gui.getInputText().trim());
} catch (NumberFormatException e1) {
messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short4.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(e.player);
return;
}
BankManager.BankResponse response = bankManager.withdraw(e.player, island, amount, admin);
switch(response){
case NOT_ENOUGH_MONEY:
messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short2.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(e.player);
break;
case DECIMALS_NOT_ALLOWED:
messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short6.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(e.player);
break;
case NEGATIVE_AMOUNT:
messageManager.sendMessage(e.player, languageLoad.getString("Command.Island.Bank.Short5.Message"));
CompatibleSound.BLOCK_ANVIL_LAND.play(e.player);
break;
case SUCCESS:
CompatibleSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(e.player);
messageManager.sendMessage(e.player, Objects.requireNonNull(languageLoad.getString("Command.Island.Bank.Withdraw.Message")).replace(
"%amount%", NumberUtil.formatNumberByDecimal(amount)));
break;
}
e.player.closeInventory();
// paint();
guiManager.showGUI(event.player, this);
}));
ItemStack input = CompatibleMaterial.PAPER.getItem();
ItemMeta im = input.getItemMeta();
if(im != null){
im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Amount")));
input.setItemMeta(im);
}
gui.setInput(input);
gui.setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Words.Withdraw")));
guiManager.showGUI(event.player, gui);
});
}
}

View File

@ -0,0 +1,173 @@
package com.songoda.skyblock.gui.bank;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.gui.Gui;
import com.songoda.core.gui.GuiUtils;
import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.bank.BankManager;
import com.songoda.skyblock.bank.Transaction;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
public class GuiBankTransaction extends Gui {
private final SkyBlock plugin;
private final BankManager bankManager;
private final FileConfiguration languageLoad;
private final FileManager.Config config;
private final Gui returnGui;
private final int transactions;
private final List<Transaction> transactionList;
private final boolean admin;
public GuiBankTransaction(SkyBlock plugin, Island island, Gui returnGui, boolean admin) {
super(returnGui);
this.plugin = plugin;
this.bankManager = plugin.getBankManager();
this.transactionList = bankManager.getTransactions(island.getOwnerUUID());
this.transactions = this.transactionList.size();
this.returnGui = returnGui;
this.admin = admin;
this.languageLoad = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
if(transactions == 0){
setRows(2);
} else if(transactions > 4*9){
setRows(6);
} else {
setRows((int) (Math.ceil((double) transactions / 9d)+1));
}
setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Title")));
setDefaultItem(null);
paint();
}
public void paint() {
if (inventory != null)
inventory.clear();
setActionForRange(0, 0, 1, 8, null);
setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> {
CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player);
guiManager.showGUI(event.player, returnGui);
});
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE, // Exit
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Exit.Displayname"))), (event) -> {
CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player);
guiManager.showGUI(event.player, returnGui);
});
setItem(4, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING, // Info
TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Info.Displayname")),
TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Info.Lore")
.replace("%totalTransactions", String.valueOf(transactions)))));
if(transactions > 0){
this.pages = (int) Math.max(1, Math.ceil((double) transactions / 36d));
if (page != 1)
setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Last.Displayname"))),
(event) -> {
page--;
paint();
});
if (page != pages)
setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Next.Displayname"))),
(event) -> {
page++;
paint();
});
for (int i = 9; i < ((getRows()-1)*9)+9; i++) { // TODO check dynamic dimension!
int current = ((page - 1) * 36) - 9;
if (current + i >= transactions) {
setItem(i, null);
continue;
}
Transaction transaction = transactionList.get(current + i);
if (transaction == null) continue;
ItemStack is = null;
ItemMeta im;
String name = "";
SimpleDateFormat formatDate = new SimpleDateFormat(languageLoad.getString("Menu.Bank.Item.Transactions.DateTimeFormat", "dd/MM/yyyy HH:mm:ss"));
switch(transaction.action){
case WITHDRAW:
is = CompatibleMaterial.RED_DYE.getItem();
im = is.getItemMeta();
if(im != null){
im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.DisplayName")
.replace("%dateTime", formatDate.format(transaction.timestamp))));
List<String> lore = new ArrayList<>();
switch (transaction.visibility){
case ADMIN:
name = languageLoad.getString("Menu.Bank.Word.Admin");
if(admin){
name += " " + transaction.player.getName();
}
break;
case USER:
name = transaction.player.getName();
break;
}
lore.add(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Withdraw.Format")
.replace("%playerName", name)
.replace("%amount", String.valueOf(transaction.amount))));
im.setLore(lore);
is.setItemMeta(im);
}
break;
case DEPOSIT:
is = CompatibleMaterial.GREEN_DYE.getItem();
im = is.getItemMeta();
if(im != null){
im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Bank.Item.Transactions.Deposit.DisplayName")
.replace("%dateTime", formatDate.format(transaction.timestamp))));
List<String> lore = new ArrayList<>();
switch (transaction.visibility){
case ADMIN:
name = languageLoad.getString("Menu.Bank.Word.Admin");
if(admin){
name += transaction.player.getName();
}
break;
case USER:
name = transaction.player.getName();
break;
}
lore.add(TextUtils.formatText(languageLoad.getString("Menu.Bank.Transactions.Deposit.Format")
.replace("%playerName", name)
.replace("%amount", String.valueOf(transaction.amount))));
im.setLore(lore);
is.setItemMeta(im);
}
break;
}
setItem(i, is);
}
} else {
setItem(31, CompatibleMaterial.BARRIER.getItem());
}
}
}

View File

@ -0,0 +1,126 @@
package com.songoda.skyblock.gui.permissions;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.gui.Gui;
import com.songoda.core.gui.GuiUtils;
import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandPermission;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.permission.BasicPermission;
import com.songoda.skyblock.permission.PermissionManager;
import com.songoda.skyblock.permission.PermissionType;
import com.songoda.skyblock.visit.Visit;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class GuiAdminPermissions extends Gui {
private final PermissionManager permissionManager;
private final IslandRole role;
private final FileConfiguration configLoad;
private final FileManager.Config settingsConfig;
private final FileConfiguration settingsConfigLoad;
private final Gui returnGui;
public GuiAdminPermissions(SkyBlock plugin, IslandRole role, Gui returnGui) {
super(6, returnGui);
this.permissionManager = plugin.getPermissionManager();
this.role = role;
this.returnGui = returnGui;
this.configLoad = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
settingsConfig = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "settings.yml"));
settingsConfigLoad = settingsConfig.getFileConfiguration();
setTitle(TextUtils.formatText(configLoad.getString("Menu.Settings." + role.name() + ".Title")));
setDefaultItem(null);
paint();
}
public void paint() {
if (inventory != null)
inventory.clear();
setActionForRange(0, 0, 5, 9, null);
setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE,
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> {
CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player);
guiManager.showGUI(event.player, returnGui);
});
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE,
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> {
CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player);
guiManager.showGUI(event.player, returnGui);
});
List<BasicPermission> permissions = permissionManager.getPermissions().stream()
.filter(p -> p.getType() == getType(role))
.collect(Collectors.toList());
double itemCount = permissions.size();
this.pages = (int) Math.max(1, Math.ceil(itemCount / 36));
if (page != 1)
setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Last.Displayname"))),
(event) -> {
page--;
paint();
});
if (page != pages)
setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Next.Displayname"))),
(event) -> {
page++;
paint();
});
for (int i = 9; i < 45; i++) {
int current = ((page - 1) * 36) - 9;
if (current + i >= permissions.size()) {
setItem(i, null);
continue;
}
BasicPermission permission = permissions.get(current + i);
if (permission == null) continue;
final String path = "Settings." + role.name() + "." + permission.getName();
boolean setting = settingsConfigLoad.getBoolean(path);
setButton(i, permission.getItem(setting, role), (event) -> {
settingsConfigLoad.set(path, !setting);
try {
settingsConfigLoad.save(settingsConfig.getFile());
} catch (IOException e) {
e.printStackTrace();
}
paint();
});
}
}
public PermissionType getType(IslandRole role) {
switch (role) {
default:
case Visitor:
case Member:
case Coop:
return PermissionType.GENERIC;
case Operator:
return PermissionType.OPERATOR;
case Owner:
return PermissionType.ISLAND;
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.skyblock.gui;
package com.songoda.skyblock.gui.permissions;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
@ -7,6 +7,8 @@ import com.songoda.core.gui.GuiUtils;
import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.gui.GuiSignatureEditor;
import com.songoda.skyblock.gui.GuiWelcomeEditor;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandPermission;
import com.songoda.skyblock.island.IslandRole;
@ -24,7 +26,7 @@ import java.util.stream.Collectors;
public class GuiPermissions extends Gui {
private SkyBlock plugin;
private final SkyBlock plugin;
private final PermissionManager permissionManager;
private final IslandRole role;
private final Island island;
@ -63,17 +65,13 @@ public class GuiPermissions extends Gui {
setButton(5, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Welcome.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu.Settings.Visitor.Item.Welcome.Lore"))),
(event) -> {
guiManager.showGUI(event.player, new GuiWelcomeEditor(plugin, this, island));
});
(event) -> guiManager.showGUI(event.player, new GuiWelcomeEditor(plugin, this, island)));
if (config.getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) {
setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Signature.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu.Settings.Visitor.Item.Signature.Lore"))),
(event) -> {
guiManager.showGUI(event.player, new GuiSignatureEditor(plugin, this, island));
});
(event) -> guiManager.showGUI(event.player, new GuiSignatureEditor(plugin, this, island)));
}
Visit visit = island.getVisit();

View File

@ -1,4 +1,4 @@
package com.songoda.skyblock.gui;
package com.songoda.skyblock.gui.permissions;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
@ -11,54 +11,68 @@ import com.songoda.skyblock.island.IslandRole;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
public class GuiPermissionsSelector extends Gui {
public GuiPermissionsSelector(SkyBlock plugin, Island island, Gui returnGui) {
public GuiPermissionsSelector(@Nonnull SkyBlock plugin, @Nullable Island island, @Nullable Gui returnGui) {
super(1, returnGui);
setDefaultItem(null);
String admin = island == null ? "Admin." : "";
FileConfiguration configLoad = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
setTitle(ChatColor.translateAlternateColorCodes('&',
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Title"))));
TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Title"))));
setButton(2, GuiUtils.createButtonItem(CompatibleMaterial.OAK_SIGN,
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Visitor.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Visitor.Lore"))), (event) ->
guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Visitor, this)));
TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Visitor.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Visitor.Lore"))), (event) ->
guiManager.showGUI(event.player, island == null ?
new GuiAdminPermissions(plugin, IslandRole.Visitor, this) :
new GuiPermissions(plugin, island, IslandRole.Visitor, this)));
setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING,
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Member.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Member.Lore"))), (event) ->
guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Member, this)));
TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Member.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Member.Lore"))), (event) ->
guiManager.showGUI(event.player, island == null ?
new GuiAdminPermissions(plugin, IslandRole.Member, this) :
new GuiPermissions(plugin, island, IslandRole.Member, this)));
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.ITEM_FRAME,
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Operator.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Operator.Lore"))), (event) ->
guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Operator, this)));
TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Operator.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Operator.Lore"))), (event) ->
guiManager.showGUI(event.player, island == null ?
new GuiAdminPermissions(plugin, IslandRole.Operator, this) :
new GuiPermissions(plugin, island, IslandRole.Operator, this)));
boolean isCoop = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Coop.Enable");
setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE,
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))), (event) -> {
TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Exit.Displayname"))), (event) -> {
CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player);
event.player.closeInventory();
});
if (isCoop)
setButton(6, GuiUtils.createButtonItem(CompatibleMaterial.NAME_TAG,
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Coop.Displayname")),
TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Coop.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Coop.Lore"))), (event) ->
guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Coop, this)));
guiManager.showGUI(event.player, island == null ?
new GuiAdminPermissions(plugin, IslandRole.Coop, this) :
new GuiPermissions(plugin, island, IslandRole.Coop, this)));
setButton(isCoop ? 7 : 8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_SAPLING.getItem(),
TextUtils.formatText(configLoad.getString("Menu.Settings.Categories.Item.Owner.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu.Settings.Categories.Item.Owner.Lore"))), (event) ->
guiManager.showGUI(event.player, new GuiPermissions(plugin, island, IslandRole.Owner, this)));
TextUtils.formatText(configLoad.getString("Menu." + admin + "Settings.Categories.Item.Owner.Displayname")),
TextUtils.formatText(configLoad.getStringList("Menu." + admin + "Settings.Categories.Item.Owner.Lore"))), (event) ->
guiManager.showGUI(event.player, island == null ?
new GuiAdminPermissions(plugin, IslandRole.Owner, this) :
new GuiPermissions(plugin, island, IslandRole.Owner, this)));
}
}

View File

@ -26,6 +26,7 @@ import org.bukkit.WeatherType;
import org.bukkit.block.Biome;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.io.File;
import java.io.IOException;
@ -561,6 +562,9 @@ public class Island {
}
public IslandRole getRole(OfflinePlayer player) {
if(isCoopPlayer(player.getUniqueId())){
return IslandRole.Coop; // TODO Rework Coop status - Fabrimat
}
for (IslandRole role : IslandRole.values())
if (getRole(role).contains(player.getUniqueId()))
return role;
@ -832,7 +836,7 @@ public class Island {
this.deleted = deleted;
}
public void save() {
public synchronized void save() {
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager
@ -885,7 +889,7 @@ public class Island {
getLevel().save();
}
public boolean isRegionUnlocked(Player player, String type) {
public boolean isRegionUnlocked(Player player, IslandWorld type) {
FileManager fileManager = skyblock.getFileManager();
SoundManager soundManager = skyblock.getSoundManager();
MessageManager messageManager = skyblock.getMessageManager();
@ -895,22 +899,26 @@ public class Island {
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
ownerUUID.toString() + ".yml"));
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
double price = configLoad.getDouble("Island.World." + type + ".UnlockPrice");
double price = configLoad.getDouble("Island.World." + type.name() + ".UnlockPrice");
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type);
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type.name());
if (price == -1) {
configLoadIslandData.set("Unlocked." + type, true);
configLoadIslandData.set("Unlocked." + type.name(), true);
unlocked = true;
}
if (!unlocked) {
messageManager.sendMessage(player,
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
.getString("Island.Unlock." + type + ".Message").replace(
.getString("Island.Unlock." + type.name() + ".Message").replace(
"%cost%", NumberUtil.formatNumberByDecimal(price)));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
player.setVelocity(player.getLocation().getDirection().multiply(-.50));
if(type.equals(IslandWorld.End)){
player.setVelocity(player.getLocation().getDirection().multiply(-.50).setY(.6f));
} else if(type.equals(IslandWorld.Nether)) {
player.setVelocity(player.getLocation().getDirection().multiply(-.50));
}
}
return unlocked;
}

View File

@ -1,5 +1,9 @@
package com.songoda.skyblock.island;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.api.ResidenceApi;
import com.bekvon.bukkit.residence.containers.Flags;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import com.google.common.base.Preconditions;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
@ -47,6 +51,7 @@ 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.Plugin;
import java.io.File;
import java.io.IOException;
@ -97,7 +102,7 @@ public class IslandManager {
}
}
public void saveNextAvailableLocation(IslandWorld world) {
public synchronized void saveNextAvailableLocation(IslandWorld world) {
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "worlds.yml"));
@ -119,7 +124,7 @@ public class IslandManager {
}
}
public void setNextAvailableLocation(IslandWorld world, org.bukkit.Location location) {
public synchronized void setNextAvailableLocation(IslandWorld world, org.bukkit.Location location) {
for (IslandPosition islandPositionList : islandPositions) {
if (islandPositionList.getWorld() == world) {
islandPositionList.setX(location.getX());
@ -129,7 +134,7 @@ public class IslandManager {
}
public org.bukkit.Location prepareNextAvailableLocation(IslandWorld world) {
public synchronized org.bukkit.Location prepareNextAvailableLocation(IslandWorld world) {
for (IslandPosition islandPositionList : islandPositions) {
if (islandPositionList.getWorld() == world) {
@ -191,7 +196,7 @@ public class IslandManager {
return null;
}
public boolean createIsland(Player player, Structure structure) {
public synchronized boolean createIsland(Player player, Structure structure) {
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
VisitManager visitManager = skyblock.getVisitManager();
FileManager fileManager = skyblock.getFileManager();
@ -291,7 +296,7 @@ public class IslandManager {
return true;
}
public boolean previewIsland(Player player, Structure structure) {
public synchronized boolean previewIsland(Player player, Structure structure) {
FileManager fileManager = skyblock.getFileManager();
PlayerData data = skyblock.getPlayerDataManager().getPlayerData(player);
@ -402,7 +407,7 @@ public class IslandManager {
return true;
}
public void giveOwnership(Island island, org.bukkit.OfflinePlayer player) {
public synchronized void giveOwnership(Island island, org.bukkit.OfflinePlayer player) {
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
CooldownManager cooldownManager = skyblock.getCooldownManager();
FileManager fileManager = skyblock.getFileManager();
@ -524,7 +529,7 @@ public class IslandManager {
}
}
public boolean deleteIsland(Island island, boolean force) {
public synchronized boolean deleteIsland(Island island, boolean force) {
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
CooldownManager cooldownManager = skyblock.getCooldownManager();
@ -652,7 +657,7 @@ public class IslandManager {
return true;
}
public void deleteIslandData(UUID uuid) {
public synchronized void deleteIslandData(UUID uuid) {
FileManager fileManager = skyblock.getFileManager();
fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml"));
fileManager.deleteConfig(new File(skyblock.getDataFolder().toString() + "/ban-data", uuid.toString() + ".yml"));
@ -666,7 +671,7 @@ public class IslandManager {
}
}
public Island loadIsland(org.bukkit.OfflinePlayer player) {
public void loadIsland(org.bukkit.OfflinePlayer player) {
VisitManager visitManager = skyblock.getVisitManager();
FileManager fileManager = skyblock.getFileManager();
BanManager banManager = skyblock.getBanManager();
@ -681,7 +686,7 @@ public class IslandManager {
deleteIslandData(player.getUniqueId());
configLoad.set("Island.Owner", null);
return null;
return;
}
islandOwnerUUID = player.getUniqueId();
@ -693,7 +698,8 @@ public class IslandManager {
if (islandOwnerUUID != null) {
if (containsIsland(islandOwnerUUID)) {
return getIsland(player);
//return getIsland(player);
return;
} else {
config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml"));
@ -701,7 +707,7 @@ public class IslandManager {
deleteIslandData(islandOwnerUUID);
configLoad.set("Island.Owner", null);
return null;
return;
}
Island island = new Island(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
@ -726,11 +732,9 @@ public class IslandManager {
Bukkit.getScheduler().runTask(skyblock, () ->
Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper())));
return island;
return;
}
}
return null;
}
/**
@ -781,11 +785,11 @@ public class IslandManager {
oldSystemIslands.put(IslandWorld.End, endZ);
}
public Island loadIslandAtLocation(Location location) {
public void loadIslandAtLocation(Location location) {
FileManager fileManager = skyblock.getFileManager();
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
if (!configFile.exists()) return null;
if (!configFile.exists()) return;
for (File fileList : configFile.listFiles()) {
if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) {
@ -802,7 +806,8 @@ public class IslandManager {
if (LocationUtil.isLocationAtLocationRadius(location, islandLocation, size)) {
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", ""));
return this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
// return this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
return;
}
} catch (Exception e) {
e.printStackTrace();
@ -810,7 +815,7 @@ public class IslandManager {
}
}
return null;
return;
}
public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) {
@ -895,7 +900,9 @@ public class IslandManager {
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) {
@ -1083,8 +1090,8 @@ public class IslandManager {
}
} else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&',
Objects.requireNonNull(skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Teleport.Unsafe.Message"))));
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration().getString("Island.Teleport.Unsafe.Message")));
}
} else {
if (scoreboardManager != null) {
@ -1184,8 +1191,8 @@ public class IslandManager {
return islandStorage.get(uuid);
}
if (offlinePlayer.isOnline()) {
Player player = offlinePlayer.getPlayer();
Player player = offlinePlayer.getPlayer();
if (offlinePlayer.isOnline() && player != null) {
if (playerDataManager.hasPlayerData(player)) {
PlayerData playerData = playerDataManager.getPlayerData(player);
@ -1196,6 +1203,7 @@ public class IslandManager {
}
} else {
OfflinePlayer offlinePlayerData = new OfflinePlayer(offlinePlayer.getUniqueId());
loadIsland(offlinePlayer);
if (offlinePlayerData.getOwner() != null && islandStorage.containsKey(offlinePlayer.getUniqueId())) {
return islandStorage.get(offlinePlayerData.getOwner());
@ -1378,6 +1386,16 @@ public class IslandManager {
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR || player.hasPermission("essentials.fly") || player.hasPermission("cmi.command.fly"))
return;
// Residence support
if (Bukkit.getServer().getPluginManager().getPlugin("Residence") != null) {
ClaimedResidence res = Residence.getInstance().getResidenceManagerAPI().getByLoc(player.getLocation());
if(res != null){
if (res.getPermissions().has(Flags.fly, false) || res.getPermissions().has(Flags.nofly, false)) {
return;
}
}
}
Island island = getIslandAtLocation(player.getLocation());
UpgradeManager upgradeManager = skyblock.getUpgradeManager();

View File

@ -68,7 +68,7 @@ public class Block implements Listener {
}
// Check permissions.
if (!skyblock.getPermissionManager().processPermission(event, player, island)) {
if (!skyblock.getPermissionManager().processPermission(event, player, island) || event.isCancelled()) {
return;
}
@ -128,8 +128,8 @@ public class Block implements Listener {
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
if (LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D))
|| LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone())) {
if (LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D)) || LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0.0D, 1.0D, 0.0D))
|| LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
if (configLoad.getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Break.Message"));
@ -337,11 +337,7 @@ public class Block implements Listener {
witherSkeleton) {
if(block.getRelative(event.getFace().getOppositeFace()).getType().equals(Material.WATER)){
event.setCancelled(true);
if(NMSUtil.getVersionNumber() > 8){
event.getToBlock().getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f);
} else {
// TODO Find a sound for 1.8
}
event.getToBlock().getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f);
event.getToBlock().getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
}
break;

View File

@ -6,6 +6,7 @@ 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;
import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.upgrade.Upgrade;
import com.songoda.skyblock.utils.version.NMSUtil;
@ -14,8 +15,10 @@ import com.songoda.skyblock.world.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.*;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -27,6 +30,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;
@ -107,9 +112,16 @@ 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 if((event.getDamager() instanceof org.bukkit.entity.Projectile
&& ((Projectile) event.getDamager()).getShooter() instanceof Player)
&& (event.getEntity().getType().equals(EntityType.ARMOR_STAND)
|| event.getEntity().getType().equals(EntityType.ITEM_FRAME))){
Player player = (Player) ((Projectile) event.getDamager()).getShooter();
skyblock.getPermissionManager()
.processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()));
} else { // Make it work with all the entities, not just TNT
org.bukkit.entity.Entity entity = event.getEntity();
// Check permissions.
@ -217,6 +229,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();
@ -229,14 +242,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()));
}
@ -292,7 +306,7 @@ public class Entity implements Listener {
}
if ((event.getEntityType() == EntityType.FALLING_BLOCK)
&& LocationUtil.isLocationLocation(event.getBlock().getLocation(), island.getLocation(world, IslandEnvironment.Main).clone())
&& LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)
&& configLoad.getBoolean("Island.Spawn.Protection")) {
FallingBlock fallingBlock = (FallingBlock) event.getEntity();
if (fallingBlock.getDropItem()) {
@ -322,28 +336,17 @@ 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;
CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(block.getType());
if (materials != null) {
IslandLevel level = island.getLevel();
if (level.hasMaterial(materials.name())) {
long materialAmount = level.getMaterialAmount(materials.name());
if (materialAmount - 1 <= 0) {
level.removeMaterial(materials.name());
} else {
level.setMaterialAmount(materials.name(), materialAmount - 1);
}
}
}
removeBlockFromLevel(island, block);
CompatibleMaterial materials;
if (event.getTo() != null && event.getTo() != Material.AIR) {
materials = CompatibleMaterial.getBlockMaterial(event.getTo());
@ -363,7 +366,7 @@ public class Entity implements Listener {
}
@EventHandler
@EventHandler(priority = EventPriority.LOW)
public void onEntityExplode(EntityExplodeEvent event) {
org.bukkit.entity.Entity entity = event.getEntity();
@ -377,43 +380,87 @@ public class Entity implements Listener {
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()) {
@SuppressWarnings("deprecation")
CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(blockList.getType());
StackableManager stackableManager = skyblock.getStackableManager();
if (materials != null) {
IslandLevel level = island.getLevel();
boolean removed;
Iterator<org.bukkit.block.Block> it = event.blockList().iterator();
while (it.hasNext()){
removed = false;
org.bukkit.block.Block block = it.next();
if (SkyBlock.getInstance().getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Spawn.Protection")) {
IslandWorld world = worldManager.getIslandWorld(event.getEntity().getWorld());
if (LocationUtil.isLocationLocation(block.getLocation(),
island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D))) {
it.remove();
removed = true;
}
}
if (level.hasMaterial(materials.name())) {
long materialAmount = level.getMaterialAmount(materials.name());
Location blockLocation = block.getLocation();
if (materialAmount - 1 <= 0) {
level.removeMaterial(materials.name());
} else {
level.setMaterialAmount(materials.name(), materialAmount - 1);
}
if (stackableManager != null && stackableManager.isStacked(blockLocation)) {
Stackable stackable = stackableManager.getStack(block.getLocation(), CompatibleMaterial.getMaterial(block));
if (stackable != null) {
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
byte data = block.getData();
int removedAmount = (int) (Math.random() * Math.min(64, stackable.getSize()-1));
stackable.take(removedAmount);
Bukkit.getScheduler().runTask(skyblock, () -> {
block.getWorld().dropItemNaturally(blockLocation.clone().add(.5, 1, .5),
new ItemStack(material.getMaterial(), (int) (Math.random() * removedAmount), data));
});
if (stackable.getSize() <= 1) {
stackableManager.removeStack(stackable);
}
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
removeBlockFromLevel(island, block);
}
it.remove();
if(!removed){
removed = true;
}
}
}
}
if (SkyBlock.getInstance().getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Spawn.Protection")) {
IslandWorld world = worldManager.getIslandWorld(event.getEntity().getWorld());
for (org.bukkit.block.Block block : event.blockList()) {
if (LocationUtil.isLocationLocation(block.getLocation(),
island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D))) {
event.blockList().remove(block);
break;
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Block.Level.Enable")) {
if(!removed){
removeBlockFromLevel(island, block);
}
}
}
}
}
}
private void removeBlockFromLevel(Island island, CompatibleMaterial material){
if (material != null) {
IslandLevel level = island.getLevel();
if (level.hasMaterial(material.name())) {
long materialAmount = level.getMaterialAmount(material.name());
if (materialAmount - 1 <= 0) {
level.removeMaterial(material.name());
} else {
level.setMaterialAmount(material.name(), materialAmount - 1);
}
}
}
}
private void removeBlockFromLevel(Island island, Block block) {
removeBlockFromLevel(island, CompatibleMaterial.getBlockMaterial(block.getType()));
}
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
LivingEntity livingEntity = event.getEntity();
@ -563,6 +610,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

@ -122,12 +122,7 @@ public class Interact implements Listener {
if(configLoad.getBoolean("Island.Nether.AllowNetherWater", false)){
event.setCancelled(true);
block.setType(Material.WATER, true);
if(NMSUtil.getVersionNumber() > 8){
block.getWorld().playSound(block.getLocation(), Sound.ITEM_BUCKET_EMPTY, 1f, 1f);
} else {
//block.getWorld().playSound(block.getLocation(), Sound.SPLASH, 1f, 1f);
// TODO Find a sound for 1.8
}
block.getWorld().playSound(block.getLocation(), CompatibleSound.ITEM_BUCKET_EMPTY.getSound(), 1f, 1f);
if(!event.getPlayer().getGameMode().equals(GameMode.CREATIVE)){
event.getItem().setType(Material.BUCKET);
}

View File

@ -50,7 +50,8 @@ public class Join implements Listener {
userCacheManager.saveAsync();
try {
Island island = islandManager.loadIsland(player);
islandManager.loadIsland(player);
Island island = islandManager.getIsland(player);
boolean teleportedToIsland = false;
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));

View File

@ -169,12 +169,18 @@ 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) {
islandManager.loadIslandAtLocation(player.getLocation());
Island loadedIsland = islandManager.getIslandAtLocation(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);
@ -230,23 +236,23 @@ public class Move implements Listener {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent e) {
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);
Bukkit.getScheduler().runTaskLater(skyblock, () -> {
if (e.getTo() != null && worldManager.isIslandWorld(e.getTo().getWorld()) && skyblock.getIslandManager().getIslandAtLocation(e.getTo()) == null)
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);
}, 10L); // 2 ticks are good, 10 because we don't know the cause yet
if(e.getTo() != null && e.getTo().getWorld() != null){
if(!e.isAsynchronous()){
e.getTo().getWorld().loadChunk(e.getTo().getChunk()); // Is that needed?
}
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

@ -81,11 +81,6 @@ public class Portal implements Listener {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
// Check permissions.
if (!skyblock.getPermissionManager().processPermission(new PlayerEnterPortalEvent(player, player.getLocation()),
player, island))
return;
IslandEnvironment spawnEnvironment;
switch (island.getRole(player)) {
case Operator:
@ -122,34 +117,43 @@ public class Portal implements Listener {
if (tick == null) return;
PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat
// Check permissions.
boolean perms = !skyblock.getPermissionManager().processPermission(playerEnterPortalEvent,
player, island);
IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld());
IslandWorld toWorld = IslandWorld.Normal;
if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.NETHER_PORTAL))
if (block.getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial())) {
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.Nether : IslandWorld.Normal;
else if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.END_PORTAL))
} else if (block.getType().equals(CompatibleMaterial.END_PORTAL.getMaterial())) {
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.End : IslandWorld.Normal;
}
switch (toWorld) {
case Nether:
if (configLoad.getBoolean("Island.World.Nether.Enable") && island.isRegionUnlocked(player, "Nether")) {
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
}
break;
if(!perms){
switch (toWorld) {
case End:
case Nether:
if (configLoad.getBoolean("Island.World." + toWorld.name() + ".Enable") && island.isRegionUnlocked(player, toWorld)) {
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
}
break;
case End:
if (configLoad.getBoolean("Island.World.End.Enable") && island.isRegionUnlocked(player, "End")) {
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
}
break;
default:
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);
break;
default:
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);
break;
}
} else {
if(toWorld.equals(IslandWorld.End)){
player.setVelocity(player.getLocation().getDirection().multiply(-.50).setY(.6f));
} else if(toWorld.equals(IslandWorld.Nether)) {
player.setVelocity(player.getLocation().getDirection().multiply(-.50));
}
}
}

View File

@ -46,7 +46,7 @@ public class Spawner implements Listener {
spawner.setMaxSpawnDelay(400);
} else {
try {
Object MobSpawner = null;
Object MobSpawner;
try {
Field TileEntityMobSpawnerField = spawner.getClass().getDeclaredField("spawner");

View File

@ -1,5 +1,6 @@
package com.songoda.skyblock.listeners;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.api.event.player.PlayerIslandEnterEvent;
@ -11,7 +12,6 @@ import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
@ -20,6 +20,7 @@ import com.songoda.skyblock.world.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -53,9 +54,33 @@ public class Teleport implements Listener {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
Bukkit.getScheduler().runTaskLater(skyblock, () -> islandManager.updateFlight(player), 1L);
if(worldManager.isIslandWorld(event.getFrom().getWorld())
|| (event.getTo() != null && worldManager.isIslandWorld(event.getTo().getWorld()))) {
Bukkit.getScheduler().runTaskLater(skyblock, () -> islandManager.updateFlight(player), 1L);
}
islandManager.loadPlayer(player);
// Fix for bug that tp you in the real Nether/End when entering in a portal in an island // TODO Simplify
if (event.getTo() != null && (worldManager.isIslandWorld(event.getFrom().getWorld())
&& !worldManager.isIslandWorld(event.getTo().getWorld())
&& (event.getFrom().getBlock().getType().equals(CompatibleMaterial.END_PORTAL.getMaterial())
|| event.getFrom().getBlock().getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial()))
&& (event.getTo().getWorld() != null
&& event.getTo().getWorld().getEnvironment().equals(World.Environment.NETHER)
|| event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END)))
|| event.getTo() != null
&& (worldManager.isIslandWorld(event.getFrom().getWorld())
&& !worldManager.isIslandWorld(event.getTo().getWorld())
&& (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)
|| event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)
|| event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL))
&& (event.getTo().getWorld() != null
&& event.getTo().getWorld().getEnvironment().equals(World.Environment.NETHER)
|| event.getTo().getWorld().getEnvironment().equals(World.Environment.THE_END)))) {
event.setCancelled(true);
}
if (worldManager.isIslandWorld(player.getWorld())) {
com.songoda.skyblock.island.Island island = islandManager.getIslandAtLocation(event.getTo());

View File

@ -1,278 +0,0 @@
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.skyblock.SkyBlock;
import com.songoda.skyblock.bank.BankManager;
import com.songoda.skyblock.bank.Transaction;
import com.songoda.skyblock.bank.Type;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
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;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.*;
public class Bank {
private static Bank instance;
private BankManager bankManager;
private IslandManager islandManager;
public static Bank getInstance() {return instance == null ? instance = new Bank() : instance;}
public Bank() {
SkyBlock skyblock = SkyBlock.getInstance();
MessageManager messageManager = skyblock.getMessageManager();
islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
bankManager = BankManager.getInstance();
MenuClickRegistry.getInstance().register((executors) -> {
executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Exit.Displayname", CompatibleMaterial.OAK_FENCE_GATE), (inst, player, e) -> {
inst.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
e.setWillClose(true);
e.setWillDestroy(false);
});
executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Barrier.Displayname", CompatibleMaterial.BLACK_STAINED_GLASS_PANE), (inst, player, e) -> {
inst.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
e.setWillClose(false);
e.setWillDestroy(false);
});
executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Deposit.Displayname", CompatibleMaterial.DIRT), (inst, player, e) -> {
inst.getSoundManager().playSound(player, CompatibleSound.ENTITY_BAT_TAKEOFF.getSound(), 1.0F, 1.0F);
//Deposit money
Island island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
if (island != null) {
Island finalIsland = island;
SelectInputMethod.getInstance().open(player,"Deposit", (action) -> {
if (action == InputMethodSelectlistener.InputMethod.CANCELED) {
Bukkit.getScheduler().runTask(skyblock,() -> {this.open(player);});
return;
} else if (action == InputMethodSelectlistener.InputMethod.ALL) {
deposit(player,finalIsland,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);
}
});
}
e.setWillClose(true);
e.setCancelled(false);
});
executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Withdraw.Displayname", CompatibleMaterial.GLISTERING_MELON_SLICE), (inst, player, e) -> {
inst.getSoundManager().playSound(player, CompatibleSound.ENTITY_BAT_TAKEOFF.getSound(), 1.0F, 1.0F);
//Withdraw money
Island island = null;
island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
if (island != null) {
Island finalIsland = island;
SelectInputMethod.getInstance().open(player,"Withdraw", (action) -> {
if (action == InputMethodSelectlistener.InputMethod.CANCELED) {
Bukkit.getScheduler().runTask(skyblock,() -> {this.open(player);});
return;
} else if (action == InputMethodSelectlistener.InputMethod.ALL) {
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;
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;
}
withdraw(player,finalIsland,amount);
return true;
}).open(player),10);
}
});
}
e.setWillClose(true);
e.setCancelled(false);
});
executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Log.Displayname", CompatibleMaterial.BOOK), (inst, player, e) -> {
inst.getSoundManager().playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
e.setWillClose(false);
e.setWillDestroy(false);
});
executors.put(MenuClickRegistry.RegistryKey.fromLanguageFile("Menu.Bank.Item.Balance.Displayname", CompatibleMaterial.STICK), (inst, player, e) -> {
e.setWillClose(false);
e.setWillDestroy(false);
});
});
}
public void open(Player player) {
Island island;
island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
SkyBlock skyblock = SkyBlock.getInstance();
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
nInventoryUtil nInv = new nInventoryUtil(player, event -> MenuClickRegistry.getInstance().dispatch(player, event));
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"));
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);
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);
nInv.addItem(nInv.createItem(CompatibleMaterial.BOOK.getItem(), configLoad.getString("Menu.Bank.Item.Log.Displayname"),
bankManager.getTransactions(player), null, null, null), 4);
nInv.addItem(nInv.createItem(CompatibleMaterial.DIRT.getItem(), configLoad.getString("Menu.Bank.Item.Deposit.Displayname"),
configLoad.getStringList("Menu.Bank.Item.Deposit.Lore"), null, null, null), 10);
nInv.addItem(nInv.createItem(CompatibleMaterial.GLISTERING_MELON_SLICE.getItem(), configLoad.getString("Menu.Bank.Item.Withdraw.Displayname"),
configLoad.getStringList("Menu.Bank.Item.Withdraw.Lore"), null, null, null), 16);
nInv.addItem(nInv.createItem(CompatibleMaterial.STICK.getItem(), configLoad.getString("Menu.Bank.Item.Balance.Displayname"),
BankManager.getInstance().getBalanceLore(player), null, null, null), 13);
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(configLoad.getString("Menu.Bank.Title"))));
nInv.setRows(2);
Bukkit.getServer().getScheduler().runTask(skyblock, nInv::open);
}
private void deposit(Player player, Island island, double amt) {
SkyBlock skyblock = SkyBlock.getInstance();
MessageManager messageManager = skyblock.getMessageManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
// Make sure the amount is positive
if (amt <= 0) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short5.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
// If decimals aren't allowed, check for them
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
int intAmt = (int) amt;
if (intAmt != amt) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short6.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
}
if (!EconomyManager.hasBalance(player, amt)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
EconomyManager.withdrawBalance(player, amt);
island.addToBank(amt);
Transaction t = new Transaction();
t.player = player;
t.ammount = (float) amt;
t.timestamp = Calendar.getInstance().getTime();
t.action = Type.DEPOSIT;
bankManager.addTransaction(player, t);
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Deposit.Message").replace(
"%amount%", NumberUtil.formatNumberByDecimal(amt)));
}
private void withdraw(Player player, Island island, double amt) {
SkyBlock skyblock = SkyBlock.getInstance();
MessageManager messageManager = skyblock.getMessageManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
FileManager.Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
// Make sure the amount is positive
if (amt <= 0) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short5.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
// If decimals aren't allowed, check for them
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
int intAmt = (int) amt;
if (intAmt != amt) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short6.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
}
if (amt > island.getBankBalance()) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short2.Message"));
return;
}
EconomyManager.deposit(player, amt);
island.removeFromBank(amt);
Transaction t = new Transaction();
t.player = player;
t.ammount = (float) amt;
t.timestamp = Calendar.getInstance().getTime();
t.action = Type.WITHDRAW;
bankManager.addTransaction(player, t);
messageManager.sendMessage(player, Objects.requireNonNull(configLoad.getString("Command.Island.Bank.Withdraw.Message")).replace(
"%amount%", NumberUtil.formatNumberByDecimal(amt)));
}
}

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

@ -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,
@ -356,7 +356,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) {
@ -462,7 +462,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,
@ -470,7 +470,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,
@ -501,7 +501,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

@ -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);
@ -188,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

@ -8,6 +8,7 @@ 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;
@ -75,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(
@ -394,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();
@ -404,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);
@ -337,6 +332,8 @@ public class Levelling implements Listener {
Bukkit.getServer().getScheduler().runTaskLater(skyblock,
() -> open(player), 1L);
levellingManager.addWorth(materials, materialPoints);
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock,
() -> {
Config config1 = fileManager.getConfig(new File(
@ -411,8 +408,6 @@ public class Levelling implements Listener {
}
}
event.setCancelled(true);
CompatibleMaterial materials = CompatibleMaterial.getMaterial(event.getCurrentItem().getType());
if (NMSUtil.getVersionNumber() < 13) {

View File

@ -1,686 +0,0 @@
package com.songoda.skyblock.menus.admin;
import com.songoda.core.compatibility.CompatibleMaterial;
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.island.IslandRole;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Settings {
private static Settings instance;
public static Settings getInstance() {
if (instance == null) {
instance = new Settings();
}
return instance;
}
public void open(Player player, Settings.Type menuType, IslandRole role) {
SkyBlock skyblock = SkyBlock.getInstance();
MessageManager messageManager = skyblock.getMessageManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = languageConfig.getFileConfiguration();
if (menuType == Settings.Type.Categories) {
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (!(player.hasPermission("fabledskyblock.admin.settings") || player.hasPermission("fabledskyblock.admin.*")
|| player.hasPermission("fabledskyblock.*"))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
ItemStack is = event.getItem();
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings.Categories.Item.Exit.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
} else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad
.getString("Menu.Admin.Settings.Categories.Item.Visitor.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Visitor), 1L);
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings.Categories.Item.Member.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Member), 1L);
} else if ((is.getType() == Material.ITEM_FRAME) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad
.getString("Menu.Admin.Settings.Categories.Item.Operator.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Operator), 1L);
} else if ((is.getType() == Material.NAME_TAG) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings.Categories.Item.Coop.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Coop), 1L);
} else if ((is.getType() == CompatibleMaterial.OAK_SAPLING.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings.Categories.Item.Owner.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, IslandRole.Owner), 1L);
}
});
nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial()),
configLoad.getString("Menu.Admin.Settings.Categories.Item.Visitor.Displayname"),
configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Visitor.Lore"), null, null, null), 2);
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING),
configLoad.getString("Menu.Admin.Settings.Categories.Item.Member.Displayname"),
configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Member.Lore"), null, null, null), 3);
nInv.addItem(nInv.createItem(new ItemStack(Material.ITEM_FRAME),
configLoad.getString("Menu.Admin.Settings.Categories.Item.Operator.Displayname"),
configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Operator.Lore"), null, null, null),
4);
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Coop.Enable")) {
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Admin.Settings.Categories.Item.Exit.Displayname"), null, null, null,
null), 0);
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG),
configLoad.getString("Menu.Admin.Settings.Categories.Item.Coop.Displayname"),
configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Coop.Lore"), null, null, null),
6);
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_SAPLING.getItem(),
configLoad.getString("Menu.Admin.Settings.Categories.Item.Owner.Displayname"),
configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Owner.Lore"), null, null, null),
7);
} else {
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Admin.Settings.Categories.Item.Exit.Displayname"), null, null, null,
null), 0, 8);
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_SAPLING.getItem(),
configLoad.getString("Menu.Admin.Settings.Categories.Item.Owner.Displayname"),
configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Owner.Lore"), null, null, null),
6);
}
nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings.Categories.Title")));
nInv.setRows(1);
Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open());
} else if (menuType == Settings.Type.Role) {
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (!(player.hasPermission("fabledskyblock.admin.settings") || player.hasPermission("fabledskyblock.admin.*")
|| player.hasPermission("fabledskyblock.*"))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
ItemStack is = event.getItem();
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta()) && (is
.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings.Visitor.Item.Return.Displayname")))
|| is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings.Member.Item.Return.Displayname")))
|| is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad
.getString("Menu.Admin.Settings.Operator.Item.Return.Displayname")))
|| is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings.Owner.Item.Return.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Categories, null), 1L);
} else if (is.hasItemMeta()) {
String roleName = getRoleName(role);
FileConfiguration settingsConfigLoad = skyblock.getFileManager()
.getConfig(new File(skyblock.getDataFolder(), "settings.yml")).getFileConfiguration();
for (String settingList : settingsConfigLoad.getConfigurationSection("Settings." + role.name())
.getKeys(false)) {
if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings." + roleName + ".Item.Setting."
+ settingList + ".Displayname")))) {
if (settingsConfigLoad.getBoolean("Settings." + role.name() + "." + settingList)) {
settingsConfigLoad.set("Settings." + role.name() + "." + settingList, false);
} else {
settingsConfigLoad.set("Settings." + role.name() + "." + settingList, true);
}
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> {
try {
Config config = skyblock.getFileManager()
.getConfig(new File(skyblock.getDataFolder(), "settings.yml"));
config.getFileConfiguration().save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
});
break;
}
}
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player, Type.Role, role), 1L);
}
});
if (role == IslandRole.Visitor
|| role == IslandRole.Member
|| role == IslandRole.Coop) {
nInv.addItemStack(createItem(role, "Destroy", new ItemStack(Material.DIAMOND_PICKAXE)), 9);
nInv.addItemStack(createItem(role, "Place", new ItemStack(Material.GRASS)), 10);
nInv.addItemStack(createItem(role, "Anvil", new ItemStack(Material.ANVIL)), 11);
nInv.addItemStack(createItem(role, "ArmorStandUse", new ItemStack(Material.ARMOR_STAND)), 12);
nInv.addItemStack(createItem(role, "Beacon", new ItemStack(Material.BEACON)), 13);
nInv.addItemStack(createItem(role, "Bed", CompatibleMaterial.WHITE_BED.getItem()), 14);
nInv.addItemStack(createItem(role, "AnimalBreeding", new ItemStack(Material.WHEAT)), 15);
nInv.addItemStack(
createItem(role, "Brewing", new ItemStack(CompatibleMaterial.BREWING_STAND.getMaterial())),
16);
nInv.addItemStack(createItem(role, "Bucket", new ItemStack(Material.BUCKET)), 17);
nInv.addItemStack(createItem(role, "WaterCollection", new ItemStack(Material.POTION)), 18);
nInv.addItemStack(createItem(role, "Storage", new ItemStack(Material.CHEST)), 19);
nInv.addItemStack(createItem(role, "Workbench", CompatibleMaterial.CRAFTING_TABLE.getItem()), 20);
nInv.addItemStack(createItem(role, "Crop", CompatibleMaterial.WHEAT_SEEDS.getItem()), 21);
nInv.addItemStack(createItem(role, "Door", CompatibleMaterial.OAK_DOOR.getItem()), 22);
nInv.addItemStack(createItem(role, "Gate", CompatibleMaterial.OAK_FENCE_GATE.getItem()), 23);
nInv.addItemStack(createItem(role, "Projectile", new ItemStack(Material.ARROW)), 24);
nInv.addItemStack(createItem(role, "Enchant", CompatibleMaterial.ENCHANTING_TABLE.getItem()), 25);
nInv.addItemStack(createItem(role, "Fire", new ItemStack(Material.FLINT_AND_STEEL)), 26);
nInv.addItemStack(createItem(role, "Furnace", new ItemStack(Material.FURNACE)), 27);
nInv.addItemStack(createItem(role, "HorseInventory", CompatibleMaterial.CHEST_MINECART.getItem()), 28);
nInv.addItemStack(createItem(role, "MobRiding", new ItemStack(Material.SADDLE)), 29);
nInv.addItemStack(createItem(role, "MonsterHurting", CompatibleMaterial.BONE.getItem()), 30);
nInv.addItemStack(createItem(role, "MobHurting", CompatibleMaterial.WOODEN_SWORD.getItem()), 31);
nInv.addItemStack(createItem(role, "MobTaming", CompatibleMaterial.POPPY.getItem()), 32);
nInv.addItemStack(createItem(role, "Leash", CompatibleMaterial.LEAD.getItem()), 33);
nInv.addItemStack(createItem(role, "LeverButton", new ItemStack(Material.LEVER)), 34);
nInv.addItemStack(createItem(role, "Milking", new ItemStack(Material.MILK_BUCKET)), 35);
nInv.addItemStack(createItem(role, "Jukebox", new ItemStack(Material.JUKEBOX)), 36);
nInv.addItemStack(createItem(role, "PressurePlate", CompatibleMaterial.OAK_PRESSURE_PLATE.getItem()), 37);
nInv.addItemStack(createItem(role, "Redstone", new ItemStack(Material.REDSTONE)), 38);
nInv.addItemStack(createItem(role, "Shearing", new ItemStack(Material.SHEARS)), 39);
nInv.addItemStack(createItem(role, "Trading", new ItemStack(Material.EMERALD)), 40);
nInv.addItemStack(createItem(role, "ItemDrop", new ItemStack(Material.PUMPKIN_SEEDS)), 41);
nInv.addItemStack(createItem(role, "ItemPickup", new ItemStack(Material.MELON_SEEDS)), 42);
nInv.addItemStack(createItem(role, "Fishing", new ItemStack(Material.FISHING_ROD)), 43);
nInv.addItemStack(createItem(role, "DropperDispenser", new ItemStack(Material.DISPENSER)), 44);
nInv.addItemStack(createItem(role, "SpawnEgg", new ItemStack(Material.EGG)), 45);
nInv.addItemStack(createItem(role, "HangingDestroy", new ItemStack(Material.ITEM_FRAME)), 46);
nInv.addItemStack(createItem(role, "Cake", new ItemStack(Material.CAKE)), 47);
nInv.addItemStack(createItem(role, "DragonEggUse", new ItemStack(Material.DRAGON_EGG)), 48);
nInv.addItemStack(createItem(role, "MinecartBoat", new ItemStack(Material.MINECART)), 49);
nInv.addItemStack(createItem(role, "Portal", new ItemStack(Material.ENDER_PEARL)), 50);
nInv.addItemStack(createItem(role, "Hopper", new ItemStack(Material.HOPPER)), 51);
nInv.addItemStack(createItem(role, "EntityPlacement", new ItemStack(Material.ARMOR_STAND)), 52);
nInv.addItemStack(createItem(role, "ExperienceOrbPickup", CompatibleMaterial.EXPERIENCE_BOTTLE.getItem()), 53);
nInv.setRows(6);
} else if (role == IslandRole.Operator) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Coop.Enable")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 9);
nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 10);
nInv.addItemStack(createItem(role, "Ban", new ItemStack(Material.IRON_AXE)), 11);
nInv.addItemStack(createItem(role, "Unban", CompatibleMaterial.RED_DYE.getItem()), 12);
nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 13);
nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 14);
nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 15);
nInv.addItemStack(createItem(role, "Coop", new ItemStack(Material.NAME_TAG)), 16);
nInv.addItemStack(createItem(role, "CoopPlayers", new ItemStack(Material.BOOK)), 17);
nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20);
nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)),
21);
nInv.addItemStack(createItem(role, "Border", new ItemStack(Material.BEACON)), 22);
nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23);
nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24);
} else {
nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 9);
nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 10);
nInv.addItemStack(createItem(role, "Ban", new ItemStack(Material.IRON_AXE)), 11);
nInv.addItemStack(createItem(role, "Unban", CompatibleMaterial.RED_DYE.getItem()), 12);
nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 13);
nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 14);
nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 15);
nInv.addItemStack(createItem(role, "Coop", new ItemStack(Material.NAME_TAG)), 16);
nInv.addItemStack(createItem(role, "CoopPlayers", new ItemStack(Material.BOOK)), 17);
nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20);
nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)),
21);
nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23);
nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24);
}
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10);
nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11);
nInv.addItemStack(createItem(role, "Ban", new ItemStack(Material.IRON_AXE)), 12);
nInv.addItemStack(createItem(role, "Unban", CompatibleMaterial.RED_DYE.getItem()), 13);
nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 14);
nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 15);
nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 16);
nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20);
nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)),
21);
nInv.addItemStack(createItem(role, "Border", new ItemStack(Material.BEACON)), 22);
nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23);
nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24);
} else {
nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10);
nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11);
nInv.addItemStack(createItem(role, "Ban", new ItemStack(Material.IRON_AXE)), 12);
nInv.addItemStack(createItem(role, "Unban", CompatibleMaterial.RED_DYE.getItem()), 13);
nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 14);
nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 15);
nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 16);
nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20);
nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)),
21);
nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23);
nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24);
}
}
nInv.setRows(3);
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.Coop.Enable")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10);
nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11);
nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 12);
nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 13);
nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 14);
nInv.addItemStack(createItem(role, "Coop", new ItemStack(Material.NAME_TAG)), 15);
nInv.addItemStack(createItem(role, "CoopPlayers", new ItemStack(Material.BOOK)), 16);
nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20);
nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)),
21);
nInv.addItemStack(createItem(role, "Border", new ItemStack(Material.BEACON)), 22);
nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23);
nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24);
} else {
nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10);
nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11);
nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 12);
nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 13);
nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 14);
nInv.addItemStack(createItem(role, "Coop", new ItemStack(Material.NAME_TAG)), 15);
nInv.addItemStack(createItem(role, "CoopPlayers", new ItemStack(Material.BOOK)), 16);
nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 20);
nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)),
21);
nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 23);
nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24);
}
nInv.setRows(3);
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10);
nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 11);
nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 12);
nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 13);
nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 14);
nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 15);
nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)),
16);
nInv.addItemStack(createItem(role, "Border", new ItemStack(Material.BEACON)), 21);
nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 22);
nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 23);
nInv.setRows(3);
} else {
nInv.addItemStack(createItem(role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 9);
nInv.addItemStack(createItem(role, "Kick", new ItemStack(Material.IRON_DOOR)), 10);
nInv.addItemStack(createItem(role, "Visitor", new ItemStack(CompatibleMaterial.OAK_SIGN.getMaterial())), 11);
nInv.addItemStack(createItem(role, "Member", new ItemStack(Material.PAINTING)), 12);
nInv.addItemStack(createItem(role, "Island", CompatibleMaterial.OAK_SAPLING.getItem()), 13);
nInv.addItemStack(createItem(role, "MainSpawn", new ItemStack(Material.EMERALD)), 14);
nInv.addItemStack(createItem(role, "VisitorSpawn", new ItemStack(Material.NETHER_STAR)),
15);
nInv.addItemStack(createItem(role, "Biome", new ItemStack(Material.MAP)), 16);
nInv.addItemStack(createItem(role, "Weather", CompatibleMaterial.CLOCK.getItem()), 17);
nInv.setRows(2);
}
}
}
} else if (role == IslandRole.Owner) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.PvP.Enable")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
10);
nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 13);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14);
nInv.addItemStack(
createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 15);
nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16);
nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 17);
} else {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
10);
nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
nInv.addItemStack(
createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 16);
nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 17);
}
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
10);
nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
nInv.addItemStack(
createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 16);
nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 17);
} else {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 12);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 13);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
nInv.addItemStack(
createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 16);
}
}
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
10);
nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16);
nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 17);
} else {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 12);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 13);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16);
}
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 12);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 13);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 16);
} else {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "PvP", new ItemStack(Material.DIAMOND_SWORD)), 12);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 14);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 15);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 16);
}
}
}
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
10);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 11);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 12);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14);
nInv.addItemStack(
createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 15);
nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16);
nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 17);
} else {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 13);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14);
nInv.addItemStack(
createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 15);
nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16);
}
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 13);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14);
nInv.addItemStack(
createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 15);
nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 16);
} else {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
nInv.addItemStack(
createItem(role, "KeepItemsOnDeath", new ItemStack(Material.ITEM_FRAME)), 16);
}
}
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 13);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 14);
nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 15);
nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 16);
} else {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
nInv.addItemStack(createItem(role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16);
}
} else {
if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
10);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
11);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 12);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
nInv.addItemStack(createItem(role, "Hunger", new ItemStack(Material.COOKED_BEEF)), 16);
} else {
nInv.addItemStack(
createItem(role, "NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG.getItem()),
11);
nInv.addItemStack(createItem(role, "MobGriefing", CompatibleMaterial.IRON_SHOVEL.getItem()),
12);
nInv.addItemStack(createItem(role, "Explosions", CompatibleMaterial.GUNPOWDER.getItem()), 13);
nInv.addItemStack(
createItem(role, "FireSpread", new ItemStack(Material.FLINT_AND_STEEL)), 14);
nInv.addItemStack(createItem(role, "LeafDecay", CompatibleMaterial.OAK_LEAVES.getItem()), 15);
}
}
}
}
nInv.setRows(2);
}
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Admin.Settings." + role.name() + ".Item.Return.Displayname"), null, null,
null, null), 0, 8);
nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings." + role.name() + ".Title")));
Bukkit.getServer().getScheduler().runTask(skyblock, () -> nInv.open());
}
}
private ItemStack createItem(IslandRole role, String setting, ItemStack is) {
SkyBlock skyblock = SkyBlock.getInstance();
FileManager fileManager = skyblock.getFileManager();
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
List<String> itemLore = new ArrayList<>();
ItemMeta im = is.getItemMeta();
String roleName = role.name();
if (role == IslandRole.Visitor
|| role == IslandRole.Member
|| role == IslandRole.Coop) {
roleName = "Default";
}
im.setDisplayName(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Settings." + roleName + ".Item.Setting." + setting + ".Displayname")));
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "settings.yml")).getFileConfiguration()
.getBoolean("Settings." + role.name() + "." + setting)) {
for (String itemLoreList : configLoad
.getStringList("Menu.Admin.Settings." + roleName + ".Item.Setting.Status.Enabled.Lore")) {
itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList));
}
} else {
for (String itemLoreList : configLoad
.getStringList("Menu.Admin.Settings." + roleName + ".Item.Setting.Status.Disabled.Lore")) {
itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList));
}
}
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
im.setLore(itemLore);
is.setItemMeta(im);
return is;
}
private String getRoleName(IslandRole role) {
if (role == IslandRole.Visitor
|| role == IslandRole.Member
|| role == IslandRole.Coop) {
return "Default";
}
return role.name();
}
public enum Type {
Categories, Panel, Role
}
}

View File

@ -6,6 +6,7 @@ import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandRole;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@ -28,6 +29,10 @@ public abstract class BasicPermission {
}
public ItemStack getItem(Island island, IslandRole role) {
return getItem(island.hasPermission(role, this), role);
}
public ItemStack getItem(boolean permissionEnabled, IslandRole role) {
ItemStack is = icon.getItem();
FileManager.Config config = SkyBlock.getInstance().getFileManager()
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"));
@ -44,31 +49,23 @@ public abstract class BasicPermission {
|| role == IslandRole.Coop)
roleName = "Default";
String nameFinal = configLoad.getString("Menu.Settings." + roleName + ".Item.Setting." + name + ".Displayname");
String nameFinal = TextUtils.formatText(configLoad.getString("Menu.Settings." + roleName + ".Item.Setting." + name + ".Displayname", name));
im.setDisplayName(TextUtils.formatText(nameFinal == null ? name : nameFinal));
if(im != null){
im.setDisplayName(nameFinal);
for (String itemLoreList : configLoad
.getStringList("Menu.Settings." + roleName + ".Item.Setting.Status."
+ (permissionEnabled ? "Enabled" : "Disabled") + ".Lore"))
itemLore.add(TextUtils.formatText(itemLoreList));
for (String itemLoreList : configLoad
.getStringList("Menu.Settings." + roleName + ".Item.Setting.Status."
+ (island.hasPermission(role, this) ? "Enabled" : "Disabled") + ".Lore"))
itemLore.add(TextUtils.formatText(itemLoreList));
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
im.setLore(itemLore);
is.setItemMeta(im);
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
im.setLore(itemLore);
is.setItemMeta(im);
}
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,13 @@ 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 org.bukkit.event.player.PlayerMoveEvent;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
@ -27,7 +32,7 @@ public class PermissionManager {
this.plugin = plugin;
// Load default permissions.
registerPermissions(
registerPermissions( // TODO Reload them with /is admin reload - Fabrimat
//Listening
new StoragePermission(plugin),
new DragonEggUsePermission(plugin),
@ -77,7 +82,6 @@ public class PermissionManager {
new MobGriefingPermission(plugin),
new ExperienceOrbPickupPermission(plugin),
new NaturalMobSpawningPermission(),
new HungerPermission(plugin),
new PortalPermission(plugin),
new ItemPickupPermission(),
new ItemDropPermission(),
@ -100,13 +104,54 @@ public class PermissionManager {
new MainSpawnPermission(),
new VisitorSpawnPermission());
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());
}
private void updateSettingsConfig(BasicPermission permission){
FileManager.Config settingsConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "settings.yml"));
FileConfiguration settingsConfigLoad = settingsConfig.getFileConfiguration();
switch (permission.getType()){
case GENERIC:
if(settingsConfigLoad.getString("Settings.Visitor." + permission.getName()) == null){
settingsConfigLoad.set("Settings.Visitor." + permission.getName(), true);
}
if(settingsConfigLoad.getString("Settings.Member." + permission.getName()) == null){
settingsConfigLoad.set("Settings.Member." + permission.getName(), true);
}
if(settingsConfigLoad.getString("Settings.Coop." + permission.getName()) == null){
settingsConfigLoad.set("Settings.Coop." + permission.getName(), true);
}
break;
case OPERATOR:
if(settingsConfigLoad.getString("Settings.Operator." + permission.getName()) == null){
settingsConfigLoad.set("Settings.Operator." + permission.getName(), true);
}
break;
case ISLAND:
if(settingsConfigLoad.getString("Settings.Owner." + permission.getName()) == null){
settingsConfigLoad.set("Settings.Owner." + permission.getName(), true);
}
break;
}
try {
settingsConfigLoad.save(settingsConfig.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
public boolean registerPermission(BasicPermission permission) {
updateSettingsConfig(permission);
registeredPermissions.put(permission.getName().toUpperCase(), permission);
Set<Method> methods;
try {
@ -141,6 +186,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) {
@ -152,7 +201,7 @@ public class PermissionManager {
BasicPermission permission = wrapper.getPermission();
if (permission.overridingCheck() || hasPermission(player, island, permission))
if (hasPermission(player, island, permission, reversePermission))
continue;
try {
@ -161,23 +210,40 @@ public class PermissionManager {
e.printStackTrace();
}
}
return true;
return !cancellable.isCancelled();
}
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

@ -6,9 +6,8 @@ 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.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.Bukkit;
import org.bukkit.entity.*;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -27,8 +26,6 @@ public class DestroyPermission extends ListeningPermission {
@PermissionHandler
public void onInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
return;
@ -42,13 +39,24 @@ public class DestroyPermission extends ListeningPermission {
@PermissionHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof Player)) return;
Player player = (Player)event.getDamager();
Entity entity = event.getEntity();
Player player = null;
if (event.getDamager() instanceof Player) {
player = (Player) event.getDamager();
}
if(event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player){
player = (Player) ((Projectile) event.getDamager()).getShooter();
}
if(player != null){
Entity entity = event.getEntity();
if (entity.getType() != EntityType.ARMOR_STAND) return;
cancelAndMessage(event, player, plugin, messageManager);
switch (entity.getType()){
case ARMOR_STAND:
case PAINTING:
case ITEM_FRAME:
cancelAndMessage(event, player, plugin, messageManager);
break;
}
}
}
@PermissionHandler

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() != null && 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

@ -24,18 +24,18 @@ public class MobHurtingPermission extends ListeningPermission {
@PermissionHandler
public void onVehicleDamage(VehicleDamageEvent event) {
Player player = (Player) event.getAttacker();
cancelAndMessage(event, player, plugin, messageManager);
if(event.getAttacker() instanceof Player){
Player player = (Player) event.getAttacker();
cancelAndMessage(event, player, plugin, messageManager);
}
}
@PermissionHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
Player player = (Player) event.getAttacker();
cancelAndMessage(event, player, plugin, messageManager);
if(event.getAttacker() instanceof Player){
Player player = (Player) event.getAttacker();
cancelAndMessage(event, player, plugin, messageManager);
}
}
@PermissionHandler

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,55 @@ 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);
}
}
@PermissionHandler
public void onMove(PlayerMoveEvent event) {
if(event.getTo() != null){
CompatibleMaterial toMaterial = CompatibleMaterial.getMaterial(event.getTo().getBlock().getType());
if (toMaterial == CompatibleMaterial.NETHER_PORTAL || toMaterial == CompatibleMaterial.END_PORTAL) {
//event.setTo(LocationUtil.getRandomLocation(event.getFrom().getWorld(), 5000, 5000, true, true));
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
}
}
}
@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

@ -8,7 +8,8 @@ import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.*;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import java.io.File;
@ -28,26 +29,24 @@ public class PvpPermission extends ListeningPermission {
@PermissionHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
Player player;
if (event.getDamager() instanceof Player)
player = (Player) event.getDamager();
else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player)
player = (Player) ((Projectile) event.getDamager()).getShooter();
else return;
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Settings.PvP.Enable")) {
event.setCancelled(true);
} else if (!configLoad.getBoolean("Island.PvP.Enable")) {
event.setCancelled(true);
Player attacker = null;
if (event.getDamager() instanceof Player) {
attacker = (Player) event.getDamager();
} else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player) {
attacker = (Player) ((Projectile) event.getDamager()).getShooter();
}
if (entity.getType() == EntityType.ARMOR_STAND || !(entity instanceof Monster)) return;
if(attacker != null && event.getEntity() instanceof Player){
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Settings.PvP.Enable") || !configLoad.getBoolean("Island.PvP.Enable")) {
event.setCancelled(true);
}
cancelAndMessage(event, attacker, plugin, messageManager);
}
cancelAndMessage(event, player, plugin, messageManager);
}
}

View File

@ -7,6 +7,7 @@ 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.Bukkit;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.minecart.StorageMinecart;
@ -27,31 +28,44 @@ public class StoragePermission extends ListeningPermission {
@PermissionHandler
public void onInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
return;
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
Player player = event.getPlayer();
if (material == CompatibleMaterial.CHEST || material == CompatibleMaterial.TRAPPED_CHEST
|| (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) && (material == CompatibleMaterial.SHULKER_BOX
|| material == CompatibleMaterial.BLACK_SHULKER_BOX || material == CompatibleMaterial.BLUE_SHULKER_BOX
|| material == CompatibleMaterial.BROWN_SHULKER_BOX || material == CompatibleMaterial.CYAN_SHULKER_BOX
|| material == CompatibleMaterial.GRAY_SHULKER_BOX || material == CompatibleMaterial.GREEN_SHULKER_BOX
|| material == CompatibleMaterial.LIGHT_BLUE_SHULKER_BOX || material == CompatibleMaterial.LIGHT_GRAY_SHULKER_BOX
|| material == CompatibleMaterial.LIME_SHULKER_BOX || material == CompatibleMaterial.MAGENTA_SHULKER_BOX
|| material == CompatibleMaterial.ORANGE_SHULKER_BOX || material == CompatibleMaterial.PINK_SHULKER_BOX
|| material == CompatibleMaterial.PURPLE_SHULKER_BOX || material == CompatibleMaterial.RED_SHULKER_BOX
|| material == CompatibleMaterial.WHITE_SHULKER_BOX || material == CompatibleMaterial.YELLOW_SHULKER_BOX))
|| ServerVersion.isServerVersionAtLeast(ServerVersion.V1_14) && material == CompatibleMaterial.BARREL)
cancelAndMessage(event, player, plugin, messageManager);
switch (material){
case CHEST:
case TRAPPED_CHEST:
case DROPPER:
case DISPENSER:
case SHULKER_BOX:
case BLACK_SHULKER_BOX:
case BLUE_SHULKER_BOX:
case BROWN_SHULKER_BOX:
case CYAN_SHULKER_BOX:
case GRAY_SHULKER_BOX:
case GREEN_SHULKER_BOX:
case LIGHT_BLUE_SHULKER_BOX:
case LIGHT_GRAY_SHULKER_BOX:
case LIME_SHULKER_BOX:
case MAGENTA_SHULKER_BOX:
case ORANGE_SHULKER_BOX:
case PURPLE_SHULKER_BOX:
case PINK_SHULKER_BOX:
case RED_SHULKER_BOX:
case YELLOW_SHULKER_BOX:
case WHITE_SHULKER_BOX:
case BARREL:
cancelAndMessage(event, player, plugin, messageManager);
}
}
@PermissionHandler
public void onInteractEntity(PlayerInteractEntityEvent event) {
Player player = event.getPlayer();
if (event.getRightClicked().getType() == EntityType.ITEM_FRAME
if (event.getRightClicked().getType().equals(EntityType.ITEM_FRAME)
|| event.getRightClicked() instanceof StorageMinecart)
cancelAndMessage(event, player, plugin, messageManager);

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

@ -3,9 +3,9 @@ package com.songoda.skyblock.playerdata;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.bank.BankManager;
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 +22,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 +45,8 @@ public class PlayerData {
uuid = player.getUniqueId();
islandOwnerUUID = null;
page = 1;
pages = new ArrayList<>();
confirmationTime = 0;
playTime = getConfig().getFileConfiguration().getInt("Statistics.Island.Playtime");
@ -57,22 +58,39 @@ public class PlayerData {
FileConfiguration configLoad = getConfig().getFileConfiguration();
for (int i = 0;i< configLoad.getInt("Bank.Transactions.Size");i++) {
Transaction t = new Transaction();
t.action = Type.valueOf(configLoad.getString("Bank.Transactions."+i+".Action"));
t.ammount = Float.parseFloat(Objects.requireNonNull(configLoad.getString("Bank.Transactions." + i + ".Amount")));
t.action = Transaction.Type.valueOf(configLoad.getString("Bank.Transactions."+i+".Action"));
t.amount = Float.parseFloat(Objects.requireNonNull(configLoad.getString("Bank.Transactions." + i + ".Amount")));
t.player = Bukkit.getOfflinePlayer(UUID.fromString(Objects.requireNonNull(configLoad.getString("Bank.Transactions." + i + ".Player"))));
Date d = new Date();
d.setTime(configLoad.getLong("Bank.Transactions."+i+".Date"));
t.timestamp = d;
String visibility = configLoad.getString("Bank.Transactions."+i+".Visibility");
if(visibility != null){
t.visibility = Transaction.Visibility.valueOf(visibility);
} else {
t.visibility = Transaction.Visibility.USER; // Defaulting this as it's a new field
}
transactions.add(t);
}
}
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() {
@ -242,7 +260,7 @@ public class PlayerData {
}
public void save() {
transactions = BankManager.getInstance().getTransactionList(getPlayer());
transactions = BankManager.getInstance().getTransactionList(getPlayerUUID());
Config config = getConfig();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Statistics.Island.Playtime", getPlaytime());
@ -251,9 +269,10 @@ public class PlayerData {
for (int i = 0; i < transactions.size(); i++) {
Transaction t = transactions.get(i);
configLoad.set("Bank.Transactions." + i + ".Action", t.action.name());
configLoad.set("Bank.Transactions." + i + ".Amount", t.ammount);
configLoad.set("Bank.Transactions." + i + ".Amount", t.amount);
configLoad.set("Bank.Transactions." + i + ".Player", t.player.getUniqueId().toString());
configLoad.set("Bank.Transactions." + i + ".Date", t.timestamp.getTime());
configLoad.set("Bank.Transactions." + i + ".Visibility", t.visibility.name());
}
}else {
configLoad.set("Bank.Transactions.Size", 0);
@ -274,6 +293,10 @@ public class PlayerData {
return Bukkit.getPlayer(uuid);
}
public UUID getPlayerUUID() {
return uuid;
}
public List<Transaction> getTransactions() {
return transactions;
}

View File

@ -1,10 +1,6 @@
package com.songoda.skyblock.scoreboard;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -118,9 +114,9 @@ public class Scoreboard {
if (displayLine.length() >= 16) {
String prefixLine = displayLine.substring(0, Math.min(displayLine.length(), 16));
String suffixLine = displayLine.substring(16, Math.min(displayLine.length(), displayLine.length()));
String suffixLine = displayLine.substring(16);
if (prefixLine.substring(prefixLine.length() - 1).equals("&")) {
if (prefixLine.endsWith("&")) {
prefixLine = ChatColor.translateAlternateColorCodes('&', prefixLine.substring(0, prefixLine.length() - 1));
suffixLine = ChatColor.translateAlternateColorCodes('&', "&" + suffixLine);
} else {
@ -175,7 +171,8 @@ public class Scoreboard {
IslandManager islandManager = skyblock.getIslandManager();
displayLine = displayLine.replace("%players_online", "" + Bukkit.getServer().getOnlinePlayers().size()).replace("%players_max", "" + Bukkit.getServer().getMaxPlayers());
displayLine = displayLine.replace("%players_online", String.valueOf(Bukkit.getServer().getOnlinePlayers().size()));
displayLine = displayLine.replace("%players_max", String.valueOf(Bukkit.getServer().getMaxPlayers()));
Island island = islandManager.getIsland(player);
@ -212,9 +209,9 @@ public class Scoreboard {
PlaceholderManager placeholderManager = skyblock.getPlaceholderManager();
if (placeholderManager.isPlaceholderAPIEnabled()) {
displayLine = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, displayLine.replace("&", "clr")).replace("clr", "&");
displayLine = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, displayLine);
}
return displayLine;
return displayLine.replace("§", "&"); // Returning unformatted line to avoid issues in next step
}
}

View File

@ -110,6 +110,13 @@ public class Stackable {
this.save();
}
public void take(int n) {
this.size-=n;
this.updateDisplay();
SkyBlock.getInstance().getSoundManager().playSound(this.location, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
this.save();
}
public boolean isMaxSize(){
return size > maxSize;
}

View File

@ -1,5 +1,6 @@
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;
@ -80,11 +81,7 @@ public class MobNetherWaterTask extends BukkitRunnable {
private void removeWater(World world, Block block) {
if (block.getType().equals(Material.WATER)) {
block.setType(Material.AIR, true);
if(NMSUtil.getVersionNumber() > 8){
world.playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f);
} else {
// TODO Find a sound for 1.8
}
block.getWorld().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1f, 1f);
world.playEffect(block.getLocation(), Effect.SMOKE, 1);
}
}

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

@ -18,6 +18,8 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@ -38,33 +40,36 @@ public final class LocationUtil {
}
}
public static Location getSafeLocation(Location loc){
public static @Nullable 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);
Location locChecked = null;
if(loc != null && loc.getWorld() != null){
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) {
locChecked = locChecked.add(0d,1d,0d);
} else {
locChecked = null;
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){
public static @Nonnull 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(Material.WATER) ||
if(locWorking.getBlock().getType().equals(CompatibleMaterial.WATER.getMaterial()) ||
(NMSUtil.getVersionNumber() > 13 && locWorking.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
loc = locWorking;
}
@ -80,11 +85,11 @@ public final class LocationUtil {
!locChecked.getBlock().isLiquid() &&
locChecked.getBlock().getType().isSolid() &&
locChecked.getBlock().getType().isBlock() &&
locChecked.add(0d,1d,0d).getBlock().getType().equals(Material.AIR) &&
locChecked.add(0d,2d,0d).getBlock().getType().equals(Material.AIR) &&
!(NMSUtil.getVersionNumber() <= 13 || locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
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(locChecked.getBlock().getType()){
switch(CompatibleMaterial.getMaterial(locChecked.getBlock())){
case ACACIA_DOOR: // <= 1.8.8
case ACACIA_FENCE_GATE:
case BIRCH_DOOR:
@ -99,17 +104,17 @@ public final class LocationUtil {
case LADDER:
case SPRUCE_DOOR:
case SPRUCE_FENCE_GATE:
case ACACIA_BUTTON: // TODO check server version
case ACACIA_TRAPDOOR: // TODO check server version
case BIRCH_TRAPDOOR: // TODO check server version
case CAMPFIRE: // TODO check server version
case COBWEB: // TODO check server version
case DARK_OAK_TRAPDOOR: // TODO check server version
case JUNGLE_TRAPDOOR: // TODO check server version
case MAGMA_BLOCK: // TODO check server version
case NETHER_PORTAL: // TODO check server version
case OAK_DOOR: // TODO check server version
case OAK_FENCE_GATE: // TODO check server version
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;
}

View File

@ -1683,14 +1683,11 @@ challenges:
- 'NEAR:COW 1'
- 'NEAR:RABBIT 1'
- 'NEAR:WOLF 1'
- 'NEAR:DONKEY 1'
- 'NEAR:HORSE 1'
- 'NEAR:LLAMA 1'
- 'NEAR:OCELOT 1'
- 'NEAR:MUSHROOM_COW 1'
- 'NEAR:SHEEP 1'
- 'NEAR:VILLAGER 1'
- 'NEAR:SKELETON_HORSE 1'
reward:
- 'CMD:eco give {player} 3000'
- 'ITEM:diamond_block 32'
@ -1709,14 +1706,11 @@ challenges:
- '&e - 1 Cow'
- '&e - 1 Rabbit'
- '&e - 1 Wolf'
- '&e - 1 Donkey'
- '&e - 1 Horse'
- '&e - 1 Llama'
- '&e - 1 Ocelot'
- '&e - 1 Mooshroom cow'
- '&e - 1 Sheep'
- '&e - 1 Villager'
- '&e - 1 Skeleton Horse'
- '&c&lRewards:'
- '&e- 32 diamond blocks'
- '&e- 3000 $'

View File

@ -37,7 +37,7 @@ Island:
Time: 60
# [!] How many seconds to wait before teleporting to a newly created island
TeleportTimeout: 1
# The distance between the islands
# The distance between the islands EXPERIMENTAL!
Distance: 1200
Deletion:
# [!] You are adviced to keep these options both enabled to prevent any issues.
@ -210,7 +210,7 @@ Island:
# Island Level Points divided by value
Division: 100
# Points to subtract to Island Level Points
Subtract: 1000
Subtract: 0
Cooldown:
# Time until Island level rescan expires
Time: 60
@ -300,6 +300,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.

View File

@ -452,6 +452,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:
@ -785,6 +787,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:
@ -1160,6 +1164,18 @@ Menu:
Displayname: '&aDoor Use'
Jukebox:
Displayname: '&aJukebox Use'
PvP:
Displayname: '&aPvP'
Noteblock:
Displayname: '&aNoteblock use'
Minecart:
Displayname: '&aMinecart'
Damage:
Displayname: '&aDamage'
Boat:
Displayname: '&aBoat'
Trample:
Displayname: '&aTrample'
Bucket:
Displayname: '&aBucket Use'
SpawnEgg:
@ -1517,6 +1533,18 @@ Menu:
- '&7Status&8: &cfalse'
Milking:
Displayname: '&aMilking'
PvP:
Displayname: '&aPvP'
Noteblock:
Displayname: '&aNoteblock use'
Minecart:
Displayname: '&aMinecart'
Damage:
Displayname: '&aDamage'
Boat:
Displayname: '&aBoat'
Trample:
Displayname: '&aTrample'
Anvil:
Displayname: '&aAnvil Use'
Portal:
@ -3262,21 +3290,43 @@ Menu:
Title: 'Bank'
Item:
Exit:
Displayname: 'Exit'
Lore: 'Exits the Menu'
Displayname: '&cExit'
Lore: '&7Exits the Menu'
Barrier:
Displayname: '&cBank'
Log:
Displayname: 'Transaction Log'
Empty: 'Looks like you haven''t got transactions'
Displayname: '&fTransaction Log'
Empty: '&7Looks like you haven''t got transactions'
Deposit:
Displayname: 'Deposit'
Lore: 'Click to deposit your money. Everything or a custom ammount.'
Displayname: '&fDeposit'
Lore: '&7Click to deposit your money. Everything or a custom amount.'
Withdraw:
Displayname: 'Withdraw'
Lore: 'Click to withdraw your money. Everything or a custom ammount.'
Displayname: '&fWithdraw'
Lore: '&7Click to withdraw your money. Everything or a custom amount.'
Balance:
Displayname: 'Balance'
Displayname: '&fBalance'
Lore: '&7Bank balance: &6$%balance'
Next:
Displayname: '&aNext Page'
Last:
Displayname: '&aPrevious Page'
Transactions:
Info:
Displayname: '&fInfo'
Lore: '&7Total transactions: %totalTransactions'
Title: 'Transactions'
Withdraw:
DisplayName: '&c%dateTime'
Format: '&7 %playerName withdrawn %amount'
Deposit:
DisplayName: '&a%dateTime'
Format: '&7 %playerName deposited %amount'
Admin: '&cAdmin&7'
DateTimeFormat: 'dd/MM/yyyy HH:mm:ss'
Words:
Withdraw: 'Withdraw'
Deposit: 'Deposit'
Amount: 'Amount'
Input:
Title: 'Select amount.'
Item:

View File

@ -5,7 +5,7 @@ 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]
softdepend: [HolographicDisplays, Holograms, CMI, PlaceholderAPI, MVdWPlaceholderAPI, Vault, Reserve, LeaderHeads, EpicSpawners, WildStacker, UltimateStacker, WorldEdit, Residence]
loadbefore: [Multiverse-Core, ProtocolLib]
commands:
island:

View File

@ -48,6 +48,7 @@ Settings:
ExperienceOrbPickup: false
Trapdoor: false
Noteblock: false
Damage: true
Member:
Destroy: true
Place: true
@ -97,6 +98,7 @@ Settings:
ExperienceOrbPickup: true
Trapdoor: true
Noteblock: true
Damage: true
Operator:
Invite: true
Kick: true
@ -158,13 +160,11 @@ Settings:
Hopper: true
EntityPlacement: true
ExperienceOrbPickup: true
Damage: true
Owner:
NaturalMobSpawning: true
MobGriefing: false
PvP: false
Explosions: false
FireSpread: true
LeafDecay: true
KeepItemsOnDeath: true
Damage: true
Hunger: true
KeepItemsOnDeath: true