mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-30 03:11:25 +01:00
Merge branch 'development'
This commit is contained in:
commit
d63a0faf41
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>skyblock</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>2.2.2</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>FabledSkyblock-${project.version}</finalName>
|
||||
|
@ -8,9 +8,9 @@ public interface Structure {
|
||||
|
||||
String getName();
|
||||
|
||||
CompatibleMaterial getMaterials();
|
||||
CompatibleMaterial getMaterial();
|
||||
|
||||
void setMaterials(CompatibleMaterial materials);
|
||||
void setMaterial(CompatibleMaterial material);
|
||||
|
||||
String getOverworldFile();
|
||||
|
||||
|
@ -93,7 +93,7 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
final ConfigurationSection liquidSection = config.getConfigurationSection("Island.World." + env + ".Liquid");
|
||||
|
||||
for (List<ChunkSnapshot> sub : parts) {
|
||||
queueWork(world, liquidSection.getBoolean("Enable") ? liquidSection.getInt("Height") + 1 : 0, sub);
|
||||
queueWork(world, liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : 0, sub);
|
||||
}
|
||||
|
||||
}
|
||||
@ -114,9 +114,9 @@ public final class BlockScanner extends BukkitRunnable {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = scanY; y < 256; y++) {
|
||||
|
||||
final Material type = VERSION > 12 ? shot.getBlockType(x, y, z) : MaterialIDHelper.getLegacyMaterial(getBlockTypeID(shot, x, y, z));
|
||||
final CompatibleMaterial type = CompatibleMaterial.getMaterial(shot.getBlockType(x, y, z));
|
||||
|
||||
if (type == Material.AIR) continue;
|
||||
if (type == CompatibleMaterial.AIR || type == CompatibleMaterial.WATER) continue;
|
||||
|
||||
blocks.add(new BlockInfo(world, x + (cX), y, z + (cZ)));
|
||||
}
|
||||
|
@ -257,9 +257,6 @@ public class Challenge {
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + id + "\" isn't a correct Minecraft EntityType (value = \"" + value + "\")");
|
||||
}
|
||||
if (et == null)
|
||||
throw new IllegalArgumentException(
|
||||
"\"" + id + "\" isn't a correct Minecraft EntityType (value = \"" + value + "\")");
|
||||
int amount = 1;
|
||||
if (index != -1) {
|
||||
String strAmount = value.substring(index + 1);
|
||||
|
@ -68,7 +68,7 @@ public class ChallengeCategory {
|
||||
+ ") at challenge " + name + "(" + id + "): " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
Bukkit.getLogger().info("[FabledSkyBlock] " + ChatColor.GREEN + " Category " + name + ChatColor.GREEN
|
||||
Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + "Category " + name + ChatColor.GREEN
|
||||
+ " loaded with " + ChatColor.GOLD + challenges.size() + ChatColor.GREEN + " challenges");
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -40,7 +41,7 @@ public class ChallengeManager {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error while loading challenges:", ex);
|
||||
return;
|
||||
}
|
||||
Bukkit.getLogger().info("[FabledSkyBlock] " + ChatColor.GREEN + " challenges loaded with " + ChatColor.GOLD
|
||||
Bukkit.getConsoleSender().sendMessage("[FabledSkyBlock] " + ChatColor.GREEN + " challenges loaded with " + ChatColor.GOLD
|
||||
+ categories.size() + ChatColor.GREEN + " categories");
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -38,13 +39,14 @@ public class DefaultInventory {
|
||||
String name = ChatColor.translateAlternateColorCodes('&', configLoad.getString(k + ".name"));
|
||||
List<String> lore = toColor(configLoad.getStringList(k + ".lore"));
|
||||
int redirect = configLoad.getInt(k + ".redirect");
|
||||
Material item = Material.matchMaterial(strItem);
|
||||
if (item == null || item == Material.AIR) {
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(strItem);
|
||||
if (material == null || material == CompatibleMaterial.AIR) {
|
||||
Bukkit.getLogger().warning("Item " + strItem + " is not a Material");
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack is = new ItemStack(item, amount);
|
||||
ItemStack is = material.getItem();
|
||||
is.setAmount(amount);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(name);
|
||||
im.setLore(lore);
|
||||
|
@ -100,7 +100,7 @@ public class ChallengeInventory implements InventoryProvider {
|
||||
// Update
|
||||
inv.updateItem(ic.getCol(), ic.getRow(), is2);
|
||||
} else
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_GLASS_BREAK, 1, 1);
|
||||
p.playSound(p.getLocation(), CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1, 1);
|
||||
};
|
||||
inv.set(ic.getCol(), ic.getRow(), ClickableItem.of(is, consumer));
|
||||
}
|
||||
|
@ -39,19 +39,6 @@ import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
|
||||
public final class IslandLevelManager {
|
||||
|
||||
private static final Set<Material> CHECKED_DOUBLE_TYPES;
|
||||
|
||||
static {
|
||||
CHECKED_DOUBLE_TYPES = EnumSet.noneOf(Material.class);
|
||||
|
||||
CHECKED_DOUBLE_TYPES.add(CompatibleMaterial.SUNFLOWER.getMaterial());
|
||||
CHECKED_DOUBLE_TYPES.add(CompatibleMaterial.LILAC.getMaterial());
|
||||
CHECKED_DOUBLE_TYPES.add(CompatibleMaterial.LARGE_FERN.getMaterial());
|
||||
CHECKED_DOUBLE_TYPES.add(CompatibleMaterial.ROSE_BUSH.getMaterial());
|
||||
CHECKED_DOUBLE_TYPES.add(CompatibleMaterial.PEONY.getMaterial());
|
||||
CHECKED_DOUBLE_TYPES.add(CompatibleMaterial.TALL_GRASS.getMaterial());
|
||||
}
|
||||
|
||||
private final static int VERSION = NMSUtil.getVersionNumber();
|
||||
private Map<Island, IslandScan> inScan;
|
||||
private Map<CompatibleMaterial, Long> worth;
|
||||
@ -65,14 +52,6 @@ public final class IslandLevelManager {
|
||||
reloadWorth();
|
||||
}
|
||||
|
||||
public static boolean isDoubleCheckedBlock(Block block) {
|
||||
return CHECKED_DOUBLE_TYPES.contains(parseType(block));
|
||||
}
|
||||
|
||||
private static CompatibleMaterial parseType(Block block) {
|
||||
return CompatibleMaterial.getBlockMaterial(block.getType());
|
||||
}
|
||||
|
||||
public void startScan(Player attemptScanner, Island island) {
|
||||
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
@ -185,52 +164,44 @@ public final class IslandLevelManager {
|
||||
|
||||
if (blockType == CompatibleMaterial.AIR) return EMPTY;
|
||||
|
||||
CompatibleMaterial compMaterial = parseType(block);
|
||||
CompatibleMaterial compMaterial = CompatibleMaterial.getMaterial(block);
|
||||
|
||||
if (compMaterial == null) return EMPTY;
|
||||
|
||||
Material finalType = compMaterial.getMaterial();
|
||||
|
||||
if (finalType == null) return EMPTY;
|
||||
|
||||
final Location blockLocation = block.getLocation();
|
||||
|
||||
if (scan.getDoubleBlocks().contains(blockLocation)) return EMPTY;
|
||||
|
||||
if (CHECKED_DOUBLE_TYPES.contains(finalType)) {
|
||||
|
||||
if (compMaterial.isTall()) {
|
||||
final Block belowBlock = block.getRelative(BlockFace.DOWN);
|
||||
final CompatibleMaterial belowType = parseType(belowBlock);
|
||||
final CompatibleMaterial belowMaterial = CompatibleMaterial.getMaterial(belowBlock);
|
||||
|
||||
if (CHECKED_DOUBLE_TYPES.contains(belowType)) {
|
||||
if (belowMaterial.isTall()) {
|
||||
block = belowBlock;
|
||||
blockType = belowType;
|
||||
blockType = belowMaterial;
|
||||
scan.getDoubleBlocks().add(belowBlock.getLocation());
|
||||
} else {
|
||||
scan.getDoubleBlocks().add(block.getRelative(BlockFace.UP).getLocation());
|
||||
}
|
||||
|
||||
} else if (finalType == CompatibleMaterial.SPAWNER.getBlockMaterial()) {
|
||||
finalType = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType()).getMaterial();
|
||||
}
|
||||
|
||||
final List<Calculator> calculators = CalculatorRegistry.getCalculators(blockType);
|
||||
final StackableManager stackableManager = SkyBlock.getInstance().getStackableManager();
|
||||
|
||||
final CompatibleMaterial finalCompatMat = CompatibleMaterial.getMaterial(finalType);
|
||||
|
||||
final long stackSize = stackableManager == null ? 0 : stackableManager.getStackSizeOf(blockLocation, finalCompatMat);
|
||||
final long stackSize = stackableManager == null ? 0 : stackableManager.getStackSizeOf(blockLocation, compMaterial);
|
||||
|
||||
if (calculators == null) {
|
||||
|
||||
if (stackSize > 1) return new AmountMaterialPair(finalCompatMat, stackSize);
|
||||
if (stackSize > 1) return new AmountMaterialPair(compMaterial, stackSize);
|
||||
|
||||
AmountMaterialPair cachedPair = cachedPairs.get(finalType);
|
||||
AmountMaterialPair cachedPair = cachedPairs.get(compMaterial);
|
||||
|
||||
if (cachedPair != null) return cachedPair;
|
||||
|
||||
cachedPair = new AmountMaterialPair(finalCompatMat, 1);
|
||||
cachedPairs.put(finalCompatMat, cachedPair);
|
||||
cachedPair = new AmountMaterialPair(compMaterial, 1);
|
||||
cachedPairs.put(compMaterial, cachedPair);
|
||||
|
||||
return cachedPair;
|
||||
}
|
||||
@ -243,7 +214,7 @@ public final class IslandLevelManager {
|
||||
|
||||
if (amount == 0) amount = 1;
|
||||
|
||||
return new AmountMaterialPair(finalCompatMat, amount + stackSize);
|
||||
return new AmountMaterialPair(compMaterial, amount + stackSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -140,11 +140,11 @@ public class Block implements Listener {
|
||||
|
||||
if (event.isCancelled() || !configLoad.getBoolean("Island.Block.Level.Enable")) return;
|
||||
|
||||
if (IslandLevelManager.isDoubleCheckedBlock(block)) {
|
||||
if (CompatibleMaterial.getMaterial(block).isTall()) {
|
||||
|
||||
final org.bukkit.block.Block belowBlock = block.getRelative(BlockFace.DOWN);
|
||||
|
||||
if (IslandLevelManager.isDoubleCheckedBlock(belowBlock)) {
|
||||
if (CompatibleMaterial.getMaterial(belowBlock).isTall()) {
|
||||
block = belowBlock;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class Creator {
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
for (Structure structureList : skyblock.getStructureManager().getStructures()) {
|
||||
if ((is.getType() == structureList.getMaterials().getMaterial()) && (is.hasItemMeta())
|
||||
if ((is.getType() == structureList.getMaterial().getMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName()
|
||||
.equals(ChatColor.translateAlternateColorCodes('&', configLoad
|
||||
.getString("Menu.Creator.Selector.Item.Island.Displayname")
|
||||
@ -229,7 +229,7 @@ public class Creator {
|
||||
}
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(structure.getMaterials().getItem(),
|
||||
nInv.addItem(nInv.createItem(structure.getMaterial().getItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Creator.Selector.Item.Island.Displayname")
|
||||
.replace("%displayname", structure.getDisplayname())),
|
||||
|
@ -106,7 +106,7 @@ public class Creator implements Listener {
|
||||
inventorySlot++;
|
||||
|
||||
Structure structure = structures.get(index);
|
||||
nInv.addItem(nInv.createItem(structure.getMaterials().getItem(),
|
||||
nInv.addItem(nInv.createItem(structure.getMaterial().getItem(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.Admin.Creator.Browse.Item.Structure.Displayname")
|
||||
.replace("%structure", structure.getName())),
|
||||
@ -235,7 +235,7 @@ public class Creator implements Listener {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.DIAMOND.getMaterial()),
|
||||
configLoad.getString("Menu.Admin.Creator.Options.Item.Item.Displayname"),
|
||||
configLoad.getStringList("Menu.Admin.Creator.Options.Item.Item.Lore"),
|
||||
new Placeholder[]{new Placeholder("%material", structure.getMaterials().name())}, null, null),
|
||||
new Placeholder[]{new Placeholder("%material", structure.getMaterial().name())}, null, null),
|
||||
6);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(CompatibleMaterial.GOLD_NUGGET.getMaterial()),
|
||||
configLoad.getString("Menu.Admin.Creator.Options.Item.DeletionCost.Displayname"),
|
||||
@ -1148,7 +1148,7 @@ public class Creator implements Listener {
|
||||
materials.getItem().setData(event.getCurrentItem().getData());
|
||||
|
||||
if (materials != null) {
|
||||
structure.setMaterials(materials);
|
||||
structure.setMaterial(materials);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
Config config113 = fileManager
|
||||
@ -1156,7 +1156,7 @@ public class Creator implements Listener {
|
||||
FileConfiguration configLoad113 = config113.getFileConfiguration();
|
||||
|
||||
configLoad113.set("Structures." + structure.getName() + ".Item.Material",
|
||||
structure.getMaterials().name());
|
||||
structure.getMaterial().name());
|
||||
|
||||
try {
|
||||
configLoad113.save(config113.getFile());
|
||||
@ -1193,7 +1193,7 @@ public class Creator implements Listener {
|
||||
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
|
||||
for (Structure structureList : structureManager.getStructures()) {
|
||||
if (event.getCurrentItem().getType() == structureList.getMaterials().getMaterial()
|
||||
if (event.getCurrentItem().getType() == structureList.getMaterial().getMaterial()
|
||||
&& ChatColor.stripColor(is.getItemMeta().getDisplayName())
|
||||
.equals(structureList.getName())) {
|
||||
if (event.getClick() == ClickType.LEFT) {
|
||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||
|
||||
public class Structure implements com.songoda.skyblock.api.structure.Structure {
|
||||
|
||||
private CompatibleMaterial materials;
|
||||
private CompatibleMaterial material;
|
||||
|
||||
private String name;
|
||||
private String overworldFile;
|
||||
@ -23,11 +23,11 @@ public class Structure implements com.songoda.skyblock.api.structure.Structure {
|
||||
|
||||
private double deletionCost;
|
||||
|
||||
public Structure(String name, CompatibleMaterial materials, String overworldFile, String netherFile, String endFile,
|
||||
public Structure(String name, CompatibleMaterial material, String overworldFile, String netherFile, String endFile,
|
||||
String displayName, boolean permission, List<String> description, List<String> commands,
|
||||
double deletionCost) {
|
||||
this.name = name;
|
||||
this.materials = materials;
|
||||
this.material = material;
|
||||
this.overworldFile = overworldFile;
|
||||
this.netherFile = netherFile;
|
||||
this.endFile = endFile;
|
||||
@ -42,12 +42,12 @@ public class Structure implements com.songoda.skyblock.api.structure.Structure {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CompatibleMaterial getMaterials() {
|
||||
return materials;
|
||||
public CompatibleMaterial getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public void setMaterials(CompatibleMaterial materials) {
|
||||
this.materials = materials;
|
||||
public void setMaterial(CompatibleMaterial material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public String getOverworldFile() {
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.io.Files;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.utils.Compression;
|
||||
@ -18,16 +19,11 @@ import com.songoda.skyblock.utils.world.entity.EntityUtil;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.Base64;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.ChunkSection;
|
||||
import net.minecraft.server.v1_15_R1.IBlockData;
|
||||
import net.minecraft.server.v1_15_R1.World;
|
||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -58,22 +54,23 @@ public final class StructureUtil {
|
||||
|
||||
String originBlockLocation = "";
|
||||
|
||||
for (Block blockList : blocks.keySet()) {
|
||||
Location location = blocks.get(blockList);
|
||||
for (Block block : blocks.keySet()) {
|
||||
Location location = blocks.get(block);
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(block);
|
||||
|
||||
if (location.isOriginLocation()) {
|
||||
originBlockLocation = location.getX() + ":" + location.getY() + ":" + location.getZ() + ":" + positions[0].getWorld().getName();
|
||||
|
||||
if (blockList.getType() == Material.AIR) {
|
||||
blockData.add(BlockUtil.convertBlockToBlockData(blockList, location.getX(), location.getY(), location.getZ()));
|
||||
if (material == CompatibleMaterial.AIR) {
|
||||
blockData.add(BlockUtil.convertBlockToBlockData(block, location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
if (blockList.getType() == Material.AIR) {
|
||||
if (material == CompatibleMaterial.AIR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
blockData.add(BlockUtil.convertBlockToBlockData(blockList, location.getX(), location.getY(), location.getZ()));
|
||||
blockData.add(BlockUtil.convertBlockToBlockData(block, location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
|
||||
for (Entity entityList : entities.keySet()) {
|
||||
@ -174,13 +171,13 @@ public final class StructureUtil {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SkyBlock.getInstance(), () -> {
|
||||
try {
|
||||
org.bukkit.Location blockRotationLocation = LocationUtil.rotateLocation(new org.bukkit.Location(location.getWorld(), blockDataList.getX(), blockDataList.getY(), blockDataList.getZ()), type);
|
||||
org.bukkit.Location blockLocation = new org.bukkit.Location(location.getWorld(), location.getX() - Math.abs(Integer.valueOf(storage.getOriginLocation().split(":")[0])),
|
||||
location.getY() - Integer.valueOf(storage.getOriginLocation().split(":")[1]), location.getZ() + Math.abs(Integer.valueOf(storage.getOriginLocation().split(":")[2])));
|
||||
org.bukkit.Location blockLocation = new org.bukkit.Location(location.getWorld(), location.getX() - Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[0])),
|
||||
location.getY() - Integer.parseInt(storage.getOriginLocation().split(":")[1]), location.getZ() + Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[2])));
|
||||
blockLocation.add(blockRotationLocation);
|
||||
BlockUtil.convertBlockDataToBlock(blockLocation.getBlock(), blockDataList);
|
||||
} catch (Exception e) {
|
||||
SkyBlock.getInstance().getLogger()
|
||||
.warning("Unable to convert BlockData to Block for type {" + blockDataList.getMaterial() + ":" + blockDataList.getData() + "} in structure {" + structure.getStructureFile() + "}");
|
||||
.warning("Unable to convert BlockData to Block for type {" + blockDataList.getCompatibleMaterial() + ":" + blockDataList.getData() + "} in structure {" + structure.getStructureFile() + "}");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -191,8 +188,8 @@ public final class StructureUtil {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SkyBlock.getInstance(), () -> {
|
||||
try {
|
||||
org.bukkit.Location blockRotationLocation = LocationUtil.rotateLocation(new org.bukkit.Location(location.getWorld(), entityDataList.getX(), entityDataList.getY(), entityDataList.getZ()), type);
|
||||
org.bukkit.Location blockLocation = new org.bukkit.Location(location.getWorld(), location.getX() - Math.abs(Integer.valueOf(storage.getOriginLocation().split(":")[0])),
|
||||
location.getY() - Integer.valueOf(storage.getOriginLocation().split(":")[1]), location.getZ() + Math.abs(Integer.valueOf(storage.getOriginLocation().split(":")[2])));
|
||||
org.bukkit.Location blockLocation = new org.bukkit.Location(location.getWorld(), location.getX() - Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[0])),
|
||||
location.getY() - Integer.parseInt(storage.getOriginLocation().split(":")[1]), location.getZ() + Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[2])));
|
||||
blockLocation.add(blockRotationLocation);
|
||||
EntityUtil.convertEntityDataToEntity(entityDataList, blockLocation, type);
|
||||
} catch (Exception e) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.songoda.skyblock.utils.world.block;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@ -17,9 +17,9 @@ import java.util.Map;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BlockData {
|
||||
|
||||
private String material = Material.AIR.toString();
|
||||
private String blockData = "";
|
||||
private String biome = Biome.PLAINS.toString();
|
||||
private CompatibleMaterial compatibleMaterial;
|
||||
private String material;
|
||||
private String biome;
|
||||
private String stateType = BlockStateType.NORMAL.toString();
|
||||
private String dataType = BlockDataType.NORMAL.toString();
|
||||
private String baseColor = Color.WHITE.toString();
|
||||
@ -46,7 +46,7 @@ public class BlockData {
|
||||
private int fuelLevel = 0;
|
||||
private int delay = 0;
|
||||
|
||||
private byte data = (byte) 0;
|
||||
private byte data;
|
||||
|
||||
private short burnTime = (short) 0;
|
||||
private short cookTime = (short) 0;
|
||||
@ -55,10 +55,8 @@ public class BlockData {
|
||||
|
||||
private boolean exactTeleport = true;
|
||||
|
||||
public BlockData(String material, byte data, int x, int y, int z, String biome) {
|
||||
this.material = material;
|
||||
this.data = data;
|
||||
|
||||
public BlockData(CompatibleMaterial material, int x, int y, int z, String biome) {
|
||||
this.compatibleMaterial = material;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
@ -66,20 +64,14 @@ public class BlockData {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
public String getMaterial() {
|
||||
return this.material;
|
||||
public CompatibleMaterial getCompatibleMaterial() {
|
||||
if (compatibleMaterial == null)
|
||||
return CompatibleMaterial.getMaterial(material);
|
||||
return compatibleMaterial;
|
||||
}
|
||||
|
||||
public void setMaterial(String material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public String getBlockData() {
|
||||
return blockData;
|
||||
}
|
||||
|
||||
public void setBlockData(String blockData) {
|
||||
this.blockData = blockData;
|
||||
public void setMaterial(CompatibleMaterial material) {
|
||||
this.compatibleMaterial = material;
|
||||
}
|
||||
|
||||
public String getBiome() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.skyblock.utils.world.block;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.utils.BlockUtils;
|
||||
import com.songoda.skyblock.utils.item.ItemStackUtil;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
import org.bukkit.*;
|
||||
@ -18,18 +19,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public final class BlockUtil {
|
||||
public final class BlockUtil extends BlockUtils {
|
||||
|
||||
public static BlockData convertBlockToBlockData(Block block, int x, int y, int z) {
|
||||
BlockData blockData = new BlockData(block.getType().toString(), block.getData(), x, y, z, block.getBiome().toString());
|
||||
BlockData blockData = new BlockData(CompatibleMaterial.getMaterial(block), x, y, z, block.getBiome().toString());
|
||||
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
blockData.setVersion(NMSVersion);
|
||||
|
||||
if (NMSVersion > 12) {
|
||||
blockData.setBlockData(block.getBlockData().getAsString());
|
||||
}
|
||||
|
||||
BlockState blockState = block.getState();
|
||||
MaterialData materialData = blockState.getData();
|
||||
|
||||
@ -249,14 +246,10 @@ public final class BlockUtil {
|
||||
public static void convertBlockDataToBlock(Block block, BlockData blockData) {
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
|
||||
Material material = null;
|
||||
CompatibleMaterial material = blockData.getCompatibleMaterial();
|
||||
if (material == null) return;
|
||||
|
||||
if (NMSVersion > 12 && blockData.getVersion() > 12 && blockData.getBlockData() != null) {
|
||||
block.setBlockData(Bukkit.getServer().createBlockData(blockData.getBlockData()));
|
||||
} else {
|
||||
material = CompatibleMaterial.getMaterial(blockData.getMaterial()).getMaterial();
|
||||
setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), material, blockData.getData());
|
||||
}
|
||||
setBlockFast(block.getWorld(), block.getX(), block.getY(), block.getZ(), material, blockData.getData());
|
||||
|
||||
// TODO Create a class to support biome changes
|
||||
// block.setBiome(Biome.valueOf(blockData.getBiome().toUpperCase()));
|
||||
@ -420,9 +413,10 @@ public final class BlockUtil {
|
||||
stairs.setFacingDirection(BlockFace.valueOf(blockData.getFacing()));
|
||||
state.setData(stairs);
|
||||
} else if (blockDataType == BlockDataType.FLOWERPOT) {
|
||||
if (NMSVersion >= 8 && NMSVersion <= 12) {
|
||||
setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), CompatibleMaterial.STONE, (byte) 0);
|
||||
if (NMSVersion >= 8 && NMSVersion <= 12) {
|
||||
if (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR) {
|
||||
setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), Material.STONE, (byte) 0);
|
||||
setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), CompatibleMaterial.STONE, (byte) 0);
|
||||
}
|
||||
|
||||
if (blockData.getFlower() != null && !blockData.getFlower().isEmpty()) {
|
||||
@ -430,10 +424,10 @@ public final class BlockUtil {
|
||||
String[] flower = blockData.getFlower().split(":");
|
||||
int materialData = Integer.parseInt(flower[1]);
|
||||
|
||||
material = CompatibleMaterial.getMaterial(flower[0].toUpperCase()).getMaterial();
|
||||
material = CompatibleMaterial.getMaterial(flower[0].toUpperCase());
|
||||
|
||||
if (material != null) {
|
||||
ItemStack is = new ItemStack(material, 1, (byte) materialData);
|
||||
ItemStack is = new ItemStack(material.getMaterial(), 1, (byte) materialData);
|
||||
|
||||
World world = block.getWorld();
|
||||
|
||||
@ -468,16 +462,16 @@ public final class BlockUtil {
|
||||
|
||||
if (blockData.getVersion() > 12) {
|
||||
if (NMSVersion > 12) {
|
||||
material = Material.valueOf(flower[0].toUpperCase());
|
||||
material = CompatibleMaterial.valueOf(flower[0].toUpperCase());
|
||||
}
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
material = Material.valueOf(flower[0].toUpperCase());
|
||||
material = CompatibleMaterial.valueOf(flower[0].toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
if (material != null) {
|
||||
flowerPot.setContents(new MaterialData(material, (byte) Integer.parseInt(flower[1])));
|
||||
flowerPot.setContents(new MaterialData(material.getMaterial(), (byte) Integer.parseInt(flower[1])));
|
||||
}
|
||||
|
||||
state.setData(flowerPot);
|
||||
@ -485,7 +479,7 @@ public final class BlockUtil {
|
||||
}
|
||||
}
|
||||
|
||||
if (blockData.getMaterial().equals("DOUBLE_PLANT")) {
|
||||
if (blockData.getCompatibleMaterial().equals("DOUBLE_PLANT")) {
|
||||
Block topBlock = block.getLocation().add(0.0D, 1.0D, 0.0D).getBlock();
|
||||
Block bottomBlock = block.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
|
||||
|
||||
@ -516,36 +510,4 @@ public final class BlockUtil {
|
||||
|
||||
return nearbyBlocks;
|
||||
}
|
||||
|
||||
private static Class<?> IBlockDataClass = NMSUtil.getNMSClass("IBlockData");
|
||||
private static Class<?> blocksClass = NMSUtil.getNMSClass("Blocks");
|
||||
|
||||
|
||||
private static void setBlockFast(World world, int x, int y, int z, Material material, byte data) {
|
||||
try {
|
||||
Object worldHandle = world.getClass().getMethod("getHandle").invoke(world);
|
||||
Object chunk = worldHandle.getClass().getMethod("getChunkAt", int.class, int.class).invoke(worldHandle, x >> 4, z >> 4);
|
||||
Object blockPosition = NMSUtil.getNMSClass("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(x & 0xF, y, z & 0xF);
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 12) {
|
||||
Object block = blocksClass.getField(material.name()).get(null);
|
||||
Object IBlockData = block.getClass().getMethod("getBlockData").invoke(block);
|
||||
worldHandle.getClass().getMethod("setTypeAndData", blockPosition.getClass(), IBlockDataClass, int.class).invoke(worldHandle, blockPosition, IBlockData, 2);
|
||||
|
||||
try {
|
||||
chunk.getClass().getMethod("a", blockPosition.getClass(), IBlockDataClass, boolean.class).invoke(chunk, blockPosition, IBlockData, true);
|
||||
} catch (Exception ignored) {
|
||||
chunk.getClass().getMethod("setType", blockPosition.getClass(), IBlockDataClass, boolean.class).invoke(chunk, blockPosition, IBlockData, true);
|
||||
}
|
||||
} else {
|
||||
Object IBlockData = NMSUtil.getNMSClass("Block").getMethod("getByCombinedId", int.class).invoke(null, material.getId() + (data << 12));
|
||||
worldHandle.getClass().getMethod("setTypeAndData", blockPosition.getClass(), IBlockDataClass, int.class).invoke(worldHandle, blockPosition, IBlockData, 3);
|
||||
chunk.getClass().getMethod("a", blockPosition.getClass(), IBlockDataClass).invoke(chunk, blockPosition, IBlockData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
block.getState().setRawData(data);
|
||||
block.setType(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +178,8 @@ Island:
|
||||
# time cycle or be fixed.
|
||||
Cycle: false
|
||||
Levelling:
|
||||
# Should the level scanner scan water?
|
||||
ScanLiquid: false
|
||||
# Run a scan automatically when pasting an island structure
|
||||
ScanAutomatically: true
|
||||
# Include Points: 0 in the '/is level' GUI
|
||||
|
Loading…
Reference in New Issue
Block a user