mirror of
https://github.com/TotalFreedomMC/TF-Marriage.git
synced 2025-02-05 14:22:45 +00:00
Add chat spy
This commit is contained in:
parent
efffa6a343
commit
d7d6d220bf
12 changed files with 122 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Marriage v2.0.8",
|
||||
"name": "Marriage v2.0.9",
|
||||
"type": "release",
|
||||
"gameVersion": "1.8.8",
|
||||
"downloadURL": "http://ci.lenis0012.com/job/Marriage/64/artifact/target/Marriage-Spigot-2.0.8.jar"
|
||||
"gameVersion": "1.9",
|
||||
"downloadURL": "http://ci.lenis0012.com/job/Marriage/67/artifact/target/Marriage-Spigot-2.0.9.jar"
|
||||
}
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>com.lenis0012.bukkit</groupId>
|
||||
<artifactId>marriage2</artifactId>
|
||||
<version>2.0.8</version>
|
||||
<version>2.0.9</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Marriage</name>
|
||||
<url>http://dev.bukkit.org/server-mods/marriage-reloaded/</url>
|
||||
|
|
|
@ -111,7 +111,31 @@ public interface MPlayer {
|
|||
*/
|
||||
void divorce();
|
||||
|
||||
/**
|
||||
* Get timestamp of last time player logged in.
|
||||
*
|
||||
* @return Last login timestamp.
|
||||
*/
|
||||
long getLastLogin();
|
||||
|
||||
/**
|
||||
* Get timestamp of last time player logged out.
|
||||
*
|
||||
* @return Last logout timestamp.
|
||||
*/
|
||||
long getLastLogout();
|
||||
|
||||
/**
|
||||
* Said whether or not player is spying on marriage private chat.
|
||||
*
|
||||
* @param enabled True if enables, false otherwise
|
||||
*/
|
||||
void setChatSpy(boolean enabled);
|
||||
|
||||
/**
|
||||
* Get whether or not player is spying on marriage private chat.
|
||||
*
|
||||
* @return True if enabled, false otherwise
|
||||
*/
|
||||
boolean isChatSpy();
|
||||
}
|
|
@ -2,8 +2,22 @@ package com.lenis0012.bukkit.marriage2;
|
|||
|
||||
import com.lenis0012.bukkit.marriage2.internal.MarriagePlugin;
|
||||
|
||||
/**
|
||||
* Marriage API.
|
||||
*
|
||||
* <b>Changelog:</b>
|
||||
* 1.01:
|
||||
* <ul>
|
||||
* <li>Added chat spy mode</li>
|
||||
* </ul>
|
||||
*
|
||||
* 1.00:
|
||||
* <ul>
|
||||
* <li>Release</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class MarriageAPI {
|
||||
private static final int API_VERSION = 100;
|
||||
private static final int API_VERSION = 101;
|
||||
|
||||
/**
|
||||
* Get the API main instance.
|
||||
|
@ -31,4 +45,15 @@ public class MarriageAPI {
|
|||
public static String getPluginVersion() {
|
||||
return MarriagePlugin.getInstance().getDescription().getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name/identifier of API version.
|
||||
* Includes API version and plugin version.
|
||||
* Used for debugging.
|
||||
*
|
||||
* @return API Version name
|
||||
*/
|
||||
public static String getName() {
|
||||
return "Marriage API v" + API_VERSION + " (plugin v" + getPluginVersion() + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.lenis0012.bukkit.marriage2.commands;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.lenis0012.bukkit.marriage2.config.Permissions;
|
||||
import com.lenis0012.bukkit.marriage2.config.Settings;
|
||||
import com.lenis0012.bukkit.marriage2.internal.Dependencies;
|
||||
|
@ -29,9 +30,9 @@ public abstract class Command {
|
|||
protected Player player;
|
||||
private String[] args;
|
||||
|
||||
public Command(Marriage marriage, String... aliases) {
|
||||
public Command(Marriage marriage, String command, String... aliases) {
|
||||
this.marriage = marriage;
|
||||
this.aliases = aliases;
|
||||
this.aliases = Lists.asList(command, aliases).toArray(new String[0]);
|
||||
if(aliases.length > 0) {
|
||||
this.permission = Permissions.getByNode("marry." + aliases[0]);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.lenis0012.bukkit.marriage2.commands;
|
||||
|
||||
import com.lenis0012.bukkit.marriage2.MPlayer;
|
||||
import com.lenis0012.bukkit.marriage2.Marriage;
|
||||
import com.lenis0012.bukkit.marriage2.config.Message;
|
||||
import com.lenis0012.bukkit.marriage2.config.Permissions;
|
||||
|
||||
public class CommandChatSpy extends Command {
|
||||
public CommandChatSpy(Marriage marriage) {
|
||||
super(marriage, "chatspy");
|
||||
setDescription("Enable admin chat spy.");
|
||||
setPermission(Permissions.CHAT_SPY);
|
||||
setHidden(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
MPlayer mPlayer = marriage.getMPlayer(player.getUniqueId());
|
||||
boolean mode = !mPlayer.isChatSpy();
|
||||
mPlayer.setChatSpy(mode);
|
||||
reply(mode ? Message.CHAT_SPY_ENABLED : Message.CHAT_SPY_DISABLED);
|
||||
}
|
||||
}
|
|
@ -42,6 +42,8 @@ public enum Message {
|
|||
MARRIED_TO("&fmarried to %s"),
|
||||
CHAT_ENABLED("&aYou are now in marriage chat mode!"),
|
||||
CHAT_DISABLED("&aYou are no longer in marriage chat mode!"),
|
||||
CHAT_SPY_ENABLED("&aNow spying on marriage private chat!"),
|
||||
CHAT_SPY_DISABLED("&aNo longer spying on marriage chat!"),
|
||||
|
||||
// COMMANDS
|
||||
COMMAND_CHAT("Enable partner-only chat mode"),
|
||||
|
|
|
@ -16,6 +16,7 @@ public enum Permissions {
|
|||
* Admin commands
|
||||
*/
|
||||
UPDATE("marry.update", PermissionDefault.FALSE, 1),
|
||||
CHAT_SPY("marry.chatspy", PermissionDefault.FALSE, 1),
|
||||
/**
|
||||
* Player commands
|
||||
*/
|
||||
|
|
|
@ -20,13 +20,14 @@ public class Settings {
|
|||
*/
|
||||
@ConfigHeader(path = "chat", value = {
|
||||
"Chat, set the format of private messages and in-chat status.",
|
||||
"Supported tags for chat: {partner}. for pm: {name}, {message}",
|
||||
"Supported tags for chat: {partner}, for pm: {name}, {message}, chat spy: {sender}, {receiver}, {message}",
|
||||
"Icons are always available: {icon:heart}, {icon:male}, {icon:female}, {icon:genderless}",
|
||||
"If you use a custom chat plugin, put {marriage_status} in the format and set force-status-format to false",
|
||||
"To show genders in chat, put {marriage_gender} in chat plugin format"
|
||||
})
|
||||
public static final ConfigOption<String> PM_FORMAT = new ConfigOption<>("chat.pm-format", "&4{icon:heart}&c{name}&4{icon:heart} &7{message}");
|
||||
public static final ConfigOption<String> CHAT_FORMAT = new ConfigOption<>("chat.status-format", "&4&l<3 &r");
|
||||
public static final ConfigOption<String> CHATSPY_FORMAT = new ConfigOption<>("cat.spy-format", "&c[CHAT SPY] &7{sender} -> {receiver}&f: {message}");
|
||||
public static final ConfigOption<Boolean> FORCE_FORMAT = new ConfigOption<>("chat.force-status-format", true);
|
||||
public static final ConfigOption<String> PREFIX_MALE = new ConfigOption<>("chat.male-prefix", "&b{icon:male} &r");
|
||||
public static final ConfigOption<String> PREFIX_FEMALE = new ConfigOption<>("chat.female-prefix", "&d{icon:female} &r");
|
||||
|
|
|
@ -22,6 +22,7 @@ public class MarriagePlayer implements MPlayer {
|
|||
private MData marriage;
|
||||
private Gender gender = Gender.UNKNOWN;
|
||||
private boolean inChat;
|
||||
private boolean chatSpy;
|
||||
private boolean priest;
|
||||
private long lastLogin;
|
||||
private long lastLogout;
|
||||
|
@ -136,11 +137,23 @@ public class MarriagePlayer implements MPlayer {
|
|||
this.priest = priest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastLogin() {
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastLogout() {
|
||||
return lastLogout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChatSpy() {
|
||||
return chatSpy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChatSpy(boolean chatSpy) {
|
||||
this.chatSpy = chatSpy;
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ public class ChatListener implements Listener {
|
|||
final Player player = event.getPlayer();
|
||||
MPlayer mp = core.getMPlayer(player.getUniqueId());
|
||||
if(mp.isInChat()) {
|
||||
// Private chat
|
||||
if(!isOnline(mp.getPartner())) {
|
||||
mp.setInChat(false);
|
||||
return;
|
||||
|
@ -39,6 +40,25 @@ public class ChatListener implements Listener {
|
|||
Player partner = Bukkit.getPlayer(mp.getPartner().getUniqueId());
|
||||
player.sendMessage(message);
|
||||
partner.sendMessage(message);
|
||||
|
||||
// Admin chat spy
|
||||
String adminMessage = null; // No need to format message if we're not going to send it.
|
||||
for(Player admin : Bukkit.getOnlinePlayers()) {
|
||||
if(admin.equals(player) || admin.equals(partner)) continue;
|
||||
final MPlayer mAdmin = core.getMPlayer(admin.getUniqueId());
|
||||
if(!mAdmin.isChatSpy()) continue;
|
||||
if(adminMessage == null) {
|
||||
// Format message
|
||||
adminMessage = Settings.CHATSPY_FORMAT.value()
|
||||
.replace("{sender}", player.getDisplayName())
|
||||
.replace("{receiver}", partner.getDisplayName());
|
||||
adminMessage = formatIcons(adminMessage);
|
||||
adminMessage = ChatColor.translateAlternateColorCodes('&', adminMessage)
|
||||
.replace("{message}", event.getMessage());
|
||||
}
|
||||
admin.sendMessage(adminMessage);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
{
|
||||
"version": "Marriage v2.0.8",
|
||||
"version": "Marriage v2.0.9",
|
||||
"data":
|
||||
[
|
||||
[
|
||||
"---[ Changelog ]---",
|
||||
"",
|
||||
"- Fixed player saving"
|
||||
"- Added command descriptions to config",
|
||||
"",
|
||||
"- Added command spy"
|
||||
],
|
||||
[
|
||||
"====[ DONATE ]====",
|
||||
|
|
Loading…
Reference in a new issue