3
0
Fork 0

Fixed data restoring

This commit is contained in:
stijnb1234 2020-09-26 15:09:39 +02:00
parent 65128f67cd
commit 160adf9a5e

View file

@ -15,6 +15,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -171,15 +172,19 @@ public class TPPCMD implements CommandExecutor {
Block block = loc.getBlock();
Material oldMaterial = block.getType();
byte oldData = block.getData();
byte oldData = block.getState().getRawData();
Material redstoneMaterial = XMaterial.REDSTONE_BLOCK.parseMaterial();
if (redstoneMaterial == null) throw new IllegalArgumentException("Redstone Material not found.");
Bukkit.getScheduler().scheduleSyncDelayedTask(ThemeParkPlus.getInstance(), () -> {
block.setType(redstoneMaterial);
if (!XMaterial.isNewVersion()) block.getState().setRawData(oldData); //LEGACY
Bukkit.getScheduler().scheduleSyncDelayedTask(ThemeParkPlus.getInstance(), () -> block.setType(oldMaterial), offDelayTicks);
Bukkit.getScheduler().scheduleSyncDelayedTask(ThemeParkPlus.getInstance(), () -> {
BlockState state = block.getState();
state.setType(oldMaterial);
if (!XMaterial.isNewVersion()) state.setRawData(oldData);
state.update(true);
}, offDelayTicks);
}, onDelayTicks);
HashMap<String, String> replacements = new HashMap<>();