-
Notifications
You must be signed in to change notification settings - Fork 68
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 #149 from yushijinhun/develop
Release v1.1.41
- Loading branch information
Showing
2 changed files
with
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2021 Haowei Wen <[email protected]> and contributors | ||
* Copyright (C) 2022 Haowei Wen <[email protected]> and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
|
@@ -53,6 +53,7 @@ | |
import moe.yushi.authlibinjector.transform.DumpClassListener; | ||
import moe.yushi.authlibinjector.transform.support.AuthServerNameInjector; | ||
import moe.yushi.authlibinjector.transform.support.AuthlibLogInterceptor; | ||
import moe.yushi.authlibinjector.transform.support.BungeeCordAllowedCharactersTransformer; | ||
import moe.yushi.authlibinjector.transform.support.CitizensTransformer; | ||
import moe.yushi.authlibinjector.transform.support.ConcatenateURLTransformUnit; | ||
import moe.yushi.authlibinjector.transform.support.ConstantURLTransformUnit; | ||
|
@@ -264,6 +265,7 @@ private static ClassTransformer createTransformer(APIMetadata config) { | |
transformer.units.add(new ConstantURLTransformUnit(urlProcessor)); | ||
transformer.units.add(new CitizensTransformer()); | ||
transformer.units.add(new ConcatenateURLTransformUnit()); | ||
transformer.units.add(new BungeeCordAllowedCharactersTransformer()); | ||
|
||
transformer.units.add(new SkinWhitelistTransformUnit()); | ||
SkinWhitelistTransformUnit.getWhitelistedDomains().addAll(config.getSkinDomains()); | ||
|
63 changes: 63 additions & 0 deletions
63
...a/moe/yushi/authlibinjector/transform/support/BungeeCordAllowedCharactersTransformer.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,63 @@ | ||
/* | ||
* Copyright (C) 2022 Haowei Wen <[email protected]> and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package moe.yushi.authlibinjector.transform.support; | ||
|
||
import static org.objectweb.asm.Opcodes.ASM9; | ||
import static org.objectweb.asm.Opcodes.ISTORE; | ||
import java.util.Optional; | ||
import org.objectweb.asm.ClassVisitor; | ||
import org.objectweb.asm.MethodVisitor; | ||
import moe.yushi.authlibinjector.transform.TransformContext; | ||
import moe.yushi.authlibinjector.transform.TransformUnit; | ||
|
||
/** | ||
* Hacks BungeeCord to allow non-ASCII characters in username. | ||
* | ||
* Since <https://github.com/SpigotMC/BungeeCord/commit/3008d7ef2f50de7e3d38e76717df72dac7fe0da3>, | ||
* BungeeCord allows only ASCII characters in username when online-mode is on. | ||
*/ | ||
public class BungeeCordAllowedCharactersTransformer implements TransformUnit { | ||
|
||
@Override | ||
public Optional<ClassVisitor> transform(ClassLoader classLoader, String className, ClassVisitor writer, TransformContext context) { | ||
if ("net.md_5.bungee.util.AllowedCharacters".equals(className)) { | ||
return Optional.of(new ClassVisitor(ASM9, writer) { | ||
@Override | ||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { | ||
if ("isValidName".equals(name) && "(Ljava/lang/String;Z)Z".equals(descriptor)) { | ||
return new MethodVisitor(ASM9, super.visitMethod(access, name, descriptor, signature, exceptions)) { | ||
@Override | ||
public void visitCode() { | ||
super.visitCode(); | ||
super.visitLdcInsn(0); | ||
super.visitVarInsn(ISTORE, 1); | ||
context.markModified(); | ||
} | ||
}; | ||
} | ||
return super.visitMethod(access, name, descriptor, signature, exceptions); | ||
} | ||
}); | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "BungeeCord Allowed Characters Transformer"; | ||
} | ||
} |