Fixed data restoring
This commit is contained in:
parent
65128f67cd
commit
160adf9a5e
1 changed files with 8 additions and 3 deletions
|
@ -15,6 +15,7 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -171,15 +172,19 @@ public class TPPCMD implements CommandExecutor {
|
||||||
|
|
||||||
Block block = loc.getBlock();
|
Block block = loc.getBlock();
|
||||||
Material oldMaterial = block.getType();
|
Material oldMaterial = block.getType();
|
||||||
byte oldData = block.getData();
|
byte oldData = block.getState().getRawData();
|
||||||
Material redstoneMaterial = XMaterial.REDSTONE_BLOCK.parseMaterial();
|
Material redstoneMaterial = XMaterial.REDSTONE_BLOCK.parseMaterial();
|
||||||
|
|
||||||
if (redstoneMaterial == null) throw new IllegalArgumentException("Redstone Material not found.");
|
if (redstoneMaterial == null) throw new IllegalArgumentException("Redstone Material not found.");
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ThemeParkPlus.getInstance(), () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(ThemeParkPlus.getInstance(), () -> {
|
||||||
block.setType(redstoneMaterial);
|
block.setType(redstoneMaterial);
|
||||||
if (!XMaterial.isNewVersion()) block.getState().setRawData(oldData); //LEGACY
|
Bukkit.getScheduler().scheduleSyncDelayedTask(ThemeParkPlus.getInstance(), () -> {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ThemeParkPlus.getInstance(), () -> block.setType(oldMaterial), offDelayTicks);
|
BlockState state = block.getState();
|
||||||
|
state.setType(oldMaterial);
|
||||||
|
if (!XMaterial.isNewVersion()) state.setRawData(oldData);
|
||||||
|
state.update(true);
|
||||||
|
}, offDelayTicks);
|
||||||
}, onDelayTicks);
|
}, onDelayTicks);
|
||||||
|
|
||||||
HashMap<String, String> replacements = new HashMap<>();
|
HashMap<String, String> replacements = new HashMap<>();
|
||||||
|
|
Reference in a new issue