SteamWar/BauSystem
Archiviert
13
0

Fixing and Editing

Dieser Commit ist enthalten in:
Chaoscaot 2021-02-01 15:06:22 +01:00
Ursprung 6376ef7dd5
Commit 7a89347248

Datei anzeigen

@ -28,9 +28,12 @@ import com.comphenix.protocol.wrappers.BlockPosition;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.core.VersionedCallable;
import net.minecraft.server.v1_15_R1.PacketPlayOutOpenSignEditor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -117,9 +120,10 @@ public class RegionListener implements Listener {
@EventHandler @EventHandler
public void editSign(PlayerInteractEvent event) { public void editSign(PlayerInteractEvent event) {
if(event.getAction() != Action.RIGHT_CLICK_BLOCK || if(event.getAction() != Action.RIGHT_CLICK_BLOCK ||
!event.getClickedBlock().getType().name().contains("_SIGN") || !event.getClickedBlock().getType().name().contains("SIGN") ||
!event.getPlayer().isSneaking()) !event.getPlayer().isSneaking())
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
Sign sign = (Sign) event.getClickedBlock().getState(); Sign sign = (Sign) event.getClickedBlock().getState();
String[] lines = sign.getLines(); String[] lines = sign.getLines();
@ -127,6 +131,7 @@ public class RegionListener implements Listener {
sign.setLine(i, lines[i].replace('§', '&')); sign.setLine(i, lines[i].replace('§', '&'));
} }
sign.update(); sign.update();
PacketContainer signOpen = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR); PacketContainer signOpen = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
signOpen.getBlockPositionModifier().write(0, new BlockPosition(event.getClickedBlock().getLocation().toVector())); signOpen.getBlockPositionModifier().write(0, new BlockPosition(event.getClickedBlock().getLocation().toVector()));
try { try {
@ -147,7 +152,7 @@ public class RegionListener implements Listener {
String[] lines = packetContainer.getStringArrays().read(0); String[] lines = packetContainer.getStringArrays().read(0);
Block signLoc = position.toLocation(player.getWorld()).getBlock(); Block signLoc = position.toLocation(player.getWorld()).getBlock();
if(!signLoc.getType().name().contains("_SIGN")) if(!signLoc.getType().name().contains("SIGN"))
return; return;
Sign sign = ((Sign) signLoc.getState()); Sign sign = ((Sign) signLoc.getState());