Initial Commit

This commit is contained in:
JaTiTV 2021-11-28 02:13:21 +01:00
commit 65c43dfd82
146 changed files with 4611 additions and 0 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="T2CodeLib">
<output-path>$PROJECT_DIR$/../../Libarys</output-path>
<root id="archive" name="T2CodeLib.jar">
<element id="module-output" name="T2CodeLib" />
</root>
</artifact>
</component>

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="T2CodeLib_1.0.0.32">
<output-path>$PROJECT_DIR$/../../Testserver/1.17.1/Server/plugins</output-path>
<root id="archive" name="T2CodeLib_1.0.0.3.jar">
<element id="module-output" name="T2CodeLib" />
</root>
</artifact>
</component>

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="T2CodeLib_7.3">
<output-path>$PROJECT_DIR$/../../Plugins/T2CodeLib/.jar</output-path>
<root id="archive" name="T2CodeLib_7.3.jar">
<element id="module-output" name="T2CodeLib" />
</root>
</artifact>
</component>

16
.idea/compiler.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="T2CodeLib" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="T2CodeLib" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>

7
.idea/discord.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
</component>
</project>

7
.idea/encodings.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

45
.idea/jarRepositories.xml Normal file
View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jitpack.io" />
<option name="name" value="jitpack.io" />
<option name="url" value="https://jitpack.io" />
</remote-repository>
<remote-repository>
<option name="id" value="sonatype" />
<option name="name" value="sonatype" />
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="spigotmc-repo" />
<option name="name" value="spigotmc-repo" />
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="placeholderapi" />
<option name="name" value="placeholderapi" />
<option name="url" value="http://repo.extendedclip.com/content/repositories/placeholderapi/" />
</remote-repository>
<remote-repository>
<option name="id" value="bungeecord-repo" />
<option name="name" value="bungeecord-repo" />
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
</remote-repository>
</component>
</project>

View File

@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="1_13_R2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Libarys/Spigot - NMS/1_13_R2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../../Libarys/Spigot - NMS/1_13_R2.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.github.MilkBowl:VaultAPI:1.7">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/github/MilkBowl/VaultAPI/1.7/VaultAPI-1.7.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/github/MilkBowl/VaultAPI/1.7/VaultAPI-1.7-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/github/MilkBowl/VaultAPI/1.7/VaultAPI-1.7-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.google.code.gson:gson:2.8.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.0/gson-2.8.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.0/gson-2.8.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.google.guava:guava:21.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/21.0/guava-21.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/21.0/guava-21.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/21.0/guava-21.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.googlecode.json-simple:json-simple:1.1.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: commons-lang:commons-lang:2.6">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/commons-lang/commons-lang/2.6/commons-lang-2.6.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/commons-lang/commons-lang/2.6/commons-lang-2.6-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/commons-lang/commons-lang/2.6/commons-lang-2.6-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: io.netty:netty-buffer:4.1.65.Final">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-buffer/4.1.65.Final/netty-buffer-4.1.65.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-buffer/4.1.65.Final/netty-buffer-4.1.65.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-buffer/4.1.65.Final/netty-buffer-4.1.65.Final-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: io.netty:netty-codec:4.1.65.Final">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-codec/4.1.65.Final/netty-codec-4.1.65.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-codec/4.1.65.Final/netty-codec-4.1.65.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-codec/4.1.65.Final/netty-codec-4.1.65.Final-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: io.netty:netty-common:4.1.65.Final">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-common/4.1.65.Final/netty-common-4.1.65.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-common/4.1.65.Final/netty-common-4.1.65.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-common/4.1.65.Final/netty-common-4.1.65.Final-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: io.netty:netty-resolver:4.1.65.Final">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-resolver/4.1.65.Final/netty-resolver-4.1.65.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-resolver/4.1.65.Final/netty-resolver-4.1.65.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-resolver/4.1.65.Final/netty-resolver-4.1.65.Final-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: io.netty:netty-transport:4.1.65.Final">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-transport/4.1.65.Final/netty-transport-4.1.65.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-transport/4.1.65.Final/netty-transport-4.1.65.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-transport/4.1.65.Final/netty-transport-4.1.65.Final-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: io.netty:netty-transport-native-unix-common:4.1.65.Final">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-transport-native-unix-common/4.1.65.Final/netty-transport-native-unix-common-4.1.65.Final.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-transport-native-unix-common/4.1.65.Final/netty-transport-native-unix-common-4.1.65.Final-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/io/netty/netty-transport-native-unix-common/4.1.65.Final/netty-transport-native-unix-common-4.1.65.Final-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: junit:junit:4.10">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: me.clip:placeholderapi:2.9.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/me/clip/placeholderapi/2.9.2/placeholderapi-2.9.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/me/clip/placeholderapi/2.9.2/placeholderapi-2.9.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/me/clip/placeholderapi/2.9.2/placeholderapi-2.9.2-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.md-5:brigadier:1.0.16-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/brigadier/1.0.16-SNAPSHOT/brigadier-1.0.16-20181219.233212-1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/brigadier/1.0.16-SNAPSHOT/brigadier-1.0.16-20181219.233212-1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/brigadier/1.0.16-SNAPSHOT/brigadier-1.0.16-20181219.233212-1-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.md-5:bungeecord-api:1.17-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-api/1.17-R0.1-SNAPSHOT/bungeecord-api-1.17-R0.1-20210722.014828-23.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-api/1.17-R0.1-SNAPSHOT/bungeecord-api-1.17-R0.1-20210722.014828-23-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-api/1.17-R0.1-SNAPSHOT/bungeecord-api-1.17-R0.1-20210722.014828-23-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.md-5:bungeecord-chat:1.16-R0.4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.16-R0.4/bungeecord-chat-1.16-R0.4.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.16-R0.4/bungeecord-chat-1.16-R0.4-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.16-R0.4/bungeecord-chat-1.16-R0.4-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.md-5:bungeecord-config:1.17-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-config/1.17-R0.1-SNAPSHOT/bungeecord-config-1.17-R0.1-20210722.014749-23.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-config/1.17-R0.1-SNAPSHOT/bungeecord-config-1.17-R0.1-20210722.014749-23-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-config/1.17-R0.1-SNAPSHOT/bungeecord-config-1.17-R0.1-20210722.014749-23-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.md-5:bungeecord-event:1.17-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-event/1.17-R0.1-SNAPSHOT/bungeecord-event-1.17-R0.1-20210722.014800-23.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-event/1.17-R0.1-SNAPSHOT/bungeecord-event-1.17-R0.1-20210722.014800-23-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-event/1.17-R0.1-SNAPSHOT/bungeecord-event-1.17-R0.1-20210722.014800-23-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.md-5:bungeecord-protocol:1.17-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-protocol/1.17-R0.1-SNAPSHOT/bungeecord-protocol-1.17-R0.1-20210722.014815-23.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-protocol/1.17-R0.1-SNAPSHOT/bungeecord-protocol-1.17-R0.1-20210722.014815-23-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-protocol/1.17-R0.1-SNAPSHOT/bungeecord-protocol-1.17-R0.1-20210722.014815-23-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.sf.trove4j:core:3.1.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/sf/trove4j/core/3.1.0/core-3.1.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/sf/trove4j/core/3.1.0/core-3.1.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/sf/trove4j/core/3.1.0/core-3.1.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.hamcrest:hamcrest-core:1.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.yaml:snakeyaml:1.28">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.28/snakeyaml-1.28.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.28/snakeyaml-1.28-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.28/snakeyaml-1.28-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: se.llbit:jo-nbt:1.3.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/se/llbit/jo-nbt/1.3.0/jo-nbt-1.3.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/se/llbit/jo-nbt/1.3.0/jo-nbt-1.3.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/se/llbit/jo-nbt/1.3.0/jo-nbt-1.3.0-sources.jar!/" />
</SOURCES>
</library>
</component>

19
.idea/misc.xml Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<list size="2">
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
<item index="1" class="java.lang.String" itemvalue="net.md_5.bungee.event.EventHandler" />
</list>
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="16" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/T2CodeLib.iml" filepath="$PROJECT_DIR$/T2CodeLib.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

52
T2CodeLib.iml Normal file
View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="McpModuleSettings">
<option name="srgType" value="SRG" />
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.MilkBowl:VaultAPI:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.9.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-api:1.17-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-config:1.17-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-event:1.17-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-protocol:1.17-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:brigadier:1.0.16-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-codec:4.1.65.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:core:3.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: se.llbit:jo-nbt:1.3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-transport-native-unix-common:4.1.65.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-common:4.1.65.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-buffer:4.1.65.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-transport:4.1.65.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-resolver:4.1.65.Final" level="project" />
<orderEntry type="library" name="1_13_R2" level="project" />
</component>
</module>

114
pom.xml Normal file
View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>T2CodeLib</name>
<description>Libarie from T2Code Plugins</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>T2Code.net</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.9.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,42 @@
package net.t2code.lib.Bungee;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import net.t2code.lib.Bungee.system.BLoad;
import net.t2code.lib.Util;
public final class BMain extends Plugin {
public static Plugin plugin;
public static String Version;
public static String Autor;
public static String Prefix = Util.Prefix;
public static Integer SpigotID = Util.SpigotID;
public static Integer BstatsID = Util.BstatsID;
public static String Spigot = Util.Spigot;
public static String Discord = Util.Discord;
@Override
public void onEnable() {
// Plugin startup logic
plugin = this;
Version = plugin.getDescription().getVersion();
Autor = plugin.getDescription().getAuthor();
BLoad.onLoad(plugin, Prefix, Autor, Version, Spigot, Discord, SpigotID,BstatsID);
}
@Override
public void onDisable() {
// Plugin shutdown logic
Bsend.console(Prefix + "§4============================= " + Prefix + " §4=============================");
Bsend.console(Prefix + " §2Autor: §6" + String.valueOf(Autor).replace("[", "").replace("]", ""));
Bsend.console(Prefix + " §2Version: §6" + Version);
Bsend.console(Prefix + " §2Spigot: §6" + Spigot);
Bsend.console(Prefix + " §2Discord: §6" + Discord);
Bsend.console(Prefix + " §4Plugin successfully disabled.");
Bsend.console(Prefix + "§4============================= " + Prefix + " §4=============================");
}
}

View File

@ -0,0 +1,66 @@
package net.t2code.lib.Bungee.Lib.commands;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public class BTab {
public static Iterable<String> tab(CommandSender sender, String[] args, String perm,Boolean onlinePlayer){
List<String> matches = new ArrayList<>();
Iterator var6 = ProxyServer.getInstance().getPlayers().iterator();
while (var6.hasNext()) {
ProxiedPlayer player1 = (ProxiedPlayer) var6.next();
if (passend(player1.getName(), args[0]) && hasPermission(sender, perm)){
matches.add(player1.getName());
}
}
return matches;
}
public static Iterable<String> tab(CommandSender sender, String[] args, HashMap<String, String> permMap) {
List<String> matches = new ArrayList<>();
for (String command : permMap.keySet()) {
if (hasPermission(sender, permMap.get(command)) && passend(command, args[0])) {
matches.add(command);
}
}
return matches;
}
public static Iterable<String> tab(CommandSender sender, String[] args, String perm, String command) {
List<String> matches = new ArrayList<>();
if (hasPermission(sender, perm) && passend(command, args[0])) {
matches.add(command);
}
return matches;
}
public static Boolean passend(String command, String arg) {
for (int i = 0; i < arg.toUpperCase().length(); i++) {
if (arg.toUpperCase().length() >= command.toUpperCase().length()) {
return false;
} else {
if (arg.toUpperCase().charAt(i) != command.toUpperCase().charAt(i)) {
return false;
}
}
}
return true;
}
public static boolean hasPermission(CommandSender sender, String permission) {
String[] Permissions = permission.split(";");
for (String perm : Permissions) {
if (sender.hasPermission(perm)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,13 @@
package net.t2code.lib.Bungee.Lib.commands;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class Bcmd {
public static void Console(String cmd){
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), cmd);
}
public static void Player(ProxiedPlayer player, String cmd){
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, cmd);
}
}

View File

@ -0,0 +1,38 @@
package net.t2code.lib.Bungee.Lib.messages;
import java.util.List;
public class BT2CodeTemplate {
public static Long onLoadHeader(String prefix, String autor, String version, String spigot, String discord) {
Long long_ = Long.valueOf(System.currentTimeMillis());
Bsend.console(prefix + "§4============================= " + prefix + " §4=============================");
Bsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
Bsend.console(prefix + " §2Version: §6" + version);
Bsend.console(prefix + " §2Spigot: §6" + spigot);
Bsend.console(prefix + " §2Discord: §6" + discord);
Bsend.console(prefix + " §8-------------------------------");
return long_;
}
public static void onLoadSeparateStroke(String prefix) {
Bsend.console(prefix + " §8-------------------------------");
}
public static void onLoadFooter(String prefix, Long long_) {
Bsend.console(prefix + " §8-------------------------------");
Bsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
Bsend.console(prefix + "§4============================= " + prefix + " §4=============================");
}
public static void onDisable(String prefix, String autor, String version, String spigot, String discord) {
Bsend.console(prefix + "§4============================= " + prefix + " §4=============================");
Bsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
Bsend.console(prefix + " §2Version: §6" + version);
Bsend.console(prefix + " §2Spigot: §6" + spigot);
Bsend.console(prefix + " §2Discord: §6" + discord);
Bsend.console(prefix + " §4Plugin successfully disabled.");
Bsend.console(prefix + "§4============================= " + prefix + " §4=============================");
}
}

View File

@ -0,0 +1,61 @@
package net.t2code.lib.Bungee.Lib.messages;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.Title;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin;
import java.util.logging.Level;
public class Bsend {
public static void console(String msg) {
ProxyServer.getInstance().getConsole().sendMessage(msg);
}
public static void player(ProxiedPlayer player, String msg) {
player.sendMessage(msg);
}
public static void title(ProxiedPlayer player, Title msg) {
player.sendTitle(msg);
}
public static void sender(CommandSender sender, String msg) {
sender.sendMessage(msg);
}
public static void debug(Plugin plugin, String msg) {
debug(plugin, msg, null);
}
public static void debug(Plugin plugin, String msg, Integer stage) {
// if (!new File(Main.getPath(), "config.yml").exists()) return;
if (stage == null) {
//todo if (plugin.getConfig().getBoolean("Plugin.Debug")){
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
// }
return;
}
// todo if (plugin.getConfig().getInt("Plugin.Debug") >= stage) {
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
// }
}
public static void debugmsg(Plugin plugin, String msg) {
ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG-MSG: §6" + msg);
}
public static void info(Plugin plugin, String msg) {
plugin.getLogger().log(Level.INFO, msg);
}
public static void warning(Plugin plugin, String msg) {
plugin.getLogger().log(Level.WARNING, msg);
}
public static void error(Plugin plugin, String msg) {
plugin.getLogger().log(Level.SEVERE, msg);
}
}

View File

@ -0,0 +1,36 @@
package net.t2code.lib.Bungee.Lib.replace;
import java.util.ArrayList;
import java.util.List;
public class BReplace {
public static String replace(String prefix, String Text) {
return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä");
}
public static List<String> replace(String prefix, List<String> Text) {
List<String> output = new ArrayList<>();
for (String input : Text) {
output.add(input.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä"));
}
return output;
}
public static List replacePrice(String prefix,List<String> Text, String price) {
List rp = new ArrayList();
for (String s : Text) {
rp.add(s.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price)));
}
return rp;
}
}

