mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-14 02:31:21 +01:00
Merge branch 'development' into 'master'
Features & Bug fixes See merge request Songoda/fabledskyblock!15
This commit is contained in:
commit
a286995428
@ -12,7 +12,7 @@ public class IslandLevelChangeEvent extends IslandEvent {
|
|||||||
private final IslandLevel level;
|
private final IslandLevel level;
|
||||||
|
|
||||||
public IslandLevelChangeEvent(Island island, IslandLevel level) {
|
public IslandLevelChangeEvent(Island island, IslandLevel level) {
|
||||||
super(island, true);
|
super(island);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,12 @@ public class IslandManager {
|
|||||||
islandPositionList.setZ(z);
|
islandPositionList.setZ(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new org.bukkit.Location(skyblock.getWorldManager().getWorld(world), x, 72, z);
|
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||||
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
int islandHeight = configLoad.getInt("Island.World." + world.name() + ".IslandSpawnHeight", 72);
|
||||||
|
|
||||||
|
return new org.bukkit.Location(skyblock.getWorldManager().getWorld(world), x, islandHeight, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,9 +30,11 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class LevellingManager {
|
public class LevellingManager {
|
||||||
@ -81,6 +83,7 @@ public class LevellingManager {
|
|||||||
boolean isWildStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("WildStacker");
|
boolean isWildStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("WildStacker");
|
||||||
|
|
||||||
Map<LevellingData, Long> levellingData = new HashMap<>();
|
Map<LevellingData, Long> levellingData = new HashMap<>();
|
||||||
|
Set<Location> spawnerLocations = new HashSet<>(); // These have to be checked synchronously :(
|
||||||
|
|
||||||
List<Material> blacklistedMaterials = new ArrayList<>();
|
List<Material> blacklistedMaterials = new ArrayList<>();
|
||||||
blacklistedMaterials.add(Materials.AIR.getPostMaterial());
|
blacklistedMaterials.add(Materials.AIR.getPostMaterial());
|
||||||
@ -95,7 +98,7 @@ public class LevellingManager {
|
|||||||
if (!chunk.isReadyToScan()) return;
|
if (!chunk.isReadyToScan()) return;
|
||||||
|
|
||||||
if (chunk.isFinished()) {
|
if (chunk.isFinished()) {
|
||||||
finalizeMaterials(levellingData, player, island);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> finalizeMaterials(levellingData, spawnerLocations, player, island), 1);
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -164,23 +167,24 @@ public class LevellingManager {
|
|||||||
|
|
||||||
if (isWildStackerEnabled && spawnerType == null) {
|
if (isWildStackerEnabled && spawnerType == null) {
|
||||||
com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager();
|
com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager();
|
||||||
if (wildStacker.isStackedSpawner(location.getBlock())) {
|
com.bgsoftware.wildstacker.api.objects.StackedSpawner spawner = wildStacker.getStackedSpawner(location);
|
||||||
com.bgsoftware.wildstacker.api.objects.StackedSpawner spawner = wildStacker.getStackedSpawner(location);
|
if (spawner != null) {
|
||||||
amount = spawner.getStackAmount();
|
amount = spawner.getStackAmount();
|
||||||
spawnerType = spawner.getSpawnedType();
|
spawnerType = spawner.getSpawnedType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spawnerType == null) {
|
if (spawnerType == null) {
|
||||||
spawnerType = ((CreatureSpawner) location.getBlock().getState()).getSpawnedType();
|
spawnerLocations.add(location);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isWildStackerEnabled) {
|
if (isWildStackerEnabled) {
|
||||||
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
World world = Bukkit.getWorld(chunkSnapshotList.getWorldName());
|
||||||
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
|
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
|
||||||
com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager();
|
com.bgsoftware.wildstacker.api.handlers.SystemManager wildStacker = com.bgsoftware.wildstacker.api.WildStackerAPI.getWildStacker().getSystemManager();
|
||||||
if (wildStacker.isStackedBarrel(location.getBlock())) {
|
com.bgsoftware.wildstacker.api.objects.StackedBarrel barrel = wildStacker.getStackedBarrel(location);
|
||||||
com.bgsoftware.wildstacker.api.objects.StackedBarrel barrel = wildStacker.getStackedBarrel(location.getBlock());
|
if (barrel != null) {
|
||||||
amount = barrel.getStackAmount();
|
amount = barrel.getStackAmount();
|
||||||
blockMaterial = barrel.getType();
|
blockMaterial = barrel.getType();
|
||||||
blockData = barrel.getData();
|
blockData = barrel.getData();
|
||||||
@ -196,7 +200,9 @@ public class LevellingManager {
|
|||||||
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
|
Location location = new Location(world, chunkSnapshotList.getX() * 16 + x, y, chunkSnapshotList.getZ() * 16 + z);
|
||||||
if (stackableManager.isStacked(location)) {
|
if (stackableManager.isStacked(location)) {
|
||||||
Stackable stackable = stackableManager.getStack(location, blockMaterial);
|
Stackable stackable = stackableManager.getStack(location, blockMaterial);
|
||||||
amount = stackable.getSize();
|
if (stackable != null) {
|
||||||
|
amount = stackable.getSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,7 +225,20 @@ public class LevellingManager {
|
|||||||
}.runTaskTimerAsynchronously(skyblock, 0L, 1L);
|
}.runTaskTimerAsynchronously(skyblock, 0L, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finalizeMaterials(Map<LevellingData, Long> levellingData, Player player, Island island) {
|
private void finalizeMaterials(Map<LevellingData, Long> levellingData, Set<Location> spawnerLocations, Player player, Island island) {
|
||||||
|
for (Location location : spawnerLocations) {
|
||||||
|
if (!(location.getBlock().getState() instanceof CreatureSpawner))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int amount = 1;
|
||||||
|
EntityType spawnerType = ((CreatureSpawner) location.getBlock().getState()).getSpawnedType();
|
||||||
|
|
||||||
|
LevellingData data = new LevellingData(Materials.SPAWNER.parseMaterial(), (byte) 0, spawnerType);
|
||||||
|
Long totalAmountInteger = levellingData.get(data);
|
||||||
|
long totalAmount = totalAmountInteger == null ? amount : totalAmountInteger + amount;
|
||||||
|
levellingData.put(data, totalAmount);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Long> materials = new HashMap<>();
|
Map<String, Long> materials = new HashMap<>();
|
||||||
for (LevellingData data : levellingData.keySet()) {
|
for (LevellingData data : levellingData.keySet()) {
|
||||||
long amount = levellingData.get(data);
|
long amount = levellingData.get(data);
|
||||||
@ -241,8 +260,7 @@ public class LevellingManager {
|
|||||||
level.setLastCalculatedLevel(level.getLevel());
|
level.setLastCalculatedLevel(level.getLevel());
|
||||||
level.setMaterials(materials);
|
level.setMaterials(materials);
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(
|
Bukkit.getServer().getPluginManager().callEvent(new IslandLevelChangeEvent(island.getAPIWrapper(), island.getAPIWrapper().getLevel()));
|
||||||
new IslandLevelChangeEvent(island.getAPIWrapper(), island.getAPIWrapper().getLevel()));
|
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
me.goodandevil.skyblock.menus.Levelling.getInstance().open(player);
|
me.goodandevil.skyblock.menus.Levelling.getInstance().open(player);
|
||||||
|
@ -47,6 +47,8 @@ public class EZPlaceholder extends PlaceholderExpansion implements Listener {
|
|||||||
return skyblock.getDescription().getVersion();
|
return skyblock.getDescription().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean persist() { return true; }
|
||||||
|
|
||||||
public String onPlaceholderRequest(Player player, String identifier) {
|
public String onPlaceholderRequest(Player player, String identifier) {
|
||||||
PlaceholderManager placeholderManager = skyblock.getPlaceholderManager();
|
PlaceholderManager placeholderManager = skyblock.getPlaceholderManager();
|
||||||
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
LeaderboardManager leaderboardManager = skyblock.getLeaderboardManager();
|
||||||
@ -143,13 +145,4 @@ public class EZPlaceholder extends PlaceholderExpansion implements Listener {
|
|||||||
return placeholderManager.getPlaceholder(player, "fabledskyblock_" + identifier);
|
return placeholderManager.getPlaceholder(player, "fabledskyblock_" + identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* If a player uses '/papi reload' then we need to reload this expansion
|
|
||||||
*/
|
|
||||||
@EventHandler
|
|
||||||
public void onExpansionUnregister(ExpansionUnregisterEvent event) {
|
|
||||||
if (event.getExpansion() instanceof EZPlaceholder) {
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, this::register, 20L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package me.goodandevil.skyblock.utils;
|
|||||||
import me.goodandevil.skyblock.SkyBlock;
|
import me.goodandevil.skyblock.SkyBlock;
|
||||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -22,7 +23,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AbstractAnvilGUI {
|
public class AbstractAnvilGUI {
|
||||||
|
|
||||||
private static Class<?> BlockPositionClass;
|
private static Class<?> BlockPositionClass;
|
||||||
private static Class<?> PacketPlayOutOpenWindowClass;
|
private static Class<?> PacketPlayOutOpenWindowClass;
|
||||||
private static Class<?> IChatBaseComponentClass;
|
private static Class<?> IChatBaseComponentClass;
|
||||||
@ -35,6 +35,7 @@ public class AbstractAnvilGUI {
|
|||||||
private static Class<?> WorldClass;
|
private static Class<?> WorldClass;
|
||||||
private static Class<?> PlayerInventoryClass;
|
private static Class<?> PlayerInventoryClass;
|
||||||
private static Class<?> ContainersClass;
|
private static Class<?> ContainersClass;
|
||||||
|
private static Class<?> CraftPlayerClass;
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private Map<AnvilSlot, ItemStack> items = new HashMap<>();
|
private Map<AnvilSlot, ItemStack> items = new HashMap<>();
|
||||||
@ -52,6 +53,7 @@ public class AbstractAnvilGUI {
|
|||||||
ContainerClass = NMSUtil.getNMSClass("Container");
|
ContainerClass = NMSUtil.getNMSClass("Container");
|
||||||
WorldClass = NMSUtil.getNMSClass("World");
|
WorldClass = NMSUtil.getNMSClass("World");
|
||||||
PlayerInventoryClass = NMSUtil.getNMSClass("PlayerInventory");
|
PlayerInventoryClass = NMSUtil.getNMSClass("PlayerInventory");
|
||||||
|
CraftPlayerClass = NMSUtil.getCraftClass("entity.CraftPlayer");
|
||||||
|
|
||||||
if (NMSUtil.getVersionNumber() > 13) {
|
if (NMSUtil.getVersionNumber() > 13) {
|
||||||
ContainerAccessClass = NMSUtil.getNMSClass("ContainerAccess");
|
ContainerAccessClass = NMSUtil.getNMSClass("ContainerAccess");
|
||||||
@ -59,84 +61,77 @@ public class AbstractAnvilGUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractAnvilGUI(final Player player, final AnvilClickEventHandler handler) {
|
public AbstractAnvilGUI(Player player, AnvilClickEventHandler handler) {
|
||||||
|
SkyBlock instance = SkyBlock.getInstance();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
this.listener = new Listener() {
|
this.listener = new Listener() {
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
if (event.getWhoClicked() instanceof Player) {
|
if (event.getWhoClicked() instanceof Player && event.getInventory().equals(AbstractAnvilGUI.this.inv)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
if (event.getInventory().equals(inv)) {
|
ItemStack item = event.getCurrentItem();
|
||||||
event.setCancelled(true);
|
int slot = event.getRawSlot();
|
||||||
|
|
||||||
ItemStack item = event.getCurrentItem();
|
if (item == null || item.getType().equals(Material.AIR) || slot != 2)
|
||||||
int slot = event.getRawSlot();
|
return;
|
||||||
String name = "";
|
|
||||||
|
|
||||||
if (item != null) {
|
String name = "";
|
||||||
if (item.hasItemMeta()) {
|
|
||||||
ItemMeta meta = item.getItemMeta();
|
|
||||||
|
|
||||||
if (meta != null && meta.hasDisplayName()) {
|
ItemMeta meta = item.getItemMeta();
|
||||||
name = meta.getDisplayName();
|
if (meta != null && meta.hasDisplayName())
|
||||||
}
|
name = meta.getDisplayName();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AnvilClickEvent clickEvent = new AnvilClickEvent(AnvilSlot.bySlot(slot), name);
|
AnvilClickEvent clickEvent = new AnvilClickEvent(AnvilSlot.bySlot(slot), name);
|
||||||
|
handler.onAnvilClick(clickEvent);
|
||||||
|
|
||||||
handler.onAnvilClick(clickEvent);
|
if (clickEvent.getWillClose())
|
||||||
|
event.getWhoClicked().closeInventory();
|
||||||
|
|
||||||
if (clickEvent.getWillClose()) {
|
if (clickEvent.getWillDestroy())
|
||||||
event.getWhoClicked().closeInventory();
|
AbstractAnvilGUI.this.destroy();
|
||||||
}
|
|
||||||
|
|
||||||
if (clickEvent.getWillDestroy()) {
|
|
||||||
destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onInventoryClose(InventoryCloseEvent event) {
|
public void onInventoryClose(InventoryCloseEvent event) {
|
||||||
if (event.getPlayer() instanceof Player) {
|
if (event.getPlayer() instanceof Player && AbstractAnvilGUI.this.inv.equals(event.getInventory())) {
|
||||||
Inventory inv = event.getInventory();
|
Inventory inv = event.getInventory();
|
||||||
player.setLevel(player.getLevel() - 1);
|
player.setLevel(player.getLevel() - 1);
|
||||||
if (inv.equals(inv)) {
|
inv.clear();
|
||||||
inv.clear();
|
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||||
destroy();
|
AbstractAnvilGUI.this.destroy();
|
||||||
}
|
}, 1L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
if (event.getPlayer().equals(getPlayer())) {
|
if (event.getPlayer().equals(AbstractAnvilGUI.this.player)) {
|
||||||
player.setLevel(player.getLevel() - 1);
|
player.setLevel(player.getLevel() - 1);
|
||||||
destroy();
|
AbstractAnvilGUI.this.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(listener, SkyBlock.getInstance());
|
Bukkit.getPluginManager().registerEvents(this.listener, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSlot(AnvilSlot slot, ItemStack item) {
|
public void setSlot(AnvilSlot slot, ItemStack item) {
|
||||||
items.put(slot, item);
|
this.items.put(slot, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void open() {
|
public void open() {
|
||||||
player.setLevel(player.getLevel() + 1);
|
this.player.setLevel(this.player.getLevel() + 1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object craftPlayer = NMSUtil.getCraftClass("entity.CraftPlayer").cast(player);
|
Object craftPlayer = CraftPlayerClass.cast(this.player);
|
||||||
Method getHandleMethod = craftPlayer.getClass().getMethod("getHandle");
|
Method getHandleMethod = CraftPlayerClass.getMethod("getHandle");
|
||||||
Object entityPlayer = getHandleMethod.invoke(craftPlayer);
|
Object entityPlayer = getHandleMethod.invoke(craftPlayer);
|
||||||
Object playerInventory = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "inventory", false));
|
Object playerInventory = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "inventory", false));
|
||||||
Object world = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "world", false));
|
Object world = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "world", false));
|
||||||
@ -159,10 +154,10 @@ public class AbstractAnvilGUI {
|
|||||||
Method getBukkitViewMethod = container.getClass().getMethod("getBukkitView");
|
Method getBukkitViewMethod = container.getClass().getMethod("getBukkitView");
|
||||||
Object bukkitView = getBukkitViewMethod.invoke(container);
|
Object bukkitView = getBukkitViewMethod.invoke(container);
|
||||||
Method getTopInventoryMethod = bukkitView.getClass().getMethod("getTopInventory");
|
Method getTopInventoryMethod = bukkitView.getClass().getMethod("getTopInventory");
|
||||||
inv = (Inventory) getTopInventoryMethod.invoke(bukkitView);
|
this.inv = (Inventory) getTopInventoryMethod.invoke(bukkitView);
|
||||||
|
|
||||||
for (AnvilSlot slot : items.keySet()) {
|
for (AnvilSlot slot : this.items.keySet()) {
|
||||||
inv.setItem(slot.getSlot(), items.get(slot));
|
this.inv.setItem(slot.getSlot(), this.items.get(slot));
|
||||||
}
|
}
|
||||||
|
|
||||||
Method nextContainerCounterMethod = entityPlayer.getClass().getMethod("nextContainerCounter");
|
Method nextContainerCounterMethod = entityPlayer.getClass().getMethod("nextContainerCounter");
|
||||||
@ -183,7 +178,7 @@ public class AbstractAnvilGUI {
|
|||||||
.newInstance(c, "minecraft:anvil", inventoryTitle, 0);
|
.newInstance(c, "minecraft:anvil", inventoryTitle, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
NMSUtil.sendPacket(player, packet);
|
NMSUtil.sendPacket(this.player, packet);
|
||||||
|
|
||||||
Field activeContainerField = NMSUtil.getField(EntityHumanClass, "activeContainer", true);
|
Field activeContainerField = NMSUtil.getField(EntityHumanClass, "activeContainer", true);
|
||||||
|
|
||||||
@ -203,12 +198,12 @@ public class AbstractAnvilGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
player = null;
|
this.player = null;
|
||||||
items = null;
|
this.items = null;
|
||||||
|
|
||||||
HandlerList.unregisterAll(listener);
|
HandlerList.unregisterAll(this.listener);
|
||||||
|
|
||||||
listener = null;
|
this.listener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AnvilSlot {
|
public enum AnvilSlot {
|
||||||
@ -233,7 +228,7 @@ public class AbstractAnvilGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSlot() {
|
public int getSlot() {
|
||||||
return slot;
|
return this.slot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,15 +251,15 @@ public class AbstractAnvilGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AnvilSlot getSlot() {
|
public AnvilSlot getSlot() {
|
||||||
return slot;
|
return this.slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getWillClose() {
|
public boolean getWillClose() {
|
||||||
return close;
|
return this.close;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWillClose(boolean close) {
|
public void setWillClose(boolean close) {
|
||||||
@ -272,7 +267,7 @@ public class AbstractAnvilGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean getWillDestroy() {
|
public boolean getWillDestroy() {
|
||||||
return destroy;
|
return this.destroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWillDestroy(boolean destroy) {
|
public void setWillDestroy(boolean destroy) {
|
||||||
@ -280,4 +275,4 @@ public class AbstractAnvilGUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,15 +1,5 @@
|
|||||||
package me.goodandevil.skyblock.utils.structure;
|
package me.goodandevil.skyblock.utils.structure;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
|
||||||
import me.goodandevil.skyblock.SkyBlock;
|
import me.goodandevil.skyblock.SkyBlock;
|
||||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -29,16 +19,16 @@ public class SchematicUtil {
|
|||||||
|
|
||||||
Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> {
|
||||||
if (NMSUtil.getVersionNumber() > 12) { // WorldEdit 7
|
if (NMSUtil.getVersionNumber() > 12) { // WorldEdit 7
|
||||||
ClipboardFormat format = com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats.findByFile(schematicFile);
|
com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat format = com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats.findByFile(schematicFile);
|
||||||
try (ClipboardReader reader = format.getReader(new FileInputStream(schematicFile))) {
|
try (com.sk89q.worldedit.extent.clipboard.io.ClipboardReader reader = format.getReader(new FileInputStream(schematicFile))) {
|
||||||
Clipboard clipboard = reader.read();
|
com.sk89q.worldedit.extent.clipboard.Clipboard clipboard = reader.read();
|
||||||
try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(location.getWorld()), -1)) {
|
try (com.sk89q.worldedit.EditSession editSession = com.sk89q.worldedit.WorldEdit.getInstance().getEditSessionFactory().getEditSession(new com.sk89q.worldedit.bukkit.BukkitWorld(location.getWorld()), -1)) {
|
||||||
Operation operation = new ClipboardHolder(clipboard)
|
com.sk89q.worldedit.function.operation.Operation operation = new com.sk89q.worldedit.session.ClipboardHolder(clipboard)
|
||||||
.createPaste(editSession)
|
.createPaste(editSession)
|
||||||
.to(BlockVector3.at(location.getX(), location.getY(), location.getZ()))
|
.to(com.sk89q.worldedit.math.BlockVector3.at(location.getX(), location.getY(), location.getZ()))
|
||||||
.ignoreAirBlocks(true)
|
.ignoreAirBlocks(true)
|
||||||
.build();
|
.build();
|
||||||
Operations.complete(operation);
|
com.sk89q.worldedit.function.operation.Operations.complete(operation);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class NMSUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getCraftClass(String className) throws ClassNotFoundException {
|
public static Class<?> getCraftClass(String className) {
|
||||||
try {
|
try {
|
||||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||||
Class<?> clazz = Class.forName(fullName);
|
Class<?> clazz = Class.forName(fullName);
|
||||||
|
@ -40,6 +40,10 @@ public class WorldManager {
|
|||||||
boolean netherWorldEnabled = configLoad.getBoolean("Island.World.Nether.Enable");
|
boolean netherWorldEnabled = configLoad.getBoolean("Island.World.Nether.Enable");
|
||||||
boolean endWorldEnabled = configLoad.getBoolean("Island.World.End.Enable");
|
boolean endWorldEnabled = configLoad.getBoolean("Island.World.End.Enable");
|
||||||
|
|
||||||
|
World.Environment normalWorldEnvironment = World.Environment.valueOf(configLoad.getString("Island.World.Normal.Environment"));
|
||||||
|
World.Environment netherWorldEnvironment = World.Environment.valueOf(configLoad.getString("Island.World.Nether.Environment"));
|
||||||
|
World.Environment endWorldEnvironment = World.Environment.valueOf(configLoad.getString("Island.World.End.Environment"));
|
||||||
|
|
||||||
normalWorld = Bukkit.getServer().getWorld(normalWorldName);
|
normalWorld = Bukkit.getServer().getWorld(normalWorldName);
|
||||||
netherWorld = Bukkit.getServer().getWorld(netherWorldName);
|
netherWorld = Bukkit.getServer().getWorld(netherWorldName);
|
||||||
endWorld = Bukkit.getServer().getWorld(endWorldName);
|
endWorld = Bukkit.getServer().getWorld(endWorldName);
|
||||||
@ -47,28 +51,28 @@ public class WorldManager {
|
|||||||
if (normalWorld == null) {
|
if (normalWorld == null) {
|
||||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||||
"SkyBlock | Info: Generating VoidWorld '" + normalWorldName + "'.");
|
"SkyBlock | Info: Generating VoidWorld '" + normalWorldName + "'.");
|
||||||
normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(World.Environment.NORMAL)
|
normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(normalWorldEnvironment)
|
||||||
.generator(new VoidGenerator()).createWorld();
|
.generator(new VoidGenerator()).createWorld();
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(normalWorldName, World.Environment.NORMAL));
|
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(normalWorldName, normalWorldEnvironment));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netherWorld == null && netherWorldEnabled) {
|
if (netherWorld == null && netherWorldEnabled) {
|
||||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||||
"SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'.");
|
"SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'.");
|
||||||
netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(World.Environment.NETHER)
|
netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(netherWorldEnvironment)
|
||||||
.generator(new VoidGenerator()).createWorld();
|
.generator(new VoidGenerator()).createWorld();
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(netherWorldName, World.Environment.NETHER));
|
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(netherWorldName, netherWorldEnvironment));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endWorld == null && endWorldEnabled) {
|
if (endWorld == null && endWorldEnabled) {
|
||||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||||
"SkyBlock | Info: Generating VoidWorld '" + endWorldName + "'.");
|
"SkyBlock | Info: Generating VoidWorld '" + endWorldName + "'.");
|
||||||
endWorld = WorldCreator.name(endWorldName).type(WorldType.FLAT).environment(World.Environment.THE_END)
|
endWorld = WorldCreator.name(endWorldName).type(WorldType.FLAT).environment(endWorldEnvironment)
|
||||||
.generator(new VoidGenerator()).createWorld();
|
.generator(new VoidGenerator()).createWorld();
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(endWorldName, World.Environment.THE_END));
|
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(endWorldName, endWorldEnvironment));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,18 +35,22 @@ Island:
|
|||||||
# Time until player can create another island.
|
# Time until player can create another island.
|
||||||
Time: 60
|
Time: 60
|
||||||
World:
|
World:
|
||||||
# [!] The Island height is 72 blocks.
|
# Delete the Island world when changing the liquid option.
|
||||||
# Delete the Island world when changing the liquid option.
|
|
||||||
# If lava disabled, the world will be a water world.
|
# If lava disabled, the world will be a water world.
|
||||||
# -1 to disable Nether and End unlock prices.
|
# -1 to disable Nether and End unlock prices.
|
||||||
|
# Valid Enrivonments: NORMAL, NETHER, THE_END
|
||||||
Normal:
|
Normal:
|
||||||
Name: "island_normal_world"
|
Name: "island_normal_world"
|
||||||
|
IslandSpawnHeight: 72
|
||||||
|
Environment: NORMAL
|
||||||
Liquid:
|
Liquid:
|
||||||
Enable: false
|
Enable: false
|
||||||
Lava: false
|
Lava: false
|
||||||
Height: 60
|
Height: 60
|
||||||
Nether:
|
Nether:
|
||||||
Name: "island_nether_world"
|
Name: "island_nether_world"
|
||||||
|
IslandSpawnHeight: 72
|
||||||
|
Environment: NETHER
|
||||||
UnlockPrice: 10000
|
UnlockPrice: 10000
|
||||||
Enable: true
|
Enable: true
|
||||||
Liquid:
|
Liquid:
|
||||||
@ -55,6 +59,8 @@ Island:
|
|||||||
Height: 60
|
Height: 60
|
||||||
End:
|
End:
|
||||||
Name: "island_end_world"
|
Name: "island_end_world"
|
||||||
|
IslandSpawnHeight: 72
|
||||||
|
Environment: THE_END
|
||||||
UnlockPrice: 50000
|
UnlockPrice: 50000
|
||||||
Enable: true
|
Enable: true
|
||||||
Liquid:
|
Liquid:
|
||||||
|
Loading…
Reference in New Issue
Block a user