1.2
- T2CodeLib 15.9 is required! - Strings and lists can now be used for the message Examples: String: message: 'test List: message: - test 1 - test 2
This commit is contained in:
parent
b9d20ffb06
commit
ea4fb0b88d
9
pom.xml
9
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>AutomatedMessages</artifactId>
|
<artifactId>AutomatedMessages</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.2</version>
|
||||||
<!--version>VERSION_snapshot-0</version-->
|
<!--version>VERSION_snapshot-0</version-->
|
||||||
<!--version>VERSION_beta-0</version-->
|
<!--version>VERSION_beta-0</version-->
|
||||||
<!--version>VERSION_dev-0</version-->
|
<!--version>VERSION_dev-0</version-->
|
||||||
@ -27,8 +27,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${java.version}</source>
|
<source>9</source>
|
||||||
<target>${java.version}</target>
|
<target>9</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -84,7 +84,8 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>T2CodeLib</artifactId>
|
<artifactId>T2CodeLib</artifactId>
|
||||||
<version>15.3</version>
|
<version>15.9</version>
|
||||||
|
<classifier>dev-2</classifier>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||||
|
@ -8,7 +8,7 @@ public class Util {
|
|||||||
private static String infoText = "";
|
private static String infoText = "";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static String requiredT2CodeLibVersion = "15.3";
|
private static String requiredT2CodeLibVersion = "15.9";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static String prefix = "<dark_gray>[<dark_red>T2C</dark_red>-<color:#5cff5c>Automated</color><color:#69d2ff>Messages</color>]</dark_gray>";
|
private static String prefix = "<dark_gray>[<dark_red>T2C</dark_red>-<color:#5cff5c>Automated</color><color:#69d2ff>Messages</color>]</dark_gray>";
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class MessagesSelect {
|
public class MessagesSelect {
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ public class MessagesSelect {
|
|||||||
|
|
||||||
for (Messages value : Messages.values()) {
|
for (Messages value : Messages.values()) {
|
||||||
Boolean enable = yamlConfiguration.getBoolean(value.msgEnablePath);
|
Boolean enable = yamlConfiguration.getBoolean(value.msgEnablePath);
|
||||||
String message = yamlConfiguration.getString(value.msgMsgPath);
|
Object message = yamlConfiguration.get(value.msgMsgPath);
|
||||||
Boolean soundEnable = yamlConfiguration.getBoolean(value.soundEnablePath);
|
Boolean soundEnable = yamlConfiguration.getBoolean(value.soundEnablePath);
|
||||||
|
|
||||||
Sound sound;
|
Sound sound;
|
||||||
|
@ -7,17 +7,44 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.*;
|
||||||
|
|
||||||
public class SendMessage {
|
public class SendMessage {
|
||||||
public static void send(Message message) {
|
public static void send(Message message) {
|
||||||
String timeStamp = new SimpleDateFormat(Config.timeFormat.valueString).format(Calendar.getInstance().getTime());
|
String timeStamp = new SimpleDateFormat(Config.timeFormat.valueString).format(Calendar.getInstance().getTime());
|
||||||
if (Config.sendConsole.valueBoolean) T2Csend.console(message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString));
|
if (Config.sendConsole.valueBoolean) {
|
||||||
|
T2Csend.console(replace(message.message, Map.entry("[time]", timeStamp), Map.entry("[prefix]", Config.prefix.valueString)));
|
||||||
|
}
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (player.hasPermission(message.permission) || !message.permissionNeededToSeeMessage){
|
if (player.hasPermission(message.permission) || !message.permissionNeededToSeeMessage) {
|
||||||
T2Csend.player(player, message.message.replace("[time]", timeStamp).replace("[prefix]",Config.prefix.valueString).replace("[player]",player.getName()));
|
T2Csend.player(player, replace(message.message, Map.entry("[time]", timeStamp), Map.entry("[prefix]", Config.prefix.valueString), Map.entry("[player]", player.getName())));
|
||||||
player.playSound(player.getLocation(), message.sound, 3, 1);
|
player.playSound(player.getLocation(), message.sound, 3, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
private static Object replace(Object object, Map.Entry<String, String>... map) {
|
||||||
|
Object o = null;
|
||||||
|
if (object instanceof List) {
|
||||||
|
ArrayList<String> res = (ArrayList<String>) object;
|
||||||
|
ArrayList<String> out = new ArrayList<>();
|
||||||
|
for (String s : res) {
|
||||||
|
String re = s;
|
||||||
|
for (Map.Entry<String, String> placeholder : map) {
|
||||||
|
re = re.replace(placeholder.getKey(), placeholder.getValue());
|
||||||
|
}
|
||||||
|
out.add(re);
|
||||||
|
}
|
||||||
|
o = out;
|
||||||
|
}
|
||||||
|
if (object instanceof String) {
|
||||||
|
String res = (String) object;
|
||||||
|
for (Map.Entry<String, String> placeholder : map) {
|
||||||
|
res = res.replace(placeholder.getKey(), placeholder.getValue());
|
||||||
|
}
|
||||||
|
o = res;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ public class Message {
|
|||||||
|
|
||||||
public String key;
|
public String key;
|
||||||
public Boolean enable;
|
public Boolean enable;
|
||||||
public String message;
|
public Object message;
|
||||||
|
|
||||||
public Boolean soundEnable;
|
public Boolean soundEnable;
|
||||||
public Sound sound;
|
public Sound sound;
|
||||||
@ -25,7 +25,7 @@ public class Message {
|
|||||||
|
|
||||||
public Message(String key,
|
public Message(String key,
|
||||||
Boolean enable,
|
Boolean enable,
|
||||||
String message,
|
Object message,
|
||||||
Boolean soundEnable,
|
Boolean soundEnable,
|
||||||
Sound sound,
|
Sound sound,
|
||||||
Boolean permissionNeededToSeeMessage,
|
Boolean permissionNeededToSeeMessage,
|
||||||
|
Loading…
Reference in New Issue
Block a user