View File

@ -0,0 +1,104 @@
package net.t2code.lib.Bungee.Lib.update;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import net.t2code.lib.Spigot.Lib.update.UpdateObject;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
public class BUpdateAPI {
public static HashMap<String, UpdateObject> bungeePluginVersionen = new HashMap<String, UpdateObject>();
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String foundVersion, String update_version) {
Bsend.console("§4=========== " + Prefix + " §4===========");
Bsend.console("§6A new version was found!");
Bsend.console("§6Your version: §c" + foundVersion + " §7- §6Current version: §a" + update_version);
Bsend.console("§6You can download it here: §e" + Spigot);
Bsend.console("§6You can find more information on Discord: §e" + Discord);
Bsend.console("§4=========== " + Prefix + " §4===========");
}
private static Boolean noUpdate = true;
private static String pluginVersion;
public static void onUpdateCheckTimer(Plugin plugin, String Prefix, String Spigot, String Discord, Integer SpigotID) {
ProxyServer.getInstance().getScheduler().schedule(plugin, new Runnable() {
public void run() {
(new BUpdateAPI(plugin, SpigotID)).getVersion((update_version) -> {
pluginVersion = plugin.getDescription().getVersion();
UpdateObject update = new UpdateObject(
plugin.getDescription().getName(),
pluginVersion,
update_version
);
bungeePluginVersionen.put(plugin.getDescription().getName(), update);
if (!pluginVersion.replace("_Bungee", "").equalsIgnoreCase(update_version)) {
sendUpdateMsg(Prefix, Spigot, Discord, pluginVersion, update_version);
noUpdate = true;
} else {
if (noUpdate) {
Bsend.console(Prefix + " §2No update found.");
noUpdate = false;
}
}
},Prefix, pluginVersion);
}
}, 0, 20 * 60 * 60L, TimeUnit.SECONDS);
}
private Plugin plugin;
private int resourceId;
public BUpdateAPI(Plugin plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(Consumer<String> consumer, String Prefix, String pluginVersion) {
ProxyServer.getInstance().getScheduler().runAsync(this.plugin, () -> {
try {
InputStream inputStream = (new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId)).openStream();
try {
Scanner scanner = new Scanner(inputStream);
try {
if (scanner.hasNext()) {
consumer.accept(scanner.next());
}
} catch (Throwable var8) {
try {
scanner.close();
} catch (Throwable var7) {
var8.addSuppressed(var7);
}
throw var8;
}
scanner.close();
} catch (Throwable var9) {
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable var6) {
var9.addSuppressed(var6);
}
}
throw var9;
}
if (inputStream != null) {
inputStream.close();
}
} catch (IOException var10) {
UpdateObject update = new UpdateObject(
plugin.getDescription().getName(),
pluginVersion,
"§4No public version found!"
);
bungeePluginVersionen.put(plugin.getDescription().getName(), update);
this.plugin.getLogger().severe(Prefix + "§4 Cannot look for updates: " + var10.getMessage());
}
});
}
}

View File

@ -0,0 +1,12 @@
package net.t2code.lib.Bungee.Lib.update;
public class BUpdateObject {
public String pluginName;
public String pluginVersion;
public String publicVersion;
public BUpdateObject(String pluginName, String pluginVersion, String publicVersion){
this.pluginName = pluginName;
this.pluginVersion = pluginVersion;
this.publicVersion = publicVersion;
}
}

View File

@ -0,0 +1,26 @@
package net.t2code.lib.Bungee.system;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import net.t2code.lib.Bungee.Lib.update.BUpdateAPI;
public class BLoad {
public static void onLoad(Plugin plugin, String prefix, String autor, String version, String spigot, String discord, Integer spigotID,Integer bstatsID){
Long long_ = Long.valueOf(System.currentTimeMillis());
Bsend.console(prefix + "§4============================= " + prefix + " §4=============================");
Bsend.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
Bsend.console(prefix + " §2Version: §6" + version);
Bsend.console(prefix + " §2Spigot: §6" + spigot);
Bsend.console(prefix + " §2Discord: §6" + discord);
BMetrics.Bstats(plugin, bstatsID);
BUpdateAPI.onUpdateCheckTimer(plugin, prefix, spigot, discord, spigotID);
Bsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
Bsend.console(prefix + "§4============================= " + prefix + " §4=============================");
}
}

View File

