mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +00:00
Rename bukkit module to paper
This commit is contained in:
1 parent
a7a9dddf89
commit
5661cc293f
24 files changed
+156
-143
No files matched your search
@@ -27,12 +27,12 @@
|
|||||||
"http://checkstyle.org/dtds/suppressions_1_2.dtd">
|
"http://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||||
<suppressions>
|
<suppressions>
|
||||||
<!-- add any necessary suppressions here -->
|
<!-- add any necessary suppressions here -->
|
||||||
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](bukkit|sponge|common|velocity|fabric)[\\/].*"
|
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](paper|sponge|common|velocity|fabric)[\\/].*"
|
||||||
checks="FilteringWriteTag"/>
|
checks="FilteringWriteTag"/>
|
||||||
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](bukkit|sponge|common|velocity|fabric)[\\/].*"
|
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](paper|sponge|common|velocity|fabric)[\\/].*"
|
||||||
checks="MissingJavadocMethod"/>
|
checks="MissingJavadocMethod"/>
|
||||||
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](bukkit|sponge|common|velocity|fabric)[\\/].*"
|
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](paper|sponge|common|velocity|fabric)[\\/].*"
|
||||||
checks="MissingJavadocPackage"/>
|
checks="MissingJavadocPackage"/>
|
||||||
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](bukkit|sponge|common|velocity|fabric)[\\/].*"
|
<suppress files="src[\\/]main[\\/]java[\\/]net[\\/]draycia[\\/]carbon[\\/](paper|sponge|common|velocity|fabric)[\\/].*"
|
||||||
checks="MissingJavadocType"/>
|
checks="MissingJavadocType"/>
|
||||||
</suppressions>
|
</suppressions>
|
||||||
@@ -36,7 +36,8 @@ public final class ConfigChannelSettings {
|
|||||||
You only need to change the second part of the key. "global" by default.
|
You only need to change the second part of the key. "global" by default.
|
||||||
The value is what's used in commands, this is probably what you want to change.
|
The value is what's used in commands, this is probably what you want to change.
|
||||||
""")
|
""")
|
||||||
private @Nullable Key key = Key.key("carbon", "basic");
|
private @Nullable
|
||||||
|
final Key key = Key.key("carbon", "basic");
|
||||||
|
|
||||||
@Comment("""
|
@Comment("""
|
||||||
The permission required to use the channel.
|
The permission required to use the channel.
|
||||||
@@ -44,19 +45,25 @@ public final class ConfigChannelSettings {
|
|||||||
To send messages you must have the permission carbon.channel.basic.speak
|
To send messages you must have the permission carbon.channel.basic.speak
|
||||||
If you want to give both, grant carbon.channel.basic or carbon.channel.basic.*
|
If you want to give both, grant carbon.channel.basic or carbon.channel.basic.*
|
||||||
""")
|
""")
|
||||||
private @Nullable String permission = "carbon.channel.basic";
|
private @Nullable
|
||||||
|
final String permission = "carbon.channel.basic";
|
||||||
|
|
||||||
@Setting("format")
|
@Setting("format")
|
||||||
@Comment("The chat formats for this channel.")
|
@Comment("The chat formats for this channel.")
|
||||||
private @Nullable ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
|
private @Nullable
|
||||||
|
final ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
|
||||||
|
|
||||||
@Comment("Messages will be sent in this channel if they start with this prefix.")
|
@Comment("Messages will be sent in this channel if they start with this prefix.")
|
||||||
private @Nullable String quickPrefix = "";
|
private @Nullable
|
||||||
|
final String quickPrefix = "";
|
||||||
|
|
||||||
private @Nullable Boolean shouldRegisterCommands = true;
|
private @Nullable
|
||||||
|
final Boolean shouldRegisterCommands = true;
|
||||||
|
|
||||||
private @Nullable String commandName = null;
|
private @Nullable
|
||||||
|
final String commandName = null;
|
||||||
|
|
||||||
private @Nullable List<String> commandAliases = Collections.emptyList();
|
private @Nullable
|
||||||
|
final List<String> commandAliases = Collections.emptyList();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,8 @@ public final class ConfigChatChannel implements ChatChannel {
|
|||||||
You only need to change the second part of the key. "global" by default.
|
You only need to change the second part of the key. "global" by default.
|
||||||
The value is what's used in commands, this is probably what you want to change.
|
The value is what's used in commands, this is probably what you want to change.
|
||||||
""")
|
""")
|
||||||
private @Nullable Key key = Key.key("carbon", "global");
|
private @Nullable
|
||||||
|
final Key key = Key.key("carbon", "global");
|
||||||
|
|
||||||
@Comment("""
|
@Comment("""
|
||||||
The permission required to use the /channel <channelname> and /<channelname> commands.
|
The permission required to use the /channel <channelname> and /<channelname> commands.
|
||||||
@@ -84,20 +85,26 @@ public final class ConfigChatChannel implements ChatChannel {
|
|||||||
To read messages you must have the permission carbon.channel.global.see
|
To read messages you must have the permission carbon.channel.global.see
|
||||||
To send messages you must have the permission carbon.channel.global.speak
|
To send messages you must have the permission carbon.channel.global.speak
|
||||||
""")
|
""")
|
||||||
private @Nullable String permission = "carbon.channel.global";
|
private @Nullable
|
||||||
|
final String permission = "carbon.channel.global";
|
||||||
|
|
||||||
@Setting("format")
|
@Setting("format")
|
||||||
@Comment("The chat formats for this channel.")
|
@Comment("The chat formats for this channel.")
|
||||||
private @Nullable ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
|
private @Nullable
|
||||||
|
final ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
|
||||||
|
|
||||||
@Comment("Messages will be sent in this channel if they start with this prefix.")
|
@Comment("Messages will be sent in this channel if they start with this prefix.")
|
||||||
private @Nullable String quickPrefix = "";
|
private @Nullable
|
||||||
|
final String quickPrefix = "";
|
||||||
|
|
||||||
private @Nullable Boolean shouldRegisterCommands = true;
|
private @Nullable
|
||||||
|
final Boolean shouldRegisterCommands = true;
|
||||||
|
|
||||||
private @Nullable String commandName = null;
|
private @Nullable
|
||||||
|
final String commandName = null;
|
||||||
|
|
||||||
private @Nullable List<String> commandAliases = Collections.emptyList();
|
private @Nullable
|
||||||
|
final List<String> commandAliases = Collections.emptyList();
|
||||||
|
|
||||||
private transient @Nullable ConfigChannelMessages carbonMessages = null;
|
private transient @Nullable ConfigChannelMessages carbonMessages = null;
|
||||||
|
|
||||||
@@ -106,9 +113,9 @@ public final class ConfigChatChannel implements ChatChannel {
|
|||||||
A value of '0' requires that both players are in the same world.
|
A value of '0' requires that both players are in the same world.
|
||||||
On velocity, '0' requires that both players are in the same server.
|
On velocity, '0' requires that both players are in the same server.
|
||||||
""")
|
""")
|
||||||
private int radius = -1;
|
private final int radius = -1;
|
||||||
|
|
||||||
private transient @Nullable ConfigChannelMessages messageService = null;
|
private final transient @Nullable ConfigChannelMessages messageService = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable String quickPrefix() {
|
public @Nullable String quickPrefix() {
|
||||||
@@ -152,7 +159,7 @@ public final class ConfigChatChannel implements ChatChannel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private transient Map<String, TagResolver> DEFAULT_TAGS = Map.ofEntries(
|
private final transient Map<String, TagResolver> DEFAULT_TAGS = Map.ofEntries(
|
||||||
Map.entry("hover", StandardTags.hoverEvent()),
|
Map.entry("hover", StandardTags.hoverEvent()),
|
||||||
Map.entry("click", StandardTags.clickEvent()),
|
Map.entry("click", StandardTags.clickEvent()),
|
||||||
Map.entry("color", StandardTags.color()),
|
Map.entry("color", StandardTags.color()),
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
|
|||||||
public class ClearChatSettings {
|
public class ClearChatSettings {
|
||||||
|
|
||||||
@Comment("The message that will be sent to each player.")
|
@Comment("The message that will be sent to each player.")
|
||||||
private String message = "";
|
private final String message = "";
|
||||||
|
|
||||||
@Comment("The number of times the message will be sent to each player.")
|
@Comment("The number of times the message will be sent to each player.")
|
||||||
private int iterations = 50;
|
private final int iterations = 50;
|
||||||
|
|
||||||
@Comment("The message to be sent after chat is cleared.")
|
@Comment("The message to be sent after chat is cleared.")
|
||||||
private String broadcast = "<gold>Chat has been cleared by </gold><green><display_name><green><gold>.";
|
private final String broadcast = "<gold>Chat has been cleared by </gold><green><display_name><green><gold>.";
|
||||||
|
|
||||||
private @MonotonicNonNull Component messageComponent = null;
|
private @MonotonicNonNull Component messageComponent = null;
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
|
|||||||
public class DatabaseSettings {
|
public class DatabaseSettings {
|
||||||
|
|
||||||
@Comment("JDBC URL")
|
@Comment("JDBC URL")
|
||||||
private String url = "jdbc:mysql://localhost:3306/carbon";
|
private final String url = "jdbc:mysql://localhost:3306/carbon";
|
||||||
|
|
||||||
@Comment("")
|
@Comment("")
|
||||||
private String username = "username";
|
private final String username = "username";
|
||||||
|
|
||||||
@Comment("")
|
@Comment("")
|
||||||
private String password = "password";
|
private final String password = "password";
|
||||||
|
|
||||||
public String url() {
|
public String url() {
|
||||||
return this.url;
|
return this.url;
|
||||||
|
|||||||
@@ -30,28 +30,28 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
|
|||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class MessagingSettings {
|
public class MessagingSettings {
|
||||||
|
|
||||||
private boolean enabled = false;
|
private final boolean enabled = false;
|
||||||
|
|
||||||
@Comment("Options: RABBITMQ, NATS, REDIS")
|
@Comment("Options: RABBITMQ, NATS, REDIS")
|
||||||
private MessagingManager.@NonNull BrokerType brokerType = MessagingManager.BrokerType.NONE;
|
private final MessagingManager.@NonNull BrokerType brokerType = MessagingManager.BrokerType.NONE;
|
||||||
|
|
||||||
@Comment("")
|
@Comment("")
|
||||||
private String url = "127.0.0.1";
|
private final String url = "127.0.0.1";
|
||||||
|
|
||||||
@Comment("")
|
@Comment("")
|
||||||
private int port = 5672; // RabbitMQ 5672, NATS 4222, Redis 6379
|
private final int port = 5672; // RabbitMQ 5672, NATS 4222, Redis 6379
|
||||||
|
|
||||||
@Comment("RabbitMQ VHost")
|
@Comment("RabbitMQ VHost")
|
||||||
private String vhost = "/"; // RabbitMQ only
|
private final String vhost = "/"; // RabbitMQ only
|
||||||
|
|
||||||
@Comment("NATS credentials file")
|
@Comment("NATS credentials file")
|
||||||
private String credentialsFile = ""; // NATS only
|
private final String credentialsFile = ""; // NATS only
|
||||||
|
|
||||||
@Comment("RabbitMQ username")
|
@Comment("RabbitMQ username")
|
||||||
private String username = "username"; // RabbitMQ only
|
private final String username = "username"; // RabbitMQ only
|
||||||
|
|
||||||
@Comment("RabbitMQ and Redis password")
|
@Comment("RabbitMQ and Redis password")
|
||||||
private String password = "password"; // RabbitMQ and Redis only
|
private final String password = "password"; // RabbitMQ and Redis only
|
||||||
|
|
||||||
public boolean enabled() {
|
public boolean enabled() {
|
||||||
return this.enabled;
|
return this.enabled;
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
|
|||||||
public class PingSettings {
|
public class PingSettings {
|
||||||
|
|
||||||
@Comment("The color your name will be when another player mentions you.")
|
@Comment("The color your name will be when another player mentions you.")
|
||||||
private TextColor highlightTextColor = NamedTextColor.YELLOW;
|
private final TextColor highlightTextColor = NamedTextColor.YELLOW;
|
||||||
|
|
||||||
private String prefix = "@";
|
private final String prefix = "@";
|
||||||
|
|
||||||
private boolean playSound = false;
|
private final boolean playSound = false;
|
||||||
private Key name = Key.key("block.anvil.use");
|
private final Key name = Key.key("block.anvil.use");
|
||||||
private Sound.Source source = Sound.Source.MASTER;
|
private final Sound.Source source = Sound.Source.MASTER;
|
||||||
private float volume = 1.0f; // 0.0 -> infinity
|
private final float volume = 1.0f; // 0.0 -> infinity
|
||||||
private float pitch = 1.0f; // 0.0 -> 2.0
|
private final float pitch = 1.0f; // 0.0 -> 2.0
|
||||||
|
|
||||||
public TextColor highlightTextColor() {
|
public TextColor highlightTextColor() {
|
||||||
return this.highlightTextColor;
|
return this.highlightTextColor;
|
||||||
|
|||||||
@@ -32,22 +32,22 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
|
|||||||
public class PrimaryConfig {
|
public class PrimaryConfig {
|
||||||
|
|
||||||
@Comment("The default locale for plugin messages.")
|
@Comment("The default locale for plugin messages.")
|
||||||
private Locale defaultLocale = Locale.US;
|
private final Locale defaultLocale = Locale.US;
|
||||||
|
|
||||||
@Comment("""
|
@Comment("""
|
||||||
The default channel that new players will be in when they join.
|
The default channel that new players will be in when they join.
|
||||||
If the channel is not found or the player cannot use the channel, they will speak in basic non-channel chat.
|
If the channel is not found or the player cannot use the channel, they will speak in basic non-channel chat.
|
||||||
""")
|
""")
|
||||||
private Key defaultChannel = Key.key("carbon", "global");
|
private final Key defaultChannel = Key.key("carbon", "global");
|
||||||
|
|
||||||
@Comment("The service that will be used to store and load player information.")
|
@Comment("The service that will be used to store and load player information.")
|
||||||
private StorageType storageType = StorageType.JSON;
|
private final StorageType storageType = StorageType.JSON;
|
||||||
|
|
||||||
@Comment("")
|
@Comment("")
|
||||||
private DatabaseSettings databaseSettings = new DatabaseSettings();
|
private final DatabaseSettings databaseSettings = new DatabaseSettings();
|
||||||
|
|
||||||
@Comment("Various ClearChat command settings.")
|
@Comment("Various ClearChat command settings.")
|
||||||
private ClearChatSettings clearChatSettings = new ClearChatSettings();
|
private final ClearChatSettings clearChatSettings = new ClearChatSettings();
|
||||||
|
|
||||||
@Comment("""
|
@Comment("""
|
||||||
Plugin-wide custom placeholders.
|
Plugin-wide custom placeholders.
|
||||||
@@ -56,12 +56,12 @@ public class PrimaryConfig {
|
|||||||
Make sure to close your tags so they do not bleed into other formats.
|
Make sure to close your tags so they do not bleed into other formats.
|
||||||
Only a single pass is done so custom placeholders will not work within each other.
|
Only a single pass is done so custom placeholders will not work within each other.
|
||||||
""")
|
""")
|
||||||
private Map<String, String> customPlaceholders = Map.of();
|
private final Map<String, String> customPlaceholders = Map.of();
|
||||||
|
|
||||||
@Comment("Various settings related to pinging players in channels.")
|
@Comment("Various settings related to pinging players in channels.")
|
||||||
private PingSettings pingSettings = new PingSettings();
|
private final PingSettings pingSettings = new PingSettings();
|
||||||
|
|
||||||
private MessagingSettings messagingSettings = new MessagingSettings();
|
private final MessagingSettings messagingSettings = new MessagingSettings();
|
||||||
|
|
||||||
public Locale defaultLocale() {
|
public Locale defaultLocale() {
|
||||||
return this.defaultLocale;
|
return this.defaultLocale;
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public class MessagingManager {
|
|||||||
this.messagingService = builder.build();
|
this.messagingService = builder.build();
|
||||||
}
|
}
|
||||||
case NONE -> throw new IllegalStateException("MessagingManager initialized with no messaging broker selected!");
|
case NONE -> throw new IllegalStateException("MessagingManager initialized with no messaging broker selected!");
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BrokerType {
|
public enum BrokerType {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ tasks {
|
|||||||
bukkit {
|
bukkit {
|
||||||
name = rootProject.name
|
name = rootProject.name
|
||||||
version = project.version as String
|
version = project.version as String
|
||||||
main = "net.draycia.carbon.bukkit.CarbonChatBukkit"
|
main = "net.draycia.carbon.paper.CarbonChatPaper"
|
||||||
apiVersion = "1.18"
|
apiVersion = "1.18"
|
||||||
author = "Draycia"
|
author = "Draycia"
|
||||||
depend = listOf("LuckPerms")
|
depend = listOf("LuckPerms")
|
||||||
+16
-17
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit;
|
package net.draycia.carbon.paper;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
@@ -36,11 +36,6 @@ import net.draycia.carbon.api.channels.ChannelRegistry;
|
|||||||
import net.draycia.carbon.api.events.CarbonEventHandler;
|
import net.draycia.carbon.api.events.CarbonEventHandler;
|
||||||
import net.draycia.carbon.api.users.UserManager;
|
import net.draycia.carbon.api.users.UserManager;
|
||||||
import net.draycia.carbon.api.util.RenderedMessage;
|
import net.draycia.carbon.api.util.RenderedMessage;
|
||||||
import net.draycia.carbon.bukkit.listeners.BukkitChatListener;
|
|
||||||
import net.draycia.carbon.bukkit.listeners.BukkitPlayerJoinListener;
|
|
||||||
import net.draycia.carbon.bukkit.listeners.DiscordMessageListener;
|
|
||||||
import net.draycia.carbon.bukkit.util.BukkitMessageRenderer;
|
|
||||||
import net.draycia.carbon.bukkit.util.CarbonChatHook;
|
|
||||||
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
|
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
|
||||||
import net.draycia.carbon.common.listeners.RadiusListener;
|
import net.draycia.carbon.common.listeners.RadiusListener;
|
||||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||||
@@ -49,6 +44,10 @@ import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
|||||||
import net.draycia.carbon.common.util.CloudUtils;
|
import net.draycia.carbon.common.util.CloudUtils;
|
||||||
import net.draycia.carbon.common.util.ListenerUtils;
|
import net.draycia.carbon.common.util.ListenerUtils;
|
||||||
import net.draycia.carbon.common.util.PlayerUtils;
|
import net.draycia.carbon.common.util.PlayerUtils;
|
||||||
|
import net.draycia.carbon.paper.listeners.DiscordMessageListener;
|
||||||
|
import net.draycia.carbon.paper.listeners.PaperChatListener;
|
||||||
|
import net.draycia.carbon.paper.listeners.PaperPlayerJoinListener;
|
||||||
|
import net.draycia.carbon.paper.util.PaperMessageRenderer;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.moonshine.message.IMessageRenderer;
|
import net.kyori.moonshine.message.IMessageRenderer;
|
||||||
@@ -66,18 +65,18 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
public final class CarbonChatPaper extends JavaPlugin implements CarbonChat {
|
||||||
|
|
||||||
private static final Set<Class<? extends Listener>> LISTENER_CLASSES = Set.of(
|
private static final Set<Class<? extends Listener>> LISTENER_CLASSES = Set.of(
|
||||||
BukkitChatListener.class,
|
PaperChatListener.class,
|
||||||
BukkitPlayerJoinListener.class
|
PaperPlayerJoinListener.class
|
||||||
);
|
);
|
||||||
private static final int BSTATS_PLUGIN_ID = 8720;
|
private static final int BSTATS_PLUGIN_ID = 8720;
|
||||||
private final CarbonEventHandler eventHandler = new CarbonEventHandler();
|
private final CarbonEventHandler eventHandler = new CarbonEventHandler();
|
||||||
private @MonotonicNonNull Injector injector;
|
private @MonotonicNonNull Injector injector;
|
||||||
private @MonotonicNonNull UserManager<CarbonPlayerCommon> userManager;
|
private @MonotonicNonNull UserManager<CarbonPlayerCommon> userManager;
|
||||||
private @MonotonicNonNull Logger logger;
|
private @MonotonicNonNull Logger logger;
|
||||||
private @MonotonicNonNull CarbonServerBukkit carbonServerBukkit;
|
private @MonotonicNonNull CarbonServerPaper carbonServerPaper;
|
||||||
private @MonotonicNonNull CarbonMessages carbonMessages;
|
private @MonotonicNonNull CarbonMessages carbonMessages;
|
||||||
private @MonotonicNonNull ChannelRegistry channelRegistry;
|
private @MonotonicNonNull ChannelRegistry channelRegistry;
|
||||||
private final UUID serverId = UUID.randomUUID();
|
private final UUID serverId = UUID.randomUUID();
|
||||||
@@ -99,11 +98,11 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
|||||||
|
|
||||||
CarbonChatProvider.register(this);
|
CarbonChatProvider.register(this);
|
||||||
|
|
||||||
this.injector = Guice.createInjector(new CarbonChatBukkitModule(this, this.dataDirectory()));
|
this.injector = Guice.createInjector(new CarbonChatPaperModule(this, this.dataDirectory()));
|
||||||
this.logger = LogManager.getLogger("CarbonChat");
|
this.logger = LogManager.getLogger("CarbonChat");
|
||||||
this.carbonMessages = this.injector.getInstance(CarbonMessages.class);
|
this.carbonMessages = this.injector.getInstance(CarbonMessages.class);
|
||||||
this.channelRegistry = this.injector.getInstance(ChannelRegistry.class);
|
this.channelRegistry = this.injector.getInstance(ChannelRegistry.class);
|
||||||
this.carbonServerBukkit = this.injector.getInstance(CarbonServerBukkit.class);
|
this.carbonServerPaper = this.injector.getInstance(CarbonServerPaper.class);
|
||||||
this.userManager = this.injector.getInstance(com.google.inject.Key.get(new TypeLiteral<UserManager<CarbonPlayerCommon>>() {}));
|
this.userManager = this.injector.getInstance(com.google.inject.Key.get(new TypeLiteral<UserManager<CarbonPlayerCommon>>() {}));
|
||||||
|
|
||||||
this.packetService();
|
this.packetService();
|
||||||
@@ -134,7 +133,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
|||||||
final long saveDelay = 5 * 60 * 20;
|
final long saveDelay = 5 * 60 * 20;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this,
|
Bukkit.getScheduler().runTaskTimerAsynchronously(this,
|
||||||
() -> PlayerUtils.saveLoggedInPlayers(this.carbonServerBukkit, this.userManager), saveDelay, saveDelay);
|
() -> PlayerUtils.saveLoggedInPlayers(this.carbonServerPaper, this.userManager), saveDelay, saveDelay);
|
||||||
|
|
||||||
// Load channels
|
// Load channels
|
||||||
((CarbonChannelRegistry) this.channelRegistry()).loadConfigChannels(this.carbonMessages);
|
((CarbonChannelRegistry) this.channelRegistry()).loadConfigChannels(this.carbonMessages);
|
||||||
@@ -157,7 +156,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
PlayerUtils.saveLoggedInPlayers(this.carbonServerBukkit, this.userManager).forEach(CompletableFuture::join);
|
PlayerUtils.saveLoggedInPlayers(this.carbonServerPaper, this.userManager).forEach(CompletableFuture::join);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -185,8 +184,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CarbonServerBukkit server() {
|
public CarbonServerPaper server() {
|
||||||
return this.carbonServerBukkit;
|
return this.carbonServerPaper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -205,7 +204,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMessageRenderer<Audience, String, RenderedMessage, Component> messageRenderer() {
|
public IMessageRenderer<Audience, String, RenderedMessage, Component> messageRenderer() {
|
||||||
return this.injector.getInstance(BukkitMessageRenderer.class);
|
return this.injector.getInstance(PaperMessageRenderer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean papiLoaded() {
|
public boolean papiLoaded() {
|
||||||
+15
-15
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit;
|
package net.draycia.carbon.paper;
|
||||||
|
|
||||||
import cloud.commandframework.CommandManager;
|
import cloud.commandframework.CommandManager;
|
||||||
import cloud.commandframework.brigadier.CloudBrigadierManager;
|
import cloud.commandframework.brigadier.CloudBrigadierManager;
|
||||||
@@ -33,14 +33,14 @@ import net.draycia.carbon.api.CarbonChat;
|
|||||||
import net.draycia.carbon.api.CarbonServer;
|
import net.draycia.carbon.api.CarbonServer;
|
||||||
import net.draycia.carbon.api.util.RenderedMessage;
|
import net.draycia.carbon.api.util.RenderedMessage;
|
||||||
import net.draycia.carbon.api.util.SourcedAudience;
|
import net.draycia.carbon.api.util.SourcedAudience;
|
||||||
import net.draycia.carbon.bukkit.command.BukkitCommander;
|
|
||||||
import net.draycia.carbon.bukkit.command.BukkitPlayerCommander;
|
|
||||||
import net.draycia.carbon.bukkit.util.BukkitMessageRenderer;
|
|
||||||
import net.draycia.carbon.common.CarbonCommonModule;
|
import net.draycia.carbon.common.CarbonCommonModule;
|
||||||
import net.draycia.carbon.common.ForCarbon;
|
import net.draycia.carbon.common.ForCarbon;
|
||||||
import net.draycia.carbon.common.command.Commander;
|
import net.draycia.carbon.common.command.Commander;
|
||||||
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
import net.draycia.carbon.common.command.argument.PlayerSuggestions;
|
||||||
import net.draycia.carbon.common.util.CloudUtils;
|
import net.draycia.carbon.common.util.CloudUtils;
|
||||||
|
import net.draycia.carbon.paper.command.PaperCommander;
|
||||||
|
import net.draycia.carbon.paper.command.PaperPlayerCommander;
|
||||||
|
import net.draycia.carbon.paper.util.PaperMessageRenderer;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.moonshine.message.IMessageRenderer;
|
import net.kyori.moonshine.message.IMessageRenderer;
|
||||||
@@ -52,14 +52,14 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public final class CarbonChatBukkitModule extends AbstractModule {
|
public final class CarbonChatPaperModule extends AbstractModule {
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger("CarbonChat");
|
private final Logger logger = LogManager.getLogger("CarbonChat");
|
||||||
private final CarbonChatBukkit carbonChat;
|
private final CarbonChatPaper carbonChat;
|
||||||
private final Path dataDirectory;
|
private final Path dataDirectory;
|
||||||
|
|
||||||
CarbonChatBukkitModule(
|
CarbonChatPaperModule(
|
||||||
final CarbonChatBukkit carbonChat,
|
final CarbonChatPaper carbonChat,
|
||||||
final Path dataDirectory
|
final Path dataDirectory
|
||||||
) {
|
) {
|
||||||
this.carbonChat = carbonChat;
|
this.carbonChat = carbonChat;
|
||||||
@@ -77,11 +77,11 @@ public final class CarbonChatBukkitModule extends AbstractModule {
|
|||||||
AsynchronousCommandExecutionCoordinator.<Commander>newBuilder().build(),
|
AsynchronousCommandExecutionCoordinator.<Commander>newBuilder().build(),
|
||||||
commandSender -> {
|
commandSender -> {
|
||||||
if (commandSender instanceof Player player) {
|
if (commandSender instanceof Player player) {
|
||||||
return new BukkitPlayerCommander(this.carbonChat, player);
|
return new PaperPlayerCommander(this.carbonChat, player);
|
||||||
}
|
}
|
||||||
return BukkitCommander.from(commandSender);
|
return PaperCommander.from(commandSender);
|
||||||
},
|
},
|
||||||
commander -> ((BukkitCommander) commander).commandSender()
|
commander -> ((PaperCommander) commander).commandSender()
|
||||||
);
|
);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
throw new RuntimeException("Failed to initialize command manager.", ex);
|
throw new RuntimeException("Failed to initialize command manager.", ex);
|
||||||
@@ -105,13 +105,13 @@ public final class CarbonChatBukkitModule extends AbstractModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public IMessageRenderer<Audience, String, RenderedMessage, Component> messageRenderer(final Injector injector) {
|
public IMessageRenderer<Audience, String, RenderedMessage, Component> messageRenderer(final Injector injector) {
|
||||||
return injector.getInstance(BukkitMessageRenderer.class);
|
return injector.getInstance(PaperMessageRenderer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public IMessageRenderer<SourcedAudience, String, RenderedMessage, Component> sourcedRenderer(final Injector injector) {
|
public IMessageRenderer<SourcedAudience, String, RenderedMessage, Component> sourcedRenderer(final Injector injector) {
|
||||||
return injector.getInstance(BukkitMessageRenderer.class);
|
return injector.getInstance(PaperMessageRenderer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -119,10 +119,10 @@ public final class CarbonChatBukkitModule extends AbstractModule {
|
|||||||
this.install(new CarbonCommonModule());
|
this.install(new CarbonCommonModule());
|
||||||
|
|
||||||
this.bind(CarbonChat.class).toInstance(this.carbonChat);
|
this.bind(CarbonChat.class).toInstance(this.carbonChat);
|
||||||
this.bind(CarbonChatBukkit.class).toInstance(this.carbonChat);
|
this.bind(CarbonChatPaper.class).toInstance(this.carbonChat);
|
||||||
this.bind(Logger.class).toInstance(this.logger);
|
this.bind(Logger.class).toInstance(this.logger);
|
||||||
this.bind(Path.class).annotatedWith(ForCarbon.class).toInstance(this.dataDirectory);
|
this.bind(Path.class).annotatedWith(ForCarbon.class).toInstance(this.dataDirectory);
|
||||||
this.bind(CarbonServer.class).to(CarbonServerBukkit.class);
|
this.bind(CarbonServer.class).to(CarbonServerPaper.class);
|
||||||
this.bind(PlayerSuggestions.class).toInstance(new PlayerArgument.PlayerParser<Commander>()::suggestions);
|
this.bind(PlayerSuggestions.class).toInstance(new PlayerArgument.PlayerParser<Commander>()::suggestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
+13
-13
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit;
|
package net.draycia.carbon.paper;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
@@ -29,8 +29,8 @@ import net.draycia.carbon.api.CarbonServer;
|
|||||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||||
import net.draycia.carbon.api.users.UserManager;
|
import net.draycia.carbon.api.users.UserManager;
|
||||||
import net.draycia.carbon.bukkit.users.CarbonPlayerBukkit;
|
|
||||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||||
|
import net.draycia.carbon.paper.users.CarbonPlayerPaper;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.audience.ForwardingAudience;
|
import net.kyori.adventure.audience.ForwardingAudience;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -41,33 +41,33 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public final class CarbonServerBukkit implements CarbonServer, ForwardingAudience.Single {
|
public final class CarbonServerPaper implements CarbonServer, ForwardingAudience.Single {
|
||||||
|
|
||||||
private final CarbonChatBukkit chatBukkitEntry;
|
private final CarbonChatPaper carbonChatPaper;
|
||||||
private final UserManager<CarbonPlayerBukkit> userManager;
|
private final UserManager<CarbonPlayerPaper> userManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CarbonServerBukkit(final CarbonChatBukkit chatBukkitEntry, final UserManager<CarbonPlayerCommon> userManager) {
|
private CarbonServerPaper(final CarbonChatPaper carbonChatPaper, final UserManager<CarbonPlayerCommon> userManager) {
|
||||||
this.chatBukkitEntry = chatBukkitEntry;
|
this.carbonChatPaper = carbonChatPaper;
|
||||||
this.userManager = new BukkitUserManager(userManager);
|
this.userManager = new PaperUserManager(userManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Audience audience() {
|
public Audience audience() {
|
||||||
return this.chatBukkitEntry.getServer();
|
return this.carbonChatPaper.getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Audience console() {
|
public Audience console() {
|
||||||
return this.chatBukkitEntry.getServer().getConsoleSender();
|
return this.carbonChatPaper.getServer().getConsoleSender();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends CarbonPlayer> players() {
|
public List<? extends CarbonPlayer> players() {
|
||||||
final var players = new ArrayList<CarbonPlayer>();
|
final var players = new ArrayList<CarbonPlayer>();
|
||||||
|
|
||||||
for (final var player : this.chatBukkitEntry.getServer().getOnlinePlayers()) {
|
for (final var player : this.carbonChatPaper.getServer().getOnlinePlayers()) {
|
||||||
final ComponentPlayerResult<CarbonPlayerBukkit> result = this.userManager.carbonPlayer(player.getUniqueId()).join();
|
final ComponentPlayerResult<CarbonPlayerPaper> result = this.userManager.carbonPlayer(player.getUniqueId()).join();
|
||||||
|
|
||||||
if (result.player() != null) {
|
if (result.player() != null) {
|
||||||
players.add(result.player());
|
players.add(result.player());
|
||||||
@@ -78,7 +78,7 @@ public final class CarbonServerBukkit implements CarbonServer, ForwardingAudienc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserManager<CarbonPlayerBukkit> userManager() {
|
public UserManager<CarbonPlayerPaper> userManager() {
|
||||||
return this.userManager;
|
return this.userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
+10
-10
@@ -17,15 +17,15 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit;
|
package net.draycia.carbon.paper;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||||
import net.draycia.carbon.api.users.UserManager;
|
import net.draycia.carbon.api.users.UserManager;
|
||||||
import net.draycia.carbon.bukkit.users.CarbonPlayerBukkit;
|
|
||||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||||
import net.draycia.carbon.common.users.SaveOnChange;
|
import net.draycia.carbon.common.users.SaveOnChange;
|
||||||
|
import net.draycia.carbon.paper.users.CarbonPlayerPaper;
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@@ -33,44 +33,44 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public class BukkitUserManager implements UserManager<CarbonPlayerBukkit>, SaveOnChange {
|
public class PaperUserManager implements UserManager<CarbonPlayerPaper>, SaveOnChange {
|
||||||
|
|
||||||
protected final UserManager<CarbonPlayerCommon> proxiedUserManager;
|
protected final UserManager<CarbonPlayerCommon> proxiedUserManager;
|
||||||
|
|
||||||
public BukkitUserManager(final UserManager<CarbonPlayerCommon> proxiedUserManager) {
|
public PaperUserManager(final UserManager<CarbonPlayerCommon> proxiedUserManager) {
|
||||||
this.proxiedUserManager = proxiedUserManager;
|
this.proxiedUserManager = proxiedUserManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<ComponentPlayerResult<CarbonPlayerBukkit>> carbonPlayer(final UUID uuid) {
|
public CompletableFuture<ComponentPlayerResult<CarbonPlayerPaper>> carbonPlayer(final UUID uuid) {
|
||||||
return this.proxiedUserManager.carbonPlayer(uuid).thenApply(result -> {
|
return this.proxiedUserManager.carbonPlayer(uuid).thenApply(result -> {
|
||||||
if (result.player() == null) {
|
if (result.player() == null) {
|
||||||
return new ComponentPlayerResult<>(null, result.reason());
|
return new ComponentPlayerResult<>(null, result.reason());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ComponentPlayerResult<>(new CarbonPlayerBukkit(result.player()), result.reason());
|
return new ComponentPlayerResult<>(new CarbonPlayerPaper(result.player()), result.reason());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<ComponentPlayerResult<CarbonPlayerBukkit>> savePlayer(final CarbonPlayerBukkit player) {
|
public CompletableFuture<ComponentPlayerResult<CarbonPlayerPaper>> savePlayer(final CarbonPlayerPaper player) {
|
||||||
return this.proxiedUserManager.savePlayer(player.carbonPlayerCommon()).thenApply(result -> {
|
return this.proxiedUserManager.savePlayer(player.carbonPlayerCommon()).thenApply(result -> {
|
||||||
if (result.player() == null) {
|
if (result.player() == null) {
|
||||||
return new ComponentPlayerResult<>(null, result.reason());
|
return new ComponentPlayerResult<>(null, result.reason());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ComponentPlayerResult<>(new CarbonPlayerBukkit(result.player()), result.reason());
|
return new ComponentPlayerResult<>(new CarbonPlayerPaper(result.player()), result.reason());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<ComponentPlayerResult<CarbonPlayerBukkit>> saveAndInvalidatePlayer(final CarbonPlayerBukkit player) {
|
public CompletableFuture<ComponentPlayerResult<CarbonPlayerPaper>> saveAndInvalidatePlayer(final CarbonPlayerPaper player) {
|
||||||
return this.proxiedUserManager.saveAndInvalidatePlayer(player.carbonPlayerCommon()).thenApply(result -> {
|
return this.proxiedUserManager.saveAndInvalidatePlayer(player.carbonPlayerCommon()).thenApply(result -> {
|
||||||
if (result.player() == null) {
|
if (result.player() == null) {
|
||||||
return new ComponentPlayerResult<>(null, result.reason());
|
return new ComponentPlayerResult<>(null, result.reason());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ComponentPlayerResult<>(new CarbonPlayerBukkit(result.player()), result.reason());
|
return new ComponentPlayerResult<>(new CarbonPlayerPaper(result.player()), result.reason());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
+5
-5
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit.command;
|
package net.draycia.carbon.paper.command;
|
||||||
|
|
||||||
import net.draycia.carbon.common.command.Commander;
|
import net.draycia.carbon.common.command.Commander;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
@@ -27,15 +27,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public interface BukkitCommander extends Commander, ForwardingAudience.Single {
|
public interface PaperCommander extends Commander, ForwardingAudience.Single {
|
||||||
|
|
||||||
static BukkitCommander from(final CommandSender sender) {
|
static PaperCommander from(final CommandSender sender) {
|
||||||
return new BukkitCommanderImpl(sender);
|
return new PaperCommanderImpl(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandSender commandSender();
|
CommandSender commandSender();
|
||||||
|
|
||||||
record BukkitCommanderImpl(CommandSender commandSender) implements BukkitCommander {
|
record PaperCommanderImpl(CommandSender commandSender) implements PaperCommander {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Audience audience() {
|
public Audience audience() {
|
||||||
+3
-3
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit.command;
|
package net.draycia.carbon.paper.command;
|
||||||
|
|
||||||
import net.draycia.carbon.api.CarbonChat;
|
import net.draycia.carbon.api.CarbonChat;
|
||||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||||
@@ -29,10 +29,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
public record BukkitPlayerCommander(
|
public record PaperPlayerCommander(
|
||||||
@NonNull CarbonChat carbon,
|
@NonNull CarbonChat carbon,
|
||||||
@NonNull Player player
|
@NonNull Player player
|
||||||
) implements PlayerCommander, BukkitCommander {
|
) implements PlayerCommander, PaperCommander {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull CommandSender commandSender() {
|
public @NonNull CommandSender commandSender() {
|
||||||
+3
-3
@@ -17,13 +17,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit.listeners;
|
package net.draycia.carbon.paper.listeners;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.draycia.carbon.api.CarbonChat;
|
import net.draycia.carbon.api.CarbonChat;
|
||||||
import net.draycia.carbon.bukkit.CarbonChatBukkit;
|
import net.draycia.carbon.paper.CarbonChatPaper;
|
||||||
import net.essentialsx.api.v2.events.discord.DiscordMessageEvent;
|
import net.essentialsx.api.v2.events.discord.DiscordMessageEvent;
|
||||||
import net.essentialsx.api.v2.events.discord.DiscordRelayEvent;
|
import net.essentialsx.api.v2.events.discord.DiscordRelayEvent;
|
||||||
import net.essentialsx.api.v2.services.discord.DiscordService;
|
import net.essentialsx.api.v2.services.discord.DiscordService;
|
||||||
@@ -81,7 +81,7 @@ public class DiscordMessageListener implements Listener {
|
|||||||
if (discord != null) {
|
if (discord != null) {
|
||||||
this.carbonChat.channelRegistry().forEach(channel -> {
|
this.carbonChat.channelRegistry().forEach(channel -> {
|
||||||
final MessageType channelMessageType = new MessageType(channel.key().value());
|
final MessageType channelMessageType = new MessageType(channel.key().value());
|
||||||
discord.registerMessageType((CarbonChatBukkit) this.carbonChat, channelMessageType);
|
discord.registerMessageType((CarbonChatPaper) this.carbonChat, channelMessageType);
|
||||||
this.channelMessageTypes.put(channel.key(), channelMessageType);
|
this.channelMessageTypes.put(channel.key(), channelMessageType);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+9
-9
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit.listeners;
|
package net.draycia.carbon.paper.listeners;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
@@ -30,8 +30,8 @@ import net.draycia.carbon.api.users.CarbonPlayer;
|
|||||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||||
import net.draycia.carbon.api.util.KeyedRenderer;
|
import net.draycia.carbon.api.util.KeyedRenderer;
|
||||||
import net.draycia.carbon.api.util.RenderedMessage;
|
import net.draycia.carbon.api.util.RenderedMessage;
|
||||||
import net.draycia.carbon.bukkit.CarbonChatBukkit;
|
import net.draycia.carbon.paper.CarbonChatPaper;
|
||||||
import net.draycia.carbon.bukkit.users.CarbonPlayerBukkit;
|
import net.draycia.carbon.paper.users.CarbonPlayerPaper;
|
||||||
import net.kyori.adventure.audience.MessageType;
|
import net.kyori.adventure.audience.MessageType;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
import net.kyori.adventure.text.TextReplacementConfig;
|
import net.kyori.adventure.text.TextReplacementConfig;
|
||||||
@@ -51,16 +51,16 @@ import static net.kyori.adventure.text.Component.empty;
|
|||||||
import static net.kyori.adventure.text.Component.text;
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public final class BukkitChatListener implements Listener {
|
public final class PaperChatListener implements Listener {
|
||||||
|
|
||||||
private final CarbonChatBukkit carbonChat;
|
private final CarbonChatPaper carbonChat;
|
||||||
private final ChannelRegistry registry;
|
private final ChannelRegistry registry;
|
||||||
|
|
||||||
private static final Pattern DEFAULT_URL_PATTERN = Pattern.compile("(?:(https?)://)?([-\\w_.]+\\.\\w{2,})(/\\S*)?");
|
private static final Pattern DEFAULT_URL_PATTERN = Pattern.compile("(?:(https?)://)?([-\\w_.]+\\.\\w{2,})(/\\S*)?");
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BukkitChatListener(final CarbonChat carbonChat, final ChannelRegistry registry) {
|
public PaperChatListener(final CarbonChat carbonChat, final ChannelRegistry registry) {
|
||||||
this.carbonChat = (CarbonChatBukkit) carbonChat;
|
this.carbonChat = (CarbonChatPaper) carbonChat;
|
||||||
this.registry = registry;
|
this.registry = registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public final class BukkitChatListener implements Listener {
|
|||||||
for (final var renderer : chatEvent.renderers()) {
|
for (final var renderer : chatEvent.renderers()) {
|
||||||
try {
|
try {
|
||||||
if (recipient instanceof Player player) {
|
if (recipient instanceof Player player) {
|
||||||
final ComponentPlayerResult<CarbonPlayerBukkit> targetPlayer = this.carbonChat.server().userManager().carbonPlayer(player.getUniqueId()).join();
|
final ComponentPlayerResult<CarbonPlayerPaper> targetPlayer = this.carbonChat.server().userManager().carbonPlayer(player.getUniqueId()).join();
|
||||||
|
|
||||||
renderedMessage = renderer.render(sender, targetPlayer.player(), renderedMessage.component(), chatEvent.message());
|
renderedMessage = renderer.render(sender, targetPlayer.player(), renderedMessage.component(), chatEvent.message());
|
||||||
} else {
|
} else {
|
||||||
@@ -162,7 +162,7 @@ public final class BukkitChatListener implements Listener {
|
|||||||
for (final var renderer : chatEvent.renderers()) {
|
for (final var renderer : chatEvent.renderers()) {
|
||||||
try {
|
try {
|
||||||
if (viewer instanceof Player player) {
|
if (viewer instanceof Player player) {
|
||||||
final ComponentPlayerResult<CarbonPlayerBukkit> targetPlayer = this.carbonChat.server().userManager().carbonPlayer(player.getUniqueId()).join();
|
final ComponentPlayerResult<CarbonPlayerPaper> targetPlayer = this.carbonChat.server().userManager().carbonPlayer(player.getUniqueId()).join();
|
||||||
renderedMessage = renderer.render(sender, targetPlayer.player(), renderedMessage.component(), message);
|
renderedMessage = renderer.render(sender, targetPlayer.player(), renderedMessage.component(), message);
|
||||||
} else {
|
} else {
|
||||||
renderedMessage = renderer.render(sender, viewer, renderedMessage.component(), message);
|
renderedMessage = renderer.render(sender, viewer, renderedMessage.component(), message);
|
||||||
+5
-5
@@ -17,14 +17,14 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit.listeners;
|
package net.draycia.carbon.paper.listeners;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import net.draycia.carbon.api.CarbonChat;
|
import net.draycia.carbon.api.CarbonChat;
|
||||||
import net.draycia.carbon.api.users.UserManager;
|
import net.draycia.carbon.api.users.UserManager;
|
||||||
import net.draycia.carbon.bukkit.users.CarbonPlayerBukkit;
|
|
||||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||||
import net.draycia.carbon.common.util.PlayerUtils;
|
import net.draycia.carbon.common.util.PlayerUtils;
|
||||||
|
import net.draycia.carbon.paper.users.CarbonPlayerPaper;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -33,13 +33,13 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public class BukkitPlayerJoinListener implements Listener {
|
public class PaperPlayerJoinListener implements Listener {
|
||||||
|
|
||||||
private final CarbonChat carbonChat;
|
private final CarbonChat carbonChat;
|
||||||
private final UserManager<CarbonPlayerCommon> userManager;
|
private final UserManager<CarbonPlayerCommon> userManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BukkitPlayerJoinListener(
|
public PaperPlayerJoinListener(
|
||||||
final CarbonChat carbonChat,
|
final CarbonChat carbonChat,
|
||||||
final UserManager<CarbonPlayerCommon> userManager
|
final UserManager<CarbonPlayerCommon> userManager
|
||||||
) {
|
) {
|
||||||
@@ -54,7 +54,7 @@ public class BukkitPlayerJoinListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerBukkit) result.player());
|
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerPaper) result.player());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
+3
-3
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit.users;
|
package net.draycia.carbon.paper.users;
|
||||||
|
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -44,11 +44,11 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public final class CarbonPlayerBukkit extends WrappedCarbonPlayer implements ForwardingAudience.Single {
|
public final class CarbonPlayerPaper extends WrappedCarbonPlayer implements ForwardingAudience.Single {
|
||||||
|
|
||||||
private final CarbonPlayerCommon carbonPlayerCommon;
|
private final CarbonPlayerCommon carbonPlayerCommon;
|
||||||
|
|
||||||
public CarbonPlayerBukkit(final CarbonPlayerCommon carbonPlayerCommon) {
|
public CarbonPlayerPaper(final CarbonPlayerCommon carbonPlayerCommon) {
|
||||||
this.carbonPlayerCommon = carbonPlayerCommon;
|
this.carbonPlayerCommon = carbonPlayerCommon;
|
||||||
}
|
}
|
||||||
|
|
||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit.util;
|
package net.draycia.carbon.paper.util;
|
||||||
|
|
||||||
import github.scarsz.discordsrv.Debug;
|
import github.scarsz.discordsrv.Debug;
|
||||||
import github.scarsz.discordsrv.DiscordSRV;
|
import github.scarsz.discordsrv.DiscordSRV;
|
||||||
+5
-5
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit.util;
|
package net.draycia.carbon.paper.util;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -27,9 +27,9 @@ import net.draycia.carbon.api.CarbonChatProvider;
|
|||||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||||
import net.draycia.carbon.api.util.RenderedMessage;
|
import net.draycia.carbon.api.util.RenderedMessage;
|
||||||
import net.draycia.carbon.api.util.SourcedAudience;
|
import net.draycia.carbon.api.util.SourcedAudience;
|
||||||
import net.draycia.carbon.bukkit.CarbonChatBukkit;
|
|
||||||
import net.draycia.carbon.common.config.ConfigFactory;
|
import net.draycia.carbon.common.config.ConfigFactory;
|
||||||
import net.draycia.carbon.common.util.ChatType;
|
import net.draycia.carbon.common.util.ChatType;
|
||||||
|
import net.draycia.carbon.paper.CarbonChatPaper;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.audience.MessageType;
|
import net.kyori.adventure.audience.MessageType;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@@ -44,7 +44,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public class BukkitMessageRenderer<T extends Audience> implements IMessageRenderer<T, String, RenderedMessage, Component> {
|
public class PaperMessageRenderer<T extends Audience> implements IMessageRenderer<T, String, RenderedMessage, Component> {
|
||||||
|
|
||||||
private @MonotonicNonNull PlaceholderAPIMiniMessageParser parser = null;
|
private @MonotonicNonNull PlaceholderAPIMiniMessageParser parser = null;
|
||||||
|
|
||||||
@@ -52,11 +52,11 @@ public class BukkitMessageRenderer<T extends Audience> implements IMessageRender
|
|||||||
private final ConfigFactory configFactory;
|
private final ConfigFactory configFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BukkitMessageRenderer(final ConfigFactory configFactory) {
|
public PaperMessageRenderer(final ConfigFactory configFactory) {
|
||||||
this.miniMessage = MiniMessage.miniMessage();
|
this.miniMessage = MiniMessage.miniMessage();
|
||||||
this.configFactory = configFactory;
|
this.configFactory = configFactory;
|
||||||
|
|
||||||
if (((CarbonChatBukkit) CarbonChatProvider.carbonChat()).papiLoaded()) {
|
if (((CarbonChatPaper) CarbonChatProvider.carbonChat()).papiLoaded()) {
|
||||||
this.parser = PlaceholderAPIMiniMessageParser.create(MiniMessage.miniMessage());
|
this.parser = PlaceholderAPIMiniMessageParser.create(MiniMessage.miniMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.draycia.carbon.bukkit.util;
|
package net.draycia.carbon.paper.util;
|
||||||
|
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
+1
-1
@@ -72,7 +72,7 @@ rootProject.name = "CarbonChat"
|
|||||||
sequenceOf(
|
sequenceOf(
|
||||||
"api",
|
"api",
|
||||||
"common",
|
"common",
|
||||||
"bukkit",
|
"paper",
|
||||||
"sponge",
|
"sponge",
|
||||||
"fabric",
|
"fabric",
|
||||||
"velocity"
|
"velocity"
|
||||||
|
|||||||
Reference in new issue
Block a user