mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Various:
- Empty StringPlotBlocks are air - Update signs to 1.13 - Fix getting material in BukktiLocalQueue#setMaterial
This commit is contained in:
parent
442473368d
commit
1543ac50cd
@ -12,10 +12,10 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.data.Rotatable;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -275,18 +275,17 @@ import java.util.*;
|
||||
// block.setType(Material.AIR);
|
||||
final Material type = block.getType();
|
||||
if (type != Material.SIGN && type != Material.WALL_SIGN) {
|
||||
int data = 2;
|
||||
BlockFace facing = BlockFace.EAST;
|
||||
if (world.getBlockAt(x, y, z + 1).getType().isSolid())
|
||||
data = 2;
|
||||
facing = BlockFace.NORTH;
|
||||
else if (world.getBlockAt(x + 1, y, z).getType().isSolid())
|
||||
data = 4;
|
||||
facing = BlockFace.WEST;
|
||||
else if (world.getBlockAt(x, y, z - 1).getType().isSolid())
|
||||
data = 3;
|
||||
else if (world.getBlockAt(x - 1, y, z).getType().isSolid())
|
||||
data = 5;
|
||||
facing = BlockFace.SOUTH;
|
||||
block.setType(Material.WALL_SIGN, false);
|
||||
final Sign sign = (Sign) block.getBlockData();
|
||||
sign.setRawData((byte) data);
|
||||
final WallSign sign = (WallSign) block.getBlockData();
|
||||
sign.setFacing(facing);
|
||||
block.setBlockData(sign, false);
|
||||
}
|
||||
final BlockState blockstate = block.getState();
|
||||
if (blockstate instanceof Sign) {
|
||||
@ -403,7 +402,7 @@ import java.util.*;
|
||||
try {
|
||||
final Material material = getMaterial(block);
|
||||
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
|
||||
Class<? extends MaterialData> data = material.getData();
|
||||
Class<?> data = material.data;
|
||||
if (data.equals(MaterialData.class) && !material.isTransparent() && material
|
||||
.isOccluding() || data.equals(Tree.class) || data.equals(Sandstone.class)
|
||||
|| data.equals(Wool.class) || data.equals(Step.class) || data
|
||||
@ -419,6 +418,7 @@ import java.util.*;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -113,22 +113,28 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
||||
}
|
||||
|
||||
private void setMaterial(@NonNull final PlotBlock plotBlock, @NonNull final Block block) {
|
||||
final Material material;
|
||||
if (plotBlock instanceof StringPlotBlock) {
|
||||
final Material material = Material
|
||||
.getMaterial(((StringPlotBlock) plotBlock).getItemId().toLowerCase(Locale.ENGLISH));
|
||||
material = Material
|
||||
.getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH));
|
||||
if (material == null) {
|
||||
throw new IllegalStateException(
|
||||
String.format("Could not find material that matches %s", block.toString()));
|
||||
throw new IllegalStateException(String
|
||||
.format("Could not find material that matches %s",
|
||||
((StringPlotBlock) plotBlock).getItemId()));
|
||||
}
|
||||
block.setType(material, false);
|
||||
} else {
|
||||
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
|
||||
block.setType(Material.getMaterial(PlotSquared.get().IMP.getLegacyMappings()
|
||||
.fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData())
|
||||
.toString()));
|
||||
// block.setTypeIdAndData(legacyPlotBlock.getId(), legacyPlotBlock.getData(), false);
|
||||
material = PlotSquared.get().IMP.getLegacyMappings()
|
||||
.fromLegacyToString(legacyPlotBlock.getId()).to(Material.class);
|
||||
if (material == null) {
|
||||
throw new IllegalStateException(String
|
||||
.format("Could not find material that matches %s",
|
||||
PlotSquared.get().IMP.getLegacyMappings()
|
||||
.fromLegacyToString(legacyPlotBlock.getId())));
|
||||
}
|
||||
}
|
||||
block.setType(material, false);
|
||||
}
|
||||
|
||||
private boolean equals(@NonNull final PlotBlock plotBlock, @NonNull final Block block) {
|
||||
if (plotBlock instanceof StringPlotBlock) {
|
||||
|
@ -34,8 +34,12 @@ public class StringPlotBlock extends PlotBlock {
|
||||
this.itemId = parts[1].toLowerCase(Locale.ENGLISH);
|
||||
} else {
|
||||
this.nameSpace = "minecraft";
|
||||
if (itemId.isEmpty()) {
|
||||
this.itemId = "air";
|
||||
} else {
|
||||
this.itemId = itemId.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
this.determineForeign();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user