@ -0,0 +1,851 @@
package net.t2code.lib.Bungee.system;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream;
public class BMetrics {
public static void Bstats(Plugin plugin, int bstatsID) {
int pluginId = bstatsID; // <-- Replace with the id of your plugin!
BMetrics metrics = new BMetrics(plugin, pluginId);
}
private final Plugin plugin;
private final MetricsBase metricsBase;
private boolean enabled;
private String serverUUID;
private boolean logErrors = false;
private boolean logSentData;
private boolean logResponseStatusText;
/**
* Creates a new Metrics instance.
*
* @param plugin Your plugin instance.
* @param serviceId The id of the service. It can be found at <a
* href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
*/
public BMetrics(Plugin plugin, int serviceId) {
this.plugin = plugin;
try {
loadConfig();
} catch (IOException e) {
// Failed to load configuration
plugin.getLogger().log(Level.WARNING, "Failed to load bStats config!", e);
metricsBase = null;
return;
}
metricsBase =
new MetricsBase(
"bungeecord",
serverUUID,
serviceId,
enabled,
this::appendPlatformData,
this::appendServiceData,
null,
() -> true,
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
(message) -> this.plugin.getLogger().log(Level.INFO, message),
logErrors,
logSentData,
logResponseStatusText);
}
/** Loads the bStats configuration. */
private void loadConfig() throws IOException {
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
bStatsFolder.mkdirs();
File configFile = new File(bStatsFolder, "config.yml");
if (!configFile.exists()) {
writeFile(
configFile,
"# bStats (https://bStats.org) collects some basic information for plugin authors, like how",
"# many people use their plugin and their total player count. It's recommended to keep bStats",
"# enabled, but if you're not comfortable with this, you can turn this setting off. There is no",
"# performance penalty associated with having metrics enabled, and data sent to bStats is fully",
"# anonymous.",
"enabled: true",
"serverUuid: \"" + UUID.randomUUID() + "\"",
"logFailedRequests: false",
"logSentData: false",
"logResponseStatusText: false");
}
Configuration configuration =
ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
// Load configuration
enabled = configuration.getBoolean("enabled", true);
serverUUID = configuration.getString("serverUuid");
logErrors = configuration.getBoolean("logFailedRequests", false);
logSentData = configuration.getBoolean("logSentData", false);
logResponseStatusText = configuration.getBoolean("logResponseStatusText", false);
}
private void writeFile(File file, String... lines) throws IOException {
try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file))) {
for (String line : lines) {
bufferedWriter.write(line);
bufferedWriter.newLine();
}
}
}
/**
* Adds a custom chart.
*
* @param chart The chart to add.
*/
public void addCustomChart(CustomChart chart) {
metricsBase.addCustomChart(chart);
}
private void appendPlatformData(JsonObjectBuilder builder) {
builder.appendField("playerAmount", plugin.getProxy().getOnlineCount());
builder.appendField("managedServers", plugin.getProxy().getServers().size());
builder.appendField("onlineMode", plugin.getProxy().getConfig().isOnlineMode() ? 1 : 0);
builder.appendField("bungeecordVersion", plugin.getProxy().getVersion());
builder.appendField("javaVersion", System.getProperty("java.version"));
builder.appendField("osName", System.getProperty("os.name"));
builder.appendField("osArch", System.getProperty("os.arch"));
builder.appendField("osVersion", System.getProperty("os.version"));
builder.appendField("coreCount", Runtime.getRuntime().availableProcessors());
}
private void appendServiceData(JsonObjectBuilder builder) {
builder.appendField("pluginVersion", plugin.getDescription().getVersion());
}
public static class MetricsBase {
/** The version of the Metrics class. */
public static final String METRICS_VERSION = "2.2.1";
private static final ScheduledExecutorService scheduler =
Executors.newScheduledThreadPool(1, task -> new Thread(task, "bStats-Metrics"));
private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s";
private final String platform;
private final String serverUuid;
private final int serviceId;
private final Consumer<JsonObjectBuilder> appendPlatformDataConsumer;
private final Consumer<JsonObjectBuilder> appendServiceDataConsumer;
private final Consumer<Runnable> submitTaskConsumer;
private final Supplier<Boolean> checkServiceEnabledSupplier;
private final BiConsumer<String, Throwable> errorLogger;
private final Consumer<String> infoLogger;
private final boolean logErrors;
private final boolean logSentData;
private final boolean logResponseStatusText;
private final Set<CustomChart> customCharts = new HashSet<>();
private final boolean enabled;
/**
* Creates a new MetricsBase class instance.
*
* @param platform The platform of the service.
* @param serviceId The id of the service.
* @param serverUuid The server uuid.
* @param enabled Whether or not data sending is enabled.
* @param appendPlatformDataConsumer A consumer that receives a {@code JsonObjectBuilder} and
* appends all platform-specific data.
* @param appendServiceDataConsumer A consumer that receives a {@code JsonObjectBuilder} and
* appends all service-specific data.
* @param submitTaskConsumer A consumer that takes a runnable with the submit task. This can be
* used to delegate the data collection to a another thread to prevent errors caused by
* concurrency. Can be {@code null}.
* @param checkServiceEnabledSupplier A supplier to check if the service is still enabled.
* @param errorLogger A consumer that accepts log message and an error.
* @param infoLogger A consumer that accepts info log messages.
* @param logErrors Whether or not errors should be logged.
* @param logSentData Whether or not the sent data should be logged.
* @param logResponseStatusText Whether or not the response status text should be logged.
*/
public MetricsBase(
String platform,
String serverUuid,
int serviceId,
boolean enabled,
Consumer<JsonObjectBuilder> appendPlatformDataConsumer,
Consumer<JsonObjectBuilder> appendServiceDataConsumer,
Consumer<Runnable> submitTaskConsumer,
Supplier<Boolean> checkServiceEnabledSupplier,
BiConsumer<String, Throwable> errorLogger,
Consumer<String> infoLogger,
boolean logErrors,
boolean logSentData,
boolean logResponseStatusText) {
this.platform = platform;
this.serverUuid = serverUuid;
this.serviceId = serviceId;
this.enabled = enabled;
this.appendPlatformDataConsumer = appendPlatformDataConsumer;
this.appendServiceDataConsumer = appendServiceDataConsumer;
this.submitTaskConsumer = submitTaskConsumer;
this.checkServiceEnabledSupplier = checkServiceEnabledSupplier;
this.errorLogger = errorLogger;
this.infoLogger = infoLogger;
this.logErrors = logErrors;
this.logSentData = logSentData;
this.logResponseStatusText = logResponseStatusText;
checkRelocation();
if (enabled) {
startSubmitting();
}
}
public void addCustomChart(CustomChart chart) {
this.customCharts.add(chart);
}
private void startSubmitting() {
final Runnable submitTask =
() -> {
if (!enabled || !checkServiceEnabledSupplier.get()) {
// Submitting data or service is disabled
scheduler.shutdown();
return;
}
if (submitTaskConsumer != null) {
submitTaskConsumer.accept(this::submitData);
} else {
this.submitData();
}
};
// Many servers tend to restart at a fixed time at xx:00 which causes an uneven distribution
// of requests on the
// bStats backend. To circumvent this problem, we introduce some randomness into the initial
// and second delay.
// WARNING: You must not modify and part of this Metrics class, including the submit delay or
// frequency!
// WARNING: Modifying this code will get your plugin banned on bStats. Just don't do it!
long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3));
long secondDelay = (long) (1000 * 60 * (Math.random() * 30));
scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS);
scheduler.scheduleAtFixedRate(
submitTask, initialDelay + secondDelay, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
}
private void submitData() {
final JsonObjectBuilder baseJsonBuilder = new JsonObjectBuilder();
appendPlatformDataConsumer.accept(baseJsonBuilder);
final JsonObjectBuilder serviceJsonBuilder = new JsonObjectBuilder();
appendServiceDataConsumer.accept(serviceJsonBuilder);
JsonObjectBuilder.JsonObject[] chartData =
customCharts.stream()
.map(customChart -> customChart.getRequestJsonObject(errorLogger, logErrors))
.filter(Objects::nonNull)
.toArray(JsonObjectBuilder.JsonObject[]::new);
serviceJsonBuilder.appendField("id", serviceId);
serviceJsonBuilder.appendField("customCharts", chartData);
baseJsonBuilder.appendField("service", serviceJsonBuilder.build());
baseJsonBuilder.appendField("serverUUID", serverUuid);
baseJsonBuilder.appendField("metricsVersion", METRICS_VERSION);
JsonObjectBuilder.JsonObject data = baseJsonBuilder.build();
scheduler.execute(
() -> {
try {
// Send the data
sendData(data);
} catch (Exception e) {
// Something went wrong! :(
if (logErrors) {
errorLogger.accept("Could not submit bStats metrics data", e);
}
}
});
}
private void sendData(JsonObjectBuilder.JsonObject data) throws Exception {
if (logSentData) {
infoLogger.accept("Sent bStats metrics data: " + data.toString());
}
String url = String.format(REPORT_URL, platform);
HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
// Compress the data to save bandwidth
byte[] compressedData = compress(data.toString());
connection.setRequestMethod("POST");
connection.addRequestProperty("Accept", "application/json");
connection.addRequestProperty("Connection", "close");
connection.addRequestProperty("Content-Encoding", "gzip");
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("User-Agent", "Metrics-Service/1");
connection.setDoOutput(true);
try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
outputStream.write(compressedData);
}
StringBuilder builder = new StringBuilder();
try (BufferedReader bufferedReader =
new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
builder.append(line);
}
}
if (logResponseStatusText) {
infoLogger.accept("Sent data to bStats and received response: " + builder);
}
}
/** Checks that the class was properly relocated. */
private void checkRelocation() {
// You can use the property to disable the check in your test environment
if (System.getProperty("bstats.relocatecheck") == null
|| !System.getProperty("bstats.relocatecheck").equals("false")) {
// Maven's Relocate is clever and changes strings, too. So we have to use this little
// "trick" ... :D
final String defaultPackage =
new String(new byte[] {'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'});
final String examplePackage =
new String(new byte[] {'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
// We want to make sure no one just copy & pastes the example and uses the wrong package
// names
if (MetricsBase.class.getPackage().getName().startsWith(defaultPackage)
|| MetricsBase.class.getPackage().getName().startsWith(examplePackage)) {
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
}
}
}
/**
* Gzips the given string.
*
* @param str The string to gzip.
* @return The gzipped string.
*/
private static byte[] compress(final String str) throws IOException {
if (str == null) {
return null;
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
gzip.write(str.getBytes(StandardCharsets.UTF_8));
}
return outputStream.toByteArray();
}
}
public static class AdvancedBarChart extends CustomChart {
private final Callable<Map<String, int[]>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, int[]> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, int[]> entry : map.entrySet()) {
if (entry.getValue().length == 0) {
// Skip this invalid
continue;
}
allSkipped = false;
valuesBuilder.appendField(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
public static class SimpleBarChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
for (Map.Entry<String, Integer> entry : map.entrySet()) {
valuesBuilder.appendField(entry.getKey(), new int[] {entry.getValue()});
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
public static class MultiLineChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
// Skip this invalid
continue;
}
allSkipped = false;
valuesBuilder.appendField(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
public static class AdvancedPie extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
// Skip this invalid
continue;
}
allSkipped = false;
valuesBuilder.appendField(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
public abstract static class CustomChart {
private final String chartId;
protected CustomChart(String chartId) {
if (chartId == null) {
throw new IllegalArgumentException("chartId must not be null");
}
this.chartId = chartId;
}
public JsonObjectBuilder.JsonObject getRequestJsonObject(
BiConsumer<String, Throwable> errorLogger, boolean logErrors) {
JsonObjectBuilder builder = new JsonObjectBuilder();
builder.appendField("chartId", chartId);
try {
JsonObjectBuilder.JsonObject data = getChartData();
if (data == null) {
// If the data is null we don't send the chart.
return null;
}
builder.appendField("data", data);
} catch (Throwable t) {
if (logErrors) {
errorLogger.accept("Failed to get data for custom chart with id " + chartId, t);
}
return null;
}
return builder.build();
}
protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception;
}
public static class SingleLineChart extends CustomChart {
private final Callable<Integer> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SingleLineChart(String chartId, Callable<Integer> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
int value = callable.call();
if (value == 0) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("value", value).build();
}
}
public static class SimplePie extends CustomChart {
private final Callable<String> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimplePie(String chartId, Callable<String> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
String value = callable.call();
if (value == null || value.isEmpty()) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("value", value).build();
}
}
public static class DrilldownPie extends CustomChart {
private final Callable<Map<String, Map<String, Integer>>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
super(chartId);
this.callable = callable;
}
@Override
public JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Map<String, Integer>> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean reallyAllSkipped = true;
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
JsonObjectBuilder valueBuilder = new JsonObjectBuilder();
boolean allSkipped = true;
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
valueBuilder.appendField(valueEntry.getKey(), valueEntry.getValue());
allSkipped = false;
}
if (!allSkipped) {
reallyAllSkipped = false;
valuesBuilder.appendField(entryValues.getKey(), valueBuilder.build());
}
}
if (reallyAllSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
/**
* An extremely simple JSON builder.
*
* <p>While this class is neither feature-rich nor the most performant one, it's sufficient enough
* for its use-case.
*/
public static class JsonObjectBuilder {
private StringBuilder builder = new StringBuilder();
private boolean hasAtLeastOneField = false;
public JsonObjectBuilder() {
builder.append("{");
}
/**
* Appends a null field to the JSON.
*
* @param key The key of the field.
* @return A reference to this object.
*/
public JsonObjectBuilder appendNull(String key) {
appendFieldUnescaped(key, "null");
return this;
}
/**
* Appends a string field to the JSON.
*
* @param key The key of the field.
* @param value The value of the field.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, String value) {
if (value == null) {
throw new IllegalArgumentException("JSON value must not be null");
}
appendFieldUnescaped(key, "\"" + escape(value) + "\"");
return this;
}
/**
* Appends an integer field to the JSON.
*
* @param key The key of the field.
* @param value The value of the field.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, int value) {
appendFieldUnescaped(key, String.valueOf(value));
return this;
}
/**
* Appends an object to the JSON.
*
* @param key The key of the field.
* @param object The object.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, JsonObject object) {
if (object == null) {
throw new IllegalArgumentException("JSON object must not be null");
}
appendFieldUnescaped(key, object.toString());
return this;
}
/**
* Appends a string array to the JSON.
*
* @param key The key of the field.
* @param values The string array.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, String[] values) {
if (values == null) {
throw new IllegalArgumentException("JSON values must not be null");
}
String escapedValues =
Arrays.stream(values)
.map(value -> "\"" + escape(value) + "\"")
.collect(Collectors.joining(","));
appendFieldUnescaped(key, "[" + escapedValues + "]");
return this;
}
/**
* Appends an integer array to the JSON.
*
* @param key The key of the field.
* @param values The integer array.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, int[] values) {
if (values == null) {
throw new IllegalArgumentException("JSON values must not be null");
}
String escapedValues =
Arrays.stream(values).mapToObj(String::valueOf).collect(Collectors.joining(","));
appendFieldUnescaped(key, "[" + escapedValues + "]");
return this;
}
/**
* Appends an object array to the JSON.
*
* @param key The key of the field.
* @param values The integer array.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, JsonObject[] values) {
if (values == null) {
throw new IllegalArgumentException("JSON values must not be null");
}
String escapedValues =
Arrays.stream(values).map(JsonObject::toString).collect(Collectors.joining(","));
appendFieldUnescaped(key, "[" + escapedValues + "]");
return this;
}
/**
* Appends a field to the object.
*
* @param key The key of the field.
* @param escapedValue The escaped value of the field.
*/
private void appendFieldUnescaped(String key, String escapedValue) {
if (builder == null) {
throw new IllegalStateException("JSON has already been built");
}
if (key == null) {
throw new IllegalArgumentException("JSON key must not be null");
}
if (hasAtLeastOneField) {
builder.append(",");
}
builder.append("\"").append(escape(key)).append("\":").append(escapedValue);
hasAtLeastOneField = true;
}
/**
* Builds the JSON string and invalidates this builder.
*
* @return The built JSON string.
*/
public JsonObject build() {
if (builder == null) {
throw new IllegalStateException("JSON has already been built");
}
JsonObject object = new JsonObject(builder.append("}").toString());
builder = null;
return object;
}
/**
* Escapes the given string like stated in https://www.ietf.org/rfc/rfc4627.txt.
*
* <p>This method escapes only the necessary characters '"', '\'. and '\u0000' - '\u001F'.
* Compact escapes are not used (e.g., '\n' is escaped as "\u000a" and not as "\n").
*
* @param value The value to escape.
* @return The escaped value.
*/
private static String escape(String value) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (c == '"') {
builder.append("\\\"");
} else if (c == '\\') {
builder.append("\\\\");
} else if (c <= '\u000F') {
builder.append("\\u000").append(Integer.toHexString(c));
} else if (c <= '\u001F') {
builder.append("\\u00").append(Integer.toHexString(c));
} else {
builder.append(c);
}
}
return builder.toString();
}
/**
* A super simple representation of a JSON object.
*
* <p>This class only exists to make methods of the {@link JsonObjectBuilder} type-safe and not
* allow a raw string inputs for methods like {@link JsonObjectBuilder#appendField(String,
* JsonObject)}.
*/
public static class JsonObject {
private final String value;
private JsonObject(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}
}
}

View File

@ -0,0 +1,14 @@
package net.t2code.lib.Spigot.Lib.commands;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class Cmd {
public static void console(String cmd) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
}
public static void player(Player player, String cmd) {
player.chat("/" + cmd);
}
}

View File

