Skip to content

Commit

Permalink
5.2.1
Browse files Browse the repository at this point in the history
added random server icons note you will have to restart to update the icon list and ill be eventually making it work with /lbq reload
  • Loading branch information
Leeewith3Es authored Mar 8, 2023
1 parent ee561f2 commit 5323da3
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/main/java/Leees/Bungee/Queue/Bungee/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/Leees/Bungee/Queue/Bungee/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> SERVERPINGINFO;
public static List<String> RANDOMMOTDS;
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/Leees/Bungee/Queue/Bungee/LeeesBungeeQueue.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<UUID, String> regularqueue = new LinkedHashMap<>();
public LinkedHashMap<UUID, String> priorityqueue = new LinkedHashMap<>();

public LinkedHashMap<UUID, String> getRegularqueue() {
return regularqueue;
}
Expand All @@ -43,6 +50,8 @@ public static LeeesBungeeQueue getInstance() {
return instance;
}

List<Favicon> icons = new ArrayList<Favicon>();

@Override
public void onEnable() {
instance = this;
Expand All @@ -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")) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/bungeeconfig.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5323da3

Please sign in to comment.