Hotfixes + chat
Dieser Commit ist enthalten in:
Ursprung
c523e8ca99
Commit
3c68d7dab1
@ -3,6 +3,9 @@ package de.steamwar.spectatesystem;
|
|||||||
import de.steamwar.spectatesystem.elements.REntity;
|
import de.steamwar.spectatesystem.elements.REntity;
|
||||||
import de.steamwar.spectatesystem.elements.RPlayer;
|
import de.steamwar.spectatesystem.elements.RPlayer;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
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 org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -24,6 +27,7 @@ class PacketProcessor {
|
|||||||
if(user == null)
|
if(user == null)
|
||||||
throw new IOException("Unknown user " + userId);
|
throw new IOException("Unknown user " + userId);
|
||||||
|
|
||||||
|
System.out.println("Player " + user.getUserName() + " spawned!");
|
||||||
new RPlayer(user.getUUID(), user.getUserName(), entityId);
|
new RPlayer(user.getUUID(), user.getUserName(), entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +48,13 @@ class PacketProcessor {
|
|||||||
REntity.getEntity(entityId).remove();
|
REntity.getEntity(entityId).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void chatMessage() throws IOException{
|
||||||
|
String chatMessage = source.rString();
|
||||||
|
|
||||||
|
BaseComponent[] message = TextComponent.fromLegacyText(chatMessage);
|
||||||
|
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(ChatMessageType.CHAT, message));
|
||||||
|
}
|
||||||
|
|
||||||
private void process(){
|
private void process(){
|
||||||
try{
|
try{
|
||||||
while(!source.isClosed()){
|
while(!source.isClosed()){
|
||||||
@ -57,6 +68,9 @@ class PacketProcessor {
|
|||||||
case 0x02:
|
case 0x02:
|
||||||
entityDespawns();
|
entityDespawns();
|
||||||
break;
|
break;
|
||||||
|
case (byte) 0xa0:
|
||||||
|
chatMessage();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Unknown packet recieved, closing");
|
Bukkit.getLogger().log(Level.SEVERE, "Unknown packet recieved, closing");
|
||||||
source.close();
|
source.close();
|
||||||
|
@ -30,7 +30,6 @@ public class RPlayer extends REntity {
|
|||||||
protected void spawnEntity(PlayerConnection connection) {
|
protected void spawnEntity(PlayerConnection connection) {
|
||||||
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, (EntityPlayer) entity)); // "Adds the player data for the client to use when spawning a player" - https://wiki.vg/Protocol#Spawn_Player
|
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, (EntityPlayer) entity)); // "Adds the player data for the client to use when spawning a player" - https://wiki.vg/Protocol#Spawn_Player
|
||||||
connection.sendPacket(new PacketPlayOutNamedEntitySpawn((EntityPlayer) entity)); // Spawns the NPC for the player client.
|
connection.sendPacket(new PacketPlayOutNamedEntitySpawn((EntityPlayer) entity)); // Spawns the NPC for the player client.
|
||||||
connection.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EntityPlayer createPlayer(UUID uuid, String name){
|
private static EntityPlayer createPlayer(UUID uuid, String name){
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.steamwar.spectatesystem.listener;
|
package de.steamwar.spectatesystem.listener;
|
||||||
|
|
||||||
import de.steamwar.spectatesystem.elements.REntity;
|
import de.steamwar.spectatesystem.elements.REntity;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
@ -11,5 +12,6 @@ public class JoinListener extends BasicListener {
|
|||||||
public void onJoin(PlayerJoinEvent e){
|
public void onJoin(PlayerJoinEvent e){
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
REntity.playerJoins(player);
|
REntity.playerJoins(player);
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren