Move updatemessage and permission to disguiseconfig
This commit is contained in:
parent
7864920385
commit
de94e6a757
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise;
|
||||
|
||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
@ -34,6 +35,10 @@ public class DisguiseConfig {
|
||||
private static boolean showNameAboveHeadAlwaysVisible;
|
||||
private static boolean targetDisguises;
|
||||
private static boolean undisguiseSwitchWorlds;
|
||||
private static String updateMessage = ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED
|
||||
+ "There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED
|
||||
+ ", the new version is " + ChatColor.RED + "%s" + ChatColor.DARK_RED + "!";
|
||||
private static String updateNotificationPermission;
|
||||
private static boolean witherSkullEnabled;
|
||||
|
||||
public static String getDisguiseBlownMessage() {
|
||||
@ -52,6 +57,14 @@ public class DisguiseConfig {
|
||||
return maxClonedDisguises;
|
||||
}
|
||||
|
||||
public static String getUpdateMessage() {
|
||||
return updateMessage;
|
||||
}
|
||||
|
||||
public static String getUpdateNotificationPermission() {
|
||||
return updateNotificationPermission;
|
||||
}
|
||||
|
||||
public static void initConfig(ConfigurationSection config) {
|
||||
setSoundsEnabled(config.getBoolean("DisguiseSounds"));
|
||||
setVelocitySent(config.getBoolean("SendVelocity"));
|
||||
@ -85,6 +98,7 @@ public class DisguiseConfig {
|
||||
setSheepDyeable(config.getBoolean("DyeableSheep"));
|
||||
setWolfDyeable(config.getBoolean("DyeableWolf"));
|
||||
setUndisguiseOnWorldChange(config.getBoolean("UndisguiseOnWorldChange"));
|
||||
setUpdateNotificationPermission(config.getString("Permission"));
|
||||
}
|
||||
|
||||
public static boolean isAnimationPacketsEnabled() {
|
||||
@ -380,6 +394,14 @@ public class DisguiseConfig {
|
||||
undisguiseSwitchWorlds = isUndisguise;
|
||||
}
|
||||
|
||||
public static void setUpdateMessage(String newMessage) {
|
||||
updateMessage = newMessage;
|
||||
}
|
||||
|
||||
public static void setUpdateNotificationPermission(String newPermission) {
|
||||
updateNotificationPermission = newPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get?
|
||||
*/
|
||||
|
@ -47,14 +47,9 @@ public class DisguiseListener implements Listener {
|
||||
private HashMap<String, BukkitRunnable> disguiseRunnable = new HashMap<String, BukkitRunnable>();
|
||||
private String latestVersion;
|
||||
private LibsDisguises plugin;
|
||||
private String updateMessage = ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED
|
||||
+ "There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED
|
||||
+ ", the new version is " + ChatColor.RED + "%s" + ChatColor.DARK_RED + "!";
|
||||
private String updateNotifyPermission;
|
||||
|
||||
public DisguiseListener(LibsDisguises libsDisguises) {
|
||||
plugin = libsDisguises;
|
||||
updateNotifyPermission = plugin.getConfig().getString("Permission");
|
||||
if (plugin.getConfig().getBoolean("NotifyUpdate")) {
|
||||
currentVersion = plugin.getDescription().getVersion();
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
@ -68,8 +63,9 @@ public class DisguiseListener implements Listener {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
if (p.hasPermission(updateNotifyPermission))
|
||||
p.sendMessage(String.format(updateMessage, currentVersion, latestVersion));
|
||||
if (p.hasPermission(DisguiseConfig.getUpdateNotificationPermission()))
|
||||
p.sendMessage(String.format(DisguiseConfig.getUpdateMessage(), currentVersion,
|
||||
latestVersion));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -138,8 +134,8 @@ public class DisguiseListener implements Listener {
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
if (latestVersion != null && p.hasPermission(updateNotifyPermission)) {
|
||||
p.sendMessage(String.format(updateMessage, currentVersion, latestVersion));
|
||||
if (latestVersion != null && p.hasPermission(DisguiseConfig.getUpdateNotificationPermission())) {
|
||||
p.sendMessage(String.format(DisguiseConfig.getUpdateMessage(), currentVersion, latestVersion));
|
||||
}
|
||||
if (DisguiseConfig.isBedPacketsEnabled()) {
|
||||
chunkMove(p, p.getLocation(), null);
|
||||
|
Loading…
Reference in New Issue
Block a user