mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-26 08:31:21 +01:00
A lot of fixes and "Updating plugin to meet Songoda standards."
This commit is contained in:
parent
e6e420bdd1
commit
9b155e12e4
@ -2,6 +2,10 @@ package me.goodandevil.skyblock;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import me.goodandevil.skyblock.command.commands.SkyBlockCommand;
|
||||
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;
|
||||
@ -85,6 +89,12 @@ public class SkyBlock extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
ConsoleCommandSender console = Bukkit.getConsoleSender();
|
||||
console.sendMessage(formatText("&a============================="));
|
||||
console.sendMessage(formatText("&7FabledSkyBlock " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
|
||||
console.sendMessage(formatText("&7Action: &aEnabling&7..."));
|
||||
console.sendMessage(formatText("&a============================="));
|
||||
|
||||
instance = this;
|
||||
|
||||
fileManager = new FileManager(this);
|
||||
@ -151,11 +161,19 @@ public class SkyBlock extends JavaPlugin {
|
||||
pluginManager.registerEvents(new Generator(), this);
|
||||
pluginManager.registerEvents(new Creator(), this);
|
||||
|
||||
this.getCommand("skyblock").setExecutor(new SkyBlockCommand());
|
||||
|
||||
SkyBlockAPI.setImplementation(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
ConsoleCommandSender console = Bukkit.getConsoleSender();
|
||||
console.sendMessage(formatText("&a============================="));
|
||||
console.sendMessage(formatText("&7FabledSkyBlock " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
|
||||
console.sendMessage(formatText("&7Action: &cDisabling&7..."));
|
||||
console.sendMessage(formatText("&a============================="));
|
||||
|
||||
if (this.userCacheManager != null) {
|
||||
this.userCacheManager.onDisable();
|
||||
}
|
||||
@ -187,6 +205,10 @@ public class SkyBlock extends JavaPlugin {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
private String formatText(String string){
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
|
||||
public static SkyBlock getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.goodandevil.skyblock.biome;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -28,46 +29,45 @@ public class BiomeManager {
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<Chunk> chunks = new ArrayList<>();
|
||||
Location location = island.getLocation(IslandWorld.Normal, IslandEnvironment.Island);
|
||||
int radius = (int) Math.ceil(island.getRadius());
|
||||
|
||||
for (Location locationList : LocationUtil.getLocations(
|
||||
new Location(location.getWorld(), location.getBlockX() - island.getRadius(), 0,
|
||||
location.getBlockZ() - island.getRadius()),
|
||||
new Location(location.getWorld(), location.getBlockX() + island.getRadius(), 0,
|
||||
location.getBlockZ() + island.getRadius()))) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
location.getWorld().setBiome(locationList.getBlockX(), locationList.getBlockZ(), biome);
|
||||
}
|
||||
});
|
||||
for(int x = location.getBlockX() - radius; x < location.getBlockX() + radius; x++){
|
||||
for(int z = location.getBlockX() - radius; z < location.getBlockX() + radius; z++){
|
||||
location.getWorld().setBiome(x, z, biome);
|
||||
Chunk chunk = location.getWorld().getChunkAt(x >> 4, z >> 4);
|
||||
if(!chunks.contains(chunk))
|
||||
chunks.add(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
for(Chunk chunk : chunks)
|
||||
updateBiome(island, chunk);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateBiome(Island island, List<Chunk> chunks) {
|
||||
public void updateBiome(Island island, Chunk chunk) {
|
||||
Class<?> packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
|
||||
Class<?> chunkClass = NMSUtil.getNMSClass("Chunk");
|
||||
|
||||
for (Player all : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) {
|
||||
for (Chunk chunkList : chunks) {
|
||||
try {
|
||||
if (NMSUtil.getVersionNumber() < 10) {
|
||||
NMSUtil.sendPacket(all,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class)
|
||||
.newInstance(all.getLocation().getChunk().getClass().getMethod("getHandle")
|
||||
.invoke(chunkList), true, 20));
|
||||
} else {
|
||||
NMSUtil.sendPacket(all,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(all
|
||||
.getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunkList),
|
||||
65535));
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
if (NMSUtil.getVersionNumber() < 10) {
|
||||
NMSUtil.sendPacket(all,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class)
|
||||
.newInstance(all.getLocation().getChunk().getClass().getMethod("getHandle")
|
||||
.invoke(chunk), true, 20));
|
||||
} else {
|
||||
NMSUtil.sendPacket(all,
|
||||
packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(all
|
||||
.getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk),
|
||||
65535));
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package me.goodandevil.skyblock.command.commands;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class SkyBlockCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(formatText("FabledSkyBlock &7Version " + SkyBlock.getInstance().getDescription().getVersion() + " Created with <3 by &5&l&oSongoda"));
|
||||
sender.sendMessage(formatText("&8 - &a/island help &7 - The default help command."));
|
||||
sender.sendMessage("");
|
||||
return true;
|
||||
}
|
||||
|
||||
private String formatText(String string){
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
}
|
@ -469,6 +469,14 @@ public class Island {
|
||||
return islandRoles;
|
||||
}
|
||||
|
||||
public IslandRole getRole(OfflinePlayer player){
|
||||
for (IslandRole role : IslandRole.values())
|
||||
if(getRole(role).contains(player.getUniqueId()))
|
||||
return role;
|
||||
|
||||
return IslandRole.Visitor;
|
||||
}
|
||||
|
||||
public boolean setRole(IslandRole role, UUID uuid) {
|
||||
if (!(role == IslandRole.Visitor || role == IslandRole.Coop || role == IslandRole.Owner)) {
|
||||
if (!hasRole(role, uuid)) {
|
||||
@ -594,7 +602,7 @@ public class Island {
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return new IslandSetting(setting, true); //TODO: Default setting value
|
||||
}
|
||||
|
||||
public List<IslandSetting> getSettings(IslandRole role) {
|
||||
|
@ -969,26 +969,19 @@ public class IslandManager {
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(player.hasPermission("skyblockearth.bypass." + setting.toLowerCase()))
|
||||
return true;
|
||||
|
||||
island = getIslandAtLocation(location);
|
||||
if(island.getSetting(island.getRole(player), setting).getStatus())
|
||||
return true;
|
||||
|
||||
if (island != null) {
|
||||
if (player.hasPermission("skyblock.bypass." + setting.toLowerCase())
|
||||
|| player.hasPermission("skyblock.bypass.*") || player.hasPermission("skyblock.*")) {
|
||||
return true;
|
||||
} else if (island.isCoopPlayer(player.getUniqueId())) {
|
||||
if (!island.getSetting(IslandRole.Coop, setting).getStatus()) {
|
||||
return false;
|
||||
}
|
||||
} else if (!island.getSetting(IslandRole.Visitor, setting).getStatus()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(island.isCoopPlayer(player.getUniqueId()) && island.getSetting(IslandRole.Coop, setting).getStatus())
|
||||
return true;
|
||||
|
||||
return true;
|
||||
if(island.getSetting(IslandRole.Visitor, setting).getStatus())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasSetting(org.bukkit.Location location, IslandRole role, String setting) {
|
||||
|
@ -6,6 +6,8 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
@ -33,6 +35,7 @@ public class LeaderboardManager {
|
||||
|
||||
public void resetLeaderboard() {
|
||||
VisitManager visitManager = skyblock.getVisitManager();
|
||||
visitManager.loadIslands();
|
||||
|
||||
List<LeaderboardPlayer> islandLevels = new ArrayList<>();
|
||||
List<LeaderboardPlayer> islandVotes = new ArrayList<>();
|
||||
@ -44,29 +47,18 @@ public class LeaderboardManager {
|
||||
islandVotes.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size()));
|
||||
}
|
||||
|
||||
islandLevels.sort(new Comparator<LeaderboardPlayer>() {
|
||||
@Override
|
||||
public int compare(LeaderboardPlayer leaderboardPlayer1, LeaderboardPlayer leaderboardPlayer2) {
|
||||
return Integer.valueOf(leaderboardPlayer2.getValue()).compareTo(leaderboardPlayer1.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
islandVotes.sort(new Comparator<LeaderboardPlayer>() {
|
||||
@Override
|
||||
public int compare(LeaderboardPlayer leaderboardPlayer1, LeaderboardPlayer leaderboardPlayer2) {
|
||||
return Integer.valueOf(leaderboardPlayer2.getValue()).compareTo(leaderboardPlayer1.getValue());
|
||||
}
|
||||
});
|
||||
islandLevels.sort(Comparator.comparingInt(LeaderboardPlayer::getValue).reversed());
|
||||
islandVotes.sort(Comparator.comparingInt(LeaderboardPlayer::getValue).reversed());
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (islandLevels.size() != 0 && i <= islandLevels.size() - 1) {
|
||||
leaderboardStorage.add(new Leaderboard(Leaderboard.Type.Level,
|
||||
visitManager.getIsland((UUID) islandLevels.get(i).getUUID()), i));
|
||||
if (!islandVotes.isEmpty() && i < islandVotes.size()) {
|
||||
Leaderboard leaderboard = new Leaderboard(Leaderboard.Type.Votes, visitManager.getIsland(islandVotes.get(i).getUUID()), i);
|
||||
leaderboardStorage.add(leaderboard);
|
||||
}
|
||||
|
||||
if (islandVotes.size() != 0 && i <= islandVotes.size() - 1) {
|
||||
leaderboardStorage.add(new Leaderboard(Leaderboard.Type.Votes,
|
||||
visitManager.getIsland((UUID) islandVotes.get(i).getUUID()), i));
|
||||
if (!islandLevels.isEmpty() && i < islandLevels.size()) {
|
||||
Leaderboard leaderboard = new Leaderboard(Leaderboard.Type.Level, visitManager.getIsland(islandLevels.get(i).getUUID()), i);
|
||||
leaderboardStorage.add(leaderboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,16 +5,17 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.minecart.StorageMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
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.ItemStack;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
@ -26,6 +27,7 @@ import me.goodandevil.skyblock.utils.structure.StructureUtil;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
|
||||
public class Interact implements Listener {
|
||||
|
||||
@ -588,7 +590,17 @@ public class Interact implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
|
||||
}
|
||||
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, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
else if (entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
|
||||
if (is.getType() == Material.BUCKET) {
|
||||
if (!islandManager.hasPermission(player, entity.getLocation(), "Milking")) {
|
||||
event.setCancelled(true);
|
||||
@ -612,7 +624,20 @@ public class Interact implements Listener {
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (entity.getType() == EntityType.MINECART || entity.getType() == EntityType.BOAT) {
|
||||
}
|
||||
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, Sounds.VILLAGER_NO.bukkitSound(), 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);
|
||||
|
||||
@ -710,15 +735,48 @@ public class Interact implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
|
||||
if (!(event.getRightClicked() instanceof ArmorStand)) {
|
||||
public void onPlayerDamageVehicle(VehicleDamageEvent event){
|
||||
if(!(event.getAttacker() instanceof Player))
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getAttacker();
|
||||
|
||||
if (!skyblock.getIslandManager().hasPermission(player, event.getVehicle().getLocation(), "MobHurting")) {
|
||||
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, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDestroyVehicle(VehicleDestroyEvent event){
|
||||
if(!(event.getAttacker() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getAttacker();
|
||||
|
||||
if (!skyblock.getIslandManager().hasPermission(player, event.getVehicle().getLocation(), "MobHurting")) {
|
||||
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, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractAtEntity(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
org.bukkit.entity.Entity entity = event.getRightClicked();
|
||||
|
||||
if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
|
||||
if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld()))
|
||||
return;
|
||||
|
||||
if (entity instanceof ArmorStand){
|
||||
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "ArmorStandUse")) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -728,5 +786,6 @@ public class Interact implements Listener {
|
||||
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -189,12 +189,18 @@ public class Move implements Listener {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Config config = skyblock.getFileManager()
|
||||
.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (LocationUtil.isLocationAtLocationRadius(to,
|
||||
island.getLocation(world, IslandEnvironment.Island), island.getRadius() + 2)) {
|
||||
player.teleport(player.getLocation()
|
||||
.add(from.toVector().subtract(to.toVector()).normalize().multiply(2.0D)));
|
||||
player.setFallDistance(0.0F);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
if(!configLoad.getBoolean("Island.WorldBorder.Enable")){
|
||||
player.teleport(player.getLocation()
|
||||
.add(from.toVector().subtract(to.toVector()).normalize().multiply(2.0D)));
|
||||
player.setFallDistance(0.0F);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
if (island.getVisit().isVisitor(player.getUniqueId())) {
|
||||
player.teleport(island.getLocation(world, IslandEnvironment.Visitor));
|
||||
|
@ -1,30 +1,27 @@
|
||||
package me.goodandevil.skyblock.listeners;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandEnvironment;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.IslandWorld;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.IslandRole;
|
||||
import me.goodandevil.skyblock.island.IslandWorld;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import me.goodandevil.skyblock.utils.world.LocationUtil;
|
||||
import me.goodandevil.skyblock.world.WorldManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Portal implements Listener {
|
||||
|
||||
@ -35,10 +32,37 @@ public class Portal implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityPortalEnter(EntityPortalEnterEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
public void onPlayerMove(PlayerMoveEvent event){
|
||||
Player player = event.getPlayer();
|
||||
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();
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(to.getLocation());
|
||||
if(from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ())
|
||||
return;
|
||||
|
||||
if(island != null){
|
||||
if((to.getType().equals(Materials.NETHER_PORTAL.parseMaterial()) ||
|
||||
to.getType().equals(Materials.END_PORTAL.parseMaterial())) &&
|
||||
!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, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityPortalEnter(EntityPortalEnterEvent event) {
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
org.bukkit.block.Block block = event.getLocation().getBlock();
|
||||
@ -53,98 +77,149 @@ public class Portal implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
|
||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
||||
|
||||
if (island != null) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (((block.getType() == Materials.NETHER_PORTAL.parseMaterial()
|
||||
&& configLoad.getBoolean("Island.World.Nether.Enable"))
|
||||
|| (block.getType() == Materials.END_PORTAL.parseMaterial()
|
||||
&& configLoad.getBoolean("Island.World.End.Enable")))
|
||||
&& islandManager.hasPermission(player, "Portal")) {
|
||||
if (configLoad.getBoolean("Island.Portal.Island")) {
|
||||
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
if (world == IslandWorld.Normal) {
|
||||
if (block.getType() == Materials.NETHER_PORTAL.parseMaterial()) {
|
||||
player.teleport(island.getLocation(IslandWorld.Nether, IslandEnvironment.Main));
|
||||
} else if (block.getType() == Materials.END_PORTAL.parseMaterial()) {
|
||||
player.teleport(island.getLocation(IslandWorld.End, IslandEnvironment.Main));
|
||||
}
|
||||
} else {
|
||||
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||
}
|
||||
} else {
|
||||
if (world == IslandWorld.Normal) {
|
||||
if (block.getType() == Materials.NETHER_PORTAL.parseMaterial()) {
|
||||
player.teleport(island.getLocation(IslandWorld.Nether, IslandEnvironment.Visitor));
|
||||
} else if (block.getType() == Materials.END_PORTAL.parseMaterial()) {
|
||||
player.teleport(island.getLocation(IslandWorld.End, IslandEnvironment.Visitor));
|
||||
}
|
||||
} else {
|
||||
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (block.getType() == Materials.NETHER_PORTAL.parseMaterial()
|
||||
&& Bukkit.getServer().getAllowNether()) {
|
||||
for (World worldList : Bukkit.getServer().getWorlds()) {
|
||||
if (worldList.getEnvironment() == Environment.NETHER) {
|
||||
player.teleport(LocationUtil.getRandomLocation(worldList, 5000, 5000, true, true));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (block.getType() == Materials.END_PORTAL.parseMaterial()
|
||||
&& Bukkit.getServer().getAllowEnd()) {
|
||||
for (World worldList : Bukkit.getServer().getWorlds()) {
|
||||
if (worldList.getEnvironment() == Environment.THE_END) {
|
||||
player.teleport(worldList.getSpawnLocation());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||
} else {
|
||||
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Portal.Destination.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
player.teleport(island.getLocation(world, IslandEnvironment.Main));
|
||||
} else {
|
||||
player.teleport(island.getLocation(world, IslandEnvironment.Visitor));
|
||||
}
|
||||
|
||||
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, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
player.setFallDistance(0.0F);
|
||||
IslandEnvironment spawnEnvironment;
|
||||
switch (island.getRole(player)){
|
||||
case Operator:
|
||||
case Owner:
|
||||
case Member:
|
||||
case Coop:
|
||||
spawnEnvironment = IslandEnvironment.Island;
|
||||
break;
|
||||
|
||||
return;
|
||||
default:
|
||||
spawnEnvironment = IslandEnvironment.Visitor;
|
||||
}
|
||||
|
||||
IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld());
|
||||
IslandWorld toWorld = IslandWorld.Normal;
|
||||
|
||||
if(block.getType().equals(Materials.NETHER_PORTAL.parseMaterial()))
|
||||
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.Nether : IslandWorld.Normal;
|
||||
else if(block.getType().equals(Materials.END_PORTAL.parseMaterial()))
|
||||
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.End : IslandWorld.Normal;
|
||||
|
||||
switch (toWorld){
|
||||
case Nether:
|
||||
if(configLoad.getBoolean("Island.World.Nether.Enable")){
|
||||
player.teleport(island.getLocation(toWorld, spawnEnvironment));
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
}
|
||||
break;
|
||||
|
||||
case End:
|
||||
if(configLoad.getBoolean("Island.World.End.Enable")){
|
||||
player.teleport(island.getLocation(toWorld, spawnEnvironment));
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
player.teleport(island.getLocation(toWorld, spawnEnvironment));
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
break;
|
||||
}
|
||||
|
||||
//region GoodAndEvil his code (garbage)
|
||||
// if (((block.getType() == Materials.NETHER_PORTAL.parseMaterial()
|
||||
// && configLoad.getBoolean("Island.World.Nether.Enable"))
|
||||
// || (block.getType() == Materials.END_PORTAL.parseMaterial()
|
||||
// && configLoad.getBoolean("Island.World.End.Enable")))
|
||||
// && islandManager.hasPermission(player, "Portal")) {
|
||||
// if (configLoad.getBoolean("Island.Portal.Island")) {
|
||||
// if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||
// || island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
// || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
// if (world == IslandWorld.Normal) {
|
||||
// if (block.getType() == Materials.NETHER_PORTAL.parseMaterial()) {
|
||||
// Bukkit.broadcastMessage("BP 1");
|
||||
// player.teleport(island.getLocation(IslandWorld.Nether, IslandEnvironment.Main));
|
||||
// } else if (block.getType() == Materials.END_PORTAL.parseMaterial()) {
|
||||
// player.teleport(island.getLocation(IslandWorld.End, IslandEnvironment.Main));
|
||||
// }
|
||||
// } else {
|
||||
// player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||
// }
|
||||
// } else {
|
||||
// if (world == IslandWorld.Normal) {
|
||||
// if (block.getType() == Materials.NETHER_PORTAL.parseMaterial()) {
|
||||
// player.teleport(island.getLocation(IslandWorld.Nether, IslandEnvironment.Visitor));
|
||||
// } else if (block.getType() == Materials.END_PORTAL.parseMaterial()) {
|
||||
// player.teleport(island.getLocation(IslandWorld.End, IslandEnvironment.Visitor));
|
||||
// }
|
||||
// } else {
|
||||
// player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
// } else if (block.getType() == Materials.NETHER_PORTAL.parseMaterial()
|
||||
// && Bukkit.getServer().getAllowNether()) {
|
||||
// for (World worldList : Bukkit.getServer().getWorlds()) {
|
||||
// if (worldList.getEnvironment() == Environment.NETHER) {
|
||||
// player.teleport(LocationUtil.getRandomLocation(worldList, 5000, 5000, true, true));
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
// } else if (block.getType() == Materials.END_PORTAL.parseMaterial()
|
||||
// && Bukkit.getServer().getAllowEnd()) {
|
||||
// for (World worldList : Bukkit.getServer().getWorlds()) {
|
||||
// if (worldList.getEnvironment() == Environment.THE_END) {
|
||||
// player.teleport(worldList.getSpawnLocation());
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
// } else {
|
||||
// if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||
// || island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
// || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
// player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||
// } else {
|
||||
// player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
||||
// }
|
||||
//
|
||||
// messageManager.sendMessage(player,
|
||||
// fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
// .getFileConfiguration().getString("Island.Portal.Destination.Message"));
|
||||
// soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
// }
|
||||
// } else {
|
||||
// if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||
// || island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
// || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
// player.teleport(island.getLocation(world, IslandEnvironment.Main));
|
||||
// } else {
|
||||
// player.teleport(island.getLocation(world, IslandEnvironment.Visitor));
|
||||
// }
|
||||
//
|
||||
// messageManager.sendMessage(player,
|
||||
// fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
// .getString("Island.Settings.Permission.Message"));
|
||||
// soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
// }
|
||||
//endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class Quit implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (playerData.getIsland() != null && islandManager.containsIsland(playerData.getIsland())) {
|
||||
if (playerData != null && playerData.getIsland() != null && islandManager.containsIsland(playerData.getIsland())) {
|
||||
island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
||||
|
||||
if (!island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||
|
@ -109,7 +109,7 @@ public class Biome {
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else {
|
||||
if (cooldownManager.hasPlayer(CooldownType.Biome, player)) {
|
||||
if (cooldownManager.hasPlayer(CooldownType.Biome, player) && !player.hasPermission("skyblockearth.bypass.cooldown")) {
|
||||
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Biome,
|
||||
player);
|
||||
Cooldown cooldown = cooldownPlayer.getCooldown();
|
||||
@ -139,7 +139,6 @@ public class Biome {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
org.bukkit.block.Biome selectedBiomeType = null;
|
||||
|
||||
if (is.getType() == Materials.SUNFLOWER.parseMaterial()) {
|
||||
@ -158,13 +157,8 @@ public class Biome {
|
||||
selectedBiomeType = Biomes.ROOFED_FOREST.bukkitBiome();
|
||||
}
|
||||
|
||||
if (!player.hasPermission("skyblock.bypass.cooldown")
|
||||
&& !player.hasPermission("skyblock.bypass.*")
|
||||
&& !player.hasPermission("skyblock.*")) {
|
||||
cooldownManager.createPlayer(CooldownType.Biome, player);
|
||||
biomeManager.setBiome(island, selectedBiomeType);
|
||||
}
|
||||
|
||||
cooldownManager.createPlayer(CooldownType.Biome, player);
|
||||
biomeManager.setBiome(island, selectedBiomeType);
|
||||
island.setBiome(selectedBiomeType);
|
||||
island.save();
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
name: SkyBlock
|
||||
name: FabledSkyBlock
|
||||
main: me.goodandevil.skyblock.SkyBlock
|
||||
version: 59
|
||||
version: 62
|
||||
api-version: 1.13
|
||||
description: A unique SkyBlock plugin
|
||||
author: GoodAndEvil
|
||||
@ -10,4 +10,7 @@ loadbefore: [Multiverse-Core]
|
||||
commands:
|
||||
island:
|
||||
description: Island command
|
||||
aliases: [is]
|
||||
aliases: [is]
|
||||
|
||||
skyblock:
|
||||
description: Skyblock info command.
|
Loading…
Reference in New Issue
Block a user