@ -0,0 +1,104 @@
package net.t2code.lib.Spigot.Lib.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public class Tab {
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, String perm, Boolean onlinePlayer) {
if (args.length == arg + 1) {
Iterator var6 = Bukkit.getOnlinePlayers().iterator();
while (var6.hasNext()) {
Player player1 = (Player) var6.next();
if (passend(player1.getName(), args[arg]) && hasPermission(sender, perm)) {
matches.add(player1.getName());
}
}
}
}
public static void tab(List<String> matches, CommandSender sender, int argEquals, String equalsValue, int arg, String[] args, String perm, Boolean onlinePlayer) {
if (args.length == arg + 1) {
if (args[argEquals].toLowerCase().equals(equalsValue)) {
Iterator var6 = Bukkit.getOnlinePlayers().iterator();
while (var6.hasNext()) {
Player player1 = (Player) var6.next();
if (passend(player1.getName(), args[arg]) && hasPermission(sender, perm)) {
matches.add(player1.getName());
}
}
}
}
}
//public static void tab(List<String> matches,CommandSender sender, int arg, String[] args, HashMap<String, String> permMap) {
//
// for (String command : permMap.keySet()) {
// if (hasPermission(sender, permMap.get(command)) && passend(command, args[arg])) {
// matches.add(command);
// }
// }
//}
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, HashMap<String, String> permMap) {
if (args.length == arg + 1) {
for (String command : permMap.keySet()) {
if (hasPermission(sender, permMap.get(command)) && passend(command, args[arg])) {
matches.add(command);
}
}
}
}
public static void tab(List<String> matches, CommandSender sender, int argEquals, String equalsValue, int arg, String[] args, HashMap<String, String> permMap) {
if (args.length == arg + 1) {
if (args[argEquals].toLowerCase().equals(equalsValue)) {
for (String command : permMap.keySet()) {
if (hasPermission(sender, permMap.get(command)) && passend(command, args[arg])) {
matches.add(command);
}
}
}
}
}
public static List<String> tab(CommandSender sender, int arg, String[] args, String perm, String command) {
List<String> matches = new ArrayList<>();
if (hasPermission(sender, perm) && passend(command, args[arg])) {
matches.add(command);
}
return matches;
}
private static Boolean passend(String command, String arg) {
for (int i = 0; i < arg.toUpperCase().length(); i++) {
if (arg.toUpperCase().length() >= command.toUpperCase().length()) {
return false;
} else {
if (arg.toUpperCase().charAt(i) != command.toUpperCase().charAt(i)) {
return false;
}
}
}
return true;
}
public static boolean hasPermission(CommandSender sender, String permission) {
String[] Permissions = permission.split(";");
for (String perm : Permissions) {
if (sender.hasPermission(perm)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,15 @@
package net.t2code.lib.Spigot.Lib.items;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import org.bukkit.Material;
public class ItemVersion {
public static Material Head;
public static void scan(){
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
Head = Material.valueOf("SKULL");
} else Head = Material.valueOf("PLAYER_HEAD");
}
}

View File

@ -0,0 +1,89 @@
package net.t2code.lib.Spigot.Lib.messages;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import net.t2code.lib.Spigot.system.Main;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.List;
import java.util.logging.Level;
public class T2CodeTemplate {
public static Long onLoadHeader(String prefix, List autor, String version, String spigot, String discord) {
Long long_ = Long.valueOf(System.currentTimeMillis());
// send.console(prefix +" §4===================== " + prefix + " §4=====================");
send.console(prefix + " §4 _______ §7___ §4_____ ");
send.console(prefix + " §4 |__ __|§7__ \\ §4/ ____|");
send.console(prefix + " §4 | | §7 ) §4| | ");
send.console(prefix + " §4 | | §7 / /§4| | ");
send.console(prefix + " §4 | | §7/ /_§4| |____ ");
send.console(prefix + " §4 |_| §7|____|§4\\_____|");
send.console(prefix + " §4 §e------------------");
send.console(prefix + " §4 §e| §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
send.console(prefix + " §4 §e| §2Version: §6" + version);
send.console(prefix + " §4 §e| §2Spigot: §6" + spigot);
send.console(prefix + " §4 §e| §2Discord: §6" + discord);
send.console(prefix + " §4 §e-------------------");
//onLoadSeparateStroke(prefix);
return long_;
}
public static Long onLoadHeader(String prefix) {
Long long_ = Long.valueOf(System.currentTimeMillis());
send.console(prefix + "§4===================== " + prefix + " §4=====================");
return long_;
}
public static void onLoadSeparateStroke(String prefix) {
send.console(prefix + " §8-------------------------------");
}
public static void onLoadFooter(String prefix, Long long_, String version) {
onLoadSeparateStroke(prefix);
send.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
// send.console(prefix +" §4===================== " + prefix + "§4=====================");
}
public static void onLoadFooter(String prefix, Long long_) {
onLoadSeparateStroke(prefix);
send.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
// send.console(prefix +" §4===================== " + prefix + "§4=====================");
}
public static void onDisable(String prefix, List autor, String version, String spigot, String discord) {
//send.console(prefix + "§4===================== " + prefix + " §7- §6" + version + " §4=====================");
//send.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
//send.console(prefix + " §2Version: §6" + version);
//send.console(prefix + " §2Spigot: §6" + spigot);
//send.console(prefix + " §2Discord: §6" + discord);
//send.console(prefix + " §4Plugin successfully disabled.");
//send.console(prefix + "§4===================== " + prefix + " §7- §6" + version + " §4=====================");
send.console(prefix + " §2Version: §6" + version);
send.console(prefix + " §4Plugin successfully disabled.");
}
public static void sendInfo(CommandSender sender, String prefix, String spigot, String discord, List autor, String pluginVersion, String publicVersion) {
send.sender(sender, prefix + "§4======= " + prefix + " §4=======");
send.sender(sender, prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
if (publicVersion.equalsIgnoreCase(pluginVersion)) {
send.sender(sender, prefix + " §2Version: §6" + pluginVersion);
} else {
if (sender instanceof Player) {
Player player = (Player) sender;
UpdateAPI.sendUpdateMsg(prefix, spigot, discord, pluginVersion, publicVersion, player);
}
}
send.sender(sender, prefix + " §2Spigot: §6" + spigot);
send.sender(sender, prefix + " §2Discord: §6" + discord);
send.sender(sender, prefix + "§4======= " + prefix + " §4=======");
}
}

View File

@ -0,0 +1,45 @@
package net.t2code.lib.Spigot.Lib.messages;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
public class TextBuilder {
private final String text;
private String hover;
private String click;
private ClickEvent.Action action;
public TextBuilder(String text) {
this.text = text;
}
public TextBuilder addHover(String hover) {
this.hover = hover;
return this;
}
public TextBuilder addClickEvent(ClickEvent.Action clickEventAction, String value) {
this.action = clickEventAction;
this.click = value;
return this;
}
public TextComponent build() {
TextComponent textComponent = new TextComponent();
textComponent.setText(this.text);
if (this.hover != null) {
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(this.hover).create()));
}
if (this.click != null && (this.action != null)) {
textComponent.setClickEvent(new ClickEvent(action, this.click));
}
return textComponent;
}
public enum ClickEventType {
OPEN_URL, OPEN_FILE, RUN_COMMAND, SUGGEST_COMMAND, CHANGE_PAGE, COPY_TO_CLIPBOARD
}
}

View File

@ -0,0 +1,64 @@
package net.t2code.lib.Spigot.Lib.messages;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.logging.Level;
public class send {
/**
* Spigot
*/
public static void console(String msg) {
Bukkit.getConsoleSender().sendMessage(msg);
}
public static void player(Player player, String msg) {
player.sendMessage(msg);
}
public static void title(Player player, String msg, String msg2) {
player.sendTitle(msg, msg2);
}
public static void title(Player player, String msg, String msg2, int i, int i1, int i2) {
player.sendTitle(msg, msg2, i, i1, i2);
}
public static void sender(CommandSender sender, String msg) {
sender.sendMessage(msg);
}
public static void debug(Plugin plugin, String msg) {
debug(plugin, msg, null);
}
public static void debug(Plugin plugin, String msg, Integer stage) {
// if (!new File(Main.getPath(), "config.yml").exists()) return;
if (stage == null) {
if (plugin.getConfig().getBoolean("Plugin.Debug")) Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
return;
}
if (plugin.getConfig().getInt("Plugin.Debug") >= stage) Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
}
public static void debugmsg(Plugin plugin, String msg) {
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG-MSG: §6" + msg);
}
public static void info(Plugin plugin, String msg) {
plugin.getLogger().log(Level.INFO, msg);
}
public static void warning(Plugin plugin, String msg) {
plugin.getLogger().log(Level.WARNING, msg);
}
public static void error(Plugin plugin, String msg) {
plugin.getLogger().log(Level.SEVERE, msg);
}
}

View File

@ -0,0 +1,34 @@
package net.t2code.lib.Spigot.Lib.minecraftVersion;
import org.bukkit.Bukkit;
public class MCVersion {
public static String isVersion;
public static String isBuckitVersion;
public static boolean minecraft1_8;
public static boolean minecraft1_9;
public static boolean minecraft1_10;
public static boolean minecraft1_11;
public static boolean minecraft1_12;
public static boolean minecraft1_13;
public static boolean minecraft1_14;
public static boolean minecraft1_15;
public static boolean minecraft1_16;
public static boolean minecraft1_17;
public static boolean minecraft1_18;
public static void onCheck(){
isVersion = Bukkit.getServer().getVersion();
isBuckitVersion = Bukkit.getServer().getBukkitVersion();
minecraft1_8 = Bukkit.getServer().getClass().getPackage().getName().contains("1_8");
minecraft1_9 = Bukkit.getServer().getClass().getPackage().getName().contains("1_9");
minecraft1_10 = Bukkit.getServer().getClass().getPackage().getName().contains("1_10");
minecraft1_11 = Bukkit.getServer().getClass().getPackage().getName().contains("1_11");
minecraft1_12 = Bukkit.getServer().getClass().getPackage().getName().contains("1_12");
minecraft1_13 = Bukkit.getServer().getClass().getPackage().getName().contains("1_13");
minecraft1_14 = Bukkit.getServer().getClass().getPackage().getName().contains("1_14");
minecraft1_15 = Bukkit.getServer().getClass().getPackage().getName().contains("1_15");
minecraft1_16 = Bukkit.getServer().getClass().getPackage().getName().contains("1_16");
minecraft1_17 = Bukkit.getServer().getClass().getPackage().getName().contains("1_17");
minecraft1_18 = Bukkit.getServer().getClass().getPackage().getName().contains("1_18");
}
}

View File

@ -0,0 +1,47 @@
package net.t2code.lib.Spigot.Lib.minecraftVersion;
import org.bukkit.Bukkit;
public class NMSVersion {
public static String isNMS;
public static boolean v1_8_R1;
public static boolean v1_8_R2;
public static boolean v1_8_R3;
public static boolean v1_9_R1;
public static boolean v1_9_R2;
public static boolean v1_10_R1;
public static boolean v1_11_R1;
public static boolean v1_12_R1;
public static boolean v1_13_R1;
public static boolean v1_13_R2;
public static boolean v1_14_R1;
public static boolean v1_15_R1;
public static boolean v1_16_R1;
public static boolean v1_16_R2;
public static boolean v1_16_R3;
public static boolean v1_17_R1;
public static boolean v1_18_R1;
public static boolean v1_18_R2;
public static void onCheck() {
isNMS = Bukkit.getServer().getClass().getPackage().getName();
v1_8_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_8_R1");
v1_8_R2 = Bukkit.getServer().getClass().getPackage().getName().contains("1_8_R2");
v1_8_R3 = Bukkit.getServer().getClass().getPackage().getName().contains("1_8_R3");
v1_9_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_9_R1");
v1_9_R2 = Bukkit.getServer().getClass().getPackage().getName().contains("1_9_R2");
v1_10_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_10_R1");
v1_11_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_11_R1");
v1_12_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_12_R1");
v1_13_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_13_R1");
v1_13_R2 = Bukkit.getServer().getClass().getPackage().getName().contains("1_13_R2");
v1_14_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_14_R1");
v1_15_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_15_R1");
v1_16_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_16_R1");
v1_16_R2 = Bukkit.getServer().getClass().getPackage().getName().contains("1_16_R2");
v1_16_R3 = Bukkit.getServer().getClass().getPackage().getName().contains("1_16_R3");
v1_17_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_17_R1");
v1_18_R1 = Bukkit.getServer().getClass().getPackage().getName().contains("1_18_R1");
v1_18_R2 = Bukkit.getServer().getClass().getPackage().getName().contains("1_18_R2");
}
}

View File

@ -0,0 +1,77 @@
package net.t2code.lib.Spigot.Lib.plugins;
import net.t2code.lib.Spigot.system.Main;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.util.logging.Level;
public class PluginCheck {
public static Boolean pluginCheck(String pluginName){
return Bukkit.getPluginManager().getPlugin(pluginName) != null;
}
public static Plugin pluginInfos(String pluginName){
return Bukkit.getPluginManager().getPlugin(pluginName);
}
public static Boolean papi(){
return Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
}
public static Boolean vault(){
return Bukkit.getPluginManager().getPlugin("Vault") != null;
}
public static Boolean plotSquared(){
return Bukkit.getPluginManager().getPlugin("PlotSquared") != null;
}
public static Boolean plugManGUI(){
return Bukkit.getPluginManager().getPlugin("PlugManGUI") != null;
}
public static Boolean cmi(){
return Bukkit.getPluginManager().getPlugin("CMI") != null;
}
/**
* T2Code Plugins
* @return
*/
public static Boolean cgui(){
return Bukkit.getPluginManager().getPlugin("CommandGUI") != null;
}
public static Boolean plotSquaredGUI(){
return Bukkit.getPluginManager().getPlugin("PlotSquaredGUI") != null;
}
public static Boolean wbs(){
return Bukkit.getPluginManager().getPlugin("WonderBagShop") != null;
}
public static Boolean opSec(){
return Bukkit.getPluginManager().getPlugin("OPSecurity") != null;
}
public static Boolean papiTest(){
return Bukkit.getPluginManager().getPlugin("PaPiTest") != null;
}
public static Boolean booster(){
return Bukkit.getPluginManager().getPlugin("Booster") != null;
}
public static Boolean antiMapCopy(){
return Bukkit.getPluginManager().getPlugin("AAntiMapCopy") != null;
}
public static Boolean loreEditor(){
return Bukkit.getPluginManager().getPlugin("LoreEditor") != null;
}
public static Boolean t2cAlias(){
return Bukkit.getPluginManager().getPlugin("T2C-Alias") != null;
}
public static Boolean t2cWarp(){
return Bukkit.getPluginManager().getPlugin("T2C-Warp") != null;
}
public static Boolean pluginNotFound(Plugin plugin, String prefix, String pl, Integer spigotID) {
if (Bukkit.getPluginManager().getPlugin(pl) == null) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true;
} else return false;
}
}

View File

@ -0,0 +1,38 @@
package net.t2code.lib.Spigot.Lib.register;
import org.bukkit.Bukkit;
import org.bukkit.permissions.Permission;
import org.bukkit.event.Listener;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Collections;
public class Register {
public static void listener(Listener listener, Plugin plugin) {
Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
}
public static void permission(String permission, Plugin plugin) {
if (plugin.getServer().getPluginManager().getPermission(permission) == null) {
plugin.getServer().getPluginManager().addPermission(new Permission(permission));
}
}
public static void permission(String permission, PermissionDefault setDefault, Plugin plugin) {
permission(permission, plugin);
plugin.getServer().getPluginManager().getPermission(permission).setDefault(setDefault);
}
public static void permission(String permission, String children, Boolean setBoolean, Plugin plugin) {
permission(permission, plugin);
plugin.getServer().getPluginManager().getPermission(permission).getChildren().put(children, setBoolean);
}
public static void permission(String permission, PermissionDefault setDefault, String children, Boolean setBoolean, Plugin plugin) {
permission(permission, plugin);
plugin.getServer().getPluginManager().getPermission(permission).setDefault(setDefault);
plugin.getServer().getPluginManager().getPermission(permission).getChildren().put(children, setBoolean);
}
}

View File

@ -0,0 +1,90 @@
package net.t2code.lib.Spigot.Lib.replace;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Replace {
public static String replace(String prefix, String Text) {
return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä");
}
public static String replace(String prefix,Player player, String Text) {
return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä"));
}
public static List<String> replace(String prefix, List<String> Text) {
List<String> output = new ArrayList<>();
for (String input : Text) {
output.add(input.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä"));
}
return output;
}
public static List<String> replace(String prefix,Player player, List<String> Text) {
List<String> output = new ArrayList();
if (player == null) {
return Arrays.asList("player is null");
}
if (Text == null) {
return Arrays.asList("Text is null");
}
for (String input : Text) {
output.add(PlaceholderAPI.setPlaceholders(player, input.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")));
}
return output;
}
public static List replacePrice(String prefix,List<String> Text, String price) {
List rp = new ArrayList();
for (String s : Text) {
rp.add(s.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price)));
}
return rp;
}
public static List replacePrice(String prefix,Player player, List<String> Text, String price) {
List rp = new ArrayList();
for (String s : Text) {
rp.add(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price))));
}
return rp;
}
public static String replacePrice(String prefix, String Text, String price) {
return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[price]", String.valueOf(price));
}
public static String replacePrice(String prefix,Player player, String Text, String price) {
return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price)));
}
}

