-
Notifications
You must be signed in to change notification settings - Fork 70
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 #167 from yushijinhun/develop
Release v1.1.46
- Loading branch information
Showing
7 changed files
with
89 additions
and
7 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
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
62 changes: 62 additions & 0 deletions
62
src/main/java/moe/yushi/authlibinjector/transform/support/PaperUsernameCheckTransformer.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,62 @@ | ||
/* | ||
* 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.*; | ||
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; | ||
|
||
/** | ||
* Disables PaperMC's username check. | ||
* See <https://github.com/PaperMC/Paper/blob/master/patches/server/0823-Validate-usernames.patch>. | ||
*/ | ||
public class PaperUsernameCheckTransformer implements TransformUnit { | ||
|
||
@Override | ||
public Optional<ClassVisitor> transform(ClassLoader classLoader, String className, ClassVisitor writer, TransformContext context) { | ||
if (!context.getStringConstants().contains("Invalid characters in username")) { | ||
return Optional.empty(); | ||
} | ||
|
||
return Optional.of(new ClassVisitor(ASM9, writer) { | ||
@Override | ||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { | ||
return new MethodVisitor(ASM9, super.visitMethod(access, name, descriptor, signature, exceptions)) { | ||
|
||
@Override | ||
public void visitFieldInsn(int opcode, String owner, String name, String descriptor) { | ||
if (opcode == GETFIELD && "iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation".equals(name)) { | ||
context.markModified(); | ||
visitInsn(POP); | ||
visitInsn(ICONST_1); | ||
} else { | ||
super.visitFieldInsn(opcode, owner, name, descriptor); | ||
} | ||
} | ||
}; | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Paper Username Check Transformer"; | ||
} | ||
} |
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