Demon Ayan

ussually i have a server in which i rtp so my items dis appear but when i go to server spawn items came back i need to fix it

Kodari AI
KodariSep 13 at 4:27 pm 1
RTPItemKeeper
RTPItemKeeper is a Minecraft plugin that preserves player inventory items during random teleportation (RTP) events. When players use RTP commands, their items are temporarily stored in a safe cache and restored after the teleport completes. The plugin intercepts RTP teleportation, saves the player's inventory, armor, and off-hand contents, then restores them seamlessly after arrival. It includes configurable options for which item types to preserve, automatic restoration on death prevention, and compatibility with popular RTP plugins. The plugin ensures no items disappear when teleporting between server spawn and random locations, providing a smooth and item-safe RTP experience for players.

I’ll create a lightweight Bukkit plugin that forces a server-side inventory resync after RTP/teleports, world changes, joins, and respawns, with a manual /invfix fallback.

Created InventorySyncFix, a Bukkit/Spigot plugin that:

  • Resynchronizes inventories after RTP and teleport events.

  • Resyncs again after world changes, joins, and respawns.

  • Retries synchronization at 1, 5, and 20 ticks to handle RTP plugins that update later.

  • Adds /invfix for manual inventory recovery.

Install the built JAR in plugins/, restart the server, and use /invfix if items visually disappear after RTP.

Demon Ayan

are u sure it gonna work

Kodari AI
KodariSep 13 at 4:27 pm 1

No—not for the actual problem you described.

The current plugin only calls player.updateInventory(). That fixes a visual client desync, but it cannot restore items that the server or RTP plugin has actually removed.

Use this test:

  1. RTP while holding an item.

  2. Run /invfix.

  3. Relog.

  4. Check whether the item returns.

  • If it returns after /invfix or relog, it was probably a client synchronization issue.

  • If it remains gone, the RTP/spawn plugin is changing or clearing the inventory, and InventorySyncFix will not solve it.

To fix the real issue, I need the name of the plugin/command you use for RTP and the plugin handling your server spawn. Also tell me whether the items disappear only visually or are still missing after relogging.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 115
src/main/java/com/kodari/inventorysync/InventorySyncPlugin.java
package com.kodari.inventorysync;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class InventorySyncPlugin extends JavaPlugin implements Listener, CommandExecutor {

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);

        if (getCommand("invfix") != null) {
            getCommand("invfix").setExecutor(this);
        }
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onTeleport(PlayerTeleportEvent event) {
        scheduleResync(event.getPlayer());
    }

    @EventHandler(priority = EventPriority.MONITOR)
    public void onWorldChange(PlayerChangedWorldEvent event) {
        scheduleResync(event.getPlayer());
    }

    @EventHandler(priority = EventPriority.MONITOR)
    public void onJoin(PlayerJoinEvent event) {
        scheduleResync(event.getPlayer());
    }

    @EventHandler(priority = EventPriority.MONITOR)
    public void onRespawn(PlayerRespawnEvent event) {
        scheduleResync(event.getPlayer());
    }

    private void scheduleResync(final Player player) {
        resync(player);

        Bukkit.getScheduler().runTaskLater(this, () -> resync(player), 1L);
        Bukkit.getScheduler().runTaskLater(this, () -> resync(player), 5L);
        Bukkit.getScheduler().runTaskLater(this, () -> resync(player), 20L);
    }

    private void resync(Player player) {
        if (player.isOnline()) {
            player.updateInventory();
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can use this command.");
            return true;
        }

        Player player = (Player) sender;
        scheduleResync(player);
        player.sendMessage("§aYour inventory has been resynchronized.");
        return true;
    }
}