Seperate projects shading works
This commit is contained in:
1 parent
6f6b844455
commit
3ba46fd780
14 files changed
+97
-222
No files matched your search
+23
-2
@@ -1,13 +1,34 @@
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
id("com.gradleup.shadow") version "8.3.3" apply false
|
||||
id("fabric-loom") version "1.7.4" apply false
|
||||
}
|
||||
|
||||
val fullVersion = "1.3.2"
|
||||
val snapshot = true
|
||||
|
||||
allprojects {
|
||||
group = "your.group.id"
|
||||
version = "1.0.0"
|
||||
fun getVersionMeta(includeHash: Boolean): String {
|
||||
if (!snapshot) {
|
||||
return ""
|
||||
}
|
||||
var commitHash = ""
|
||||
if (includeHash && file(".git").isDirectory) {
|
||||
val stdout = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||
standardOutput = stdout
|
||||
}
|
||||
commitHash = "+${stdout.toString().trim()}"
|
||||
}
|
||||
return "$commitHash-SNAPSHOT"
|
||||
}
|
||||
|
||||
group = "me.caseload.knockbacksync"
|
||||
version = "$fullVersion${getVersionMeta(true)}"
|
||||
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
+41
-12
@@ -7,36 +7,65 @@ base {
|
||||
archivesName.set("${rootProject.property("archives_base_name")}-bukkit")
|
||||
}
|
||||
|
||||
val shadeThisThing: Configuration by configurations.creating {
|
||||
isCanBeConsumed = true
|
||||
isTransitive = true
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir(project(":common").file("src/main/java"))
|
||||
}
|
||||
resources {
|
||||
srcDir(project(":common").file("src/main/resources"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":common"))
|
||||
// implementation(project(":common"))
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||
compileOnly("org.geysermc.floodgate:api:2.0-SNAPSHOT")
|
||||
compileOnly("dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("com.fasterxml.jackson.core:jackson-databind:2.17.2")
|
||||
compileOnly("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.2")
|
||||
|
||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||
|
||||
implementation("com.github.retrooper:packetevents-spigot:2.5.0")
|
||||
implementation("dev.jorel:commandapi-bukkit-shade:9.5.3")
|
||||
shadeThisThing(implementation("org.kohsuke:github-api:1.326") {
|
||||
exclude(group = "commons-io", module = "commons-io")
|
||||
exclude(group = "org.apache.commons", module = "commons-lang3")
|
||||
})
|
||||
|
||||
shadeThisThing(implementation("com.fasterxml.jackson.core:jackson-databind:2.17.2")!!)
|
||||
shadeThisThing(implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.2")!!)
|
||||
shadeThisThing(implementation("com.github.retrooper:packetevents-spigot:2.5.0")!!)
|
||||
shadeThisThing(implementation("dev.jorel:commandapi-bukkit-shade:9.5.3")!!)
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
archiveClassifier.set("")
|
||||
configurations = listOf(project.configurations.runtimeClasspath.get())
|
||||
|
||||
relocate("io.github.retrooper.packetevents", "${project.group}.shaded.packetevents")
|
||||
relocate("dev.jorel.commandapi", "${project.group}.shaded.commandapi")
|
||||
|
||||
minimize()
|
||||
// archiveClassifier.set("dev")
|
||||
configurations = listOf(shadeThisThing)
|
||||
isEnableRelocation = true
|
||||
relocationPrefix = "${project.property("maven_group")}.${project.property("archives_base_name")}.shaded"
|
||||
}
|
||||
|
||||
tasks.build {
|
||||
dependsOn(tasks.shadowJar)
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
inputs.property("version", project.version)
|
||||
filteringCharset = "UTF-8"
|
||||
|
||||
filesMatching("plugin.yml") {
|
||||
expand(
|
||||
"version" to project.version,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
neoForge {
|
||||
// Look for versions on https://projects.neoforged.net/neoforged/neoform
|
||||
neoFormVersion.set("1.21-20240613.152323")
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package me.caseload.knockbacksync.manager;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CombatManager {
|
||||
|
||||
private static final Set<UUID> combatPlayers = ConcurrentHashMap.newKeySet();
|
||||
|
||||
public static @NotNull Set<UUID> getPlayers() {
|
||||
return combatPlayers;
|
||||
}
|
||||
|
||||
public static void addPlayer(UUID uuid) {
|
||||
combatPlayers.add(uuid);
|
||||
}
|
||||
|
||||
public static void removePlayer(UUID uuid) {
|
||||
combatPlayers.remove(uuid);
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package me.caseload.knockbacksync.manager;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.caseload.knockbacksync.ConfigWrapper;
|
||||
import me.caseload.knockbacksync.KnockbackSyncBase;
|
||||
import me.caseload.knockbacksync.Platform;
|
||||
import me.caseload.knockbacksync.runnable.PingRunnable;
|
||||
import me.caseload.knockbacksync.scheduler.AbstractTaskHandle;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ConfigManager {
|
||||
|
||||
private boolean toggled;
|
||||
private boolean runnableEnabled;
|
||||
private boolean updateAvailable;
|
||||
private boolean notifyUpdate;
|
||||
|
||||
private long runnableInterval;
|
||||
private long combatTimer;
|
||||
private long spikeThreshold;
|
||||
|
||||
private String enableMessage;
|
||||
private String disableMessage;
|
||||
private String playerEnableMessage;
|
||||
private String playerDisableMessage;
|
||||
private String playerIneligibleMessage;
|
||||
private String reloadMessage;
|
||||
|
||||
private AbstractTaskHandle pingTask;
|
||||
|
||||
private Map<String, Object> config;
|
||||
private File configFile;
|
||||
private ObjectMapper mapper;
|
||||
private ConfigWrapper configWrapper; // Cache the ConfigWrapper instance
|
||||
|
||||
public ConfigManager() {
|
||||
mapper = new ObjectMapper(new YAMLFactory());
|
||||
KnockbackSyncBase instance = KnockbackSyncBase.INSTANCE;
|
||||
configFile = new File(instance.getDataFolder(), "config.yml");
|
||||
}
|
||||
|
||||
public ConfigWrapper getConfigWrapper() {
|
||||
if (configWrapper == null) {
|
||||
reloadConfig();
|
||||
}
|
||||
return configWrapper;
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
try {
|
||||
if (!configFile.exists()) {
|
||||
KnockbackSyncBase.INSTANCE.saveDefaultConfig();
|
||||
}
|
||||
config = mapper.readValue(configFile, Map.class);
|
||||
configWrapper = new ConfigWrapper(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
config = new HashMap<>();
|
||||
configWrapper = new ConfigWrapper(config);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
try {
|
||||
mapper.writeValue(configFile, config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadConfig(boolean reloadConfig) {
|
||||
if (reloadConfig || config == null) {
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
ConfigWrapper config = getConfigWrapper(); // Use cached ConfigWrapper
|
||||
|
||||
toggled = config.getBoolean("enabled", true);
|
||||
|
||||
// Checks to see if the runnable was enabled...
|
||||
// and if we now want to disable it
|
||||
boolean newRunnableEnabled = config.getBoolean("runnable.enabled", true);
|
||||
if (runnableEnabled && newRunnableEnabled && pingTask != null) { // null check for first startup
|
||||
pingTask.cancel();
|
||||
}
|
||||
|
||||
runnableEnabled = newRunnableEnabled;
|
||||
|
||||
if (runnableEnabled) {
|
||||
long initialDelay = 0L;
|
||||
long pingTaskRunnableInterval = runnableInterval;
|
||||
// Folia does not allow 0 ticks of wait time
|
||||
if (KnockbackSyncBase.INSTANCE.platform == Platform.FOLIA) {
|
||||
initialDelay = 1L;
|
||||
pingTaskRunnableInterval = Math.max(pingTaskRunnableInterval, 1L);
|
||||
}
|
||||
pingTask = KnockbackSyncBase.INSTANCE.getScheduler().runTaskTimerAsynchronously(new PingRunnable(), initialDelay, pingTaskRunnableInterval);
|
||||
}
|
||||
|
||||
notifyUpdate = config.getBoolean("notify_updates", true);
|
||||
runnableInterval = config.getLong("runnable.interval", 5L);
|
||||
combatTimer = config.getLong("runnable.timer", 30L);
|
||||
spikeThreshold = config.getLong("spike_threshold", 20L);
|
||||
enableMessage = config.getString("enable_message", "&aSuccessfully enabled KnockbackSync.");
|
||||
disableMessage = config.getString("disable_message", "&cSuccessfully disabled KnockbackSync.");
|
||||
playerEnableMessage = config.getString("player_enable_message", "&aSuccessfully enabled KnockbackSync for %player%.");
|
||||
playerDisableMessage = config.getString("player_disable_message", "&cSuccessfully disabled KnockbackSync for %player%.");
|
||||
playerIneligibleMessage = config.getString("player_ineligible_message", "&c%player% is ineligible for KnockbackSync. If you believe this is an error, please open an issue on the github page.");
|
||||
reloadMessage = config.getString("reload_message", "&aSuccessfully reloaded KnockbackSync.");
|
||||
PlayerData.PING_OFFSET = config.getInt("ping_offset", 25);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package me.caseload.knockbacksync.manager;
|
||||
|
||||
import io.github.retrooper.packetevents.util.GeyserUtil;
|
||||
import me.caseload.knockbacksync.util.FloodgateUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class PlayerDataManager {
|
||||
|
||||
private static final Map<UUID, PlayerData> playerDataMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static PlayerData getPlayerData(@NotNull UUID uuid) {
|
||||
return playerDataMap.get(uuid);
|
||||
}
|
||||
|
||||
public static void addPlayerData(@NotNull UUID uuid, @NotNull PlayerData playerData) {
|
||||
if (!shouldExempt(uuid))
|
||||
playerDataMap.put(uuid, playerData);
|
||||
}
|
||||
|
||||
public static void removePlayerData(@NotNull UUID uuid) {
|
||||
playerDataMap.remove(uuid);
|
||||
}
|
||||
|
||||
public static boolean containsPlayerData(@NotNull UUID uuid) {
|
||||
return playerDataMap.containsKey(uuid);
|
||||
}
|
||||
|
||||
public static boolean shouldExempt(@NotNull UUID uuid) {
|
||||
// Geyser players don't have Java movement
|
||||
return GeyserUtil.isGeyserPlayer(uuid)
|
||||
// Floodgate is the authentication system for Geyser on servers that use Geyser as a proxy instead of installing it as a plugin directly on the server
|
||||
|| FloodgateUtil.isFloodgatePlayer(uuid)
|
||||
// Geyser formatted player string
|
||||
// This will never happen for Java players, as the first character in the 3rd group is always 4 (xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx)
|
||||
|| uuid.toString().startsWith("00000000-0000-0000-0009");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package me.caseload.knockbacksync.stats.custom;
|
||||
|
||||
import org.lwjgl.Version;
|
||||
|
||||
public class BukkitBuildTypePie extends BuildTypePie {
|
||||
BukkitBuildTypePie() {
|
||||
super("build_type", );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package me.caseload.knockbacksync.stats.custom;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PluginJarHashProvider {
|
||||
String getPluginJarHash() throws Exception;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
name: KnockbackSync
|
||||
version: '1.3.2'
|
||||
version: ${version}
|
||||
main: me.caseload.knockbacksync.KnockbackSyncPlugin
|
||||
api-version: '1.18'
|
||||
authors: [ Caseload ]
|
||||
|
||||
+11
-6
@@ -2,19 +2,24 @@ plugins {
|
||||
id("net.neoforged.moddev") version "1.0.11"
|
||||
}
|
||||
|
||||
val bukkitShadeThisThing: Configuration by configurations.creating {
|
||||
isCanBeConsumed = true
|
||||
isTransitive = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// True compileOnly deps
|
||||
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
|
||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||
implementation("com.github.retrooper:packetevents-api:2.5.0")
|
||||
compileOnly("org.geysermc.floodgate:api:2.0-SNAPSHOT")
|
||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||
|
||||
// Shadded in or bundled by platform-specific code
|
||||
compileOnly("net.fabricmc:fabric-loader:${rootProject.property("loader_version")}")
|
||||
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind:2.17.2")
|
||||
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.2")
|
||||
implementation("org.kohsuke:github-api:1.326") {
|
||||
compileOnly("com.github.retrooper:packetevents-api:2.5.0")
|
||||
compileOnly("com.fasterxml.jackson.core:jackson-databind:2.17.2")
|
||||
compileOnly("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.2")
|
||||
compileOnly("org.kohsuke:github-api:1.326") {
|
||||
exclude(group = "commons-io", module = "commons-io")
|
||||
exclude(group = "org.apache.commons", module = "commons-lang3")
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import me.caseload.knockbacksync.scheduler.SchedulerAdapter;
|
||||
import me.caseload.knockbacksync.stats.custom.StatsManager;
|
||||
import me.caseload.knockbacksync.world.PlatformServer;
|
||||
import org.kohsuke.github.GitHub;
|
||||
//import org.kohsuke.github.GitHub;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -4,9 +4,6 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import me.caseload.knockbacksync.KnockbackSyncBase;
|
||||
import me.caseload.knockbacksync.stats.SimplePie;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.kohsuke.github.GHAsset;
|
||||
import org.kohsuke.github.GHRelease;
|
||||
import org.kohsuke.github.GitHub;
|
||||
@@ -21,7 +18,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BuildTypePie extends SimplePie {
|
||||
|
||||
@@ -29,6 +25,7 @@ public class BuildTypePie extends SimplePie {
|
||||
private static final String DEV_BUILDS_FILE = "dev-builds.txt";
|
||||
private static final File dataFolder = KnockbackSyncBase.INSTANCE.getDataFolder();
|
||||
private static String cachedBuildType = null;
|
||||
public URL jarUrl;
|
||||
|
||||
public BuildTypePie() {
|
||||
super("build_type", BuildTypePie::determineBuildType);
|
||||
@@ -91,7 +88,6 @@ public class BuildTypePie extends SimplePie {
|
||||
}
|
||||
|
||||
private static String getPluginJarHash() throws Exception {
|
||||
URL jarUrl = null;
|
||||
switch (KnockbackSyncBase.INSTANCE.platform) {
|
||||
case BUKKIT:
|
||||
case FOLIA:
|
||||
@@ -102,7 +98,7 @@ public class BuildTypePie extends SimplePie {
|
||||
Optional<ModContainer> modContainer = FabricLoader.getInstance().getModContainer("knockbacksync");
|
||||
if (modContainer.isPresent()) {
|
||||
String jarPath = modContainer.get().getRootPath().getFileSystem().toString();
|
||||
// jarPath = jarPath.replaceAll("^jar:", "").replaceAll("!/$", "");
|
||||
jarPath = jarPath.replaceAll("^jar:", "").replaceAll("!/$", "");
|
||||
jarUrl = new File(jarPath).toURI().toURL();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
package me.caseload.knockbacksync.world;
|
||||
|
||||
import me.caseload.knockbacksync.KnockbackSyncBase;
|
||||
import me.caseload.knockbacksync.player.PlatformPlayer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public interface PlatformServer {
|
||||
Collection<PlatformPlayer> getOnlinePlayers();
|
||||
|
||||
@@ -19,10 +19,9 @@ dependencies {
|
||||
modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.property("fabric_version")}")
|
||||
|
||||
include(modImplementation("me.lucko:fabric-permissions-api:0.3.1")!!)
|
||||
include(modImplementation("com.github.retrooper:packetevents-fabric:2.5.6-SNAPSHOT")!!)
|
||||
|
||||
compileOnly("com.fasterxml.jackson.core:jackson-databind:2.17.2")
|
||||
compileOnly("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.2")
|
||||
include(modImplementation("com.github.retrooper:packetevents-fabric:2.5.7-SNAPSHOT")!!)
|
||||
include(implementation("com.fasterxml.jackson.core:jackson-databind:2.17.2")!!)
|
||||
include(implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.2")!!)
|
||||
|
||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||
|
||||
@@ -3,8 +3,6 @@ package me.caseload.knockbacksync.world;
|
||||
import me.caseload.knockbacksync.KnockbackSyncFabric;
|
||||
import me.caseload.knockbacksync.player.FabricPlayer;
|
||||
import me.caseload.knockbacksync.player.PlatformPlayer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
Reference in new issue
Block a user