Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
8f89c4d63a
Commit
54b955c1f5
@ -34,6 +34,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
@Linked(LinkageType.LISTENER)
|
@Linked(LinkageType.LISTENER)
|
||||||
@ -56,15 +57,22 @@ public class SignEdit implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void editSign(PlayerInteractEvent event) {
|
public void editSign(PlayerInteractEvent event) {
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK ||
|
if (!event.getPlayer().isSneaking()) return;
|
||||||
!event.getClickedBlock().getType().name().contains("SIGN") ||
|
if (!event.getClickedBlock().getType().name().contains("SIGN")) return;
|
||||||
!event.getPlayer().isSneaking() ||
|
|
||||||
(event.getItem() != null && event.getItem().getType() != Material.AIR))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && (event.getItem() == null || event.getItem().getType() == Material.AIR)) {
|
||||||
Player player = event.getPlayer();
|
event.setCancelled(true);
|
||||||
Sign sign = (org.bukkit.block.Sign) event.getClickedBlock().getState();
|
edit(event.getPlayer(), event.getClickedBlock());
|
||||||
|
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
edit(event.getPlayer(), event.getClickedBlock());
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void edit(Player player, Block block) {
|
||||||
|
Sign sign = (org.bukkit.block.Sign) block.getState();
|
||||||
String[] lines = sign.getLines();
|
String[] lines = sign.getLines();
|
||||||
for (int i = 0; i < lines.length; i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
sign.setLine(i, lines[i].replace('§', '&'));
|
sign.setLine(i, lines[i].replace('§', '&'));
|
||||||
@ -72,7 +80,7 @@ public class SignEdit implements Listener {
|
|||||||
sign.update();
|
sign.update();
|
||||||
|
|
||||||
Object openSignObject = Reflection.newInstance(openSign);
|
Object openSignObject = Reflection.newInstance(openSign);
|
||||||
blockPositionFieldAccessor.set(openSignObject, getPosition.invoke(event.getClickedBlock()));
|
blockPositionFieldAccessor.set(openSignObject, getPosition.invoke(block));
|
||||||
TinyProtocol.instance.sendPacket(player, openSignObject);
|
TinyProtocol.instance.sendPacket(player, openSignObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren