Add Block place and break
Dieser Commit ist enthalten in:
Ursprung
3c68d7dab1
Commit
e40371338c
@ -6,7 +6,10 @@ import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.minecraft.server.v1_15_R1.Block;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
@ -48,11 +51,28 @@ class PacketProcessor {
|
||||
REntity.getEntity(entityId).remove();
|
||||
}
|
||||
|
||||
private void chatMessage() throws IOException{
|
||||
String chatMessage = source.rString();
|
||||
private void send(ChatMessageType type) throws IOException {
|
||||
String message = source.rString();
|
||||
|
||||
BaseComponent[] message = TextComponent.fromLegacyText(chatMessage);
|
||||
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(ChatMessageType.CHAT, message));
|
||||
BaseComponent[] text = TextComponent.fromLegacyText(message);
|
||||
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(type, text));
|
||||
}
|
||||
|
||||
private World world = null;
|
||||
|
||||
private void block() throws IOException {
|
||||
if (world == null) {
|
||||
world = Bukkit.getWorlds().get(0);
|
||||
}
|
||||
|
||||
int x = source.rInt();
|
||||
byte y = source.rByte();
|
||||
int z = source.rInt();
|
||||
|
||||
short blockState = source.rShort();
|
||||
|
||||
CraftBlockData craftBlockData = CraftBlockData.fromData(Block.REGISTRY_ID.fromId(blockState));
|
||||
world.getBlockAt(x, y, z).setBlockData(craftBlockData);
|
||||
}
|
||||
|
||||
private void process(){
|
||||
@ -68,8 +88,17 @@ class PacketProcessor {
|
||||
case 0x02:
|
||||
entityDespawns();
|
||||
break;
|
||||
case (byte) 0xa0:
|
||||
chatMessage();
|
||||
case 0x30:
|
||||
block();
|
||||
break;
|
||||
case (byte) 0xA0:
|
||||
send(ChatMessageType.CHAT);
|
||||
break;
|
||||
case (byte) 0xA1:
|
||||
send(ChatMessageType.ACTION_BAR);
|
||||
break;
|
||||
case (byte) 0xa2:
|
||||
send(ChatMessageType.SYSTEM);
|
||||
break;
|
||||
default:
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Unknown packet recieved, closing");
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren