Skip to content

Commit

Permalink
feat: initial 1.19.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker committed Aug 1, 2022
1 parent 475ee84 commit 9404495
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 34 deletions.
16 changes: 11 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import net.kyori.indra.repository.SonatypeRepositories
import net.kyori.indra.repository.sonatypeSnapshots

plugins {
id("vanilla-tweaks.parent-build-logic")
id("net.kyori.indra") version "2.0.6"
id("net.kyori.indra") version "2.1.1"
id("net.kyori.indra.license-header") version "2.0.6"
id("com.github.johnrengelman.shadow") version "7.0.0" apply false
}
Expand Down Expand Up @@ -38,7 +39,12 @@ subprojects {

repositories {
mavenCentral()
sonatypeSnapshots()
sonatype.s01Snapshots().mavenContent {
includeGroup("net.kyori")
}
sonatype.ossSnapshots().mavenContent {
includeGroup("cloud.commandframework")
}
maven("https://libraries.minecraft.net/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://maven.enginehub.org/repo/")
Expand All @@ -53,9 +59,9 @@ subprojects {
compileOnly("io.leangen.geantyref:geantyref:1.3.11")
implementation("me.machinemaker.mirror:mirror-paper:0.1.0")
implementation("me.machinemaker.lectern:lectern-yaml:0.2.1")
implementation("net.kyori:adventure-platform-bukkit:4.1.1")
implementation("net.kyori:adventure-platform-bukkit:4.1.2-SNAPSHOT") // s01.oss
implementation("net.kyori:adventure-text-minimessage:4.11.0")
implementation(platform("cloud.commandframework:cloud-bom:1.7.0-SNAPSHOT"))
implementation(platform("cloud.commandframework:cloud-bom:1.8.0-SNAPSHOT")) // oss
implementation("cloud.commandframework:cloud-paper")
implementation("cloud.commandframework:cloud-minecraft-extras")
implementation("org.bstats:bstats-bukkit:2.2.1")
Expand All @@ -76,7 +82,7 @@ subprojects {
compileOnly("org.xerial:sqlite-jdbc:3.36.0.3")

// Native to minecraft
compileOnly("com.mojang:authlib:1.5.25")
compileOnly("com.mojang:authlib:3.11.49")
compileOnly("org.slf4j:slf4j-api:1.7.30")
compileOnly("com.mojang:brigadier:1.0.18")

Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mcVersion=1.19.1-R0.1-SNAPSHOT

org.gradle.parallel=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 4 additions & 2 deletions vanilla-tweaks-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ dependencies {
val adventureVersion = "4.11.0"
implementation("net.kyori:adventure-text-serializer-plain:$adventureVersion")
implementation("net.kyori:adventure-api:$adventureVersion")
compileOnly("org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT")

val mcVersion = project.providers.gradleProperty("mcVersion").get()
compileOnly("org.spigotmc:spigot-api:$mcVersion")

// tests
testImplementation("org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT")
testImplementation("org.spigotmc:spigot-api:$mcVersion")
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
*/
package me.machinemaker.vanillatweaks;

import cloud.commandframework.bukkit.CloudBukkitCapabilities;
import cloud.commandframework.paper.PaperCommandManager;
import com.google.inject.Inject;
import me.machinemaker.vanillatweaks.cloud.dispatchers.CommandDispatcher;
import me.machinemaker.vanillatweaks.modules.ModuleManager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -29,16 +32,21 @@
public class GlobalListener implements Listener {

private final ModuleManager moduleManager;
private final PaperCommandManager<CommandDispatcher> commandManager;

@Inject
public GlobalListener(ModuleManager moduleManager) {
public GlobalListener(ModuleManager moduleManager, PaperCommandManager<CommandDispatcher> commandManager) {
this.moduleManager = moduleManager;
this.commandManager = commandManager;
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBukkitReload(ServerLoadEvent event) {
if (event.getType() == ServerLoadEvent.LoadType.RELOAD) {
moduleManager.reloadModules();
} else if (event.getType() == ServerLoadEvent.LoadType.STARTUP && this.commandManager.hasCapability(CloudBukkitCapabilities.COMMODORE_BRIGADIER)) {
// This is very annoying
ModuleManager.reSyncCommands();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public final class LoggerFactory {

private static final String GLOBAL_PREFIX = "VanillaTweaks";
static final String GLOBAL_PREFIX = "PaperTweaks";
private static final Logger PLUGIN_LOGGER = org.slf4j.LoggerFactory.getLogger(GLOBAL_PREFIX);

private LoggerFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
import com.google.inject.Injector;
import com.google.inject.name.Names;
import io.papermc.lib.PaperLib;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Stream;
import me.machinemaker.lectern.BaseConfig;
import me.machinemaker.vanillatweaks.adventure.MiniMessageComponentRenderer;
import me.machinemaker.vanillatweaks.cloud.CloudModule;
Expand All @@ -41,26 +49,13 @@
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component;
import org.apache.commons.io.FileUtils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Jdbi;
import org.slf4j.Logger;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Stream;

import static me.machinemaker.vanillatweaks.adventure.Components.join;
import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.Component.translatable;
Expand All @@ -70,7 +65,7 @@ public class VanillaTweaks extends JavaPlugin {

public static boolean RAN_CONFIG_MIGRATIONS = false;

public static final Component PLUGIN_PREFIX = text().append(text("[", DARK_GRAY)).append(text("PaperTweaks", BLUE)).append(text("] ", DARK_GRAY)).build();
public static final Component PLUGIN_PREFIX = text().append(text("[", DARK_GRAY)).append(text(LoggerFactory.GLOBAL_PREFIX, BLUE)).append(text("] ", DARK_GRAY)).build();
public static final Logger LOGGER = LoggerFactory.getLogger();

private static final ScheduledExecutorService EXECUTOR_SERVICE = Executors.newScheduledThreadPool(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.mojang.brigadier.arguments.StringArgumentType;
import io.leangen.geantyref.TypeToken;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import me.machinemaker.mirror.FieldAccessor;
import me.machinemaker.mirror.MethodInvoker;
import me.machinemaker.mirror.Mirror;
Expand All @@ -52,12 +57,7 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.checkerframework.checker.nullness.qual.NonNull;

import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import static java.util.Objects.requireNonNull;
import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.format.NamedTextColor.*;

Expand Down Expand Up @@ -136,7 +136,7 @@ PaperCommandManager<CommandDispatcher> paperCommandManager(CommandDispatcherFact
manager.registerCommandPostProcessor(new GamemodePostprocessor());
manager.commandSuggestionProcessor(new SimpleSuggestionProcessor());

manager.brigadierManager().registerMapping(new TypeToken<PseudoEnumArgument.PseudoEnumParser<CommandDispatcher>>() {}, builder -> {
requireNonNull(manager.brigadierManager()).registerMapping(new TypeToken<PseudoEnumArgument.PseudoEnumParser<CommandDispatcher>>() {}, builder -> {
builder.cloudSuggestions().to(argument -> switch (argument.getStringMode()) {
case QUOTED -> StringArgumentType.string();
case GREEDY -> StringArgumentType.greedyString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static void resendData() {
RESEND_DATA_METHOD.invoke(PaperMirror.PLAYER_LIST);
}

private static void reSyncCommands() {
public static void reSyncCommands() {
Bukkit.getServer().getHelpMap().clear();
SIMPLE_HELP_MAP_INITIALIZE_GENERAL_TOPICS_METHOD.invoke(Bukkit.getHelpMap());
SYNC_COMMANDS_METHOD.invoke(Bukkit.getServer());
Expand Down
5 changes: 3 additions & 2 deletions vanilla-tweaks-paper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ dependencies {
exclude(group="me.lucko", module="commodore")
}

compileOnly("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT")
val mcVersion = providers.gradleProperty("mcVersion").get()
compileOnly("io.papermc.paper:paper-api:$mcVersion")

// tests
testImplementation("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT")
testImplementation("io.papermc.paper:paper-api:$mcVersion")
}

tasks {
Expand Down

0 comments on commit 9404495

Please sign in to comment.