mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +00:00
Fixes round 3000
This commit is contained in:
1 parent
58477c0b6a
commit
569cd78748
15 files changed
+583
-54
No files matched your search
@@ -4,9 +4,11 @@ import com.palmergames.bukkit.towny.TownyAPI;
|
|||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AllianceChatChannel extends SimpleChatChannel {
|
public class AllianceChatChannel extends SimpleChatChannel {
|
||||||
@@ -55,9 +57,142 @@ public class AllianceChatChannel extends SimpleChatChannel {
|
|||||||
return new AllianceChatChannel.Builder(name);
|
return new AllianceChatChannel.Builder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends SimpleChatChannel.Builder {
|
public static class Builder extends ChatChannel.Builder {
|
||||||
private Builder(String name) {
|
|
||||||
super(name);
|
private TextColor color = TextColor.of(255, 255, 255);
|
||||||
|
private long id = -1;
|
||||||
|
private Map<String, String> formats = new HashMap<>();
|
||||||
|
private String webhook = null;
|
||||||
|
private boolean isDefault = false;
|
||||||
|
private boolean ignorable = true;
|
||||||
|
private String name;
|
||||||
|
private double distance = -1;
|
||||||
|
private String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
|
||||||
|
private String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
|
||||||
|
private String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
|
||||||
|
private boolean forwardFormatting = true;
|
||||||
|
private boolean shouldBungee = false;
|
||||||
|
private boolean filterEnabled = true;
|
||||||
|
private boolean firstMatchingGroup = false;
|
||||||
|
|
||||||
|
Builder(String name) {
|
||||||
|
this.name = name.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel build(SimpleChat simpleChat) {
|
||||||
|
return new AllianceChatChannel(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, firstMatchingGroup, simpleChat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setColor(TextColor color) {
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setColor(String color) {
|
||||||
|
return setColor(TextColor.fromHexString(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setFormats(Map<String, String> formats) {
|
||||||
|
this.formats = formats;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setWebhook(String webhook) {
|
||||||
|
this.webhook = webhook;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setIsDefault(boolean aDefault) {
|
||||||
|
this.isDefault = aDefault;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setIgnorable(boolean ignorable) {
|
||||||
|
this.ignorable = ignorable;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setDistance(double distance) {
|
||||||
|
this.distance = distance;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setSwitchMessage(String switchMessage) {
|
||||||
|
this.switchMessage = switchMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setToggleOffMessage(String toggleOffMessage) {
|
||||||
|
this.toggleOffMessage = toggleOffMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setToggleOnMessage(String toggleOnMessage) {
|
||||||
|
this.toggleOnMessage = toggleOnMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setShouldForwardFormatting(boolean forwardFormatting) {
|
||||||
|
this.forwardFormatting = forwardFormatting;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setShouldBungee(boolean shouldBungee) {
|
||||||
|
this.shouldBungee = shouldBungee;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setFilterEnabled(boolean filterEnabled) {
|
||||||
|
this.filterEnabled = filterEnabled;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AllianceChatChannel.Builder setFirstMatchingGroup(boolean firstMatchingGroup) {
|
||||||
|
this.firstMatchingGroup = firstMatchingGroup;
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,11 @@ import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
|||||||
import com.palmergames.bukkit.towny.object.Nation;
|
import com.palmergames.bukkit.towny.object.Nation;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class NationChatChannel extends SimpleChatChannel {
|
public class NationChatChannel extends SimpleChatChannel {
|
||||||
@@ -54,9 +56,141 @@ public class NationChatChannel extends SimpleChatChannel {
|
|||||||
return new NationChatChannel.Builder(name);
|
return new NationChatChannel.Builder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends SimpleChatChannel.Builder {
|
public static class Builder extends ChatChannel.Builder {
|
||||||
private Builder(String name) {
|
|
||||||
super(name);
|
private TextColor color = TextColor.of(255, 255, 255);
|
||||||
|
private long id = -1;
|
||||||
|
private Map<String, String> formats = new HashMap<>();
|
||||||
|
private String webhook = null;
|
||||||
|
private boolean isDefault = false;
|
||||||
|
private boolean ignorable = true;
|
||||||
|
private String name;
|
||||||
|
private double distance = -1;
|
||||||
|
private String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
|
||||||
|
private String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
|
||||||
|
private String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
|
||||||
|
private boolean forwardFormatting = true;
|
||||||
|
private boolean shouldBungee = false;
|
||||||
|
private boolean filterEnabled = true;
|
||||||
|
private boolean firstMatchingGroup = false;
|
||||||
|
|
||||||
|
Builder(String name) {
|
||||||
|
this.name = name.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel build(SimpleChat simpleChat) {
|
||||||
|
return new NationChatChannel(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, firstMatchingGroup, simpleChat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setColor(TextColor color) {
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setColor(String color) {
|
||||||
|
return setColor(TextColor.fromHexString(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setFormats(Map<String, String> formats) {
|
||||||
|
this.formats = formats;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setWebhook(String webhook) {
|
||||||
|
this.webhook = webhook;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setIsDefault(boolean aDefault) {
|
||||||
|
this.isDefault = aDefault;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setIgnorable(boolean ignorable) {
|
||||||
|
this.ignorable = ignorable;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setDistance(double distance) {
|
||||||
|
this.distance = distance;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setSwitchMessage(String switchMessage) {
|
||||||
|
this.switchMessage = switchMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setToggleOffMessage(String toggleOffMessage) {
|
||||||
|
this.toggleOffMessage = toggleOffMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setToggleOnMessage(String toggleOnMessage) {
|
||||||
|
this.toggleOnMessage = toggleOnMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setShouldForwardFormatting(boolean forwardFormatting) {
|
||||||
|
this.forwardFormatting = forwardFormatting;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setShouldBungee(boolean shouldBungee) {
|
||||||
|
this.shouldBungee = shouldBungee;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setFilterEnabled(boolean filterEnabled) {
|
||||||
|
this.filterEnabled = filterEnabled;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NationChatChannel.Builder setFirstMatchingGroup(boolean firstMatchingGroup) {
|
||||||
|
this.firstMatchingGroup = firstMatchingGroup;
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package net.draycia.simplechat.channels.impls;
|
|||||||
|
|
||||||
import com.gmail.nossr50.api.PartyAPI;
|
import com.gmail.nossr50.api.PartyAPI;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PartyChatChannel extends SimpleChatChannel {
|
public class PartyChatChannel extends SimpleChatChannel {
|
||||||
@@ -35,9 +37,141 @@ public class PartyChatChannel extends SimpleChatChannel {
|
|||||||
return new PartyChatChannel.Builder(name);
|
return new PartyChatChannel.Builder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends SimpleChatChannel.Builder {
|
public static class Builder extends ChatChannel.Builder {
|
||||||
private Builder(String name) {
|
|
||||||
super(name);
|
private TextColor color = TextColor.of(255, 255, 255);
|
||||||
|
private long id = -1;
|
||||||
|
private Map<String, String> formats = new HashMap<>();
|
||||||
|
private String webhook = null;
|
||||||
|
private boolean isDefault = false;
|
||||||
|
private boolean ignorable = true;
|
||||||
|
private String name;
|
||||||
|
private double distance = -1;
|
||||||
|
private String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
|
||||||
|
private String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
|
||||||
|
private String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
|
||||||
|
private boolean forwardFormatting = true;
|
||||||
|
private boolean shouldBungee = false;
|
||||||
|
private boolean filterEnabled = true;
|
||||||
|
private boolean firstMatchingGroup = false;
|
||||||
|
|
||||||
|
Builder(String name) {
|
||||||
|
this.name = name.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel build(SimpleChat simpleChat) {
|
||||||
|
return new PartyChatChannel(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, firstMatchingGroup, simpleChat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setColor(TextColor color) {
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setColor(String color) {
|
||||||
|
return setColor(TextColor.fromHexString(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setFormats(Map<String, String> formats) {
|
||||||
|
this.formats = formats;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setWebhook(String webhook) {
|
||||||
|
this.webhook = webhook;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setIsDefault(boolean aDefault) {
|
||||||
|
this.isDefault = aDefault;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setIgnorable(boolean ignorable) {
|
||||||
|
this.ignorable = ignorable;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setDistance(double distance) {
|
||||||
|
this.distance = distance;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setSwitchMessage(String switchMessage) {
|
||||||
|
this.switchMessage = switchMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setToggleOffMessage(String toggleOffMessage) {
|
||||||
|
this.toggleOffMessage = toggleOffMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setToggleOnMessage(String toggleOnMessage) {
|
||||||
|
this.toggleOnMessage = toggleOnMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setShouldForwardFormatting(boolean forwardFormatting) {
|
||||||
|
this.forwardFormatting = forwardFormatting;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setShouldBungee(boolean shouldBungee) {
|
||||||
|
this.shouldBungee = shouldBungee;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setFilterEnabled(boolean filterEnabled) {
|
||||||
|
this.filterEnabled = filterEnabled;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PartyChatChannel.Builder setFirstMatchingGroup(boolean firstMatchingGroup) {
|
||||||
|
this.firstMatchingGroup = firstMatchingGroup;
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -258,14 +258,14 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender.isOnline()) {
|
||||||
if (getDistance() > 0 && targetPlayer.getLocation().distance(((Player)sender).getLocation()) > getDistance()) {
|
if (getDistance() > 0 && targetPlayer.getLocation().distance(sender.asPlayer().getLocation()) > getDistance()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isIgnorable() && sender != null) {
|
if (isIgnorable()) {
|
||||||
if (target.isIgnoringUser(sender.getUUID()) && !targetPlayer.hasPermission("simplechat.ignoreexempt")) {
|
if (target.isIgnoringUser(sender) && !targetPlayer.hasPermission("simplechat.ignoreexempt")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import com.palmergames.bukkit.towny.TownyAPI;
|
|||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class TownChatChannel extends SimpleChatChannel {
|
public class TownChatChannel extends SimpleChatChannel {
|
||||||
@@ -49,10 +51,143 @@ public class TownChatChannel extends SimpleChatChannel {
|
|||||||
return new TownChatChannel.Builder(name);
|
return new TownChatChannel.Builder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends SimpleChatChannel.Builder {
|
public static class Builder extends ChatChannel.Builder {
|
||||||
private Builder(String name) {
|
|
||||||
super(name);
|
private TextColor color = TextColor.of(255, 255, 255);
|
||||||
|
private long id = -1;
|
||||||
|
private Map<String, String> formats = new HashMap<>();
|
||||||
|
private String webhook = null;
|
||||||
|
private boolean isDefault = false;
|
||||||
|
private boolean ignorable = true;
|
||||||
|
private String name;
|
||||||
|
private double distance = -1;
|
||||||
|
private String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
|
||||||
|
private String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
|
||||||
|
private String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
|
||||||
|
private boolean forwardFormatting = true;
|
||||||
|
private boolean shouldBungee = false;
|
||||||
|
private boolean filterEnabled = true;
|
||||||
|
private boolean firstMatchingGroup = false;
|
||||||
|
|
||||||
|
Builder(String name) {
|
||||||
|
this.name = name.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel build(SimpleChat simpleChat) {
|
||||||
|
return new TownChatChannel(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, firstMatchingGroup, simpleChat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setColor(TextColor color) {
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setColor(String color) {
|
||||||
|
return setColor(TextColor.fromHexString(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setFormats(Map<String, String> formats) {
|
||||||
|
this.formats = formats;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setWebhook(String webhook) {
|
||||||
|
this.webhook = webhook;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setIsDefault(boolean aDefault) {
|
||||||
|
this.isDefault = aDefault;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setIgnorable(boolean ignorable) {
|
||||||
|
this.ignorable = ignorable;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setDistance(double distance) {
|
||||||
|
this.distance = distance;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setSwitchMessage(String switchMessage) {
|
||||||
|
this.switchMessage = switchMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setToggleOffMessage(String toggleOffMessage) {
|
||||||
|
this.toggleOffMessage = toggleOffMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setToggleOnMessage(String toggleOnMessage) {
|
||||||
|
this.toggleOnMessage = toggleOnMessage;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setShouldForwardFormatting(boolean forwardFormatting) {
|
||||||
|
this.forwardFormatting = forwardFormatting;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setShouldBungee(boolean shouldBungee) {
|
||||||
|
this.shouldBungee = shouldBungee;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setFilterEnabled(boolean filterEnabled) {
|
||||||
|
this.filterEnabled = filterEnabled;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TownChatChannel.Builder setFirstMatchingGroup(boolean firstMatchingGroup) {
|
||||||
|
this.firstMatchingGroup = firstMatchingGroup;
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,10 +22,14 @@ public class AliasedChannelCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Default
|
@Default
|
||||||
//@CommandAlias("channel %channelName")
|
|
||||||
public void baseCommand(Player player, @Optional String[] args) {
|
public void baseCommand(Player player, @Optional String[] args) {
|
||||||
ChatUser user = simpleChat.getUserService().wrap(player);
|
ChatUser user = simpleChat.getUserService().wrap(player);
|
||||||
|
|
||||||
|
if (!chatChannel.canPlayerUse(user)) {
|
||||||
|
// TODO: send message
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args == null || args.length == 0) {
|
if (args == null || args.length == 0) {
|
||||||
user.setSelectedChannel(getChatChannel());
|
user.setSelectedChannel(getChatChannel());
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import co.aikar.commands.annotation.Default;
|
|||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandAlias("ignore")
|
@CommandAlias("ignore")
|
||||||
@@ -23,9 +22,8 @@ public class IgnoreCommand extends BaseCommand {
|
|||||||
|
|
||||||
@Default
|
@Default
|
||||||
@CommandCompletion("@players")
|
@CommandCompletion("@players")
|
||||||
public void baseCommand(Player player, OfflinePlayer target) {
|
public void baseCommand(Player player, ChatUser targetUser) {
|
||||||
ChatUser user = simpleChat.getUserService().wrap(player);
|
ChatUser user = simpleChat.getUserService().wrap(player);
|
||||||
ChatUser targetUser = simpleChat.getUserService().wrap(target.getUniqueId());
|
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import co.aikar.commands.annotation.CommandPermission;
|
|||||||
import co.aikar.commands.annotation.Default;
|
import co.aikar.commands.annotation.Default;
|
||||||
import net.draycia.simplechat.SimpleChat;
|
import net.draycia.simplechat.SimpleChat;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandAlias("msg|whisper|message|w")
|
@CommandAlias("msg|whisper|message|w")
|
||||||
@@ -22,10 +21,8 @@ public class MessageCommand extends BaseCommand {
|
|||||||
|
|
||||||
@Default
|
@Default
|
||||||
@CommandCompletion("@players")
|
@CommandCompletion("@players")
|
||||||
public void baseCommand(Player player, String target, String... args) {
|
public void baseCommand(Player player, ChatUser targetUser, String... args) {
|
||||||
ChatUser sender = simpleChat.getUserService().wrap(player);
|
ChatUser sender = simpleChat.getUserService().wrap(player);
|
||||||
ChatUser targetUser = simpleChat.getUserService().wrap(Bukkit.getOfflinePlayer(target));
|
|
||||||
|
|
||||||
targetUser.sendMessage(sender, String.join(" ", args));
|
targetUser.sendMessage(sender, String.join(" ", args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.draycia.simplechat.SimpleChat;
|
|||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@CommandAlias("mute")
|
@CommandAlias("mute")
|
||||||
@@ -24,9 +23,7 @@ public class MuteCommand extends BaseCommand {
|
|||||||
|
|
||||||
@Default
|
@Default
|
||||||
@CommandCompletion("@players")
|
@CommandCompletion("@players")
|
||||||
public void baseCommand(CommandSender sender, OfflinePlayer target) { // TODO: ChatUser support in ACF
|
public void baseCommand(CommandSender sender, ChatUser targetUser) {
|
||||||
ChatUser targetUser = simpleChat.getUserService().wrap(target.getUniqueId());
|
|
||||||
|
|
||||||
String format;
|
String format;
|
||||||
|
|
||||||
if (targetUser.isMuted()) {
|
if (targetUser.isMuted()) {
|
||||||
@@ -37,7 +34,7 @@ public class MuteCommand extends BaseCommand {
|
|||||||
format = simpleChat.getConfig().getString("language.is-now-muted");
|
format = simpleChat.getConfig().getString("language.is-now-muted");
|
||||||
}
|
}
|
||||||
|
|
||||||
Component message = MiniMessage.instance().parse(format, "user", target.getName());
|
Component message = MiniMessage.instance().parse(format, "user", targetUser.asOfflinePlayer().getName());
|
||||||
|
|
||||||
simpleChat.getAudiences().audience(sender).sendMessage(message);
|
simpleChat.getAudiences().audience(sender).sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.draycia.simplechat.SimpleChat;
|
|||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@CommandAlias("shadowmute|sm|smute")
|
@CommandAlias("shadowmute|sm|smute")
|
||||||
@@ -24,9 +23,7 @@ public class ShadowMuteCommand extends BaseCommand {
|
|||||||
|
|
||||||
@Default
|
@Default
|
||||||
@CommandCompletion("@players")
|
@CommandCompletion("@players")
|
||||||
public void baseCommand(CommandSender sender, OfflinePlayer target) {
|
public void baseCommand(CommandSender sender, ChatUser targetUser) {
|
||||||
ChatUser targetUser = simpleChat.getUserService().wrap(target.getUniqueId());
|
|
||||||
|
|
||||||
String format;
|
String format;
|
||||||
|
|
||||||
if (targetUser.isShadowMuted()) {
|
if (targetUser.isShadowMuted()) {
|
||||||
@@ -37,7 +34,7 @@ public class ShadowMuteCommand extends BaseCommand {
|
|||||||
format = simpleChat.getConfig().getString("language.is-now-shadow-muted");
|
format = simpleChat.getConfig().getString("language.is-now-shadow-muted");
|
||||||
}
|
}
|
||||||
|
|
||||||
Component message = MiniMessage.instance().parse(format, "user", target.getName());
|
Component message = MiniMessage.instance().parse(format, "user", targetUser.asOfflinePlayer().getName());
|
||||||
|
|
||||||
simpleChat.getAudiences().audience(sender).sendMessage(message);
|
simpleChat.getAudiences().audience(sender).sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ public class ItemLinkHandler implements Listener {
|
|||||||
public void onItemLink(ChatComponentEvent event) {
|
public void onItemLink(ChatComponentEvent event) {
|
||||||
// Handle item linking placeholders
|
// Handle item linking placeholders
|
||||||
if (event.getUser().isOnline()) {
|
if (event.getUser().isOnline()) {
|
||||||
// TODO: move this into a ChatComponentEvent listener
|
|
||||||
for (Pattern pattern : event.getChatChannel().getItemLinkPatterns()) {
|
for (Pattern pattern : event.getChatChannel().getItemLinkPatterns()) {
|
||||||
TextComponent component = event.getComponent().replace(pattern, (input) -> {
|
TextComponent component = event.getComponent().replace(pattern, (input) -> {
|
||||||
return TextComponent.builder().append(simpleChat.getItemStackUtils().createComponent(event.getUser().asPlayer()));
|
return TextComponent.builder().append(simpleChat.getItemStackUtils().createComponent(event.getUser().asPlayer()));
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ public class ChannelManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: register command for each channel
|
|
||||||
simpleChat.getChannels().add(channel);
|
simpleChat.getChannels().add(channel);
|
||||||
|
|
||||||
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
|
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.draycia.simplechat.SimpleChat;
|
|||||||
import net.draycia.simplechat.channels.ChatChannel;
|
import net.draycia.simplechat.channels.ChatChannel;
|
||||||
import net.draycia.simplechat.commands.*;
|
import net.draycia.simplechat.commands.*;
|
||||||
import net.draycia.simplechat.storage.ChatUser;
|
import net.draycia.simplechat.storage.ChatUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -44,6 +45,10 @@ public class CommandManager {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
commandManager.getCommandContexts().registerContext(ChatUser.class, (context) -> {
|
||||||
|
return simpleChat.getUserService().wrap(Bukkit.getOfflinePlayer(context.popFirstArg()));
|
||||||
|
});
|
||||||
|
|
||||||
commandManager.getCommandConditions().addCondition(ChatChannel.class,"canuse", (context, execution, value) -> {
|
commandManager.getCommandConditions().addCondition(ChatChannel.class,"canuse", (context, execution, value) -> {
|
||||||
ChatUser user = simpleChat.getUserService().wrap(context.getIssuer().getPlayer());
|
ChatUser user = simpleChat.getUserService().wrap(context.getIssuer().getPlayer());
|
||||||
|
|
||||||
|
|||||||
@@ -177,8 +177,8 @@ public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
|||||||
if (this.isOnline()) {
|
if (this.isOnline()) {
|
||||||
this.sendMessage(fromPlayerComponent);
|
this.sendMessage(fromPlayerComponent);
|
||||||
|
|
||||||
sender.setReplyTarget(this.getUUID());
|
sender.setReplyTarget(this);
|
||||||
this.setReplyTarget(sender.getUUID());
|
this.setReplyTarget(sender);
|
||||||
|
|
||||||
if (simpleChat.getConfig().getBoolean("pings.on-whisper")) {
|
if (simpleChat.getConfig().getBoolean("pings.on-whisper")) {
|
||||||
Key key = Key.of(simpleChat.getConfig().getString("pings.sound"));
|
Key key = Key.of(simpleChat.getConfig().getString("pings.sound"));
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@@ -46,24 +45,20 @@ public final class ItemStackUtils {
|
|||||||
this.cMethod = this.itemStackClass.getMethod("C");
|
this.cMethod = this.itemStackClass.getMethod("C");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component createComponent(final CommandSender player) {
|
public Component createComponent(final Player player) {
|
||||||
if (player instanceof Player) {
|
final ItemStack itemStack = player.getInventory().getItemInMainHand();
|
||||||
final ItemStack itemStack = ((Player)player).getInventory().getItemInMainHand();
|
|
||||||
|
|
||||||
if (itemStack == null || itemStack.getType() == Material.AIR) {
|
if (itemStack == null || itemStack.getType() == Material.AIR) {
|
||||||
return TextComponent.empty();
|
return TextComponent.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Object cbItemStack = this.asNMSCopyMethod.invoke(null, itemStack);
|
final Object cbItemStack = this.asNMSCopyMethod.invoke(null, itemStack);
|
||||||
final Object mojangComponent = this.cMethod.invoke(cbItemStack);
|
final Object mojangComponent = this.cMethod.invoke(cbItemStack);
|
||||||
|
|
||||||
return MinecraftComponentSerializer.INSTANCE.deserialize(mojangComponent);
|
return MinecraftComponentSerializer.INSTANCE.deserialize(mojangComponent);
|
||||||
} catch (final IllegalAccessException | InvocationTargetException e) {
|
} catch (final IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return TextComponent.empty();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return TextComponent.empty();
|
return TextComponent.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user