Skip to content

Commit

Permalink
Workaround the bukkit teleport API to sucessfull teleport players
Browse files Browse the repository at this point in the history
(Fixes #15)
  • Loading branch information
games647 committed Jun 10, 2016
1 parent d9d2c41 commit e67cb99
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
##### 1.4.1

* Fixed instant updates for BungeeCord servers
* Fix chunk loading issues on instant updates

##### 1.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.logging.Level;

import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

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

Location location = receiver.getLocation().clone();

PacketContainer teleport = protocolManager.createPacket(PacketType.Play.Server.POSITION);
teleport.getModifier().writeDefaults();
teleport.getDoubles().write(0, location.getX());
teleport.getDoubles().write(1, location.getY());
teleport.getDoubles().write(2, location.getZ());
teleport.getFloat().write(0, location.getYaw());
teleport.getFloat().write(1, location.getPitch());
//send an invalid teleport id in order to let bukkit ignore the incoming confirm packet
teleport.getIntegers().writeSafely(0, -1);

try {
//remove the old skin - client updates it only on a complete remove and add
protocolManager.sendServerPacket(receiver, removeInfo);
Expand All @@ -108,12 +120,8 @@ private void sendUpdateSelf(WrappedGameProfile gameProfile) throws FieldAccessEx
//notify the client that it should update the own skin
protocolManager.sendServerPacket(receiver, respawn);

//refresh the chunk
Chunk chunk = receiver.getWorld().getChunkAt(receiver.getLocation());
receiver.getWorld().refreshChunk(chunk.getX(), chunk.getZ());

//prevent the moved too quickly message
receiver.teleport(receiver.getLocation().clone());
protocolManager.sendServerPacket(receiver, teleport);

//send the current inventory - otherwise player would have an empty inventory
receiver.updateInventory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public void createTables() throws ClassNotFoundException, SQLException {
+ "`SkinURL` VARCHAR(255) NOT NULL, "
+ "`CapeURL` VARCHAR(255), "
+ "`Signature` BLOB NOT NULL"
//SQLite doesn't support this on a create table statement
//+ "INDEX(`UUID`)"
+ ")";

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

0 comments on commit e67cb99

Please sign in to comment.