-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #459 from jchung01/vanilla-tweaks
Change disconnect dupe fix event
- Loading branch information
Showing
5 changed files
with
13 additions
and
43 deletions.
There are no files selected for viewing
32 changes: 12 additions & 20 deletions
32
.../java/mod/acgaming/universaltweaks/bugfixes/entities/disconnectdupe/UTDisconnectDupe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
...od/acgaming/universaltweaks/bugfixes/entities/disconnectdupe/mixin/PlayerListInvoker.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
src/main/resources/mixins.bugfixes.entities.disconnectdupe.json
This file was deleted.
Oops, something went wrong.