diff --git a/src/main/java/Leees/Bungee/Queue/Bungee/Events.java b/src/main/java/Leees/Bungee/Queue/Bungee/Events.java index 0bb7688..3a7fe98 100644 --- a/src/main/java/Leees/Bungee/Queue/Bungee/Events.java +++ b/src/main/java/Leees/Bungee/Queue/Bungee/Events.java @@ -268,4 +268,12 @@ public void onkick(ServerKickEvent event) { event.setKickReason(Lang.KICKMESSAGE.replace("&", "§")); } } + + @EventHandler + public void onPing(ProxyPingEvent event) { + if (Lang.RANDOMICONS.contains("true")) { + if (LeeesBungeeQueue.getInstance().icons.size() > 0) + event.getResponse().setFavicon(LeeesBungeeQueue.getInstance().icons.get((int) (Math.random() * LeeesBungeeQueue.getInstance().icons.size()))); + } + } } diff --git a/src/main/java/Leees/Bungee/Queue/Bungee/Lang.java b/src/main/java/Leees/Bungee/Queue/Bungee/Lang.java index 98df9f0..8bc20a5 100644 --- a/src/main/java/Leees/Bungee/Queue/Bungee/Lang.java +++ b/src/main/java/Leees/Bungee/Queue/Bungee/Lang.java @@ -11,7 +11,7 @@ public class Lang { HEADER, FOOTER, POSITIONMESSAGEHOTBAR, QUEUESERVER, QUEUEPRIORITYPERMISSION, HEADERPRIORITY, FOOTERPRIORITY, REGEX, KICKMESSAGE, ADMINPERMISSION, ENABLEKICKMESSAGE, MAINSERVER, AUTHSERVER, ENABLEAUTHSERVER, SERVERDOWNKICKMESSAGE, SERVERPINGINFOENABLE, ALWAYSQUEUE, CUSTOMPROTOCOL, - CONNECTTOQUEUEWHENDOWN,ENABLEMOTD, MOTD, ENABLERANDOMMOTD, ENABLEQUEUESERVERSLOTS, AFTERQUEUE, ANTIBOT, ANTIBOTMESSAGE; + CONNECTTOQUEUEWHENDOWN,ENABLEMOTD, MOTD, ENABLERANDOMMOTD, ENABLEQUEUESERVERSLOTS, AFTERQUEUE, ANTIBOT, ANTIBOTMESSAGE, RANDOMICONS; public static int MAINSERVERSLOTS, QUEUESERVERSLOTS; public static List SERVERPINGINFO; public static List RANDOMMOTDS; diff --git a/src/main/java/Leees/Bungee/Queue/Bungee/LeeesBungeeQueue.java b/src/main/java/Leees/Bungee/Queue/Bungee/LeeesBungeeQueue.java index 76e7edd..05b27f3 100644 --- a/src/main/java/Leees/Bungee/Queue/Bungee/LeeesBungeeQueue.java +++ b/src/main/java/Leees/Bungee/Queue/Bungee/LeeesBungeeQueue.java @@ -1,5 +1,6 @@ package Leees.Bungee.Queue.Bungee; +import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -9,24 +10,30 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Logger; +import net.md_5.bungee.api.Favicon; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.ProxyPingEvent; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; +import net.md_5.bungee.event.EventHandler; import org.apache.commons.lang.ObjectUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import javax.imageio.ImageIO; + /** * LeeesBungeeQueue */ public class LeeesBungeeQueue extends Plugin { public LinkedHashMap regularqueue = new LinkedHashMap<>(); public LinkedHashMap priorityqueue = new LinkedHashMap<>(); + public LinkedHashMap getRegularqueue() { return regularqueue; } @@ -43,6 +50,8 @@ public static LeeesBungeeQueue getInstance() { return instance; } + List icons = new ArrayList(); + @Override public void onEnable() { instance = this; @@ -59,6 +68,37 @@ public void onEnable() { getProxy().getPluginManager().registerListener(this, new PingEvent()); logger.info("§9Scheduling tasks"); + + //Random icon + if (Lang.RANDOMICONS.contains("true")) { + logger.info("RandomIcon: Enabled"); + File iconsDir = new File(getDataFolder() + "/icons"); + if (!iconsDir.exists()) + iconsDir.mkdirs(); + File[] iconFiles = iconsDir.listFiles(); + if (iconFiles != null) { + for (File file : iconFiles) { + try { + BufferedImage bimg = ImageIO.read(file); + if (bimg.getHeight() == 64 && bimg.getWidth() == 64) { + this.icons.add(Favicon.create(bimg)); + } else { + getLogger().warning("Cannot load " + file.getName() + ": incorrect size. Must be 64x64 pixels."); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + if (this.icons.size() > 0) { + getLogger().info(this.icons.size() + " icons loaded."); + } else { + getLogger().warning("No icons found. Using default icon."); + } + } + } else { + logger.info("RandomIcon: Disabled"); + } + //sends the position message and updates tab on an interval for non priority players and priority players in chat getProxy().getScheduler().schedule(this, () -> { if (!Lang.POSITIONMESSAGEHOTBAR.equals("true")) { diff --git a/src/main/resources/bungee.yml b/src/main/resources/bungee.yml index 2dec5c2..ce81ed7 100644 --- a/src/main/resources/bungee.yml +++ b/src/main/resources/bungee.yml @@ -1,6 +1,6 @@ name: LeeesBungeeQueue main: Leees.Bungee.Queue.Bungee.LeeesBungeeQueue -version: 5.2.0 +version: 5.2.1 author: XeraPlugins authors: [Nate, Legault, Pistonmaster] commands: diff --git a/src/main/resources/bungeeconfig.yml b/src/main/resources/bungeeconfig.yml index c6656b7..0bfca0d 100644 --- a/src/main/resources/bungeeconfig.yml +++ b/src/main/resources/bungeeconfig.yml @@ -1,4 +1,4 @@ -#LeeesBungeeQueue V5.2.0 +#LeeesBungeeQueue V5.2.1 #make sure to follow the tutorial on the github #it tells you everything you need to do #https://github.com/XeraPlugins/LeeesBungeeQueue @@ -69,6 +69,13 @@ SERVERPINGINFO: - "&6Max players on main server: &l%maxplayers%" - "&6Donate to recieve priority queue at &chttps://donate.8b8t.me" CUSTOMPROTOCOL: "&18b&98t &61.8.x to 1.19.x" + + +#Do you want your server icons to change randomly +#you must place 64x64 .png images in the icons folder +RANDOMICONS: "true" + +#Do you want LBQ to control your MOTD's ? ENABLEMOTD: "true" MOTD: "&18b&98t &6Queue Size: Prio: &l%priosize% &6Reg: &l%regsize% &6Total: &l%total% &6Max: &l%maxplayers%" ENABLERANDOMMOTD: "true" diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5d5a5c8..ad29d16 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,4 +1,4 @@ -# LeeesBungeeQueue V5.2.0 +# LeeesBungeeQueue V5.2.1 # Note - Operators and users with the permission "queue.admin" will be excluded from restrictions. ## forceLocation: true # Force the user to remain in a certain location. diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index bbe9506..948c483 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: LeeesBungeeQueue -version: 5.2.0 +version: 5.2.1 api-version: 1.12 main: Leees.Bungee.Queue.Bukkit.Main author: Nate Legault