Move commands.

This commit is contained in:
Aust1n46 2022-05-01 14:21:26 -05:00
parent 862c673cd8
commit 9e88a9733b
54 changed files with 203 additions and 193 deletions

View File

@ -17,44 +17,44 @@ import org.bukkit.configuration.file.YamlConfiguration;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import venture.Aust1n46.chat.controllers.commands.Broadcast;
import venture.Aust1n46.chat.controllers.commands.BungeeToggle;
import venture.Aust1n46.chat.controllers.commands.Channel;
import venture.Aust1n46.chat.controllers.commands.ChannelAlias;
import venture.Aust1n46.chat.controllers.commands.Channelinfo;
import venture.Aust1n46.chat.controllers.commands.Chatinfo;
import venture.Aust1n46.chat.controllers.commands.Chatreload;
import venture.Aust1n46.chat.controllers.commands.Chlist;
import venture.Aust1n46.chat.controllers.commands.Chwho;
import venture.Aust1n46.chat.controllers.commands.Clearchat;
import venture.Aust1n46.chat.controllers.commands.Commandblock;
import venture.Aust1n46.chat.controllers.commands.Commandspy;
import venture.Aust1n46.chat.controllers.commands.Edit;
import venture.Aust1n46.chat.controllers.commands.Filter;
import venture.Aust1n46.chat.controllers.commands.Force;
import venture.Aust1n46.chat.controllers.commands.Forceall;
import venture.Aust1n46.chat.controllers.commands.Ignore;
import venture.Aust1n46.chat.controllers.commands.Kickchannel;
import venture.Aust1n46.chat.controllers.commands.Kickchannelall;
import venture.Aust1n46.chat.controllers.commands.Leave;
import venture.Aust1n46.chat.controllers.commands.Listen;
import venture.Aust1n46.chat.controllers.commands.Me;
import venture.Aust1n46.chat.controllers.commands.Message;
import venture.Aust1n46.chat.controllers.commands.MessageToggle;
import venture.Aust1n46.chat.controllers.commands.Mute;
import venture.Aust1n46.chat.controllers.commands.Muteall;
import venture.Aust1n46.chat.controllers.commands.Notifications;
import venture.Aust1n46.chat.controllers.commands.Party;
import venture.Aust1n46.chat.controllers.commands.RangedSpy;
import venture.Aust1n46.chat.controllers.commands.Removemessage;
import venture.Aust1n46.chat.controllers.commands.Reply;
import venture.Aust1n46.chat.controllers.commands.Setchannel;
import venture.Aust1n46.chat.controllers.commands.Setchannelall;
import venture.Aust1n46.chat.controllers.commands.Spy;
import venture.Aust1n46.chat.controllers.commands.Unmute;
import venture.Aust1n46.chat.controllers.commands.Unmuteall;
import venture.Aust1n46.chat.controllers.commands.VentureChatGui;
import venture.Aust1n46.chat.controllers.commands.Venturechat;
import venture.Aust1n46.chat.initators.commands.Broadcast;
import venture.Aust1n46.chat.initators.commands.BungeeToggle;
import venture.Aust1n46.chat.initators.commands.Channel;
import venture.Aust1n46.chat.initators.commands.ChannelAlias;
import venture.Aust1n46.chat.initators.commands.Channelinfo;
import venture.Aust1n46.chat.initators.commands.Chatinfo;
import venture.Aust1n46.chat.initators.commands.Chatreload;
import venture.Aust1n46.chat.initators.commands.Chlist;
import venture.Aust1n46.chat.initators.commands.Chwho;
import venture.Aust1n46.chat.initators.commands.Clearchat;
import venture.Aust1n46.chat.initators.commands.Commandblock;
import venture.Aust1n46.chat.initators.commands.Commandspy;
import venture.Aust1n46.chat.initators.commands.Edit;
import venture.Aust1n46.chat.initators.commands.Filter;
import venture.Aust1n46.chat.initators.commands.Force;
import venture.Aust1n46.chat.initators.commands.Forceall;
import venture.Aust1n46.chat.initators.commands.Ignore;
import venture.Aust1n46.chat.initators.commands.Kickchannel;
import venture.Aust1n46.chat.initators.commands.Kickchannelall;
import venture.Aust1n46.chat.initators.commands.Leave;
import venture.Aust1n46.chat.initators.commands.Listen;
import venture.Aust1n46.chat.initators.commands.Me;
import venture.Aust1n46.chat.initators.commands.Message;
import venture.Aust1n46.chat.initators.commands.MessageToggle;
import venture.Aust1n46.chat.initators.commands.Mute;
import venture.Aust1n46.chat.initators.commands.Muteall;
import venture.Aust1n46.chat.initators.commands.Notifications;
import venture.Aust1n46.chat.initators.commands.Party;
import venture.Aust1n46.chat.initators.commands.RangedSpy;
import venture.Aust1n46.chat.initators.commands.Removemessage;
import venture.Aust1n46.chat.initators.commands.Reply;
import venture.Aust1n46.chat.initators.commands.Setchannel;
import venture.Aust1n46.chat.initators.commands.Setchannelall;
import venture.Aust1n46.chat.initators.commands.Spy;
import venture.Aust1n46.chat.initators.commands.Unmute;
import venture.Aust1n46.chat.initators.commands.Unmuteall;
import venture.Aust1n46.chat.initators.commands.VentureChatGui;
import venture.Aust1n46.chat.initators.commands.Venturechat;
import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.model.ChatChannel;
import venture.Aust1n46.chat.service.ConfigService;

