From 14d23c2d57bf8346dcc5111d3f80b0dc2c7d8478 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 6 Jul 2016 17:05:30 +0200 Subject: [PATCH] Removed broadcast message This was never really used... Also, in the API, you can now get the player of the ShopPreInfoEvent --- .../java/de/epiceric/shopchest/Commands.java | 12 +------ .../java/de/epiceric/shopchest/ShopChest.java | 35 +------------------ .../de/epiceric/shopchest/config/Config.java | 3 -- .../shopchest/event/ShopCreateEvent.java | 2 +- .../shopchest/event/ShopPreInfoEvent.java | 4 +++ .../listeners/NotifyUpdateOnJoinListener.java | 8 ----- .../shopchest/utils/UpdateChecker.java | 33 +---------------- ShopChest/src/main/resources/config.yml | 3 -- ShopChest/src/main/resources/plugin.yml | 5 +-- 9 files changed, 9 insertions(+), 96 deletions(-) diff --git a/ShopChest/src/main/java/de/epiceric/shopchest/Commands.java b/ShopChest/src/main/java/de/epiceric/shopchest/Commands.java index 7e6d169..a7df01a 100644 --- a/ShopChest/src/main/java/de/epiceric/shopchest/Commands.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/Commands.java @@ -149,7 +149,7 @@ public class Commands extends BukkitCommand { player.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CHECKING)); UpdateChecker uc = new UpdateChecker(ShopChest.getInstance()); - UpdateCheckerResult result = uc.updateNeeded(); + UpdateCheckerResult result = uc.check(); if (result == UpdateCheckerResult.TRUE) { plugin.setLatestVersion(uc.getVersion()); @@ -192,16 +192,6 @@ public class Commands extends BukkitCommand { plugin.setUpdateNeeded(false); player.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_ERROR)); } - - if (perm.has(player, "shopchest.broadcast")) { - if (Config.enable_broadcast) plugin.setBroadcast(uc.getBroadcast()); - if (plugin.getBroadcast() != null) { - for (String message : plugin.getBroadcast()) { - player.sendMessage(message); - } - } - } - } /** diff --git a/ShopChest/src/main/java/de/epiceric/shopchest/ShopChest.java b/ShopChest/src/main/java/de/epiceric/shopchest/ShopChest.java index 829581f..1501e17 100644 --- a/ShopChest/src/main/java/de/epiceric/shopchest/ShopChest.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/ShopChest.java @@ -46,7 +46,6 @@ public class ShopChest extends JavaPlugin { private boolean isUpdateNeeded = false; private String latestVersion = ""; private String downloadLink = ""; - private String[] broadcast = null; private LanguageConfiguration langConfig; /** @@ -260,9 +259,7 @@ public class ShopChest extends JavaPlugin { lwc = getServer().getPluginManager().getPlugin("LWC") != null; UpdateChecker uc = new UpdateChecker(this); - UpdateCheckerResult result = uc.updateNeeded(); - - if (Config.enable_broadcast) broadcast = uc.getBroadcast(); + UpdateCheckerResult result = uc.check(); Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CHECKING)); if (result == UpdateCheckerResult.TRUE) { @@ -312,22 +309,6 @@ public class ShopChest extends JavaPlugin { Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_ERROR)); } - for (Player p : getServer().getOnlinePlayers()) { - if (perm.has(p, "shopchest.broadcast")) { - if (broadcast != null) { - for (String message : broadcast) { - p.sendMessage(message); - } - } - } - } - - if (broadcast != null) { - for (String message : broadcast) { - Bukkit.getConsoleSender().sendMessage("[ShopChest] " + message); - } - } - try { Commands.registerCommand(new Commands(this, Config.main_command_name, "Manage Shops.", "", new ArrayList()), this); } catch (Exception e) { @@ -460,18 +441,4 @@ public class ShopChest extends JavaPlugin { this.downloadLink = downloadLink; } - /** - * @return The broadcast message as a string array of lines (will return null if not checked or if no message is available) - */ - public String[] getBroadcast() { - return broadcast; - } - - /** - * Set the broadcast message - * @param broadcast Broadcast message as a string array of lines to set - */ - public void setBroadcast(String[] broadcast) { - this.broadcast = broadcast; - } } diff --git a/ShopChest/src/main/java/de/epiceric/shopchest/config/Config.java b/ShopChest/src/main/java/de/epiceric/shopchest/config/Config.java index 7022b51..9998a10 100644 --- a/ShopChest/src/main/java/de/epiceric/shopchest/config/Config.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/config/Config.java @@ -73,9 +73,6 @@ public class Config { /** Whether shops should be protected by explosions **/ public static boolean explosion_protection = plugin.getConfig().getBoolean("explosion-protection"); - /** Whether broadcast messages should be enabled **/ - public static boolean enable_broadcast = plugin.getConfig().getBoolean("enable-broadcast"); - /** Whether admin shops should be excluded of the shop limits **/ public static boolean exclude_admin_shops = plugin.getConfig().getBoolean("shop-limits.exclude-admin-shops"); diff --git a/ShopChest/src/main/java/de/epiceric/shopchest/event/ShopCreateEvent.java b/ShopChest/src/main/java/de/epiceric/shopchest/event/ShopCreateEvent.java index 4678e20..0036ac9 100644 --- a/ShopChest/src/main/java/de/epiceric/shopchest/event/ShopCreateEvent.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/event/ShopCreateEvent.java @@ -4,7 +4,7 @@ import de.epiceric.shopchest.shop.Shop; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; -public class ShopCreateEvent extends ShopEvent implements Cancellable{ +public class ShopCreateEvent extends ShopEvent implements Cancellable { private Player player; private Shop shop; private double creationPrice; diff --git a/ShopChest/src/main/java/de/epiceric/shopchest/event/ShopPreInfoEvent.java b/ShopChest/src/main/java/de/epiceric/shopchest/event/ShopPreInfoEvent.java index dc64af5..ffd404e 100644 --- a/ShopChest/src/main/java/de/epiceric/shopchest/event/ShopPreInfoEvent.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/event/ShopPreInfoEvent.java @@ -14,6 +14,10 @@ public class ShopPreInfoEvent extends Event implements Cancellable { public ShopPreInfoEvent(Player player) { this.player = player; } + + public Player getPlayer() { + return player; + } @Override public boolean isCancelled() { diff --git a/ShopChest/src/main/java/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java index efc8473..90d46b4 100644 --- a/ShopChest/src/main/java/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java @@ -57,14 +57,6 @@ public class NotifyUpdateOnJoinListener implements Listener { } } - if (perm.has(p, "shopchest.broadcast")) { - if (plugin.getBroadcast() != null) { - for (String message : plugin.getBroadcast()) { - p.sendMessage(message); - } - } - } - } } diff --git a/ShopChest/src/main/java/de/epiceric/shopchest/utils/UpdateChecker.java b/ShopChest/src/main/java/de/epiceric/shopchest/utils/UpdateChecker.java index 4696a50..c0c4411 100644 --- a/ShopChest/src/main/java/de/epiceric/shopchest/utils/UpdateChecker.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/utils/UpdateChecker.java @@ -22,7 +22,7 @@ public class UpdateChecker { * * @return {@link UpdateCheckerResult#TRUE} if an update is available, {@link UpdateCheckerResult#FALSE} if no update is needed or {@link UpdateCheckerResult#ERROR} if an error occurred */ - public UpdateCheckerResult updateNeeded() { + public UpdateCheckerResult check() { try { URL url = new URL("http://textuploader.com/all1l/raw"); URLConnection conn = url.openConnection(); @@ -50,37 +50,6 @@ public class UpdateChecker { } } - /** - * Get the broadcast message - * @return A String Array of the lines of the broadcast message or null when no message is available - */ - public String[] getBroadcast() { - try { - URL url = new URL("http://textuploader.com/5b51f/raw"); - URLConnection conn = url.openConnection(); - conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0"); - conn.connect(); - - InputStreamReader isr = new InputStreamReader(conn.getInputStream()); - BufferedReader br = new BufferedReader(isr); - - String line = br.readLine(); - - isr.close(); - br.close(); - - String[] messages = line.split("#n"); - - if (!line.equals("/")) - return messages; - - } catch (Exception | Error e) { - e.printStackTrace(); - } - - return null; - } - /** * @return Latest Version or null if no update is available */ diff --git a/ShopChest/src/main/resources/config.yml b/ShopChest/src/main/resources/config.yml index 6299211..da3f9d3 100644 --- a/ShopChest/src/main/resources/config.yml +++ b/ShopChest/src/main/resources/config.yml @@ -32,9 +32,6 @@ hopper-protection: true # Set whether the shop's chest should be protected by explosions explosion-protection: true -# Set whether broadcast messages should be enabled -enable-broadcast: true - # Set whether the buy price must be greater than or equal sell price. buy-greater-or-equal-sell: true diff --git a/ShopChest/src/main/resources/plugin.yml b/ShopChest/src/main/resources/plugin.yml index fa6abf8..a984f95 100644 --- a/ShopChest/src/main/resources/plugin.yml +++ b/ShopChest/src/main/resources/plugin.yml @@ -57,7 +57,4 @@ permissions: default: op shopchest.limits: description: Allows you to view shop limits. - default: true - shopchest.broadcast: - description: Allows you to get broadcast messages. - default: op \ No newline at end of file + default: true \ No newline at end of file