mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
It compiles!
This commit is contained in:
1 parent
3a69d0d74b
commit
3878be3563
6 files changed
+110
-26
No files matched your search
@@ -1,20 +1,30 @@
|
||||
package net.draycia.carbon.api.config;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.objectmapping.Setting;
|
||||
import org.spongepowered.configurate.serialize.ConfigSerializable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ConfigSerializable
|
||||
public class CarbonSettings {
|
||||
|
||||
private @NonNull String spyPrefix;
|
||||
private @NonNull String serverName;
|
||||
private boolean showTips;
|
||||
private @NonNull List<@NonNull ChannelSettings> channelSettings;
|
||||
private @Nullable StorageType storageType;
|
||||
private @NonNull SQLCredentials sqlCredentials;
|
||||
private @NonNull Map<@Nullable String, @NonNull String> customPlaceholders;
|
||||
@Setting private @NonNull String spyPrefix = "<color>[SPY] ";
|
||||
@Setting private @NonNull String serverName = "Server";
|
||||
@Setting private boolean showTips = true;
|
||||
@Setting private @NonNull List<@NonNull ChannelSettings> channelSettings; // TODO: unfuck this, it's loaded from file?
|
||||
@Setting private @Nullable StorageType storageType = StorageType.JSON;
|
||||
@Setting private @NonNull SQLCredentials sqlCredentials =
|
||||
new SQLCredentials("username", "password", "db", "localhost", 3306);
|
||||
@Setting private @NonNull Map<@Nullable String, @NonNull String> customPlaceholders = new HashMap<>();
|
||||
@Setting private @NonNull Pings pings = new Pings();
|
||||
@Setting private @NonNull WhisperPings whisperPings = new WhisperPings();
|
||||
@Setting private @Nullable String channelOnJoin = "";
|
||||
|
||||
public @NonNull String spyPrefix() {
|
||||
return this.spyPrefix;
|
||||
@@ -44,9 +54,89 @@ public class CarbonSettings {
|
||||
return this.customPlaceholders;
|
||||
}
|
||||
|
||||
public @Nullable String channelOnJoin() {
|
||||
return this.channelOnJoin;
|
||||
}
|
||||
|
||||
public @NonNull Pings pings() {
|
||||
return this.pings;
|
||||
}
|
||||
|
||||
public @NonNull WhisperPings whisperPings() {
|
||||
return this.whisperPings;
|
||||
}
|
||||
|
||||
public enum StorageType {
|
||||
MYSQL,
|
||||
JSON
|
||||
}
|
||||
|
||||
@ConfigSerializable
|
||||
public final class WhisperPings {
|
||||
@Setting private boolean enabled = true;
|
||||
@Setting private @NonNull Key sound = Key.of(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup");
|
||||
@Setting private Sound.Source source = Sound.Source.PLAYER;
|
||||
@Setting private float volume = 10.0F;
|
||||
@Setting private float pitch = 1.0F;
|
||||
|
||||
public boolean enabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public Key sound() {
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
public Sound.Source source() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
public float volume() {
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
public float pitch() {
|
||||
return this.pitch;
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigSerializable
|
||||
public final class Pings {
|
||||
@Setting private boolean enabled = true;
|
||||
@Setting private @NonNull String prefix = "";
|
||||
@Setting private boolean caseSensitive = false;
|
||||
@Setting private @NonNull Key sound = Key.of(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup");
|
||||
@Setting private Sound.Source source = Sound.Source.PLAYER;
|
||||
@Setting private float volume = 10.0F;
|
||||
@Setting private float pitch = 1.0F;
|
||||
|
||||
public boolean enabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public String prefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
public boolean caseSensitive() {
|
||||
return this.caseSensitive;
|
||||
}
|
||||
|
||||
public Key sound() {
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
public Sound.Source source() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
public float volume() {
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
public float pitch() {
|
||||
return this.pitch;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,13 +20,9 @@
|
||||
*/
|
||||
package net.draycia.carbon.util;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeCordComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
@@ -37,7 +33,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
+7
-7
@@ -14,7 +14,7 @@ public class PingHandler {
|
||||
final CarbonChat carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
CarbonEvents.register(ChatComponentEvent.class, PostOrders.LAST, false, event -> {
|
||||
if (!carbonChat.getConfig().getBoolean("pings.enabled")) {
|
||||
if (!carbonChat.carbonSettings().pings().enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ public class PingHandler {
|
||||
}
|
||||
|
||||
final String targetName = event.target().name();
|
||||
final String prefix = carbonChat.getConfig().getString("pings.prefix", "");
|
||||
final boolean caseSensitive = carbonChat.getConfig().getBoolean("pings.case-sensitive", false);
|
||||
final String prefix = carbonChat.carbonSettings().pings().prefix();
|
||||
final boolean caseSensitive = carbonChat.carbonSettings().pings().caseSensitive();
|
||||
|
||||
if (caseSensitive) {
|
||||
if (!event.originalMessage().contains(prefix + targetName)) {
|
||||
@@ -36,10 +36,10 @@ public class PingHandler {
|
||||
}
|
||||
}
|
||||
|
||||
final Key key = Key.of(carbonChat.getConfig().getString("pings.sound"));
|
||||
final Sound.Source source = Sound.Source.valueOf(carbonChat.getConfig().getString("pings.source"));
|
||||
final float volume = (float) carbonChat.getConfig().getDouble("pings.volume");
|
||||
final float pitch = (float) carbonChat.getConfig().getDouble("pings.pitch");
|
||||
final Key key = carbonChat.carbonSettings().pings().sound();
|
||||
final Sound.Source source = carbonChat.carbonSettings().pings().source();
|
||||
final float volume = carbonChat.carbonSettings().pings().volume();
|
||||
final float pitch = carbonChat.carbonSettings().pings().pitch();
|
||||
|
||||
event.target().playSound(Sound.of(key, source, volume, pitch));
|
||||
});
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class PlayerJoinListener {
|
||||
user.nickname(user.nickname());
|
||||
}
|
||||
|
||||
final String channel = carbonChat.getConfig().getString("channel-on-join");
|
||||
final String channel = carbonChat.carbonSettings().channelOnJoin();
|
||||
|
||||
if (channel == null || channel.isEmpty()) {
|
||||
return;
|
||||
|
||||
+5
-5
@@ -22,14 +22,14 @@ public class WhisperPingHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!carbonChat.getConfig().getBoolean("whisper.pings.enabled")) {
|
||||
if (!carbonChat.carbonSettings().whisperPings().enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Key key = Key.of(carbonChat.getConfig().getString("whisper.pings.sound"));
|
||||
final Sound.Source source = Sound.Source.valueOf(carbonChat.getConfig().getString("whisper.pings.source"));
|
||||
final float volume = (float) carbonChat.getConfig().getDouble("whisper.pings.volume");
|
||||
final float pitch = (float) carbonChat.getConfig().getDouble("whisper.pings.pitch");
|
||||
final Key key = carbonChat.carbonSettings().whisperPings().sound();
|
||||
final Sound.Source source = carbonChat.carbonSettings().whisperPings().source();
|
||||
final float volume = carbonChat.carbonSettings().whisperPings().volume();
|
||||
final float pitch = carbonChat.carbonSettings().whisperPings().pitch();
|
||||
|
||||
event.sender().playSound(Sound.of(key, source, volume, pitch));
|
||||
});
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
Reference in new issue
Block a user