mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
Cleanup and bug fixes
This commit is contained in:
1 parent
947b3f9317
commit
e0760fe84d
10 files changed
+64
-62
No files matched your search
@@ -11,13 +11,8 @@ import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class SimpleChat extends JavaPlugin {
|
||||
|
||||
private final List<Pattern> itemPatterns = new ArrayList<>();
|
||||
|
||||
private Permission permission;
|
||||
|
||||
private PluginMessageManager pluginMessageManager;
|
||||
@@ -71,7 +66,6 @@ public final class SimpleChat extends JavaPlugin {
|
||||
|
||||
// Setup listeners
|
||||
setupListeners();
|
||||
reloadPatterns();
|
||||
registerContexts();
|
||||
}
|
||||
|
||||
@@ -94,14 +88,6 @@ public final class SimpleChat extends JavaPlugin {
|
||||
pluginManager.registerEvents(new UserFormattingListener(), this);
|
||||
}
|
||||
|
||||
public void reloadPatterns() {
|
||||
itemPatterns.clear();
|
||||
|
||||
for (String entry : getConfig().getStringList("item-link-placeholders")) {
|
||||
itemPatterns.add(Pattern.compile(Pattern.quote(entry)));
|
||||
}
|
||||
}
|
||||
|
||||
private void registerContexts() {
|
||||
getContextManager().register("distance", new DistanceContext());
|
||||
}
|
||||
|
||||
-2
@@ -4,14 +4,12 @@ import net.draycia.simplechat.SimpleChat;
|
||||
import net.draycia.simplechat.channels.ChatChannel;
|
||||
import net.draycia.simplechat.events.ChatComponentEvent;
|
||||
import net.draycia.simplechat.events.ChatFormatEvent;
|
||||
import net.draycia.simplechat.managers.ContextManager;
|
||||
import net.draycia.simplechat.storage.ChatUser;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -20,14 +20,12 @@ public class SetColorCommand extends BaseCommand {
|
||||
@Default
|
||||
@CommandCompletion("@chatchannel")
|
||||
public void baseCommand(Player player, @Conditions("canuse:true") ChatChannel channel, String color) {
|
||||
// TODO: condition for ChatChannel existing
|
||||
if (channel == null || color == null) {
|
||||
throw new ConditionFailedException("Channel or Color not supplied!");
|
||||
}
|
||||
|
||||
ChatUser user = simpleChat.getUserService().wrap(player);
|
||||
|
||||
// TODO: move into conditions
|
||||
if (!player.hasPermission("simplechat.setcolor." + channel.getName())) {
|
||||
throw new ConditionFailedException("You can't set colors for this channel!");
|
||||
}
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import net.draycia.simplechat.util.Registry;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,7 +15,7 @@ public class ChannelRegisterEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChannelSwitchEvent extends Event implements Cancellable {
|
||||
|
||||
@@ -14,7 +15,7 @@ public class ChannelSwitchEvent extends Event implements Cancellable {
|
||||
private boolean cancelled = false;
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PrivateMessageEvent extends Event {
|
||||
|
||||
@@ -12,7 +13,7 @@ public class PrivateMessageEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -45,12 +45,16 @@ public class PluginMessageManager implements PluginMessageListener {
|
||||
|
||||
ByteArrayDataInput msg = ByteStreams.newDataInput(msgbytes);
|
||||
|
||||
if (subchannel.equals("simplechat:message")) {
|
||||
onMessageReceived(msg);
|
||||
} else if (subchannel.equals("simplechat:component")) {
|
||||
onComponentReceived(msg);
|
||||
} else if (subchannel.equals("simplechat:whisper")) {
|
||||
onWhisperReceived(msg);
|
||||
switch (subchannel) {
|
||||
case "simplechat:message":
|
||||
onMessageReceived(msg);
|
||||
break;
|
||||
case "simplechat:component":
|
||||
onComponentReceived(msg);
|
||||
break;
|
||||
case "simplechat:whisper":
|
||||
onWhisperReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user