mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 18:55:30 +01:00
The permissions overhaul.
This commit is contained in:
parent
501e7a0e75
commit
b5121fe37e
@ -28,6 +28,6 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.songoda:epicspawners:6-pre4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.songoda:EpicAnchors:1.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.sk89q:worldedit-bukkit:7.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.songoda:SongodaCore:2.3.34" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.songoda:SongodaCore:2.3.37" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -4,6 +4,7 @@ import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.skyblock.api.SkyBlockAPI;
|
||||
import com.songoda.skyblock.ban.BanManager;
|
||||
@ -15,6 +16,7 @@ import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.confirmation.ConfirmationTask;
|
||||
import com.songoda.skyblock.cooldown.CooldownManager;
|
||||
import com.songoda.skyblock.generator.GeneratorManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.tasks.HologramTask;
|
||||
import com.songoda.skyblock.invite.InviteManager;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
@ -44,7 +46,6 @@ import com.songoda.skyblock.world.WorldManager;
|
||||
import com.songoda.skyblock.world.generator.VoidGenerator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@ -82,6 +83,9 @@ public class SkyBlock extends SongodaPlugin {
|
||||
private LocalizationManager localizationManager;
|
||||
private RewardManager rewardManager;
|
||||
private FabledChallenge fabledChallenge;
|
||||
private PermissionManager permissionManager;
|
||||
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
|
||||
public static SkyBlock getInstance() {
|
||||
return INSTANCE;
|
||||
@ -103,6 +107,7 @@ public class SkyBlock extends SongodaPlugin {
|
||||
// Load Holograms
|
||||
com.songoda.core.hooks.HologramManager.load(this);
|
||||
|
||||
permissionManager = new PermissionManager(this);
|
||||
fileManager = new FileManager(this);
|
||||
localizationManager = new LocalizationManager();
|
||||
worldManager = new WorldManager(this);
|
||||
@ -357,4 +362,12 @@ public class SkyBlock extends SongodaPlugin {
|
||||
public FabledChallenge getFabledChallenge() {
|
||||
return fabledChallenge;
|
||||
}
|
||||
|
||||
public PermissionManager getPermissionManager() {
|
||||
return permissionManager;
|
||||
}
|
||||
|
||||
public GuiManager getGuiManager() {
|
||||
return guiManager;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.songoda.skyblock.api.ban.Ban;
|
||||
import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import com.songoda.skyblock.api.visit.Visit;
|
||||
import com.songoda.skyblock.island.IslandCoop;
|
||||
import com.songoda.skyblock.island.IslandPermission;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.WeatherType;
|
||||
@ -360,29 +361,12 @@ public class Island {
|
||||
return this.handle.isUpgrade(APIUtil.toImplementation(upgrade));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Setting of an IslandRole for the Island
|
||||
*/
|
||||
public IslandSetting getSetting(IslandRole role, String setting) {
|
||||
Preconditions.checkArgument(role != null, "Cannot get setting to null role");
|
||||
Preconditions.checkArgument(setting != null, "Cannot get setting for null setting");
|
||||
|
||||
return new IslandSetting(this.handle.getSetting(APIUtil.toImplementation(role), setting));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A List of Settings of an IslandRole for the Island
|
||||
*/
|
||||
public List<IslandSetting> getSettings(IslandRole role) {
|
||||
public List<IslandPermission> getSettings(IslandRole role) {
|
||||
Preconditions.checkArgument(role != null, "Cannot get settings to null role");
|
||||
List<IslandSetting> settings = new ArrayList<>();
|
||||
|
||||
for (com.songoda.skyblock.island.IslandSetting settingList : this.handle
|
||||
.getSettings(APIUtil.toImplementation(role))) {
|
||||
settings.add(new IslandSetting(settingList));
|
||||
}
|
||||
|
||||
return settings;
|
||||
return this.handle.getSettings(APIUtil.toImplementation(role));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.api.structure.Structure;
|
||||
import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import com.songoda.skyblock.island.IslandPermission;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -15,9 +18,11 @@ import java.util.UUID;
|
||||
public class IslandManager {
|
||||
|
||||
private final com.songoda.skyblock.island.IslandManager islandManager;
|
||||
private final PermissionManager permissionManager;
|
||||
|
||||
public IslandManager(com.songoda.skyblock.island.IslandManager islandManager) {
|
||||
this.islandManager = islandManager;
|
||||
this.permissionManager = SkyBlock.getInstance().getPermissionManager();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,41 +80,6 @@ public class IslandManager {
|
||||
this.islandManager.closeIsland(island.getIsland());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player has permission at an Island for a Setting
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasPermission(Player player, String setting) {
|
||||
Preconditions.checkArgument(player != null, "Cannot check permission to null player");
|
||||
|
||||
return this.islandManager.hasPermission(player, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player has permission at a location of an Island for a Setting
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasPermission(Player player, Location location, String setting) {
|
||||
Preconditions.checkArgument(player != null, "Cannot check permission to null player");
|
||||
Preconditions.checkArgument(location != null, "Cannot check permission to null location");
|
||||
|
||||
return this.islandManager.hasPermission(player, location, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the permission of a Setting for a Role at a Location
|
||||
*
|
||||
* @return true of conditions met, false otherwise
|
||||
*/
|
||||
public boolean hasSetting(Location location, IslandRole role, String setting) {
|
||||
Preconditions.checkArgument(location != null, "Cannot check setting to null location");
|
||||
Preconditions.checkArgument(role != null, "Cannot check setting to null role");
|
||||
|
||||
return this.islandManager.hasSetting(location, APIUtil.toImplementation(role), setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A Set of Members of an Island that are online
|
||||
*/
|
||||
|
@ -1,31 +0,0 @@
|
||||
package com.songoda.skyblock.api.island;
|
||||
|
||||
public class IslandSetting {
|
||||
|
||||
private final com.songoda.skyblock.island.IslandSetting handle;
|
||||
|
||||
public IslandSetting(com.songoda.skyblock.island.IslandSetting handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name of the Setting
|
||||
*/
|
||||
public String getName() {
|
||||
return this.handle.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The status condition of the Setting
|
||||
*/
|
||||
public boolean getStatus() {
|
||||
return this.handle.getStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status condition for the Setting
|
||||
*/
|
||||
public void setStatus(boolean status) {
|
||||
this.handle.setStatus(status);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -27,6 +28,7 @@ public class BanCommand extends SubCommand {
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
@ -42,7 +44,7 @@ public class BanCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) && island.getSetting(IslandRole.Operator, "Ban").getStatus())) {
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "Ban", IslandRole.Operator))) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
UUID targetPlayerUUID = null;
|
||||
|
@ -30,7 +30,7 @@ public class BansCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Unban").getStatus())
|
||||
&& skyblock.getPermissionManager().hasPermission(island, "Unban", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (island.getBan().getBans().size() == 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Bans.Message"));
|
||||
|
@ -32,7 +32,7 @@ public class BiomeCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Biome").getStatus())
|
||||
&& skyblock.getPermissionManager().hasPermission(island,"Biome", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
Biome.getInstance().open(player);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
|
@ -9,6 +9,7 @@ import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.menus.Border;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -22,6 +23,7 @@ public class BorderCommand extends SubCommand {
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
@ -34,7 +36,7 @@ public class BorderCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Border.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Border").getStatus())
|
||||
&& permissionManager.hasPermission(island, "Border", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.WorldBorder.Enable")) {
|
||||
|
@ -32,7 +32,7 @@ public class CloseCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Visitor").getStatus())) {
|
||||
&& skyblock.getPermissionManager().hasPermission(island,"Visitor", IslandRole.Operator))) {
|
||||
if (island.isOpen()) {
|
||||
islandManager.closeIsland(island);
|
||||
|
||||
|
@ -10,6 +10,7 @@ import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.menus.Coop;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
@ -27,6 +28,7 @@ public class CoopCommand extends SubCommand {
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
@ -44,7 +46,7 @@ public class CoopCommand extends SubCommand {
|
||||
.getBoolean("Island.Coop.Enable")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "CoopPlayers").getStatus())) {
|
||||
&& permissionManager.hasPermission(island, "CoopPlayers", IslandRole.Operator))) {
|
||||
if (args.length == 1 || args.length == 2) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class InviteCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Invite").getStatus())) {
|
||||
&& skyblock.getPermissionManager().hasPermission(island, "Invite", IslandRole.Operator))) {
|
||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
|
||||
if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()
|
||||
|
@ -38,7 +38,7 @@ public class KickAllCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Kick").getStatus())) {
|
||||
&& skyblock.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator))) {
|
||||
if (island.isOpen()) {
|
||||
Set<UUID> islandVisitors = islandManager.getVisitorsAtIsland(island);
|
||||
|
||||
|
@ -6,6 +6,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -40,6 +41,7 @@ public class KickCommand extends SubCommand {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
@ -52,7 +54,7 @@ public class KickCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) && island.getSetting(IslandRole.Operator, "Kick").getStatus())) {
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "Kick", IslandRole.Operator))) {
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
|
||||
|
@ -7,6 +7,7 @@ import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -21,6 +22,7 @@ public class OpenCommand extends SubCommand {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -32,7 +34,7 @@ public class OpenCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Visitor").getStatus())) {
|
||||
&& permissionManager.hasPermission(island, "Visitor", IslandRole.Operator))) {
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Already.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
@ -32,7 +32,7 @@ public class PublicCommand extends SubCommand {
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Visitor").getStatus())) {
|
||||
&& skyblock.getPermissionManager().hasPermission(island, "Visitor", IslandRole.Operator))) {
|
||||
if (island.isOpen()) {
|
||||
islandManager.closeIsland(island);
|
||||
|
||||
|
@ -51,7 +51,8 @@ public class SetSpawnCommand extends SubCommand {
|
||||
if (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& (island.getSetting(IslandRole.Operator, environment.name() + "Spawn").getStatus()))
|
||||
&& (skyblock.getPermissionManager().hasPermission(island,
|
||||
environment.name() + "Spawn", IslandRole.Operator)))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (islandManager.isPlayerAtIsland(island, player)) {
|
||||
IslandWorld world = skyblock.getWorldManager().getIslandWorld(player.getWorld());
|
||||
|
@ -3,11 +3,15 @@ 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.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;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -22,6 +26,7 @@ public class SettingsCommand extends SubCommand {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -34,16 +39,15 @@ public class SettingsCommand extends SubCommand {
|
||||
} else if (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& (island.getSetting(IslandRole.Operator, "Visitor").getStatus()
|
||||
|| island.getSetting(IslandRole.Operator, "Member").getStatus()))
|
||||
&& (permissionManager.hasPermission(island, "Visitor", IslandRole.Operator)
|
||||
|| permissionManager.hasPermission(island, "Member", IslandRole.Operator)))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
Settings.getInstance().open(player,
|
||||
Settings.Type.Categories, null, null);
|
||||
skyblock.getGuiManager().showGUI(player, new GuiPermissionsSelector(skyblock, island, null));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
} else{
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Settings.Permission.Default.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Settings.Role.Message"));
|
||||
|
@ -41,7 +41,7 @@ public class UnbanCommand extends SubCommand {
|
||||
.getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Unban").getStatus())) {
|
||||
&& skyblock.getPermissionManager().hasPermission(island,"Unban", IslandRole.Operator))) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
UUID targetPlayerUUID = null;
|
||||
|
@ -31,7 +31,7 @@ public class WeatherCommand extends SubCommand {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Weather.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Weather").getStatus())
|
||||
&& skyblock.getPermissionManager().hasPermission(island, "Weather", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
Weather.getInstance().open(player);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
|
||||
|
163
src/main/java/com/songoda/skyblock/gui/GuiPermissions.java
Normal file
163
src/main/java/com/songoda/skyblock/gui/GuiPermissions.java
Normal file
@ -0,0 +1,163 @@
|
||||
package com.songoda.skyblock.gui;
|
||||
|
||||
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.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GuiPermissions extends Gui {
|
||||
|
||||
private SkyBlock plugin;
|
||||
private final PermissionManager permissionManager;
|
||||
private final IslandRole role;
|
||||
private final Island island;
|
||||
private final FileConfiguration configLoad;
|
||||
private final FileManager.Config config;
|
||||
private final Gui returnGui;
|
||||
|
||||
public GuiPermissions(SkyBlock plugin, Island island, IslandRole role, Gui returnGui) {
|
||||
super(6, returnGui);
|
||||
this.plugin = plugin;
|
||||
this.permissionManager = plugin.getPermissionManager();
|
||||
this.role = role;
|
||||
this.island = island;
|
||||
this.returnGui = returnGui;
|
||||
this.configLoad = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
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);
|
||||
});
|
||||
|
||||
if (role == IslandRole.Visitor) {
|
||||
if (config.getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable"))
|
||||
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 WelcomeEditor(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 SignatureEditor(plugin, this, island));
|
||||
});
|
||||
}
|
||||
|
||||
Visit visit = island.getVisit();
|
||||
List<String> welcomeLore = TextUtils.formatText(configLoad.getStringList(
|
||||
island.isOpen()
|
||||
? "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Closed.Lore"
|
||||
: "Menu.Settings.Visitor.Item.Statistics.Vote.Enabled.Open.Lore"));
|
||||
|
||||
List<String> welcomeFinal = new ArrayList<>();
|
||||
|
||||
for (String line : welcomeLore) {
|
||||
welcomeFinal.add(line.replace("%visits", String.valueOf(visit.getVisitors().size()))
|
||||
.replace("%votes", String.valueOf(visit.getVoters().size()))
|
||||
.replace("%visitors", String.valueOf(plugin.getIslandManager().getVisitorsAtIsland(island).size())));
|
||||
}
|
||||
|
||||
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.PAINTING,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname")),
|
||||
welcomeFinal),
|
||||
(event -> {
|
||||
if (island.isOpen()) {
|
||||
plugin.getIslandManager().closeIsland(island);
|
||||
CompatibleSound.BLOCK_WOODEN_DOOR_CLOSE.play(event.player);
|
||||
} else {
|
||||
island.setOpen(true);
|
||||
CompatibleSound.BLOCK_WOODEN_DOOR_OPEN.play(event.player);
|
||||
}
|
||||
paint();
|
||||
}));
|
||||
}
|
||||
|
||||
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, "Back"),
|
||||
(event) -> {
|
||||
page--;
|
||||
paint();
|
||||
});
|
||||
|
||||
if (page != pages)
|
||||
setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, "Next"),
|
||||
(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;
|
||||
|
||||
setButton(i, permission.getItem(island, role), (event) -> {
|
||||
IslandPermission islandPermission = island.getPermission(role, permission);
|
||||
islandPermission.setStatus(!islandPermission.getStatus());
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.songoda.skyblock.gui;
|
||||
|
||||
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.island.Island;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class GuiPermissionsSelector extends Gui {
|
||||
|
||||
public GuiPermissionsSelector(SkyBlock plugin, Island island, Gui returnGui) {
|
||||
super(1, returnGui);
|
||||
setDefaultItem(null);
|
||||
|
||||
FileConfiguration configLoad = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
|
||||
setTitle(ChatColor.translateAlternateColorCodes('&',
|
||||
TextUtils.formatText(configLoad.getString("Menu.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)));
|
||||
|
||||
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)));
|
||||
|
||||
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)));
|
||||
|
||||
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) -> {
|
||||
CompatibleSound.BLOCK_CHEST_CLOSE.play(event.player);
|
||||
guiManager.showGUI(event.player, returnGui);
|
||||
});
|
||||
|
||||
if (isCoop)
|
||||
setButton(6, GuiUtils.createButtonItem(CompatibleMaterial.NAME_TAG,
|
||||
TextUtils.formatText(configLoad.getString("Menu.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)));
|
||||
|
||||
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)));
|
||||
|
||||
}
|
||||
}
|
86
src/main/java/com/songoda/skyblock/gui/SignatureEditor.java
Normal file
86
src/main/java/com/songoda/skyblock/gui/SignatureEditor.java
Normal file
@ -0,0 +1,86 @@
|
||||
package com.songoda.skyblock.gui;
|
||||
|
||||
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.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.IslandMessage;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SignatureEditor extends Gui {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final FileConfiguration configLoad;
|
||||
private final Gui returnGui;
|
||||
private final Island island;
|
||||
private final FileManager.Config mainConfig;
|
||||
|
||||
public SignatureEditor(SkyBlock plugin, Gui returnGui, Island island) {
|
||||
super(1);
|
||||
this.plugin = plugin;
|
||||
this.returnGui = returnGui;
|
||||
this.island = island;
|
||||
this.configLoad = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.mainConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
setDefaultItem(null);
|
||||
setTitle(TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Title")));
|
||||
paint();
|
||||
}
|
||||
|
||||
public void paint() {
|
||||
List<String> signatureMessage = island.getMessage(IslandMessage.Signature);
|
||||
setButton(2, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Item.Return.Displayname"))),
|
||||
(event) -> guiManager.showGUI(event.player, returnGui));
|
||||
setButton(6, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Item.Return.Displayname"))),
|
||||
(event) -> guiManager.showGUI(event.player, returnGui));
|
||||
|
||||
setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Item.Line.Add.Displayname")),
|
||||
TextUtils.formatText(configLoad.getStringList(
|
||||
signatureMessage.size() == mainConfig.getFileConfiguration().getInt("Island.Visitor.Signature.Lines")
|
||||
? "Menu.Settings.Visitor.Panel.Signature.Item.Line.Add.Limit.Lore"
|
||||
: "Menu.Settings.Visitor.Panel.Signature.Item.Line.Add.More.Lore"))),
|
||||
(event -> {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setAction((e -> {
|
||||
signatureMessage.add(gui.getInputText().trim());
|
||||
island.setMessage(IslandMessage.Signature, e.player.getName(), signatureMessage);
|
||||
CompatibleSound.BLOCK_NOTE_BLOCK_PLING.play(e.player);
|
||||
e.player.closeInventory();
|
||||
paint();
|
||||
}));
|
||||
gui.setTitle(configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Item.Line.Add.Word.Enter"));
|
||||
guiManager.showGUI(event.player, gui);
|
||||
}));
|
||||
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
itemLore.add(configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Item.Message.Word.Empty"));
|
||||
setItem(4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_SIGN,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Item.Message.Displayname")),
|
||||
TextUtils.formatText(signatureMessage.size() == 0 ? itemLore : signatureMessage)));
|
||||
|
||||
setButton(5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Item.Line.Remove.Displayname")),
|
||||
TextUtils.formatText(configLoad.getStringList(
|
||||
signatureMessage.size() == 0
|
||||
? "Menu.Settings.Visitor.Panel.Signature.Item.Line.Remove.None.Lore"
|
||||
: "Menu.Settings.Visitor.Panel.Signature.Item.Line.Remove.Lines.Lore"))),
|
||||
(event -> {
|
||||
signatureMessage.remove(signatureMessage.size() - 1);
|
||||
island.setMessage(IslandMessage.Signature, event.player.getName(), signatureMessage);
|
||||
paint();
|
||||
}));
|
||||
}
|
||||
}
|
137
src/main/java/com/songoda/skyblock/gui/WelcomeEditor.java
Normal file
137
src/main/java/com/songoda/skyblock/gui/WelcomeEditor.java
Normal file
@ -0,0 +1,137 @@
|
||||
package com.songoda.skyblock.gui;
|
||||
|
||||
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.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.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandMessage;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WelcomeEditor extends Gui {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final FileConfiguration configLoad;
|
||||
private final Gui returnGui;
|
||||
private final Island island;
|
||||
private final FileManager.Config mainConfig;
|
||||
private final MessageManager messageManager;
|
||||
private final IslandManager islandManager;
|
||||
|
||||
public WelcomeEditor(SkyBlock plugin, Gui returnGui, Island island) {
|
||||
super(1);
|
||||
this.plugin = plugin;
|
||||
this.returnGui = returnGui;
|
||||
this.island = island;
|
||||
this.configLoad = plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
this.mainConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
this.islandManager = plugin.getIslandManager();
|
||||
setDefaultItem(null);
|
||||
setTitle(TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Title")));
|
||||
paint();
|
||||
}
|
||||
|
||||
public void paint() {
|
||||
List<String> welcomeMessage = island.getMessage(IslandMessage.Welcome);
|
||||
setButton(2, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Item.Return.Displayname"))),
|
||||
(event) -> guiManager.showGUI(event.player, returnGui));
|
||||
setButton(6, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Item.Return.Displayname"))),
|
||||
(event) -> guiManager.showGUI(event.player, returnGui));
|
||||
|
||||
setButton(3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Item.Line.Add.Displayname")),
|
||||
TextUtils.formatText(configLoad.getStringList(
|
||||
welcomeMessage.size() == mainConfig.getFileConfiguration().getInt("Island.Visitor.Welcome.Lines")
|
||||
? "Menu.Settings.Visitor.Panel.Welcome.Item.Line.Add.Limit.Lore"
|
||||
: "Menu.Settings.Visitor.Panel.Welcome.Item.Line.Add.More.Lore"))),
|
||||
(event -> {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setAction((e -> {
|
||||
if (!hasPermission(e.player))
|
||||
return;
|
||||
if (island.getMessage(IslandMessage.Signature)
|
||||
.size() > mainConfig.getFileConfiguration().getInt(
|
||||
"Island.Visitor.Signature.Lines")
|
||||
|| gui.getInputText().length() > mainConfig.getFileConfiguration()
|
||||
.getInt("Island.Visitor.Signature.Length")) {
|
||||
CompatibleSound.BLOCK_ANVIL_LAND.play(e.player);
|
||||
} else {
|
||||
welcomeMessage.add(gui.getInputText().trim());
|
||||
island.setMessage(IslandMessage.Welcome, e.player.getName(), welcomeMessage);
|
||||
CompatibleSound.BLOCK_NOTE_BLOCK_PLING.play(e.player);
|
||||
}
|
||||
e.player.closeInventory();
|
||||
paint();
|
||||
}));
|
||||
gui.setTitle(configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Item.Line.Add.Word.Enter"));
|
||||
guiManager.showGUI(event.player, gui);
|
||||
}));
|
||||
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
itemLore.add(configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Item.Message.Word.Empty"));
|
||||
setItem(4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_SIGN,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Item.Message.Displayname")),
|
||||
TextUtils.formatText(welcomeMessage.size() == 0 ? itemLore : welcomeMessage)));
|
||||
|
||||
setButton(5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW,
|
||||
TextUtils.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Item.Line.Remove.Displayname")),
|
||||
TextUtils.formatText(configLoad.getStringList(
|
||||
welcomeMessage.size() == 0
|
||||
? "Menu.Settings.Visitor.Panel.Welcome.Item.Line.Remove.None.Lore"
|
||||
: "Menu.Settings.Visitor.Panel.Welcome.Item.Line.Remove.Lines.Lore"))),
|
||||
(event -> {
|
||||
welcomeMessage.remove(welcomeMessage.size() - 1);
|
||||
island.setMessage(IslandMessage.Welcome, event.player.getName(), welcomeMessage);
|
||||
paint();
|
||||
}));
|
||||
}
|
||||
|
||||
private boolean hasPermission(Player player) {
|
||||
Island island1 = islandManager.getIsland(player);
|
||||
|
||||
if (island1 == null) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString(
|
||||
"Command.Island.Settings.Owner.Message"));
|
||||
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
|
||||
player.closeInventory();
|
||||
return false;
|
||||
} else if (!(island1.hasRole(IslandRole.Operator,
|
||||
player.getUniqueId())
|
||||
|| island1.hasRole(IslandRole.Owner,
|
||||
player.getUniqueId()))) {
|
||||
messageManager.sendMessage(player, configLoad
|
||||
.getString("Command.Island.Role.Message"));
|
||||
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
|
||||
player.closeInventory();
|
||||
return false;
|
||||
} else if (!plugin.getFileManager()
|
||||
.getConfig(new File(plugin.getDataFolder(),
|
||||
"config.yml"))
|
||||
.getFileConfiguration().getBoolean(
|
||||
"Island.Visitor.Signature.Enable")) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString(
|
||||
"Island.Settings.Visitor.Signature.Disabled.Message"));
|
||||
CompatibleSound.BLOCK_ANVIL_LAND.play(player);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -9,6 +9,8 @@ import com.songoda.skyblock.ban.Ban;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.upgrade.Upgrade;
|
||||
@ -36,7 +38,7 @@ public class Island {
|
||||
private final SkyBlock skyblock;
|
||||
private final com.songoda.skyblock.api.island.Island apiWrapper;
|
||||
|
||||
private Map<IslandRole, List<IslandSetting>> islandSettings = new HashMap<>();
|
||||
private Map<IslandRole, List<IslandPermission>> islandPermissions = new HashMap<>();
|
||||
private List<IslandLocation> islandLocations = new ArrayList<>();
|
||||
private Map<UUID, IslandCoop> coopPlayers = new HashMap<>();
|
||||
|
||||
@ -50,6 +52,7 @@ public class Island {
|
||||
this.skyblock = SkyBlock.getInstance();
|
||||
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
|
||||
this.islandUUID = UUID.randomUUID();
|
||||
this.ownerUUID = player.getUniqueId();
|
||||
@ -159,18 +162,22 @@ public class Island {
|
||||
}
|
||||
|
||||
for (IslandRole roleList : IslandRole.getRoles()) {
|
||||
List<IslandSetting> settings = new ArrayList<>();
|
||||
List<IslandPermission> permissions = new ArrayList<>();
|
||||
|
||||
for (String settingList : defaultSettingsConfig.getFileConfiguration().getConfigurationSection("Settings." + roleList.name()).getKeys(false)) {
|
||||
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration().getString("Settings." + roleList.name() + "." + settingList) == null) {
|
||||
settings.add(
|
||||
new IslandSetting(settingList, defaultSettingsConfig.getFileConfiguration().getBoolean("Settings." + roleList.name() + "." + settingList)));
|
||||
for (BasicPermission permission : skyblock.getPermissionManager().getPermissions()) {
|
||||
|
||||
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration()
|
||||
.getString("Settings." + roleList.name() + "." + permission.getName()) == null) {
|
||||
permissions.add(
|
||||
new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration()
|
||||
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
|
||||
} else {
|
||||
settings.add(new IslandSetting(settingList, settingsDataConfig.getFileConfiguration().getBoolean("Settings." + roleList.name() + "." + settingList)));
|
||||
permissions.add(new IslandPermission(permission, settingsDataConfig.getFileConfiguration()
|
||||
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
|
||||
}
|
||||
}
|
||||
|
||||
islandSettings.put(roleList, settings);
|
||||
islandPermissions.put(roleList, permissions);
|
||||
}
|
||||
} else {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -186,15 +193,15 @@ public class Island {
|
||||
configLoad.set("Ownership.Original", ownerUUID.toString());
|
||||
|
||||
for (IslandRole roleList : IslandRole.getRoles()) {
|
||||
List<BasicPermission> allPermissions = skyblock.getPermissionManager().getPermissions();
|
||||
List<IslandPermission> permissions = new ArrayList<>(allPermissions.size());
|
||||
|
||||
Set<String> keys = defaultSettingsConfig.getFileConfiguration().getConfigurationSection("Settings." + roleList.name()).getKeys(false);
|
||||
List<IslandSetting> settings = new ArrayList<>(keys.size());
|
||||
|
||||
for (String settingList : keys) {
|
||||
settings.add(new IslandSetting(settingList, defaultSettingsConfig.getFileConfiguration().getBoolean("Settings." + roleList.name() + "." + settingList)));
|
||||
for (BasicPermission permission : allPermissions) {
|
||||
permissions.add(
|
||||
new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration().getBoolean("Settings." + roleList.name() + "." + permission, true)));
|
||||
}
|
||||
|
||||
islandSettings.put(roleList, settings);
|
||||
islandPermissions.put(roleList, permissions);
|
||||
}
|
||||
|
||||
save();
|
||||
@ -649,26 +656,34 @@ public class Island {
|
||||
.getFileConfiguration().getBoolean("Upgrade." + type.name());
|
||||
}
|
||||
|
||||
public IslandSetting getSetting(IslandRole role, String setting) {
|
||||
if (islandSettings.containsKey(role)) {
|
||||
for (IslandSetting settingList : islandSettings.get(role)) {
|
||||
if (settingList.getName().equalsIgnoreCase(setting)) {
|
||||
return settingList;
|
||||
}
|
||||
public boolean hasPermission(IslandRole role, BasicPermission permission) {
|
||||
if (islandPermissions.containsKey(role)) {
|
||||
for (IslandPermission islandPermission : islandPermissions.get(role)) {
|
||||
if (islandPermission.getPermission() == permission)
|
||||
return islandPermission.getStatus();
|
||||
}
|
||||
}
|
||||
|
||||
return new IslandSetting(setting, true); //TODO: Default setting value
|
||||
return true; //TODO: Default setting value
|
||||
}
|
||||
|
||||
public List<IslandSetting> getSettings(IslandRole role) {
|
||||
if (islandSettings.containsKey(role)) {
|
||||
return islandSettings.get(role);
|
||||
public IslandPermission getPermission(IslandRole role, BasicPermission permission) {
|
||||
if (islandPermissions.containsKey(role)) {
|
||||
for (IslandPermission islandPermission : islandPermissions.get(role)) {
|
||||
if (islandPermission.getPermission() == permission)
|
||||
return islandPermission;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<IslandPermission> getSettings(IslandRole role) {
|
||||
if (islandPermissions.containsKey(role))
|
||||
return Collections.unmodifiableList(islandPermissions.get(role));
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public double getBankBalance() {
|
||||
return skyblock.getFileManager().getConfig(
|
||||
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
|
||||
@ -809,9 +824,9 @@ public class Island {
|
||||
.getConfig(new File(skyblock.getDataFolder().toString() + "/setting-data", ownerUUID.toString() + ".yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
for (Entry<IslandRole, List<IslandSetting>> entry : islandSettings.entrySet()) {
|
||||
for (IslandSetting setting : entry.getValue()) {
|
||||
configLoad.set("Settings." + entry.getKey() + "." + setting.getName(), setting.getStatus());
|
||||
for (Entry<IslandRole, List<IslandPermission>> entry : islandPermissions.entrySet()) {
|
||||
for (IslandPermission permission : entry.getValue()) {
|
||||
configLoad.set("Settings." + entry.getKey() + "." + permission.getPermission().getName(), permission.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@ -879,4 +894,5 @@ public class Island {
|
||||
public com.songoda.skyblock.api.island.Island getAPIWrapper() {
|
||||
return apiWrapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.songoda.skyblock.island;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.core.utils.PlayerUtils;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.api.event.island.*;
|
||||
import com.songoda.skyblock.ban.BanManager;
|
||||
@ -1184,32 +1183,6 @@ public class IslandManager {
|
||||
return islandStorage.containsKey(uuid);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, String setting) {
|
||||
return hasPermission(player, player.getLocation(), setting);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, org.bukkit.Location location, String setting) {
|
||||
Island island = getIslandAtLocation(location);
|
||||
|
||||
if (island == null) return true;
|
||||
|
||||
if (player.hasPermission("fabledskyblock.bypass." + setting.toLowerCase())) return true;
|
||||
|
||||
if (island.getSetting(island.getRole(player), setting).getStatus()) return true;
|
||||
|
||||
if (island.isCoopPlayer(player.getUniqueId()) && island.getSetting(IslandRole.Coop, setting).getStatus())
|
||||
return true;
|
||||
|
||||
return island.getSetting(IslandRole.Visitor, setting).getStatus();
|
||||
}
|
||||
|
||||
public boolean hasSetting(org.bukkit.Location location, IslandRole role, String setting) {
|
||||
Island island = getIslandAtLocation(location);
|
||||
if (island == null) return false;
|
||||
|
||||
return island.getSetting(role, setting).getStatus();
|
||||
}
|
||||
|
||||
public void removeSpawnProtection(org.bukkit.Location location) {
|
||||
Block block = location.getBlock();
|
||||
|
||||
@ -1386,7 +1359,7 @@ public class IslandManager {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
boolean coopPlayers = island.getSetting(IslandRole.Operator, "CoopPlayers").getStatus();
|
||||
boolean coopPlayers = island.hasPermission(IslandRole.Operator, skyblock.getPermissionManager().getPermission("CoopPlayers"));
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (uuid != null && all.getUniqueId().equals(uuid)) {
|
||||
@ -1433,7 +1406,7 @@ public class IslandManager {
|
||||
settings.put("Damage", true);
|
||||
|
||||
for (String settingList : settings.keySet()) {
|
||||
if (configLoad.getBoolean("Island.Settings." + settingList + ".Enable") && island.getSetting(IslandRole.Owner, settingList).getStatus() == settings.get(settingList)) {
|
||||
if (configLoad.getBoolean("Island.Settings." + settingList + ".Enable") && island.hasPermission(IslandRole.Owner, skyblock.getPermissionManager().getPermission(settingList)) == settings.get(settingList)) {
|
||||
safeLevel++;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.songoda.skyblock.island;
|
||||
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
|
||||
public class IslandPermission {
|
||||
|
||||
private final BasicPermission permission;
|
||||
private boolean status;
|
||||
|
||||
public IslandPermission(BasicPermission permission, boolean status) {
|
||||
this.permission = permission;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public BasicPermission getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public boolean getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.songoda.skyblock.island;
|
||||
|
||||
public class IslandSetting {
|
||||
|
||||
private String name;
|
||||
private boolean status;
|
||||
|
||||
public IslandSetting(String name, boolean status) {
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
@ -10,6 +10,8 @@ import com.songoda.skyblock.generator.GeneratorManager;
|
||||
import com.songoda.skyblock.island.*;
|
||||
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
|
||||
import com.songoda.skyblock.limit.impl.BlockLimitation;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
|
||||
import com.songoda.skyblock.stackable.Stackable;
|
||||
import com.songoda.skyblock.stackable.StackableManager;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
@ -66,10 +68,8 @@ public class Block implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!islandManager.hasPermission(player, blockLocation, "Destroy")) {
|
||||
event.setCancelled(true);
|
||||
skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(event, player, island)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -203,12 +203,10 @@ public class Block implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!islandManager.hasPermission(player, blockLoc, "Place")) {
|
||||
event.setCancelled(true);
|
||||
skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(new PlayerEnterPortalEvent(player, player.getLocation()),
|
||||
player, island))
|
||||
return;
|
||||
}
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -569,7 +567,10 @@ public class Block implements Listener {
|
||||
if (!worldManager.isIslandWorld(block.getWorld())) return;
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
if (!islandManager.hasSetting(block.getLocation(), IslandRole.Owner, "FireSpread")) event.setCancelled(true);
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
if (!permissionManager.hasPermission(
|
||||
islandManager.getIslandAtLocation(block.getLocation()),"FireSpread", IslandRole.Owner))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -30,19 +30,17 @@ public class Bucket implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
org.bukkit.block.Block block = event.getBlockClicked();
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
CompatibleMaterial clickedBlock = CompatibleMaterial.getBlockMaterial(event.getBlockClicked().getType());
|
||||
|
||||
if (clickedBlock == CompatibleMaterial.WATER
|
||||
|| clickedBlock == CompatibleMaterial.LAVA) {
|
||||
if (skyblock.getWorldManager().isIslandWorld(block.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, block.getLocation(), "Bucket")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(event, player, island))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,24 +50,21 @@ public class Bucket implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
org.bukkit.block.Block block = event.getBlockClicked().getRelative(event.getBlockFace());
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(block.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, block.getLocation(), "Bucket")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(block.getWorld())) {
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(event, player, island))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
|
||||
return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||
|
||||
if (island == null)
|
||||
return;
|
||||
|
||||
|
@ -31,8 +31,8 @@ public class Death implements Listener {
|
||||
boolean keepInventory = false;
|
||||
|
||||
if (configLoad.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
|
||||
if (skyblock.getIslandManager().hasSetting(player.getLocation(), IslandRole.Owner,
|
||||
"KeepItemsOnDeath")) {
|
||||
if (skyblock.getPermissionManager().hasPermission(player.getLocation(),"KeepItemsOnDeath",
|
||||
IslandRole.Owner)) {
|
||||
keepInventory = true;
|
||||
}
|
||||
} else keepInventory = configLoad.getBoolean("Island.KeepItemsOnDeath.Enable");
|
||||
|
@ -1,25 +1,19 @@
|
||||
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.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.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.stackable.StackableManager;
|
||||
import com.songoda.skyblock.upgrade.Upgrade;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import com.songoda.skyblock.utils.world.entity.EntityUtil;
|
||||
import com.songoda.skyblock.world.WorldManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -29,10 +23,8 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -61,46 +53,16 @@ public class Entity implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
event.getCause();
|
||||
if (event.getCause() == DamageCause.VOID) {
|
||||
return;
|
||||
} else if (event.getCause() == DamageCause.ENTITY_ATTACK) {
|
||||
EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) event;
|
||||
|
||||
if (entityDamageByEntityEvent.getDamager() != null && entityDamageByEntityEvent.getDamager() instanceof Player) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (NMSUtil.getVersionNumber() > 11) {
|
||||
if (event.getCause() == DamageCause.valueOf("ENTITY_SWEEP_ATTACK")) {
|
||||
EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) event;
|
||||
|
||||
if (entityDamageByEntityEvent.getDamager() != null && entityDamageByEntityEvent.getDamager() instanceof Player) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Settings.Damage.Enable")) {
|
||||
if (!skyblock.getIslandManager().hasSetting(player.getLocation(), IslandRole.Owner, "Damage")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!configLoad.getBoolean("Island.Damage.Enable")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()));
|
||||
}
|
||||
|
||||
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if
|
||||
@ -113,129 +75,40 @@ public class Entity implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
if (event.getDamager() instanceof Player) {
|
||||
Player player = (Player) event.getDamager();
|
||||
org.bukkit.entity.Entity entity = event.getEntity();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
|
||||
if (entity instanceof Player) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (configLoad.getBoolean("Island.Settings.PvP.Enable")) {
|
||||
if (!islandManager.hasSetting(entity.getLocation(), IslandRole.Owner, "PvP")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!configLoad.getBoolean("Island.PvP.Enable")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (entity instanceof ArmorStand) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "Destroy")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
// Check if it's a monster and player has the permission to damage the entity
|
||||
// If
|
||||
// If it's not a monster or the player has the permission
|
||||
if (EntityUtil.isMonster(entity.getType()) && islandManager.hasPermission(player, entity.getLocation(), "MonsterHurting")) {
|
||||
// Player has permission to damage the entity
|
||||
return;
|
||||
}
|
||||
// Either the entity is not a monster or the player doesn't have permission so whe check if he has permission to damage mobs
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "MobHurting")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager()
|
||||
.processPermission(event, player, islandManager.getIslandAtLocation(entity.getLocation()));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player) {
|
||||
Player player = (Player) ((Projectile) event.getDamager()).getShooter();
|
||||
org.bukkit.entity.Entity entity = event.getEntity();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (entity.getType() == EntityType.ITEM_FRAME && !islandManager.hasPermission(player, entity.getLocation(), "HangingDestroy")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (configLoad.getBoolean("Island.Settings.PvP.Enable")) {
|
||||
if (!islandManager.hasSetting(entity.getLocation(), IslandRole.Owner, "PvP")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!configLoad.getBoolean("Island.PvP.Enable")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
// Check if it's a monster and player has the permission to damage the entity
|
||||
// If
|
||||
// If it's not a monster or the player has the permission
|
||||
if (EntityUtil.isMonster(entity.getType()) && islandManager.hasPermission(player, entity.getLocation(), "MonsterHurting")) {
|
||||
// Player has permission to damage the entity
|
||||
return;
|
||||
}
|
||||
// Either the entity is not a monster or the player doesn't have permission so whe check if he has permission to damage mobs
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "MobHurting")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (event.getEntity() instanceof Player) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager()
|
||||
.processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()));
|
||||
|
||||
if (configLoad.getBoolean("Island.Settings.Damage.Enable")) {
|
||||
if (!islandManager.hasSetting(player.getLocation(), IslandRole.Owner, "Damage") || (event.getDamager() instanceof TNTPrimed
|
||||
&& !islandManager.hasSetting(player.getLocation(), IslandRole.Owner, "Explosions"))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!configLoad.getBoolean("Island.Damage.Enable")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (event.getDamager() instanceof TNTPrimed) {
|
||||
org.bukkit.entity.Entity entity = event.getEntity();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
|
||||
if (!islandManager.hasSetting(entity.getLocation(), IslandRole.Owner, "Explosions")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager()
|
||||
.processPermission(event, islandManager.getIslandAtLocation(entity.getLocation()));
|
||||
}
|
||||
|
||||
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if
|
||||
// the shot entity isn't damaged
|
||||
if (event.isCancelled() && event.getEntity() != null && event.getDamager() instanceof Arrow
|
||||
if (event.isCancelled() && event.getDamager() instanceof Arrow
|
||||
&& ((Arrow) event.getDamager()).getShooter() instanceof Player) {
|
||||
Arrow arrow = (Arrow) event.getDamager();
|
||||
if (arrow.getFireTicks() != 0) {
|
||||
@ -254,19 +127,16 @@ public class Entity implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, event.getEntity().getLocation(), "Shearing")) {
|
||||
event.setCancelled(true);
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
Island island = islandManager.getIslandAtLocation(event.getEntity().getLocation());
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, player, island);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that an entity is not targeting another entity on different islands.
|
||||
* Checks that an entity is not targeting another entity on different islands.x
|
||||
*
|
||||
* @author LimeGlass
|
||||
*/
|
||||
@ -300,13 +170,13 @@ public class Entity implements Listener {
|
||||
@EventHandler
|
||||
public void onStackableInteract(PlayerArmorStandManipulateEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!skyblock.getIslandManager().hasPermission(player, event.getRightClicked().getLocation(), "ArmorStandUse")) {
|
||||
event.setCancelled(true);
|
||||
if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return;
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(event, player,
|
||||
islandManager.getIslandAtLocation(event.getRightClicked().getLocation())))
|
||||
return;
|
||||
|
||||
if (NMSUtil.getVersionNumber() != 8) return;
|
||||
|
||||
@ -325,116 +195,53 @@ public class Entity implements Listener {
|
||||
@EventHandler
|
||||
public void onHangingPlace(HangingPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return;
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, event.getEntity().getLocation(), "EntityPlacement")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, player,
|
||||
islandManager.getIslandAtLocation(event.getEntity().getLocation()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreak(HangingBreakEvent event) {
|
||||
Hanging hanging = event.getEntity();
|
||||
if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return;
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
if (event.getCause() != RemoveCause.EXPLOSION) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasSetting(hanging.getLocation(), IslandRole.Owner, "Explosions")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, null,
|
||||
islandManager.getIslandAtLocation(hanging.getLocation()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreak(HangingBreakByEntityEvent event) {
|
||||
Hanging hanging = event.getEntity();
|
||||
|
||||
if (!(event.getRemover() instanceof Player)) {
|
||||
if (!(event.getRemover() instanceof Player))
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getRemover();
|
||||
if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return;
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, hanging.getLocation(), "HangingDestroy")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingInteract(PlayerInteractEntityEvent event) {
|
||||
if (!(event.getRightClicked() instanceof Hanging)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Hanging hanging = (Hanging) event.getRightClicked();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, hanging.getLocation(), "HangingDestroy")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingRemoveItem(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Player && event.getEntity() instanceof Hanging)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getDamager();
|
||||
Hanging hanging = (Hanging) event.getEntity();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, hanging.getLocation(), "HangingDestroy")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, (Player) event.getRemover(),
|
||||
islandManager.getIslandAtLocation(hanging.getLocation()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityTaming(EntityTameEvent event) {
|
||||
if (!(event.getOwner() instanceof Player)) {
|
||||
if (!(event.getOwner() instanceof Player))
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getOwner();
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, event.getEntity().getLocation(), "MobTaming")) {
|
||||
event.setCancelled(true);
|
||||
if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld())) return;
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, (Player) event.getOwner(),
|
||||
islandManager.getIslandAtLocation(entity.getLocation()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -504,10 +311,8 @@ public class Entity implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!islandManager.hasSetting(entity.getLocation(), IslandRole.Owner, "MobGriefing")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, null, island);
|
||||
|
||||
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Block.Level.Enable"))
|
||||
@ -555,9 +360,10 @@ public class Entity implements Listener {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
|
||||
if (!islandManager.hasSetting(entity.getLocation(), IslandRole.Owner, "Explosions")) {
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().hasPermission(null,
|
||||
islandManager.getIslandAtLocation(entity.getLocation()), "Explosions"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
Island island = islandManager.getIslandAtLocation(entity.getLocation());
|
||||
@ -668,22 +474,16 @@ public class Entity implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityTargetLivingEntity(EntityTargetLivingEntityEvent event) {
|
||||
if (!(event.getTarget() instanceof Player)) {
|
||||
if (!(event.getTarget() instanceof Player))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof ExperienceOrb)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getTarget();
|
||||
if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return;
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, "ExperienceOrbPickup")) {
|
||||
event.setTarget(null);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, player,
|
||||
islandManager.getIslandAtLocation(event.getEntity().getLocation()));
|
||||
}
|
||||
|
||||
private static final Set<SpawnReason> CHECKED_REASONS;
|
||||
@ -724,7 +524,6 @@ public class Entity implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SpawnReason spawnReason = event.getSpawnReason();
|
||||
@ -732,7 +531,7 @@ public class Entity implements Listener {
|
||||
if (!CHECKED_REASONS.contains(spawnReason)) return;
|
||||
|
||||
if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld())) return;
|
||||
if (skyblock.getIslandManager().hasSetting(entityLocation, IslandRole.Owner, "NaturalMobSpawning")) return;
|
||||
if (skyblock.getPermissionManager().hasPermission(null, island, "NaturalMobSpawning")) return;
|
||||
if (spawnReason != SpawnReason.JOCKEY && spawnReason != SpawnReason.MOUNT) {
|
||||
entity.remove(); // Older versions ignore the event being cancelled, so this fixes that issue.
|
||||
return;
|
||||
|
@ -1,14 +1,11 @@
|
||||
package com.songoda.skyblock.listeners;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Food implements Listener {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
@ -22,11 +19,8 @@ public class Food implements Listener {
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")
|
||||
&& !skyblock.getIslandManager().hasSetting(player.getLocation(), IslandRole.Owner, "Hunger")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, player, player.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -182,8 +183,8 @@ public class Grow implements Listener {
|
||||
org.bukkit.block.Block block = event.getBlock();
|
||||
if (!skyblock.getWorldManager().isIslandWorld(block.getWorld())) return;
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
if (!islandManager.hasSetting(block.getLocation(), IslandRole.Owner, "FireSpread")) event.setCancelled(true);
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
if (!permissionManager.hasPermission(block.getLocation(), "FireSpread", IslandRole.Owner)) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -191,8 +192,8 @@ public class Grow implements Listener {
|
||||
org.bukkit.block.Block block = event.getBlock();
|
||||
if (!skyblock.getWorldManager().isIslandWorld(block.getWorld())) return;
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
if (!islandManager.hasSetting(block.getLocation(), IslandRole.Owner, "LeafDecay")) event.setCancelled(true);
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
if (!permissionManager.hasPermission(block.getLocation(), "LeafDecay", IslandRole.Owner)) event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,20 +18,13 @@ import com.songoda.skyblock.stackable.Stackable;
|
||||
import com.songoda.skyblock.stackable.StackableManager;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import com.songoda.skyblock.utils.structure.StructureUtil;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import com.songoda.skyblock.world.WorldManager;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Beacon;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.StorageMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -41,7 +34,6 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
@ -66,9 +58,7 @@ public class Interact implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
StackableManager stackableManager = skyblock.getStackableManager();
|
||||
IslandLevelManager levellingManager = skyblock.getLevellingManager();
|
||||
|
||||
@ -78,64 +68,12 @@ public class Interact implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DRAGON_EGG) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "DragonEggUse")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (block.getState() instanceof Beacon) { // ChunkCollectors support
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Beacon")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (block.getState() instanceof InventoryHolder || block.getState() instanceof CreatureSpawner) { // EpicHoppers/EpicSpawners support
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CAULDRON) { // WildStacker stackables
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Place") || !islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) {
|
||||
if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.EGG) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CompatibleMaterial material = block == null ? null : CompatibleMaterial.getMaterial(block.getType());
|
||||
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(event, player, island))
|
||||
return;
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
final CompatibleMaterial blockType = CompatibleMaterial.getBlockMaterial(event.getClickedBlock().getType());
|
||||
final CompatibleMaterial heldType;
|
||||
@ -147,8 +85,8 @@ public class Interact implements Listener {
|
||||
heldType = CompatibleMaterial.AIR;
|
||||
}
|
||||
|
||||
if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType && !player.isSneaking() && islandManager
|
||||
.hasPermission(player, block.getLocation(), "Place")
|
||||
if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType
|
||||
&& !player.isSneaking() && skyblock.getPermissionManager().hasPermission(player, island, "Place")
|
||||
&& (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission")
|
||||
|| player.hasPermission("fabledskyblock.stackable"))) {
|
||||
|
||||
@ -248,215 +186,13 @@ public class Interact implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BONE_MEAL && !islandManager.hasPermission(player, block.getLocation(), "Place")) {
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (material == CompatibleMaterial.SWEET_BERRY_BUSH) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.ANVIL) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Anvil")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.WHITE_BED || material == CompatibleMaterial.ORANGE_BED
|
||||
|| material == CompatibleMaterial.MAGENTA_BED || material == CompatibleMaterial.LIGHT_BLUE_BED
|
||||
|| material == CompatibleMaterial.YELLOW_BED || material == CompatibleMaterial.LIME_BED
|
||||
|| material == CompatibleMaterial.PINK_BED || material == CompatibleMaterial.GRAY_BED
|
||||
|| material == CompatibleMaterial.LIGHT_GRAY_BED || material == CompatibleMaterial.CYAN_BED
|
||||
|| material == CompatibleMaterial.CYAN_BED || material == CompatibleMaterial.PURPLE_BED
|
||||
|| material == CompatibleMaterial.BLUE_BED || material == CompatibleMaterial.BROWN_BED
|
||||
|| material == CompatibleMaterial.GREEN_BED || material == CompatibleMaterial.RED_BED
|
||||
|| material == CompatibleMaterial.BLACK_BED
|
||||
) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Bed")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.BREWING_STAND) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Brewing")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.CHEST || material == CompatibleMaterial.TRAPPED_CHEST
|
||||
|| (NMSUtil.getVersionNumber() > 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))) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.CRAFTING_TABLE) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Workbench")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.BIRCH_DOOR || material == CompatibleMaterial.ACACIA_DOOR
|
||||
|| material == CompatibleMaterial.DARK_OAK_DOOR || material == CompatibleMaterial.JUNGLE_DOOR
|
||||
|| material == CompatibleMaterial.SPRUCE_DOOR || material == CompatibleMaterial.OAK_DOOR) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Door")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.ENCHANTING_TABLE) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Enchant")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.FURNACE) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Furnace")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.STONE_BUTTON || material == CompatibleMaterial.OAK_BUTTON || material == CompatibleMaterial.SPRUCE_BUTTON
|
||||
|| material == CompatibleMaterial.BIRCH_BUTTON || material == CompatibleMaterial.JUNGLE_BUTTON || material == CompatibleMaterial.ACACIA_BUTTON
|
||||
|| material == CompatibleMaterial.DARK_OAK_BUTTON || material == CompatibleMaterial.LEVER) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.JUKEBOX) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Jukebox")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.OAK_TRAPDOOR || material == CompatibleMaterial.SPRUCE_TRAPDOOR
|
||||
|| material == CompatibleMaterial.BIRCH_TRAPDOOR || material == CompatibleMaterial.JUNGLE_TRAPDOOR
|
||||
|| material == CompatibleMaterial.ACACIA_TRAPDOOR || material == CompatibleMaterial.DARK_OAK_TRAPDOOR
|
||||
|| material == CompatibleMaterial.NOTE_BLOCK || material == CompatibleMaterial.HOPPER
|
||||
|| material == CompatibleMaterial.COMPARATOR || material == CompatibleMaterial.REPEATER) {
|
||||
if (material == CompatibleMaterial.HOPPER && !islandManager.hasPermission(player, block.getLocation(), "Hopper")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.OAK_FENCE_GATE || material == CompatibleMaterial.ACACIA_FENCE_GATE || material == CompatibleMaterial.BIRCH_FENCE_GATE
|
||||
|| material == CompatibleMaterial.DARK_OAK_FENCE_GATE || material == CompatibleMaterial.JUNGLE_FENCE_GATE || material == CompatibleMaterial.SPRUCE_FENCE_GATE) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Gate")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if ((material == CompatibleMaterial.DROPPER || (material == CompatibleMaterial.DISPENSER))) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "DropperDispenser")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.TNT) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.CAKE) {
|
||||
if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, block.getLocation(), "Cake")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (player.getGameMode() == GameMode.SURVIVAL
|
||||
if (player.getGameMode() == GameMode.SURVIVAL
|
||||
&& material == CompatibleMaterial.OBSIDIAN
|
||||
&& event.getItem() != null
|
||||
&& CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR
|
||||
&& CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BUCKET) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable")
|
||||
&& islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable")) {
|
||||
|
||||
CompatibleSound.BLOCK_FIRE_EXTINGUISH.play(block.getWorld(), block.getLocation(), 1.0F, 1.0F);
|
||||
block.setType(CompatibleMaterial.AIR.getBlockMaterial());
|
||||
@ -470,8 +206,8 @@ public class Interact implements Listener {
|
||||
return;
|
||||
}
|
||||
} else if (material == CompatibleMaterial.END_PORTAL_FRAME) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
|
||||
&& islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")) {
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
|
||||
if (com.songoda.epicanchors.EpicAnchors.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
|
||||
@ -532,94 +268,6 @@ public class Interact implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((event.getItem() != null) && (CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR) && !event.isCancelled()) {
|
||||
if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BUCKET
|
||||
|| CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.WATER_BUCKET
|
||||
|| CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.LAVA_BUCKET) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
player.updateInventory();
|
||||
}
|
||||
} else if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.GLASS_BOTTLE) {
|
||||
if (material == CompatibleMaterial.WATER || material == CompatibleMaterial.CAULDRON) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "WaterCollection")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
} else if (event.getItem().getType().name().contains("SPAWN_EGG") || event.getItem().getType().name().equals("MONSTER_EGG")) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "SpawnEgg")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
player.updateInventory();
|
||||
}
|
||||
} else if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.ARMOR_STAND || event.getItem().getType().name().contains("BOAT") || event.getItem().getType().name().contains("MINECART")) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "EntityPlacement")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
// Note: Cast is necessary as it is ambiguous without it in 1.8
|
||||
if (CompatibleMaterial.getMaterial(player.getTargetBlock(null, 5).getType()) == CompatibleMaterial.FIRE) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Fire")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == Action.PHYSICAL) {
|
||||
if (material == CompatibleMaterial.TURTLE_EGG) {
|
||||
event.setCancelled(true);
|
||||
} else if (material == CompatibleMaterial.FARMLAND) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else if (material == CompatibleMaterial.STONE_PRESSURE_PLATE || material == CompatibleMaterial.OAK_PRESSURE_PLATE
|
||||
|| material == CompatibleMaterial.SPRUCE_PRESSURE_PLATE || material == CompatibleMaterial.BIRCH_PRESSURE_PLATE
|
||||
|| material == CompatibleMaterial.JUNGLE_PRESSURE_PLATE || material == CompatibleMaterial.ACACIA_PRESSURE_PLATE
|
||||
|| material == CompatibleMaterial.DARK_OAK_PRESSURE_PLATE
|
||||
|| material == CompatibleMaterial.LIGHT_WEIGHTED_PRESSURE_PLATE
|
||||
|| material == CompatibleMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "PressurePlate")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (material == CompatibleMaterial.TRIPWIRE) {
|
||||
if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -693,219 +341,15 @@ public class Interact implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
org.bukkit.entity.Entity entity = event.getRightClicked();
|
||||
|
||||
ItemStack is = player.getItemInHand();
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
|
||||
if ((is != null) && (CompatibleMaterial.getMaterial(is) != CompatibleMaterial.AIR)) {
|
||||
if (CompatibleMaterial.getMaterial(is) == CompatibleMaterial.LEAD) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "Leash")) {
|
||||
event.setCancelled(true);
|
||||
if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld())) return;
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
Island island = islandManager.getIslandAtLocation(entity.getLocation());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.getType() == EntityType.HORSE || entity.getType() == EntityType.PIG) {
|
||||
if (entity.getType() == EntityType.HORSE) {
|
||||
Horse horse = (Horse) event.getRightClicked();
|
||||
|
||||
if (horse.getInventory().getSaddle() != null && player.isSneaking()) {
|
||||
if (!islandManager.hasPermission(player, horse.getLocation(), "HorseInventory")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!islandManager.hasPermission(player, horse.getLocation(), "MobRiding")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (entity.getType() == EntityType.PIG) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "MobRiding")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (entity.getType().equals(EntityType.SHEEP)) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "EntityPlacement")) {
|
||||
event.setCancelled(true);
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else if (entity.getType().equals(EntityType.ITEM_FRAME)) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "Storage")) {
|
||||
event.setCancelled(true);
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else if (entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
|
||||
if (CompatibleMaterial.getMaterial(is) == CompatibleMaterial.BUCKET) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "Milking")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (entity.getType() == EntityType.VILLAGER) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "Trading")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (entity instanceof StorageMinecart) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "Storage")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.MINECART || entity.getType() == EntityType.BOAT) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "MinecartBoat")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.MINECART_HOPPER) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "Hopper")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.getType() == EntityType.HORSE) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.GOLDEN_APPLE
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.GOLDEN_CARROT
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.SUGAR
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.WHEAT
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.APPLE
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.HAY_BLOCK)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.SHEEP || entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.WHEAT)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.PIG) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.CARROT || CompatibleMaterial.getMaterial(is) == CompatibleMaterial.POTATO)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.CHICKEN) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.WHEAT_SEEDS
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.PUMPKIN_SEEDS || CompatibleMaterial.getMaterial(is) == CompatibleMaterial.MELON_SEEDS)) {
|
||||
if (NMSUtil.getVersionNumber() > 8) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.BEETROOT_SEEDS)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (entity.getType() == EntityType.WOLF) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.BONE
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.PORKCHOP
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.BEEF
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.CHICKEN
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.RABBIT
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.MUTTON
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.ROTTEN_FLESH
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_PORKCHOP
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_BEEF
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_CHICKEN
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_RABBIT
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_MUTTON)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.OCELOT) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COD
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.SALMON
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.TROPICAL_FISH
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.PUFFERFISH)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.RABBIT) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.DANDELION
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.CARROTS
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.GOLDEN_CARROT)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
|
||||
if (NMSVersion > 10) {
|
||||
if (entity.getType() == EntityType.LLAMA) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.HAY_BLOCK)) {
|
||||
return;
|
||||
}
|
||||
} else if (NMSVersion > 12) {
|
||||
if (entity.getType() == EntityType.TURTLE) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.SEAGRASS)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "AnimalBreeding")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(event, player, island))
|
||||
return;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -914,15 +358,17 @@ public class Interact implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
Player player = (Player) event.getAttacker();
|
||||
|
||||
if (!skyblock.getIslandManager().hasPermission(player, event.getVehicle().getLocation(), "MobHurting")) {
|
||||
event.setCancelled(true);
|
||||
if (!skyblock.getWorldManager().isIslandWorld(event.getVehicle().getWorld())) return;
|
||||
|
||||
skyblock.getMessageManager()
|
||||
.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
Island island = islandManager.getIslandAtLocation(event.getVehicle().getLocation());
|
||||
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(event, player, island))
|
||||
return;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -931,15 +377,17 @@ public class Interact implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
Player player = (Player) event.getAttacker();
|
||||
|
||||
if (!skyblock.getIslandManager().hasPermission(player, event.getVehicle().getLocation(), "MobHurting")) {
|
||||
event.setCancelled(true);
|
||||
if (!skyblock.getWorldManager().isIslandWorld(event.getVehicle().getWorld())) return;
|
||||
|
||||
skyblock.getMessageManager()
|
||||
.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
Island island = islandManager.getIslandAtLocation(event.getVehicle().getLocation());
|
||||
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(event, player, island))
|
||||
return;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@ -948,25 +396,4 @@ public class Interact implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractAtEntity(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
org.bukkit.entity.Entity entity = event.getRightClicked();
|
||||
|
||||
if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity instanceof ArmorStand) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "ArmorStandUse")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,10 @@
|
||||
package com.songoda.skyblock.listeners;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.inventory.HorseInventory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Inventory implements Listener {
|
||||
|
||||
@ -22,19 +18,10 @@ public class Inventory implements Listener {
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
if (!(event.getInventory() instanceof HorseInventory)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, "HorseInventory")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
skyblock.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, player,
|
||||
skyblock.getIslandManager().getIsland(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.songoda.skyblock.listeners;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -18,23 +20,25 @@ public class Item implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, "ItemDrop")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return;
|
||||
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, player,
|
||||
islandManager.getIslandAtLocation(event.getItemDrop().getLocation()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(player.getWorld())) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, "ItemPickup")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if (!skyblock.getWorldManager().isIslandWorld(player.getWorld())) return;
|
||||
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, player,
|
||||
islandManager.getIslandAtLocation(event.getItem().getLocation()));
|
||||
}
|
||||
}
|
||||
|
@ -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.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -49,6 +50,7 @@ public class Move implements Listener {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
@ -105,7 +107,7 @@ public class Move implements Listener {
|
||||
boolean keepItemsOnDeath;
|
||||
|
||||
if (configLoad.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
|
||||
keepItemsOnDeath = island.getSetting(IslandRole.Owner, "KeepItemsOnDeath").getStatus();
|
||||
keepItemsOnDeath = permissionManager.hasPermission(island,"KeepItemsOnDeath", IslandRole.Owner);
|
||||
} else {
|
||||
keepItemsOnDeath = configLoad.getBoolean("Island.KeepItemsOnDeath.Enable");
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.songoda.skyblock.island.IslandEnvironment;
|
||||
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.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import com.songoda.skyblock.world.WorldManager;
|
||||
@ -43,10 +44,7 @@ public class Portal implements Listener {
|
||||
org.bukkit.block.Block from = event.getFrom().getBlock();
|
||||
org.bukkit.block.Block to = event.getTo().getBlock();
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) return;
|
||||
|
||||
@ -54,15 +52,9 @@ public class Portal implements Listener {
|
||||
|
||||
if (island == null) return;
|
||||
|
||||
CompatibleMaterial toMaterial = CompatibleMaterial.getMaterial(to.getType());
|
||||
|
||||
if( (toMaterial == CompatibleMaterial.NETHER_BRICK || toMaterial == CompatibleMaterial.END_PORTAL)
|
||||
&& !islandManager.hasPermission(player, player.getLocation(), "Portal")) {
|
||||
event.setTo(LocationUtil.getRandomLocation(event.getFrom().getWorld(), 5000, 5000, true, true));
|
||||
messageManager.sendMessage(player,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, player,
|
||||
islandManager.getIslandAtLocation(event.getTo()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@ -87,24 +79,22 @@ public class Portal implements Listener {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (!islandManager.hasPermission(player, player.getLocation(), "Portal")) {
|
||||
messageManager.sendMessage(player,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(new PlayerEnterPortalEvent(player, player.getLocation()),
|
||||
player, island))
|
||||
return;
|
||||
}
|
||||
|
||||
IslandEnvironment spawnEnvironment;
|
||||
switch (island.getRole(player)) {
|
||||
case Operator:
|
||||
case Owner:
|
||||
case Member:
|
||||
case Coop:
|
||||
spawnEnvironment = IslandEnvironment.Main;
|
||||
break;
|
||||
case Operator:
|
||||
case Owner:
|
||||
case Member:
|
||||
case Coop:
|
||||
spawnEnvironment = IslandEnvironment.Main;
|
||||
break;
|
||||
|
||||
default:
|
||||
spawnEnvironment = IslandEnvironment.Visitor;
|
||||
default:
|
||||
spawnEnvironment = IslandEnvironment.Visitor;
|
||||
}
|
||||
|
||||
Tick tick;
|
||||
@ -133,37 +123,39 @@ public class Portal implements Listener {
|
||||
IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld());
|
||||
IslandWorld toWorld = IslandWorld.Normal;
|
||||
|
||||
if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.NETHER_PORTAL)) toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.Nether : IslandWorld.Normal;
|
||||
else if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.END_PORTAL)) toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.End : IslandWorld.Normal;
|
||||
if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.NETHER_PORTAL))
|
||||
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.Nether : IslandWorld.Normal;
|
||||
else if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.END_PORTAL))
|
||||
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.End : IslandWorld.Normal;
|
||||
|
||||
switch (toWorld) {
|
||||
case Nether:
|
||||
if (configLoad.getBoolean("Island.World.Nether.Enable") && island.isRegionUnlocked(player, "Nether")) {
|
||||
case Nether:
|
||||
if (configLoad.getBoolean("Island.World.Nether.Enable") && island.isRegionUnlocked(player, "Nether")) {
|
||||
IslandWorld toWorldF = toWorld;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
tick.setTick(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case End:
|
||||
if (configLoad.getBoolean("Island.World.End.Enable") && island.isRegionUnlocked(player, "End")) {
|
||||
IslandWorld toWorldF = toWorld;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
tick.setTick(1);
|
||||
}
|
||||
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;
|
||||
|
||||
case End:
|
||||
if (configLoad.getBoolean("Island.World.End.Enable") && island.isRegionUnlocked(player, "End")) {
|
||||
IslandWorld toWorldF = toWorld;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
tick.setTick(1);
|
||||
}
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,58 +1,38 @@
|
||||
package com.songoda.skyblock.listeners;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Projectile implements Listener {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private final SkyBlock skyblock;
|
||||
|
||||
public Projectile(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
}
|
||||
public Projectile(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||
org.bukkit.entity.Projectile projectile = event.getEntity();
|
||||
ProjectileSource shooter = projectile.getShooter();
|
||||
if (!(shooter instanceof Player))
|
||||
return;
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||
org.bukkit.entity.Projectile projectile = event.getEntity();
|
||||
ProjectileSource shooter = projectile.getShooter();
|
||||
if (!(shooter instanceof Player))
|
||||
return;
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
Player player = (Player) shooter;
|
||||
Player player = (Player) shooter;
|
||||
|
||||
if (!skyblock.getWorldManager().isIslandWorld(player.getWorld()))
|
||||
return;
|
||||
if (!skyblock.getWorldManager().isIslandWorld(player.getWorld()))
|
||||
return;
|
||||
|
||||
if (projectile instanceof FishHook) {
|
||||
if (!skyblock.getIslandManager().hasPermission(player, "Fishing")) {
|
||||
event.setCancelled(true);
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) {
|
||||
event.setCancelled(true);
|
||||
messageManager.sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(new ProjectileLaunchByPlayerEvent(event.getEntity()), player, player.getLocation());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ 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;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import com.songoda.skyblock.visit.Visit;
|
||||
import com.songoda.skyblock.world.WorldManager;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -27,7 +27,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityPortalEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
@ -58,31 +57,13 @@ public class Teleport implements Listener {
|
||||
islandManager.loadPlayer(player);
|
||||
|
||||
if (worldManager.isIslandWorld(player.getWorld())) {
|
||||
boolean isCause = false;
|
||||
|
||||
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.NETHER_PORTAL || event.getCause() == TeleportCause.END_PORTAL) {
|
||||
isCause = true;
|
||||
} else {
|
||||
if (NMSUtil.getVersionNumber() > 9) {
|
||||
if (event.getCause() == TeleportCause.END_GATEWAY) {
|
||||
isCause = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isCause && !islandManager.hasPermission(player, "Portal")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
com.songoda.skyblock.island.Island island = islandManager.getIslandAtLocation(event.getTo());
|
||||
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(new PlayerEnterPortalEvent(player, player.getLocation()),
|
||||
player, island))
|
||||
return;
|
||||
}
|
||||
|
||||
if (isCause && event.getCause() != TeleportCause.ENDER_PEARL) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
|
@ -140,7 +140,7 @@ public class Bans {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
|
||||
} else {
|
||||
if ((island1.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island1.getSetting(IslandRole.Operator, "Unban").getStatus())
|
||||
&& skyblock.getPermissionManager().hasPermission(island1,"Unban", IslandRole.Operator))
|
||||
|| island1.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
Bukkit.getServer().dispatchCommand(player, "island unban " + playerName);
|
||||
|
@ -10,6 +10,7 @@ import com.songoda.skyblock.cooldown.CooldownPlayer;
|
||||
import com.songoda.skyblock.cooldown.CooldownType;
|
||||
import com.songoda.skyblock.island.*;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.placeholder.Placeholder;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -47,6 +48,7 @@ public class Biome {
|
||||
CooldownManager cooldownManager = skyblock.getCooldownManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
BiomeManager biomeManager = skyblock.getBiomeManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
@ -64,7 +66,7 @@ public class Biome {
|
||||
|
||||
return;
|
||||
} else if (!((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Biome").getStatus())
|
||||
&& permissionManager.hasPermission(island, "Biome", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId()))) {
|
||||
messageManager.sendMessage(player,
|
||||
langConfig.getString("Command.Island.Biome.Permission.Message"));
|
||||
|
@ -55,7 +55,7 @@ public class Border {
|
||||
|
||||
return;
|
||||
} else if (!((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Border").getStatus())
|
||||
&& skyblock.getPermissionManager().hasPermission(island,"Border", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId()))) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Border.Permission.Message"));
|
||||
|
@ -10,6 +10,7 @@ import com.songoda.skyblock.island.IslandCoop;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.placeholder.Placeholder;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
@ -49,6 +50,7 @@ public class Coop {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
@ -161,7 +163,7 @@ public class Coop {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> open(player), 1L);
|
||||
} else {
|
||||
if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "CoopPlayers").getStatus())
|
||||
&& permissionManager.hasPermission(island, "CoopPlayers", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
|
||||
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
|
@ -7,6 +7,7 @@ import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.placeholder.Placeholder;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
@ -48,6 +49,7 @@ public class Members {
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
@ -179,7 +181,7 @@ public class Members {
|
||||
return;
|
||||
}
|
||||
} else if (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Kick").getStatus()) {
|
||||
&& permissionManager.hasPermission(island, "Kick", IslandRole.Operator)) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock,
|
||||
@ -312,7 +314,7 @@ public class Members {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
operatorActions = new boolean[]{true, true};
|
||||
} else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) {
|
||||
if (island.getSetting(IslandRole.Operator, "Kick").getStatus()) {
|
||||
if (permissionManager.hasPermission(island, "Kick", IslandRole.Operator)) {
|
||||
operatorActions = new boolean[]{false, true};
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.*;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.placeholder.Placeholder;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -46,6 +47,7 @@ public class Settings {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
@ -65,6 +67,7 @@ public class Settings {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Settings.Owner.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (!(island13.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
@ -96,7 +99,7 @@ public class Settings {
|
||||
}
|
||||
|
||||
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& !island13.getSetting(IslandRole.Operator, "Coop").getStatus()) {
|
||||
&& !permissionManager.hasPermission(island13, "Coop", IslandRole.Operator)) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
@ -114,7 +117,7 @@ public class Settings {
|
||||
.equals(ChatColor.translateAlternateColorCodes('&', configLoad
|
||||
.getString("Menu.Settings.Categories.Item.Visitor.Displayname"))))) {
|
||||
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& !island13.getSetting(IslandRole.Operator, "Visitor").getStatus()) {
|
||||
&& !permissionManager.hasPermission(island13, "Visitor", IslandRole.Operator)) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
@ -133,7 +136,7 @@ public class Settings {
|
||||
.equals(ChatColor.translateAlternateColorCodes('&', configLoad
|
||||
.getString("Menu.Settings.Categories.Item.Member.Displayname"))))) {
|
||||
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& !island13.getSetting(IslandRole.Operator, "Member").getStatus()) {
|
||||
&& !permissionManager.hasPermission(island13, "Member", IslandRole.Operator)) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
@ -169,7 +172,7 @@ public class Settings {
|
||||
.equals(ChatColor.translateAlternateColorCodes('&', configLoad
|
||||
.getString("Menu.Settings.Categories.Item.Owner.Displayname"))))) {
|
||||
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& !island13.getSetting(IslandRole.Operator, "Island").getStatus()) {
|
||||
&& !permissionManager.hasPermission(island13,"Island", IslandRole.Operator)) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
|
||||
@ -241,7 +244,7 @@ public class Settings {
|
||||
|
||||
return;
|
||||
} else if (island14.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& !island14.getSetting(IslandRole.Operator, role.name()).getStatus()) {
|
||||
&& !permissionManager.hasPermission(island14, role.name(), IslandRole.Operator)) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
@ -295,11 +298,11 @@ public class Settings {
|
||||
} else if (is.hasItemMeta()) {
|
||||
String roleName = getRoleName(role);
|
||||
|
||||
for (IslandSetting settingList : island14.getSettings(role)) {
|
||||
for (IslandPermission settingList : island14.getSettings(role)) {
|
||||
if (is.getItemMeta().getDisplayName()
|
||||
.equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Settings." + roleName + ".Item.Setting."
|
||||
+ settingList.getName() + ".Displayname")))) {
|
||||
+ settingList.getPermission().getName() + ".Displayname")))) {
|
||||
if (!hasPermission(island14, player, role)) {
|
||||
messageManager.sendMessage(player, configLoad
|
||||
.getString("Command.Island.Settings.Permission.Change.Message"));
|
||||
@ -308,19 +311,17 @@ public class Settings {
|
||||
return;
|
||||
}
|
||||
|
||||
if (settingList != null) {
|
||||
if (settingList.getStatus()) {
|
||||
settingList.setStatus(false);
|
||||
} else {
|
||||
settingList.setStatus(true);
|
||||
}
|
||||
if (settingList.getStatus()) {
|
||||
settingList.setStatus(false);
|
||||
} else {
|
||||
settingList.setStatus(true);
|
||||
}
|
||||
|
||||
if (settingList.getName().equals("KeepItemsOnDeath")
|
||||
|| settingList.getName().equals("PvP")
|
||||
|| settingList.getName().equals("Damage")) {
|
||||
island14.getVisit()
|
||||
.setSafeLevel(islandManager.getIslandSafeLevel(island14));
|
||||
}
|
||||
if (settingList.getPermission().getName().equals("KeepItemsOnDeath")
|
||||
|| settingList.getPermission().getName().equals("PvP")
|
||||
|| settingList.getPermission().getName().equals("Damage")) {
|
||||
island14.getVisit()
|
||||
.setSafeLevel(islandManager.getIslandSafeLevel(island14));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1515,6 +1516,7 @@ public class Settings {
|
||||
|
||||
private ItemStack createItem(Island island, IslandRole role, String setting, ItemStack is) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -1532,7 +1534,7 @@ public class Settings {
|
||||
im.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Settings." + roleName + ".Item.Setting." + setting + ".Displayname")));
|
||||
|
||||
if (island.getSetting(role, setting).getStatus()) {
|
||||
if (island.hasPermission(role, permissionManager.getPermission(setting))) {
|
||||
for (String itemLoreList : configLoad
|
||||
.getStringList("Menu.Settings." + roleName + ".Item.Setting.Status.Enabled.Lore")) {
|
||||
itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList));
|
||||
@ -1560,6 +1562,7 @@ public class Settings {
|
||||
}
|
||||
|
||||
private boolean hasPermission(Island island, Player player, IslandRole role) {
|
||||
PermissionManager permissionManager = SkyBlock.getInstance().getPermissionManager();
|
||||
if (role == IslandRole.Visitor || role == IslandRole.Member || role == IslandRole.Coop
|
||||
|| role == IslandRole.Owner) {
|
||||
String roleName = role.name();
|
||||
@ -1569,7 +1572,7 @@ public class Settings {
|
||||
}
|
||||
|
||||
return !island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.getSetting(IslandRole.Operator, roleName).getStatus();
|
||||
|| permissionManager.hasPermission(island, roleName, IslandRole.Operator);
|
||||
} else if (role == IslandRole.Operator) {
|
||||
return island.hasRole(IslandRole.Owner, player.getUniqueId());
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.placeholder.Placeholder;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
@ -43,6 +44,7 @@ public class Visitors {
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
@ -106,8 +108,8 @@ public class Visitors {
|
||||
} else {
|
||||
boolean isOperator = island.hasRole(IslandRole.Operator, player.getUniqueId()),
|
||||
isOwner = island.hasRole(IslandRole.Owner, player.getUniqueId()),
|
||||
canKick = island.getSetting(IslandRole.Operator, "Kick").getStatus(),
|
||||
canBan = island.getSetting(IslandRole.Operator, "Ban").getStatus(),
|
||||
canKick = permissionManager.hasPermission(island, "Kick", IslandRole.Operator),
|
||||
canBan = permissionManager.hasPermission(island, "Ban", IslandRole.Operator),
|
||||
banningEnabled = fileManager
|
||||
.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Visitor.Banning");
|
||||
@ -206,8 +208,8 @@ public class Visitors {
|
||||
} else {
|
||||
boolean isOperator = island.hasRole(IslandRole.Operator, player.getUniqueId()),
|
||||
isOwner = island.hasRole(IslandRole.Owner, player.getUniqueId()),
|
||||
canKick = island.getSetting(IslandRole.Operator, "Kick").getStatus(),
|
||||
canBan = island.getSetting(IslandRole.Operator, "Ban").getStatus(),
|
||||
canKick = skyblock.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator),
|
||||
canBan = skyblock.getPermissionManager().hasPermission(island, "Ban", IslandRole.Operator),
|
||||
banningEnabled = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Visitor.Banning");
|
||||
int index = playerMenuPage * 36 - 36,
|
||||
|
@ -9,6 +9,7 @@ import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.PermissionManager;
|
||||
import com.songoda.skyblock.placeholder.Placeholder;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -43,6 +44,7 @@ public class Weather {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
PermissionManager permissionManager = skyblock.getPermissionManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
@ -62,7 +64,7 @@ public class Weather {
|
||||
|
||||
return;
|
||||
} else if (!((island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Biome").getStatus())
|
||||
&& permissionManager.hasPermission(island, "Biome", IslandRole.Operator))
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId()))) {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Weather.Permission.Message"));
|
||||
|
@ -0,0 +1,83 @@
|
||||
package com.songoda.skyblock.permission;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
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.IslandRole;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BasicPermission {
|
||||
|
||||
private final String name;
|
||||
private final CompatibleMaterial icon;
|
||||
private final PermissionType type;
|
||||
|
||||
protected BasicPermission(String name, CompatibleMaterial icon, PermissionType type) {
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ItemStack getItem(Island island, IslandRole role) {
|
||||
ItemStack is = icon.getItem();
|
||||
FileManager.Config config = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().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";
|
||||
|
||||
String nameFinal = configLoad.getString("Menu.Settings." + roleName + ".Item.Setting." + name + ".Displayname");
|
||||
|
||||
im.setDisplayName(TextUtils.formatText(nameFinal == null ? name : nameFinal));
|
||||
|
||||
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);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to check additional perms.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean extraCheck() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CompatibleMaterial getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public PermissionType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.songoda.skyblock.permission;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class HandlerWrapper {
|
||||
|
||||
private final BasicPermission permission;
|
||||
private final Method handler;
|
||||
|
||||
public HandlerWrapper(BasicPermission permission, Method handler) {
|
||||
this.permission = permission;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public BasicPermission getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public Method getHandler() {
|
||||
return handler;
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.songoda.skyblock.permission;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
|
||||
import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class ListeningPermission extends BasicPermission {
|
||||
|
||||
protected ListeningPermission(String name, CompatibleMaterial icon, PermissionType type) {
|
||||
super(name, icon, type);
|
||||
}
|
||||
|
||||
public void onInteract(PlayerInteractEvent event) {}
|
||||
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {}
|
||||
|
||||
public void onShear(PlayerShearEntityEvent event) {}
|
||||
|
||||
public void onBreak(BlockBreakEvent event) {}
|
||||
|
||||
public void onPlace(BlockPlaceEvent event) {}
|
||||
|
||||
public void onVehicleDamage(VehicleDamageEvent event) {}
|
||||
|
||||
public void onVehicleDestroy(VehicleDestroyEvent event) {}
|
||||
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {}
|
||||
|
||||
public void onEntityDamage(EntityDamageEvent event) {}
|
||||
|
||||
public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event) {}
|
||||
|
||||
public void onHangingPlace(HangingPlaceEvent event) {}
|
||||
|
||||
public void onHangingBreak(HangingBreakEvent event) {}
|
||||
|
||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {}
|
||||
|
||||
public void onEntityTame(EntityTameEvent event) {}
|
||||
|
||||
public void onTargetEntity(EntityTargetLivingEntityEvent event) {}
|
||||
|
||||
public void onBucketEmpty(PlayerBucketEmptyEvent event) {}
|
||||
|
||||
public void onBucketFill(PlayerBucketFillEvent event) {}
|
||||
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {}
|
||||
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {}
|
||||
|
||||
public void onPortalEnter(PlayerEnterPortalEvent event) {}
|
||||
|
||||
public void onPickupItem(PlayerPickupItemEvent event) {}
|
||||
|
||||
public void onDropItem(PlayerDropItemEvent event) {}
|
||||
|
||||
public void onMove(PlayerMoveEvent event) {}
|
||||
|
||||
public void onTeleport(PlayerTeleportEvent event) {}
|
||||
|
||||
public void onProjectileLaunch(ProjectileLaunchByPlayerEvent event) {}
|
||||
|
||||
protected void noPermsMessage(Player player, SkyBlock plugin, MessageManager messageManager) {
|
||||
messageManager.sendMessage(player,
|
||||
plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
CompatibleSound.ENTITY_VILLAGER_NO.play(player);
|
||||
}
|
||||
|
||||
protected void cancelAndMessage(Cancellable cancellable, Player player,
|
||||
SkyBlock plugin, MessageManager messageManager) {
|
||||
cancellable.setCancelled(true);
|
||||
noPermsMessage(player, plugin, messageManager);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.songoda.skyblock.permission;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface PermissionHandler {
|
||||
|
||||
PermissionPriority priority() default PermissionPriority.NORMAL;
|
||||
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
package com.songoda.skyblock.permission;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.permission.event.Stoppable;
|
||||
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.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PermissionManager {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
|
||||
private final List<BasicPermission> registeredPermissions = new ArrayList<>();
|
||||
private List<HandlerWrapper> registeredHandlers = new LinkedList<>();
|
||||
|
||||
public PermissionManager(SkyBlock plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> {
|
||||
// Load default permissions.
|
||||
registerPermissions(
|
||||
//Listening
|
||||
new StoragePermission(plugin),
|
||||
new DragonEggUsePermission(plugin),
|
||||
new BeaconPermission(plugin),
|
||||
new ProjectilePermission(plugin),
|
||||
new DestroyPermission(plugin),
|
||||
new AnvilPermission(plugin),
|
||||
new BedPermission(plugin),
|
||||
new BrewingPermission(plugin),
|
||||
new WorkbenchPermission(plugin),
|
||||
new DoorPermission(plugin),
|
||||
new EnchantPermission(plugin),
|
||||
new FurnacePermission(plugin),
|
||||
new LeverButtonPermission(plugin),
|
||||
new JukeboxPermission(plugin),
|
||||
new HopperPermission(plugin),
|
||||
new NoteblockPermission(plugin),
|
||||
new RedstonePermission(plugin),
|
||||
new GatePermission(plugin),
|
||||
new DropperDispenserPermission(plugin),
|
||||
new BucketPermission(plugin),
|
||||
new WaterCollectionPermission(plugin),
|
||||
new SpawnEggPermission(plugin),
|
||||
new EntityPlacementPermission(plugin),
|
||||
new FirePermission(plugin),
|
||||
new TramplePermission(plugin),
|
||||
new PressurePlatePermission(plugin),
|
||||
new CakePermission(plugin),
|
||||
new PlacePermission(plugin),
|
||||
new LeashPermission(plugin),
|
||||
new AnimalBreedingPermission(plugin),
|
||||
new MinecartPermission(plugin),
|
||||
new BoatPermission(plugin),
|
||||
new TradingPermission(plugin),
|
||||
new MilkingPermission(plugin),
|
||||
new ShearingPermission(plugin),
|
||||
new MobRidingPermission(plugin),
|
||||
new HorseInventoryPermission(plugin),
|
||||
new MobHurtingPermission(plugin),
|
||||
new ArmorStandUsePermission(plugin),
|
||||
new MonsterHurtingPermission(plugin),
|
||||
new PvpPermission(plugin),
|
||||
new HangingDestroyPermission(plugin),
|
||||
new DamagePermission(plugin),
|
||||
new ExplosionsPermission(),
|
||||
new MobTamingPermission(plugin),
|
||||
new MobGriefingPermission(plugin),
|
||||
new ExperienceOrbPickupPermission(plugin),
|
||||
new NaturalMobSpawningPermission(),
|
||||
new HungerPermission(plugin),
|
||||
new PortalPermission(plugin),
|
||||
new ItemPickupPermission(),
|
||||
new ItemDropPermission(),
|
||||
new FishingPermission(plugin),
|
||||
|
||||
// Basic
|
||||
new MemberPermission(),
|
||||
new VisitorPermission(),
|
||||
new KickPermission(),
|
||||
new BiomePermission(),
|
||||
new KeepItemsOnDeathPermission(),
|
||||
new UnbanPermission(),
|
||||
new BanPermission(),
|
||||
new BorderPermission(),
|
||||
new FireSpreadPermission(),
|
||||
new CoopPlayersPermission(),
|
||||
new IslandPermission(),
|
||||
new LeafDecayPermission(),
|
||||
new WeatherPermission(),
|
||||
new MainSpawnPermission(),
|
||||
new VisitorSpawnPermission());
|
||||
|
||||
registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> {
|
||||
final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class);
|
||||
return permissionHandler.priority().ordinal();
|
||||
})).collect(Collectors.toList());
|
||||
}, 20L);
|
||||
}
|
||||
|
||||
public boolean registerPermission(BasicPermission permission) {
|
||||
registeredPermissions.add(permission);
|
||||
Set<Method> methods;
|
||||
try {
|
||||
Method[] publicMethods = permission.getClass().getMethods();
|
||||
methods = new HashSet<>(publicMethods.length, Float.MAX_VALUE);
|
||||
methods.addAll(Arrays.asList(publicMethods));
|
||||
Collections.addAll(methods, permission.getClass().getDeclaredMethods());
|
||||
} catch (NoClassDefFoundError e) {
|
||||
return false;
|
||||
}
|
||||
for (Method method : methods) {
|
||||
final PermissionHandler permissionHandler = method.getAnnotation(PermissionHandler.class);
|
||||
if (permissionHandler == null) continue;
|
||||
registeredHandlers.add(new HandlerWrapper(permission, method));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean registerPermissions(BasicPermission... permissions) {
|
||||
for (BasicPermission permission : permissions)
|
||||
if (!registerPermission(permission))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean processPermission(Cancellable cancellable, Island island) {
|
||||
return processPermission(cancellable, null, island);
|
||||
}
|
||||
|
||||
public boolean processPermission(Cancellable cancellable, Player player, Location location) {
|
||||
return processPermission(cancellable, player, plugin.getIslandManager().getIslandAtLocation(location));
|
||||
}
|
||||
|
||||
public boolean processPermission(Cancellable cancellable, Player player, Island island) {
|
||||
if (island == null) return true;
|
||||
|
||||
for (HandlerWrapper wrapper : registeredHandlers) {
|
||||
Method handler = wrapper.getHandler();
|
||||
if (handler.getParameterTypes()[0] != cancellable.getClass()) continue;
|
||||
|
||||
if (cancellable.isCancelled()) return false;
|
||||
if (cancellable instanceof Stoppable && ((Stoppable) cancellable).isStopped()) return true;
|
||||
|
||||
BasicPermission permission = wrapper.getPermission();
|
||||
|
||||
if (permission.extraCheck() && hasPermission(player, island, permission))
|
||||
continue;
|
||||
|
||||
try {
|
||||
handler.invoke(permission, cancellable);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, Island island, BasicPermission permission) {
|
||||
if (player == null)
|
||||
return island.hasPermission(IslandRole.Owner, permission);
|
||||
|
||||
if (player.hasPermission("fabledskyblock.bypass." + permission.getName().toLowerCase()))
|
||||
return true;
|
||||
|
||||
if (island.hasPermission(island.getRole(player), permission))
|
||||
return true;
|
||||
|
||||
if (island.isCoopPlayer(player.getUniqueId()) && island.hasPermission(IslandRole.Coop, permission))
|
||||
return true;
|
||||
|
||||
return island.hasPermission(IslandRole.Visitor, permission);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Location location, String permission, IslandRole islandRole) {
|
||||
if (location == null)
|
||||
return false;
|
||||
return plugin.getIslandManager().getIslandAtLocation(location)
|
||||
.hasPermission(islandRole, getPermission(permission));
|
||||
}
|
||||
|
||||
public boolean hasPermission(Island island, String permission, IslandRole islandRole) {
|
||||
return island.hasPermission(islandRole, getPermission(permission));
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, Island island, String permission) {
|
||||
return hasPermission(player, island, getPermission(permission));
|
||||
}
|
||||
|
||||
public BasicPermission getPermission(String permissionName) {
|
||||
return registeredPermissions.stream()
|
||||
.filter(p -> p.getName().equalsIgnoreCase(permissionName))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public List<BasicPermission> getPermissions() {
|
||||
return new ArrayList<>(registeredPermissions);
|
||||
}
|
||||
|
||||
public List<ListeningPermission> getListeningPermissions() {
|
||||
return registeredPermissions.stream()
|
||||
.filter(p -> p instanceof ListeningPermission)
|
||||
.map(p -> (ListeningPermission) p)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.songoda.skyblock.permission;
|
||||
|
||||
public enum PermissionPriority {
|
||||
|
||||
FIRST, NORMAL, LAST
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.songoda.skyblock.permission;
|
||||
|
||||
public enum PermissionType {
|
||||
|
||||
GENERIC, OPERATOR, ISLAND
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.songoda.skyblock.permission.event;
|
||||
|
||||
public interface Stoppable {
|
||||
|
||||
boolean isStopped();
|
||||
|
||||
void setStopped(boolean stopped);
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.songoda.skyblock.permission.event.events;
|
||||
|
||||
import com.songoda.skyblock.permission.event.Stoppable;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||
|
||||
public class PlayerEnterPortalEvent extends EntityPortalEnterEvent implements Cancellable, Stoppable {
|
||||
|
||||
private boolean isCancelled = false;
|
||||
private boolean isStopped = false;
|
||||
|
||||
public PlayerEnterPortalEvent(Player player, Location location) {
|
||||
super(player, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return isCancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
isCancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStopped() {
|
||||
return isStopped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStopped(boolean stopped) {
|
||||
isStopped = stopped;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.songoda.skyblock.permission.event.events;
|
||||
|
||||
import com.songoda.skyblock.permission.event.Stoppable;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
|
||||
public class ProjectileLaunchByPlayerEvent extends ProjectileLaunchEvent implements Cancellable, Stoppable {
|
||||
|
||||
private boolean isCancelled = false;
|
||||
private boolean isStopped = false;
|
||||
|
||||
public ProjectileLaunchByPlayerEvent(Entity what) {
|
||||
super(what);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return isCancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
isCancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStopped() {
|
||||
return isStopped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStopped(boolean stopped) {
|
||||
isStopped = stopped;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class BanPermission extends BasicPermission {
|
||||
|
||||
public BanPermission() {
|
||||
super("Ban", CompatibleMaterial.IRON_AXE, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class BiomePermission extends BasicPermission {
|
||||
|
||||
public BiomePermission() {
|
||||
super("Biome", CompatibleMaterial.MAP, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class BorderPermission extends BasicPermission {
|
||||
|
||||
public BorderPermission() {
|
||||
super("Border", CompatibleMaterial.BEACON, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class CoopPlayersPermission extends BasicPermission {
|
||||
|
||||
public CoopPlayersPermission() {
|
||||
super("CoopPlayers", CompatibleMaterial.BOOK, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class FireSpreadPermission extends BasicPermission {
|
||||
|
||||
public FireSpreadPermission() {
|
||||
super("FireSpread", CompatibleMaterial.FLINT_AND_STEEL, PermissionType.ISLAND);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class IslandPermission extends BasicPermission {
|
||||
|
||||
public IslandPermission() {
|
||||
super("Island", CompatibleMaterial.OAK_SAPLING, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class KeepItemsOnDeathPermission extends BasicPermission {
|
||||
|
||||
public KeepItemsOnDeathPermission() {
|
||||
super("KeepItemsOnDeath", CompatibleMaterial.ITEM_FRAME, PermissionType.ISLAND);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class KickPermission extends BasicPermission {
|
||||
|
||||
public KickPermission() {
|
||||
super("Visitor", CompatibleMaterial.IRON_DOOR, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class LeafDecayPermission extends BasicPermission {
|
||||
|
||||
public LeafDecayPermission() {
|
||||
super("LeafDecay", CompatibleMaterial.OAK_LEAVES, PermissionType.ISLAND);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class MainSpawnPermission extends BasicPermission {
|
||||
|
||||
public MainSpawnPermission() {
|
||||
super("MainSpawn", CompatibleMaterial.EMERALD, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class MemberPermission extends BasicPermission {
|
||||
|
||||
public MemberPermission() {
|
||||
super("Member", CompatibleMaterial.PAINTING, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class NaturalMobSpawningPermission extends BasicPermission {
|
||||
|
||||
public NaturalMobSpawningPermission() {
|
||||
super("NaturalMobSpawning", CompatibleMaterial.PIG_SPAWN_EGG, PermissionType.ISLAND);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class UnbanPermission extends BasicPermission {
|
||||
|
||||
public UnbanPermission() {
|
||||
super("Unban", CompatibleMaterial.RED_DYE, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class VisitorPermission extends BasicPermission {
|
||||
|
||||
public VisitorPermission() {
|
||||
super("Visitor", CompatibleMaterial.OAK_SIGN, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class VisitorSpawnPermission extends BasicPermission {
|
||||
|
||||
public VisitorSpawnPermission() {
|
||||
super("VisitorSpawn", CompatibleMaterial.NETHER_STAR, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.songoda.skyblock.permission.permissions.basic;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.permission.BasicPermission;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
|
||||
public class WeatherPermission extends BasicPermission {
|
||||
|
||||
public WeatherPermission() {
|
||||
super("Weather", CompatibleMaterial.CLOCK, PermissionType.OPERATOR);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
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 com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class AnimalBreedingPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public AnimalBreedingPermission(SkyBlock plugin) {
|
||||
super("AnimalBreeding", CompatibleMaterial.WHEAT, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ItemStack is = player.getItemInHand();
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
if (entity.getType() == EntityType.HORSE) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.GOLDEN_APPLE
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.GOLDEN_CARROT
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.SUGAR
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.WHEAT
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.APPLE
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.HAY_BLOCK)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.SHEEP || entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.WHEAT)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.PIG) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.CARROT || CompatibleMaterial.getMaterial(is) == CompatibleMaterial.POTATO)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.CHICKEN) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.WHEAT_SEEDS
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.PUMPKIN_SEEDS || CompatibleMaterial.getMaterial(is) == CompatibleMaterial.MELON_SEEDS)) {
|
||||
if (NMSUtil.getVersionNumber() > 8) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.BEETROOT_SEEDS)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (entity.getType() == EntityType.WOLF) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.BONE
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.PORKCHOP
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.BEEF
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.CHICKEN
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.RABBIT
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.MUTTON
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.ROTTEN_FLESH
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_PORKCHOP
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_BEEF
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_CHICKEN
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_RABBIT
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COOKED_MUTTON)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.OCELOT) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.COD
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.SALMON
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.TROPICAL_FISH
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.PUFFERFISH)) {
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.RABBIT) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.DANDELION
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.CARROTS
|
||||
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.GOLDEN_CARROT)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
|
||||
if (NMSVersion > 10) {
|
||||
if (entity.getType() == EntityType.LLAMA) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.HAY_BLOCK)) {
|
||||
return;
|
||||
}
|
||||
} else if (NMSVersion > 12) {
|
||||
if (entity.getType() == EntityType.TURTLE) {
|
||||
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.SEAGRASS)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
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.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class AnvilPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public AnvilPermission(SkyBlock plugin) {
|
||||
super("Anvil", CompatibleMaterial.ANVIL, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (material == CompatibleMaterial.ANVIL)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
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.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
public class ArmorStandUsePermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public ArmorStandUsePermission(SkyBlock plugin) {
|
||||
super("ArmorStandUse", CompatibleMaterial.ARMOR_STAND, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getRightClicked() instanceof ArmorStand)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event) {
|
||||
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
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.block.Beacon;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class BeaconPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public BeaconPermission(SkyBlock plugin) {
|
||||
super("Beacon", CompatibleMaterial.BEACON, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (block.getState() instanceof Beacon) // ChunkCollectors support
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
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.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class BedPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public BedPermission(SkyBlock plugin) {
|
||||
super("Bed", CompatibleMaterial.RED_BED, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (material == CompatibleMaterial.WHITE_BED || material == CompatibleMaterial.ORANGE_BED
|
||||
|| material == CompatibleMaterial.MAGENTA_BED || material == CompatibleMaterial.LIGHT_BLUE_BED
|
||||
|| material == CompatibleMaterial.YELLOW_BED || material == CompatibleMaterial.LIME_BED
|
||||
|| material == CompatibleMaterial.PINK_BED || material == CompatibleMaterial.GRAY_BED
|
||||
|| material == CompatibleMaterial.LIGHT_GRAY_BED || material == CompatibleMaterial.CYAN_BED
|
||||
|| material == CompatibleMaterial.PURPLE_BED || material == CompatibleMaterial.BLUE_BED
|
||||
|| material == CompatibleMaterial.BROWN_BED || material == CompatibleMaterial.GREEN_BED
|
||||
|| material == CompatibleMaterial.RED_BED || material == CompatibleMaterial.BLACK_BED)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
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.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
public class BoatPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public BoatPermission(SkyBlock plugin) {
|
||||
super("Boat", CompatibleMaterial.OAK_BOAT, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getRightClicked().getType() == EntityType.BOAT)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
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.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class BrewingPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public BrewingPermission(SkyBlock plugin) {
|
||||
super("Brewing", CompatibleMaterial.BREWING_STAND, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (CompatibleMaterial.getMaterial(block) == CompatibleMaterial.BREWING_STAND)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Player player = (Player)event.getDamager();
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof Monster)) return;
|
||||
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
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.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class BucketPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public BucketPermission(SkyBlock plugin) {
|
||||
super("Bucket", CompatibleMaterial.BUCKET, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
if (player.getGameMode() == GameMode.SURVIVAL
|
||||
&& CompatibleMaterial.getMaterial(event.getClickedBlock()) == CompatibleMaterial.OBSIDIAN
|
||||
&& event.getItem() != null
|
||||
&& CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR
|
||||
&& CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BUCKET)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
} else if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR) {
|
||||
if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BUCKET
|
||||
|| CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.WATER_BUCKET
|
||||
|| CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.LAVA_BUCKET) {
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onBucketFill(PlayerBucketFillEvent event) {
|
||||
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
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.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class CakePermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public CakePermission(SkyBlock plugin) {
|
||||
super("Cake", CompatibleMaterial.CAKE, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (CompatibleMaterial.getMaterial(block) == CompatibleMaterial.CAKE)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.songoda.skyblock.permission.permissions.listening;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
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.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DamagePermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final FileManager fileManager;
|
||||
|
||||
public DamagePermission(SkyBlock plugin) {
|
||||
super("Damage", CompatibleMaterial.RED_DYE, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.fileManager = plugin.getFileManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
|
||||
return;
|
||||
} else if (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK) {
|
||||
EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) event;
|
||||
|
||||
if (entityDamageByEntityEvent.getDamager() instanceof Player) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (NMSUtil.getVersionNumber() > 11) {
|
||||
if (event.getCause() == EntityDamageEvent.DamageCause.valueOf("ENTITY_SWEEP_ATTACK")) {
|
||||
EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) event;
|
||||
|
||||
if (entityDamageByEntityEvent.getDamager() instanceof Player) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity.getType() != EntityType.PLAYER) return;
|
||||
|
||||
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")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
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.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class DestroyPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public DestroyPermission(SkyBlock plugin) {
|
||||
super("Destroy", CompatibleMaterial.DIAMOND_PICKAXE, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (material == CompatibleMaterial.SWEET_BERRY_BUSH || material == CompatibleMaterial.TNT
|
||||
|| material == CompatibleMaterial.END_PORTAL_FRAME)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Player player = (Player)event.getDamager();
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity.getType() != EntityType.ARMOR_STAND) return;
|
||||
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
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.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class DoorPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public DoorPermission(SkyBlock plugin) {
|
||||
super("Door", CompatibleMaterial.OAK_DOOR, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (material == CompatibleMaterial.BIRCH_DOOR || material == CompatibleMaterial.ACACIA_DOOR
|
||||
|| material == CompatibleMaterial.DARK_OAK_DOOR || material == CompatibleMaterial.JUNGLE_DOOR
|
||||
|| material == CompatibleMaterial.SPRUCE_DOOR || material == CompatibleMaterial.OAK_DOOR)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
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.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class DragonEggUsePermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public DragonEggUsePermission(SkyBlock plugin) {
|
||||
super("DragonEggUse", CompatibleMaterial.DRAGON_EGG, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DRAGON_EGG)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
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.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class DropperDispenserPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public DropperDispenserPermission(SkyBlock plugin) {
|
||||
super("DropperDispenser", CompatibleMaterial.DROPPER, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
|
||||
|
||||
if (material == CompatibleMaterial.DROPPER || material == CompatibleMaterial.DISPENSER)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
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.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class EnchantPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public EnchantPermission(SkyBlock plugin) {
|
||||
super("Enchant", CompatibleMaterial.ENCHANTING_TABLE, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (CompatibleMaterial.getMaterial(block) == CompatibleMaterial.ENCHANTING_TABLE)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
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.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class EntityPlacementPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public EntityPlacementPermission(SkyBlock plugin) {
|
||||
super("EntityPlacement", CompatibleMaterial.SHEEP_SPAWN_EGG, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR) {
|
||||
if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.ARMOR_STAND
|
||||
|| event.getItem().getType().name().contains("BOAT")
|
||||
|| event.getItem().getType().name().contains("MINECART")) {
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
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.ExperienceOrb;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
|
||||
public class ExperienceOrbPickupPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public ExperienceOrbPickupPermission(SkyBlock plugin) {
|
||||
super("ExperienceOrbPickup", CompatibleMaterial.EXPERIENCE_BOTTLE, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onTargetEntity(EntityTargetLivingEntityEvent event) {
|
||||
Player player = (Player) event.getTarget();
|
||||
|
||||
if (!(event.getEntity() instanceof ExperienceOrb))
|
||||
return;
|
||||
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.songoda.skyblock.permission.permissions.listening;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
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.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
|
||||
public class ExplosionsPermission extends ListeningPermission {
|
||||
|
||||
public ExplosionsPermission() {
|
||||
super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.GENERIC);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (event.getDamager() instanceof TNTPrimed)
|
||||
event.setCancelled(true);
|
||||
if (entity.getType() == EntityType.PLAYER
|
||||
&& event.getDamager() instanceof TNTPrimed)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onHangingBreak(HangingBreakEvent event) {
|
||||
if (event.getCause() != HangingBreakEvent.RemoveCause.EXPLOSION)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
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.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class FirePermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public FirePermission(SkyBlock plugin) {
|
||||
super("Fire", CompatibleMaterial.FLINT_AND_STEEL, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (CompatibleMaterial.getMaterial(player.getTargetBlock(null, 5)) == CompatibleMaterial.FIRE)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
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.PermissionPriority;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
import com.songoda.skyblock.permission.event.events.ProjectileLaunchByPlayerEvent;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
|
||||
public class FishingPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public FishingPermission(SkyBlock plugin) {
|
||||
super("Fishing", CompatibleMaterial.FISHING_ROD, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler(priority = PermissionPriority.LAST)
|
||||
public void onProjectileLaunch(ProjectileLaunchByPlayerEvent event) {
|
||||
org.bukkit.entity.Projectile projectile = event.getEntity();
|
||||
Player shooter = (Player) projectile.getShooter();
|
||||
if (projectile instanceof FishHook) {
|
||||
cancelAndMessage(event, shooter, plugin, messageManager);
|
||||
event.setStopped(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
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.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class FurnacePermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public FurnacePermission(SkyBlock plugin) {
|
||||
super("Furnace", CompatibleMaterial.FURNACE, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (CompatibleMaterial.getMaterial(block) == CompatibleMaterial.FURNACE)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
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.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class GatePermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public GatePermission(SkyBlock plugin) {
|
||||
super("Gate", CompatibleMaterial.OAK_FENCE_GATE, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
|
||||
|
||||
if (material == CompatibleMaterial.OAK_FENCE_GATE || material == CompatibleMaterial.ACACIA_FENCE_GATE
|
||||
|| material == CompatibleMaterial.BIRCH_FENCE_GATE || material == CompatibleMaterial.DARK_OAK_FENCE_GATE
|
||||
|| material == CompatibleMaterial.JUNGLE_FENCE_GATE || material == CompatibleMaterial.SPRUCE_FENCE_GATE)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
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.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
public class HangingDestroyPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public HangingDestroyPermission(SkyBlock plugin) {
|
||||
super("HangingDestroy", CompatibleMaterial.ITEM_FRAME, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Hanging) {
|
||||
|
||||
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;
|
||||
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
||||
if (!(event.getRemover() instanceof Player))
|
||||
return;
|
||||
|
||||
cancelAndMessage(event, (Player) event.getRemover(), plugin, messageManager);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (!(event.getRightClicked() instanceof Hanging))
|
||||
return;
|
||||
|
||||
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
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.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class HopperPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public HopperPermission(SkyBlock plugin) {
|
||||
super("Hopper", CompatibleMaterial.HOPPER, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
if (CompatibleMaterial.getMaterial(block) == CompatibleMaterial.HOPPER)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getRightClicked().getType() == EntityType.MINECART_HOPPER)
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
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.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.HorseInventory;
|
||||
|
||||
public class HorseInventoryPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public HorseInventoryPermission(SkyBlock plugin) {
|
||||
super("HorseInventory", CompatibleMaterial.DIAMOND_HORSE_ARMOR, PermissionType.GENERIC);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
if (entity.getType() == EntityType.HORSE) {
|
||||
Horse horse = (Horse) event.getRightClicked();
|
||||
if (horse.getInventory().getSaddle() != null && player.isSneaking())
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
if (!(event.getInventory() instanceof HorseInventory))
|
||||
return;
|
||||
|
||||
cancelAndMessage(event, (Player) event.getPlayer(), plugin, messageManager);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user