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.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<>();
|
||||
|
|
Reference in a new issue