View File

@ -0,0 +1,167 @@
package net.t2code.lib.Spigot.Lib.update;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.t2code.lib.Spigot.Lib.messages.TextBuilder;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Scanner;
import java.util.function.Consumer;
public class UpdateAPI {
public static HashMap<String, UpdateObject> PluginVersionen = new HashMap<>();
public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) {
String pluginVersion = plugin.getDescription().getVersion();
String publicVersion = UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion;
if (!player.hasPermission(perm) || !player.isOp()) {
return;
}
if (publicVersion == null) {
new BukkitRunnable() {
@Override
public void run() {
join(plugin, prefix, perm, player, spigot, discord);
}
}.runTaskLater(plugin, 20L);
} else use(plugin, prefix, player, pluginVersion, publicVersion, spigot, discord);
}
private static void use(Plugin plugin, String prefix, Player player, String pluginVersion, String publicVersion, String spigot, String discord) {
new BukkitRunnable() {
@Override
public void run() {
if (!pluginVersion.equals(publicVersion)) {
if (SelectLibConfig.UpdateCheckOnJoin) {
UpdateAPI.sendUpdateMsg(prefix, spigot, discord, pluginVersion, publicVersion, player);
}
}
}
}.runTaskLater(plugin, 200L);
}
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String pluginVersion, String publicVersion) {
send.console("§4=========== " + Prefix + " §4===========");
send.console("§6A new version was found!");
send.console("§6Your version: §c" + pluginVersion + " §7- §6Current version: §a" + publicVersion);
send.console("§6You can download it here: §e" + Spigot);
send.console("§6You can find more information on Discord: §e" + Discord);
send.console("§4=========== " + Prefix + " §4===========");
}
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String pluginVersion, String publicVersion, Player player) {
if (publicVersion.equals("§4No public version found!")) {
return;
}
send.player(player, Prefix);
TextComponent comp = new TextBuilder(Prefix + " §6A new version was found!")
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
player.spigot().sendMessage(comp);
TextComponent comp1 = new TextBuilder(Prefix + " §c" + pluginVersion + " §7-> §a" + publicVersion)
.addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build();
player.spigot().sendMessage(comp1);
TextComponent comp2 = new TextBuilder(Prefix + " §6You can find more information on Discord.")
.addHover("§e" + Discord).addClickEvent(ClickEvent.Action.OPEN_URL, Discord).build();
player.spigot().sendMessage(comp2);
send.player(player, Prefix);
}
private static Boolean noUpdate = true;
public static void onUpdateCheck(Plugin plugin, String Prefix, String Spigot, int SpigotID, String Discord) {
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
public void run() {
(new UpdateAPI((JavaPlugin) plugin, SpigotID)).getVersion((update_version) -> {
UpdateObject update = new UpdateObject(
plugin.getName(),
plugin.getDescription().getVersion(),
update_version
);
UpdateAPI.PluginVersionen.put(plugin.getName(), update);
if (!plugin.getDescription().getVersion().equalsIgnoreCase(update_version)) {
noUpdate = true;
new BukkitRunnable() {
@Override
public void run() {
sendUpdateMsg(Prefix, Spigot, Discord, plugin.getDescription().getVersion(), update_version);
}
}.runTaskLater(plugin, 600L);
} else {
if (noUpdate) {
send.console(Prefix + " §2No update found.");
noUpdate = false;
}
}
}, Prefix, plugin.getDescription().getVersion());
}
}, 0L, 20 * 60 * 60L);
}
private JavaPlugin plugin;
private int resourceId;
public UpdateAPI(JavaPlugin plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(Consumer<String> consumer, String Prefix, String pluginVersion) {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try {
InputStream inputStream = (new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId)).openStream();
try {
Scanner scanner = new Scanner(inputStream);
try {
if (scanner.hasNext()) {
consumer.accept(scanner.next());
}
} catch (Throwable var8) {
try {
scanner.close();
} catch (Throwable var7) {
var8.addSuppressed(var7);
}
throw var8;
}
scanner.close();
} catch (Throwable var9) {
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable var6) {
var9.addSuppressed(var6);
}
}
throw var9;
}
if (inputStream != null) {
inputStream.close();
}
} catch (IOException var10) {
UpdateObject update = new UpdateObject(
plugin.getName(),
pluginVersion,
"§4No public version found!"
);
UpdateAPI.PluginVersionen.put(plugin.getName(), update);
this.plugin.getLogger().severe(Prefix + "§4 Cannot look for updates: " + var10.getMessage());
}
});
}
}

View File

@ -0,0 +1,14 @@
package net.t2code.lib.Spigot.Lib.update;
public class UpdateObject {
public String pluginName;
public String pluginVersion;
public String publicVersion;
public UpdateObject(String pluginName, String pluginVersion, String publicVersion) {
this.pluginName = pluginName;
this.pluginVersion = pluginVersion;
this.publicVersion = publicVersion;
}
}

View File

