mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-10 17:58:03 +01:00
New ChatSpy admin command
This commit is contained in:
parent
2a514b5467
commit
4456c5f356
@ -116,7 +116,8 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
|||||||
new com.songoda.skyblock.command.commands.admin.UpgradeCommand(),
|
new com.songoda.skyblock.command.commands.admin.UpgradeCommand(),
|
||||||
new StackableCommand(),
|
new StackableCommand(),
|
||||||
new AdminBank(),
|
new AdminBank(),
|
||||||
new SetMaxMembers()
|
new SetMaxMembers(),
|
||||||
|
new ChatSpyCommand()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.songoda.skyblock.command.commands.admin;
|
||||||
|
|
||||||
|
import com.songoda.skyblock.command.SubCommand;
|
||||||
|
import com.songoda.skyblock.config.FileManager;
|
||||||
|
import com.songoda.skyblock.message.MessageManager;
|
||||||
|
import com.songoda.skyblock.playerdata.PlayerData;
|
||||||
|
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class ChatSpyCommand extends SubCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommandByPlayer(Player player, String[] args) {
|
||||||
|
MessageManager messageManager = skyblock.getMessageManager();
|
||||||
|
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||||
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
|
|
||||||
|
FileManager.Config language = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||||
|
FileConfiguration languageLoad = language.getFileConfiguration();
|
||||||
|
|
||||||
|
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||||
|
if(playerData != null) {
|
||||||
|
if(playerData.isChatSpy()){
|
||||||
|
playerData.setChatSpy(false);
|
||||||
|
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Disabled.Message"));
|
||||||
|
} else {
|
||||||
|
playerData.setChatSpy(true);
|
||||||
|
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Enabled.Message"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||||
|
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "chatspy";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInfoMessagePath() {
|
||||||
|
return "Command.Island.Admin.ChatSpy.Info.Message";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getAliases() {
|
||||||
|
return new String[]{"spychat", "spy"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getArguments() {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ import com.songoda.skyblock.message.MessageManager;
|
|||||||
import com.songoda.skyblock.placeholder.PlaceholderManager;
|
import com.songoda.skyblock.placeholder.PlaceholderManager;
|
||||||
import com.songoda.skyblock.playerdata.PlayerData;
|
import com.songoda.skyblock.playerdata.PlayerData;
|
||||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||||
|
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -88,7 +89,20 @@ public class Chat implements Listener {
|
|||||||
String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer,
|
String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer,
|
||||||
islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName())))
|
islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName())))
|
||||||
.replace("%message", islandChatEvent.getMessage());
|
.replace("%message", islandChatEvent.getMessage());
|
||||||
targetPlayer.sendMessage(message);
|
messageManager.sendMessage(targetPlayer, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Player targetPlayer : Bukkit.getServer().getOnlinePlayers()){
|
||||||
|
if(targetPlayer.hasPermission("fabledskyblock.admin.chatspy")) {
|
||||||
|
PlayerData pd = playerDataManager.getPlayerData(targetPlayer);
|
||||||
|
if(pd != null && pd.isChatSpy()) {
|
||||||
|
String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer,
|
||||||
|
islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName())))
|
||||||
|
.replace("%islandOwner", new OfflinePlayer(island.getOwnerUUID()).getName())
|
||||||
|
.replace("%message", islandChatEvent.getMessage());
|
||||||
|
messageManager.sendMessage(targetPlayer, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
|
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
|
||||||
|
@ -34,6 +34,8 @@ public class PlayerData {
|
|||||||
|
|
||||||
private Area area;
|
private Area area;
|
||||||
|
|
||||||
|
private boolean chatSpy;
|
||||||
|
|
||||||
private boolean chat;
|
private boolean chat;
|
||||||
private boolean preview;
|
private boolean preview;
|
||||||
|
|
||||||
@ -52,6 +54,8 @@ public class PlayerData {
|
|||||||
|
|
||||||
area = new Area();
|
area = new Area();
|
||||||
|
|
||||||
|
chatSpy = getConfig().getFileConfiguration().getBoolean("ChatSpy", false);
|
||||||
|
|
||||||
chat = false;
|
chat = false;
|
||||||
preview = false;
|
preview = false;
|
||||||
transactions = new ArrayList<>();
|
transactions = new ArrayList<>();
|
||||||
@ -307,4 +311,13 @@ public class PlayerData {
|
|||||||
public List<Transaction> getTransactions() {
|
public List<Transaction> getTransactions() {
|
||||||
return transactions;
|
return transactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isChatSpy() {
|
||||||
|
return chatSpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChatSpy(boolean chatSpy) {
|
||||||
|
this.chatSpy = chatSpy;
|
||||||
|
getConfig().getFileConfiguration().set("ChatSpy", chatSpy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,13 @@ Command:
|
|||||||
Message: 'Succesfully removed %ammount% from %player%''s island'
|
Message: 'Succesfully removed %ammount% from %player%''s island'
|
||||||
SuccesDeposit:
|
SuccesDeposit:
|
||||||
Message: 'Succesfully added %ammount% to %player%''s island'
|
Message: 'Succesfully added %ammount% to %player%''s island'
|
||||||
|
ChatSpy:
|
||||||
|
Info:
|
||||||
|
Message: '&f&oToggle island chat spy.'
|
||||||
|
Enabled:
|
||||||
|
Message: '&bSkyBlock &8| &aInfo&8: &eChat spy enabled.'
|
||||||
|
Disabled:
|
||||||
|
Message: '&bSkyBlock &8| &aInfo&8: &eChat spy disabled.'
|
||||||
Reload:
|
Reload:
|
||||||
Info:
|
Info:
|
||||||
Message: '&f&oReload all loaded files.'
|
Message: '&f&oReload all loaded files.'
|
||||||
@ -3542,6 +3549,13 @@ Island:
|
|||||||
Message: '&8[&bSkyBlock &8| &dChat&8] %role &e%player&8: &f%message'
|
Message: '&8[&bSkyBlock &8| &dChat&8] %role &e%player&8: &f%message'
|
||||||
Untoggled:
|
Untoggled:
|
||||||
Message: '&bSkyBlock &8| &aInfo&8: &eThe Island chat has been untoggled because there are no Island Members online. Chat messages will now be visible for all players.'
|
Message: '&bSkyBlock &8| &aInfo&8: &eThe Island chat has been untoggled because there are no Island Members online. Chat messages will now be visible for all players.'
|
||||||
|
Spy:
|
||||||
|
Format:
|
||||||
|
Role:
|
||||||
|
Member: '&a[Member]'
|
||||||
|
Operator: '&b[Operator]'
|
||||||
|
Owner: '&c[Owner]'
|
||||||
|
Message: '&8[&bSkyBlock &8| &dChatSpy&8] [&7%islandOwner&8] &e%player&8: &f%message'
|
||||||
SpawnProtection:
|
SpawnProtection:
|
||||||
Break:
|
Break:
|
||||||
Message: '&bSkyBlock &8| &cError&8: &eYou cannot break the spawn point of the Island.'
|
Message: '&bSkyBlock &8| &cError&8: &eYou cannot break the spawn point of the Island.'
|
||||||
|
Loading…
Reference in New Issue
Block a user