Skip to content

Commit

Permalink
Port to 1.20.6
Browse files Browse the repository at this point in the history
Signed-off-by: ErdbeerbaerLP <[email protected]>
  • Loading branch information
ErdbeerbaerLP committed May 8, 2024
1 parent 9d81a89 commit b700518
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 117 deletions.
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ buildscript {

//Gradle Plugins
plugins {
id 'net.neoforged.gradle.userdev' version '7.0.80'
id "com.matthewprenger.cursegradle" version "1.4.0"
id 'java'
id 'idea'
id "com.modrinth.minotaur" version "2.+"
id 'com.github.johnrengelman.shadow' version '8.0.0+'
id 'com.github.johnrengelman.shadow' version '8.1.1+'
id 'net.neoforged.gradle.userdev' version '7.0.109'

}
apply plugin: 'eclipse'
Expand All @@ -26,7 +26,7 @@ version = "3.0.7"
group = "de.erdbeerbaerlp.dcintegration"
archivesBaseName = "dcintegration-neoforge"

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

//Gradle Repositories
repositories {
Expand All @@ -35,7 +35,6 @@ repositories {
name = 'sponge'
url = 'https://repo.spongepowered.org/maven'
}
maven { url "https://nexus.vankka.dev/repository/maven-public/" }
maven { url "https://repository.dev.gotan.io/repository/gotan.os/" }
maven { url "https://repo.opencollab.dev/maven-snapshots" }
maven { url "https://repo.opencollab.dev/maven-releases" }
Expand All @@ -54,6 +53,8 @@ configurations {
embed
compileOnly.extendsFrom(embed)
}

sourceSets.main.resources { srcDir 'src/generated/resources' }
task release {

}
Expand Down Expand Up @@ -81,7 +82,7 @@ dependencies {
}

// ========= NeoForge =============
implementation "net.neoforged:neoforge:20.4.80-beta"
implementation "net.neoforged:neoforge:20.6.48-beta"

//Dynmap-API
compileOnly('com.github.webbukkit:DynmapCoreAPI:2.5')
Expand Down
8 changes: 6 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
changelog=Fixed more bugs\nAdded a /discord rawmsg command\nAdded whitelist option for commandlog
changelog=Port to 1.20.6
releaseType = RELEASE
mcVersion = 1.20.4
mcVersion = 1.20.6


neogradle.subsystems.parchment.minecraftVersion=1.20.6
neogradle.subsystems.parchment.mappingsVersion=2024.05.01
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
test=0
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ pluginManagement {
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.erdbeerbaerlp.dcintegration.forge;

import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dcshadow.dev.vankka.mcdiscordreserializer.discord.DiscordSerializer;
import dcshadow.net.kyori.adventure.text.Component;
Expand Down Expand Up @@ -32,16 +31,13 @@
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
import net.minecraft.ChatFormatting;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.ComponentArgument;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModList;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
import net.neoforged.fml.loading.FMLEnvironment;
Expand Down Expand Up @@ -84,7 +80,6 @@ public class DiscordIntegrationMod {
public DiscordIntegrationMod(IEventBus modEventBus) {
LOGGER.info("Version is " + VERSION);
bstats = new Metrics(9765);
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true));
try {
//Create data directory if missing
if (!discordDataDir.exists()) discordDataDir.mkdir();
Expand Down Expand Up @@ -373,13 +368,7 @@ public void command(CommandEvent ev) {
} catch (CommandSyntaxException e) {
final String txt = GsonComponentSerializer.gson().serialize(mcSubCommand.execute(cmdArgs, null));

source.sendSuccess(() -> {
try {
return ComponentArgument.textComponent().parse(new StringReader(txt));
} catch (CommandSyntaxException ignored) {
return null;
}
}, false);
source.sendSuccess(() -> net.minecraft.network.chat.Component.Serializer.fromJson(txt, source.registryAccess()), false);

}
break;
Expand All @@ -390,32 +379,14 @@ public void command(CommandEvent ev) {
final String txt = GsonComponentSerializer.gson().serialize(mcSubCommand.execute(cmdArgs, player.getUUID()));


source.sendSuccess(() -> {
try {
return ComponentArgument.textComponent().parse(new StringReader(txt));
} catch (CommandSyntaxException ignored) {
return null;
}
}, false);
source.sendSuccess(() -> net.minecraft.network.chat.Component.Serializer.fromJson(txt, source.registryAccess()), false);
} else if (source.hasPermission(4)) {
final String txt = GsonComponentSerializer.gson().serialize(mcSubCommand.execute(cmdArgs, player.getUUID()));

source.sendSuccess(() -> {
try {
return ComponentArgument.textComponent().parse(new StringReader(txt));
} catch (CommandSyntaxException ignored) {
return null;
}
}, false);
source.sendSuccess(() -> net.minecraft.network.chat.Component.Serializer.fromJson(txt, source.registryAccess()), false);
} else if (DiscordIntegration.INSTANCE.getServerInterface().playerHasPermissions(player.getUUID(), MinecraftPermission.RUN_DISCORD_COMMAND_ADMIN, MinecraftPermission.ADMIN)) {
final String txt = GsonComponentSerializer.gson().serialize(mcSubCommand.execute(cmdArgs, player.getUUID()));
source.sendSuccess(() -> {
try {
return ComponentArgument.textComponent().parse(new StringReader(txt));
} catch (CommandSyntaxException ignored) {
return null;
}
}, false);
source.sendSuccess(() -> net.minecraft.network.chat.Component.Serializer.fromJson(txt, source.registryAccess()), false);
} else {
source.sendFailure(net.minecraft.network.chat.Component.nullToEmpty(Localization.instance().commands.noPermission));
}
Expand All @@ -431,25 +402,13 @@ public void command(CommandEvent ev) {
if (!mcSubCommand.needsOP()) {
final String txt = GsonComponentSerializer.gson().serialize(mcSubCommand.execute(cmdArgs, player.getUUID()));

source.sendSuccess(() -> {
try {
return ComponentArgument.textComponent().parse(new StringReader(txt));
} catch (CommandSyntaxException ignored) {
return null;
}
}, false);
source.sendSuccess(() -> net.minecraft.network.chat.Component.Serializer.fromJson(txt, source.registryAccess()), false);

} else if (source.hasPermission(4)) {
final String txt = GsonComponentSerializer.gson().serialize(mcSubCommand.execute(cmdArgs, player.getUUID()));


source.sendSuccess(() -> {
try {
return ComponentArgument.textComponent().parse(new StringReader(txt));
} catch (CommandSyntaxException ignored) {
return null;
}
}, false);
source.sendSuccess(() -> net.minecraft.network.chat.Component.Serializer.fromJson(txt, source.registryAccess()), false);

} else {
source.sendFailure(net.minecraft.network.chat.Component.nullToEmpty(Localization.instance().commands.noPermission));
Expand All @@ -458,13 +417,7 @@ public void command(CommandEvent ev) {
} catch (CommandSyntaxException e) {
final String txt = GsonComponentSerializer.gson().serialize(mcSubCommand.execute(cmdArgs, null));

source.sendSuccess(() -> {
try {
return ComponentArgument.textComponent().parse(new StringReader(txt));
} catch (CommandSyntaxException ignored) {
return null;
}
}, false);
source.sendSuccess(() -> net.minecraft.network.chat.Component.Serializer.fromJson(txt, source.registryAccess()), false);
}
break;
}
Expand All @@ -475,7 +428,6 @@ public void command(CommandEvent ev) {
}

}

@SubscribeEvent
public void serverStopping(ServerStoppedEvent ev) {
Metrics.MetricsBase.scheduler.shutdownNow();
Expand Down Expand Up @@ -529,7 +481,7 @@ public void chat(ServerChatEvent ev) {
})) return;
GuildMessageChannel channel = INSTANCE.getChannel(Configuration.instance().advanced.chatOutputChannelID);
if (channel == null) return;
final String json = net.minecraft.network.chat.Component.Serializer.toJson(ev.getMessage());
final String json = net.minecraft.network.chat.Component.Serializer.toJson(ev.getMessage(), ev.getPlayer().registryAccess());
final Component comp = GsonComponentSerializer.gson().deserialize(json);
if(INSTANCE.callEvent((e)->e.onMinecraftMessage(comp, ev.getPlayer().getUUID()))){
return;
Expand Down Expand Up @@ -560,7 +512,7 @@ public void chat(ServerChatEvent ev) {
INSTANCE.sendMessage(ForgeMessageUtils.formatPlayerName(ev.getPlayer()), ev.getPlayer().getUUID().toString(), new DiscordMessage(embed, text, true), channel);
if (!Configuration.instance().compatibility.disableParsingMentionsIngame) {
final String editedJson = GsonComponentSerializer.gson().serialize(MessageUtils.mentionsToNames(comp, channel.getGuild()));
ev.setMessage(net.minecraft.network.chat.Component.Serializer.fromJson(editedJson));
ev.setMessage(net.minecraft.network.chat.Component.Serializer.fromJson(editedJson, ev.getPlayer().registryAccess()));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.erdbeerbaerlp.dcintegration.forge.mixin;

import de.erdbeerbaerlp.dcintegration.forge.util.accessors.ShowInTooltipAccessor;
import net.minecraft.world.item.enchantment.ItemEnchantments;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(ItemEnchantments.class)
public class ItemEnchantmentsMixin implements ShowInTooltipAccessor {
@Shadow @Final boolean showInTooltip;


public boolean discordIntegrationFabric$showsInTooltip() {
return showInTooltip;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package de.erdbeerbaerlp.dcintegration.forge.mixin;

import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.StringReader;
import dcshadow.net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import de.erdbeerbaerlp.dcintegration.common.DiscordIntegration;
import de.erdbeerbaerlp.dcintegration.common.compat.FloodgateUtils;
import de.erdbeerbaerlp.dcintegration.common.storage.Configuration;
import de.erdbeerbaerlp.dcintegration.common.storage.Localization;
import de.erdbeerbaerlp.dcintegration.common.storage.linking.LinkManager;
import de.erdbeerbaerlp.dcintegration.common.util.MinecraftPermission;
import net.minecraft.commands.arguments.ComponentArgument;
import net.minecraft.network.chat.Component;
import net.minecraft.server.players.PlayerList;
import net.neoforged.neoforge.server.ServerLifecycleHooks;
Expand All @@ -32,7 +30,7 @@ private void canLogin(SocketAddress address, GameProfile profile, CallbackInfoRe
if(eventKick != null){
final String jsonComp = GsonComponentSerializer.gson().serialize(eventKick).replace("\\\\n", "\n");
try {
final Component comp = ComponentArgument.textComponent().parse(new StringReader(jsonComp));
final Component comp = Component.Serializer.fromJson(jsonComp, ServerLifecycleHooks.getCurrentServer().registryAccess());
cir.setReturnValue(comp);
} catch (Exception e) {
e.printStackTrace();
Expand Down
Loading

0 comments on commit b700518

Please sign in to comment.