mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-10 04:31:06 +00:00
Re-added broadcast messages
They work a bit different now. They are still only shown on startup, on join or when a player checks for updates, but also if no update is available. Also the player needs the permission "shopchest.broadcast" in order to get the message.
This commit is contained in:
parent
e1198028ee
commit
558741e587
@ -48,8 +48,6 @@ hopper-protection: true
|
||||
explosion-protection: true
|
||||
|
||||
# Set whether broadcast messages should be enabled
|
||||
# The messages are sent to every player who have permission to get update notifications.
|
||||
# They are sent each time the update checker checks for an update below the message whether an update is available.
|
||||
enable-broadcast: true
|
||||
|
||||
# Set the currency symbol after price values
|
||||
|
@ -64,3 +64,6 @@ permissions:
|
||||
shopchest.limits:
|
||||
description: Allows you to view shop limits.
|
||||
default: true
|
||||
shopchest.broadcast:
|
||||
description: Allows you to get broadcast messages.
|
||||
default: op
|
@ -212,6 +212,10 @@ public class Commands extends BukkitCommand {
|
||||
player.sendMessage(Config.update_check_error());
|
||||
}
|
||||
|
||||
if (perm.has(player, "shopchest.broadcast")) {
|
||||
if (Config.enable_broadcast()) ShopChest.broadcast = uc.getBroadcast();
|
||||
if (!ShopChest.broadcast.equals("")) player.sendMessage(ShopChest.broadcast);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ public class ShopChest extends JavaPlugin{
|
||||
public static boolean isUpdateNeeded = false;
|
||||
public static String latestVersion = "";
|
||||
public static String downloadLink = "";
|
||||
public static String broadcast = "";
|
||||
|
||||
public static Utils utils;
|
||||
|
||||
@ -191,6 +192,8 @@ public class ShopChest extends JavaPlugin{
|
||||
UpdateChecker uc = new UpdateChecker(this, getDescription().getWebsite());
|
||||
UpdateCheckerResult result = uc.updateNeeded();
|
||||
|
||||
if (Config.enable_broadcast()) broadcast = uc.getBroadcast();
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage("[ShopChest] " + Config.checking_update());
|
||||
if(result == UpdateCheckerResult.TRUE) {
|
||||
latestVersion = uc.getVersion();
|
||||
@ -224,6 +227,14 @@ public class ShopChest extends JavaPlugin{
|
||||
Bukkit.getConsoleSender().sendMessage("[ShopChest] " + Config.update_check_error());
|
||||
}
|
||||
|
||||
for (Player p : getServer().getOnlinePlayers()) {
|
||||
if (perm.has(p, "shopchest.broadcast")) {
|
||||
if (!broadcast.equals("")) p.sendMessage(broadcast);
|
||||
}
|
||||
}
|
||||
|
||||
if (!broadcast.equals("")) Bukkit.getConsoleSender().sendMessage("[ShopChest] " + broadcast);
|
||||
|
||||
File itemNamesFile = new File(getDataFolder(), "item_names.txt");
|
||||
|
||||
if (!itemNamesFile.exists())
|
||||
|
@ -38,6 +38,10 @@ public class NotifyUpdate implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (perm.has(p, "shopchest.broadcast")) {
|
||||
if (!ShopChest.broadcast.equals("")) p.sendMessage(ShopChest.broadcast);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,6 +44,23 @@ public class UpdateChecker {
|
||||
}
|
||||
}
|
||||
|
||||
public String getBroadcast() {
|
||||
try {
|
||||
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");
|
||||
|
||||
Document doc = con.get();
|
||||
|
||||
String broadcast = doc.text();
|
||||
|
||||
if (!broadcast.equals("/"))
|
||||
return broadcast;
|
||||
|
||||
} catch (Exception | Error e) {}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user