View File

@ -21,7 +21,7 @@ import com.google.inject.Singleton;
import me.clip.placeholderapi.PlaceholderAPI;
import venture.Aust1n46.chat.api.events.VentureChatEvent;
import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.initators.commands.MuteContainer;
import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.localization.LocalizedMessage;
import venture.Aust1n46.chat.model.ChatChannel;

View File

@ -21,7 +21,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.initators.commands.MuteContainer;
import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.model.ChatChannel;
import venture.Aust1n46.chat.model.VentureChatPlayer;

View File

@ -9,7 +9,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import com.google.inject.Inject;
import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.initators.commands.MuteContainer;
import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer;
import venture.Aust1n46.chat.model.TemporaryDataInstance;
import venture.Aust1n46.chat.model.VentureChatProxyServer;

View File

@ -16,7 +16,7 @@ import com.google.inject.Inject;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.initators.commands.MuteContainer;
import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer;
import venture.Aust1n46.chat.model.VentureChatProxySource;
import venture.Aust1n46.chat.service.proxy.ProxyUuidService;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.entity.Player;
@ -25,7 +25,7 @@ public class ChannelAlias extends PlayerCommand {
}
@Override
public void executeCommand(final Player player, final String commandLabel, final String[] args) {
protected void executeCommand(final Player player, final String commandLabel, final String[] args) {
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(player);
for (ChatChannel channel : configService.getChatChannels()) {
if (commandLabel.toLowerCase().equals(channel.getAlias())) {

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.util.UUID;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import static venture.Aust1n46.chat.utilities.FormatUtils.LINE_LENGTH;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.util.List;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
public class MuteContainer {
private String channel;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import static venture.Aust1n46.chat.utilities.FormatUtils.LINE_LENGTH;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import java.util.ArrayList;
import java.util.List;
@ -24,7 +24,7 @@ import venture.Aust1n46.chat.model.VentureChatPlayer;
import venture.Aust1n46.chat.service.ConfigService;
import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.utilities.FormatUtils;
import venture.Aust1n46.chat.utilities.VersionHandler;
import venture.Aust1n46.chat.xcut.VersionService;
public class VentureChatGui extends PlayerCommand {
@Inject
@ -33,6 +33,8 @@ public class VentureChatGui extends PlayerCommand {
private VentureChatPlayerApiService playerApiService;
@Inject
private ConfigService configService;
@Inject
private VersionService versionService;
@Inject
public VentureChatGui(String name) {
@ -80,13 +82,13 @@ public class VentureChatGui extends PlayerCommand {
Inventory inv = Bukkit.createInventory(null, this.getSlots(), "VentureChat: " + target.getName() + " GUI");
ItemStack close = null;
ItemStack skull = null;
if (VersionHandler.is1_7()) {
if (versionService.is1_7()) {
close = new ItemStack(Material.BEDROCK);
} else {
close = new ItemStack(Material.BARRIER);
}
if (VersionHandler.is1_7() || VersionHandler.is1_8() || VersionHandler.is1_9() || VersionHandler.is1_10() || VersionHandler.is1_11() || VersionHandler.is1_12()) {
if (versionService.is1_7() || versionService.is1_8() || versionService.is1_9() || versionService.is1_10() || versionService.is1_11() || versionService.is1_12()) {
skull = new ItemStack(Material.getMaterial("SKULL_ITEM"));
} else {
skull = new ItemStack(Material.PLAYER_HEAD);
@ -137,13 +139,13 @@ public class VentureChatGui extends PlayerCommand {
Inventory inv = Bukkit.createInventory(null, this.getSlots(), "VentureChat: Discord_Message GUI");
ItemStack close = null;
ItemStack skull = null;
if (VersionHandler.is1_7()) {
if (versionService.is1_7()) {
close = new ItemStack(Material.BEDROCK);
} else {
close = new ItemStack(Material.BARRIER);
}
if (VersionHandler.is1_7() || VersionHandler.is1_8() || VersionHandler.is1_9() || VersionHandler.is1_10() || VersionHandler.is1_11() || VersionHandler.is1_12()) {
if (versionService.is1_7() || versionService.is1_8() || versionService.is1_9() || versionService.is1_10() || versionService.is1_11() || versionService.is1_12()) {
skull = new ItemStack(Material.getMaterial("SKULL_ITEM"));
} else {
skull = new ItemStack(Material.PLAYER_HEAD);

View File

@ -1,4 +1,4 @@
package venture.Aust1n46.chat.controllers.commands;
package venture.Aust1n46.chat.initators.commands;
import org.bukkit.command.CommandSender;

View File

@ -25,7 +25,7 @@ import me.clip.placeholderapi.PlaceholderAPI;
import net.essentialsx.api.v2.services.discord.DiscordService;
import venture.Aust1n46.chat.api.events.VentureChatEvent;
import venture.Aust1n46.chat.controllers.PluginMessageController;
import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.initators.commands.MuteContainer;
import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.localization.LocalizedMessage;
import venture.Aust1n46.chat.model.ChatChannel;

View File

@ -12,9 +12,9 @@ import com.google.inject.Singleton;
import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.model.ChatMessage;
import venture.Aust1n46.chat.model.VentureChatPlayer;
import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.utilities.VersionHandler;
import venture.Aust1n46.chat.service.VentureChatFormatService;
import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.xcut.VersionService;
//This class listens for chat packets and intercepts them before they are sent to the Player.
//The packets are modified to include advanced json formating and the message remover button if the
@ -25,6 +25,9 @@ public class PacketListener extends PacketAdapter {
private VentureChatFormatService formatter;
@Inject
private VentureChatPlayerApiService playerApiService;
@Inject
private VersionService versionService;
@Inject
public PacketListener(final VentureChat plugin) {
@ -49,13 +52,13 @@ public class PacketListener extends PacketAdapter {
}
try {
if(VersionHandler.is1_7()) {
if(versionService.is1_7()) {
packet.getBooleans().getField(0).setAccessible(true);
if(!((boolean) packet.getBooleans().getField(0).get(packet.getHandle()))) {
return;
}
}
else if(VersionHandler.is1_8() || VersionHandler.is1_9() || VersionHandler.is1_10() || VersionHandler.is1_11()) {
else if(versionService.is1_8() || versionService.is1_9() || versionService.is1_10() || versionService.is1_11()) {
packet.getBytes().getField(0).setAccessible(true);
if(((Byte) packet.getBytes().getField(0).get(packet.getHandle())).intValue() > 1) {
return;

View File

@ -30,12 +30,12 @@ import venture.Aust1n46.chat.model.Alias;
import venture.Aust1n46.chat.model.ChatChannel;
import venture.Aust1n46.chat.model.GuiSlot;
import venture.Aust1n46.chat.model.VentureChatPlayer;
import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.utilities.FormatUtils;
import venture.Aust1n46.chat.utilities.VersionHandler;
import venture.Aust1n46.chat.service.ConfigService;
import venture.Aust1n46.chat.service.VentureChatDatabaseService;
import venture.Aust1n46.chat.service.VentureChatFormatService;
import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.utilities.FormatUtils;
import venture.Aust1n46.chat.xcut.VersionService;
//This class listens for commands (Any chat that begins with a /) to use in the command spy and
//in the custom commands such as aliases.
@ -53,6 +53,8 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
private VentureChatPlayerApiService playerApiService;
@Inject
private ConfigService configService;
@Inject
private VersionService versionService;
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) throws FileNotFoundException {
@ -261,7 +263,7 @@ public class PreProcessCommandListener implements CommandExecutor, Listener {
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
ChatChannel channel = configService.getChannel(ChatColor.stripColor(skullMeta.getLore().get(0)).replace("Channel: ", ""));
int hash = Integer.parseInt(ChatColor.stripColor(skullMeta.getLore().get(1).replace("Hash: ", "")));
if(VersionHandler.is1_7()) {
if(versionService.is1_7()) {
if(item.getType() == Material.BEDROCK) {
mcp.getPlayer().closeInventory();
}

View File

@ -2,13 +2,13 @@ package venture.Aust1n46.chat.initiators.schedulers;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.scheduler.BukkitScheduler;
import com.google.inject.Inject;
import venture.Aust1n46.chat.controllers.PluginMessageController;
import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.initators.commands.MuteContainer;
import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.localization.LocalizedMessage;
import venture.Aust1n46.chat.model.ChatChannel;
@ -26,10 +26,11 @@ public class UnmuteScheduler {
private VentureChatPlayerApiService playerApiService;
@Inject
private ConfigService configService;
@Inject
public void postConstruct() {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
final Server server = plugin.getServer();
BukkitScheduler scheduler = server.getScheduler();
scheduler.runTaskTimerAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@ -38,7 +39,7 @@ public class UnmuteScheduler {
Iterator<MuteContainer> iterator = p.getMutes().iterator();
while (iterator.hasNext()) {
MuteContainer mute = iterator.next();
if(configService.isChannel(mute.getChannel())) {
if (configService.isChannel(mute.getChannel())) {
ChatChannel channel = configService.getChannel(mute.getChannel());
long timemark = mute.getDuration();
if (timemark == 0) {
@ -49,10 +50,9 @@ public class UnmuteScheduler {
}
if (currentTimeMillis >= timemark) {
iterator.remove();
p.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString()
.replace("{player}", p.getName()).replace("{channel_color}", channel.getColor())
.replace("{channel_name}", mute.getChannel()));
if(channel.getBungee()) {
p.getPlayer().sendMessage(LocalizedMessage.UNMUTE_PLAYER_PLAYER.toString().replace("{player}", p.getName())
.replace("{channel_color}", channel.getColor()).replace("{channel_name}", mute.getChannel()));
if (channel.getBungee()) {
pluginMessageController.synchronize(p, true);
}
}
@ -60,8 +60,7 @@ public class UnmuteScheduler {
}
}
if (plugin.getConfig().getString("loglevel", "info").equals("trace")) {
Bukkit.getConsoleSender()
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - Updating Player Mutes"));
server.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - Updating Player Mutes"));
}
}
}, 0L, 60L); // three second interval

View File

@ -2,37 +2,36 @@ package venture.Aust1n46.chat.localization;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.utilities.FormatUtils;
//This class is used to create objects of localization for different languages.
public class Localization {
private static final String VERSION = "2.22.4";
private static FileConfiguration localization;
public static void initialize(final VentureChat plugin) {
File localizationFile = new File(plugin.getDataFolder().getAbsolutePath(), "Messages.yml");
if(!localizationFile.isFile()) {
plugin.saveResource("Messages.yml", true);
if (!localizationFile.isFile()) {
plugin.saveResource("Messages.yml", true);
}
localization = YamlConfiguration.loadConfiguration(localizationFile);
String fileVersion = localization.getString("Version", "null");
if(!fileVersion.equals(VERSION)) {
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - Version Change Detected! Saving Old Messages.yml and Generating Latest File"));
if (!fileVersion.equals(VERSION)) {
plugin.getServer().getConsoleSender()
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&e - Version Change Detected! Saving Old Messages.yml and Generating Latest File"));
localizationFile.renameTo(new File(plugin.getDataFolder().getAbsolutePath(), "Messages_Old_" + fileVersion + ".yml"));
plugin.saveResource("Messages.yml", true);
localization = YamlConfiguration.loadConfiguration(localizationFile);
}
}
public static FileConfiguration getLocalization() {
public static FileConfiguration getLocalization() {
return localization;
}
}

View File

@ -8,7 +8,7 @@ import java.util.List;
import java.util.Set;
import java.util.UUID;
import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.initators.commands.MuteContainer;
public class SynchronizedVentureChatPlayer {
private UUID uuid;

View File

@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;
import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.initators.commands.MuteContainer;
/**
* Wrapper for {@link Player}

View File

@ -33,7 +33,7 @@ import venture.Aust1n46.chat.model.JsonAttribute;
import venture.Aust1n46.chat.model.JsonFormat;
import venture.Aust1n46.chat.model.VentureChatPlayer;
import venture.Aust1n46.chat.utilities.FormatUtils;
import venture.Aust1n46.chat.utilities.VersionHandler;
import venture.Aust1n46.chat.xcut.VersionService;
/**
* Class containing chat formatting methods.
@ -52,6 +52,8 @@ public class VentureChatFormatService {
private VentureChatPlayerApiService playerApiService;
@Inject
private ConfigService configService;
@Inject
private VersionService versionService;
/**
* Converts a message to Minecraft JSON formatting while applying the
@ -451,7 +453,7 @@ public class VentureChatFormatService {
@SuppressWarnings("unchecked")
public String toColoredText(Object o, Class<?> c) {
if (VersionHandler.is1_7()) {
if (versionService.is1_7()) {
return "\"extra\":[{\"text\":\"Hover to see original message is not currently supported in 1.7\",\"color\":\"red\"}]";
}
List<Object> finalList = new ArrayList<>();
@ -461,10 +463,10 @@ public class VentureChatFormatService {
splitComponents(finalList, o, c);
for (Object component : finalList) {
try {
if (VersionHandler.is1_8() || VersionHandler.is1_9() || VersionHandler.is1_10()
|| VersionHandler.is1_11() || VersionHandler.is1_12() || VersionHandler.is1_13()
|| VersionHandler.is1_14() || VersionHandler.is1_15() || VersionHandler.is1_16()
|| VersionHandler.is1_17()) {
if (versionService.is1_8() || versionService.is1_9() || versionService.is1_10()
|| versionService.is1_11() || versionService.is1_12() || versionService.is1_13()
|| versionService.is1_14() || versionService.is1_15() || versionService.is1_16()
|| versionService.is1_17()) {
String text = (String) component.getClass().getMethod("getText").invoke(component);
Object chatModifier = component.getClass().getMethod("getChatModifier").invoke(component);
Object color = chatModifier.getClass().getMethod("getColor").invoke(chatModifier);
@ -533,12 +535,12 @@ public class VentureChatFormatService {
try {
splitComponents(finalList, o, c);
for (Object component : finalList) {
if (VersionHandler.is1_7()) {
if (versionService.is1_7()) {
stringbuilder.append((String) component.getClass().getMethod("e").invoke(component));
} else if (VersionHandler.is1_8() || VersionHandler.is1_9() || VersionHandler.is1_10()
|| VersionHandler.is1_11() || VersionHandler.is1_12() || VersionHandler.is1_13()
|| VersionHandler.is1_14() || VersionHandler.is1_15() || VersionHandler.is1_16()
|| VersionHandler.is1_17()) {
} else if (versionService.is1_8() || versionService.is1_9() || versionService.is1_10()
|| versionService.is1_11() || versionService.is1_12() || versionService.is1_13()
|| versionService.is1_14() || versionService.is1_15() || versionService.is1_16()
|| versionService.is1_17()) {
stringbuilder.append((String) component.getClass().getMethod("getText").invoke(component));
} else {
stringbuilder.append((String) component.getClass().getMethod("getString").invoke(component));
@ -551,9 +553,9 @@ public class VentureChatFormatService {
}
private void splitComponents(List<Object> finalList, Object o, Class<?> c) throws Exception {
if (VersionHandler.is1_7() || VersionHandler.is1_8() || VersionHandler.is1_9() || VersionHandler.is1_10()
|| VersionHandler.is1_11() || VersionHandler.is1_12() || VersionHandler.is1_13()
|| (VersionHandler.is1_14() && !VersionHandler.is1_14_4())) {
if (versionService.is1_7() || versionService.is1_8() || versionService.is1_9() || versionService.is1_10()
|| versionService.is1_11() || versionService.is1_12() || versionService.is1_13()
|| (versionService.is1_14() && !versionService.is1_14_4())) {
ArrayList<?> list = (ArrayList<?>) c.getMethod("a").invoke(o, new Object[0]);
for (Object component : list) {
ArrayList<?> innerList = (ArrayList<?>) c.getMethod("a").invoke(component, new Object[0]);
@ -563,8 +565,8 @@ public class VentureChatFormatService {
finalList.add(component);
}
}
} else if (VersionHandler.is1_14_4() || VersionHandler.is1_15() || VersionHandler.is1_16()
|| VersionHandler.is1_17()) {
} else if (versionService.is1_14_4() || versionService.is1_15() || versionService.is1_16()
|| versionService.is1_17()) {
ArrayList<?> list = (ArrayList<?>) c.getMethod("getSiblings").invoke(o, new Object[0]);
for (Object component : list) {
ArrayList<?> innerList = (ArrayList<?>) c.getMethod("getSiblings").invoke(component, new Object[0]);
@ -637,7 +639,7 @@ public class VentureChatFormatService {
}
private Sound getDefaultMessageSound() {
if (VersionHandler.is1_7() || VersionHandler.is1_8()) {
if (versionService.is1_7() || versionService.is1_8()) {
return Sound.valueOf(DEFAULT_LEGACY_MESSAGE_SOUND);
} else {
return Sound.valueOf(DEFAULT_MESSAGE_SOUND);

View File

@ -1,55 +0,0 @@
package venture.Aust1n46.chat.utilities;
import org.bukkit.Bukkit;
//This class contains methods for determining what version of Minecraft the server is running.
public class VersionHandler {
public static boolean is1_7() {
return Bukkit.getVersion().contains("1.7");
}
public static boolean is1_8() {
return Bukkit.getVersion().contains("1.8");
}
public static boolean is1_9() {
return Bukkit.getVersion().contains("1.9");
}
public static boolean is1_10() {
return Bukkit.getVersion().contains("1.10");
}
public static boolean is1_11() {
return Bukkit.getVersion().contains("1.11");
}
public static boolean is1_12() {
return Bukkit.getVersion().contains("1.12");
}
public static boolean is1_13() {
return Bukkit.getVersion().contains("1.13");
}
public static boolean is1_14() {
return Bukkit.getVersion().contains("1.14");
}
public static boolean is1_14_4() {
return Bukkit.getVersion().contains("1.14.4");
}
public static boolean is1_15() {
return Bukkit.getVersion().contains("1.15");
}
public static boolean is1_16() {
return Bukkit.getVersion().contains("1.16");
}
public static boolean is1_17() {
return Bukkit.getVersion().contains("1.17");
}
}

View File

@ -0,0 +1,58 @@
package venture.Aust1n46.chat.xcut;
import com.google.inject.Inject;
import venture.Aust1n46.chat.initiators.application.VentureChat;
public class VersionService {
@Inject
private VentureChat plugin;
public boolean is1_7() {
return plugin.getServer().getVersion().contains("1.7");
}
public boolean is1_8() {
return plugin.getServer().getVersion().contains("1.8");
}
public boolean is1_9() {
return plugin.getServer().getVersion().contains("1.9");
}
public boolean is1_10() {
return plugin.getServer().getVersion().contains("1.10");
}
public boolean is1_11() {
return plugin.getServer().getVersion().contains("1.11");
}
public boolean is1_12() {
return plugin.getServer().getVersion().contains("1.12");
}
public boolean is1_13() {
return plugin.getServer().getVersion().contains("1.13");
}
public boolean is1_14() {
return plugin.getServer().getVersion().contains("1.14");
}
public boolean is1_14_4() {
return plugin.getServer().getVersion().contains("1.14.4");
}
public boolean is1_15() {
return plugin.getServer().getVersion().contains("1.15");
}
public boolean is1_16() {
return plugin.getServer().getVersion().contains("1.16");
}
public boolean is1_17() {
return plugin.getServer().getVersion().contains("1.17");
}
}