Model updates

This commit is contained in:
Aust1n46 2024-02-12 06:00:20 -06:00
parent ba1bc62fb9
commit d36fca277d
10 changed files with 116 additions and 125 deletions

View File

@ -59,7 +59,7 @@ public class ProxyFlatFileController {
while (m.hasMoreTokens()) { while (m.hasMoreTokens()) {
String[] parts = m.nextToken().split(":"); String[] parts = m.nextToken().split(":");
String channelName = parts[0]; 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>(); HashSet<UUID> ignores = new HashSet<UUID>();
StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ","); StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ",");

View File

@ -94,7 +94,7 @@ public class SpigotFlatFileController {
continue; continue;
} }
String channelName = parts[0]; 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>(); Set<String> blockedCommands = new HashSet<String>();

View File

@ -190,7 +190,7 @@ public class ChatListener implements Listener {
private void processMute(final VentureChatPlayer ventureChatPlayer, final ChatChannel channel) { private void processMute(final VentureChatPlayer ventureChatPlayer, final ChatChannel channel) {
MuteContainer muteContainer = ventureChatPlayer.getMute(channel.getName()); MuteContainer muteContainer = ventureChatPlayer.getMute(channel.getName());
if (muteContainer.hasDuration()) { if (muteContainer.getDuration() > 0) {
long dateTimeMillis = System.currentTimeMillis(); long dateTimeMillis = System.currentTimeMillis();
long muteTimeMillis = muteContainer.getDuration(); long muteTimeMillis = muteContainer.getDuration();
long remainingMuteTime = muteTimeMillis - dateTimeMillis; long remainingMuteTime = muteTimeMillis - dateTimeMillis;
@ -198,7 +198,7 @@ public class ChatListener implements Listener {
remainingMuteTime = 1000; remainingMuteTime = 1000;
} }
String timeString = FormatUtils.parseTimeStringFromMillis(remainingMuteTime); 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()) 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())); .replace("{channel_name}", channel.getName()).replace("{time}", timeString).replace("{reason}", muteContainer.getReason()));
} else { } else {
@ -206,7 +206,7 @@ public class ChatListener implements Listener {
.replace("{channel_name}", channel.getName()).replace("{time}", timeString)); .replace("{channel_name}", channel.getName()).replace("{time}", timeString));
} }
} else { } else {
if (muteContainer.hasReason()) { if (!muteContainer.getReason().isEmpty()) {
ventureChatPlayer.getPlayer().sendMessage(LocalizedMessage.CHANNEL_MUTED_REASON.toString().replace("{channel_color}", channel.getColor()) ventureChatPlayer.getPlayer().sendMessage(LocalizedMessage.CHANNEL_MUTED_REASON.toString().replace("{channel_color}", channel.getColor())
.replace("{channel_name}", channel.getName()).replace("{reason}", muteContainer.getReason())); .replace("{channel_name}", channel.getName()).replace("{reason}", muteContainer.getReason()));
} else { } else {

View File

@ -2,19 +2,20 @@ package venture.Aust1n46.chat.model;
import com.comphenix.protocol.wrappers.WrappedChatComponent; 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 { public class ChatMessage {
private WrappedChatComponent component; private WrappedChatComponent component;
private String message; private String message;
private String coloredMessage; private String coloredMessage;
private int hash; 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;
}
} }

View File

@ -2,19 +2,20 @@ package venture.Aust1n46.chat.model;
import java.util.List; import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Getter @Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class JsonAttribute { public class JsonAttribute {
private String name; private String name;
private List<String> hoverText; private List<String> hoverText;
private ClickAction clickAction; private ClickAction clickAction;
private String clickText; 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;
}
} }

View File

@ -2,17 +2,19 @@ package venture.Aust1n46.chat.model;
import java.util.List; import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Getter @Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class JsonFormat { public class JsonFormat {
private List<JsonAttribute> jsonAttributes;
private int priority;
private String name; private String name;
private int priority;
public JsonFormat(String name, int priority, List<JsonAttribute> jsonAttributes) { private List<JsonAttribute> jsonAttributes;
this.name = name;
this.priority = priority;
this.jsonAttributes = jsonAttributes;
}
} }

View File

@ -1,45 +1,18 @@
package venture.Aust1n46.chat.model; 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 { public class MuteContainer {
private String channel; private String channel;
private String reason;
private long duration; private long duration;
private String reason;
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;
}
} }

View File

@ -3,7 +3,10 @@ package venture.Aust1n46.chat.model;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
import lombok.Getter;
public class TemporaryDataInstance { public class TemporaryDataInstance {
@Getter
private int messagePackets; private int messagePackets;
private final UUID uuid; private final UUID uuid;
@ -23,10 +26,6 @@ public class TemporaryDataInstance {
return temporaryDataInstances.get(uuid); return temporaryDataInstances.get(uuid);
} }
public int getMessagePackets() {
return this.messagePackets;
}
public void incrementMessagePackets() { public void incrementMessagePackets() {
this.messagePackets++; this.messagePackets++;
} }

View File

@ -11,15 +11,22 @@ import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Data; import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
/** /**
* Wrapper for {@link Player} * Wrapper for {@link Player}
* *
* @author Aust1n46 * @author Aust1n46
*/ */
@Data @Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class VentureChatPlayer { public class VentureChatPlayer {
@Setter(value = AccessLevel.NONE) @Setter(value = AccessLevel.NONE)
private UUID uuid; private UUID uuid;
@ -54,7 +61,9 @@ public class VentureChatPlayer {
private boolean messageToggle; private boolean messageToggle;
private boolean bungeeToggle; 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.uuid = uuid;
this.name = name; this.name = name;
this.currentChannel = currentChannel; this.currentChannel = currentChannel;

View File

@ -1,9 +1,15 @@
package venture.Aust1n46.chat.model; package venture.Aust1n46.chat.model;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Data @Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class VentureChatProxyServer { public class VentureChatProxyServer {
private String name; private String name;