Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for patbox Styled Chat #447

Open
wants to merge 3 commits into
base: ver/1.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Cardboard is an implementation of the popular Bukkit/Spigot/Paper Modding API fo
Fabric version chart:
| Supported| Minecraft | Git Branch | Download |
|----------|----------------|------------|----------------------|
| ✅ | Fabric 1.20.1 | ver/1.20 | Work-in-Progress
| ✅ | Fabric 1.20.2 | ver/1.20 | Work-in-Progress
| ✅ | Fabric 1.19.4 | ver/1.19.4 | [View Downloads](https://cardboardpowered.org/download/) |
| ✅ | Fabric 1.19.2 | ver/1.19.2 | [View Downloads](https://cardboardpowered.org/download/) |
| ✅ | Fabric 1.18.2 | ver/1.18.2 | [View Downloads](https://cardboardpowered.org/download/) |
Expand Down
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency
import com.modrinth.minotaur.TaskModrinthUpload
import com.modrinth.minotaur.request.VersionType

plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
Expand Down Expand Up @@ -101,7 +99,7 @@ dependencies {
// NMS Remapping
// srglib-0.1.2.jar
extraLibs fileTree(dir: 'libs', include: "srglib-0.1.2.jar")
include(modImplementation("com.github.IsaiahPatton:SpecialSource:master-SNAPSHOT"))
include(modImplementation("net.md-5:SpecialSource:1.11.2"))

compileOnly fileTree(dir: 'libs', include: "srglib-0.1.2.jar")

Expand Down Expand Up @@ -198,4 +196,4 @@ modrinth {
uploadFile = remapJar // With Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions = ["1.19.4"] // Must be an array, even with only one version
loaders = ["fabric"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
}
}
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ org.gradle.jvmargs=-Xmx1G
#fabric_version=0.81.1+1.19.4

# 1.20
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21
fabric_version=0.83.0+1.20
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22
fabric_version=0.90.7+1.20.2

# Mod Properties
mod_version = 1.20
mod_version = 1.20.2
maven_group = org.cardboardpowered
archives_base_name = Cardboard

# Paper API
#paper_jar = paper-api-1.17-test.jar
#paper_jar = paper-api-1.17.1-388.jar
paper_jar = paper-api-1.18.2-167.jar
paper_jar = paper-api-1.18.2-167.jar
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.UserCache;
import net.minecraft.util.Util;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.Validate;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.profile.PlayerTextures;
Expand Down Expand Up @@ -140,7 +139,7 @@ public CraftPlayerProfile clone() {

@Override
public boolean isComplete() {
return profile.isComplete();
return this.getUniqueId() != null && this.getName() != null && !getTextures().isEmpty();
}

@Override
Expand Down Expand Up @@ -174,7 +173,7 @@ public boolean completeFromCache(boolean lookupUUID, boolean onlineMode) {

if ((profile.getName() == null || !hasTextures()) && profile.getId() != null) {
Optional<GameProfile> o = userCache.card_getByUuid(this.profile.getId());
if (!o.isEmpty()) {
if (o.isPresent()) {
GameProfile profile = o.get();
if (profile != null) {
// if old has it, assume its newer, so overwrite, else use cached if it was set and ours wasn't
Expand All @@ -183,7 +182,8 @@ public boolean completeFromCache(boolean lookupUUID, boolean onlineMode) {
}
}
}
return this.profile.isComplete();

return isProfileComplete();
}

public boolean complete(boolean textures) {
Expand All @@ -195,15 +195,19 @@ public boolean complete(boolean textures, boolean onlineMode) {

boolean isCompleteFromCache = this.completeFromCache(true, onlineMode);
if (onlineMode && (!isCompleteFromCache || textures && !hasTextures())) {
GameProfile result = server.getSessionService().fillProfileProperties(profile, true);
GameProfile result = null; // TODO
if (result != null)
copyProfileProperties(result, this.profile, true);
if (this.profile.isComplete()) {
if (isProfileComplete()) {
CraftServer.server.getUserCache().add(this.profile);
CraftServer.server.getUserCache().save();
}
}
return profile.isComplete() && (!onlineMode || !textures || hasTextures());
return isProfileComplete() && (!onlineMode || !textures || hasTextures());
}

private boolean isProfileComplete() {
return profile.getId() != null && StringUtils.isNotBlank(profile.getName());
}

private static void copyProfileProperties(GameProfile source, GameProfile target) {
Expand All @@ -217,13 +221,13 @@ private static void copyProfileProperties(GameProfile source, GameProfile target
if (sourceProperties.isEmpty()) return;

for (Property property : sourceProperties.values()) {
targetProperties.removeAll(property.getName());
targetProperties.put(property.getName(), property);
targetProperties.removeAll(property.name());
targetProperties.put(property.name(), property);
}
}

private static ProfileProperty toBukkit(Property property) {
return new ProfileProperty(property.getName(), property.getValue(), property.getSignature());
return new ProfileProperty(property.name(), property.value(), property.signature());
}

public static PlayerProfile asBukkitCopy(GameProfile gameProfile) {
Expand Down Expand Up @@ -350,4 +354,4 @@ public void setTextures(@Nullable PlayerTextures arg0) {

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@
*/
package com.javazilla.bukkitfabric.interfaces;

import java.util.Map;

import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeType;
import net.minecraft.util.Identifier;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;

public interface IMixinRecipeManager {

void addRecipe(Recipe<?> irecipe);
import java.util.Map;

Map<RecipeType<?>, Map<Identifier, Recipe<?>>> getRecipes();
public interface IMixinRecipeManager {

default void addRecipe(NamespacedKey key, Recipe<?> recipe) {
addRecipe(new RecipeEntry<>(
CraftNamespacedKey.toMinecraft(key),
recipe
));
}
void addRecipe(RecipeEntry<?> recipeEntry);
Map<RecipeType<?>, Map<Identifier, RecipeEntry<?>>> getRecipes();
void clearRecipes();

}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.javazilla.bukkitfabric.interfaces;

import net.minecraft.network.packet.c2s.play.ResourcePackStatusC2SPacket;
import net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket.Status;

public interface IMixinResourcePackStatusC2SPacket {

public ResourcePackStatusC2SPacket.Status getStatus_Bukkit();
public Status getStatus_Bukkit();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,29 @@
*/
package com.javazilla.bukkitfabric.nms;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.regex.Pattern;

import com.javazilla.bukkitfabric.BukkitFabricMod;
import net.minecraft.SharedConstants;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerNetworkIo;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.SimplePluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;

import com.javazilla.bukkitfabric.BukkitFabricMod;

import net.minecraft.SharedConstants;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerNetworkIo;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.regex.Pattern;

/**
* Very unsafe re-mapping of Reflection.
*/
public class ReflectionRemapper {

private static final String NMS_VERSION = "v1_20_R1";// "v1_19_R3";
private static final String NMS_VERSION = "v1_20_R2";
public static JavaPlugin plugin;

public static String mapClassName(String className) {
Expand Down Expand Up @@ -345,4 +343,4 @@ public static Method getMethodByName(Class<?> calling, String f, Class<?>[] p) t
return m;
}

}
}
29 changes: 16 additions & 13 deletions src/main/java/com/mohistmc/banner/bukkit/nms/utils/RemapUtils.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
package com.mohistmc.banner.bukkit.nms.utils;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.mohistmc.banner.bukkit.nms.model.ClassMapping;
import com.mohistmc.banner.bukkit.nms.remappers.*;

import com.mohistmc.banner.bukkit.nms.remappers.BannerInheritanceProvider;
import com.mohistmc.banner.bukkit.nms.remappers.BannerJarMapping;
import com.mohistmc.banner.bukkit.nms.remappers.BannerJarRemapper;
import com.mohistmc.banner.bukkit.nms.remappers.BannerSuperClassRemapper;
import com.mohistmc.banner.bukkit.nms.remappers.ClassRemapperSupplier;
import com.mohistmc.banner.bukkit.nms.remappers.ReflectMethodRemapper;
import com.mohistmc.banner.bukkit.nms.remappers.ReflectRemapper;
import net.md_5.specialsource.InheritanceMap;
import net.md_5.specialsource.provider.JointProvider;
import net.md_5.specialsource.transformer.MavenShade;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.ClassRemapper;
import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.tree.ClassNode;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
*
* @author pyz
Expand All @@ -36,7 +39,7 @@ public static void init() {
System.out.println("REMAP UTIL DEBUG");
jarMapping = new BannerJarMapping();
// v1_20_R1
jarMapping.packages.put("org/bukkit/craftbukkit/v1_20_R1/", "org/bukkit/craftbukkit/");
jarMapping.packages.put("org/bukkit/craftbukkit/v1_20_R2/", "org/bukkit/craftbukkit/");
//jarMapping.packages.put("org/bukkit/craftbukkit/v1_19_R3/", "org/bukkit/craftbukkit/");
jarMapping.packages.put("org/bukkit/craftbukkit/libs/it/unimi/dsi/fastutil/", "it/unimi/dsi/fastutil/");
jarMapping.packages.put("org/bukkit/craftbukkit/libs/jline/", "jline/");
Expand All @@ -47,7 +50,7 @@ public static void init() {

try {
jarMapping.loadMappings(
new BufferedReader(new InputStreamReader(RemapUtils.class.getClassLoader().getResourceAsStream("mappings/spigot2srg-1.20.srg"))),
new BufferedReader(new InputStreamReader(RemapUtils.class.getClassLoader().getResourceAsStream("mappings/spigot2srg-1.20.2.srg"))),
null,
null, false);
} catch (Exception e) {
Expand Down
Loading