mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
Model updates
This commit is contained in:
parent
ba1bc62fb9
commit
d36fca277d
@ -59,7 +59,7 @@ public class ProxyFlatFileController {
|
||||
while (m.hasMoreTokens()) {
|
||||
String[] parts = m.nextToken().split(":");
|
||||
String channelName = parts[0];
|
||||
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1])));
|
||||
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1]), ""));
|
||||
}
|
||||
HashSet<UUID> ignores = new HashSet<UUID>();
|
||||
StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ",");
|
||||
|
@ -94,7 +94,7 @@ public class SpigotFlatFileController {
|
||||
continue;
|
||||
}
|
||||
String channelName = parts[0];
|
||||
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1])));
|
||||
mutes.put(channelName, new MuteContainer(channelName, Long.parseLong(parts[1]), ""));
|
||||
}
|
||||
}
|
||||
Set<String> blockedCommands = new HashSet<String>();
|
||||
|
@ -190,7 +190,7 @@ public class ChatListener implements Listener {
|
||||
|
||||
private void processMute(final VentureChatPlayer ventureChatPlayer, final ChatChannel channel) {
|
||||
MuteContainer muteContainer = ventureChatPlayer.getMute(channel.getName());
|
||||
if (muteContainer.hasDuration()) {
|
||||
if (muteContainer.getDuration() > 0) {
|
||||
long dateTimeMillis = System.currentTimeMillis();
|
||||
long muteTimeMillis = muteContainer.getDuration();
|
||||
long remainingMuteTime = muteTimeMillis - dateTimeMillis;
|
||||
@ -198,7 +198,7 @@ public class ChatListener implements Listener {
|
||||
remainingMuteTime = 1000;
|
||||
}
|
||||
String timeString = FormatUtils.parseTimeStringFromMillis(remainingMuteTime);
|
||||
if (muteContainer.hasReason()) {
|
||||
if (!muteContainer.getReason().isEmpty()) {
|
||||
ventureChatPlayer.getPlayer().sendMessage(LocalizedMessage.CHANNEL_MUTED_TIMED_REASON.toString().replace("{channel_color}", channel.getColor())
|
||||
.replace("{channel_name}", channel.getName()).replace("{time}", timeString).replace("{reason}", muteContainer.getReason()));
|
||||
} else {
|
||||
@ -206,7 +206,7 @@ public class ChatListener implements Listener {
|
||||
.replace("{channel_name}", channel.getName()).replace("{time}", timeString));
|
||||
}
|
||||
} else {
|
||||
if (muteContainer.hasReason()) {
|
||||
if (!muteContainer.getReason().isEmpty()) {
|
||||
ventureChatPlayer.getPlayer().sendMessage(LocalizedMessage.CHANNEL_MUTED_REASON.toString().replace("{channel_color}", channel.getColor())
|
||||
.replace("{channel_name}", channel.getName()).replace("{reason}", muteContainer.getReason()));
|
||||
} else {
|
||||
|
@ -2,19 +2,20 @@ package venture.Aust1n46.chat.model;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ChatMessage {
|
||||
private WrappedChatComponent component;
|
||||
private String message;
|
||||
private String coloredMessage;
|
||||
private int hash;
|
||||
|
||||
public ChatMessage(WrappedChatComponent component, String message, String coloredMessage, int hash) {
|
||||
this.component = component;
|
||||
this.message = message;
|
||||
this.coloredMessage = coloredMessage;
|
||||
this.hash = hash;
|
||||
}
|
||||
}
|
||||
|
@ -2,19 +2,20 @@ package venture.Aust1n46.chat.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class JsonAttribute {
|
||||
private String name;
|
||||
private List<String> hoverText;
|
||||
private ClickAction clickAction;
|
||||
private String clickText;
|
||||
|
||||
public JsonAttribute(String name, List<String> hoverText, ClickAction clickAction, String clickText) {
|
||||
this.name = name;
|
||||
this.hoverText = hoverText;
|
||||
this.clickAction = clickAction;
|
||||
this.clickText = clickText;
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,19 @@ package venture.Aust1n46.chat.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class JsonFormat {
|
||||
private List<JsonAttribute> jsonAttributes;
|
||||
private int priority;
|
||||
private String name;
|
||||
|
||||
public JsonFormat(String name, int priority, List<JsonAttribute> jsonAttributes) {
|
||||
this.name = name;
|
||||
this.priority = priority;
|
||||
this.jsonAttributes = jsonAttributes;
|
||||
}
|
||||
private int priority;
|
||||
private List<JsonAttribute> jsonAttributes;
|
||||
}
|
||||
|
@ -1,45 +1,18 @@
|
||||
package venture.Aust1n46.chat.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MuteContainer {
|
||||
private String channel;
|
||||
private String reason;
|
||||
private long duration;
|
||||
|
||||
public MuteContainer(String channel) {
|
||||
this(channel, 0, "");
|
||||
}
|
||||
|
||||
public MuteContainer(String channel, long duration) {
|
||||
this(channel, duration, "");
|
||||
}
|
||||
|
||||
public MuteContainer(String channel, String reason) {
|
||||
this(channel, 0, reason);
|
||||
}
|
||||
|
||||
public MuteContainer(String channel, long duration, String reason) {
|
||||
this.channel = channel;
|
||||
this.reason = reason;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public boolean hasReason() {
|
||||
return !reason.equals("");
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public boolean hasDuration() {
|
||||
return duration > 0;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
private String channel;
|
||||
private long duration;
|
||||
private String reason;
|
||||
}
|
||||
|
@ -3,35 +3,34 @@ package venture.Aust1n46.chat.model;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class TemporaryDataInstance {
|
||||
private int messagePackets;
|
||||
private final UUID uuid;
|
||||
@Getter
|
||||
private int messagePackets;
|
||||
private final UUID uuid;
|
||||
|
||||
private static final HashMap<UUID, TemporaryDataInstance> temporaryDataInstances = new HashMap<UUID, TemporaryDataInstance>();
|
||||
private static final HashMap<UUID, TemporaryDataInstance> temporaryDataInstances = new HashMap<UUID, TemporaryDataInstance>();
|
||||
|
||||
private TemporaryDataInstance(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
private TemporaryDataInstance(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public static UUID createTemporaryDataInstance() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
temporaryDataInstances.put(uuid, new TemporaryDataInstance(uuid));
|
||||
return uuid;
|
||||
}
|
||||
public static UUID createTemporaryDataInstance() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
temporaryDataInstances.put(uuid, new TemporaryDataInstance(uuid));
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public static TemporaryDataInstance getTemporaryDataInstance(UUID uuid) {
|
||||
return temporaryDataInstances.get(uuid);
|
||||
}
|
||||
public static TemporaryDataInstance getTemporaryDataInstance(UUID uuid) {
|
||||
return temporaryDataInstances.get(uuid);
|
||||
}
|
||||
|
||||
public int getMessagePackets() {
|
||||
return this.messagePackets;
|
||||
}
|
||||
public void incrementMessagePackets() {
|
||||
this.messagePackets++;
|
||||
}
|
||||
|
||||
public void incrementMessagePackets() {
|
||||
this.messagePackets++;
|
||||
}
|
||||
|
||||
public void destroyInstance() {
|
||||
temporaryDataInstances.remove(uuid);
|
||||
}
|
||||
public void destroyInstance() {
|
||||
temporaryDataInstances.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
@ -11,15 +11,22 @@ import java.util.UUID;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* Wrapper for {@link Player}
|
||||
*
|
||||
* @author Aust1n46
|
||||
*/
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VentureChatPlayer {
|
||||
@Setter(value = AccessLevel.NONE)
|
||||
private UUID uuid;
|
||||
@ -53,8 +60,10 @@ public class VentureChatPlayer {
|
||||
private boolean rangedSpy;
|
||||
private boolean messageToggle;
|
||||
private boolean bungeeToggle;
|
||||
|
||||
public VentureChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, MuteContainer> mutes, Set<String> blockedCommands, boolean host, UUID party, boolean filter, boolean notifications, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean messageToggle, boolean bungeeToggle) {
|
||||
|
||||
public VentureChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, MuteContainer> mutes,
|
||||
Set<String> blockedCommands, boolean host, UUID party, boolean filter, boolean notifications, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy,
|
||||
boolean messageToggle, boolean bungeeToggle) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.currentChannel = currentChannel;
|
||||
@ -76,7 +85,7 @@ public class VentureChatPlayer {
|
||||
this.messageToggle = messageToggle;
|
||||
this.bungeeToggle = bungeeToggle;
|
||||
}
|
||||
|
||||
|
||||
public VentureChatPlayer(UUID uuid, String name, ChatChannel currentChannel) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
@ -95,10 +104,10 @@ public class VentureChatPlayer {
|
||||
this.messageToggle = true;
|
||||
this.bungeeToggle = true;
|
||||
}
|
||||
|
||||
|
||||
public boolean getRangedSpy() {
|
||||
if(isOnline()) {
|
||||
if(!getPlayer().hasPermission("venturechat.rangedspy")) {
|
||||
if (isOnline()) {
|
||||
if (!getPlayer().hasPermission("venturechat.rangedspy")) {
|
||||
setRangedSpy(false);
|
||||
return false;
|
||||
}
|
||||
@ -107,7 +116,7 @@ public class VentureChatPlayer {
|
||||
}
|
||||
|
||||
public boolean setCurrentChannel(ChatChannel channel) {
|
||||
if(channel != null) {
|
||||
if (channel != null) {
|
||||
this.currentChannel = channel;
|
||||
return true;
|
||||
}
|
||||
@ -121,13 +130,13 @@ public class VentureChatPlayer {
|
||||
public void removeIgnore(UUID ignore) {
|
||||
this.ignores.remove(ignore);
|
||||
}
|
||||
|
||||
|
||||
public boolean isListening(String channel) {
|
||||
return listening.contains(channel);
|
||||
}
|
||||
|
||||
public boolean addListening(String channel) {
|
||||
if(channel != null) {
|
||||
if (channel != null) {
|
||||
this.listening.add(channel);
|
||||
return true;
|
||||
}
|
||||
@ -135,7 +144,7 @@ public class VentureChatPlayer {
|
||||
}
|
||||
|
||||
public boolean removeListening(String channel) {
|
||||
if(channel != null) {
|
||||
if (channel != null) {
|
||||
this.listening.remove(channel);
|
||||
return true;
|
||||
}
|
||||
@ -149,7 +158,7 @@ public class VentureChatPlayer {
|
||||
public Collection<MuteContainer> getMutes() {
|
||||
return this.mutes.values();
|
||||
}
|
||||
|
||||
|
||||
public MuteContainer getMute(String channel) {
|
||||
return mutes.get(channel);
|
||||
}
|
||||
@ -157,17 +166,17 @@ public class VentureChatPlayer {
|
||||
public boolean addMute(String channel) {
|
||||
return addMute(channel, 0, "");
|
||||
}
|
||||
|
||||
|
||||
public boolean addMute(String channel, long time) {
|
||||
return addMute(channel, time, "");
|
||||
}
|
||||
|
||||
|
||||
public boolean addMute(String channel, String reason) {
|
||||
return addMute(channel, 0, reason);
|
||||
}
|
||||
|
||||
|
||||
public boolean addMute(String channel, long time, String reason) {
|
||||
if(channel != null && time >= 0) {
|
||||
if (channel != null && time >= 0) {
|
||||
mutes.put(channel, new MuteContainer(channel, time, reason));
|
||||
return true;
|
||||
}
|
||||
@ -175,7 +184,7 @@ public class VentureChatPlayer {
|
||||
}
|
||||
|
||||
public boolean removeMute(String channel) {
|
||||
if(channel != null) {
|
||||
if (channel != null) {
|
||||
mutes.remove(channel);
|
||||
return true;
|
||||
}
|
||||
@ -211,8 +220,8 @@ public class VentureChatPlayer {
|
||||
}
|
||||
|
||||
public boolean isSpy() {
|
||||
if(this.isOnline()) {
|
||||
if(!this.getPlayer().hasPermission("venturechat.spy")) {
|
||||
if (this.isOnline()) {
|
||||
if (!this.getPlayer().hasPermission("venturechat.spy")) {
|
||||
this.setSpy(false);
|
||||
return false;
|
||||
}
|
||||
@ -221,8 +230,8 @@ public class VentureChatPlayer {
|
||||
}
|
||||
|
||||
public boolean hasCommandSpy() {
|
||||
if(this.isOnline()) {
|
||||
if(!this.getPlayer().hasPermission("venturechat.commandspy")) {
|
||||
if (this.isOnline()) {
|
||||
if (!this.getPlayer().hasPermission("venturechat.commandspy")) {
|
||||
this.setCommandSpy(false);
|
||||
return false;
|
||||
}
|
||||
@ -231,7 +240,7 @@ public class VentureChatPlayer {
|
||||
}
|
||||
|
||||
public boolean setQuickChannel(ChatChannel channel) {
|
||||
if(channel != null) {
|
||||
if (channel != null) {
|
||||
this.quickChannel = channel;
|
||||
return true;
|
||||
}
|
||||
@ -243,7 +252,7 @@ public class VentureChatPlayer {
|
||||
}
|
||||
|
||||
public boolean addCooldown(ChatChannel channel, long time) {
|
||||
if(channel != null && time > 0) {
|
||||
if (channel != null && time > 0) {
|
||||
cooldowns.put(channel, time);
|
||||
return true;
|
||||
}
|
||||
@ -251,7 +260,7 @@ public class VentureChatPlayer {
|
||||
}
|
||||
|
||||
public boolean removeCooldown(ChatChannel channel) {
|
||||
if(channel != null) {
|
||||
if (channel != null) {
|
||||
cooldowns.remove(channel);
|
||||
return true;
|
||||
}
|
||||
@ -261,13 +270,13 @@ public class VentureChatPlayer {
|
||||
public boolean hasCooldown(ChatChannel channel) {
|
||||
return channel != null && this.cooldowns != null ? this.cooldowns.containsKey(channel) : false;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasSpam(ChatChannel channel) {
|
||||
return channel != null && this.spam != null ? this.spam.containsKey(channel) : false;
|
||||
}
|
||||
|
||||
|
||||
public boolean addSpam(ChatChannel channel) {
|
||||
if(channel != null) {
|
||||
if (channel != null) {
|
||||
spam.put(channel, new ArrayList<Long>());
|
||||
return true;
|
||||
}
|
||||
@ -275,7 +284,7 @@ public class VentureChatPlayer {
|
||||
}
|
||||
|
||||
public void addMessage(ChatMessage message) {
|
||||
if(this.messages.size() >= 100) {
|
||||
if (this.messages.size() >= 100) {
|
||||
this.messages.remove(0);
|
||||
}
|
||||
this.messages.add(message);
|
||||
|
@ -1,9 +1,15 @@
|
||||
package venture.Aust1n46.chat.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VentureChatProxyServer {
|
||||
private String name;
|
||||
|
Loading…
x
Reference in New Issue
Block a user