Compare commits

...

10 Commits

Author SHA1 Message Date
31b65b694d Rename D7 to System Commad
All checks were successful
Build Plugin / build-test (push) Successful in 42s
2024-12-13 08:39:40 +01:00
be54d87289 timer command hotfix
All checks were successful
Build Plugin / build-test (push) Successful in 43s
2024-12-13 08:15:53 +01:00
a5c53696b8 Rename to LS
All checks were successful
Build Plugin / build-test (push) Successful in 43s
2024-12-11 12:21:53 +01:00
141bdd163f Hotfix and change Tablist Header
All checks were successful
Build Plugin / build-test (push) Successful in 59s
2024-11-27 19:16:08 +01:00
00f741eb2c Make ChatMessages have Status (Hopefully)
All checks were successful
Build Plugin / build-test (push) Successful in 42s
2024-11-26 18:24:02 +00:00
1701006db3 Hotfix (/playtime | Tablist TPS)
All checks were successful
Build Plugin / build-test (push) Successful in 46s
2024-11-25 21:50:22 +01:00
885030eae3 Fix PlaytimeCommand and Timer not shown
All checks were successful
Build Plugin / build-test (push) Successful in 43s
2024-11-25 17:16:47 +01:00
d75cb90cb6 Fix Typo
All checks were successful
Build Plugin / build-test (push) Successful in 43s
2024-11-25 12:51:34 +00:00
dc564e7baf Changes:
All checks were successful
Build Plugin / build-test (push) Successful in 44s
- Fix Status Color Bug
- Add /playtime
- Add /timer
2024-11-25 12:39:49 +00:00
befce5d7d0 # Changes:
All checks were successful
Build Plugin / build-test (push) Successful in 43s
- Add D7 Command (Admin interface)
- Add remove func to status
- Add Color table to Status custom
- Add wordlist
2024-11-24 12:03:15 +01:00
21 changed files with 552 additions and 121 deletions

View File

@ -20,13 +20,13 @@ jobs:
- name: Upload
uses: actions/upload-artifact@v3
with:
name: d7serverlite
path: target/d7serverlite*.jar
name: LSServerLite
path: target/LSServerLite*.jar
- name: Create Pre Release
run: |
FILES=./target/d7serverlite*.jar
USER=D7MC
REPO=D7ServerLite
FILES=./target/LSServerLite*.jar
USER=LagacySurvival
REPO=ServerLite
# Set up variables
AUTH_HEADER="Authorization: token ${{ secrets.TOKEN }}"
CONTENT_TYPE="Content-Type: application/json"

15
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "mvn",
"args": [
"clean",
"package"
],
"type": "shell",
"problemMatcher": []
}
]
}

View File

@ -1,4 +1,4 @@
# D7 Server Lite
# Server Lite
D7ServerUtil in a more stable Version
Version 1.17.1+

View File

@ -6,13 +6,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.npid7.serverlite</groupId>
<artifactId>d7serverlite</artifactId>
<artifactId>LSServerLite</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>

View File

@ -0,0 +1,56 @@
package de.npid7.serverlite.Commands;
import de.npid7.serverlite.Helpers.Spielzeit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.Statistic;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PlaytimeCommand implements CommandExecutor {
private void makeMessage(OfflinePlayer pl, Player exec) {
if (pl == null) {
return;
}
exec.sendMessage("- " + ChatColor.GOLD.toString() + "PlayTime: ");
exec.sendMessage(
"- " + ChatColor.GRAY.toString() + "Player: " + ChatColor.WHITE.toString() + pl.getName());
// exec.sendMessage("- First Join: ");
int playtime = Spielzeit.getHours(pl.getStatistic(Statistic.TOTAL_WORLD_TIME));
String str = " Stunden";
if (playtime == 1) {
str = " Stunde";
}
exec.sendMessage("- " + ChatColor.GRAY.toString() + "Spielzeit: " + ChatColor.GREEN.toString()
+ playtime + str);
exec.sendMessage("- " + ChatColor.GRAY.toString()
+ "Detailierte Spielzeit: " + ChatColor.GREEN.toString()
+ Spielzeit.formatTicks(pl.getStatistic(Statistic.TOTAL_WORLD_TIME)));
exec.sendMessage("- " + ChatColor.GRAY.toString() + "Server " + ChatColor.GREEN.toString()
+ (pl.getStatistic(Statistic.LEAVE_GAME) + 1) + ChatColor.GRAY.toString()
+ " mal betreten.");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
if (strings.length != 0) {
if (!sender.hasPermission("d7.d7")) {
sender.sendMessage(
ChatColor.RED.toString() + "Nur Admins dürfen /plytime auf spieler anwenden");
return false;
}
OfflinePlayer pl = Bukkit.getOfflinePlayer(strings[0]);
if (pl == null) {
sender.sendMessage(ChatColor.RED.toString() + "Der Spieler existiert nicht!");
return false;
}
makeMessage(pl, (Player) sender);
} else {
makeMessage(Bukkit.getOfflinePlayer(((Player) sender).getUniqueId()), (Player) sender);
}
return false;
}
}

View File

@ -1,7 +1,7 @@
package de.npid7.serverlite.Commands;
import de.npid7.serverlite.Configs.PlayerConfig;
import de.npid7.serverlite.D7ServerLite;
import de.npid7.serverlite.ServerLite;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -11,13 +11,14 @@ import org.bukkit.entity.Player;
public class StatusCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
if (strings.length != 1 && strings.length != 2) {
sender.sendMessage("Verwendung: /status Status");
if (strings.length < 1 || strings.length > 3) {
sender.sendMessage("Verwendung: /status <status/custom/remove>");
return false;
}
String str = "";
String color = ChatColor.WHITE.toString(); // Default to White
boolean is_def = false;
for (String st : D7ServerLite.getInst().getPluginConfig().getDefaultStatusList()) {
for (String st : ServerLite.getInst().getPluginConfig().getDefaultStatusList()) {
if (strings[0].equals(st)) {
str = strings[0];
is_def = true;
@ -26,8 +27,8 @@ public class StatusCommand implements CommandExecutor {
if (is_def) {
// Leave empty
} else if (strings[0].equals("custom")) {
if (strings.length != 2) {
sender.sendMessage("Verwendung: /status custom Status");
if (strings.length < 2) {
sender.sendMessage("Verwendung: /status custom <status> <color>");
return false;
}
if (strings[1].length() > 10) {
@ -35,17 +36,33 @@ public class StatusCommand implements CommandExecutor {
return false;
}
str = strings[1];
if (strings.length == 3) {
for (ChatColor c : ChatColor.values()) {
if (c.isColor() && c.name().equals(strings[2])) {
color = c.toString();
}
}
}
} else if (strings[0].equals("remove")) {
PlayerConfig pcfg = ServerLite.getInst().getPlayerConfig();
pcfg.setStatus(((Player) sender).getUniqueId(), "");
pcfg.Save();
return false;
} else {
sender.sendMessage(
ChatColor.RED.toString() + "Was auch immer du versuchst... lass es einfach!");
return false;
}
if (D7ServerLite.getInst().getPluginConfig().getWordBlacklist().find(str) != null) {
sender.sendMessage(ChatColor.RED.toString() + "Diser Status ist nicht erlaubt!");
if (ServerLite.getInst().getPluginConfig().getWordBlacklist().find(str) != null) {
sender.sendMessage(ChatColor.RED.toString() + "Dieser Status ist nicht erlaubt!");
return false;
}
PlayerConfig pcfg = D7ServerLite.getInst().getPlayerConfig();
pcfg.setStatus(((Player) sender).getUniqueId(), str);
// Fix defined status whitre here
if (is_def) {
color = "";
}
PlayerConfig pcfg = ServerLite.getInst().getPlayerConfig();
pcfg.setStatus(((Player) sender).getUniqueId(), color + str);
pcfg.Save();
return false;
}

View File

@ -0,0 +1,115 @@
package de.npid7.serverlite.Commands;
import de.npid7.serverlite.Configs.PluginConfig;
import de.npid7.serverlite.ServerLite;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SystemCommand implements CommandExecutor {
private void printUsage(CommandSender sender) {
sender.sendMessage("Verwendung: ");
sender.sendMessage("/system config reload -> Läd Config nau");
sender.sendMessage("/system config save -> Speichert die Config");
sender.sendMessage("/system wordlist add <word>");
sender.sendMessage("/system wordlist remove <word>");
sender.sendMessage("/system status <playername> set <status> <color> (color ist optional)");
sender.sendMessage("/system status <playername> remove -> Entfernt einem Spieler den Status");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
if (!sender.hasPermission("d7.d7")) {
sender.sendMessage(ChatColor.RED.toString() + "This is an admin command!");
return false;
}
if (strings.length < 2 || strings.length > 5) {
printUsage(sender);
return false;
}
if (strings[0].equals("config")) {
if (strings.length != 2) {
printUsage(sender);
return false;
}
if (strings[1].equals("reload")) {
ServerLite.getInst().getPluginConfig().Load();
sender.sendMessage(ChatColor.GREEN.toString() + "Config neu geladen!");
return false;
} else if (strings[1].equals("save")) {
ServerLite.getInst().getPluginConfig().Save();
sender.sendMessage(ChatColor.GREEN.toString() + "Config gespeichert!");
return false;
} else {
sender.sendMessage(
ChatColor.RED.toString() + strings[1] + " ist kein subcommand von config!");
return false;
}
} else if (strings[0].equals("wordlist")) {
if (strings.length != 3) {
printUsage(sender);
return false;
}
PluginConfig pcfg = ServerLite.getInst().getPluginConfig();
if (strings[1].equals("add")) {
if (!pcfg.getWordBlacklist().add(strings[2])) {
sender.sendMessage(ChatColor.RED.toString() + "Wort ist bereits in der Liste!");
} else {
sender.sendMessage(ChatColor.GREEN.toString() + "Wort hinzugefügt!");
}
pcfg.Save();
return false;
} else if (strings[1].equals("remove")) {
if (!pcfg.getWordBlacklist().remove(strings[2])) {
sender.sendMessage(ChatColor.RED.toString() + "Wort nicht gefunden!");
} else {
sender.sendMessage(ChatColor.GREEN.toString() + "Wort entfernt!");
}
pcfg.Save();
return false;
}
} else if (strings[0].equals("status")) {
if (strings.length < 3 || strings.length > 5) {
printUsage(sender);
return false;
}
if (strings[2].equals("remove")) {
Player pl = Bukkit.getPlayer(strings[1]);
if (pl == null) {
sender.sendMessage(ChatColor.RED.toString() + "Player existiert nicht!");
return false;
}
ServerLite.getInst().getPlayerConfig().setStatus(pl.getUniqueId(), "");
ServerLite.getInst().getPlayerConfig().Save();
sender.sendMessage(ChatColor.GREEN.toString() + "Status entfernt von " + pl.getName());
return false;
} else if (strings[2].equals("set")) {
Player pl = Bukkit.getPlayer(strings[1]);
if (pl == null) {
sender.sendMessage(ChatColor.RED.toString() + "Player existiert nicht!");
return false;
}
String status = strings[3];
String color = ChatColor.WHITE.toString();
if (strings.length == 5) {
for (ChatColor c : ChatColor.values()) {
if (c.isColor() && c.name().equals(strings[4])) {
color = c.toString();
}
}
}
if (ServerLite.getInst().getPluginConfig().getWordBlacklist().find(status) != null) {
sender.sendMessage(ChatColor.RED.toString() + "Dieser Status ist nicht erlaubt!");
return false;
}
ServerLite.getInst().getPlayerConfig().setStatus(pl.getUniqueId(), color + status);
ServerLite.getInst().getPlayerConfig().Save();
sender.sendMessage(ChatColor.GREEN.toString() + "Status gesetzt für " + pl.getName());
}
}
return false;
}
}

View File

@ -0,0 +1,30 @@
package de.npid7.serverlite.Commands;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.npid7.serverlite.ServerLite;
public class TimerCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
if (strings.length != 1) {
sender.sendMessage(ChatColor.RED.toString() + "kein argument definiert!");
return false;
}
if (strings[0].equals("show")) {
ServerLite.getInst().getPlayerConfig().setTimer(((Player) sender).getUniqueId(), true);
ServerLite.getInst().getPlayerConfig().Save();
} else if (strings[0].equals("hide")) {
ServerLite.getInst().getPlayerConfig().setTimer(((Player) sender).getUniqueId(), false);
ServerLite.getInst().getPlayerConfig().Save();
} else {
sender.sendMessage(ChatColor.RED.toString() + "argument nicht erlaubt!");
return false;
}
return false;
}
}

View File

@ -15,15 +15,20 @@ import java.util.UUID;
public class PlayerConfig {
File file = null;
int cfg_version = 0;
int cfg_version = 1;
public static class PlayerEntry {
public String status = "";
public String name = "";
public PlayerEntry() {}
public PlayerEntry(String s, String n) {
public boolean timer = false;
public PlayerEntry() {
}
public PlayerEntry(String s, String n, boolean t) {
status = s;
name = n;
timer = t;
}
}
@ -44,11 +49,6 @@ public class PlayerConfig {
JsonObject js = prs.parse(r).getAsJsonObject();
r.close();
int pver = js.get("version").getAsInt();
if (pver != cfg_version) {
// Use PVER to not create a complete new config
file.delete();
return false;
}
player_map.clear();
// Load Data
for (Map.Entry<String, JsonElement> e : js.entrySet()) {
@ -59,8 +59,16 @@ public class PlayerConfig {
PlayerEntry pe = new PlayerEntry();
pe.name = e.getValue().getAsJsonObject().get("name").getAsString();
pe.status = e.getValue().getAsJsonObject().get("status").getAsString();
if (pver >= 1) {
pe.timer = e.getValue().getAsJsonObject().get("timer").getAsBoolean();
}
player_map.put(key, pe);
}
if (pver != cfg_version) {
// Use PVER to update Config
Save();
return false;
}
} catch (IOException e) {
e.printStackTrace();
return true;
@ -75,6 +83,7 @@ public class PlayerConfig {
JsonObject o = new JsonObject();
o.addProperty("name", e.getValue().name);
o.addProperty("status", e.getValue().status);
o.addProperty("timer", e.getValue().timer);
js.add(e.getKey().toString(), o);
}
try {
@ -103,6 +112,7 @@ public class PlayerConfig {
public String getStatus(UUID ref) {
return this.player_map.get(ref).status;
}
public void setStatus(UUID ref, String value) {
this.player_map.get(ref).status = value;
}
@ -110,7 +120,16 @@ public class PlayerConfig {
public String getName(UUID ref) {
return this.player_map.get(ref).name;
}
public void setName(UUID ref, String value) {
this.player_map.get(ref).name = value;
}
public boolean getTimer(UUID ref) {
return this.player_map.get(ref).timer;
}
public void setTimer(UUID ref, boolean value) {
this.player_map.get(ref).timer = value;
}
}

View File

@ -104,6 +104,8 @@ public class PluginConfig {
wordBlacklist.add("MOD");
wordBlacklist.add("TEAM");
wordBlacklist.add("STAFF");
wordBlacklist.add("OWNER");
wordBlacklist.add("MODERATOR");
defaultStatus = "";
defaultStatusList.add("Online");
defaultStatusList.add("AFK");

View File

@ -1,58 +0,0 @@
package de.npid7.serverlite;
import de.npid7.serverlite.Commands.StatusCommand;
import de.npid7.serverlite.Configs.PlayerConfig;
import de.npid7.serverlite.Configs.PluginConfig;
import de.npid7.serverlite.Helpers.Spielzeit;
import de.npid7.serverlite.Listeners.JoinListener;
import de.npid7.serverlite.TabCompleters.StatusCompleter;
import de.npid7.serverlite.Tasks.TablistTask;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
/*
* d7serverlite java plugin
*/
public class D7ServerLite extends JavaPlugin {
private static D7ServerLite inst;
private TablistTask tablistUpdater;
private PluginConfig pluginConfig;
private PlayerConfig playerConfig;
@Override
public void onLoad() {
inst = this;
}
@Override
public void onEnable() {
if (!getDataFolder().exists()) {
getDataFolder().mkdirs();
}
pluginConfig = new PluginConfig(getDataFolder() + "/config.json");
playerConfig = new PlayerConfig(getDataFolder() + "/player_config.json");
tablistUpdater = new TablistTask();
getCommand("status").setExecutor(new StatusCommand());
getCommand("status").setTabCompleter(new StatusCompleter());
Bukkit.getPluginManager().registerEvents(new JoinListener(), this);
}
@Override
public void onDisable() {}
public static D7ServerLite getInst() {
return inst;
}
public PluginConfig getPluginConfig() {
return this.pluginConfig;
}
public PlayerConfig getPlayerConfig() {
return this.playerConfig;
}
}

View File

@ -2,8 +2,6 @@ package de.npid7.serverlite.Helpers;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Map;
import java.util.Vector;
public class Wordlist {

View File

@ -1,22 +0,0 @@
package de.npid7.serverlite.Listeners;
import de.npid7.serverlite.Configs.PlayerConfig;
import de.npid7.serverlite.D7ServerLite;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class JoinListener implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (D7ServerLite.getInst().getPlayerConfig().Find(player.getUniqueId()) == null) {
D7ServerLite.getInst().getPlayerConfig().Add(player.getUniqueId(),
new PlayerConfig.PlayerEntry(
D7ServerLite.getInst().getPluginConfig().getDefaultStatus(), player.getName()));
D7ServerLite.getInst().getPlayerConfig().Save();
}
}
}

View File

@ -0,0 +1,41 @@
package de.npid7.serverlite.Listeners;
import de.npid7.serverlite.Configs.PlayerConfig;
import de.npid7.serverlite.ServerLite;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerListener implements Listener {
@EventHandler
public void onPlayerMessage(AsyncPlayerChatEvent e) {
String msg = e.getMessage();
String prefix = "";
String status = ServerLite.getInst().getPlayerConfig().getStatus(e.getPlayer().getUniqueId());
String statusColor = "";
if (!status.equals("")) {
statusColor = ServerLite.getInst().getPluginConfig().getStatusColor(status);
if (statusColor == null) {
statusColor = ChatColor.WHITE.toString();
}
prefix = "[" + statusColor + status + ChatColor.WHITE.toString() + "] ";
}
prefix += "<" + e.getPlayer().getDisplayName() + "> ";
e.setFormat(prefix + msg);
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (ServerLite.getInst().getPlayerConfig().Find(player.getUniqueId()) == null) {
ServerLite.getInst().getPlayerConfig().Add(player.getUniqueId(),
new PlayerConfig.PlayerEntry(
ServerLite.getInst().getPluginConfig().getDefaultStatus(), player.getName(), false));
ServerLite.getInst().getPlayerConfig().Save();
}
}
}

View File

@ -0,0 +1,79 @@
package de.npid7.serverlite;
import de.npid7.serverlite.Commands.SystemCommand;
import de.npid7.serverlite.Commands.PlaytimeCommand;
import de.npid7.serverlite.Commands.StatusCommand;
import de.npid7.serverlite.Commands.TimerCommand;
import de.npid7.serverlite.Configs.PlayerConfig;
import de.npid7.serverlite.Configs.PluginConfig;
import de.npid7.serverlite.Listeners.PlayerListener;
import de.npid7.serverlite.TabCompleters.SystemCompleter;
import de.npid7.serverlite.TabCompleters.PlaytimeCompleter;
import de.npid7.serverlite.TabCompleters.StatusCompleter;
import de.npid7.serverlite.TabCompleters.TimerCompleter;
import de.npid7.serverlite.Tasks.TablistTask;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
/*
* d7serverlite java plugin
*/
public class ServerLite extends JavaPlugin {
// Declare static Instance To access with getInst();
// using this to access Configs from this Class
private static ServerLite inst;
// declare TablistTask and Configs
private TablistTask tablistUpdater;
private PluginConfig pluginConfig;
private PlayerConfig playerConfig;
// Override onLoad to set static inst to this class
@Override
public void onLoad() {
inst = this;
}
// Override on Enabel to init the Plugin
@Override
public void onEnable() {
// Create Data Folder
if (!getDataFolder().exists()) {
getDataFolder().mkdirs();
}
// Init Configs
pluginConfig = new PluginConfig(getDataFolder() + "/config.json");
playerConfig = new PlayerConfig(getDataFolder() + "/player_config.json");
// Run Tablist Updater
tablistUpdater = new TablistTask();
// declare commands
getCommand("status").setExecutor(new StatusCommand());
getCommand("status").setTabCompleter(new StatusCompleter());
getCommand("system").setExecutor(new SystemCommand());
getCommand("system").setTabCompleter(new SystemCompleter());
getCommand("timer").setExecutor(new TimerCommand());
getCommand("timer").setTabCompleter(new TimerCompleter());
getCommand("playtime").setExecutor(new PlaytimeCommand());
getCommand("playtime").setTabCompleter(new PlaytimeCompleter());
// Register onJoin Event to generate PlayerConfigEntry and customize chat message
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
}
/**
* Getters declared below
*/
public static ServerLite getInst() {
return inst;
}
public PluginConfig getPluginConfig() {
return this.pluginConfig;
}
public PlayerConfig getPlayerConfig() {
return this.playerConfig;
}
}

View File

@ -0,0 +1,26 @@
package de.npid7.serverlite.TabCompleters;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
public class PlaytimeCompleter implements TabCompleter {
@Override
public List<String> onTabComplete(
CommandSender sender, Command command, String alias, String[] args) {
List<String> completions = new ArrayList<>();
if (command.getName().equalsIgnoreCase("playtime")) {
if (sender.hasPermission("d7.d7")) {
for (OfflinePlayer pl : Bukkit.getOfflinePlayers()) {
completions.add(pl.getName());
}
}
}
return completions;
}
}

View File

@ -1,8 +1,9 @@
package de.npid7.serverlite.TabCompleters;
import de.npid7.serverlite.D7ServerLite;
import de.npid7.serverlite.ServerLite;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
@ -14,10 +15,19 @@ public class StatusCompleter implements TabCompleter {
List<String> completions = new ArrayList<>();
if (command.getName().equalsIgnoreCase("status")) {
if (args.length == 1) {
for (String s : D7ServerLite.getInst().getPluginConfig().getDefaultStatusList()) {
for (String s : ServerLite.getInst().getPluginConfig().getDefaultStatusList()) {
completions.add(s);
}
completions.add("custom");
completions.add("remove");
} else if (args.length == 3) {
if (args[0].equals("custom")) {
for (ChatColor c : ChatColor.values()) {
if (c.isColor()) {
completions.add(c.name());
}
}
}
}
}
return completions;

View File

@ -0,0 +1,62 @@
package de.npid7.serverlite.TabCompleters;
import de.npid7.serverlite.ServerLite;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
public class SystemCompleter implements TabCompleter {
@Override
public List<String> onTabComplete(
CommandSender sender, Command command, String alias, String[] args) {
List<String> completions = new ArrayList<>();
if (command.getName().equals("system")) {
if (!sender.hasPermission("ls.system")) {
return completions;
}
if (args.length == 1) {
completions.add("config");
completions.add("status");
completions.add("wordlist");
} else if (args.length == 2) {
if (args[0].equals("config")) {
completions.add("reload");
completions.add("save");
} else if (args[0].equals("status")) {
for (Player pl : Bukkit.getOnlinePlayers()) {
completions.add(pl.getName());
}
} else if (args[0].equals("wordlist")) {
completions.add("add");
completions.add("remove");
}
} else if (args.length == 3) {
if (args[0].equals("status")) {
completions.add("remove");
completions.add("set");
} else if (args[0].equals("wordlist")) {
if (args[1].equals("remove")) {
for (String s : ServerLite.getInst().getPluginConfig().getWordBlacklist().getList()) {
completions.add(s);
}
}
}
} else if (args.length == 5) {
if (args[2].equals("set")) {
for (ChatColor c : ChatColor.values()) {
if (c.isColor()) {
completions.add(c.name());
}
}
}
}
}
return completions;
}
}

View File

@ -0,0 +1,21 @@
package de.npid7.serverlite.TabCompleters;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
public class TimerCompleter implements TabCompleter {
@Override
public List<String> onTabComplete(
CommandSender sender, Command command, String alias, String[] args) {
List<String> completions = new ArrayList<>();
if (command.getName().equalsIgnoreCase("timer")) {
completions.add("show");
completions.add("hide");
}
return completions;
}
}

View File

@ -1,9 +1,11 @@
package de.npid7.serverlite.Tasks;
import de.npid7.serverlite.D7ServerLite;
import de.npid7.serverlite.ServerLite;
import de.npid7.serverlite.Helpers.Spielzeit;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Statistic;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -46,20 +48,26 @@ public class TablistTask {
if (playtime == 1) {
str = " Stunde";
}
String tpsclr = ChatColor.GREEN.toString();
if (tps < 18.0 && tps > 15.0) {
tpsclr = ChatColor.GOLD.toString();
} else if (tps <= 15 || tps > 20) {
tpsclr = ChatColor.RED.toString();
}
pl.setPlayerListHeader(
"\n§x§5§5§5§5§5§5§lѕ§x§5§B§5§B§5§B§l§x§6§1§6§1§6§1§lʀ§x§6§7§6§7§6§7§l§x§6§D§6§D§6§D§lɪ§x§7§3§7§3§7§3§l§x§7§9§7§9§7§9§lᴀ§x§8§0§8§0§8§0§lʟ§x§8§6§8§6§8§6§lᴘ§x§8§C§8§C§8§C§lʀ§x§9§2§9§2§9§2§l§x§9§8§9§8§9§8§lᴊ§x§9§E§9§E§9§E§lᴇ§x§A§4§A§4§A§4§lᴋ§x§A§A§A§A§A§A§lᴛ\n"
"\n§x§B§1§9§1§6§9§lʟ§x§A§D§8§E§6§8§lᴇ§x§A§A§8§C§6§7§lɢ§x§A§6§8§9§6§6§lᴀ§x§A§2§8§7§6§5§l§x§9§F§8§4§6§4§lʏ §x§9§8§7§F§6§2§lѕ§x§9§4§7§C§6§0§l§x§9§0§7§A§5§F§lʀ§x§8§D§7§7§5§E§l§x§8§9§7§5§5§D§lɪ§x§8§5§7§2§5§C§l§x§8§2§7§0§5§B§lᴀ§x§7§E§6§D§5§A§lʟ\n"
+ "\n" + ChatColor.GRAY.toString() + "ᴅᴇɪɴ ᴘɪɴɢ" + ChatColor.DARK_GRAY.toString() + ": "
+ ChatColor.GREEN.toString() + pl.getPing() + " " + ChatColor.GRAY.toString()
+ "ѕᴇʀᴠᴇʀ ᴛᴘѕ" + ChatColor.DARK_GRAY.toString() + ": " + ChatColor.GREEN.toString()
+ String.format("%.1f", tps) + "\n\n" + ChatColor.GRAY.toString() + "ѕᴘɪᴇʟᴢᴇɪᴛ"
+ tpsclr + String.format("%.1f", tps) + "\n\n" + ChatColor.GRAY.toString() + "ѕᴘɪᴇʟᴢᴇɪᴛ"
+ ChatColor.DARK_GRAY.toString() + ": " + ChatColor.GREEN.toString() + playtime + str
+ "\n");
pl.setPlayerListFooter("\n");
String body = "";
String status = D7ServerLite.getInst().getPlayerConfig().getStatus(pl.getUniqueId());
String status = ServerLite.getInst().getPlayerConfig().getStatus(pl.getUniqueId());
if (!status.equals("")) {
body += "[";
String color = D7ServerLite.getInst().getPluginConfig().getStatusColor(status);
String color = ServerLite.getInst().getPluginConfig().getStatusColor(status);
if (color == null) {
color = ChatColor.WHITE.toString();
}
@ -71,6 +79,11 @@ public class TablistTask {
body += ChatColor.WHITE.toString() + pl.getDisplayName();
body += " " + ChatColor.RED.toString() + pl.getStatistic(Statistic.DEATHS);
pl.setPlayerListName(body);
if (ServerLite.getInst().getPlayerConfig().getTimer(pl.getUniqueId())) {
pl.spigot().sendMessage(ChatMessageType.ACTION_BAR,
new TextComponent(ChatColor.GOLD.toString()
+ Spielzeit.formatTicks(pl.getStatistic(Statistic.TOTAL_WORLD_TIME))));
}
}
}
@ -81,6 +94,6 @@ public class TablistTask {
CalcTPS();
displayTablist();
}
}.runTaskTimer(D7ServerLite.getInst(), 0, 0);
}.runTaskTimer(ServerLite.getInst(), 0, 0);
}
}

View File

@ -1,8 +1,15 @@
name: D7SerevrLite
main: de.npid7.serverlite.D7ServerLite
name: LSSerevrLite
main: de.npid7.serverlite.ServerLite
version: 1.0
api-version: 1.17
commands:
status:
description: Play Status Command
system:
description: Admin Command Interface
permission: ls.system
timer:
description: Display Timer in Actionbar
playtime:
description: Display your Playtime