3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 05:20:05 +01:00

improved sign handling

Dieser Commit ist enthalten in:
Tahg 2011-04-28 01:29:36 -04:00
Ursprung b054cfdda7
Commit 97c5f2bb8e
2 geänderte Dateien mit 39 neuen und 43 gelöschten Zeilen

Datei anzeigen

@ -855,16 +855,15 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit start // CraftBukkit start
if (((WorldServer) this.player.world).isLoaded(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z)) { if (((WorldServer) this.player.world).isLoaded(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z)) {
TileEntity tileentity = ((WorldServer) this.player.world).getTileEntity(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z); TileEntity tileentity = ((WorldServer) this.player.world).getTileEntity(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z);
// CraftBukkit end
if (tileentity instanceof TileEntitySign) { if (tileentity instanceof TileEntitySign) {
TileEntitySign tileentitysign = (TileEntitySign) tileentity; TileEntitySign tileentitysign = (TileEntitySign) tileentity;
if (!tileentitysign.a()) { if (!tileentitysign.a()) {
this.minecraftServer.c("Player " + this.player.name + " just tried to change non-editable sign"); this.minecraftServer.c("Player " + this.player.name + " just tried to change non-editable sign");
this.sendPacket(new Packet130UpdateSign(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z, tileentitysign.lines));
return; return;
} }
}
int i; int i;
int j; int j;
@ -890,35 +889,26 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (tileentity instanceof TileEntitySign) { if (tileentity instanceof TileEntitySign) {
j = packet130updatesign.x; j = packet130updatesign.x;
int k = packet130updatesign.y; int k = packet130updatesign.y;
i = packet130updatesign.z; i = packet130updatesign.z;
TileEntitySign tileentitysign1 = (TileEntitySign) tileentity;
// CraftBukkit start - SIGN_CHANGE hook
Player player = server.getPlayer(this.player); Player player = server.getPlayer(this.player);
SignChangeEvent event = new SignChangeEvent((CraftBlock) player.getWorld().getBlockAt(j, k, i), server.getPlayer(this.player), packet130updatesign.lines); SignChangeEvent event = new SignChangeEvent((CraftBlock) player.getWorld().getBlockAt(j, k, i), server.getPlayer(this.player), packet130updatesign.lines);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (!event.isCancelled()) {
// Normally we would return here, but we have to update the sign with blank text if it's been cancelled
// Otherwise the client will have bad text on their sign (client shows text changes as they type)
for (int l = 0; l < 4; ++l) { for (int l = 0; l < 4; ++l) {
event.setLine(l, ""); tileentitysign.lines[l] = event.getLine(l);
} }
} tileentitysign.setEditable(false);
// CraftBukkit end
for (int l = 0; l < 4; ++l) {
tileentitysign1.lines[l] = event.getLine(l);
// CraftBukkit
} }
tileentitysign1.update(); tileentitysign.update();
// CraftBukkit
((WorldServer) this.player.world).notify(j, k, i); ((WorldServer) this.player.world).notify(j, k, i);
} }
} }
} }
// CraftBukkit end
}
public boolean c() { public boolean c() {
return true; return true;

Datei anzeigen

@ -47,4 +47,10 @@ public class TileEntitySign extends TileEntity {
public boolean a() { public boolean a() {
return this.c; return this.c;
} }
// CraftBukkit start
public void setEditable(boolean editable) {
this.c = editable;
}
// CraftBukkit end
} }