-
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.
fix Forestry mail offline uuid issues
- Loading branch information
1 parent
e878592
commit c8179b3
Showing
7 changed files
with
127 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package de.pilz.sammelsorium; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import com.gtnewhorizon.gtnhmixins.ILateMixinLoader; | ||
import com.gtnewhorizon.gtnhmixins.LateMixin; | ||
|
||
@LateMixin | ||
public class LateMixinPlugin implements ILateMixinLoader { | ||
|
||
@Override | ||
public String getMixinConfig() { | ||
return "mixins.pilzmcsammelsorium.late.json"; | ||
} | ||
|
||
@Override | ||
public List<String> getMixins(Set<String> loadedMods) { | ||
List<String> list = new ArrayList<String>(); | ||
|
||
// Forestry | ||
if (loadedMods.contains("Forestry")) { | ||
// Offline UUID Fix | ||
list.add("MixinForestryPlayerUtils"); | ||
list.add("MixinForestryPostRegistry"); | ||
} | ||
|
||
return list; | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
src/main/java/de/pilz/sammelsorium/mixins/MixinForestryPlayerUtils.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,49 @@ | ||
package de.pilz.sammelsorium.mixins; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
|
||
import de.pilz.sammelsorium.configuration.ModIntegrationConfigs; | ||
import forestry.core.utils.PlayerUtil; | ||
|
||
@Mixin(PlayerUtil.class) | ||
public abstract class MixinForestryPlayerUtils { | ||
|
||
// @Inject( | ||
// method = "getRecipient(Ljava/lang/String;Lforestry/api/mail/EnumAddressee;)Lforestry/api/mail/IMailAddress;", | ||
// at = @At("HEAD"), | ||
// cancellable = true, | ||
// remap = false) | ||
// private static void pilzmcsammelsorium$fixOfflineUUID(String recipientName, EnumAddressee type, | ||
// CallbackInfoReturnable<IMailAddress> callback) { | ||
// if (ModIntegrationConfigs.forestryMailFixOfflineUUDID && type == EnumAddressee.PLAYER) { | ||
// UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + recipientName).getBytes(Charsets.UTF_8)); | ||
// GameProfile gameProfile = new GameProfile(uuid, recipientName); | ||
// IMailAddress address = PostManager.postRegistry.getMailAddress(gameProfile); | ||
// callback.setReturnValue(address); | ||
// callback.cancel(); | ||
// } | ||
// } | ||
|
||
@Inject( | ||
method = "isSameGameProfile(Lcom/mojang/authlib/GameProfile;Lcom/mojang/authlib/GameProfile;)Z", | ||
at = @At("RETURN"), | ||
cancellable = true, | ||
remap = false) | ||
private static void pilzmcsammelsorium$fixOfflineUUID(GameProfile player1, GameProfile player2, | ||
CallbackInfoReturnable<Boolean> callback) { | ||
if (ModIntegrationConfigs.forestryMailFixOfflineUUDID && !callback.getReturnValueZ() | ||
&& player1 != null | ||
&& player2 != null) { | ||
String name1 = player1.getName(); | ||
String name2 = player2.getName(); | ||
if (name1 != null && name2 != null && !name1.equals("") && !name2.equals("") && name1.equals(name2)) { | ||
callback.setReturnValue(true); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/de/pilz/sammelsorium/mixins/MixinForestryPostRegistry.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,28 @@ | ||
package de.pilz.sammelsorium.mixins; | ||
|
||
import java.util.Locale; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import de.pilz.sammelsorium.configuration.ModIntegrationConfigs; | ||
import forestry.api.mail.EnumAddressee; | ||
import forestry.api.mail.IMailAddress; | ||
import forestry.mail.MailAddress; | ||
|
||
@Mixin(MailAddress.class) | ||
public abstract class MixinForestryPostRegistry implements IMailAddress { | ||
|
||
@Inject(method = "toString()Ljava/lang/String;", at = @At("HEAD"), cancellable = true, remap = false) | ||
public void pilzmcsammelsorium$fixOfflineUUID(CallbackInfoReturnable<String> callback) { | ||
if (ModIntegrationConfigs.forestryMailFixOfflineUUDID && isPlayer()) { | ||
MailAddress $this = (MailAddress) (Object) this; | ||
String name = $this.getName() | ||
.toLowerCase(Locale.ENGLISH); | ||
callback.setReturnValue(EnumAddressee.PLAYER.toString() + "-" + name); | ||
callback.cancel(); | ||
} | ||
} | ||
} |
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,12 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8.5-GTNH", | ||
"package": "de.pilz.sammelsorium.mixins", | ||
"refmap": "mixins.pilzmcsammelsorium.refmap.json", | ||
"target": "@env(DEFAULT)", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": [ | ||
], | ||
"client": [], | ||
"server": [] | ||
} |