mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-12-23 09:31:46 +00:00
Removed broadcast message
This was never really used... Also, in the API, you can now get the player of the ShopPreInfoEvent
This commit is contained in:
parent
0b3f45ccd1
commit
14d23c2d57
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<String>()), 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;
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 <b>null</b> 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 <b>null</b> if no update is available
|
||||
*/
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
default: true
|
Loading…
Reference in New Issue
Block a user