@ -0,0 +1,68 @@
package net.t2code.lib.Spigot.Lib.vault;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.system.Main;
import net.t2code.lib.Spigot.system.languages.SelectLibMsg;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
public class Vault {
public static Boolean vaultEnable;
public static Boolean connected;
public static boolean buy(String prefix, Player p, Double price) {
if (Main.eco == null) {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
send.console(prefix + " §4\n" + prefix + " §4Vault could not be found! §9Please download it here: " +
"§6https://www.spigotmc.org/resources/vault.34315/§4\n" + prefix);
}
p.sendMessage(prefix + "\n" + SelectLibMsg.VaultNotSetUp + "\n" + prefix);
} else {
if (Main.eco.getBalance(p) < price) {
return false;
} else {
Main.eco.withdrawPlayer(p, price);
return true;
}
}
return false;
}
public static void loadVault() throws InterruptedException {
Long long_ = Long.valueOf(System.currentTimeMillis());
if (Main.plugin.getServer().getPluginManager().getPlugin("Vault") != null) {
vaultEnable = true;
RegisteredServiceProvider<Economy> eco = Main.plugin.getServer().getServicesManager().getRegistration(Economy.class);
if (eco != null) {
Main.eco = eco.getProvider();
if (Main.eco != null) {
connected = true;
send.console(Main.prefix + " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else {
connected = false;
send.console(Main.prefix + " §4Economy could not be connected / found! 1" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
} else {
connected = false;
send.console(Main.prefix + " §4Economy could not be connected / found! 2" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
RegisteredServiceProvider<Permission> perm = Main.plugin.getServer().getServicesManager().getRegistration(Permission.class);
if (perm != null) {
Main.perm = perm.getProvider();
}
} else {
vaultEnable = false;
connected = false;
send.console(Main.prefix + " §4Vault could not be connected! 3" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
}
public static void vaultDisable() {
connected = false;
send.console(Main.prefix + " §4Vault / Economy successfully deactivated.");
}
}

View File

@ -0,0 +1,189 @@
package net.t2code.lib.Spigot.Lib.yamlConfiguration;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import net.t2code.lib.Spigot.system.languages.SelectLibMsg;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
import java.util.ArrayList;
import java.util.List;
public class Config {
public static void set(String path, String value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
public static void set(String path, YamlConfiguration YamlConfiguration) {
YamlConfiguration.set(path, null);
}
public static void set(String path, Integer value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
public static void set(String path, Double value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
public static void set(String path, Boolean value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
public static void set(String path, List value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
public static void setSound(String soundName, String sound1_8, String sound1_9, String sound1_13, YamlConfiguration yamlConfiguration) {
Config.set("Sound." + soundName + ".Enable", true, yamlConfiguration);
String sound;
if (MCVersion.minecraft1_8) {
sound = sound1_8.toString();
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
sound = sound1_9.toString();
} else sound = sound1_13.toString();
Config.set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
}
public static void setSound(String soundName, String sound1_8, String sound1_13, YamlConfiguration yamlConfiguration) {
Config.set("Sound." + soundName + ".Enable", true, yamlConfiguration);
String sound;
if (MCVersion.minecraft1_8) {
sound = sound1_8.toString();
} else sound = sound1_13.toString();
Config.set("Sound." + soundName + ".Sound", sound, yamlConfiguration);
}
public static void setSound(String soundName, String sound, YamlConfiguration yamlConfiguration) {
Config.set("Sound." + soundName + ".Enable", true, yamlConfiguration);
Config.set("Sound." + soundName + ".Sound", sound.toString(), yamlConfiguration);
}
public static boolean selectSoundEnable( String soundName, YamlConfiguration yamlConfiguration) {
return selectBoolean("Sound." + soundName + ".Enable", yamlConfiguration);
}
public static String selectSound(String prefix, String soundName, YamlConfiguration yamlConfiguration) {
return select(prefix, "Sound." + soundName + ".Sound", yamlConfiguration);
}
public static Sound checkSound(String sound1_8, String sound1_9, String sound1_13, String selectSoundFromConfig, String prefix) {
String SOUND;
if (MCVersion.minecraft1_8) {
SOUND = sound1_8;
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
SOUND = sound1_9;
} else SOUND = sound1_13;
try {
Sound sound_Buy = Sound.valueOf(selectSoundFromConfig);
if (sound_Buy != null) {
return sound_Buy;
} else return null;
} catch (Exception e) {
send.console("§4\n§4\n§4\n" + SelectLibMsg.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§8Buy: §6" + selectSoundFromConfig) + "§4\n§4\n§4\n");
return Sound.valueOf(SOUND);
}
}
public static Sound checkSound(String sound1_8, String sound1_13, String selectSoundFromConfig, String prefix) {
String SOUND;
if (MCVersion.minecraft1_8) {
SOUND = sound1_8;
} else SOUND = sound1_13;
try {
Sound sound_Buy = Sound.valueOf(selectSoundFromConfig);
if (sound_Buy != null) {
return sound_Buy;
} else return null;
} catch (Exception e) {
send.console("§4\n§4\n§4\n" + SelectLibMsg.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§8Buy: §6" + selectSoundFromConfig) + "§4\n§4\n§4\n");
return Sound.valueOf(SOUND);
}
}
public static Sound checkSound(String sound, String selectSoundFromConfig, String prefix) {
try {
Sound sound_Buy = Sound.valueOf(selectSoundFromConfig);
if (sound_Buy != null) {
return sound_Buy;
} else return null;
} catch (Exception e) {
send.console("§4\n§4\n§4\n" + SelectLibMsg.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§8Buy: §6" + selectSoundFromConfig) + "§4\n§4\n§4\n");
return Sound.valueOf(sound);
}
}
public static String select(String prefix, String path, YamlConfiguration yamlConfiguration) {
return Replace.replace(prefix, yamlConfiguration.getString(path));
}
public static void select(String prefix, String value, String path, YamlConfiguration yamlConfiguration) {
value = Replace.replace(prefix, yamlConfiguration.getString(path));
}
public static Integer selectInt(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getInt(path));
}
public static void select(String path, Integer value, YamlConfiguration yamlConfiguration) {
value = (yamlConfiguration.getInt(path));
}
public static Boolean selectBoolean(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getBoolean(path));
}
public static void select(String path, Boolean value, YamlConfiguration yamlConfiguration) {
value = (yamlConfiguration.getBoolean(path));
}
public static Double selectDouble(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getDouble(path));
}
public static void select(String path, Double value, YamlConfiguration yamlConfiguration) {
value = (yamlConfiguration.getDouble(path));
}
public static List selectList(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getList(path));
}
public static void select(String path, List value, YamlConfiguration yamlConfiguration) {
value = (yamlConfiguration.getList(path));
}
public static List selectList(String prefix, String path, YamlConfiguration yamlConfiguration) {
List<String> output = new ArrayList<>();
List<String> input = yamlConfiguration.getStringList(path);
for (String st : input) {
output.add(Replace.replace(prefix, st));
}
return output;
}
public static void select(String prefix, List value, String path, YamlConfiguration yamlConfiguration) {
List<String> output = new ArrayList<>();
List<String> input = yamlConfiguration.getStringList(path);
for (String st : input) {
output.add(Replace.replace(prefix, st));
}
value = output;
}
}

View File

@ -0,0 +1,110 @@
package net.t2code.lib.Spigot.system;
import net.md_5.bungee.protocol.packet.Commands;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
import java.nio.file.*;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class CmdExecuter implements CommandExecutor, TabCompleter {
private static Plugin plugin = Main.plugin;
private static String prefix = Main.prefix;
private static List autor = Main.autor;
private static String version = Main.version;
private static String spigot = Main.spigot;
private static String discord = Main.discord;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
T2CodeTemplate.sendInfo(sender, prefix, spigot, discord, autor, version, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion);
} else {
if ("debug".equals(args[0].toLowerCase())) {
if (args.length != 2) {
send.sender(sender,"§4Use: §7/t2code debug createReportLog");
return false;
}
if ("createreportlog".equals(args[1].toLowerCase())) {
CreateReportLog.create(sender);
} else send.sender(sender,"§4Use: §7/t2code debug createReportLog");
} else send.sender(sender,"§4Use: §7/t2code debug createReportLog");
}
return false;
}
//TabCompleter
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("debug", "t2code.admin");
}};
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
List<String> list = new ArrayList<>();
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length == 1) {
for (String command : arg1.keySet()) {
if (hasPermission(p, arg1.get(command)) && passend(command, args[0])) {
list.add(command);
}
}
}
if (args.length == 2 && args[0].equalsIgnoreCase("debug")) {
if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("debug")) && passend("debug", args[1])) {
list.add("createReportLog");
}
}
return list;
}
}
return list;
}
private static Boolean passend(String command, String arg) {
for (int i = 0; i < arg.toUpperCase().length(); i++) {
if (arg.toUpperCase().length() >= command.toUpperCase().length()) {
return false;
} else {
if (arg.toUpperCase().charAt(i) != command.toUpperCase().charAt(i)) {
return false;
}
}
}
return true;
}
public static boolean hasPermission(Player player, String permission) {
if (player.isOp()) {
return true;
}
String[] Permissions = permission.split(";");
for (String perm : Permissions) {
if (player.hasPermission(perm)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,179 @@
package net.t2code.lib.Spigot.system;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import net.t2code.lib.Spigot.Lib.vault.Vault;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class CreateReportLog {
protected static void create(CommandSender sender) {
send.sender(sender, Main.prefix + " §6A DebugLog is created...");
String timeStampFile = new SimpleDateFormat("HH_mm_ss-dd_MM_yyyy").format(Calendar.getInstance().getTime());
File directory = new File(Main.getPath() + "/DebugLogs");
if (!directory.exists()) {
directory.mkdir();
}
File file = new File(Main.getPath(), "/DebugLogs/T2CodeLog.txt");
PrintWriter pWriter = null;
try {
pWriter = new PrintWriter(new FileWriter(file.getPath()));
String timeStamp = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy").format(Calendar.getInstance().getTime());
pWriter.println("Created on: " + timeStamp);
pWriter.println();
pWriter.println("Server Bukkit version: " + MCVersion.isBuckitVersion);
pWriter.println("Server run on: " + MCVersion.isVersion);
pWriter.println("Server NMS: " + NMSVersion.isNMS);
pWriter.println();
pWriter.println("Online Mode: " + Bukkit.getOnlineMode());
pWriter.println("Worlds: " + Bukkit.getWorlds());
pWriter.println();
if (Vault.vaultEnable) {
pWriter.println("Vault: " + Bukkit.getPluginManager().getPlugin("Vault").getName() + " - " + Bukkit.getPluginManager().getPlugin("Vault").getDescription().getVersion());
} else pWriter.println("Vault: not connected");
if (Main.eco != null) {
String st;
st = Main.eco.getName();
if (Main.eco.getName().equals("CMIEconomy")) st = "CMI";
pWriter.println("Economy: " + Main.eco.isEnabled() + " - " + Main.eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion());
} else pWriter.println("Economy: not connected via vault");
if (Main.perm != null) {
pWriter.println("Permission: " + Main.perm.isEnabled() + " - " + Main.perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(Main.perm.getName()).getDescription().getVersion());
} else pWriter.println("Permission: not connected via vault");
pWriter.println();
pWriter.println("Java: " + System.getProperty("java.version"));
pWriter.println("System: " + System.getProperty("os.name"));
pWriter.println("System: " + System.getProperty("os.version"));
pWriter.println("User Home: " + System.getProperty("user.home"));
pWriter.println();
pWriter.println("T2CodeLib: " + Main.plugin.getDescription().getVersion());
pWriter.println();
pWriter.println("Plugins: ");
for (Plugin pl : Bukkit.getPluginManager().getPlugins()) {
pWriter.println(" - " + pl.getName() + " - " + pl.getDescription().getVersion() + " - Enabled: " + pl.isEnabled() + " - Autors: " + pl.getDescription().getAuthors() + " - Website: " + pl.getDescription().getWebsite());
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
if (pWriter != null) {
pWriter.flush();
pWriter.close();
}
}
String filePath = Main.getPath() + "/DebugLogs/T2CodeLog.txt";
String log = "logs/latest.log";
String zipPath = "plugins/T2CodeLib/DebugLogs/T2CLog-" + timeStampFile + ".zip";
try (ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(zipPath))) {
File fileToZip = new File(filePath);
zip.putNextEntry(new ZipEntry(fileToZip.getName()));
Files.copy(fileToZip.toPath(), zip);
//File logToZip = new File(log);
//zipOut.putNextEntry(new ZipEntry(logToZip.getName()));
//Files.copy(logToZip.toPath(), zipOut);
addFileToZip("", "logs/latest.log", zip, false);
pluginToDebug("T2C-LuckyBox", "T2C-LuckyBox", zip);
pluginToDebug("WonderBagShop", "WonderBagShop", zip);
pluginToDebug("CommandGUI", "CommandGUI", zip);
pluginToDebug("OPSecurity", "OPSecurity", zip);
pluginToDebug("PaPiTest", "PaPiTest", zip);
pluginToDebug("PlotSquaredGUI", "PlotSquaredGUI", zip);
pluginToDebug("T2C-Alias", "T2Code-Alias", zip);
pluginToDebug("LoreEditor", "LoreEditor", zip);
pluginToDebug("Booster", "Booster", zip);
pluginToDebug("AntiMapCopy", "AntiCopy", zip);
zip.closeEntry();
zip.close();
} catch (IOException e) {
e.printStackTrace();
}
file.delete();
if (sender instanceof Player) {
send.sender(sender, Main.prefix + " §6The DebugLog has been created. You can find it under: §e" + zipPath);
send.console(Main.prefix + " §6A DebugLog has been created. You can find it under: §e" + zipPath);
} else send.sender(sender, Main.prefix + " §6The DebugLog has been created. You can find it under: §e" + zipPath);
}
private static void pluginToDebug(String pluginName, String jar, ZipOutputStream zip) throws IOException {
if (PluginCheck.pluginCheck(pluginName)) {
Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
File plConfigs = new File(plugin.getDataFolder().getPath());
if (plConfigs.exists()) {
addFolderToZip("T2Code-Plugins", plugin.getDataFolder().getPath(), zip);
}
File f = new File("plugins/");
File[] fileArray = f.listFiles();
for (File config : fileArray) {
if (config.getName().contains(jar) && config.getName().contains(".jar")) {
addFileToZip("T2Code-Plugins", config.getPath(), zip, false);
}
}
}
}
private static void addFolderToZip(String path, String srcFolder, ZipOutputStream zip) throws IOException {
File folder = new File(srcFolder);
if (folder.list() == null) {
addFileToZip(path + "/" + folder.getName(), srcFolder, zip, false);
} else if (folder.list().length == 0) {
addFileToZip(path, srcFolder, zip, true);
} else {
for (String fileName : folder.list()) {
if (path.equals("")) {
addFileToZip(folder.getName(), srcFolder + "/" + fileName, zip, false);
} else {
addFileToZip(path + "/" + folder.getName(), srcFolder + "/" + fileName, zip, false);
}
}
}
}
private static void addFileToZip(String path, String srcFile, ZipOutputStream zip, boolean flag) throws IOException {
File folder = new File(srcFile);
if (flag) {
zip.putNextEntry(new ZipEntry(path + "/" + folder.getName() + "/"));
} else {
if (folder.isDirectory()) {
addFolderToZip(path, srcFile, zip);
} else {
byte[] buf = new byte[1024];
int len;
FileInputStream in = new FileInputStream(srcFile);
if (path.equals("")) {
zip.putNextEntry(new ZipEntry((folder.getName())));
} else {
zip.putNextEntry(new ZipEntry((path + "/" + folder.getName())));
}
while ((len = in.read(buf)) > 0) {
zip.write(buf, 0, len);
}
}
}
}
}

View File

@ -0,0 +1,19 @@
// This claas was created by JaTiTV
package net.t2code.lib.Spigot.system;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import net.t2code.lib.Util;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
public class JoinEvent implements Listener {
@EventHandler
public void onJoinEvent(PlayerLoginEvent event) {
Player player = event.getPlayer();
UpdateAPI.join(Main.plugin, Util.Prefix, "t2code.lib.updatemsg", event.getPlayer(), Main.spigot, Main.discord);
}
}

View File

@ -0,0 +1,109 @@
package net.t2code.lib.Spigot.system;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import net.t2code.lib.Spigot.Lib.register.Register;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import net.t2code.lib.Spigot.Lib.vault.Vault;
import net.t2code.lib.Spigot.system.config.ConfigCreate;
import net.t2code.lib.Spigot.system.languages.LanguagesCreate;
import net.t2code.lib.Util;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
import net.t2code.lib.Spigot.system.languages.SelectLibMsg;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.List;
public final class Main extends JavaPlugin {
public static File getPath() {
return plugin.getDataFolder();
}
public static Main plugin;
public static Economy eco = null;
public static Permission perm = null;
public static List<String> autor;
public static String version;
public static String prefix = Util.Prefix;
public static Integer spigotID = Util.SpigotID;
public static Integer bstatsID = Util.BstatsID;
public static String spigot = Util.Spigot;
public static String discord = Util.Discord;
@Override
public void onEnable() {
// Plugin startup logic
plugin = this;
autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion();
Long long_;
long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
//send.console("§4 _|_|_|_|_| _|_| _|_|_| _| ");
//send.console("§4 _| _| _| _| _|_| _|_|_| _|_| ");
//send.console("§4 _| _| _| _| _| _| _| _|_|_|_| ");
//send.console("§4 _| _| _| _| _| _| _| _| ");
//send.console("§4 _| _|_|_|_| _|_|_| _|_| _|_|_| _|_|_| ");
//T2CodeTemplate.onLoadSeparateStroke(prefix);
try {
Vault.loadVault();
} catch (InterruptedException e) {
e.printStackTrace();
}
NMSVersion.onCheck();
MCVersion.onCheck();
if (MCVersion.minecraft1_18){
send.warning(this, "The 1.18 is not yet supported with this version! Please check if there are updates of our plugins! " +
"For further questions please join our Discord: http://dc.t2code.net");
}
ItemVersion.scan();
send.console(Main.prefix + " §3Server run on: §6" + MCVersion.isVersion + " / " + NMSVersion.isNMS);
if (eco != null) {
String st;
st = eco.getName();
if (eco.getName().equals("CMIEconomy")) st = "CMI";
if (Bukkit.getPluginManager().getPlugin(st) != null){
send.console(Main.prefix + " §3Economy: §6" + eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion() + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else send.console(Main.prefix + " §3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else send.console(Main.prefix + " §3Economy: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
if (perm != null) {
if (Bukkit.getPluginManager().getPlugin(perm.getName()) != null){
send.console(Main.prefix + " §3Permission plugin: §6" + perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(perm.getName()).getDescription().getVersion() + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else send.console(Main.prefix + " §3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else send.console(Main.prefix + " §3Permission plugin: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
if (PluginCheck.pluginCheck("PlaceholderAPI")) {
send.console(Main.prefix + " §3PlaceholderAPI: §6connected" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
Main.plugin.getCommand("t2code").setExecutor(new CmdExecuter());
ConfigCreate.configCreate();
LanguagesCreate.langCreate();
SelectLibConfig.onSelect();
SelectLibMsg.onSelect(prefix);
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
Metrics.Bstats(plugin, bstatsID);
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
T2CodeTemplate.onLoadFooter(prefix, long_);
}
@Override
public void onDisable() {
// Plugin shutdown logic
Vault.vaultDisable();
T2CodeTemplate.onDisable(prefix, autor, version, spigot, discord);
}
}

View File

@ -0,0 +1,851 @@
// This claas was created by JaTiTV
package net.t2code.lib.Spigot.system;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.stream.Collectors;
import java.util.zip.GZIPOutputStream;
public class Metrics {
public static void Bstats(Plugin plugin, int bstatsID) {
int pluginId = bstatsID; // <-- Replace with the id of your plugin!
Metrics metrics = new Metrics((JavaPlugin) plugin, pluginId);
metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(SelectLibConfig.UpdateCheckOnJoin)));
}
private final Plugin plugin;
private final MetricsBase metricsBase;
/**
* Creates a new Metrics instance.
*
* @param plugin Your plugin instance.
* @param serviceId The id of the service. It can be found at <a
* href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
*/
public Metrics(JavaPlugin plugin, int serviceId) {
this.plugin = plugin;
// Get the config file
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
File configFile = new File(bStatsFolder, "config.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
if (!config.isSet("serverUuid")) {
config.addDefault("enabled", true);
config.addDefault("serverUuid", UUID.randomUUID().toString());
config.addDefault("logFailedRequests", false);
config.addDefault("logSentData", false);
config.addDefault("logResponseStatusText", false);
// Inform the server owners about bStats
config
.options()
.header(
"bStats (https://bStats.org) collects some basic information for plugin authors, like how\n"
+ "many people use their plugin and their total player count. It's recommended to keep bStats\n"
+ "enabled, but if you're not comfortable with this, you can turn this setting off. There is no\n"
+ "performance penalty associated with having metrics enabled, and data sent to bStats is fully\n"
+ "anonymous.")
.copyDefaults(true);
try {
config.save(configFile);
} catch (IOException ignored) {
}
}
// Load the data
boolean enabled = config.getBoolean("enabled", true);
String serverUUID = config.getString("serverUuid");
boolean logErrors = config.getBoolean("logFailedRequests", false);
boolean logSentData = config.getBoolean("logSentData", false);
boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false);
metricsBase =
new MetricsBase(
"bukkit",
serverUUID,
serviceId,
enabled,
this::appendPlatformData,
this::appendServiceData,
submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
plugin::isEnabled,
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
(message) -> this.plugin.getLogger().log(Level.INFO, message),
logErrors,
logSentData,
logResponseStatusText);
}
/**
* Adds a custom chart.
*
* @param chart The chart to add.
*/
public void addCustomChart(CustomChart chart) {
metricsBase.addCustomChart(chart);
}
private void appendPlatformData(JsonObjectBuilder builder) {
builder.appendField("playerAmount", getPlayerAmount());
builder.appendField("onlineMode", Bukkit.getOnlineMode() ? 1 : 0);
builder.appendField("bukkitVersion", Bukkit.getVersion());
builder.appendField("bukkitName", Bukkit.getName());
builder.appendField("javaVersion", System.getProperty("java.version"));
builder.appendField("osName", System.getProperty("os.name"));
builder.appendField("osArch", System.getProperty("os.arch"));
builder.appendField("osVersion", System.getProperty("os.version"));
builder.appendField("coreCount", Runtime.getRuntime().availableProcessors());
}
private void appendServiceData(JsonObjectBuilder builder) {
builder.appendField("pluginVersion", plugin.getDescription().getVersion());
}
private int getPlayerAmount() {
try {
// Around MC 1.8 the return type was changed from an array to a collection,
// This fixes java.lang.NoSuchMethodError:
// org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
return onlinePlayersMethod.getReturnType().equals(Collection.class)
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
} catch (Exception e) {
// Just use the new method if the reflection failed
return Bukkit.getOnlinePlayers().size();
}
}
public static class MetricsBase {
/**
* The version of the Metrics class.
*/
public static final String METRICS_VERSION = "2.2.1";
private static final ScheduledExecutorService scheduler =
Executors.newScheduledThreadPool(1, task -> new Thread(task, "bStats-Metrics"));
private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s";
private final String platform;
private final String serverUuid;
private final int serviceId;
private final Consumer<JsonObjectBuilder> appendPlatformDataConsumer;
private final Consumer<JsonObjectBuilder> appendServiceDataConsumer;
private final Consumer<Runnable> submitTaskConsumer;
private final Supplier<Boolean> checkServiceEnabledSupplier;
private final BiConsumer<String, Throwable> errorLogger;
private final Consumer<String> infoLogger;
private final boolean logErrors;
private final boolean logSentData;
private final boolean logResponseStatusText;
private final Set<CustomChart> customCharts = new HashSet<>();
private final boolean enabled;
/**
* Creates a new MetricsBase class instance.
*
* @param platform The platform of the service.
* @param serviceId The id of the service.
* @param serverUuid The server uuid.
* @param enabled Whether or not data sending is enabled.
* @param appendPlatformDataConsumer A consumer that receives a {@code JsonObjectBuilder} and
* appends all platform-specific data.
* @param appendServiceDataConsumer A consumer that receives a {@code JsonObjectBuilder} and
* appends all service-specific data.
* @param submitTaskConsumer A consumer that takes a runnable with the submit task. This can be
* used to delegate the data collection to a another thread to prevent errors caused by
* concurrency. Can be {@code null}.
* @param checkServiceEnabledSupplier A supplier to check if the service is still enabled.
* @param errorLogger A consumer that accepts log message and an error.
* @param infoLogger A consumer that accepts info log messages.
* @param logErrors Whether or not errors should be logged.
* @param logSentData Whether or not the sent data should be logged.
* @param logResponseStatusText Whether or not the response status text should be logged.
*/
public MetricsBase(
String platform,
String serverUuid,
int serviceId,
boolean enabled,
Consumer<JsonObjectBuilder> appendPlatformDataConsumer,
Consumer<JsonObjectBuilder> appendServiceDataConsumer,
Consumer<Runnable> submitTaskConsumer,
Supplier<Boolean> checkServiceEnabledSupplier,
BiConsumer<String, Throwable> errorLogger,
Consumer<String> infoLogger,
boolean logErrors,
boolean logSentData,
boolean logResponseStatusText) {
this.platform = platform;
this.serverUuid = serverUuid;
this.serviceId = serviceId;
this.enabled = enabled;
this.appendPlatformDataConsumer = appendPlatformDataConsumer;
this.appendServiceDataConsumer = appendServiceDataConsumer;
this.submitTaskConsumer = submitTaskConsumer;
this.checkServiceEnabledSupplier = checkServiceEnabledSupplier;
this.errorLogger = errorLogger;
this.infoLogger = infoLogger;
this.logErrors = logErrors;
this.logSentData = logSentData;
this.logResponseStatusText = logResponseStatusText;
checkRelocation();
if (enabled) {
startSubmitting();
}
}
public void addCustomChart(CustomChart chart) {
this.customCharts.add(chart);
}
private void startSubmitting() {
final Runnable submitTask =
() -> {
if (!enabled || !checkServiceEnabledSupplier.get()) {
// Submitting data or service is disabled
scheduler.shutdown();
return;
}
if (submitTaskConsumer != null) {
submitTaskConsumer.accept(this::submitData);
} else {
this.submitData();
}
};
// Many servers tend to restart at a fixed time at xx:00 which causes an uneven distribution
// of requests on the
// bStats backend. To circumvent this problem, we introduce some randomness into the initial
// and second delay.
// WARNING: You must not modify and part of this Metrics class, including the submit delay or
// frequency!
// WARNING: Modifying this code will get your plugin banned on bStats. Just don't do it!
long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3));
long secondDelay = (long) (1000 * 60 * (Math.random() * 30));
scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS);
scheduler.scheduleAtFixedRate(
submitTask, initialDelay + secondDelay, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
}
private void submitData() {
final JsonObjectBuilder baseJsonBuilder = new JsonObjectBuilder();
appendPlatformDataConsumer.accept(baseJsonBuilder);
final JsonObjectBuilder serviceJsonBuilder = new JsonObjectBuilder();
appendServiceDataConsumer.accept(serviceJsonBuilder);
JsonObjectBuilder.JsonObject[] chartData =
customCharts.stream()
.map(customChart -> customChart.getRequestJsonObject(errorLogger, logErrors))
.filter(Objects::nonNull)
.toArray(JsonObjectBuilder.JsonObject[]::new);
serviceJsonBuilder.appendField("id", serviceId);
serviceJsonBuilder.appendField("customCharts", chartData);
baseJsonBuilder.appendField("service", serviceJsonBuilder.build());
baseJsonBuilder.appendField("serverUUID", serverUuid);
baseJsonBuilder.appendField("metricsVersion", METRICS_VERSION);
JsonObjectBuilder.JsonObject data = baseJsonBuilder.build();
scheduler.execute(
() -> {
try {
// Send the data
sendData(data);
} catch (Exception e) {
// Something went wrong! :(
if (logErrors) {
errorLogger.accept("Could not submit bStats metrics data", e);
}
}
});
}
private void sendData(JsonObjectBuilder.JsonObject data) throws Exception {
if (logSentData) {
infoLogger.accept("Sent bStats metrics data: " + data.toString());
}
String url = String.format(REPORT_URL, platform);
HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
// Compress the data to save bandwidth
byte[] compressedData = compress(data.toString());
connection.setRequestMethod("POST");
connection.addRequestProperty("Accept", "application/json");
connection.addRequestProperty("Connection", "close");
connection.addRequestProperty("Content-Encoding", "gzip");
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("User-Agent", "Metrics-Service/1");
connection.setDoOutput(true);
try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
outputStream.write(compressedData);
}
StringBuilder builder = new StringBuilder();
try (BufferedReader bufferedReader =
new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
builder.append(line);
}
}
if (logResponseStatusText) {
infoLogger.accept("Sent data to bStats and received response: " + builder);
}
}
/**
* Checks that the class was properly relocated.
*/
private void checkRelocation() {
// You can use the property to disable the check in your test environment
if (System.getProperty("bstats.relocatecheck") == null
|| !System.getProperty("bstats.relocatecheck").equals("false")) {
// Maven's Relocate is clever and changes strings, too. So we have to use this little
// "trick" ... :D
final String defaultPackage =
new String(new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'});
final String examplePackage =
new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
// We want to make sure no one just copy & pastes the example and uses the wrong package
// names
if (MetricsBase.class.getPackage().getName().startsWith(defaultPackage)
|| MetricsBase.class.getPackage().getName().startsWith(examplePackage)) {
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
}
}
}
/**
* Gzips the given string.
*
* @param str The string to gzip.
* @return The gzipped string.
*/
private static byte[] compress(final String str) throws IOException {
if (str == null) {
return null;
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
gzip.write(str.getBytes(StandardCharsets.UTF_8));
}
return outputStream.toByteArray();
}
}
public static class AdvancedBarChart extends CustomChart {
private final Callable<Map<String, int[]>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, int[]> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, int[]> entry : map.entrySet()) {
if (entry.getValue().length == 0) {
// Skip this invalid
continue;
}
allSkipped = false;
valuesBuilder.appendField(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
public static class SimpleBarChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
for (Map.Entry<String, Integer> entry : map.entrySet()) {
valuesBuilder.appendField(entry.getKey(), new int[]{entry.getValue()});
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
public static class MultiLineChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
// Skip this invalid
continue;
}
allSkipped = false;
valuesBuilder.appendField(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
public static class AdvancedPie extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
// Skip this invalid
continue;
}
allSkipped = false;
valuesBuilder.appendField(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
public abstract static class CustomChart {
private final String chartId;
protected CustomChart(String chartId) {
if (chartId == null) {
throw new IllegalArgumentException("chartId must not be null");
}
this.chartId = chartId;
}
public JsonObjectBuilder.JsonObject getRequestJsonObject(
BiConsumer<String, Throwable> errorLogger, boolean logErrors) {
JsonObjectBuilder builder = new JsonObjectBuilder();
builder.appendField("chartId", chartId);
try {
JsonObjectBuilder.JsonObject data = getChartData();
if (data == null) {
// If the data is null we don't send the chart.
return null;
}
builder.appendField("data", data);
} catch (Throwable t) {
if (logErrors) {
errorLogger.accept("Failed to get data for custom chart with id " + chartId, t);
}
return null;
}
return builder.build();
}
protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception;
}
public static class SingleLineChart extends CustomChart {
private final Callable<Integer> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SingleLineChart(String chartId, Callable<Integer> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
int value = callable.call();
if (value == 0) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("value", value).build();
}
}
public static class SimplePie extends CustomChart {
private final Callable<String> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimplePie(String chartId, Callable<String> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObjectBuilder.JsonObject getChartData() throws Exception {
String value = callable.call();
if (value == null || value.isEmpty()) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("value", value).build();
}
}
public static class DrilldownPie extends CustomChart {
private final Callable<Map<String, Map<String, Integer>>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
super(chartId);
this.callable = callable;
}
@Override
public JsonObjectBuilder.JsonObject getChartData() throws Exception {
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
Map<String, Map<String, Integer>> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean reallyAllSkipped = true;
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
JsonObjectBuilder valueBuilder = new JsonObjectBuilder();
boolean allSkipped = true;
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
valueBuilder.appendField(valueEntry.getKey(), valueEntry.getValue());
allSkipped = false;
}
if (!allSkipped) {
reallyAllSkipped = false;
valuesBuilder.appendField(entryValues.getKey(), valueBuilder.build());
}
}
if (reallyAllSkipped) {
// Null = skip the chart
return null;
}
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
}
}
/**
* An extremely simple JSON builder.
*
* <p>While this class is neither feature-rich nor the most performant one, it's sufficient enough
* for its use-case.
*/
public static class JsonObjectBuilder {
private StringBuilder builder = new StringBuilder();
private boolean hasAtLeastOneField = false;
public JsonObjectBuilder() {
builder.append("{");
}
/**
* Appends a null field to the JSON.
*
* @param key The key of the field.
* @return A reference to this object.
*/
public JsonObjectBuilder appendNull(String key) {
appendFieldUnescaped(key, "null");
return this;
}
/**
* Appends a string field to the JSON.
*
* @param key The key of the field.
* @param value The value of the field.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, String value) {
if (value == null) {
throw new IllegalArgumentException("JSON value must not be null");
}
appendFieldUnescaped(key, "\"" + escape(value) + "\"");
return this;
}
/**
* Appends an integer field to the JSON.
*
* @param key The key of the field.
* @param value The value of the field.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, int value) {
appendFieldUnescaped(key, String.valueOf(value));
return this;
}
/**
* Appends an object to the JSON.
*
* @param key The key of the field.
* @param object The object.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, JsonObject object) {
if (object == null) {
throw new IllegalArgumentException("JSON object must not be null");
}
appendFieldUnescaped(key, object.toString());
return this;
}
/**
* Appends a string array to the JSON.
*
* @param key The key of the field.
* @param values The string array.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, String[] values) {
if (values == null) {
throw new IllegalArgumentException("JSON values must not be null");
}
String escapedValues =
Arrays.stream(values)
.map(value -> "\"" + escape(value) + "\"")
.collect(Collectors.joining(","));
appendFieldUnescaped(key, "[" + escapedValues + "]");
return this;
}
/**
* Appends an integer array to the JSON.
*
* @param key The key of the field.
* @param values The integer array.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, int[] values) {
if (values == null) {
throw new IllegalArgumentException("JSON values must not be null");
}
String escapedValues =
Arrays.stream(values).mapToObj(String::valueOf).collect(Collectors.joining(","));
appendFieldUnescaped(key, "[" + escapedValues + "]");
return this;
}
/**
* Appends an object array to the JSON.
*
* @param key The key of the field.
* @param values The integer array.
* @return A reference to this object.
*/
public JsonObjectBuilder appendField(String key, JsonObject[] values) {
if (values == null) {
throw new IllegalArgumentException("JSON values must not be null");
}
String escapedValues =
Arrays.stream(values).map(JsonObject::toString).collect(Collectors.joining(","));
appendFieldUnescaped(key, "[" + escapedValues + "]");
return this;
}
/**
* Appends a field to the object.
*
* @param key The key of the field.
* @param escapedValue The escaped value of the field.
*/
private void appendFieldUnescaped(String key, String escapedValue) {
if (builder == null) {
throw new IllegalStateException("JSON has already been built");
}
if (key == null) {
throw new IllegalArgumentException("JSON key must not be null");
}
if (hasAtLeastOneField) {
builder.append(",");
}
builder.append("\"").append(escape(key)).append("\":").append(escapedValue);
hasAtLeastOneField = true;
}
/**
* Builds the JSON string and invalidates this builder.
*
* @return The built JSON string.
*/
public JsonObject build() {
if (builder == null) {
throw new IllegalStateException("JSON has already been built");
}
JsonObject object = new JsonObject(builder.append("}").toString());
builder = null;
return object;
}
/**
* Escapes the given string like stated in https://www.ietf.org/rfc/rfc4627.txt.
*
* <p>This method escapes only the necessary characters '"', '\'. and '\u0000' - '\u001F'.
* Compact escapes are not used (e.g., '\n' is escaped as "\u000a" and not as "\n").
*
* @param value The value to escape.
* @return The escaped value.
*/
private static String escape(String value) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (c == '"') {
builder.append("\\\"");
} else if (c == '\\') {
builder.append("\\\\");
} else if (c <= '\u000F') {
builder.append("\\u000").append(Integer.toHexString(c));
} else if (c <= '\u001F') {
builder.append("\\u00").append(Integer.toHexString(c));
} else {
builder.append(c);
}
}
return builder.toString();
}
/**
* A super simple representation of a JSON object.
*
* <p>This class only exists to make methods of the {@link JsonObjectBuilder} type-safe and not
* allow a raw string inputs for methods like {@link JsonObjectBuilder#appendField(String,
* JsonObject)}.
*/
public static class JsonObject {
private final String value;
private JsonObject(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}
}
}

View File

@ -0,0 +1,67 @@
package net.t2code.lib.Spigot.system.config;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.system.Main;
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class ConfigCreate {
private static Boolean UpdateCheckOnJoin = true;
private static Boolean Debug = false;
private static String language = "english";
private static Boolean mySQL = false;
private static String Storage = "YML";
private static String ip = "localhost";
private static Integer port = 3306;
private static String database = "database";
private static String user = "root";
private static String password = "password";
private static Boolean SSL = false;
private static Boolean Bungee = false;
private static String thisServer = "server";
public static void configCreate() {
Long long_ = Long.valueOf(System.currentTimeMillis());
if (new File(Main.getPath(), "config.yml").exists()){
if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Main.prefix + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else send.console(Main.prefix + " §4config.yml are created...");
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
Config.set("Plugin.UpdateCheckOnJoin", UpdateCheckOnJoin, yamlConfiguration);
Config.set("Plugin.language", language, yamlConfiguration);
Config.set("BungeeCord.Enable", Bungee, yamlConfiguration);
Config.set("BungeeCord.ThisServer", thisServer, yamlConfiguration);
// Config.set("Storage.MySQL.Enable", mySQL, yamlConfiguration);
// Config.set("Storage.Type", Storage, yamlConfiguration);
// Config.set("Storage.MySQL.IP", ip, yamlConfiguration);
// Config.set("Storage.MySQL.Port", port, yamlConfiguration);
// Config.set("Storage.MySQL.Database", database, yamlConfiguration);
// Config.set("Storage.MySQL.User", user, yamlConfiguration);
// Config.set("Storage.MySQL.Password", password, yamlConfiguration);
// Config.set("Storage.MySQL.SSL", SSL, yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
}

View File

@ -0,0 +1,24 @@
package net.t2code.lib.Spigot.system.config;
import net.t2code.lib.Spigot.system.Main;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class SelectLibConfig {
public static Boolean UpdateCheckOnJoin;
public static Boolean Debug;
public static String language;
public static void onSelect() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin");
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
language = yamlConfiguration.getString("Plugin.language");
}
}

View File

@ -0,0 +1,78 @@
package net.t2code.lib.Spigot.system.languages;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.system.Main;
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException;
public class LanguagesCreate {
static Plugin plugin = Main.plugin;
public static void langCreate() {
send.debug(plugin,"§4Language files are created / updated...");
Long long_ = Long.valueOf(System.currentTimeMillis());
/**
*
* ENGLISH
*
*/
File messagesEN = new File(Main.getPath(), "languages/english_messages.yml");
YamlConfiguration yamlConfigurationEN = YamlConfiguration.loadConfiguration(messagesEN);
Config.set("Plugin.VaultNotSetUp", MSG.EN_VaultNotSetUp, yamlConfigurationEN);
Config.set("Plugin.SoundNotFound", MSG.EN_SoundNotFound, yamlConfigurationEN);
try {
yamlConfigurationEN.save(messagesEN);
} catch (IOException e) {
send.warning(Main.plugin,e.getMessage());
e.printStackTrace();
}
/**
*
* GERMAN
*
*/
File messagesDE = new File(Main.getPath(), "languages/german_messages.yml");
YamlConfiguration yamlConfigurationDE = YamlConfiguration.loadConfiguration(messagesDE);
Config.set("Plugin.VaultNotSetUp", MSG.DE_VaultNotSetUp, yamlConfigurationDE);
Config.set("Plugin.SoundNotFound", MSG.DE_SoundNotFound, yamlConfigurationDE);
try {
yamlConfigurationDE.save(messagesDE);
} catch (IOException e) {
send.warning(Main.plugin,e.getMessage());
e.printStackTrace();
}
/**
*
* norwegian
*
*/
File messagesNO = new File(Main.getPath(), "languages/norwegian_messages.yml");
YamlConfiguration yamlConfigurationNO = YamlConfiguration.loadConfiguration(messagesNO);
Config.set("Plugin.VaultNotSetUp", MSG.NO_VaultNotSetUp, yamlConfigurationNO);
Config.set("Plugin.SoundNotFound", MSG.NO_SoundNotFound, yamlConfigurationNO);
try {
yamlConfigurationNO.save(messagesNO);
} catch (IOException e) {
send.warning(Main.plugin,e.getMessage());
e.printStackTrace();
}
send.console(Main.prefix + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
}

View File

@ -0,0 +1,22 @@
// This claas was created by JaTiTV
package net.t2code.lib.Spigot.system.languages;
public class MSG {
// EN
public static String EN_VaultNotSetUp = "[prefix] &4Vault / Economy not set up!";
public static String EN_SoundNotFound = "[prefix] &4The sound &6[sound] &4was not found! Please check the settings.";
// DE
public static String DE_VaultNotSetUp = "[prefix] &4Vault / Economy nicht eingerichtet!";
public static String DE_SoundNotFound = "[prefix] &4Der Sound &6[sound] &4wurde nicht gefunden! Bitte [ue]berpr[ue]fe die Einstellungen.";
// NO
public static String NO_VaultNotSetUp = "[prefix] &4Vault / Økonomi har ikke blitt satt opp!";
public static String NO_SoundNotFound = "[prefix] &4Lyden &6[sound] &4ble ikke bli funnet! Vennligst sjekk innstillingene.";
}

View File

@ -0,0 +1,48 @@
package net.t2code.lib.Spigot.system.languages;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import net.t2code.lib.Spigot.system.Main;
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import java.io.File;
public class SelectLibMsg {
private static Plugin plugin = Main.plugin;
private static String prefix = Main.prefix;
public static String selectMSG;
public static String VaultNotSetUp;
public static String SoundNotFound;
public static void onSelect(String Prefix) {
send.debug(plugin, "§4Select language...");
Long long_ = Long.valueOf(System.currentTimeMillis());
File msg;
msg = new File(Main.getPath(), "languages/" + SelectLibConfig.language + "_messages.yml");
if (!msg.isFile()) {
send.console(Prefix);
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
send.console(Prefix + " §4The selected §c" + SelectLibConfig.language + " §4language file was not found.");
send.console(Prefix + " §6The default language §eEnglish §6is used!");
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
send.console(Prefix);
msg = new File(Main.getPath(), "languages/" + "english_messages.yml");
selectMSG = "english";
} else selectMSG = SelectLibConfig.language;
YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg);
VaultNotSetUp = Replace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VaultNotSetUp"));
SoundNotFound = Replace.replace(prefix, yamlConfiguration_msg.getString("Plugin.SoundNotFound"));
send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}
}

View File

@ -0,0 +1,9 @@
package net.t2code.lib;
public class Util {
public static String Prefix = "§8[§4T2Code§5Lib§8]";
public static Integer SpigotID = 96388;
public static Integer BstatsID = 12518;
public static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
public static String Discord = "http://dc.t2code.net";
}

View File

@ -0,0 +1,5 @@
name: T2CodeLib
version: 7.3
main: net.t2code.lib.Bungee.BMain
author: JaTiTV, Jkobs
description: Libarie from T2Code Plugins

View File

@ -0,0 +1,18 @@
name: T2CodeLib
version: 7.3
main: net.t2code.lib.Spigot.system.Main
api-version: 1.13
prefix: T2CodeLib
authors: [ JaTiTV, Jkobs ]
description: Libarie from T2Code Plugins
website: T2Code.net
load: STARTUP
softdepend: [ PlaceholderAPI, PlotSquared, CMI, CMILib, Vault, Economy, XConomy ]
loadbefore: [ T2C-Alias ]
commands:
t2code:
permissions:
t2code.admin:
default: op

View File

@ -0,0 +1,5 @@
name: T2CodeLib
version: 7.3
main: net.t2code.lib.Bungee.BMain
author: JaTiTV, Jkobs
description: Libarie from T2Code Plugins

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More