Mostly visual changes and cleanup
+ Added tps formatter to Style.java * Updated plugin.yml to include Author and Website * Updated NetworkCommand.java to wrap information nicely
This commit is contained in:
parent
6d6134e670
commit
14c6ee1d03
|
@ -4,6 +4,7 @@ import com.google.gson.JsonObject;
|
|||
import com.jonahseguin.drink.annotation.Command;
|
||||
import com.jonahseguin.drink.annotation.Sender;
|
||||
import org.atmospheregames.network.Network;
|
||||
import org.atmospheregames.network.util.Style;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class NetworkCommand {
|
||||
|
@ -13,22 +14,22 @@ public class NetworkCommand {
|
|||
public NetworkCommand(Network plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Command(name = "info", desc = "Find information about a server", usage = "<server>")
|
||||
@Command(name = "info", desc = "Show information about a server", usage = "<server>")
|
||||
public void networkInfo(@Sender CommandSender sender, String target) {
|
||||
JsonObject object = plugin.getRedisClient().getRedisListener().getCachedMessages().get(target);
|
||||
|
||||
if(object == null) {
|
||||
sender.sendMessage("Failed to find a server with the name: " + target);
|
||||
if (object == null) {
|
||||
sender.sendMessage(Style.translate("&cUnable to find the server &n" + target + "&r&c. &7Remember, this command is case-sensitive."));
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("Server Information: " + target);
|
||||
sender.sendMessage(object.get("online").getAsString());
|
||||
sender.sendMessage(object.get("whitelisted").getAsString());
|
||||
sender.sendMessage(object.get("onlinePlayers").getAsString());
|
||||
sender.sendMessage(object.get("onlinePlayerLimit").getAsString());
|
||||
sender.sendMessage(object.get("ticksPerSecond").getAsString());
|
||||
sender.sendMessage(Style.CHAT_BAR);
|
||||
sender.sendMessage(Style.translate("&b&lServer Information for &n" + target));
|
||||
sender.sendMessage(Style.CHAT_BAR);
|
||||
sender.sendMessage(Style.translate(" &3• &fStatus: " + (object.get("online").getAsBoolean() ? "&aOnline" : "&cOffline") + (object.get("whitelisted").getAsBoolean() ? " &7(&eWhitelisted&7)" : "")));
|
||||
sender.sendMessage(Style.translate(" &3• &fOnline: &b" + object.get("onlinePlayers").getAsString() + "&7/&b" + object.get("onlinePlayerLimit").getAsString()));
|
||||
sender.sendMessage(Style.translate(" &3• &fTPS: &r" + Style.tps(object.get("ticksPerSecond").getAsDouble())));
|
||||
sender.sendMessage(Style.CHAT_BAR);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class RedisClient {
|
|||
private final JedisPool jedisPool;
|
||||
|
||||
public RedisClient(Network plugin) {
|
||||
this.jedisPool = new JedisPool(plugin.getConfig().getString("REDIS.HOSTNAME"), plugin.getConfig().getInt("REDIS.PORT"));
|
||||
this.jedisPool = new JedisPool(plugin.getConfig().getString("REDIS.HOST"), plugin.getConfig().getInt("REDIS.PORT"));
|
||||
this.redisListener = new RedisListener();
|
||||
|
||||
Jedis jedis = jedisPool.getResource();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class RedisListener extends JedisPubSub {
|
|||
if(!player.hasPermission("network.servermonitor"))
|
||||
continue;
|
||||
|
||||
player.sendMessage(Style.translate("&6[Server Monitor] &fThe server &e" + serverName + " &fhas gone &coffline"));
|
||||
player.sendMessage(Style.translate("&6[Server Monitor] &fThe server &e" + serverName + " &fhas gone &coffline&f."));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,25 @@ public class Style {
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
public static String tps(Double input) {
|
||||
double tpsValue = Math.min(20, Math.round(input* 10) / 10.0);
|
||||
String color;
|
||||
if (tpsValue > 19.2D) {
|
||||
color = Style.GREEN;
|
||||
} else if (tpsValue > 17.4D) {
|
||||
color = Style.YELLOW;
|
||||
} else {
|
||||
color = Style.RED;
|
||||
}
|
||||
|
||||
String tps = String.valueOf(tpsValue);
|
||||
if (tps.equals("20.0")) {
|
||||
tps = "*20.0";
|
||||
}
|
||||
|
||||
return color+tps;
|
||||
}
|
||||
|
||||
public static List<String> strip(List<String> inputs) {
|
||||
List<String> toReturn = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
REDIS:
|
||||
HOSTNAME: "172.17.0.1"
|
||||
HOST: "172.17.0.1"
|
||||
PORT: 6379
|
||||
PASSWORD: ""
|
||||
|
||||
SERVER-NAME: "Hub-01"
|
|
@ -1,4 +1,6 @@
|
|||
name: Network
|
||||
author: Atmosphere Games
|
||||
website: https://git.atmospheregames.org/Atmosphere-Games/Network
|
||||
version: '${project.version}'
|
||||
main: org.atmospheregames.network.Network
|
||||
api-version: '1.20'
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,6 @@
|
|||
REDIS:
|
||||
HOSTNAME: "172.17.0.1"
|
||||
HOST: "172.17.0.1"
|
||||
PORT: 6379
|
||||
PASSWORD: ""
|
||||
|
||||
SERVER-NAME: "Hub-01"
|
|
@ -1,4 +1,6 @@
|
|||
name: Network
|
||||
author: Atmosphere Games
|
||||
website: https://git.atmospheregames.org/Atmosphere-Games/Network
|
||||
version: '1.0-SNAPSHOT'
|
||||
main: org.atmospheregames.network.Network
|
||||
api-version: '1.20'
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue