diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/disconnectdupe/UTDisconnectDupe.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/disconnectdupe/UTDisconnectDupe.java index e0a06b08..42067fc3 100644 --- a/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/disconnectdupe/UTDisconnectDupe.java +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/disconnectdupe/UTDisconnectDupe.java @@ -1,35 +1,27 @@ package mod.acgaming.universaltweaks.bugfixes.entities.disconnectdupe; -import java.util.concurrent.FutureTask; - +import mod.acgaming.universaltweaks.UniversalTweaks; +import mod.acgaming.universaltweaks.config.UTConfigBugfixes; +import mod.acgaming.universaltweaks.config.UTConfigGeneral; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.server.MinecraftServer; +import net.minecraftforge.event.entity.item.ItemTossEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.PlayerEvent; import net.minecraftforge.fml.relauncher.Side; -import mod.acgaming.universaltweaks.UniversalTweaks; -import mod.acgaming.universaltweaks.bugfixes.entities.disconnectdupe.mixin.PlayerListInvoker; -import mod.acgaming.universaltweaks.config.UTConfigBugfixes; -import mod.acgaming.universaltweaks.config.UTConfigGeneral; - -// Courtesy of Meldexun -@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID, value = Side.CLIENT) +// Courtesy of jchung01 +@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID, value = Side.SERVER) public class UTDisconnectDupe { @SubscribeEvent - public static void utDisconnectDupe(PlayerEvent.PlayerLoggedOutEvent event) + public static void utDisconnectDupe(ItemTossEvent event) { - if (!UTConfigBugfixes.ENTITIES.utDisconnectDupeToggle || event.player.world.isRemote) return; - if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTDisconnectDupe ::: Player logged out event"); - MinecraftServer server = event.player.getServer(); - if (server != null) + if (!UTConfigBugfixes.ENTITIES.utDisconnectDupeToggle || event.getPlayer().world.isRemote) return; + EntityPlayerMP player = (EntityPlayerMP) event.getPlayer(); + if (!player.connection.getNetworkManager().channel().isOpen()) { - server.futureTaskQueue.add(new FutureTask<>(() -> { - ((PlayerListInvoker) server.getPlayerList()).invokeWritePlayerData((EntityPlayerMP) event.player); - return null; - })); + if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTDisconnectDupe ::: Player dropped item but is disconnected! Ignoring drop."); + event.setCanceled(true); } } } \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/disconnectdupe/mixin/PlayerListInvoker.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/disconnectdupe/mixin/PlayerListInvoker.java deleted file mode 100644 index 1cc94dda..00000000 --- a/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/disconnectdupe/mixin/PlayerListInvoker.java +++ /dev/null @@ -1,14 +0,0 @@ -package mod.acgaming.universaltweaks.bugfixes.entities.disconnectdupe.mixin; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.server.management.PlayerList; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(PlayerList.class) -public interface PlayerListInvoker -{ - @Invoker("writePlayerData") - void invokeWritePlayerData(EntityPlayerMP playerIn); -} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java index 7295005c..0b257061 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java @@ -181,7 +181,7 @@ public static class EntitiesCategory public boolean utDestroyPacketToggle = true; @Config.Name("Disconnect Dupe") - @Config.Comment("Fixes item duplications when players are dropping items and disconnecting (singleplayer only)") + @Config.Comment("Fixes item duplications when players are dropping items and disconnecting") public boolean utDisconnectDupeToggle = true; @Config.RequiresMcRestart diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index 5f9a40ae..4c49088c 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -54,7 +54,6 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader put("mixins.bugfixes.entities.destroypacket.json", () -> UTConfigBugfixes.ENTITIES.utDestroyPacketToggle); put("mixins.bugfixes.entities.desync.json", () -> UTConfigBugfixes.ENTITIES.ENTITY_DESYNC.utEntityDesyncToggle); put("mixins.bugfixes.entities.dimensionchange.json", () -> UTConfigBugfixes.ENTITIES.utDimensionChangeToggle); - put("mixins.bugfixes.entities.disconnectdupe.json", () -> UTConfigBugfixes.ENTITIES.utDisconnectDupeToggle); put("mixins.bugfixes.entities.entityid.json", () -> UTConfigBugfixes.ENTITIES.utEntityIDToggle); put("mixins.bugfixes.entities.entitylists.json", () -> UTConfigBugfixes.ENTITIES.utEntityListsToggle); put("mixins.bugfixes.entities.horsefalling.json", () -> UTConfigBugfixes.ENTITIES.utHorseFallingToggle); diff --git a/src/main/resources/mixins.bugfixes.entities.disconnectdupe.json b/src/main/resources/mixins.bugfixes.entities.disconnectdupe.json deleted file mode 100644 index 7a99332d..00000000 --- a/src/main/resources/mixins.bugfixes.entities.disconnectdupe.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "package": "mod.acgaming.universaltweaks.bugfixes.entities.disconnectdupe.mixin", - "refmap": "universaltweaks.refmap.json", - "minVersion": "0.8", - "compatibilityLevel": "JAVA_8", - "mixins": ["PlayerListInvoker"] -} \ No newline at end of file