mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 18:32:24 +00:00
Allow multiline broadcast messages
Apparently the new-line character isn't detected so I had to make a workaround with a custom new-line character (#n) where it could split the lines.
This commit is contained in:
parent
5f5fd05e6c
commit
54b0f42eaf
@ -167,7 +167,11 @@ public class Commands extends BukkitCommand {
|
|||||||
|
|
||||||
if (perm.has(player, "shopchest.broadcast")) {
|
if (perm.has(player, "shopchest.broadcast")) {
|
||||||
if (Config.enable_broadcast()) ShopChest.broadcast = uc.getBroadcast();
|
if (Config.enable_broadcast()) ShopChest.broadcast = uc.getBroadcast();
|
||||||
if (!ShopChest.broadcast.equals("")) player.sendMessage(ShopChest.broadcast);
|
if (ShopChest.broadcast != null) {
|
||||||
|
for (String message : ShopChest.broadcast) {
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class ShopChest extends JavaPlugin{
|
|||||||
public static boolean isUpdateNeeded = false;
|
public static boolean isUpdateNeeded = false;
|
||||||
public static String latestVersion = "";
|
public static String latestVersion = "";
|
||||||
public static String downloadLink = "";
|
public static String downloadLink = "";
|
||||||
public static String broadcast = "";
|
public static String[] broadcast = null;
|
||||||
|
|
||||||
public static Utils utils;
|
public static Utils utils;
|
||||||
|
|
||||||
@ -226,11 +226,19 @@ public class ShopChest extends JavaPlugin{
|
|||||||
|
|
||||||
for (Player p : getServer().getOnlinePlayers()) {
|
for (Player p : getServer().getOnlinePlayers()) {
|
||||||
if (perm.has(p, "shopchest.broadcast")) {
|
if (perm.has(p, "shopchest.broadcast")) {
|
||||||
if (!broadcast.equals("")) p.sendMessage(broadcast);
|
if (broadcast != null) {
|
||||||
|
for (String message : broadcast) {
|
||||||
|
p.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!broadcast.equals("")) Bukkit.getConsoleSender().sendMessage("[ShopChest] " + broadcast);
|
if (broadcast != null) {
|
||||||
|
for (String message : broadcast) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage("[ShopChest] " + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
File itemNamesFile = new File(getDataFolder(), "item_names.txt");
|
File itemNamesFile = new File(getDataFolder(), "item_names.txt");
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class Config {
|
|||||||
public static boolean buy_greater_or_equal_sell() {return plugin.getConfig().getBoolean("buy-greater-or-equal-sell");}
|
public static boolean buy_greater_or_equal_sell() {return plugin.getConfig().getBoolean("buy-greater-or-equal-sell");}
|
||||||
public static boolean hopper_protection() {return plugin.getConfig().getBoolean("hopper-protection");}
|
public static boolean hopper_protection() {return plugin.getConfig().getBoolean("hopper-protection");}
|
||||||
public static boolean explosion_protection() {return plugin.getConfig().getBoolean("explosion-protection)");}
|
public static boolean explosion_protection() {return plugin.getConfig().getBoolean("explosion-protection)");}
|
||||||
public static boolean enable_broadcast() {return plugin.getConfig().getBoolean("enable-broadcast)");}
|
public static boolean enable_broadcast() {return plugin.getConfig().getBoolean("enable-broadcast");}
|
||||||
|
|
||||||
public static double maximal_distance() {return plugin.getConfig().getDouble("maximal-distance");}
|
public static double maximal_distance() {return plugin.getConfig().getDouble("maximal-distance");}
|
||||||
public static int default_limit() {return plugin.getConfig().getInt("shop-limits.default");}
|
public static int default_limit() {return plugin.getConfig().getInt("shop-limits.default");}
|
||||||
|
@ -39,7 +39,11 @@ public class NotifyUpdate implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (perm.has(p, "shopchest.broadcast")) {
|
if (perm.has(p, "shopchest.broadcast")) {
|
||||||
if (!ShopChest.broadcast.equals("")) p.sendMessage(ShopChest.broadcast);
|
if (ShopChest.broadcast != null) {
|
||||||
|
for (String message : ShopChest.broadcast) {
|
||||||
|
p.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class UpdateChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBroadcast() {
|
public String[] getBroadcast() {
|
||||||
try {
|
try {
|
||||||
Connection con = Jsoup.connect("http://textuploader.com/5b51f/raw");
|
Connection con = Jsoup.connect("http://textuploader.com/5b51f/raw");
|
||||||
con.userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0");
|
con.userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0");
|
||||||
@ -53,12 +53,14 @@ public class UpdateChecker {
|
|||||||
|
|
||||||
String broadcast = doc.text();
|
String broadcast = doc.text();
|
||||||
|
|
||||||
|
String[] messages = broadcast.split("#n");
|
||||||
|
|
||||||
if (!broadcast.equals("/"))
|
if (!broadcast.equals("/"))
|
||||||
return broadcast;
|
return messages;
|
||||||
|
|
||||||
} catch (Exception | Error e) {}
|
} catch (Exception | Error e) {}
|
||||||
|
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
|
Loading…
Reference in New Issue
Block a user