Skip to content

Commit e67cb99

Browse files
committed
Workaround the bukkit teleport API to sucessfull teleport players
(Fixes #15)
1 parent d9d2c41 commit e67cb99

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
##### 1.4.1
44

55
* Fixed instant updates for BungeeCord servers
6+
* Fix chunk loading issues on instant updates
67

78
##### 1.4
89

bukkit/src/main/java/com/github/games647/changeskin/bukkit/tasks/SkinUpdater.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.logging.Level;
2222

2323
import org.bukkit.Bukkit;
24-
import org.bukkit.Chunk;
24+
import org.bukkit.Location;
2525
import org.bukkit.command.CommandSender;
2626
import org.bukkit.entity.Player;
2727

@@ -100,6 +100,18 @@ private void sendUpdateSelf(WrappedGameProfile gameProfile) throws FieldAccessEx
100100
respawn.getGameModes().write(0, gamemode);
101101
respawn.getWorldTypeModifier().write(0, receiver.getWorld().getWorldType());
102102

103+
Location location = receiver.getLocation().clone();
104+
105+
PacketContainer teleport = protocolManager.createPacket(PacketType.Play.Server.POSITION);
106+
teleport.getModifier().writeDefaults();
107+
teleport.getDoubles().write(0, location.getX());
108+
teleport.getDoubles().write(1, location.getY());
109+
teleport.getDoubles().write(2, location.getZ());
110+
teleport.getFloat().write(0, location.getYaw());
111+
teleport.getFloat().write(1, location.getPitch());
112+
//send an invalid teleport id in order to let bukkit ignore the incoming confirm packet
113+
teleport.getIntegers().writeSafely(0, -1);
114+
103115
try {
104116
//remove the old skin - client updates it only on a complete remove and add
105117
protocolManager.sendServerPacket(receiver, removeInfo);
@@ -108,12 +120,8 @@ private void sendUpdateSelf(WrappedGameProfile gameProfile) throws FieldAccessEx
108120
//notify the client that it should update the own skin
109121
protocolManager.sendServerPacket(receiver, respawn);
110122

111-
//refresh the chunk
112-
Chunk chunk = receiver.getWorld().getChunkAt(receiver.getLocation());
113-
receiver.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
114-
115123
//prevent the moved too quickly message
116-
receiver.teleport(receiver.getLocation().clone());
124+
protocolManager.sendServerPacket(receiver, teleport);
117125

118126
//send the current inventory - otherwise player would have an empty inventory
119127
receiver.updateInventory();

core/src/main/java/com/github/games647/changeskin/core/SkinStorage.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ public void createTables() throws ClassNotFoundException, SQLException {
6969
+ "`SkinURL` VARCHAR(255) NOT NULL, "
7070
+ "`CapeURL` VARCHAR(255), "
7171
+ "`Signature` BLOB NOT NULL"
72-
//SQLite doesn't support this on a create table statement
73-
//+ "INDEX(`UUID`)"
7472
+ ")";
7573

7674
String createPreferencesStmt = "CREATE TABLE IF NOT EXISTS " + PREFERENCES_TABLE + " ("

0 commit comments

Comments
 (0)