forked from ACGaming/UniversalTweaks
-
Notifications
You must be signed in to change notification settings - Fork 0
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 ACGaming#556 from jchung01/vanilla-tweaks
Add RandomPatches timeout tweaks
- Loading branch information
Showing
10 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
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
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
25 changes: 25 additions & 0 deletions
25
src/main/java/mod/acgaming/universaltweaks/tweaks/misc/timeouts/UTTimeoutManager.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package mod.acgaming.universaltweaks.tweaks.misc.timeouts; | ||
|
||
import org.apache.commons.lang3.math.NumberUtils; | ||
|
||
import mod.acgaming.universaltweaks.config.UTConfigTweaks; | ||
|
||
public class UTTimeoutManager | ||
{ | ||
public static long readTimeoutMillis; | ||
public static int loginTimeoutTicks; | ||
|
||
public static void init() | ||
{ | ||
if (!UTConfigTweaks.MISC.TIMEOUTS.utTimeoutsToggle) return; | ||
int readTimeout = NumberUtils.toInt(System.getProperty("fml.readTimeout"), UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout); | ||
// Don't overwrite read timeout that was specified by command line. | ||
if (readTimeout == UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout) | ||
{ | ||
System.setProperty("fml.readTimeout", String.valueOf(UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout)); | ||
} | ||
readTimeoutMillis = UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout * 1000L; | ||
loginTimeoutTicks = UTConfigTweaks.MISC.TIMEOUTS.utLoginTimeout * 20; | ||
// fml.loginTimeout is unused | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ava/mod/acgaming/universaltweaks/tweaks/misc/timeouts/mixin/UTClientReadTimeoutMixin.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package mod.acgaming.universaltweaks.tweaks.misc.timeouts.mixin; | ||
|
||
import mod.acgaming.universaltweaks.config.UTConfigTweaks; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
|
||
// Courtesy of jchung01, TheRandomLabs (RandomPatches) | ||
@Mixin(targets = "net.minecraft.network.NetworkManager$5") | ||
public class UTClientReadTimeoutMixin | ||
{ | ||
@SuppressWarnings("UnresolvedMixinReference") | ||
@ModifyConstant(method = "initChannel", constant = @Constant(intValue = 30)) | ||
private int utModifyReadTimeout(int original) | ||
{ | ||
return UTConfigTweaks.MISC.TIMEOUTS.utReadTimeout; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ain/java/mod/acgaming/universaltweaks/tweaks/misc/timeouts/mixin/UTLoginTimeoutMixin.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package mod.acgaming.universaltweaks.tweaks.misc.timeouts.mixin; | ||
|
||
import net.minecraft.server.network.NetHandlerLoginServer; | ||
|
||
import mod.acgaming.universaltweaks.tweaks.misc.timeouts.UTTimeoutManager; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
|
||
// Courtesy of jchung01, TheRandomLabs (RandomPatches) | ||
@Mixin(value = NetHandlerLoginServer.class) | ||
public class UTLoginTimeoutMixin | ||
{ | ||
@ModifyConstant(method = "update", constant = @Constant(intValue = 600)) | ||
private int utModifyLoginTimeout(int original) | ||
{ | ||
return UTTimeoutManager.loginTimeoutTicks; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ava/mod/acgaming/universaltweaks/tweaks/misc/timeouts/mixin/UTServerReadTimeoutMixin.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package mod.acgaming.universaltweaks.tweaks.misc.timeouts.mixin; | ||
|
||
import net.minecraft.network.NetHandlerPlayServer; | ||
import net.minecraft.util.text.ITextComponent; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import mod.acgaming.universaltweaks.tweaks.misc.timeouts.UTTimeoutManager; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Slice; | ||
|
||
// Courtesy of jchung01, TheRandomLabs (RandomPatches) | ||
@Mixin(value = NetHandlerPlayServer.class) | ||
public class UTServerReadTimeoutMixin | ||
{ | ||
// lastPingTime, not sure why this is MCP name | ||
@Shadow | ||
private long field_194402_f; | ||
|
||
@WrapOperation(method = "update", | ||
slice = @Slice(from = @At(value = "CONSTANT", args = "stringValue=keepAlive"), | ||
to = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/Profiler;endSection()V")), | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetHandlerPlayServer;disconnect(Lnet/minecraft/util/text/ITextComponent;)V")) | ||
private void utKeepAliveUntilReadTimeout(NetHandlerPlayServer instance, ITextComponent textComponent, Operation<Void> original, @Local long currentTimeMillis) | ||
{ | ||
if (currentTimeMillis - field_194402_f >= UTTimeoutManager.readTimeoutMillis) | ||
{ | ||
original.call(instance, textComponent); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"package": "mod.acgaming.universaltweaks.tweaks.misc.timeouts.mixin", | ||
"refmap": "universaltweaks.refmap.json", | ||
"minVersion": "0.8", | ||
"compatibilityLevel": "JAVA_8", | ||
"client": ["UTClientReadTimeoutMixin"] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"package": "mod.acgaming.universaltweaks.tweaks.misc.timeouts.mixin", | ||
"refmap": "universaltweaks.refmap.json", | ||
"minVersion": "0.8", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": ["UTLoginTimeoutMixin", "UTServerReadTimeoutMixin"] | ||
} |