mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 22:16:22 +00:00
dependency catalog & relocations
This commit is contained in:
1 parent
407de5479e
commit
6637830e86
9 files changed
+298
-209
No files matched your search
+7
-23
@@ -1,18 +1,16 @@
|
||||
import java.util.Locale
|
||||
import net.draycia.carbon.BSTATS_VER
|
||||
import net.draycia.carbon.CLOUD_VER
|
||||
import org.spongepowered.plugin.metadata.PluginDependency
|
||||
import org.spongepowered.gradle.plugin.config.PluginLoaders
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("org.spongepowered.gradle.plugin") version "1.0.3"
|
||||
id("org.spongepowered.gradle.plugin")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.carbonchatApi)
|
||||
implementation("cloud.commandframework:cloud-sponge:$CLOUD_VER")
|
||||
implementation("org.bstats:bstats-sponge:$BSTATS_VER")
|
||||
implementation(libs.cloudSponge)
|
||||
//implementation(libs.bstatsSponge) // not updated for api 8 yet
|
||||
}
|
||||
|
||||
tasks {
|
||||
@@ -23,26 +21,12 @@ tasks {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
shadowJar {
|
||||
minimize()
|
||||
archiveFileName.set(project.name + "-" + project.version + ".jar")
|
||||
doLast {
|
||||
val archive = archiveFile.get().asFile
|
||||
val libs = rootProject.buildDir.resolve("libs")
|
||||
libs.mkdirs()
|
||||
archive.copyTo(libs.resolve(archive.name), overwrite = true)
|
||||
configureShadow()
|
||||
dependencies {
|
||||
// included in sponge
|
||||
exclude(dependency("io.leangen.geantyref:geantyref"))
|
||||
}
|
||||
relocate("org.yaml", "net.draycia.carbon.libs.org.yaml")
|
||||
relocate("org.checkerframework", "net.draycia.carbon.libs.checkerframework")
|
||||
relocate("org.reactivestreams", "net.draycia.carbon.libs.reactivestreams")
|
||||
relocate("org.codehaus", "net.draycia.carbon.libs.codehaus")
|
||||
relocate("io.leangen.geantyref", "net.draycia.carbon.libs.typereference")
|
||||
relocate("io.lettuce", "net.draycia.carbon.libs.lettuce")
|
||||
relocate("cloud.commandframework", "net.draycia.carbon.libs.cloud")
|
||||
relocate("com.zaxxer.hikari", "net.draycia.carbon.libs.hikari")
|
||||
relocate("com.typesafe.config", "net.draycia.carbon.libs.typesafe.config")
|
||||
relocate("com.google.common", "net.draycia.carbon.libs.google.common")
|
||||
relocate("reactor", "net.draycia.carbon.libs.reactor")
|
||||
relocate("javax.annotation", "net.draycia.carbon.libs.javax.annotation")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.draycia.carbon.api.CarbonChat;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bstats.sponge.Metrics;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.data.Keys;
|
||||
@@ -15,7 +14,6 @@ import org.spongepowered.api.item.inventory.ItemStack;
|
||||
import org.spongepowered.plugin.PluginContainer;
|
||||
import org.spongepowered.plugin.jvm.Plugin;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.kyori.adventure.text.Component.empty;
|
||||
@@ -31,14 +29,14 @@ public class CarbonChatSponge implements CarbonChat {
|
||||
|
||||
@Inject
|
||||
public CarbonChatSponge(
|
||||
//final Metrics.@NonNull Factory metricsFactory,
|
||||
final @NonNull PluginContainer pluginContainer,
|
||||
final @NonNull Logger logger,
|
||||
final Metrics.Factory metricsFactory
|
||||
final @NonNull Logger logger
|
||||
) {
|
||||
this.pluginContainer = pluginContainer;
|
||||
this.logger = logger;
|
||||
|
||||
metricsFactory.make(BSTATS_PLUGIN_ID);
|
||||
//metricsFactory.make(BSTATS_PLUGIN_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,36 +46,37 @@ public class CarbonChatSponge implements CarbonChat {
|
||||
|
||||
@Override
|
||||
public @NonNull Component createComponent(final @NonNull UUID uuid) {
|
||||
final Optional<ServerPlayer> player = Sponge.server().player(uuid);
|
||||
|
||||
if (player.isPresent()) {
|
||||
ItemStack itemStack = null;
|
||||
|
||||
final ItemStack mainHand = player.get().itemInHand(HandTypes.MAIN_HAND);
|
||||
|
||||
if (!mainHand.isEmpty()) {
|
||||
itemStack = mainHand;
|
||||
} else {
|
||||
final ItemStack offHand = player.get().itemInHand(HandTypes.OFF_HAND);
|
||||
|
||||
if (!offHand.isEmpty()) {
|
||||
itemStack = offHand;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemStack == null || itemStack.isEmpty()) {
|
||||
return empty();
|
||||
}
|
||||
|
||||
final TextComponent.Builder builder = text();
|
||||
|
||||
builder.append(text("[", WHITE));
|
||||
builder.append(itemStack.get(Keys.DISPLAY_NAME).orElse(itemStack.type().asComponent()));
|
||||
builder.append(text("]", WHITE));
|
||||
|
||||
return builder.build();
|
||||
final ServerPlayer player = Sponge.server().player(uuid).orElse(null);
|
||||
if (player == null) {
|
||||
return empty();
|
||||
}
|
||||
|
||||
return empty();
|
||||
final ItemStack itemStack;
|
||||
|
||||
final ItemStack mainHand = player.itemInHand(HandTypes.MAIN_HAND);
|
||||
|
||||
if (!mainHand.isEmpty()) {
|
||||
itemStack = mainHand;
|
||||
} else {
|
||||
final ItemStack offHand = player.itemInHand(HandTypes.OFF_HAND);
|
||||
|
||||
if (!offHand.isEmpty()) {
|
||||
itemStack = offHand;
|
||||
} else {
|
||||
itemStack = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemStack == null || itemStack.isEmpty()) {
|
||||
return empty();
|
||||
}
|
||||
|
||||
final TextComponent.Builder builder = text();
|
||||
|
||||
builder.append(text('[', WHITE));
|
||||
builder.append(itemStack.get(Keys.DISPLAY_NAME).orElse(itemStack.type().asComponent()));
|
||||
builder.append(text(']', WHITE));
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user