SteamWar/SpigotCore
Archiviert
13
0

Fix BedrockEdition inability for Non-Full-Chunk packets

Dieser Commit ist enthalten in:
Lixfel 2020-07-25 12:58:11 +02:00
Ursprung 021a189823
Commit 743e40c9ce
11 geänderte Dateien mit 164 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,14 @@
package de.steamwar.chunk;
import net.minecraft.server.v1_10_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class Chunk_10 {
private Chunk_10(){}
public static void sendChunk(Player p, int chunkX, int chunkZ){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
}
}

Datei anzeigen

@ -0,0 +1,14 @@
package de.steamwar.chunk;
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class Chunk_12 {
private Chunk_12(){}
public static void sendChunk(Player p, int chunkX, int chunkZ){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
}
}

Datei anzeigen

@ -0,0 +1,14 @@
package de.steamwar.chunk;
import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_14_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class Chunk_14 {
private Chunk_14(){}
public static void sendChunk(Player p, int chunkX, int chunkZ){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
}
}

Datei anzeigen

@ -0,0 +1,14 @@
package de.steamwar.chunk;
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class Chunk_15 {
private Chunk_15(){}
public static void sendChunk(Player p, int chunkX, int chunkZ){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
}
}

Datei anzeigen

@ -0,0 +1,14 @@
package de.steamwar.chunk;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class Chunk_8 {
private Chunk_8(){}
public static void sendChunk(Player p, int chunkX, int chunkZ){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), true, 65535));
}
}

Datei anzeigen

@ -0,0 +1,14 @@
package de.steamwar.chunk;
import net.minecraft.server.v1_9_R2.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_9_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class Chunk_9 {
private Chunk_9(){}
public static void sendChunk(Player p, int chunkX, int chunkZ){
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
}
}

Datei anzeigen

@ -56,6 +56,12 @@
<version>1.0</version> <version>1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>ProtocolLib</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>SpigotCore_API</artifactId> <artifactId>SpigotCore_API</artifactId>

Datei anzeigen

@ -1,6 +1,7 @@
package de.steamwar.core; package de.steamwar.core;
import de.steamwar.core.events.ChattingEvent; import de.steamwar.core.events.ChattingEvent;
import de.steamwar.core.events.ChunkListener;
import de.steamwar.core.events.PlayerJoinedEvent; import de.steamwar.core.events.PlayerJoinedEvent;
import de.steamwar.core.events.WorldLoadEvent; import de.steamwar.core.events.WorldLoadEvent;
import de.steamwar.sql.SQL; import de.steamwar.sql.SQL;
@ -38,6 +39,7 @@ public class Core extends JavaPlugin{
Bukkit.getPluginManager().registerEvents(new PlayerJoinedEvent(), this); Bukkit.getPluginManager().registerEvents(new PlayerJoinedEvent(), this);
Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this); Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this);
Bukkit.getPluginManager().registerEvents(new WorldLoadEvent(), this); Bukkit.getPluginManager().registerEvents(new WorldLoadEvent(), this);
ChunkListener.init();
if(version >= 12) if(version >= 12)
ErrorLogger.init(); ErrorLogger.init();
} }

Datei anzeigen

@ -0,0 +1,64 @@
package de.steamwar.core.events;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import de.steamwar.chunk.*;
import de.steamwar.core.Core;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.entity.Player;
public class ChunkListener {
private ChunkListener(){}
public static void init(){
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Core.getInstance(), PacketType.Play.Server.MAP_CHUNK) {
@Override
public void onPacketSending(PacketEvent e) {
Player p = e.getPlayer();
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
if(!user.isBedrock())
return;
PacketContainer packet = e.getPacket();
StructureModifier<Boolean> fullChunk = packet.getBooleans();
if(fullChunk.read(0))
return;
e.setCancelled(true);
StructureModifier<Integer> ints = packet.getIntegers();
int chunkX = ints.read(0);
int chunkZ = ints.read(1);
sendChunk(p, chunkX, chunkZ);
}
});
}
public static void sendChunk(Player p, int chunkX, int chunkZ){
switch(Core.getVersion()){
case 15:
Chunk_15.sendChunk(p, chunkX, chunkZ);
break;
case 14:
Chunk_14.sendChunk(p, chunkX, chunkZ);
break;
case 12:
Chunk_12.sendChunk(p, chunkX, chunkZ);
break;
case 10:
Chunk_10.sendChunk(p, chunkX, chunkZ);
break;
case 9:
Chunk_9.sendChunk(p, chunkX, chunkZ);
break;
case 8:
Chunk_8.sendChunk(p, chunkX, chunkZ);
break;
}
}
}

Datei anzeigen

@ -26,6 +26,7 @@ public class SteamwarUser {
private final String userName; private final String userName;
private final UserGroup userGroup; private final UserGroup userGroup;
private final int team; private final int team;
private final boolean bedrock;
private SteamwarUser(ResultSet rs){ private SteamwarUser(ResultSet rs){
try { try {
@ -34,6 +35,7 @@ public class SteamwarUser {
userName = rs.getString("UserName"); userName = rs.getString("UserName");
userGroup = UserGroup.valueOf(rs.getString("UserGroup")); userGroup = UserGroup.valueOf(rs.getString("UserGroup"));
team = rs.getInt("Team"); team = rs.getInt("Team");
bedrock = rs.getBoolean("Bedrock");
byUUID.put(uuid, this); byUUID.put(uuid, this);
byName.put(userName.toLowerCase(), this); byName.put(userName.toLowerCase(), this);
@ -63,6 +65,10 @@ public class SteamwarUser {
return team; return team;
} }
public boolean isBedrock(){
return bedrock;
}
private static SteamwarUser fromDB(String statement, Object identifier){ private static SteamwarUser fromDB(String statement, Object identifier){
ResultSet rs = SQL.select(statement, identifier); ResultSet rs = SQL.select(statement, identifier);
try { try {

Datei anzeigen

@ -5,6 +5,8 @@ api-version: "1.13"
load: STARTUP load: STARTUP
softdepend: softdepend:
- WorldEdit - WorldEdit
depend:
- ProtocolLib
main: de.steamwar.core.Core main: de.steamwar.core.Core
commands: commands: