mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +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
@@ -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