fix blockdisplay
This commit is contained in:
parent
891ef64b63
commit
027e975a98
1 changed files with 14 additions and 12 deletions
|
|
@ -36,7 +36,7 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
private final Map<Entity, Vector> velocitiesMap = new HashMap<>();
|
private final Map<Entity, Vector> velocitiesMap = new HashMap<>();
|
||||||
private ScheduledTask task;
|
private ScheduledTask task;
|
||||||
private ScheduledTask blockktask;
|
private ScheduledTask blockktask;
|
||||||
private boolean blockCreated = false;
|
private BlockDisplay display;
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
|
|
@ -81,22 +81,24 @@ public class FoliaFlow extends JavaPlugin implements Listener {
|
||||||
} catch (UnsupportedOperationException ignored) {
|
} catch (UnsupportedOperationException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location = new Location(Bukkit.getWorld("world_the_end"), 100, 48, 0);
|
Location loc = new Location(Bukkit.getWorld("world_the_end"), 100, 48, 0);
|
||||||
if (!blockCreated) {
|
BlockData blockData = Material.OBSIDIAN.createBlockData();
|
||||||
World world = location.getWorld();
|
display = Objects.requireNonNull(Bukkit.getWorld("world_the_end")).spawn(loc, BlockDisplay.class);
|
||||||
if (world != null) {
|
display.setBlock(blockData);
|
||||||
Block block = world.getBlockAt(location);
|
|
||||||
BlockData blockData = block.getBlockData();
|
|
||||||
BlockDisplay blockDisplay = (BlockDisplay) world.spawnEntity(location, EntityType.BLOCK_DISPLAY);
|
|
||||||
blockDisplay.setBlock(blockData);
|
|
||||||
blockCreated = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
if (display != null) {
|
||||||
|
display.remove();
|
||||||
|
display = null;
|
||||||
|
}
|
||||||
|
for (Entity entity : Objects.requireNonNull(Bukkit.getWorld("world_the_end")).getEntitiesByClass(BlockDisplay.class)) {
|
||||||
|
entity.remove();
|
||||||
|
}
|
||||||
task.cancel();
|
task.cancel();
|
||||||
blockktask.cancel();
|
blockktask.cancel();
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue