commit
08129adcb4
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
|
@ -0,0 +1,8 @@
|
|||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="KygekPingTPS-Spigot">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/KygekPingTPS</output-path>
|
||||
<root id="archive" name="KygekPingTPS.jar">
|
||||
<element id="module-output" name="KygekPingTPS-Spigot" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
|
@ -0,0 +1,9 @@
|
|||
<component name="libraryTable">
|
||||
<library name="spigot-api-1.16.5-R0.1-20210604.221538-95">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/Desktop/Minecraft Dev Server/Spigot APIs/spigot-api-1.16.5-R0.1-20210604.221538-95.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/KygekPingTPS-Spigot.iml" filepath="$PROJECT_DIR$/KygekPingTPS-Spigot.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="spigot-api-1.16.5-R0.1-20210604.221538-95" level="project" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
# KygekPingTPS configuration file
|
||||
# KygekPingTPS was made by KygekTeam
|
||||
|
||||
# Messages configuration (Leave empty to use default messages)
|
||||
# Use "{prefix}" to display KygekPingTPS default prefix
|
||||
# Use "&" as formatting codes
|
||||
# Use "\n" to break into new line
|
||||
no-permission: ""
|
||||
player-not-found: ""
|
||||
# Use "{tps}" to display server TPS in server-tps
|
||||
server-tps: ""
|
||||
# Use "{player}" to display player name or self and "{ping}" to display player's ping in player-ping
|
||||
player-ping: ""
|
||||
|
||||
##### DANGER ZONE #####
|
||||
# Do not change this (Only for internal use)!
|
||||
config-version: "1.0"
|
||||
#######################
|
|
@ -0,0 +1,45 @@
|
|||
/* I couldn't find a vanilla method so this is there until we do.
|
||||
The script is by LazyLemons on the Bukkit forums. */
|
||||
|
||||
package org.kygekteam.java.kygekpingtps;
|
||||
|
||||
public class Lag
|
||||
implements Runnable
|
||||
{
|
||||
public static int TICK_COUNT= 0;
|
||||
public static long[] TICKS= new long[600];
|
||||
public static long LAST_TICK= 0L;
|
||||
|
||||
public static double getTPS()
|
||||
{
|
||||
return getTPS(100);
|
||||
}
|
||||
|
||||
public static double getTPS(int ticks)
|
||||
{
|
||||
if (TICK_COUNT< ticks) {
|
||||
return 20.0D;
|
||||
}
|
||||
int target = (TICK_COUNT- 1 - ticks) % TICKS.length;
|
||||
long elapsed = System.currentTimeMillis() - TICKS[target];
|
||||
|
||||
return ticks / (elapsed / 1000.0D);
|
||||
}
|
||||
|
||||
public static long getElapsed(int tickID)
|
||||
{
|
||||
if (TICK_COUNT- tickID >= TICKS.length)
|
||||
{
|
||||
}
|
||||
|
||||
long time = TICKS[(tickID % TICKS.length)];
|
||||
return System.currentTimeMillis() - time;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
TICKS[(TICK_COUNT% TICKS.length)] = System.currentTimeMillis();
|
||||
|
||||
TICK_COUNT+= 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package org.kygekteam.java.kygekpingtps;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L);
|
||||
this.saveDefaultConfig();
|
||||
this.checkConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
this.reloadConfig();
|
||||
switch (command.getName().toLowerCase()) {
|
||||
case "tps":
|
||||
new TPS(sender, this).execute();
|
||||
break;
|
||||
case "ping":
|
||||
new Ping(sender, args, this).execute();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkConfig() {
|
||||
if (!this.getConfig().getString("config-version").equals("1.0")) {
|
||||
getServer().getConsoleSender().sendMessage("Your configuration file is outdated, updating the config.yml...");
|
||||
getServer().getConsoleSender().sendMessage("The old configuration file can be found at config-old.yml");
|
||||
this.renameConfig();
|
||||
this.saveDefaultConfig();
|
||||
this.reloadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void renameConfig() {
|
||||
File oldConfig = new File(this.getDataFolder() + "/config.yml");
|
||||
File newConfig = new File(this.getDataFolder() + "/config-old.yml");
|
||||
|
||||
if (newConfig.exists()) newConfig.delete();
|
||||
|
||||
oldConfig.renameTo(newConfig);
|
||||
}
|
||||
|
||||
public static final String PREFIX = ChatColor.YELLOW + "[KygekPingTPS] ";
|
||||
|
||||
public static String replace(String string) {
|
||||
return string.replace("{prefix}", PREFIX).replace("&", "§");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package org.kygekteam.java.kygekpingtps;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Ping {
|
||||
private final CommandSender sender;
|
||||
private final String[] args;
|
||||
private final Main main;
|
||||
|
||||
public Ping(CommandSender sender, String[] args, Main main) {
|
||||
this.sender = sender;
|
||||
this.args = args;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
if (!this.sender.hasPermission("kygekpingtps.ping")) {
|
||||
String noperm = Main.replace(this.main.getConfig().getString("no-permission", ""));
|
||||
noperm = noperm.isEmpty() ? Main.PREFIX + ChatColor.RED + "You do not have permission to use this command" : noperm;
|
||||
|
||||
this.sender.sendMessage(noperm);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.args.length < 1) {
|
||||
if (!(this.sender instanceof Player)) {
|
||||
this.sender.sendMessage(Main.PREFIX + ChatColor.WHITE + "Usage: /ping <player>");
|
||||
} else {
|
||||
String ping = Main.replace(this.main.getConfig().getString("player-ping", "")).replace("{player}", "Your").replace("{ping}", Integer.toString(((Player) sender).getPing()));
|
||||
ping = ping.isEmpty() ? Main.PREFIX + ChatColor.GREEN + "Your current ping: " + ChatColor.AQUA + ((Player) sender).getPing() : ping;
|
||||
|
||||
this.sender.sendMessage(ping);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = sender.getServer().getPlayer(this.args[0]);
|
||||
if (player == null) {
|
||||
String notfound = Main.replace(this.main.getConfig().getString( "player-not-found", ""));
|
||||
notfound = notfound.isEmpty() ? Main.PREFIX + ChatColor.RED + "Player was not found" : notfound;
|
||||
|
||||
this.sender.sendMessage(notfound);
|
||||
return;
|
||||
}
|
||||
|
||||
String ping = Main.replace(this.main.getConfig().getString("player-ping", "")).replace("{player}", player.getName()).replace("{ping}", Integer.toString(player.getPing()));
|
||||
ping = ping.isEmpty() ? Main.PREFIX + ChatColor.GREEN + player.getName() + "'s current ping: " + ChatColor.AQUA + player.getPing() : ping;
|
||||
|
||||
this.sender.sendMessage(ping);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package org.kygekteam.java.kygekpingtps;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class TPS {
|
||||
private final CommandSender sender;
|
||||
private final Main main;
|
||||
|
||||
public TPS(CommandSender sender, Main main) {
|
||||
this.sender = sender;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
double tps = Lag.getTPS();
|
||||
|
||||
if (sender.hasPermission("kygekpingtps.tps")) {
|
||||
String servertps = Main.replace(this.main.getConfig().getString("server-tps", "")).replace("{tps}", Double.toString(tps));
|
||||
servertps = servertps.isEmpty() ? Main.PREFIX + ChatColor.GREEN + "Current server TPS: " + ChatColor.AQUA + tps : servertps;
|
||||
|
||||
this.sender.sendMessage(servertps);
|
||||
} else {
|
||||
String noperm = Main.replace(this.main.getConfig().getString("no-permission", ""));
|
||||
noperm = noperm.isEmpty() ? Main.PREFIX + ChatColor.RED + "You do not have permission to use this command" : noperm;
|
||||
|
||||
this.sender.sendMessage(noperm);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
# See server TPS and a player's ping
|
||||
# Copyright (C) 2020 KygekTeam
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
name: KygekPingTPS
|
||||
version: "1.0.0"
|
||||
author: KygekTeam
|
||||
api-version: 1.16
|
||||
main: org.kygekteam.java.kygekpingtps.Main
|
||||
|
||||
commands:
|
||||
ping:
|
||||
description: Current ping of a player
|
||||
permission: kygekpingtps.ping
|
||||
usage: "/ping [player]"
|
||||
tps:
|
||||
description: Current TPS of the server
|
||||
permission: kygekpingtps.tps
|
||||
usage: "/tps"
|
||||
aliases: ktps
|
||||
|
||||
permissions:
|
||||
kygekpingtps.ping:
|
||||
description: Permission to use /ping
|
||||
default: true
|
||||
kygekpingtps.tps:
|
||||
description: Permission to use /tps
|
||||
default: true
|
Loading…
Reference in New Issue