Compare commits
No commits in common. "master" and "v1.0-pre1" have entirely different histories.
171 changed files with 4088 additions and 5712 deletions
|
@ -1,17 +0,0 @@
|
|||
[*]
|
||||
charset=utf-8
|
||||
end_of_line=lf
|
||||
insert_final_newline=false
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
[*.java]
|
||||
indent_style=tab
|
||||
tab_width=4
|
||||
|
||||
[{*.yml,*.yaml}]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[*.xml]
|
||||
indent_style = tab
|
75
.github/workflows/codeql-analysis.yml
vendored
75
.github/workflows/codeql-analysis.yml
vendored
|
@ -1,75 +0,0 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '0 10 * * 1'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Override automatic language detection by changing the below list
|
||||
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||
language: [ 'java' ]
|
||||
# Learn more...
|
||||
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||
|
||||
steps:
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v1.3.0
|
||||
with:
|
||||
java-version: 11
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
13
.idea/ButtonCore.iml
Executable file
13
.idea/ButtonCore.iml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
|
||||
</component>
|
||||
</module>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
28
.idea/compiler.xml
Executable file
28
.idea/compiler.xml
Executable file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
<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="BuildConfigUpdater" />
|
||||
<module name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="BuildConfigUpdater" target="1.8" />
|
||||
<module name="ButtonCore" target="1.5" />
|
||||
<module name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" target="1.8" />
|
||||
<module name="ButtonProcessor" target="1.8" />
|
||||
<module name="ChunkArchive" target="1.8" />
|
||||
<module name="RandomTeleport" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="ButtonProcessor" options="-proc:none" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
7
.idea/encodings.xml
Executable file
7
.idea/encodings.xml
Executable file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/ButtonCore" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/ButtonProcessor" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
11
.idea/inspectionProfiles/Project_Default.xml
Normal file
11
.idea/inspectionProfiles/Project_Default.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="WeakerAccess" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="false" />
|
||||
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="false" />
|
||||
<option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" />
|
||||
<disabledExtension id="moduleInfo" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: com.github.TBMCPlugins.ButtonCore:Towny:master-248b0d8d0a-1">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/TBMCPlugins/ButtonCore/Towny/master-248b0d8d0a-1/Towny-master-248b0d8d0a-1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/TBMCPlugins/ButtonCore/Towny/master-248b0d8d0a-1/Towny-master-248b0d8d0a-1-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/TBMCPlugins/ButtonCore/Towny/master-248b0d8d0a-1/Towny-master-248b0d8d0a-1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: com.github.milkbowl:VaultAPI:master-431c5273c2-1">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/milkbowl/VaultAPI/master-431c5273c2-1/VaultAPI-master-431c5273c2-1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/milkbowl/VaultAPI/master-431c5273c2-1/VaultAPI-master-431c5273c2-1-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/milkbowl/VaultAPI/master-431c5273c2-1/VaultAPI-master-431c5273c2-1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__com_google_code_findbugs_annotations_2_0_1.xml
Executable file
13
.idea/libraries/Maven__com_google_code_findbugs_annotations_2_0_1.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: com.google.code.findbugs:annotations:2.0.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/annotations/2.0.1/annotations-2.0.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/annotations/2.0.1/annotations-2.0.1-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/annotations/2.0.1/annotations-2.0.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml
Normal file
13
.idea/libraries/Maven__com_google_code_gson_gson_2_8_0.xml
Normal 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>
|
13
.idea/libraries/Maven__com_google_guava_guava_15_0.xml
Executable file
13
.idea/libraries/Maven__com_google_guava_guava_15_0.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: com.google.guava:guava:15.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/15.0/guava-15.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/15.0/guava-15.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/15.0/guava-15.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__com_google_guava_guava_21_0.xml
Normal file
13
.idea/libraries/Maven__com_google_guava_guava_21_0.xml
Normal 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>
|
13
.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml
Executable file
13
.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml
Executable 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>
|
13
.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml
Executable file
13
.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: commons-io:commons-io:1.3.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/1.3.2/commons-io-1.3.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/1.3.2/commons-io-1.3.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__commons_io_commons_io_2_6.xml
Normal file
13
.idea/libraries/Maven__commons_io_commons_io_2_6.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: commons-io:commons-io:2.6">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/2.6/commons-io-2.6.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/2.6/commons-io-2.6-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/2.6/commons-io-2.6-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml
Executable file
13
.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml
Executable 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>
|
13
.idea/libraries/Maven__junit_junit_3_8_1.xml
Executable file
13
.idea/libraries/Maven__junit_junit_3_8_1.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: junit:junit:3.8.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/3.8.1/junit-3.8.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/3.8.1/junit-3.8.1-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/3.8.1/junit-3.8.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_6_11.xml
Executable file
13
.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_6_11.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: net.bytebuddy:byte-buddy:1.6.11">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.6.11/byte-buddy-1.6.11.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.6.11/byte-buddy-1.6.11-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.6.11/byte-buddy-1.6.11-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_6_11.xml
Executable file
13
.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_6_11.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: net.bytebuddy:byte-buddy-agent:1.6.11">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.6.11/byte-buddy-agent-1.6.11.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.6.11/byte-buddy-agent-1.6.11-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.6.11/byte-buddy-agent-1.6.11-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__net_ess3_Essentials_2_13_1.xml
Normal file
13
.idea/libraries/Maven__net_ess3_Essentials_2_13_1.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: net.ess3:Essentials:2.13.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/ess3/Essentials/2.13.1/Essentials-2.13.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/ess3/Essentials/2.13.1/Essentials-2.13.1-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/ess3/Essentials/2.13.1/Essentials-2.13.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-20180712.114550-97.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-20180712.114550-97-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-20180712.114550-97-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-20181022.190036-99.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-20181022.190036-99-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-20181022.190036-99-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__org_javassist_javassist_3_20_0_GA.xml
Executable file
13
.idea/libraries/Maven__org_javassist_javassist_3_20_0_GA.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: org.javassist:javassist:3.20.0-GA">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__org_mockito_mockito_core_2_7_20.xml
Executable file
13
.idea/libraries/Maven__org_mockito_mockito_core_2_7_20.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: org.mockito:mockito-core:2.7.20">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-core/2.7.20/mockito-core-2.7.20.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-core/2.7.20/mockito-core-2.7.20-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-core/2.7.20/mockito-core-2.7.20-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__org_objenesis_objenesis_2_5.xml
Executable file
13
.idea/libraries/Maven__org_objenesis_objenesis_2_5.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: org.objenesis:objenesis:2.5">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/2.5/objenesis-2.5.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/2.5/objenesis-2.5-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/2.5/objenesis-2.5-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
14
.idea/libraries/Maven__org_projectlombok_lombok_1_16_16.xml
Executable file
14
.idea/libraries/Maven__org_projectlombok_lombok_1_16_16.xml
Executable file
|
@ -0,0 +1,14 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: org.projectlombok:lombok:1.16.16">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.16.16/lombok-1.16.16.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.16.16/lombok-1.16.16-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.16.16/lombok-1.16.16-sources.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.ideaLibSources/lombok-1.16.16-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__org_reflections_reflections_0_9_10.xml
Executable file
13
.idea/libraries/Maven__org_reflections_reflections_0_9_10.xml
Executable file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: org.reflections:reflections:0.9.10">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/reflections/reflections/0.9.10/reflections-0.9.10.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/reflections/reflections/0.9.10/reflections-0.9.10-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/reflections/reflections/0.9.10/reflections-0.9.10-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-SNAPSHOT.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-SNAPSHOT-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-SNAPSHOT-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml
Normal file
13
.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Maven: org.yaml:snakeyaml:1.19">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.19/snakeyaml-1.19.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.19/snakeyaml-1.19-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.19/snakeyaml-1.19-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
8
.idea/markdown-exported-files.xml
Normal file
8
.idea/markdown-exported-files.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MarkdownExportedFiles">
|
||||
<htmlFiles />
|
||||
<imageFiles />
|
||||
<otherFiles />
|
||||
</component>
|
||||
</project>
|
82
.idea/markdown-navigator.xml
Normal file
82
.idea/markdown-navigator.xml
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MarkdownProjectSettings" wasCopied="false">
|
||||
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
|
||||
<PanelProvider>
|
||||
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
|
||||
</PanelProvider>
|
||||
</PreviewSettings>
|
||||
<ParserSettings gitHubSyntaxChange="false" emojiShortcuts="1" emojiImages="0">
|
||||
<PegdownExtensions>
|
||||
<option name="ABBREVIATIONS" value="false" />
|
||||
<option name="ANCHORLINKS" value="true" />
|
||||
<option name="ASIDE" value="false" />
|
||||
<option name="ATXHEADERSPACE" value="true" />
|
||||
<option name="AUTOLINKS" value="true" />
|
||||
<option name="DEFINITIONS" value="false" />
|
||||
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
|
||||
<option name="FENCED_CODE_BLOCKS" value="true" />
|
||||
<option name="FOOTNOTES" value="false" />
|
||||
<option name="HARDWRAPS" value="false" />
|
||||
<option name="HTML_DEEP_PARSER" value="false" />
|
||||
<option name="INSERTED" value="false" />
|
||||
<option name="QUOTES" value="false" />
|
||||
<option name="RELAXEDHRULES" value="true" />
|
||||
<option name="SMARTS" value="false" />
|
||||
<option name="STRIKETHROUGH" value="true" />
|
||||
<option name="SUBSCRIPT" value="false" />
|
||||
<option name="SUPERSCRIPT" value="false" />
|
||||
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
|
||||
<option name="SUPPRESS_INLINE_HTML" value="false" />
|
||||
<option name="TABLES" value="true" />
|
||||
<option name="TASKLISTITEMS" value="true" />
|
||||
<option name="TOC" value="false" />
|
||||
<option name="WIKILINKS" value="true" />
|
||||
</PegdownExtensions>
|
||||
<ParserOptions>
|
||||
<option name="ADMONITION_EXT" value="false" />
|
||||
<option name="ATTRIBUTES_EXT" value="false" />
|
||||
<option name="COMMONMARK_LISTS" value="true" />
|
||||
<option name="DUMMY" value="false" />
|
||||
<option name="EMOJI_SHORTCUTS" value="true" />
|
||||
<option name="ENUMERATED_REFERENCES_EXT" value="false" />
|
||||
<option name="FLEXMARK_FRONT_MATTER" value="false" />
|
||||
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
|
||||
<option name="GFM_TABLE_RENDERING" value="true" />
|
||||
<option name="GITBOOK_URL_ENCODING" value="false" />
|
||||
<option name="GITHUB_LISTS" value="false" />
|
||||
<option name="GITHUB_WIKI_LINKS" value="true" />
|
||||
<option name="GITLAB_EXT" value="false" />
|
||||
<option name="GITLAB_MATH_EXT" value="false" />
|
||||
<option name="GITLAB_MERMAID_EXT" value="false" />
|
||||
<option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
|
||||
<option name="JEKYLL_FRONT_MATTER" value="false" />
|
||||
<option name="MACROS_EXT" value="false" />
|
||||
<option name="NO_TEXT_ATTRIBUTES" value="false" />
|
||||
<option name="PARSE_HTML_ANCHOR_ID" value="false" />
|
||||
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
|
||||
</ParserOptions>
|
||||
</ParserSettings>
|
||||
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false" addDocTypeHtml="true">
|
||||
<GeneratorProvider>
|
||||
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
|
||||
</GeneratorProvider>
|
||||
<headerTop />
|
||||
<headerBottom />
|
||||
<bodyTop />
|
||||
<bodyBottom />
|
||||
</HtmlSettings>
|
||||
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="false" isCssTextEnabled="false" isDynamicPageWidth="true">
|
||||
<StylesheetProvider>
|
||||
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
|
||||
</StylesheetProvider>
|
||||
<ScriptProviders />
|
||||
<cssText />
|
||||
<cssUriHistory />
|
||||
</CssSettings>
|
||||
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
|
||||
<LinkMapSettings>
|
||||
<textMaps />
|
||||
</LinkMapSettings>
|
||||
</component>
|
||||
</project>
|
3
.idea/markdown-navigator/profiles_settings.xml
Normal file
3
.idea/markdown-navigator/profiles_settings.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<component name="MarkdownNavigator.ProfileManager">
|
||||
<settings default="" pdf-export="" />
|
||||
</component>
|
18
.idea/misc.xml
Executable file
18
.idea/misc.xml
Executable file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="ignoredFiles">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
11
.idea/modules.xml
Executable file
11
.idea/modules.xml
Executable file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/BuildConfigUpdater/BuildConfigUpdater.iml" filepath="$PROJECT_DIR$/BuildConfigUpdater/BuildConfigUpdater.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml" filepath="$PROJECT_DIR$/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml" filepath="$PROJECT_DIR$/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/ButtonProcessor/ButtonProcessor.iml" filepath="$PROJECT_DIR$/ButtonProcessor/ButtonProcessor.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal 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
Executable file
6
.idea/vcs.xml
Executable file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
17
.travis.yml
17
.travis.yml
|
@ -9,13 +9,18 @@ before_install: | # Wget BuildTools and run if cached folder not found
|
|||
fi
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk11
|
||||
- oraclejdk8
|
||||
sudo: true
|
||||
deploy:
|
||||
- provider: releases
|
||||
api_key:
|
||||
secure: "T/ITeRn4JSx4HS4n44P7vy03HWmJGVpYeR6tABu8qOLrwz2MUCFu8xvYqoq4MiqIKqFIKtZHgCSWiB1WsTIJPHm9S2xYs0BFocoQDthE+eCtT2wgCHj/xdo0wBm8uktXr2hxRF5Nd2R/mfSLkoVxAM6otOoSa1SidRGKgDCJxRnsgssk5igQR+tpahZYPvuzM5xJ4G6J07cC+HHM7RLYXkkKrsK3LFugTsnNtctwmxQkm6SqzDcc8YPwoJGhj8PLbXc5S8/KaWT0//LNdypnzeIaRv+aY+ky/zLntXlw3EFOk4erTthAEMSu2x6PgX5B/paMawdwnqKul/L4ynMGojrLH8ha9KM7p/lze2bxCaf08RFVFvTQt6yzmvM1suL4KH6gAF4mKhyaU0kBeOsnTTskoxyGxvbZgdo0Y1V+Yd7w58eu8zfxnauaX7f2DEz7gH4qkSl+hC7HAFoY7m7IXkgVN6Vuv3lGdFO5S15lbGoihOPqt9T79lBxi/efiXEE4BmA1g8MeLsyN8N/EO+LqVr6xXAKJet6YtOAe/iIAqxpNDSuME1szusc6+4q3jOy6cPmB1TKsfnIKQmbT98SHc9wE4/76VLd2PlNPppa0AIG/g+qnjhjpFQxB7LnWdP+D6io9N1FYrvoOX8UVAp4XYhwUMNLUInDT/6P6j8lL7A="
|
||||
file: 'Chroma-Core/target/Chroma-Core.jar'
|
||||
# deploy develop to the staging environment
|
||||
- provider: script
|
||||
script: chmod +x deploy.sh && sh deploy.sh staging
|
||||
on:
|
||||
tags: true
|
||||
branch: dev
|
||||
skip_cleanup: true
|
||||
# deploy master to production
|
||||
- provider: script
|
||||
script: chmod +x deploy.sh && sh deploy.sh production
|
||||
on:
|
||||
branch: master
|
||||
skip_cleanup: true
|
||||
|
|
32
BuildConfigUpdater/BuildConfigUpdater.iml
Normal file
32
BuildConfigUpdater/BuildConfigUpdater.iml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<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" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mockito:mockito-core:2.7.20" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: net.bytebuddy:byte-buddy:1.6.11" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: net.bytebuddy:byte-buddy-agent:1.6.11" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.objenesis:objenesis:2.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" />
|
||||
</component>
|
||||
</module>
|
43
BuildConfigUpdater/pom.xml
Normal file
43
BuildConfigUpdater/pom.xml
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?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">
|
||||
<parent>
|
||||
<artifactId>ButtonCore</artifactId>
|
||||
<groupId>com.github.TBMCPlugins</groupId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>BuildConfigUpdater</artifactId>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>Jitpack</id>
|
||||
<url>https://jitpack.io/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||
<artifactId>ButtonCore</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency> <!-- Needed for TBMCCoreAPI -->
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
16
BuildConfigUpdater/src/main/java/BCUMain.java
Normal file
16
BuildConfigUpdater/src/main/java/BCUMain.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
import buttondevteam.component.updater.PluginUpdater;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BCUMain {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Getting list of repositories...");
|
||||
List<String> plugins = PluginUpdater.GetPluginNames();
|
||||
System.out.println("Removing non-Maven projects...");
|
||||
plugins.removeIf(plugin -> PluginUpdater.isNotMaven(plugin, "master"));
|
||||
System.out.println(plugins.stream().collect(Collectors.joining("\n")));
|
||||
for (String plugin : plugins) { //TODO: We don't want to apply it all at once, especially to unused/unowned repos
|
||||
} //TODO: Add it to ButtonCore - or actually as a plugin or ButtonProcessor
|
||||
}
|
||||
}
|
2
ButtonCore/.factorypath
Executable file
2
ButtonCore/.factorypath
Executable file
|
@ -0,0 +1,2 @@
|
|||
<factorypath>
|
||||
</factorypath>
|
4
.gitignore → ButtonCore/.gitignore
vendored
4
.gitignore → ButtonCore/.gitignore
vendored
|
@ -220,8 +220,8 @@ pip-log.txt
|
|||
TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar
|
||||
*.iml
|
||||
*.name
|
||||
.idea
|
||||
dependency-reduced-pom.xml
|
||||
.idea/compiler.xml
|
||||
*.xml
|
||||
|
||||
TBMC/
|
||||
/.apt_generated/
|
23
ButtonCore/.project
Executable file
23
ButtonCore/.project
Executable file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ButtonCore</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
6
ButtonCore/.settings/org.eclipse.core.resources.prefs
Executable file
6
ButtonCore/.settings/org.eclipse.core.resources.prefs
Executable file
|
@ -0,0 +1,6 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
encoding/src=UTF-8
|
4
ButtonCore/.settings/org.eclipse.jdt.apt.core.prefs
Executable file
4
ButtonCore/.settings/org.eclipse.jdt.apt.core.prefs
Executable file
|
@ -0,0 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.apt.aptEnabled=true
|
||||
org.eclipse.jdt.apt.genSrcDir=.apt_generated
|
||||
org.eclipse.jdt.apt.reconcileEnabled=true
|
14
ButtonCore/.settings/org.eclipse.jdt.core.prefs
Executable file
14
ButtonCore/.settings/org.eclipse.jdt.core.prefs
Executable file
|
@ -0,0 +1,14 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=enabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
4
ButtonCore/.settings/org.eclipse.m2e.core.prefs
Executable file
4
ButtonCore/.settings/org.eclipse.m2e.core.prefs
Executable file
|
@ -0,0 +1,4 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
2
ButtonCore/README.md
Executable file
2
ButtonCore/README.md
Executable file
|
@ -0,0 +1,2 @@
|
|||
# ButtonCore
|
||||
A plugin that serves as a container for things common to many of our plugins
|
|
@ -1,226 +1,200 @@
|
|||
<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>
|
||||
<parent>
|
||||
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
||||
<artifactId>CorePOM</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<relativePath>../CorePOM</relativePath>
|
||||
</parent>
|
||||
<artifactId>Chroma-Core</artifactId>
|
||||
<name>Chroma-Core</name>
|
||||
<description>Chroma-Core</description>
|
||||
<version>v${noprefix.version}-SNAPSHOT</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>*.properties</include>
|
||||
<include>*.yml</include>
|
||||
<include>*.csv</include>
|
||||
<include>*.txt</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>Chroma-Core</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>me.lucko:commodore</include>
|
||||
<include>org.javatuples:javatuples</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>me.lucko.commodore</pattern>
|
||||
<!-- vvv Replace with the package of your plugin vvv -->
|
||||
<shadedPattern>buttondevteam.core.commodore</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>target</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M3</version>
|
||||
<configuration>
|
||||
<useSystemClassLoader>false
|
||||
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io/</url>
|
||||
</repository>
|
||||
<!-- <repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository> -->
|
||||
<repository>
|
||||
<id>ess-repo</id>
|
||||
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Multiverse-Core</id>
|
||||
<url>https://repo.onarandombox.com/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>minecraft-repo</id>
|
||||
<url>https://libraries.minecraft.net/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.10.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TownyAdvanced</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
<version>0.94.0.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.milkbowl</groupId> <!-- net.milkbowl.vault -->
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>master-SNAPSHOT</version> <!-- 1.6 -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>3.28.0-GA</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
||||
<artifactId>ButtonProcessor</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.17.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.NuVotifier.NuVotifier/nuvotifier-bukkit -->
|
||||
<dependency>
|
||||
<groupId>com.github.NuVotifier.NuVotifier</groupId>
|
||||
<artifactId>nuvotifier-bukkit</artifactId>
|
||||
<version>v2.7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.lucko</groupId>
|
||||
<artifactId>commodore</artifactId>
|
||||
<version>1.11</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.javatuples</groupId>
|
||||
<artifactId>javatuples</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<organization>
|
||||
<name>TBMCPlugins</name>
|
||||
<url>https://github.com/TBMCPlugins</url>
|
||||
</organization>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo/${project.name}</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<noprefix.version>1.0.1</noprefix.version>
|
||||
</properties>
|
||||
<scm>
|
||||
<url>https://github.com/TBMCPlugins/mvn-repo</url>
|
||||
<connection>scm:git:https://github.com/TBMCPlugins/mvn-repo.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/TBMCPlugins/mvn-repo.git</developerConnection>
|
||||
</scm>
|
||||
</project>
|
||||
<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>
|
||||
<parent>
|
||||
<groupId>com.github.TBMCPlugins</groupId>
|
||||
<artifactId>ButtonCore</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||
<artifactId>ButtonCore</artifactId>
|
||||
<name>ButtonCore</name>
|
||||
<description>ButtonCore</description>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>*.properties</include>
|
||||
<include>*.yml</include>
|
||||
<include>*.csv</include>
|
||||
<include>*.txt</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>ButtonCore</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.4.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>target</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<useSystemClassLoader>false
|
||||
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>ess-repo</id>
|
||||
<url>http://repo.ess3.net/content/repositories/essrel/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.10</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Change jitpack.yml to set location of Towny JAR -->
|
||||
<dependency>
|
||||
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.milkbowl</groupId> <!-- net.milkbowl.vault -->
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>master-SNAPSHOT</version> <!-- 1.6 -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>3.20.0-GA</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>2.7.20</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.16.16</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||
<artifactId>ButtonProcessor</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>Essentials</artifactId>
|
||||
<version>2.13.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<organization>
|
||||
<name>TBMCPlugins</name>
|
||||
<url>https://github.com/TBMCPlugins</url>
|
||||
</organization>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo/${project.name}</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<scm>
|
||||
<url>https://github.com/TBMCPlugins/mvn-repo</url>
|
||||
<connection>scm:git:https://github.com/TBMCPlugins/mvn-repo.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/TBMCPlugins/mvn-repo.git</developerConnection>
|
||||
</scm>
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package buttondevteam.component.commands;
|
||||
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
|
||||
public class CommandComponent extends Component { //TODO: Do we just move everything here?
|
||||
@Override
|
||||
public void enable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package buttondevteam.component.restart;
|
||||
|
||||
import buttondevteam.core.PrimeRestartCommand;
|
||||
import buttondevteam.core.ScheduledRestartCommand;
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
|
||||
public class RestartComponent extends Component {
|
||||
@Override
|
||||
public void enable() {
|
||||
//TODO: Permissions for the commands
|
||||
TBMCChatAPI.AddCommand(getPlugin(), ScheduledRestartCommand.class);
|
||||
TBMCChatAPI.AddCommand(getPlugin(), PrimeRestartCommand.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
}
|
195
ButtonCore/src/main/java/buttondevteam/component/updater/PluginUpdater.java
Executable file
195
ButtonCore/src/main/java/buttondevteam/component/updater/PluginUpdater.java
Executable file
|
@ -0,0 +1,195 @@
|
|||
package buttondevteam.component.updater;
|
||||
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class PluginUpdater {
|
||||
private PluginUpdater() {
|
||||
}
|
||||
|
||||
public static final File updatedir = new File("TBMC", "pluginupdates");
|
||||
/**
|
||||
* See {@link TBMCCoreAPI#UpdatePlugin(String, CommandSender, String)}
|
||||
*/
|
||||
public static boolean UpdatePlugin(String name, CommandSender sender, String branch) {
|
||||
if (!updatedir.exists() && !updatedir.mkdirs()) {
|
||||
error(sender, "Failed to create update directory!");
|
||||
return false;
|
||||
}
|
||||
info(sender, "Checking plugin name...");
|
||||
List<String> plugins = GetPluginNames();
|
||||
String correctname = null;
|
||||
for (String plugin : plugins) {
|
||||
if (plugin.equalsIgnoreCase(name)) {
|
||||
correctname = plugin; // Fixes capitalization
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (correctname == null) {
|
||||
error(sender, "Can't find plugin: " + name);
|
||||
return false;
|
||||
}
|
||||
info(sender, "Checking branch name...");
|
||||
if (!TBMCCoreAPI.IsTestServer() && !branch.equalsIgnoreCase("master")) {
|
||||
error(sender, "The server is in production mode, updating only allowed from master!");
|
||||
return false;
|
||||
}
|
||||
Optional<String> correctbranch = GetPluginBranches(correctname).stream().filter(b -> b.equalsIgnoreCase(branch))
|
||||
.findAny();
|
||||
if (!correctbranch.isPresent()) {
|
||||
error(sender, "Can't find branch \"" + branch + "\" for plugin \"" + correctname + "\"");
|
||||
return false;
|
||||
}
|
||||
if (isNotMaven(correctname, correctbranch.get())) {
|
||||
error(sender, "The plugin doesn't appear to have a pom.xml. Make sure it's a Maven project.");
|
||||
return false;
|
||||
}
|
||||
info(sender, "Updating TBMC plugin: " + correctname + " from " + correctbranch.get());
|
||||
return updatePluginJitPack(sender, correctname, correctbranch.get());
|
||||
}
|
||||
|
||||
private static boolean updatePluginJitPack(CommandSender sender, String correctname,
|
||||
String correctbranch) {
|
||||
URL url;
|
||||
File result = new File(updatedir, correctname + ".jar");
|
||||
try {
|
||||
url = new URL("https://jitpack.io/com/github/TBMCPlugins/"
|
||||
+ (correctname.equals("ButtonCore") ? "ButtonCore/ButtonCore" : correctname) + "/"
|
||||
+ correctbranch + "-SNAPSHOT/" + correctname + "-" + correctbranch + "-SNAPSHOT.jar"); // ButtonCore exception required since it hosts Towny as well
|
||||
FileUtils.copyURLToFile(url, result);
|
||||
if (!result.exists() || result.length() < 25) {
|
||||
result.delete();
|
||||
error(sender, "The downloaded JAR for " + correctname + " from " + correctbranch
|
||||
+ " is too small (smnaller than 25 bytes). Am I downloading from the right place?");
|
||||
return false;
|
||||
} else {
|
||||
info(sender, "Updating plugin " + correctname + " from " + correctbranch + " done!");
|
||||
return true;
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
error(sender,
|
||||
"Can't find JAR for " + correctname + " from " + correctbranch
|
||||
+ ", the build probably failed. Build log (scroll to bottom):" + "\n"
|
||||
+ "https://jitpack.io/com/github/TBMCPlugins/" + correctname + "/" + correctbranch
|
||||
+ "-SNAPSHOT/build.log\nIf you'd like to rebuild the same commit, go to:\nhttps://jitpack.io/#TBMCPlugins/"
|
||||
+ correctname + "\nAnd delete the newest build.");
|
||||
} catch (IOException e) {
|
||||
error(sender, "IO error while updating " + correctname + "\n" + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
error(sender, "Unknown error while updating " + correctname + ": " + e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if pom.xml is not present for the project.
|
||||
*
|
||||
* @param pluginname
|
||||
* Does not have to match case
|
||||
* @param branch
|
||||
* Does not have to match case
|
||||
*/
|
||||
public static boolean isNotMaven(String pluginname, String branch) {
|
||||
try {
|
||||
return TBMCCoreAPI
|
||||
.DownloadString(
|
||||
"https://raw.githubusercontent.com/TBMCPlugins/" + pluginname + "/" + branch + "/pom.xml")
|
||||
.equals("404: Not Found\n");
|
||||
} catch (IOException e1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void error(CommandSender sender, String message) {
|
||||
if (!sender.equals(Bukkit.getConsoleSender()))
|
||||
Bukkit.getLogger().warning(message);
|
||||
sender.sendMessage("§c" + message);
|
||||
}
|
||||
|
||||
private static void info(CommandSender sender, String message) {
|
||||
if (!sender.equals(Bukkit.getConsoleSender()))
|
||||
Bukkit.getLogger().info(message);
|
||||
sender.sendMessage("§b" + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all the repository names from the GitHub organization.
|
||||
*
|
||||
* @return A list of names
|
||||
*/
|
||||
public static List<String> GetPluginNames() {
|
||||
List<String> ret = new ArrayList<>();
|
||||
try {
|
||||
String resp = TBMCCoreAPI.DownloadString("https://api.github.com/orgs/" + "TBMCPlugins" + "/repos"); //TODO: PluginUpdater
|
||||
JsonArray arr = new JsonParser().parse(resp).getAsJsonArray();
|
||||
for (JsonElement obj : arr) {
|
||||
JsonObject jobj = obj.getAsJsonObject();
|
||||
ret.add(jobj.get("name").getAsString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all the branches from the plugin repository.
|
||||
*
|
||||
* @return A list of names
|
||||
*/
|
||||
public static List<String> GetPluginBranches(String plugin) {
|
||||
List<String> ret = new ArrayList<>();
|
||||
try {
|
||||
String resp = TBMCCoreAPI
|
||||
.DownloadString("https://api.github.com/repos/TBMCPlugins/" + plugin + "/branches");
|
||||
JsonArray arr = new JsonParser().parse(resp).getAsJsonArray();
|
||||
for (JsonElement obj : arr) {
|
||||
JsonObject jobj = obj.getAsJsonObject();
|
||||
ret.add(jobj.get("name").getAsString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static class UpdatedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final JsonObject data;
|
||||
|
||||
public UpdatedEvent(JsonObject data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public JsonObject getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package buttondevteam.component.updater;
|
||||
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
|
||||
public class PluginUpdaterComponent extends Component {
|
||||
@Override
|
||||
public void enable() {
|
||||
TBMCChatAPI.AddCommand(getPlugin(), UpdatePluginCommand.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() { //TODO: Unregister commands and such
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package buttondevteam.component.updater;
|
||||
|
||||
import buttondevteam.core.MainPlugin;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandClass(modOnly = true)
|
||||
public class UpdatePluginCommand extends TBMCCommandBase {
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, () -> {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("Downloading plugin names...");
|
||||
boolean first = true;
|
||||
for (String plugin : PluginUpdater.GetPluginNames()) {
|
||||
if (first) {
|
||||
sender.sendMessage("§6---- Plugin names ----");
|
||||
first = false;
|
||||
}
|
||||
sender.sendMessage("- " + plugin);
|
||||
}
|
||||
} else {
|
||||
TBMCCoreAPI.UpdatePlugin(args[0], sender, args.length == 1 ? "master" : args[1]);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[] { //
|
||||
"§6---- Update plugin ----", //
|
||||
"This command downloads the latest version of a TBMC plugin from GitHub", //
|
||||
"To update a plugin: /" + alias + " <plugin>", //
|
||||
"To list the plugin names: /" + alias //
|
||||
};
|
||||
}
|
||||
}
|
88
ButtonCore/src/main/java/buttondevteam/core/CommandCaller.java
Executable file
88
ButtonCore/src/main/java/buttondevteam/core/CommandCaller.java
Executable file
|
@ -0,0 +1,88 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CommandCaller implements CommandExecutor {
|
||||
|
||||
private CommandCaller() {
|
||||
}
|
||||
|
||||
private static CommandCaller instance;
|
||||
|
||||
public static void RegisterCommand(TBMCCommandBase cmd) throws Exception {
|
||||
if (instance == null)
|
||||
instance = new CommandCaller();
|
||||
String topcmd = cmd.GetCommandPath();
|
||||
if (topcmd == null)
|
||||
throw new Exception("Command " + cmd.getClass().getSimpleName() + " has no command path!");
|
||||
if (cmd.getPlugin() == null)
|
||||
throw new Exception("Command " + cmd.GetCommandPath() + " has no plugin!");
|
||||
int i;
|
||||
if ((i = topcmd.indexOf(' ')) != -1) // Get top-level command
|
||||
topcmd = topcmd.substring(0, i);
|
||||
{
|
||||
PluginCommand pc = ((JavaPlugin) cmd.getPlugin()).getCommand(topcmd);
|
||||
if (pc == null)
|
||||
throw new Exception("Top level command " + topcmd + " not registered in plugin.yml for plugin: "
|
||||
+ cmd.getPlugin().getName());
|
||||
else {
|
||||
pc.setExecutor(instance);
|
||||
String[] helptext = cmd.GetHelpText(topcmd);
|
||||
if (helptext == null || helptext.length == 0)
|
||||
throw new Exception("Command " + cmd.GetCommandPath() + " has no help text!");
|
||||
pc.setUsage(helptext.length > 1 ? helptext[1] : helptext[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
|
||||
String path = command.getName().toLowerCase();
|
||||
for (String arg : args)
|
||||
path += " " + arg;
|
||||
TBMCCommandBase cmd = TBMCChatAPI.GetCommands().get(path);
|
||||
int argc = 0;
|
||||
String[] subcmds = null;
|
||||
while (cmd == null && (subcmds = TBMCChatAPI.GetSubCommands(path, sender)).length == 0 && path.contains(" ")) {
|
||||
path = path.substring(0, path.lastIndexOf(' '));
|
||||
argc++;
|
||||
cmd = TBMCChatAPI.GetCommands().get(path);
|
||||
}
|
||||
if (cmd == null) {
|
||||
if (subcmds.length > 0) //Subcmds will always have value here (see assignment above)
|
||||
sender.sendMessage(subcmds);
|
||||
else {
|
||||
final String errormsg = "§cYou don't have access to any of this command's subcommands or it doesn't have any.";
|
||||
sender.sendMessage(errormsg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (cmd.isModOnly() && (MainPlugin.permission != null ? !MainPlugin.permission.has(sender, "tbmc.admin") : !sender.isOp())) {
|
||||
sender.sendMessage("§cYou need to be a mod to use this command.");
|
||||
return true;
|
||||
}
|
||||
final String[] cmdargs = args.length > 0 ? Arrays.copyOfRange(args, args.length - argc, args.length) : args;
|
||||
try {
|
||||
if (!cmd.OnCommand(sender, alias, cmdargs)) {
|
||||
if (cmd.GetHelpText(alias) == null) {
|
||||
sender.sendMessage("Wrong usage, but there's no help text! Error is being reported to devs.");
|
||||
throw new NullPointerException("GetHelpText is null for comand /" + cmd.GetCommandPath());
|
||||
} else
|
||||
sender.sendMessage(cmd.GetHelpText(alias));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("Failed to execute command /" + cmd.GetCommandPath() + " with arguments "
|
||||
+ Arrays.toString(cmdargs), e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandClass(modOnly = true)
|
||||
public class ComponentCommand extends TBMCCommandBase {
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
if (args.length < 2)
|
||||
return false;
|
||||
switch (args[0]) {
|
||||
case "enable":
|
||||
break;
|
||||
case "disable":
|
||||
break;
|
||||
case "list":
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.architecture.ButtonPlugin;
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
import lombok.val;
|
||||
|
||||
|
@ -21,24 +20,28 @@ public final class ComponentManager {
|
|||
*/
|
||||
public static void enableComponents() {
|
||||
//Component.getComponents().values().stream().filter(c->cs.getConfigurationSection(c.getClass().getSimpleName()).getBoolean("enabled")).forEach(c-> {
|
||||
Component.getComponents().values().stream().filter(c -> c.shouldBeEnabled.get()).forEach(c -> {
|
||||
Component.getComponents().values().stream().filter(c -> c.shouldBeEnabled().get()).forEach(c -> {
|
||||
try {
|
||||
Component.setComponentEnabled(c, true);
|
||||
} catch (Exception | NoClassDefFoundError e) {
|
||||
TBMCCoreAPI.SendException("Failed to enable one of the components: " + c.getClass().getSimpleName(), e, c);
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("Failed to enable one of the components: " + c.getClass().getSimpleName(), e);
|
||||
}
|
||||
});
|
||||
componentsEnabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister all components of a plugin that are enabled - called on {@link ButtonPlugin} disable
|
||||
* Disables all components that are enabled
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends ButtonPlugin> void unregComponents(T plugin) {
|
||||
while (!plugin.getComponentStack().empty()) //Unregister in reverse order
|
||||
Component.unregisterComponent(plugin, (Component<T>) plugin.getComponentStack().pop()); //Components are pushed on register
|
||||
//componentsEnabled = false; - continue enabling new components after a plugin gets disabled
|
||||
public static void disableComponents() {
|
||||
Component.getComponents().values().stream().filter(Component::isEnabled).forEach(c -> {
|
||||
try {
|
||||
Component.setComponentEnabled(c, false);
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("Failed to disable one of the components: " + c.getClass().getSimpleName(), e);
|
||||
}
|
||||
});
|
||||
componentsEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,16 +54,4 @@ public final class ComponentManager {
|
|||
val c = Component.getComponents().get(cl);
|
||||
return c != null && c.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Will also return null if the component is not registered.
|
||||
*
|
||||
* @param cl The component class
|
||||
* @return The component if it's registered and enabled
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Component> T getIfEnabled(Class<T> cl) {
|
||||
val c = Component.getComponents().get(cl);
|
||||
return c != null && c.isEnabled() ? (T) c : null;
|
||||
}
|
||||
}
|
117
ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java
Executable file
117
ButtonCore/src/main/java/buttondevteam/core/MainPlugin.java
Executable file
|
@ -0,0 +1,117 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.component.restart.RestartComponent;
|
||||
import buttondevteam.component.updater.PluginUpdater;
|
||||
import buttondevteam.component.updater.PluginUpdaterComponent;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import buttondevteam.lib.chat.ChatRoom;
|
||||
import buttondevteam.lib.chat.Color;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
import buttondevteam.lib.player.ChromaGamerBase;
|
||||
import buttondevteam.lib.player.TBMCPlayer;
|
||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MainPlugin extends JavaPlugin {
|
||||
public static MainPlugin Instance;
|
||||
@Nullable
|
||||
public static Permission permission;
|
||||
public static boolean Test;
|
||||
public static Essentials ess;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Logs "Plugin Enabled", registers commands
|
||||
Instance = this;
|
||||
PluginDescriptionFile pdf = getDescription();
|
||||
logger = getLogger();
|
||||
setupPermissions();
|
||||
Test = getConfig().getBoolean("test", true);
|
||||
saveConfig();
|
||||
Component.registerComponent(this, new PluginUpdaterComponent());
|
||||
Component.registerComponent(this, new RestartComponent());
|
||||
ComponentManager.enableComponents();
|
||||
TBMCChatAPI.AddCommand(this, MemberCommand.class);
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
|
||||
ChromaGamerBase.addConverter(commandSender -> Optional.ofNullable(commandSender instanceof ConsoleCommandSender || commandSender instanceof BlockCommandSender
|
||||
? TBMCPlayer.getPlayer(new UUID(0, 0), TBMCPlayer.class) : null)); //Console & cmdblocks
|
||||
ChromaGamerBase.addConverter(sender -> Optional.ofNullable(sender instanceof Player
|
||||
? TBMCPlayer.getPlayer(((Player) sender).getUniqueId(), TBMCPlayer.class) : null)); //Players, has higher priority
|
||||
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class);
|
||||
TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fOOC§f", Color.White, "ooc", null));
|
||||
Channel.GlobalChat.IDs = new String[]{"g"}; //Support /g as well
|
||||
TBMCChatAPI.RegisterChatChannel(
|
||||
Channel.AdminChat = new Channel("§cADMIN§f", Color.Red, "a", Channel.inGroupFilter(null)));
|
||||
TBMCChatAPI.RegisterChatChannel(
|
||||
Channel.ModChat = new Channel("§9MOD§f", Color.Blue, "mod", Channel.inGroupFilter("mod")));
|
||||
TBMCChatAPI.RegisterChatChannel(new Channel("§6DEV§f", Color.Gold, "dev", Channel.inGroupFilter("developer")));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§cRED§f", Color.DarkRed, "red"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§6ORANGE§f", Color.Gold, "orange"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§eYELLOW§f", Color.Yellow, "yellow"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§aGREEN§f", Color.Green, "green"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§bBLUE§f", Color.Blue, "blue"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§5PURPLE§f", Color.DarkPurple, "purple"));
|
||||
try {
|
||||
Files.write(new File("plugins", "plugins.txt").toPath(), Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(p -> (CharSequence) p.getDataFolder().getName())::iterator);
|
||||
} catch (IOException e) {
|
||||
TBMCCoreAPI.SendException("Failed to write plugin list!", e);
|
||||
}
|
||||
ess = Essentials.getPlugin(Essentials.class);
|
||||
new RandomTP().onEnable(this); //It registers it's command
|
||||
logger.info(pdf.getName() + " has been Enabled (V." + pdf.getVersion() + ") Test: " + Test + ".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
ComponentManager.disableComponents();
|
||||
logger.info("Saving player data...");
|
||||
TBMCPlayerBase.savePlayers();
|
||||
logger.info("Player data saved.");
|
||||
new Thread(() -> {
|
||||
File[] files = PluginUpdater.updatedir.listFiles();
|
||||
if (files == null)
|
||||
return;
|
||||
System.out.println("Updating " + files.length + " plugins...");
|
||||
for (File file : files) {
|
||||
try {
|
||||
Files.move(file.toPath(), new File("plugins", file.getName()).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
System.out.println("Updated " + file.getName());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("Update complete!");
|
||||
}).start();
|
||||
}
|
||||
|
||||
private boolean setupPermissions() {
|
||||
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager()
|
||||
.getRegistration(Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
permission = permissionProvider.getProvider();
|
||||
}
|
||||
return (permission != null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import lombok.val;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandClass(modOnly = true, path = "member")
|
||||
public class MemberCommand extends TBMCCommandBase {
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
if (args.length < 2)
|
||||
return false;
|
||||
final boolean add;
|
||||
if (args[0].equalsIgnoreCase("add"))
|
||||
add = true;
|
||||
else if (args[0].equalsIgnoreCase("remove"))
|
||||
add = false;
|
||||
else
|
||||
return false;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, () -> {
|
||||
if (MainPlugin.permission == null) {
|
||||
sender.sendMessage("§cError: No permission plugin found!");
|
||||
return;
|
||||
}
|
||||
val op = Bukkit.getOfflinePlayer(args[1]);
|
||||
if (!op.hasPlayedBefore()) {
|
||||
sender.sendMessage("§cCannot find player or haven't played before.");
|
||||
return;
|
||||
}
|
||||
if (add) {
|
||||
if (MainPlugin.permission.playerAddGroup(null, op, "member"))
|
||||
sender.sendMessage("§b" + op.getName() + " added as a member!");
|
||||
else
|
||||
sender.sendMessage("§cFailed to add " + op.getName() + " as a member!");
|
||||
} else {
|
||||
if (MainPlugin.permission.playerRemoveGroup(null, op, "member"))
|
||||
sender.sendMessage("§b" + op.getName() + " removed as a member!");
|
||||
else
|
||||
sender.sendMessage("§bFailed to remove " + op.getName() + " as a member!");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[]{ //
|
||||
"06---- Member ----", //
|
||||
"Add or remove server members.", //
|
||||
"Usage: /member <add|remove> <player>" //
|
||||
};
|
||||
}
|
||||
}
|
61
ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java
Executable file
61
ButtonCore/src/main/java/buttondevteam/core/PlayerListener.java
Executable file
|
@ -0,0 +1,61 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.lib.TBMCSystemChatEvent;
|
||||
import buttondevteam.lib.chat.IFakePlayer;
|
||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
|
||||
import static buttondevteam.core.MainPlugin.permission;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void OnPlayerJoin(PlayerJoinEvent event) {
|
||||
TBMCPlayerBase.joinPlayer(event.getPlayer());
|
||||
if (permission != null && !permission.playerInGroup(event.getPlayer(), "member")
|
||||
&& (new Date(event.getPlayer().getFirstPlayed()).toInstant().plus(7, ChronoUnit.DAYS).isBefore(Instant.now())
|
||||
|| event.getPlayer().getStatistic(Statistic.PLAY_ONE_TICK) > 20 * 3600 * 12)) {
|
||||
permission.playerAddGroup(null, event.getPlayer(), "member");
|
||||
event.getPlayer().sendMessage("§bYou are a member now. YEEHAW");
|
||||
MainPlugin.Instance.getLogger().info("Added " + event.getPlayer().getName() + " as a member.");
|
||||
}
|
||||
}
|
||||
|
||||
private long lasttime = 0;
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void OnPlayerLeave(PlayerQuitEvent event) {
|
||||
TBMCPlayerBase.quitPlayer(event.getPlayer());
|
||||
if (PrimeRestartCommand.isPlsrestart()
|
||||
&& !event.getQuitMessage().equalsIgnoreCase("Server closed")
|
||||
&& !event.getQuitMessage().equalsIgnoreCase("Server is restarting")) {
|
||||
if (Bukkit.getOnlinePlayers().size() <= 1) {
|
||||
if (PrimeRestartCommand.isLoud())
|
||||
Bukkit.broadcastMessage("§cNobody is online anymore. Restarting.");
|
||||
Bukkit.spigot().restart();
|
||||
} else if (!(event.getPlayer() instanceof IFakePlayer) && System.nanoTime() - 10 * 1000000000L - lasttime > 0) { //Ten seconds passed since last reminder
|
||||
lasttime = System.nanoTime();
|
||||
if (PrimeRestartCommand.isLoud())
|
||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onSystemChat(TBMCSystemChatEvent event) {
|
||||
if (event.isHandled())
|
||||
return; // Only handle here if ButtonChat couldn't
|
||||
Bukkit.getOnlinePlayers().stream().filter(event::shouldSendTo)
|
||||
.forEach(p -> p.sendMessage(event.getChannel().DisplayName.substring(0, 2) + event.getMessage()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandClass(path = "primerestart", modOnly = true)
|
||||
public class PrimeRestartCommand extends TBMCCommandBase {
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
loud = args.length > 0;
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
sender.sendMessage("§bPlayers online, restart delayed.");
|
||||
if (loud)
|
||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "The server will restart as soon as nobody is online.");
|
||||
plsrestart = true;
|
||||
} else {
|
||||
sender.sendMessage("§bNobody is online. Restarting now.");
|
||||
if (loud)
|
||||
Bukkit.broadcastMessage("§cNobody is online. Restarting server.");
|
||||
Bukkit.spigot().restart();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private static boolean plsrestart = false;
|
||||
@Getter
|
||||
private static boolean loud = false;
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[]{ //
|
||||
"§6---- Prime restart ----", //
|
||||
"Restarts the server as soon as nobody is online.", //
|
||||
"To be loud, type something after, like /primerestart lol (it doesn't matter what you write)", //
|
||||
"To be silent, don't type anything" //
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,20 +1,16 @@
|
|||
package buttondevteam.core.component.randomtp;
|
||||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.lib.chat.Command2;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.ICommand2MC;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
// @formatter:off
|
||||
@SuppressWarnings("FieldCanBeLocal")@CommandClass(helpText = {
|
||||
"§6---- Random Teleport ----",
|
||||
"Teleport player to random location within world border. Every five players teleport to the same general area, and then a new general area is randomly selected for the next five players."
|
||||
})
|
||||
public class RandomTP extends ICommand2MC
|
||||
@CommandClass
|
||||
public class RandomTP extends TBMCCommandBase
|
||||
{
|
||||
private final int radius = 70; //set how far apart the five teleport positions are
|
||||
|
||||
|
@ -55,22 +51,33 @@ public class RandomTP extends ICommand2MC
|
|||
|
||||
/*================================================================================================*/
|
||||
|
||||
public void onEnable(RandomTPComponent component)
|
||||
public void onEnable(JavaPlugin plugin)
|
||||
{
|
||||
TBMCChatAPI.AddCommand(plugin, this);
|
||||
|
||||
world = Bukkit.getWorld("World");
|
||||
border = world.getWorldBorder();
|
||||
component.log("Getting new location");
|
||||
if(border.getSize() > 100000)
|
||||
component.logWarn("World border is wide, it may take a minute...");
|
||||
component.log("Success: "+newLocation());
|
||||
newLocation();
|
||||
}
|
||||
|
||||
/*================================================================================================*/
|
||||
|
||||
public String[] GetHelpText(String alias)
|
||||
{
|
||||
return new String[]
|
||||
{
|
||||
"§6---- Random Teleport ----",
|
||||
"Teleport player to random location within world border. Every five players teleport to the same general area, and then a new general area is randomly selected for the next five players."
|
||||
};
|
||||
}
|
||||
|
||||
/*================================================================================================*/
|
||||
|
||||
@Command2.Subcommand
|
||||
public boolean def(CommandSender sender, Player player)
|
||||
|
||||
public boolean OnCommand(CommandSender sender, String command, String[] args)
|
||||
{
|
||||
if (sender.isOp()) return rtp(player);
|
||||
if (args.length == 0) return false;
|
||||
|
||||
if (sender.isOp()) return rtp(Bukkit.getPlayer(args[0]));
|
||||
|
||||
else sender.sendMessage("§7 hmm, " + sender.getName() + "... " + sender.getName() + "... nope, no operator permissions.");
|
||||
|
65
ButtonCore/src/main/java/buttondevteam/core/ScheduledRestartCommand.java
Executable file
65
ButtonCore/src/main/java/buttondevteam/core/ScheduledRestartCommand.java
Executable file
|
@ -0,0 +1,65 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.lib.ScheduledServerRestartEvent;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@CommandClass(modOnly = true, path = "schrestart")
|
||||
public class ScheduledRestartCommand extends TBMCCommandBase {
|
||||
private static volatile int restartcounter;
|
||||
private static volatile BukkitTask restarttask;
|
||||
private static volatile BossBar restartbar;
|
||||
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
int ticks = 20 * 60;
|
||||
try {
|
||||
if (args.length > 0)
|
||||
ticks = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage("§cError: Ticks must be a number.");
|
||||
return false;
|
||||
}
|
||||
if (ticks < 20) {
|
||||
sender.sendMessage("§cError: Ticks must be more than 20.");
|
||||
return false;
|
||||
}
|
||||
final int restarttime = restartcounter = ticks;
|
||||
restartbar = Bukkit.createBossBar("Server restart in " + ticks / 20f + "s", BarColor.RED, BarStyle.SOLID,
|
||||
BarFlag.DARKEN_SKY);
|
||||
restartbar.setProgress(1);
|
||||
Bukkit.getOnlinePlayers().forEach(p -> restartbar.addPlayer(p));
|
||||
sender.sendMessage("Scheduled restart in " + ticks / 20f);
|
||||
ScheduledServerRestartEvent e = new ScheduledServerRestartEvent(ticks);
|
||||
Bukkit.getPluginManager().callEvent(e);
|
||||
restarttask = Bukkit.getScheduler().runTaskTimer(MainPlugin.Instance, () -> {
|
||||
if (restartcounter < 0) {
|
||||
restarttask.cancel();
|
||||
restartbar.getPlayers().forEach(p -> restartbar.removePlayer(p));
|
||||
Bukkit.spigot().restart();
|
||||
}
|
||||
if (restartcounter % 200 == 0)
|
||||
Bukkit.broadcastMessage("§c-- The server is restarting in " + restartcounter / 20 + " seconds!");
|
||||
restartbar.setProgress(restartcounter / (double) restarttime);
|
||||
restartbar.setTitle(String.format("Server restart in %.2f", restartcounter / 20f));
|
||||
restartcounter--;
|
||||
}, 1, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[] { //
|
||||
"§6---- Scheduled restart ----", //
|
||||
"This command restarts the server 1 minute after it's executed, warning players every 10 seconds.", //
|
||||
"You can optionally set the amount of ticks to wait before the restart." //
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,15 +1,11 @@
|
|||
package buttondevteam.core;
|
||||
|
||||
import buttondevteam.core.component.channel.Channel;
|
||||
import buttondevteam.core.component.channel.ChannelComponent;
|
||||
import buttondevteam.lib.ChromaUtils;
|
||||
import buttondevteam.lib.architecture.Component;
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import buttondevteam.lib.chat.Color;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
|
@ -20,13 +16,11 @@ import java.util.Collections;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
public class TestPrepare {
|
||||
|
||||
public static void PrepareServer() {
|
||||
ChromaUtils.setTest(); //Needs to be in a separate class because of the potential lack of Mockito
|
||||
Bukkit.setServer(Mockito.mock(Server.class, new Answer<Object>() {
|
||||
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) {
|
||||
public Object answer(InvocationOnMock invocation) {
|
||||
if (returns(invocation, String.class))
|
||||
return "test";
|
||||
if (returns(invocation, Logger.class))
|
||||
|
@ -44,7 +38,6 @@ public class TestPrepare {
|
|||
return cl.isAssignableFrom(invocation.getMethod().getReturnType());
|
||||
}
|
||||
}));
|
||||
Component.registerComponent(Mockito.mock(JavaPlugin.class), new ChannelComponent());
|
||||
TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fg§f", Color.White, "g", null));
|
||||
}
|
||||
}
|
|
@ -1,14 +1,13 @@
|
|||
package buttondevteam.lib;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
class EventExceptionCoreHandler extends EventExceptionHandler {
|
||||
|
||||
@Override
|
||||
public boolean handle(Throwable ex, Event event) {
|
||||
TBMCCoreAPI.SendException("An error occured while executing " + event.getEventName() + "!", ex, false, Bukkit.getLogger()::warning);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
package buttondevteam.lib;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
class EventExceptionCoreHandler extends EventExceptionHandler {
|
||||
|
||||
@Override
|
||||
public boolean handle(Throwable ex, Event event) {
|
||||
TBMCCoreAPI.SendException("An error occured while executing " + event.getEventName() + "!", ex);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +1,20 @@
|
|||
package buttondevteam.lib;
|
||||
|
||||
import buttondevteam.core.component.restart.ScheduledRestartCommand;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class ScheduledServerRestartEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final int restartTicks;
|
||||
private final ScheduledRestartCommand command;
|
||||
private final int restartticks;
|
||||
|
||||
public ScheduledServerRestartEvent(int restartticks) {
|
||||
this.restartticks = restartticks;
|
||||
}
|
||||
|
||||
public int getRestartTicks() {
|
||||
return restartticks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
|
@ -1,6 +1,6 @@
|
|||
package buttondevteam.lib;
|
||||
|
||||
import buttondevteam.core.component.channel.Channel;
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import buttondevteam.lib.chat.ChatMessage;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.Delegate;
|
||||
|
@ -30,6 +30,7 @@ public class TBMCChatEvent extends TBMCChatEventBase {
|
|||
private boolean isIgnoreSenderPermissions() {
|
||||
return cm.getPermCheck() != cm.getSender();
|
||||
}
|
||||
// TODO: Message object with data?
|
||||
|
||||
/**
|
||||
* This will allow the sender of the message if {@link #isIgnoreSenderPermissions()} is true.
|
|
@ -1,8 +1,9 @@
|
|||
package buttondevteam.lib;
|
||||
|
||||
import buttondevteam.core.component.channel.Channel;
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
@ -11,6 +12,7 @@ import org.bukkit.event.Event;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public abstract class TBMCChatEventBase extends Event implements Cancellable {
|
||||
private final Channel channel;
|
||||
private @NonNull String message;
|
||||
|
@ -24,15 +26,6 @@ public abstract class TBMCChatEventBase extends Event implements Cancellable {
|
|||
*/
|
||||
private final String groupID;
|
||||
|
||||
@java.beans.ConstructorProperties({"channel", "message", "score", "groupID"})
|
||||
public TBMCChatEventBase(Channel channel, String message, int score, String groupID) {
|
||||
super(true);
|
||||
this.channel = channel;
|
||||
this.message = message;
|
||||
this.score = score;
|
||||
this.groupID = groupID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: Errors are sent to the sender automatically
|
||||
*/
|
||||
|
@ -54,6 +47,6 @@ public abstract class TBMCChatEventBase extends Event implements Cancellable {
|
|||
*/
|
||||
@Nullable
|
||||
public String getGroupID(CommandSender sender) {
|
||||
return channel.getGroupID(sender);
|
||||
return channel.getGroupID(sender); //TODO: Performance-wise it'd be much better to use serialization for player data - it's only converted once
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package buttondevteam.lib;
|
||||
|
||||
import buttondevteam.core.component.channel.Channel;
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -27,12 +27,15 @@ public class TBMCChatPreprocessEvent extends Event implements Cancellable {
|
|||
private boolean cancelled;
|
||||
|
||||
public TBMCChatPreprocessEvent(CommandSender sender, Channel channel, String message) {
|
||||
super(true);
|
||||
this.sender = sender;
|
||||
this.channel = channel;
|
||||
this.message = message;
|
||||
this.message = message; // TODO: Message object with data?
|
||||
}
|
||||
|
||||
/*
|
||||
* public TBMCPlayer getPlayer() { return TBMCPlayer.getPlayer(sender); // TODO: Get Chroma user }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
188
ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java
Executable file
188
ButtonCore/src/main/java/buttondevteam/lib/TBMCCoreAPI.java
Executable file
|
@ -0,0 +1,188 @@
|
|||
package buttondevteam.lib;
|
||||
|
||||
import buttondevteam.component.updater.PluginUpdater;
|
||||
import buttondevteam.core.MainPlugin;
|
||||
import buttondevteam.lib.player.ChromaGamerBase;
|
||||
import buttondevteam.lib.potato.DebugPotato;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class TBMCCoreAPI {
|
||||
static final List<String> coders = new ArrayList<String>() {
|
||||
private static final long serialVersionUID = -4462159250738367334L;
|
||||
{
|
||||
add("Alisolarflare");
|
||||
add("NorbiPeti");
|
||||
add("iie");
|
||||
add("thewindmillman");
|
||||
add("mayskam1995");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates or installs the specified plugin. The plugin must use Maven.
|
||||
*
|
||||
* @param name
|
||||
* The plugin's repository name.
|
||||
* @param sender
|
||||
* The command sender (if not console, messages will be printed to console as well).
|
||||
*/
|
||||
public static void UpdatePlugin(String name, CommandSender sender) {
|
||||
UpdatePlugin(name, sender, "master");
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates or installs the specified plugin from the specified branch. The plugin must use Maven.
|
||||
*
|
||||
* @param name
|
||||
* The plugin's repository name.
|
||||
* @param sender
|
||||
* The command sender (if not console, messages will be printed to console as well).
|
||||
* @param branch
|
||||
* The branch to download the plugin from.
|
||||
* @return Success or not
|
||||
*/
|
||||
public static boolean UpdatePlugin(String name, CommandSender sender, String branch) {
|
||||
return PluginUpdater.UpdatePlugin(name, sender, branch);
|
||||
}
|
||||
|
||||
public static String DownloadString(String urlstr) throws IOException {
|
||||
URL url = new URL(urlstr);
|
||||
URLConnection con = url.openConnection();
|
||||
con.setRequestProperty("User-Agent", "TBMCPlugins");
|
||||
InputStream in = con.getInputStream();
|
||||
String encoding = con.getContentEncoding();
|
||||
encoding = encoding == null ? "UTF-8" : encoding;
|
||||
String body = IOUtils.toString(in, encoding);
|
||||
in.close();
|
||||
return body;
|
||||
}
|
||||
|
||||
private static final HashMap<String, Throwable> exceptionsToSend = new HashMap<>();
|
||||
private static final List<String> debugMessagesToSend = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Send exception to the {@link TBMCExceptionEvent}.
|
||||
*
|
||||
* @param sourcemsg
|
||||
* A message that is shown at the top of the exception (before the exception's message)
|
||||
* @param e
|
||||
* The exception to send
|
||||
*/
|
||||
public static void SendException(String sourcemsg, Throwable e) {
|
||||
SendException(sourcemsg, e, false);
|
||||
}
|
||||
|
||||
public static void SendException(String sourcemsg, Throwable e, boolean debugPotato) {
|
||||
SendUnsentExceptions();
|
||||
TBMCExceptionEvent event = new TBMCExceptionEvent(sourcemsg, e);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
synchronized (exceptionsToSend) {
|
||||
if (!event.isHandled())
|
||||
exceptionsToSend.put(sourcemsg, e);
|
||||
}
|
||||
Bukkit.getLogger().warning(sourcemsg);
|
||||
e.printStackTrace();
|
||||
if (debugPotato) {
|
||||
List<Player> devsOnline = new ArrayList<Player>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (coders.contains(player.getName())) {
|
||||
devsOnline.add(player);
|
||||
}
|
||||
}
|
||||
if (!devsOnline.isEmpty()) {
|
||||
DebugPotato potato = new DebugPotato()
|
||||
.setMessage(new String[] { //
|
||||
"§b§o" + e.getClass().getSimpleName(), //
|
||||
"§c§o" + sourcemsg, //
|
||||
"§a§oFind a dev to fix this issue" })
|
||||
.setType(e instanceof IOException ? "Throwable Potato"
|
||||
: e instanceof ClassCastException ? "Squished Potato"
|
||||
: e instanceof NullPointerException ? "Plain Potato"
|
||||
: e instanceof StackOverflowError ? "Chips" : "Error Potato");
|
||||
for (Player dev : devsOnline) {
|
||||
potato.Send(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendDebugMessage(String debugMessage) {
|
||||
SendUnsentDebugMessages();
|
||||
TBMCDebugMessageEvent event = new TBMCDebugMessageEvent(debugMessage);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
synchronized (debugMessagesToSend) {
|
||||
if (!event.isSent())
|
||||
debugMessagesToSend.add(debugMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers Bukkit events, handling the exceptions occurring in those events
|
||||
*
|
||||
* @param listener
|
||||
* The class that handles the events
|
||||
* @param plugin
|
||||
* The plugin which the listener belongs to
|
||||
*/
|
||||
public static void RegisterEventsForExceptions(Listener listener, Plugin plugin) {
|
||||
EventExceptionHandler.registerEvents(listener, plugin, new EventExceptionCoreHandler());
|
||||
}
|
||||
|
||||
public static <T extends ChromaGamerBase> void RegisterUserClass(Class<T> userclass) {
|
||||
ChromaGamerBase.RegisterPluginUserClass(userclass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send exceptions that haven't been sent (their events didn't get handled). This method is used by the DiscordPlugin's ready event
|
||||
*/
|
||||
public static void SendUnsentExceptions() {
|
||||
synchronized (exceptionsToSend) {
|
||||
if (exceptionsToSend.size() > 20) {
|
||||
exceptionsToSend.clear(); // Don't call more and more events if all the handler plugins are unloaded
|
||||
Bukkit.getLogger().warning("Unhandled exception list is over 20! Clearing!");
|
||||
}
|
||||
for (Iterator<Entry<String, Throwable>> iterator = exceptionsToSend.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Entry<String, Throwable> entry = iterator.next();
|
||||
TBMCExceptionEvent event = new TBMCExceptionEvent(entry.getKey(), entry.getValue());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isHandled())
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendUnsentDebugMessages() {
|
||||
synchronized (debugMessagesToSend) {
|
||||
if (debugMessagesToSend.size() > 20) {
|
||||
debugMessagesToSend.clear(); // Don't call more and more DebugMessages if all the handler plugins are unloaded
|
||||
Bukkit.getLogger().warning("Unhandled Debug Message list is over 20! Clearing!");
|
||||
}
|
||||
for (Iterator<String> iterator = debugMessagesToSend.iterator(); iterator.hasNext(); ) {
|
||||
String message = iterator.next();
|
||||
TBMCDebugMessageEvent event = new TBMCDebugMessageEvent(message);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isSent())
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean IsTestServer() {
|
||||
return MainPlugin.Test;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package buttondevteam.lib;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
|
@ -10,7 +9,6 @@ public class TBMCDebugMessageEvent extends Event {
|
|||
private boolean sent;
|
||||
|
||||
public TBMCDebugMessageEvent(String message) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
this.message = message;
|
||||
}
|
||||
|
|
@ -1,43 +1,37 @@
|
|||
package buttondevteam.lib;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Throwable)}.
|
||||
* </p>
|
||||
*
|
||||
* @author Norbi
|
||||
*
|
||||
*/
|
||||
@Getter
|
||||
public class TBMCExceptionEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final String sourceMessage;
|
||||
private final Throwable exception;
|
||||
private boolean handled;
|
||||
|
||||
@java.beans.ConstructorProperties({"sourceMessage", "exception"})
|
||||
public TBMCExceptionEvent(String sourceMessage, Throwable exception) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
this.sourceMessage = sourceMessage;
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
public void setHandled() {
|
||||
handled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
package buttondevteam.lib;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Throwable)}.
|
||||
* </p>
|
||||
*
|
||||
* @author Norbi
|
||||
*
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class TBMCExceptionEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final String sourceMessage;
|
||||
private final Throwable exception;
|
||||
private boolean handled;
|
||||
|
||||
public void setHandled() {
|
||||
handled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
36
ButtonCore/src/main/java/buttondevteam/lib/TBMCSystemChatEvent.java
Executable file
36
ButtonCore/src/main/java/buttondevteam/lib/TBMCSystemChatEvent.java
Executable file
|
@ -0,0 +1,36 @@
|
|||
package buttondevteam.lib;
|
||||
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Make sure to only send the message to users who {@link #shouldSendTo(CommandSender)} returns true.
|
||||
*
|
||||
* @author NorbiPeti
|
||||
*
|
||||
*/
|
||||
@Getter
|
||||
public class TBMCSystemChatEvent extends TBMCChatEventBase {
|
||||
private boolean handled;
|
||||
|
||||
public void setHandled() {
|
||||
handled = true;
|
||||
}
|
||||
|
||||
public TBMCSystemChatEvent(Channel channel, String message, int score, String groupid) { // TODO: Rich message
|
||||
super(channel, message, score, groupid);
|
||||
}
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package buttondevteam.lib.architecture;
|
||||
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public abstract class ButtonPlugin extends JavaPlugin {
|
||||
private final HashMap<String, ConfigData<?>> datamap = new HashMap<>();
|
||||
private ConfigurationSection section;
|
||||
|
||||
protected abstract void pluginEnable();
|
||||
|
||||
protected abstract void pluginDisable();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
section = getConfig().getConfigurationSection("global");
|
||||
if (section == null) section = getConfig().createSection("global");
|
||||
try {
|
||||
pluginEnable();
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("Error while enabling plugin " + getName() + "!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
try {
|
||||
pluginDisable();
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("Error while disabling plugin " + getName() + "!", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IHaveConfig#getData(Map, ConfigurationSection, String, Object)
|
||||
*/
|
||||
protected <T> ConfigData<T> getData(String path, T def) {
|
||||
return IHaveConfig.getData(datamap, section, path, def);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IHaveConfig#getData(Map, ConfigurationSection, String, Object, Function, Function)
|
||||
*/
|
||||
protected <T> ConfigData<T> getData(String path, T def, Function<Object, T> getter, Function<T, Object> setter) {
|
||||
return IHaveConfig.getData(datamap, section, path, def, getter, setter);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,221 @@
|
|||
package buttondevteam.lib.architecture;
|
||||
|
||||
import buttondevteam.core.ComponentManager;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.architecture.exceptions.UnregisteredComponentException;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.var;
|
||||
import lombok.val;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Configuration is based on class name
|
||||
*/
|
||||
public abstract class Component {
|
||||
private static HashMap<Class<? extends Component>, Component> components = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private boolean enabled = false;
|
||||
@Getter(value = AccessLevel.PROTECTED)
|
||||
@NonNull
|
||||
private JavaPlugin plugin;
|
||||
@NonNull
|
||||
private ConfigurationSection config;
|
||||
|
||||
public ConfigData<Boolean> shouldBeEnabled() {
|
||||
return getData("enabled", true);
|
||||
}
|
||||
|
||||
private HashMap<String, ConfigData<?>> datamap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @see IHaveConfig#getData(Map, ConfigurationSection, String, Object)
|
||||
*/
|
||||
protected <T> ConfigData<T> getData(String path, T def) {
|
||||
return IHaveConfig.getData(datamap, config, path, def);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IHaveConfig#getData(Map, ConfigurationSection, String, Object, Function, Function)
|
||||
*/
|
||||
protected <T> ConfigData<T> getData(String path, T def, Function<Object, T> getter, Function<T, Object> setter) {
|
||||
return IHaveConfig.getData(datamap, config, path, def, getter, setter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a component checking it's dependencies and calling {@link #register(JavaPlugin)}.<br>
|
||||
* Make sure to register the dependencies first.<br>
|
||||
* The component will be enabled automatically, regardless of when it was registered.
|
||||
*
|
||||
* @param component The component to register
|
||||
* @return Whether the component is registered successfully (it may have failed to enable)
|
||||
*/
|
||||
public static boolean registerComponent(JavaPlugin plugin, Component component) {
|
||||
return registerUnregisterComponent(plugin, component, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a component by calling {@link #unregister(JavaPlugin)}.<br>
|
||||
* Make sure to unregister the dependencies last.
|
||||
*
|
||||
* @param componentClass The component class to unregister
|
||||
* @return Whether the component is unregistered successfully (it also got disabled)
|
||||
*/
|
||||
public static boolean unregisterComponent(JavaPlugin plugin, Class<? extends Component> componentClass) {
|
||||
val component = components.get(componentClass);
|
||||
if (component == null)
|
||||
return false; //Failed to load
|
||||
return registerUnregisterComponent(plugin, component, false);
|
||||
}
|
||||
|
||||
public static boolean registerUnregisterComponent(JavaPlugin plugin, Component component, boolean register) {
|
||||
try {
|
||||
val metaAnn = component.getClass().getAnnotation(ComponentMetadata.class);
|
||||
if (metaAnn != null) {
|
||||
Class<? extends Component>[] dependencies = metaAnn.depends();
|
||||
for (val dep : dependencies) {
|
||||
if (!components.containsKey(dep)) {
|
||||
plugin.getLogger().warning("Failed to " + (register ? "" : "un") + "register component " + component.getClassName() + " as a required dependency is missing/disabled: " + dep.getSimpleName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (register) {
|
||||
component.plugin = plugin;
|
||||
var compconf = plugin.getConfig().getConfigurationSection("components");
|
||||
if (compconf == null) compconf = plugin.getConfig().createSection("components");
|
||||
component.config = compconf.getConfigurationSection(component.getClassName());
|
||||
if (component.config == null) component.config = compconf.createSection(component.getClassName());
|
||||
component.register(plugin);
|
||||
components.put(component.getClass(), component);
|
||||
if (ComponentManager.areComponentsEnabled() && component.shouldBeEnabled().get()) {
|
||||
try { //Enable components registered after the previous ones getting enabled
|
||||
setComponentEnabled(component, true);
|
||||
return true;
|
||||
} catch (Exception | NoClassDefFoundError e) {
|
||||
TBMCCoreAPI.SendException("Failed to enable component " + component.getClassName() + "!", e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (component.enabled) {
|
||||
try {
|
||||
component.disable();
|
||||
component.enabled = false;
|
||||
} catch (Exception | NoClassDefFoundError e) {
|
||||
TBMCCoreAPI.SendException("Failed to disable component " + component.getClassName() + "!", e);
|
||||
return false; //If failed to disable, won't unregister either
|
||||
}
|
||||
}
|
||||
component.unregister(plugin);
|
||||
components.remove(component.getClass());
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("Failed to " + (register ? "" : "un") + "register component " + component.getClassName() + "!", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a component checking it's dependencies and calling {@link #register(JavaPlugin)}.<br>
|
||||
* Make sure to register the dependencies first.
|
||||
*
|
||||
* @param component The component to register
|
||||
*/
|
||||
public static void setComponentEnabled(Component component, boolean enabled) throws UnregisteredComponentException {
|
||||
if (!components.containsKey(component.getClass()))
|
||||
throw new UnregisteredComponentException(component);
|
||||
if (component.enabled = enabled)
|
||||
component.enable();
|
||||
else
|
||||
component.disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered components<br>
|
||||
*
|
||||
* @return The currently registered components
|
||||
*/
|
||||
public static Map<Class<? extends Component>, Component> getComponents() {
|
||||
return Collections.unmodifiableMap(components);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the module, when called by the JavaPlugin class.
|
||||
* This gets fired when the plugin is enabled. Use {@link #enable()} to register commands and such.
|
||||
*
|
||||
* @param plugin Plugin object
|
||||
*/
|
||||
protected void register(JavaPlugin plugin) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the module, when called by the JavaPlugin class.
|
||||
* This gets fired when the plugin is disabled.
|
||||
* Do any cleanups needed within this method.
|
||||
*
|
||||
* @param plugin Plugin object
|
||||
*/
|
||||
protected void unregister(JavaPlugin plugin) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the module, when called by the JavaPlugin class. Call
|
||||
* registerCommand() and registerListener() within this method.<br>
|
||||
* To access the plugin, use {@link #getPlugin()}.
|
||||
*/
|
||||
protected abstract void enable();
|
||||
|
||||
/**
|
||||
* Disables the module, when called by the JavaPlugin class. Do
|
||||
* any cleanups needed within this method.
|
||||
* To access the plugin, use {@link #getPlugin()}.
|
||||
*/
|
||||
protected abstract void disable();
|
||||
|
||||
/**
|
||||
* Registers a TBMCCommand to the plugin. Make sure to add it to plugin.yml and use {@link buttondevteam.lib.chat.CommandClass}.
|
||||
*
|
||||
* @param plugin Main plugin responsible for stuff
|
||||
* @param commandBase Custom coded command class
|
||||
*/
|
||||
protected void registerCommand(JavaPlugin plugin, TBMCCommandBase commandBase) {
|
||||
TBMCChatAPI.AddCommand(plugin, commandBase);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a Listener to this plugin
|
||||
*
|
||||
* @param plugin Main plugin responsible for stuff
|
||||
* @param listener The event listener to register
|
||||
* @return The provided listener
|
||||
*/
|
||||
protected Listener registerListener(JavaPlugin plugin, Listener listener) {
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(listener, plugin);
|
||||
return listener;
|
||||
}
|
||||
|
||||
private String getClassName() {
|
||||
Class<?> enclosingClass = getClass().getEnclosingClass();
|
||||
String className;
|
||||
if (enclosingClass != null) {
|
||||
className = (enclosingClass.getName());
|
||||
} else {
|
||||
className = (getClass().getName());
|
||||
}
|
||||
return className;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,5 @@ import java.lang.annotation.Target;
|
|||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ComponentMetadata {
|
||||
Class<? extends Component>[] depends() default {};
|
||||
|
||||
boolean enabledByDefault() default true;
|
||||
Class<? extends Component>[] depends();
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package buttondevteam.lib.architecture;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Use the getter/setter constructor if {@link T} isn't a primitive type or String.<br>
|
||||
* Use {@link Component#getData(String, Object)} or {@link ButtonPlugin#getData(String, Object)} to get an instance.
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
@AllArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class ConfigData<T> { //TODO: Save after a while
|
||||
private final ConfigurationSection config;
|
||||
private final String path;
|
||||
private final T def;
|
||||
/**
|
||||
* The parameter is of a primitive type as returned by {@link YamlConfiguration#get(String)}
|
||||
*/
|
||||
private Function<Object, T> getter;
|
||||
/**
|
||||
* The result should be a primitive type or string that can be retrieved correctly later
|
||||
*/
|
||||
private Function<T, Object> setter;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T get() {
|
||||
Object val = config.get(path, def);
|
||||
if (getter != null) {
|
||||
T hmm = getter.apply(val);
|
||||
if (hmm == null) hmm = def; //Set if the getter returned null
|
||||
return hmm;
|
||||
}
|
||||
return (T) val;
|
||||
}
|
||||
|
||||
public void set(T value) {
|
||||
Object val;
|
||||
if (setter != null)
|
||||
val = setter.apply(value);
|
||||
else val = value;
|
||||
config.set(path, val);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package buttondevteam.lib.architecture;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Members of this interface should be protected (access level)
|
||||
*/
|
||||
final class IHaveConfig {
|
||||
private IHaveConfig() {}
|
||||
|
||||
/**
|
||||
* This method overload should only be used with primitves or String.
|
||||
*
|
||||
* @param path The path in config to use
|
||||
* @param def The value to use by default
|
||||
* @param <T> The type of this variable (only use primitives or String)
|
||||
* @return The data object that can be used to get or set the value
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static <T> ConfigData<T> getData(Map<String, ConfigData<?>> datamap, ConfigurationSection config, String path, T def) {
|
||||
ConfigData<?> data = datamap.get(path);
|
||||
if (data == null) datamap.put(path, data = new ConfigData<>(config, path, def));
|
||||
return (ConfigData<T>) data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method overload may be used with any class.
|
||||
*
|
||||
* @param path The path in config to use
|
||||
* @param def The value to use by default
|
||||
* @param getter A function that converts a primitive representation to the correct value
|
||||
* @param setter A function that converts a value to a primitive representation
|
||||
* @param <T> The type of this variable (can be any class)
|
||||
* @return The data object that can be used to get or set the value
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static <T> ConfigData<T> getData(Map<String, ConfigData<?>> datamap, ConfigurationSection config, String path, T def, Function<Object, T> getter, Function<T, Object> setter) {
|
||||
ConfigData<?> data = datamap.get(path);
|
||||
if (data == null) datamap.put(path, data = new ConfigData<>(config, path, def, getter, setter));
|
||||
return (ConfigData<T>) data;
|
||||
}
|
||||
}
|
175
ButtonCore/src/main/java/buttondevteam/lib/chat/Channel.java
Executable file
175
ButtonCore/src/main/java/buttondevteam/lib/chat/Channel.java
Executable file
|
@ -0,0 +1,175 @@
|
|||
package buttondevteam.lib.chat;
|
||||
|
||||
import buttondevteam.core.MainPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Channel {
|
||||
/**
|
||||
* Specifies a score that means it's OK to send - but it does not define any groups, only send or not send. See {@link #GROUP_EVERYONE}
|
||||
*/
|
||||
public static final int SCORE_SEND_OK = 0;
|
||||
/**
|
||||
* Specifies a score that means the user doesn't have permission to see or send the message. Any negative value has the same effect.
|
||||
*/
|
||||
public static final int SCORE_SEND_NOPE = -1;
|
||||
/**
|
||||
* Send the message to everyone <i>who has access to the channel</i> - this does not necessarily mean all players
|
||||
*/
|
||||
public static final String GROUP_EVERYONE = "everyone";
|
||||
public final String DisplayName;
|
||||
public final Color color;
|
||||
public final String ID;
|
||||
@Nullable
|
||||
public String[] IDs;
|
||||
/**
|
||||
* Filters both the sender and the targets
|
||||
*/
|
||||
private final Function<CommandSender, RecipientTestResult> filteranderrormsg;
|
||||
|
||||
private static final List<Channel> channels = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a channel.
|
||||
*
|
||||
* @param displayname The name that should appear at the start of the message. <b>A chat color is expected at the beginning (§9).</b>
|
||||
* @param color The default color of the messages sent in the channel
|
||||
* @param command The command to be used for the channel <i>without /</i>. For example "mod". It's also used for scoreboard objective names.
|
||||
* @param filteranderrormsg Checks all senders against the criteria provided here and sends the message if the index matches the sender's - if no score at all, displays the error.<br>
|
||||
* May be null to send to everyone.
|
||||
*/
|
||||
public Channel(String displayname, Color color, String command,
|
||||
Function<CommandSender, RecipientTestResult> filteranderrormsg) {
|
||||
DisplayName = displayname;
|
||||
this.color = color;
|
||||
ID = command;
|
||||
this.filteranderrormsg = filteranderrormsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be only called from a subclass - otherwise it'll throw an exception.
|
||||
*
|
||||
* @see Channel#Channel(String, Color, String, Function)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends Channel> Channel(String displayname, Color color, String command,
|
||||
BiFunction<T, CommandSender, RecipientTestResult> filteranderrormsg) {
|
||||
DisplayName = displayname;
|
||||
this.color = color;
|
||||
ID = command;
|
||||
this.filteranderrormsg = s -> filteranderrormsg.apply((T) this, s);
|
||||
}
|
||||
|
||||
public boolean isGlobal() {
|
||||
return filteranderrormsg == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: Errors are sent to the sender automatically
|
||||
*
|
||||
* @param sender The user we're sending to
|
||||
* @param score The (source) score to compare with the user's
|
||||
*/
|
||||
public boolean shouldSendTo(CommandSender sender, int score) {
|
||||
return score == getMCScore(sender); //If there's any error, the score won't be equal
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: Errors are sent to the sender automatically
|
||||
*/
|
||||
public int getMCScore(CommandSender sender) {
|
||||
return getRTR(sender).score; //No need to check if there was an error
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: Errors are sent to the sender automatically<br>
|
||||
* <p>
|
||||
* Null means don't send
|
||||
*/
|
||||
@Nullable
|
||||
public String getGroupID(CommandSender sender) {
|
||||
return getRTR(sender).groupID; //No need to check if there was an error
|
||||
}
|
||||
|
||||
public RecipientTestResult getRTR(CommandSender sender) {
|
||||
if (filteranderrormsg == null)
|
||||
return new RecipientTestResult(SCORE_SEND_OK, GROUP_EVERYONE);
|
||||
return filteranderrormsg.apply(sender);
|
||||
}
|
||||
|
||||
public static List<Channel> getChannels() {
|
||||
return channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for the function parameter of {@link #Channel(String, Color, String, Function)}. It checks if the sender is OP or optionally has the specified group. The error message is
|
||||
* generated automatically.
|
||||
*
|
||||
* @param permgroup The group that can access the channel or <b>null</b> to only allow OPs.
|
||||
* @return If has access
|
||||
*/
|
||||
public static Function<CommandSender, RecipientTestResult> inGroupFilter(String permgroup) {
|
||||
return noScoreResult(
|
||||
s -> s.isOp() || (permgroup != null && (s instanceof Player && MainPlugin.permission != null && MainPlugin.permission.playerInGroup((Player) s, permgroup))),
|
||||
"You need to be a(n) " + (permgroup != null ? permgroup : "OP") + " to use this channel.");
|
||||
}
|
||||
|
||||
public static Function<CommandSender, RecipientTestResult> noScoreResult(Predicate<CommandSender> filter,
|
||||
String errormsg) {
|
||||
return s -> filter.test(s) ? new RecipientTestResult(SCORE_SEND_OK, GROUP_EVERYONE) : new RecipientTestResult(errormsg);
|
||||
}
|
||||
|
||||
public static <T extends Channel> BiFunction<T, CommandSender, RecipientTestResult> noScoreResult(
|
||||
BiPredicate<T, CommandSender> filter, String errormsg) {
|
||||
return (this_, s) -> filter.test(this_, s) ? new RecipientTestResult(SCORE_SEND_OK, GROUP_EVERYONE) : new RecipientTestResult(errormsg);
|
||||
}
|
||||
|
||||
public static Channel GlobalChat;
|
||||
public static Channel AdminChat;
|
||||
public static Channel ModChat;
|
||||
|
||||
static void RegisterChannel(Channel channel) {
|
||||
channels.add(channel);
|
||||
Bukkit.getScheduler().runTask(MainPlugin.Instance, () -> Bukkit.getPluginManager().callEvent(new ChatChannelRegisterEvent(channel))); // Wait for server start
|
||||
}
|
||||
|
||||
public static class RecipientTestResult {
|
||||
public final String errormessage;
|
||||
public final int score; // Anything below 0 is "never send"
|
||||
public final String groupID;
|
||||
public static final RecipientTestResult ALL = new RecipientTestResult(SCORE_SEND_OK, GROUP_EVERYONE);
|
||||
|
||||
/**
|
||||
* Creates a result that indicates an <b>error</b>
|
||||
*
|
||||
* @param errormessage The error message to show the sender if they don't meet the criteria.
|
||||
*/
|
||||
public RecipientTestResult(String errormessage) {
|
||||
this.errormessage = errormessage;
|
||||
this.score = SCORE_SEND_NOPE;
|
||||
this.groupID = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a result that indicates a <b>success</b>
|
||||
*
|
||||
* @param score The score that identifies the target group. <b>Must be non-negative.</b> For example, the index of the town or nation to send to.
|
||||
* @param groupID The ID of the target group.
|
||||
*/
|
||||
public RecipientTestResult(int score, String groupID) {
|
||||
if (score < 0) throw new IllegalArgumentException("Score must be non-negative!");
|
||||
this.score = score;
|
||||
this.groupID = groupID;
|
||||
this.errormessage = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package buttondevteam.core.component.channel;
|
||||
package buttondevteam.lib.chat;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
|
@ -1,8 +1,5 @@
|
|||
package buttondevteam.core.component.channel;
|
||||
package buttondevteam.lib.chat;
|
||||
|
||||
import buttondevteam.lib.TBMCSystemChatEvent;
|
||||
import buttondevteam.lib.chat.Color;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -18,11 +15,11 @@ public class ChatRoom extends Channel {
|
|||
|
||||
public void joinRoom(CommandSender sender) {
|
||||
usersInRoom.add(sender);
|
||||
TBMCChatAPI.SendSystemMessage(this, RecipientTestResult.ALL, sender.getName() + " joined the room", TBMCSystemChatEvent.BroadcastTarget.ALL); //Always show message in the same kind of channel
|
||||
TBMCChatAPI.SendSystemMessage(this, RecipientTestResult.ALL, sender.getName() + " joined the room");
|
||||
}
|
||||
|
||||
public void leaveRoom(CommandSender sender) {
|
||||
usersInRoom.remove(sender);
|
||||
TBMCChatAPI.SendSystemMessage(this, RecipientTestResult.ALL, sender.getName() + " left the room", ChannelComponent.roomJoinLeave);
|
||||
TBMCChatAPI.SendSystemMessage(this, RecipientTestResult.ALL, sender.getName() + " left the room");
|
||||
}
|
||||
}
|
20
ButtonCore/src/main/java/buttondevteam/lib/chat/Color.java
Executable file
20
ButtonCore/src/main/java/buttondevteam/lib/chat/Color.java
Executable file
|
@ -0,0 +1,20 @@
|
|||
package buttondevteam.lib.chat;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum Color implements TellrawSerializableEnum {
|
||||
Black("black", 0, 0, 0), DarkBlue("dark_blue", 0, 0, 170), DarkGreen("dark_green", 0, 170, 0), DarkAqua("dark_aqua",
|
||||
0, 170, 170), DarkRed("dark_red", 170, 0, 0), DarkPurple("dark_purple", 0, 170, 0), Gold("gold", 255, 170,
|
||||
0), Gray("gray", 170, 170, 170), DarkGray("dark_gray", 85, 85, 85), Blue("blue", 85, 85,
|
||||
255), Green("green", 85, 255, 85), Aqua("aqua", 85, 255, 255), Red("red", 255, 85,
|
||||
85), LightPurple("light_purple", 255, 85,
|
||||
255), Yellow("yellow", 255, 255, 85), White("white", 255, 255, 255);
|
||||
|
||||
private final String name;
|
||||
private final int red;
|
||||
private final int green;
|
||||
private final int blue;
|
||||
}
|
|
@ -36,18 +36,4 @@ public @interface CommandClass {
|
|||
* Exclude this class from the path. Useful if more commands share some property but aren't subcommands of a common command. See {@link CommandClass} for more details.
|
||||
*/
|
||||
boolean excludeFromPath() default false;
|
||||
|
||||
/**
|
||||
* The help text to show for the players. A usage message will be also shown below it.<br>
|
||||
* <b>The fist line will be converted to a header.</b>
|
||||
*
|
||||
* @return The help text
|
||||
*/
|
||||
String[] helpText() default {};
|
||||
|
||||
/**
|
||||
* The main permission which allows using this command (individual access can be still granted with "chroma.command.X").
|
||||
* Used to be "tbmc.admin"
|
||||
*/
|
||||
String permGroup() default ""; //TODO: A single annotation instead of these two
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package buttondevteam.lib.chat;
|
||||
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class OptionallyPlayerCommandBase extends TBMCCommandBase {
|
||||
public boolean OnCommand(Player player, String alias, String[] args) {
|
||||
if (getClass().isAnnotationPresent(OptionallyPlayerCommandClass.class)
|
||||
&& getClass().getAnnotation(OptionallyPlayerCommandClass.class).playerOnly())
|
||||
TBMCCoreAPI.SendException("Error while executing command " + getClass().getSimpleName() + "!",
|
||||
new Exception(
|
||||
"The PlayerCommand annotation is present and set to playerOnly but the Player overload isn't overriden!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
if (sender instanceof Player)
|
||||
return OnCommand((Player) sender, alias, args);
|
||||
if (!getClass().isAnnotationPresent(OptionallyPlayerCommandClass.class)
|
||||
|| !getClass().getAnnotation(OptionallyPlayerCommandClass.class).playerOnly())
|
||||
TBMCCoreAPI.SendException("Error while executing command " + getClass().getSimpleName() + "!",
|
||||
new Exception(
|
||||
"Command class doesn't override the CommandSender overload and no PlayerCommandClass annotation is present or playerOnly is false!"));
|
||||
sender.sendMessage("§cYou need to be a player to use this command.");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package buttondevteam.lib.chat;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Only needed to use with {@link OptionallyPlayerCommandBase} command classes
|
||||
*
|
||||
* @author NorbiPeti
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Inherited
|
||||
public @interface OptionallyPlayerCommandClass {
|
||||
boolean playerOnly();
|
||||
}
|
16
ButtonCore/src/main/java/buttondevteam/lib/chat/PlayerCommandBase.java
Executable file
16
ButtonCore/src/main/java/buttondevteam/lib/chat/PlayerCommandBase.java
Executable file
|
@ -0,0 +1,16 @@
|
|||
package buttondevteam.lib.chat;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class PlayerCommandBase extends TBMCCommandBase {
|
||||
public abstract boolean OnCommand(Player player, String alias, String[] args);
|
||||
|
||||
@Override
|
||||
public final boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
if (sender instanceof Player)
|
||||
return OnCommand((Player) sender, alias, args);
|
||||
sender.sendMessage("§cYou need to be a player to use this command.");
|
||||
return true;
|
||||
}
|
||||
}
|
282
ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java
Executable file
282
ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java
Executable file
|
@ -0,0 +1,282 @@
|
|||
package buttondevteam.lib.chat;
|
||||
|
||||
import buttondevteam.core.CommandCaller;
|
||||
import buttondevteam.core.MainPlugin;
|
||||
import buttondevteam.lib.TBMCChatEvent;
|
||||
import buttondevteam.lib.TBMCChatPreprocessEvent;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.TBMCSystemChatEvent;
|
||||
import buttondevteam.lib.chat.Channel.RecipientTestResult;
|
||||
import lombok.val;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class TBMCChatAPI {
|
||||
|
||||
private static final HashMap<String, TBMCCommandBase> commands = new HashMap<>();
|
||||
|
||||
public static HashMap<String, TBMCCommandBase> GetCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns messages formatted for Minecraft chat listing the subcommands of the command.
|
||||
*
|
||||
* @param command
|
||||
* The command which we want the subcommands of
|
||||
* @param sender
|
||||
* The sender for permissions
|
||||
* @return The subcommands
|
||||
*/
|
||||
public static String[] GetSubCommands(TBMCCommandBase command, CommandSender sender) {
|
||||
return GetSubCommands(command.GetCommandPath(), sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns messages formatted for Minecraft chat listing the subcommands of the command.<br>
|
||||
* Returns a header if subcommands were found, otherwise returns an empty array.
|
||||
*
|
||||
* @param command
|
||||
* The command which we want the subcommands of
|
||||
* @param sender
|
||||
* The sender for permissions
|
||||
* @return The subcommands
|
||||
*/
|
||||
public static String[] GetSubCommands(String command, CommandSender sender) {
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
Consumer<String> addToCmds = cmd -> {
|
||||
if (cmds.size() == 0)
|
||||
cmds.add("§6---- Subcommands ----");
|
||||
cmds.add(cmd);
|
||||
};
|
||||
for (Entry<String, TBMCCommandBase> cmd : TBMCChatAPI.GetCommands().entrySet()) {
|
||||
if (cmd.getKey().startsWith(command + " ")) {
|
||||
if (cmd.getValue().isPlayerOnly() && !(sender instanceof Player))
|
||||
continue;
|
||||
if (cmd.getValue().isModOnly() && (MainPlugin.permission != null ? !MainPlugin.permission.has(sender, "tbmc.admin") : !sender.isOp()))
|
||||
continue;
|
||||
int ind = cmd.getKey().indexOf(' ', command.length() + 2);
|
||||
if (ind >= 0) {
|
||||
String newcmd = cmd.getKey().substring(0, ind);
|
||||
if (!cmds.contains("/" + newcmd))
|
||||
addToCmds.accept("/" + newcmd);
|
||||
} else
|
||||
addToCmds.accept("/" + cmd.getKey());
|
||||
}
|
||||
}
|
||||
return cmds.toArray(new String[0]); //Apparently it's faster to use an empty array in modern Java
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This method adds a plugin's commands to help and sets their executor.
|
||||
* </p>
|
||||
* <p>
|
||||
* </p>
|
||||
* <b>The command classes have to have a constructor each with no parameters</b>
|
||||
* <p>
|
||||
* The <u>command must be registered</u> in the caller plugin's plugin.yml. Otherwise the plugin will output a messsage to console.
|
||||
* </p>
|
||||
* <p>
|
||||
* <i>Using this method after the server is done loading will have no effect.</i>
|
||||
* </p>
|
||||
*
|
||||
* @param plugin
|
||||
* The caller plugin
|
||||
* @param acmdclass
|
||||
* A command's class to get the package name for commands. The provided class's package and subpackages are scanned for commands.
|
||||
*/
|
||||
public static synchronized void AddCommands(JavaPlugin plugin, Class<? extends TBMCCommandBase> acmdclass) {
|
||||
plugin.getLogger().info("Registering commands from " + acmdclass.getPackage().getName());
|
||||
Reflections rf = new Reflections(new ConfigurationBuilder()
|
||||
.setUrls(ClasspathHelper.forPackage(acmdclass.getPackage().getName(),
|
||||
plugin.getClass().getClassLoader()))
|
||||
.addUrls(
|
||||
ClasspathHelper.forClass(OptionallyPlayerCommandBase.class,
|
||||
OptionallyPlayerCommandBase.class.getClassLoader()),
|
||||
ClasspathHelper.forClass(PlayerCommandBase.class, PlayerCommandBase.class.getClassLoader())) // http://stackoverflow.com/questions/12917417/using-reflections-for-finding-the-transitive-subtypes-of-a-class-when-not-all
|
||||
.addClassLoader(plugin.getClass().getClassLoader()).addScanners(new SubTypesScanner()));
|
||||
Set<Class<? extends TBMCCommandBase>> cmds = rf.getSubTypesOf(TBMCCommandBase.class);
|
||||
for (Class<? extends TBMCCommandBase> cmd : cmds) {
|
||||
try {
|
||||
if (!cmd.getPackage().getName().startsWith(acmdclass.getPackage().getName()))
|
||||
continue; // It keeps including the commands from here
|
||||
if (Modifier.isAbstract(cmd.getModifiers()))
|
||||
continue;
|
||||
TBMCCommandBase c = cmd.newInstance();
|
||||
c.plugin = plugin;
|
||||
if (HasNulls(plugin, c))
|
||||
continue;
|
||||
commands.put(c.GetCommandPath(), c);
|
||||
CommandCaller.RegisterCommand(c);
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("An error occured while registering command " + cmd.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This method adds a plugin's command to help and sets it's executor.
|
||||
* </p>
|
||||
* <p>
|
||||
* The <u>command must be registered</u> in the caller plugin's plugin.yml. Otherwise the plugin will output a messsage to console.
|
||||
* </p>
|
||||
* <p>
|
||||
* <i>Using this method after the server is done loading will have no effect.</i>
|
||||
* </p>
|
||||
*
|
||||
* @param plugin
|
||||
* The caller plugin
|
||||
* @param thecmdclass
|
||||
* The command's class to create it (because why let you create the command class)
|
||||
*/
|
||||
public static void AddCommand(JavaPlugin plugin, Class<? extends TBMCCommandBase> thecmdclass, Object... params) {
|
||||
// plugin.getLogger().info("Registering command " + thecmdclass.getSimpleName() + " for " + plugin.getName());
|
||||
try {
|
||||
TBMCCommandBase c;
|
||||
if (params.length > 0)
|
||||
c = thecmdclass.getConstructor(Arrays.stream(params).map(Object::getClass).toArray(Class[]::new))
|
||||
.newInstance(params);
|
||||
else
|
||||
c = thecmdclass.newInstance();
|
||||
c.plugin = plugin;
|
||||
if (HasNulls(plugin, c))
|
||||
return;
|
||||
commands.put(c.GetCommandPath(), c);
|
||||
CommandCaller.RegisterCommand(c);
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("An error occured while registering command " + thecmdclass.getSimpleName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This method adds a plugin's command to help and sets it's executor.
|
||||
* </p>
|
||||
* <p>
|
||||
* The <u>command must be registered</u> in the caller plugin's plugin.yml. Otherwise the plugin will output a messsage to console.
|
||||
* </p>
|
||||
* <p>
|
||||
* <i>Using this method after the server is done loading will have no effect.</i>
|
||||
* </p>
|
||||
*
|
||||
* @param plugin
|
||||
* The caller plugin
|
||||
* @param cmd
|
||||
* The command to add
|
||||
*/
|
||||
public static void AddCommand(JavaPlugin plugin, TBMCCommandBase cmd) {
|
||||
if (HasNulls(plugin, cmd))
|
||||
return;
|
||||
// plugin.getLogger().info("Registering command /" + cmd.GetCommandPath() + " for " + plugin.getName());
|
||||
try {
|
||||
cmd.plugin = plugin;
|
||||
commands.put(cmd.GetCommandPath(), cmd);
|
||||
CommandCaller.RegisterCommand(cmd);
|
||||
} catch (Exception e) {
|
||||
TBMCCoreAPI.SendException("An error occured while registering command " + cmd.GetCommandPath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean HasNulls(JavaPlugin plugin, TBMCCommandBase cmd) {
|
||||
if (cmd == null) {
|
||||
TBMCCoreAPI.SendException("An error occured while registering a command for plugin " + plugin.getName(),
|
||||
new Exception("The command is null!"));
|
||||
return true;
|
||||
} else if (cmd.GetCommandPath() == null) {
|
||||
TBMCCoreAPI.SendException("An error occured while registering command " + cmd.getClass().getSimpleName()
|
||||
+ " for plugin " + plugin.getName(), new Exception("The command path is null!"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a chat message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.<br>
|
||||
* This will also send the error message to the sender, if they can't send the message.
|
||||
*
|
||||
* @param cm The message to send
|
||||
* @return The event cancelled state
|
||||
*/
|
||||
public static boolean SendChatMessage(ChatMessage cm) {
|
||||
return SendChatMessage(cm, cm.getUser().channel().get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a chat message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.<br>
|
||||
* This will also send the error message to the sender, if they can't send the message.
|
||||
*
|
||||
* @param cm The message to send
|
||||
* @param channel The MC channel to send in
|
||||
* @return The event cancelled state
|
||||
*/
|
||||
public static boolean SendChatMessage(ChatMessage cm, Channel channel) {
|
||||
if (!Channel.getChannels().contains(channel))
|
||||
throw new RuntimeException("Channel " + channel.DisplayName + " not registered!");
|
||||
val permcheck = cm.getPermCheck();
|
||||
RecipientTestResult rtr = getScoreOrSendError(channel, permcheck);
|
||||
int score = rtr.score;
|
||||
if (score == Channel.SCORE_SEND_NOPE || rtr.groupID == null)
|
||||
return true;
|
||||
TBMCChatPreprocessEvent eventPre = new TBMCChatPreprocessEvent(cm.getSender(), channel, cm.getMessage());
|
||||
Bukkit.getPluginManager().callEvent(eventPre);
|
||||
if (eventPre.isCancelled())
|
||||
return true;
|
||||
cm.setMessage(eventPre.getMessage());
|
||||
TBMCChatEvent event;
|
||||
event = new TBMCChatEvent(channel, cm, rtr);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event.isCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a regular message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.
|
||||
*
|
||||
* @param channel
|
||||
* The channel to send to
|
||||
* @param rtr
|
||||
* The score&group to use to find the group - use {@link RecipientTestResult#ALL} if the channel doesn't have scores
|
||||
* @param message
|
||||
* The message to send
|
||||
* @return The event cancelled state
|
||||
*/
|
||||
public static boolean SendSystemMessage(Channel channel, RecipientTestResult rtr, String message) {
|
||||
if (!Channel.getChannels().contains(channel))
|
||||
throw new RuntimeException("Channel " + channel.DisplayName + " not registered!");
|
||||
TBMCSystemChatEvent event = new TBMCSystemChatEvent(channel, message, rtr.score, rtr.groupID);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event.isCancelled();
|
||||
}
|
||||
|
||||
private static RecipientTestResult getScoreOrSendError(Channel channel, CommandSender sender) {
|
||||
RecipientTestResult result = channel.getRTR(sender);
|
||||
if (result.errormessage != null)
|
||||
sender.sendMessage("§c" + result.errormessage);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a chat channel. See {@link Channel#Channel(String, Color, String, java.util.function.Function)} for details.
|
||||
*
|
||||
* @param channel
|
||||
* A new {@link Channel} to register
|
||||
*/
|
||||
public static void RegisterChatChannel(Channel channel) {
|
||||
Channel.RegisterChannel(channel);
|
||||
}
|
||||
}
|
106
ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java
Executable file
106
ButtonCore/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java
Executable file
|
@ -0,0 +1,106 @@
|
|||
package buttondevteam.lib.chat;
|
||||
|
||||
import javassist.Modifier;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Extend this class to create new TBMCCommand and use {@link TBMCChatAPI#AddCommand(org.bukkit.plugin.java.JavaPlugin, TBMCCommandBase)} to add it. <u><b>Note:</b></u> The command path (command name
|
||||
* and subcommand arguments) will be the class name by default, removing any "command" from it. To change it (especially for subcommands), use the path field in the {@link CommandClass} annotation.
|
||||
*
|
||||
* @author Norbi
|
||||
*
|
||||
*/
|
||||
@TBMCCommandEnforcer
|
||||
public abstract class TBMCCommandBase {
|
||||
|
||||
public TBMCCommandBase() {
|
||||
path = getcmdpath();
|
||||
modonly = ismodonly();
|
||||
}
|
||||
|
||||
public abstract boolean OnCommand(CommandSender sender, String alias, String[] args);
|
||||
|
||||
public abstract String[] GetHelpText(String alias);
|
||||
|
||||
private final String path;
|
||||
|
||||
/**
|
||||
* The command's path, or name if top-level command.<br>
|
||||
* For example:<br>
|
||||
* "u admin updateplugin" or "u" for the top level one<br>
|
||||
* <u>The path must be lowercase!</u><br>
|
||||
* <b>Abstract classes with no {@link CommandClass} annotations will be ignored.</b>
|
||||
*
|
||||
* @return The command path, <i>which is the command class name by default</i> (removing any "command" from it) - Change via the {@link CommandClass} annotation
|
||||
*/
|
||||
public final String GetCommandPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
private String getcmdpath() {
|
||||
if (!getClass().isAnnotationPresent(CommandClass.class))
|
||||
throw new RuntimeException(
|
||||
"No @CommandClass annotation on command class " + getClass().getSimpleName() + "!");
|
||||
Function<Class<?>, String> getFromClass = cl -> cl.getSimpleName().toLowerCase().replace("commandbase", "") // <-- ...
|
||||
.replace("command", "");
|
||||
String path = getClass().getAnnotation(CommandClass.class).path(),
|
||||
prevpath = path = path.length() == 0 ? getFromClass.apply(getClass()) : path;
|
||||
for (Class<?> cl = getClass().getSuperclass(); cl != null
|
||||
&& !cl.getPackage().getName().equals(TBMCCommandBase.class.getPackage().getName()); cl = cl
|
||||
.getSuperclass()) { //
|
||||
String newpath;
|
||||
if (!cl.isAnnotationPresent(CommandClass.class)
|
||||
|| (newpath = cl.getAnnotation(CommandClass.class).path()).length() == 0
|
||||
|| newpath.equals(prevpath)) {
|
||||
if ((Modifier.isAbstract(cl.getModifiers()) && !cl.isAnnotationPresent(CommandClass.class))
|
||||
|| cl.getAnnotation(CommandClass.class).excludeFromPath()) // <--
|
||||
continue;
|
||||
newpath = getFromClass.apply(cl);
|
||||
}
|
||||
path = (prevpath = newpath) + " " + path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
Plugin plugin; // Used By TBMCChatAPI
|
||||
|
||||
public final Plugin getPlugin() { // Used by CommandCaller (ButtonChat)
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public final boolean isPlayerOnly() {
|
||||
return this instanceof PlayerCommandBase ||
|
||||
(this instanceof OptionallyPlayerCommandBase &&
|
||||
(!getClass().isAnnotationPresent(OptionallyPlayerCommandClass.class)
|
||||
|| getClass().getAnnotation(OptionallyPlayerCommandClass.class).playerOnly()));
|
||||
}
|
||||
|
||||
private final boolean modonly;
|
||||
|
||||
/**
|
||||
* Returns true if this class' or any superclass' modOnly property is set to true.
|
||||
*/
|
||||
public final boolean isModOnly() {
|
||||
return modonly;
|
||||
}
|
||||
|
||||
private boolean ismodonly() {
|
||||
if (!getClass().isAnnotationPresent(CommandClass.class))
|
||||
throw new RuntimeException(
|
||||
"No @CommandClass annotation on command class " + getClass().getSimpleName() + "!");
|
||||
boolean modOnly = getClass().getAnnotation(CommandClass.class).modOnly();
|
||||
for (Class<?> cl = getClass().getSuperclass(); cl != null
|
||||
&& !cl.getPackage().getName().equals(TBMCCommandBase.class.getPackage().getName()); cl = cl
|
||||
.getSuperclass()) { //
|
||||
if (cl.isAnnotationPresent(CommandClass.class) && !modOnly
|
||||
&& cl.getAnnotation(CommandClass.class).modOnly()) {
|
||||
modOnly = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return modOnly;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package buttondevteam.lib.chat;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Target(ElementType.TYPE)
|
||||
@Inherited
|
||||
public @interface TBMCCommandEnforcer {
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package buttondevteam.lib.player;
|
||||
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class ChannelPlayerData { //I just want this to work
|
||||
private final PlayerData<String> data;
|
||||
private final Channel def;
|
||||
|
||||
public ChannelPlayerData(String name, YamlConfiguration yaml, Channel def) {
|
||||
data = new PlayerData<>(name, yaml, "");
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
public Channel get() {
|
||||
String str = data.get();
|
||||
if (str.isEmpty())
|
||||
return def;
|
||||
return Channel.getChannels().stream().filter(c -> str.equals(c.ID)).findAny().orElse(def);
|
||||
}
|
||||
|
||||
public void set(Channel value) {
|
||||
data.set(value.ID);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue