mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
java 16 stuff and headaches
This commit is contained in:
1 parent
a273f5896f
commit
aec22f12c9
10 files changed
+51
-78
No files matched your search
@@ -13,9 +13,8 @@ import static net.kyori.adventure.text.Component.translatable;
|
||||
*/
|
||||
public class CarbonChatEvent extends CancellableCarbonEvent {
|
||||
|
||||
private @NonNull PlayerComponentRenderer renderer = (sender, recipient, message) -> {
|
||||
return translatable("chat.type.text", sender.displayName(), message);
|
||||
};
|
||||
private @NonNull PlayerComponentRenderer renderer = (sender, recipient, message) ->
|
||||
translatable("chat.type.text", sender.displayName(), message);
|
||||
|
||||
private final @NonNull List<@NonNull CarbonPlayer> recipients;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public final class CarbonEventHandler {
|
||||
}
|
||||
|
||||
public <T extends CarbonEvent> void register(final @NonNull Class<T> clazz, final int priority, final boolean consumeCancelled, final @NonNull Consumer<T> consumer) {
|
||||
this.eventBus.register(clazz, new EventSubscriber<T>() {
|
||||
this.eventBus.register(clazz, new EventSubscriber<>() {
|
||||
@Override
|
||||
public int postOrder() {
|
||||
return priority;
|
||||
|
||||
+13
-5
@@ -10,7 +10,7 @@ plugins {
|
||||
id("net.kyori.indra.git")
|
||||
id("net.kyori.indra.checkstyle")
|
||||
id("net.kyori.indra.publishing") apply false
|
||||
id("com.github.johnrengelman.shadow") apply false
|
||||
//id("com.github.johnrengelman.shadow") apply false
|
||||
id("org.checkerframework") apply false
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ subprojects {
|
||||
apply<IndraPlugin>()
|
||||
apply<IndraCheckstylePlugin>()
|
||||
apply<IndraPublishingPlugin>()
|
||||
//apply<CheckerFrameworkPlugin>()
|
||||
apply<CheckerFrameworkPlugin>()
|
||||
|
||||
if (projectVersion.endsWith("-SNAPSHOT")) {
|
||||
// Add git commit hash to version for platforms, but not for API
|
||||
@@ -61,19 +61,17 @@ subprojects {
|
||||
disableAutoTargetJvm()
|
||||
}
|
||||
|
||||
/*
|
||||
configure<CheckerFrameworkExtension> {
|
||||
checkers = listOf(
|
||||
"org.checkerframework.checker.nullness.NullnessChecker"
|
||||
)
|
||||
}
|
||||
*/
|
||||
|
||||
indra {
|
||||
gpl3OnlyLicense()
|
||||
|
||||
javaVersions {
|
||||
target(11)
|
||||
target(16)
|
||||
}
|
||||
|
||||
github("Hexaoxide", "Carbon")
|
||||
@@ -85,4 +83,14 @@ tasks {
|
||||
withType<Jar> {
|
||||
onlyIf { false }
|
||||
}
|
||||
|
||||
withType<JavaCompile> {
|
||||
options.forkOptions.jvmArgs = listOf("--illegal-access=permit")
|
||||
options.isFork = true
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<JavaCompile>("compileJava") {
|
||||
options.forkOptions.jvmArgs = listOf("--illegal-access=permit")
|
||||
options.isFork = true
|
||||
}
|
||||
@@ -77,7 +77,7 @@ bukkit {
|
||||
name = rootProject.name
|
||||
version = project.version as String
|
||||
main = "net.draycia.carbon.bukkit.CarbonChatBukkitEntry"
|
||||
apiVersion = "1.13"
|
||||
apiVersion = "1.16"
|
||||
author = "Draycia"
|
||||
depend = listOf("PlaceholderAPI", "Vault")
|
||||
loadBefore = listOf("Essentials")
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.papermc.lib.PaperLib;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -12,7 +12,8 @@ public class CarbonChatBukkitEntry extends JavaPlugin {
|
||||
|
||||
private static final int BSTATS_PLUGIN_ID = 8720;
|
||||
|
||||
private @MonotonicNonNull CarbonChatBukkit carbon;
|
||||
@SuppressWarnings("initialization.fields.uninitialized")
|
||||
private @NonNull CarbonChatBukkit carbon;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
@@ -14,21 +14,13 @@ public interface BukkitCommander extends Commander, ForwardingAudience.Single {
|
||||
return new BukkitCommanderImpl(sender);
|
||||
}
|
||||
|
||||
final class BukkitCommanderImpl implements BukkitCommander {
|
||||
private final CommandSender commandSender;
|
||||
|
||||
private BukkitCommanderImpl(final @NonNull CommandSender commandSender) {
|
||||
this.commandSender = commandSender;
|
||||
}
|
||||
|
||||
public @NonNull CommandSender commandSender() {
|
||||
return this.commandSender;
|
||||
}
|
||||
record BukkitCommanderImpl(@NonNull CommandSender commandSender) implements BukkitCommander {
|
||||
|
||||
@Override
|
||||
public @NonNull Audience audience() {
|
||||
return this.commandSender;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,33 +10,26 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
public final class BukkitPlayerCommander implements PlayerCommander, BukkitCommander {
|
||||
public record BukkitPlayerCommander(CarbonChat carbon,
|
||||
@NonNull Player player) implements PlayerCommander, BukkitCommander {
|
||||
|
||||
private final CarbonChat carbon;
|
||||
private final Player player;
|
||||
|
||||
public BukkitPlayerCommander(final @NonNull CarbonChat carbon, final @NonNull Player player) {
|
||||
this.carbon = carbon;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public @NonNull Player player() {
|
||||
@Override
|
||||
public @NonNull
|
||||
CommandSender commandSender() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CommandSender commandSender() {
|
||||
public @NonNull
|
||||
Audience audience() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Audience audience() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CarbonPlayer carbonPlayer() {
|
||||
return requireNonNull(this.carbon.userManager().carbonPlayer(this.player.getUniqueId()), "No CarbonPlayer for logged in Player!");
|
||||
public @NonNull
|
||||
CarbonPlayer carbonPlayer() {
|
||||
return requireNonNull(this.carbon.userManager().carbonPlayer(this.player.getUniqueId()),
|
||||
"No CarbonPlayer for logged in Player!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,12 +63,12 @@ public class CarbonPlayerBukkit extends CarbonPlayerCommon {
|
||||
|
||||
final ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (mainHand != null && !mainHand.getType().isAir()) {
|
||||
if (!mainHand.getType().isAir()) {
|
||||
itemStack = mainHand;
|
||||
} else {
|
||||
final ItemStack offHand = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (offHand != null && !offHand.getType().isAir()) {
|
||||
if (!offHand.getType().isAir()) {
|
||||
itemStack = offHand;
|
||||
} else {
|
||||
itemStack = null;
|
||||
|
||||
@@ -14,22 +14,15 @@ public interface SpongeCommander extends Commander, ForwardingAudience.Single {
|
||||
return new SpongeCommanderImpl(commandCause);
|
||||
}
|
||||
|
||||
final class SpongeCommanderImpl implements SpongeCommander {
|
||||
private final CommandCause commandCause;
|
||||
|
||||
private SpongeCommanderImpl(final @NonNull CommandCause commandCause) {
|
||||
this.commandCause = commandCause;
|
||||
}
|
||||
record SpongeCommanderImpl(
|
||||
@NonNull CommandCause commandCause) implements SpongeCommander {
|
||||
|
||||
@Override
|
||||
public @NonNull CommandCause commandCause() {
|
||||
return this.commandCause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Audience audience() {
|
||||
public @NonNull
|
||||
Audience audience() {
|
||||
return this.commandCause.audience();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,34 +10,21 @@ import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
public final class SpongePlayerCommander implements PlayerCommander, SpongeCommander {
|
||||
public record SpongePlayerCommander(CarbonChat carbon,
|
||||
@NonNull ServerPlayer player,
|
||||
@NonNull CommandCause commandCause)
|
||||
implements PlayerCommander, SpongeCommander {
|
||||
|
||||
private final CarbonChat carbon;
|
||||
private final ServerPlayer player;
|
||||
private final CommandCause commandCause;
|
||||
|
||||
public SpongePlayerCommander(final @NonNull CarbonChat carbon, final @NonNull ServerPlayer player, final @NonNull CommandCause commandCause) {
|
||||
this.carbon = carbon;
|
||||
this.player = player;
|
||||
this.commandCause = commandCause;
|
||||
@Override
|
||||
public @NonNull
|
||||
CarbonPlayer carbonPlayer() {
|
||||
return requireNonNull(this.carbon.userManager().carbonPlayer(this.player.uniqueId()),
|
||||
"No CarbonPlayer for logged in Player!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CarbonPlayer carbonPlayer() {
|
||||
return requireNonNull(this.carbon.userManager().carbonPlayer(this.player.uniqueId()), "No CarbonPlayer for logged in Player!");
|
||||
}
|
||||
|
||||
public @NonNull ServerPlayer player() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CommandCause commandCause() {
|
||||
return this.commandCause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Audience audience() {
|
||||
public @NonNull
|
||||
Audience audience() {
|
||||
return this.commandCause.audience();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user