commit b40f23b1405376002d436e81cabd66658a6c7cef Author: hanna Date: Sat Jan 30 11:47:41 2021 +0100 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7b20272 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +dist +api \ No newline at end of file diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..31da32f --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project xenon. + + + diff --git a/build/built-jar.properties b/build/built-jar.properties new file mode 100644 index 0000000..7ae9bae --- /dev/null +++ b/build/built-jar.properties @@ -0,0 +1,4 @@ +#Fri, 29 Jan 2021 22:23:53 +0100 + + +C\:\\Users\\hanna\\Documents\\NetBeansProjects\\hnhx= diff --git a/build/classes/plugin.yml b/build/classes/plugin.yml new file mode 100644 index 0000000..04af7e2 --- /dev/null +++ b/build/classes/plugin.yml @@ -0,0 +1,14 @@ +main: xenon.main +name: xenon +version: 1.0 +api-version: 1.16 +description: The main plugin of Xenon. +commands: + kill: + aliases: suicide + help: + discord: + aliases: d + stats: + joindate: + aliases: jd \ No newline at end of file diff --git a/build/classes/xenon/commands/Discord.class b/build/classes/xenon/commands/Discord.class new file mode 100644 index 0000000..5515f9c Binary files /dev/null and b/build/classes/xenon/commands/Discord.class differ diff --git a/build/classes/xenon/commands/Help.class b/build/classes/xenon/commands/Help.class new file mode 100644 index 0000000..5db5e1b Binary files /dev/null and b/build/classes/xenon/commands/Help.class differ diff --git a/build/classes/xenon/commands/Joindate.class b/build/classes/xenon/commands/Joindate.class new file mode 100644 index 0000000..d8597e2 Binary files /dev/null and b/build/classes/xenon/commands/Joindate.class differ diff --git a/build/classes/xenon/commands/Kill.class b/build/classes/xenon/commands/Kill.class new file mode 100644 index 0000000..7945ba0 Binary files /dev/null and b/build/classes/xenon/commands/Kill.class differ diff --git a/build/classes/xenon/commands/Stats.class b/build/classes/xenon/commands/Stats.class new file mode 100644 index 0000000..2a29432 Binary files /dev/null and b/build/classes/xenon/commands/Stats.class differ diff --git a/build/classes/xenon/events/AntiIllegals$1.class b/build/classes/xenon/events/AntiIllegals$1.class new file mode 100644 index 0000000..2ce09c3 Binary files /dev/null and b/build/classes/xenon/events/AntiIllegals$1.class differ diff --git a/build/classes/xenon/events/AntiIllegals.class b/build/classes/xenon/events/AntiIllegals.class new file mode 100644 index 0000000..1bebbe1 Binary files /dev/null and b/build/classes/xenon/events/AntiIllegals.class differ diff --git a/build/classes/xenon/events/AntiNetherRoof$1.class b/build/classes/xenon/events/AntiNetherRoof$1.class new file mode 100644 index 0000000..6717224 Binary files /dev/null and b/build/classes/xenon/events/AntiNetherRoof$1.class differ diff --git a/build/classes/xenon/events/AntiNetherRoof.class b/build/classes/xenon/events/AntiNetherRoof.class new file mode 100644 index 0000000..568b699 Binary files /dev/null and b/build/classes/xenon/events/AntiNetherRoof.class differ diff --git a/build/classes/xenon/events/AntiSpam.class b/build/classes/xenon/events/AntiSpam.class new file mode 100644 index 0000000..97516ee Binary files /dev/null and b/build/classes/xenon/events/AntiSpam.class differ diff --git a/build/classes/xenon/events/BoatflyPatch.class b/build/classes/xenon/events/BoatflyPatch.class new file mode 100644 index 0000000..8d5ac49 Binary files /dev/null and b/build/classes/xenon/events/BoatflyPatch.class differ diff --git a/build/classes/xenon/events/CustomChat.class b/build/classes/xenon/events/CustomChat.class new file mode 100644 index 0000000..f5889be Binary files /dev/null and b/build/classes/xenon/events/CustomChat.class differ diff --git a/build/classes/xenon/events/CustomMessages.class b/build/classes/xenon/events/CustomMessages.class new file mode 100644 index 0000000..7c09141 Binary files /dev/null and b/build/classes/xenon/events/CustomMessages.class differ diff --git a/build/classes/xenon/events/CustomTab$1.class b/build/classes/xenon/events/CustomTab$1.class new file mode 100644 index 0000000..8c3b6ee Binary files /dev/null and b/build/classes/xenon/events/CustomTab$1.class differ diff --git a/build/classes/xenon/events/CustomTab.class b/build/classes/xenon/events/CustomTab.class new file mode 100644 index 0000000..f1f7fc4 Binary files /dev/null and b/build/classes/xenon/events/CustomTab.class differ diff --git a/build/classes/xenon/events/ElytraflyPatch$1.class b/build/classes/xenon/events/ElytraflyPatch$1.class new file mode 100644 index 0000000..6196500 Binary files /dev/null and b/build/classes/xenon/events/ElytraflyPatch$1.class differ diff --git a/build/classes/xenon/events/ElytraflyPatch.class b/build/classes/xenon/events/ElytraflyPatch.class new file mode 100644 index 0000000..277d67f Binary files /dev/null and b/build/classes/xenon/events/ElytraflyPatch.class differ diff --git a/build/classes/xenon/events/LimitArmorStands$1.class b/build/classes/xenon/events/LimitArmorStands$1.class new file mode 100644 index 0000000..2d74dad Binary files /dev/null and b/build/classes/xenon/events/LimitArmorStands$1.class differ diff --git a/build/classes/xenon/events/LimitArmorStands.class b/build/classes/xenon/events/LimitArmorStands.class new file mode 100644 index 0000000..5858b1e Binary files /dev/null and b/build/classes/xenon/events/LimitArmorStands.class differ diff --git a/build/classes/xenon/events/RandomRespawn.class b/build/classes/xenon/events/RandomRespawn.class new file mode 100644 index 0000000..b7aa489 Binary files /dev/null and b/build/classes/xenon/events/RandomRespawn.class differ diff --git a/build/classes/xenon/main.class b/build/classes/xenon/main.class new file mode 100644 index 0000000..442abb3 Binary files /dev/null and b/build/classes/xenon/main.class differ diff --git a/build/classes/xenon/misc/Common.class b/build/classes/xenon/misc/Common.class new file mode 100644 index 0000000..c098b23 Binary files /dev/null and b/build/classes/xenon/misc/Common.class differ diff --git a/build/classes/xenon/misc/GetElapsedTime.class b/build/classes/xenon/misc/GetElapsedTime.class new file mode 100644 index 0000000..cc397a4 Binary files /dev/null and b/build/classes/xenon/misc/GetElapsedTime.class differ diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..ceae3f2 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1770 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..c0c68cd --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=32f2a6aa +build.xml.script.CRC32=9a81a35d +build.xml.stylesheet.CRC32=f85dc8f2@1.96.0.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=32f2a6aa +nbproject/build-impl.xml.script.CRC32=28eb4367 +nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.96.0.48 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..de745fc --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\hanna\\AppData\\Roaming\\NetBeans\\12.1\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..db7ec95 --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,27 @@ + + + + + + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Help.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/BoatflyPatch.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/ElytraflyPatch.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/CustomChat.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/AntiIllegals.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/main.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/CustomTab.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Stats.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/misc/GetElapsedTime.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Kill.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Discord.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/LimitArmorStands.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/AntiSpam.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/misc/Common.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/AntiNetherRoof.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/RandomRespawn.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Joindate.java + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/plugin.yml + file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/CustomMessages.java + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..44143ed --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,99 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/xenon.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/xenon +excludes= +file.reference.spigot-1.16.5.jar=api\\spigot-1.16.5.jar +file.reference.spigot1122.jar=C:\\Users\\hanna\\Downloads\\spigot1122.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.spigot1122.jar}:\ + ${file.reference.spigot-1.16.5.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=xenon +main.class=hnhx.Hnhx +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..476a3a4 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + xenon + + + + + + + + + diff --git a/src/plugin.yml b/src/plugin.yml new file mode 100644 index 0000000..04af7e2 --- /dev/null +++ b/src/plugin.yml @@ -0,0 +1,14 @@ +main: xenon.main +name: xenon +version: 1.0 +api-version: 1.16 +description: The main plugin of Xenon. +commands: + kill: + aliases: suicide + help: + discord: + aliases: d + stats: + joindate: + aliases: jd \ No newline at end of file diff --git a/src/xenon/commands/Discord.java b/src/xenon/commands/Discord.java new file mode 100644 index 0000000..38ddcb5 --- /dev/null +++ b/src/xenon/commands/Discord.java @@ -0,0 +1,22 @@ +package xenon.commands; + + +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +/** + * + * @author hanna + */ +public class Discord implements Listener, CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String labe, String[] args) { + Player p = (Player) sender; + p.sendMessage("§bClick on the link to join: §dhttps://discord.gg/gHn8aqTR5j"); + return true; + } +} diff --git a/src/xenon/commands/Help.java b/src/xenon/commands/Help.java new file mode 100644 index 0000000..05e15ca --- /dev/null +++ b/src/xenon/commands/Help.java @@ -0,0 +1,26 @@ +package xenon.commands; + +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +/** + * + * @author hanna + */ +public class Help implements Listener, CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String labe, String[] args) { + Player p = (Player) sender; + p.sendMessage("§d/kill §bKills you\n" + + "§d/stats §bServer information\n" + + "§d/discord §bLink to the discord server\n" + + "§d/tps §bTPS from the last 1m, 5m, 15m\n" + + "§d/help §bThis command\n" + + "§d/joindate (player) §bJoindate of a player"); + return true; + } +} diff --git a/src/xenon/commands/Joindate.java b/src/xenon/commands/Joindate.java new file mode 100644 index 0000000..70839a9 --- /dev/null +++ b/src/xenon/commands/Joindate.java @@ -0,0 +1,41 @@ +package xenon.commands; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +/** + * + * @author hanna + */ +public class Joindate implements Listener, CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String labe, String[] args) { + Player p = (Player) sender; + OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(p.getName()); + if (args.length != 0 ) { + String target = args[0]; + targetPlayer = Bukkit.getOfflinePlayer(target); + } + + long joinTime = targetPlayer.getFirstPlayed(); + if (joinTime == 0) { + p.sendMessage("§cThat user never played here!"); + return false; + } + Date joinDate = new Date(joinTime); + DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + String joinDateFormatted = String.format("§d%s §bjoin date: §d%s", targetPlayer.getName(), df.format(joinDate)); + p.sendMessage(joinDateFormatted); + + return true; + } +} diff --git a/src/xenon/commands/Kill.java b/src/xenon/commands/Kill.java new file mode 100644 index 0000000..dc0db3a --- /dev/null +++ b/src/xenon/commands/Kill.java @@ -0,0 +1,21 @@ +package xenon.commands; + +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +/** + * + * @author hanna + */ +public class Kill implements Listener, CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String labe, String[] args) { + Player p = (Player) sender; + p.setHealth(0); + return true; + } +} diff --git a/src/xenon/commands/Stats.java b/src/xenon/commands/Stats.java new file mode 100644 index 0000000..52f3395 --- /dev/null +++ b/src/xenon/commands/Stats.java @@ -0,0 +1,92 @@ +package xenon.commands; + +import xenon.misc.GetElapsedTime; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.FileTime; +import java.text.CharacterIterator; +import java.text.StringCharacterIterator; +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.World; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.Command; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +/** + * + * @author hanna + */ +public class Stats implements Listener, CommandExecutor { + + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String labe, String[] args) { + Player p = (Player) sender; + int allPlayers = Bukkit.getOfflinePlayers().length; + long maxRam = Runtime.getRuntime().maxMemory() / 1024 / 1024; + long usedRam = Runtime.getRuntime().freeMemory() / 1024 / 1024; + long size = 0; + for (World world : Bukkit.getWorlds()) { + String worldName = world.getName(); + File worldFile = new File(worldName); + size+= getDirectorySizeLegacy(worldFile); + + } + + File owFile = new File(Bukkit.getWorlds().get(0).getName()); + long creationTime = 0; + try { + BasicFileAttributes attrs = Files.readAttributes(owFile.toPath(), BasicFileAttributes.class); + FileTime time = attrs.creationTime(); + creationTime = time.toMillis(); + } catch (IOException e) { + e.printStackTrace(); + } + + String serverAge = GetElapsedTime.get(creationTime).replace(" -", ", "); + + String readableSize = humanReadableByteCountBin(size); + + p.sendMessage(String.format("§bCurrent RAM usage: §d%s MB §b/ §d%s MB\n" + + "§bCurrent server size: §d%s\n" + + "§bThe server is %s §bold.\n" + + "§bThere are §d%s §bindividual players who joined at least once.",usedRam,maxRam, readableSize, serverAge, allPlayers)); + return true; + } + + + public static long getDirectorySizeLegacy(File dir) { + long length = 0; + File[] files = dir.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isFile()) + length += file.length(); + else + length += getDirectorySizeLegacy(file); + } + } + return length; + } + + public static String humanReadableByteCountBin(long bytes) { + long absB = bytes == Long.MIN_VALUE ? Long.MAX_VALUE : Math.abs(bytes); + if (absB < 1024) { + return bytes + " B"; + } + long value = absB; + CharacterIterator ci = new StringCharacterIterator("KMGTPE"); + for (int i = 40; i >= 0 && absB > 0xfffccccccccccccL >> i; i -= 10) { + value >>= 10; + ci.next(); + } + value *= Long.signum(bytes); + return String.format("%.1f %cB", value / 1024.0, ci.current()); +} + +} diff --git a/src/xenon/events/AntiIllegals.java b/src/xenon/events/AntiIllegals.java new file mode 100644 index 0000000..83c004c --- /dev/null +++ b/src/xenon/events/AntiIllegals.java @@ -0,0 +1,74 @@ +package xenon.events; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityPickupItemEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; +import xenon.misc.Common; + +/** + * + * @author hanna + */ +public class AntiIllegals implements Listener { + @EventHandler + public void PlayerPickupItemEvent​(EntityPickupItemEvent e) { + if (e.getEntity().getType() == EntityType.PLAYER) { + UUID uuid = e.getEntity().getUniqueId(); + Player p = Bukkit.getPlayer(uuid); + new BukkitRunnable(){ + @Override + public void run(){ + Inventory inv = p.getInventory(); + revert(inv); + } + }.runTaskLater(Common.getPlugin(), 1); + } + } + + @EventHandler + public void onInventoryOpenEvent(InventoryOpenEvent e){ + Inventory inv = e.getInventory(); + revert(inv); + } + + static List illegals = Arrays.asList(Material.BEDROCK, Material.END_PORTAL_FRAME, Material.SPAWNER); + + public void revert(Inventory inv) { + for(ItemStack item : inv.getContents()) { + if (item != null) { + + // remove illegal items + if (illegals.contains(item.getType())) { + inv.remove(item); + continue; + } + + // revert illegal enchantments + if (item.getEnchantments() != null) { + for(Map.Entry enchantment : item.getEnchantments().entrySet()) { + Enchantment enchantmentType = enchantment.getKey(); + int enchantmentLevel = enchantment.getValue(); + int enchantmentMaxLevel = enchantmentType.getMaxLevel(); + if (enchantmentLevel > enchantmentMaxLevel) { + item.removeEnchantment(enchantmentType); + item.addEnchantment(enchantmentType, enchantmentMaxLevel); + } + } + } + } + } + } +} diff --git a/src/xenon/events/AntiNetherRoof.java b/src/xenon/events/AntiNetherRoof.java new file mode 100644 index 0000000..828b55d --- /dev/null +++ b/src/xenon/events/AntiNetherRoof.java @@ -0,0 +1,52 @@ +package xenon.events; + +import java.util.ArrayList; +import java.util.List; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.scheduler.BukkitRunnable; +import xenon.misc.Common; + +/** + * + * @author hanna + */ +public class AntiNetherRoof implements Listener { + @EventHandler + public void onMove(PlayerMoveEvent event) { + if (!playersToDamage.contains(event.getPlayer())) { + World nether = Bukkit.getServer().getWorlds().get(1); + if (event.getPlayer().getWorld() == nether) { + if (event.getPlayer().getLocation().getY() >= 128 || 0 >= event.getPlayer().getLocation().getY()) { + playersToDamage.add(event.getPlayer()); + netherRoofDamage(event.getPlayer()); + } + } + } + } + + + protected List playersToDamage = new ArrayList(); + public void netherRoofDamage(Player p) { + new BukkitRunnable(){ + int netherDamage = 2; + @Override + public void run(){ + World nether = Bukkit.getServer().getWorlds().get(1); + if (p.getWorld() == nether) { + if (p.getLocation().getY() >= 128 || 0 >= p.getLocation().getY()) { + p.damage(netherDamage); + netherDamage *= 1.5; + } else { + playersToDamage.remove(p); + this.cancel(); + } + } + } + }.runTaskTimer(Common.getPlugin(), 0, 20); + } +} diff --git a/src/xenon/events/AntiSpam.java b/src/xenon/events/AntiSpam.java new file mode 100644 index 0000000..45c2db6 --- /dev/null +++ b/src/xenon/events/AntiSpam.java @@ -0,0 +1,84 @@ +package xenon.events; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; + +/** + * + * @author hanna + */ +public class AntiSpam implements Listener { + HashMap> playerMessages = new HashMap>(); + @EventHandler + public void onChat(AsyncPlayerChatEvent event) { + + String UUID = event.getPlayer().getUniqueId().toString(); + + String newMessage = event.getMessage(); + List messages = new ArrayList(); + messages = playerMessages.get(UUID); + List newMessageWords = Arrays.asList(newMessage.split(" ")); + + if (messages == null) { + messages = new ArrayList(); + messages.add(newMessage); + playerMessages.put(UUID, messages); + } else { + if (newMessage.length() > 6 && newMessageWords.size() > 2) { + for (String oldMessage : messages) { + + if (oldMessage.toLowerCase().equals(newMessage.toLowerCase())) { + event.getPlayer().sendMessage("§cYour message has been detected as spam!"); + event.setCancelled(true); + break; + } + + List oldMessageWords = Arrays.asList(oldMessage.split(" ")); + + List oldMessageWordsLower = new ArrayList(); + for (String msg : oldMessageWords) { + oldMessageWordsLower.add(msg.toLowerCase()); + } + + List newMessageWordsLower = new ArrayList(); + for (String msg : newMessageWords) { + newMessageWordsLower.add(msg.toLowerCase()); + } + + + if (3 > oldMessageWords.size() - newMessageWords.size()) { + + ArrayList duplicates = new ArrayList(oldMessageWordsLower); + duplicates.retainAll(newMessageWordsLower); + + if (duplicates.size() >= newMessageWords.size() - 1) { + event.getPlayer().sendMessage("§cYour message has been detected as spam!"); + event.setCancelled(true); + break; + } + + } + } + + } else if (newMessage.toLowerCase().equals(messages.get(messages.size() - 1).toLowerCase())) { + event.getPlayer().sendMessage("§cYour message has been detected as spam!"); + event.setCancelled(true); + } + + if (!event.isCancelled()) { + if (25 > messages.size()) { + messages.add(newMessage); + } else { + messages.remove(0); + messages.add(newMessage); + } + playerMessages.put(UUID, messages); + } + } + } +} diff --git a/src/xenon/events/BoatflyPatch.java b/src/xenon/events/BoatflyPatch.java new file mode 100644 index 0000000..df17f43 --- /dev/null +++ b/src/xenon/events/BoatflyPatch.java @@ -0,0 +1,29 @@ +package xenon.events; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; + +/** + * + * @author hanna + */ +public class BoatflyPatch implements Listener { + @EventHandler + public void onMove(PlayerMoveEvent event) { + Player p = event.getPlayer(); + if (p.isInsideVehicle()) { + if(p.getVehicle().getType() == EntityType.BOAT){ + Vehicle v = (Vehicle) p.getVehicle(); + if (v.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) { + v.eject(); + } + } + } + } +} diff --git a/src/xenon/events/CustomChat.java b/src/xenon/events/CustomChat.java new file mode 100644 index 0000000..b7c1b29 --- /dev/null +++ b/src/xenon/events/CustomChat.java @@ -0,0 +1,59 @@ +package xenon.events; + +import java.util.HashMap; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; + +/** + * + * @author hanna + */ +public class CustomChat implements Listener { + @EventHandler + public void onChat(AsyncPlayerChatEvent event) { + event.setFormat("§d%s§b: §f%s"); + + String message = event.getMessage(); + + if (message.charAt(0) == '$') event.setMessage(lgbtColors(message)); + + if (message.charAt(0) == '>') event.setMessage("§a" + message); + } + + public static String lgbtColors(String textToConvert) { + if (3 > textToConvert.length()) return textToConvert; + + HashMap colors = new HashMap(); + colors.put('g',new String[]{"§c", "§6", "§e", "§a", "§3", "§d"}); + colors.put('t',new String[]{"§b", "§d", "§f", "§d", "§b"}); + colors.put('b',new String[]{"§d", "§5", "§3"}); + colors.put('p',new String[]{"§d", "§e", "§b"}); + colors.put('n',new String[]{"§e", "§f", "§5", "§0"}); + colors.put('l',new String[]{"§c", "§e", "§f", "§d", "§5"}); + + String[] chosenColors = colors.get(Character.toLowerCase(textToConvert.charAt(1))); + if (chosenColors == null) return textToConvert; + + String convertedText = ""; + byte colorCount = 0; + for (int i = 2; i < textToConvert.length(); i++) { + char c = textToConvert.charAt(i); + if (c == ' ') { + convertedText += c; + continue; + } + + convertedText += chosenColors[colorCount] + c; + + if (colorCount >= chosenColors.length - 1) { + colorCount = 0; + } else { + colorCount++; + } + + } + + return convertedText; + } +} diff --git a/src/xenon/events/CustomMessages.java b/src/xenon/events/CustomMessages.java new file mode 100644 index 0000000..bce3235 --- /dev/null +++ b/src/xenon/events/CustomMessages.java @@ -0,0 +1,26 @@ +package xenon.events; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent​; +import org.bukkit.event.player.PlayerJoinEvent; + +/** + * + * @author hanna + */ +public class CustomMessages implements Listener { + @EventHandler + public void PlayerDeathEvent​(PlayerDeathEvent​ event) { + String pName = event.getEntity().getName(); + String dMessage = event.getDeathMessage().replace(pName + " ", ""); + event.setDeathMessage(String.format("§d%s §b%s",pName, dMessage)); + } + + @EventHandler + public void PlayerJoinEvent(PlayerJoinEvent e) { + e.setJoinMessage(String.format("§d%s §bjoined the server %s", e.getPlayer().getName(), (e.getPlayer().hasPlayedBefore() ? "" : "§dfor the first time"))); + } + + +} diff --git a/src/xenon/events/CustomTab.java b/src/xenon/events/CustomTab.java new file mode 100644 index 0000000..8f78ea1 --- /dev/null +++ b/src/xenon/events/CustomTab.java @@ -0,0 +1,78 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package xenon.events; + +import java.lang.reflect.Field; +import net.minecraft.server.v1_16_R3.ChatComponentText; +import net.minecraft.server.v1_16_R3.MinecraftServer; +import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerListHeaderFooter; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; +import xenon.misc.Common; +import xenon.misc.GetElapsedTime; + +/** + * + * @author hanna + */ +public class CustomTab { + public static void tab() { + long startTime = System.currentTimeMillis(); + + PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(); + new BukkitRunnable() { + @Override + public void run() { + try { + Field header = packet.getClass().getDeclaredField("header"); + header.setAccessible(true); + + Field footer = packet.getClass().getDeclaredField("footer"); + footer.setAccessible(true); + + + // PLAYERS + int onlinePlayers = Bukkit.getOnlinePlayers().size(); + int maxPlayers = Bukkit.getMaxPlayers(); + + + // TPS + double tps = MinecraftServer.getServer().recentTps[0]; + double fixedTps = (tps > 20 ? 20 : tps); + + // Uptime + String uptime = "§bUptime: " + GetElapsedTime.get(startTime); + + for (Player p : Bukkit.getOnlinePlayers()) { + String name = p.getName(); + + int ping = ((CraftPlayer) p).getHandle().ping; + + String headerMessage = String.format("§b§l§ka§r §d§lXenon §r§b§l§ka\n§d%s §b/ §d%s §bplayers\n", onlinePlayers, maxPlayers); + Object headerObj = new ChatComponentText(headerMessage); + + String footerMessage = String.format("\n§bTPS: §d%.2f §b- Ping: §d%s\n%s\n§bDiscord: §d/discord\n\n§cElytra fly hacks are limited but not disabled.\n§cThis might change depending on the server's performance",fixedTps,ping,uptime); + Object footerObj = new ChatComponentText(footerMessage); + + header.set(packet, headerObj); + footer.set(packet, footerObj); + + + ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); + } + + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + }.runTaskTimer(Common.getPlugin(), 0, 20); + } +} diff --git a/src/xenon/events/ElytraflyPatch.java b/src/xenon/events/ElytraflyPatch.java new file mode 100644 index 0000000..6c7274a --- /dev/null +++ b/src/xenon/events/ElytraflyPatch.java @@ -0,0 +1,75 @@ +package xenon.events; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.scheduler.BukkitRunnable; +import xenon.misc.Common; + +/** + * + * @author hanna + */ +public class ElytraflyPatch implements Listener { + + @EventHandler + public void PlayerJoinEvent(PlayerJoinEvent e) { + e.getPlayer().setGliding(false); + elytraPatch(e.getPlayer()); + } + + public void elytraPatch(Player p) { + new BukkitRunnable(){ + + Location prevLocation = p.getLocation(); + protected List distancesFlown = new ArrayList(); + Location glideStarted = null; + + @Override + public void run(){ + + if (!p.isOnline()) { + this.cancel(); + } + + Location curLocation = p.getLocation(); + double curDistanceFlown = curLocation.distanceSquared(prevLocation); + + if (p.isGliding() && !p.isInWater()) { + if (glideStarted == null) glideStarted = curLocation; + + if (distancesFlown.size() == 10) { + + HashSet fDistanceFlown = new HashSet(distancesFlown); + if (8 >= fDistanceFlown.size() ) { + p.teleport(glideStarted); + distancesFlown.clear(); + p.setGliding(false); + //p.sendMessage("§cElytra hacks are not allowed!"); + //p.kickPlayer("§b§l[§d§lXENON§b§l]\n\n§bKick reason: §dElytra related"); + } + + + glideStarted = curLocation; + } + if (distancesFlown.size() == 20) { + distancesFlown.clear(); + } else { + distancesFlown.add(Double.parseDouble(String.format("%.6g%n", curDistanceFlown))); + } + + } else { + glideStarted = null; + } + prevLocation = curLocation; + + } + }.runTaskTimer(Common.getPlugin(), 0, 3); + } + +} diff --git a/src/xenon/events/LimitArmorStands.java b/src/xenon/events/LimitArmorStands.java new file mode 100644 index 0000000..c6e2b09 --- /dev/null +++ b/src/xenon/events/LimitArmorStands.java @@ -0,0 +1,37 @@ +package xenon.events; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.EntityEffect; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.scheduler.BukkitRunnable; +import xenon.misc.Common; + +/** + * + * @author hanna + */ +public class LimitArmorStands { + public static void limit() { + new BukkitRunnable() { + @Override + public void run() { + for (World world: Bukkit.getServer().getWorlds()) + for (Chunk chunk : world.getLoadedChunks()) { + int armorStandCount = 0; + for (Entity entity : chunk.getEntities()) { + if (entity.getType() == EntityType.ARMOR_STAND) { + armorStandCount++; + if (armorStandCount > 10) { + entity.playEffect(EntityEffect.DEATH); + entity.remove(); + } + } + } + } + + }}.runTaskTimer(Common.getPlugin(), 0, 20); + } +} diff --git a/src/xenon/events/RandomRespawn.java b/src/xenon/events/RandomRespawn.java new file mode 100644 index 0000000..3607a1c --- /dev/null +++ b/src/xenon/events/RandomRespawn.java @@ -0,0 +1,50 @@ +package xenon.events; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerRespawnEvent; + +/** + * + * @author hanna + */ +public class RandomRespawn implements Listener { + + @EventHandler + public void onRespawn(PlayerRespawnEvent event) { + Player p = event.getPlayer(); + if (p.getBedSpawnLocation() == null) { + World overWorld = Bukkit.getServer().getWorlds().get(0); + List blacklistedBlocks = Arrays.asList(Material.AIR, Material.VOID_AIR); + int radius = 1001; + + Boolean safeRespawn = false; + Location potentialSpawn = null; + Random r = new Random(); + do { + int x = r.nextInt(radius); + int z = r.nextInt(radius); + + for (int y = overWorld.getMaxHeight(); y>0; y--) { + potentialSpawn = new Location(overWorld, x,y,z); + Block currentBlock = potentialSpawn.getBlock(); + if (!blacklistedBlocks.contains(currentBlock.getType())) { + safeRespawn = true; + event.setRespawnLocation(potentialSpawn); + break; + } + + } + } while (!safeRespawn); + } + } +} diff --git a/src/xenon/main.java b/src/xenon/main.java new file mode 100644 index 0000000..20942d1 --- /dev/null +++ b/src/xenon/main.java @@ -0,0 +1,51 @@ +package xenon; + + + +import xenon.commands.Discord; +import xenon.commands.Help; +import xenon.commands.Stats; +import xenon.commands.Joindate; +import xenon.commands.Kill; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; +import xenon.events.AntiIllegals; +import xenon.events.AntiNetherRoof; +import xenon.events.AntiSpam; +import xenon.events.BoatflyPatch; +import xenon.events.CustomChat; +import xenon.events.CustomMessages; +import xenon.events.CustomTab; +import xenon.events.ElytraflyPatch; +import xenon.events.LimitArmorStands; +import xenon.events.RandomRespawn; + +/** + * + * @author hanna + */ + + public class main extends JavaPlugin implements Listener { + + @Override + public void onEnable() { + getServer().getPluginManager().registerEvents(new AntiIllegals(), this); + getServer().getPluginManager().registerEvents(new AntiNetherRoof(), this); + getServer().getPluginManager().registerEvents(new AntiSpam(), this); + getServer().getPluginManager().registerEvents(new BoatflyPatch(), this); + getServer().getPluginManager().registerEvents(new CustomChat(), this); + getServer().getPluginManager().registerEvents(new CustomMessages(), this); + getServer().getPluginManager().registerEvents(new ElytraflyPatch(), this); + getServer().getPluginManager().registerEvents(new RandomRespawn(), this); + + LimitArmorStands.limit(); + CustomTab.tab(); + + this.getCommand("kill").setExecutor(new Kill()); + this.getCommand("help").setExecutor(new Help()); + this.getCommand("discord").setExecutor(new Discord()); + this.getCommand("stats").setExecutor(new Stats()); + this.getCommand("joindate").setExecutor(new Joindate()); + + } +} \ No newline at end of file diff --git a/src/xenon/misc/Common.java b/src/xenon/misc/Common.java new file mode 100644 index 0000000..376ac3e --- /dev/null +++ b/src/xenon/misc/Common.java @@ -0,0 +1,14 @@ +package xenon.misc; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; + +/** + * + * @author hanna + */ +public class Common { + public static Plugin getPlugin() { + return Bukkit.getServer().getPluginManager().getPlugin("xenon"); + } +} diff --git a/src/xenon/misc/GetElapsedTime.java b/src/xenon/misc/GetElapsedTime.java new file mode 100644 index 0000000..178fdfa --- /dev/null +++ b/src/xenon/misc/GetElapsedTime.java @@ -0,0 +1,42 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package xenon.misc; + +/** + * + * @author hanna + */ +public class GetElapsedTime { + + public static String get(long timeToConvert) { + // UPTIME + long different = System.currentTimeMillis() - timeToConvert; + + long secondsInMilli = 1000; + long minutesInMilli = secondsInMilli * 60; + long hoursInMilli = minutesInMilli * 60; + long daysInMilli = hoursInMilli * 24; + long weeksInMilli = daysInMilli * 7; + + long elapsedWeeks = different / weeksInMilli; + different = different % weeksInMilli; + + long elapsedDays = different / daysInMilli; + different = different % daysInMilli; + + long elapsedHours = different / hoursInMilli; + different = different % hoursInMilli; + + long elapsedMinutes = different / minutesInMilli; + different = different % minutesInMilli; + + long elapsedSeconds = different / secondsInMilli; + + return String.format("§d%d w§b - §d%d d§b - §d%d h§b - §d%d m§b - §d%d s", elapsedWeeks,elapsedDays,elapsedHours,elapsedMinutes,elapsedSeconds); + + } + +}