mirror of
https://github.com/hnhx/xenon.git
synced 2025-01-24 10:07:48 -03:00
first commit
This commit is contained in:
commit
b40f23b140
53 changed files with 2904 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
dist
|
||||
api
|
73
build.xml
Normal file
73
build.xml
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="xenon" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project xenon.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar: JAR building
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="xenon-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
</project>
|
4
build/built-jar.properties
Normal file
4
build/built-jar.properties
Normal file
|
@ -0,0 +1,4 @@
|
|||
#Fri, 29 Jan 2021 22:23:53 +0100
|
||||
|
||||
|
||||
C\:\\Users\\hanna\\Documents\\NetBeansProjects\\hnhx=
|
14
build/classes/plugin.yml
Normal file
14
build/classes/plugin.yml
Normal file
|
@ -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
|
BIN
build/classes/xenon/commands/Discord.class
Normal file
BIN
build/classes/xenon/commands/Discord.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/commands/Help.class
Normal file
BIN
build/classes/xenon/commands/Help.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/commands/Joindate.class
Normal file
BIN
build/classes/xenon/commands/Joindate.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/commands/Kill.class
Normal file
BIN
build/classes/xenon/commands/Kill.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/commands/Stats.class
Normal file
BIN
build/classes/xenon/commands/Stats.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/AntiIllegals$1.class
Normal file
BIN
build/classes/xenon/events/AntiIllegals$1.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/AntiIllegals.class
Normal file
BIN
build/classes/xenon/events/AntiIllegals.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/AntiNetherRoof$1.class
Normal file
BIN
build/classes/xenon/events/AntiNetherRoof$1.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/AntiNetherRoof.class
Normal file
BIN
build/classes/xenon/events/AntiNetherRoof.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/AntiSpam.class
Normal file
BIN
build/classes/xenon/events/AntiSpam.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/BoatflyPatch.class
Normal file
BIN
build/classes/xenon/events/BoatflyPatch.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/CustomChat.class
Normal file
BIN
build/classes/xenon/events/CustomChat.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/CustomMessages.class
Normal file
BIN
build/classes/xenon/events/CustomMessages.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/CustomTab$1.class
Normal file
BIN
build/classes/xenon/events/CustomTab$1.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/CustomTab.class
Normal file
BIN
build/classes/xenon/events/CustomTab.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/ElytraflyPatch$1.class
Normal file
BIN
build/classes/xenon/events/ElytraflyPatch$1.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/ElytraflyPatch.class
Normal file
BIN
build/classes/xenon/events/ElytraflyPatch.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/LimitArmorStands$1.class
Normal file
BIN
build/classes/xenon/events/LimitArmorStands$1.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/LimitArmorStands.class
Normal file
BIN
build/classes/xenon/events/LimitArmorStands.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/events/RandomRespawn.class
Normal file
BIN
build/classes/xenon/events/RandomRespawn.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/main.class
Normal file
BIN
build/classes/xenon/main.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/misc/Common.class
Normal file
BIN
build/classes/xenon/misc/Common.class
Normal file
Binary file not shown.
BIN
build/classes/xenon/misc/GetElapsedTime.class
Normal file
BIN
build/classes/xenon/misc/GetElapsedTime.class
Normal file
Binary file not shown.
3
manifest.mf
Normal file
3
manifest.mf
Normal file
|
@ -0,0 +1,3 @@
|
|||
Manifest-Version: 1.0
|
||||
X-COMMENT: Main-Class will be added automatically by build
|
||||
|
1770
nbproject/build-impl.xml
Normal file
1770
nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load diff
8
nbproject/genfiles.properties
Normal file
8
nbproject/genfiles.properties
Normal file
|
@ -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
|
2
nbproject/private/private.properties
Normal file
2
nbproject/private/private.properties
Normal file
|
@ -0,0 +1,2 @@
|
|||
compile.on.save=true
|
||||
user.properties.file=C:\\Users\\hanna\\AppData\\Roaming\\NetBeans\\12.1\\build.properties
|
27
nbproject/private/private.xml
Normal file
27
nbproject/private/private.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Help.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/BoatflyPatch.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/ElytraflyPatch.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/CustomChat.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/AntiIllegals.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/main.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/CustomTab.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Stats.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/misc/GetElapsedTime.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Kill.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Discord.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/LimitArmorStands.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/AntiSpam.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/misc/Common.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/AntiNetherRoof.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/RandomRespawn.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/commands/Joindate.java</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/plugin.yml</file>
|
||||
<file>file:/C:/Users/hanna/Documents/NetBeansProjects/hnhx/src/xenon/events/CustomMessages.java</file>
|
||||
</group>
|
||||
</open-files>
|
||||
</project-private>
|
99
nbproject/project.properties
Normal file
99
nbproject/project.properties
Normal file
|
@ -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
|
15
nbproject/project.xml
Normal file
15
nbproject/project.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>xenon</name>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
14
src/plugin.yml
Normal file
14
src/plugin.yml
Normal file
|
@ -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
|
22
src/xenon/commands/Discord.java
Normal file
22
src/xenon/commands/Discord.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
26
src/xenon/commands/Help.java
Normal file
26
src/xenon/commands/Help.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
41
src/xenon/commands/Joindate.java
Normal file
41
src/xenon/commands/Joindate.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
21
src/xenon/commands/Kill.java
Normal file
21
src/xenon/commands/Kill.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
92
src/xenon/commands/Stats.java
Normal file
92
src/xenon/commands/Stats.java
Normal file
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
74
src/xenon/events/AntiIllegals.java
Normal file
74
src/xenon/events/AntiIllegals.java
Normal file
|
@ -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<Material> 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, Integer> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
52
src/xenon/events/AntiNetherRoof.java
Normal file
52
src/xenon/events/AntiNetherRoof.java
Normal file
|
@ -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<Player> playersToDamage = new ArrayList<Player>();
|
||||
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);
|
||||
}
|
||||
}
|
84
src/xenon/events/AntiSpam.java
Normal file
84
src/xenon/events/AntiSpam.java
Normal file
|
@ -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<String, List<String>> playerMessages = new HashMap<String, List<String>>();
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
|
||||
String UUID = event.getPlayer().getUniqueId().toString();
|
||||
|
||||
String newMessage = event.getMessage();
|
||||
List<String> messages = new ArrayList<String>();
|
||||
messages = playerMessages.get(UUID);
|
||||
List<String> newMessageWords = Arrays.asList(newMessage.split(" "));
|
||||
|
||||
if (messages == null) {
|
||||
messages = new ArrayList<String>();
|
||||
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<String> oldMessageWords = Arrays.asList(oldMessage.split(" "));
|
||||
|
||||
List<String> oldMessageWordsLower = new ArrayList<String>();
|
||||
for (String msg : oldMessageWords) {
|
||||
oldMessageWordsLower.add(msg.toLowerCase());
|
||||
}
|
||||
|
||||
List<String> newMessageWordsLower = new ArrayList<String>();
|
||||
for (String msg : newMessageWords) {
|
||||
newMessageWordsLower.add(msg.toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
if (3 > oldMessageWords.size() - newMessageWords.size()) {
|
||||
|
||||
ArrayList<String> duplicates = new ArrayList<String>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
src/xenon/events/BoatflyPatch.java
Normal file
29
src/xenon/events/BoatflyPatch.java
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
59
src/xenon/events/CustomChat.java
Normal file
59
src/xenon/events/CustomChat.java
Normal file
|
@ -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<Character, String[]> colors = new HashMap<Character,String[]>();
|
||||
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;
|
||||
}
|
||||
}
|
26
src/xenon/events/CustomMessages.java
Normal file
26
src/xenon/events/CustomMessages.java
Normal file
|
@ -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")));
|
||||
}
|
||||
|
||||
|
||||
}
|
78
src/xenon/events/CustomTab.java
Normal file
78
src/xenon/events/CustomTab.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
75
src/xenon/events/ElytraflyPatch.java
Normal file
75
src/xenon/events/ElytraflyPatch.java
Normal file
|
@ -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<Double> distancesFlown = new ArrayList<Double>();
|
||||
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<Double> fDistanceFlown = new HashSet<Double>(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);
|
||||
}
|
||||
|
||||
}
|
37
src/xenon/events/LimitArmorStands.java
Normal file
37
src/xenon/events/LimitArmorStands.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
50
src/xenon/events/RandomRespawn.java
Normal file
50
src/xenon/events/RandomRespawn.java
Normal file
|
@ -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<Material> 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);
|
||||
}
|
||||
}
|
||||
}
|
51
src/xenon/main.java
Normal file
51
src/xenon/main.java
Normal file
|
@ -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());
|
||||
|
||||
}
|
||||
}
|
14
src/xenon/misc/Common.java
Normal file
14
src/xenon/misc/Common.java
Normal file
|
@ -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");
|
||||
}
|
||||
}
|
42
src/xenon/misc/GetElapsedTime.java
Normal file
42
src/xenon/misc/GetElapsedTime.java
Normal file
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue