mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
Compare commits
1 Commits
ptero-upda
...
2020.10
Author | SHA1 | Date | |
---|---|---|---|
df7e30ba4e |
46
.github/workflows/codacy-analysis.yml
vendored
46
.github/workflows/codacy-analysis.yml
vendored
@ -1,46 +0,0 @@
|
||||
# This workflow checks out code, performs a Codacy security scan
|
||||
# and integrates the results with the
|
||||
# GitHub Advanced Security code scanning feature. For more information on
|
||||
# the Codacy security scan action usage and parameters, see
|
||||
# https://github.com/codacy/codacy-analysis-cli-action.
|
||||
# For more information on Codacy Analysis CLI in general, see
|
||||
# https://github.com/codacy/codacy-analysis-cli.
|
||||
|
||||
name: Codacy Security Scan
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ development ]
|
||||
pull_request:
|
||||
branches: [ development ]
|
||||
|
||||
jobs:
|
||||
codacy-security-scan:
|
||||
name: Codacy Security Scan
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Checkout the repository to the GitHub Actions runner
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
|
||||
- name: Run Codacy Analysis CLI
|
||||
uses: codacy/codacy-analysis-cli-action@1.1.0
|
||||
with:
|
||||
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
|
||||
# You can also omit the token and run the tools that support default configurations
|
||||
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||
verbose: true
|
||||
output: results.sarif
|
||||
format: sarif
|
||||
# Adjust severity of non-security issues
|
||||
gh-code-scanning-compat: true
|
||||
# Force 0 exit code to allow SARIF file generation
|
||||
# This will handover control about PR rejection to the GitHub side
|
||||
max-allowed-issues: 2147483647
|
||||
|
||||
# Upload the SARIF file generated in the previous step
|
||||
- name: Upload SARIF results file
|
||||
uses: github/codeql-action/upload-sarif@v1
|
||||
with:
|
||||
sarif_file: results.sarif
|
73
.github/workflows/codeql-analysis.yml
vendored
73
.github/workflows/codeql-analysis.yml
vendored
@ -1,73 +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.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ development ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ development ]
|
||||
schedule:
|
||||
- cron: '20 18 * * 1'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'java' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v1.4.3
|
||||
with:
|
||||
# The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28
|
||||
java-version: 11
|
||||
|
||||
# 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
|
43
.github/workflows/downstream.yml
vendored
43
.github/workflows/downstream.yml
vendored
@ -1,43 +0,0 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: Downstream Branch Updates
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '20 7 * * *'
|
||||
# scheduled at 07:00 every Monday and Thursday
|
||||
|
||||
workflow_dispatch: # click the button on Github repo!
|
||||
|
||||
|
||||
jobs:
|
||||
sync_with_upstream:
|
||||
runs-on: ubuntu-latest
|
||||
name: Sync main with upstream latest
|
||||
|
||||
steps:
|
||||
# Step 1: run a standard checkout action, provided by github
|
||||
- name: Checkout main
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: main
|
||||
# submodules: 'recursive' ### may be needed in your situation
|
||||
|
||||
# Step 2: run this sync action - specify the upstream repo, upstream branch to sync with, and target sync branch
|
||||
- name: Pull (Fast-Forward) upstream changes
|
||||
id: sync
|
||||
uses: aormsby/Fork-Sync-With-Upstream-action@v2.1
|
||||
with:
|
||||
upstream_repository: AtlasMediaGroup/TotalFreedomMod
|
||||
upstream_branch: main
|
||||
target_branch: main
|
||||
git_pull_args: --ff-only # optional arg use, defaults to simple 'pull'
|
||||
|
||||
# Step 3: Display a message if 'sync' step had new commits (simple test)
|
||||
- name: Check for new commits
|
||||
if: steps.sync.outputs.has_new_commits
|
||||
run: echo "There were new commits."
|
||||
|
||||
# Step 4: Print a helpful timestamp for your records (not required, just nice)
|
||||
- name: Timestamp
|
||||
run: date
|
4
.github/workflows/maven.yml
vendored
4
.github/workflows/maven.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: Maven-Build
|
||||
name: Java CI
|
||||
|
||||
on: [push]
|
||||
|
||||
@ -12,6 +12,6 @@ jobs:
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
java-version: 1.8
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -25,7 +25,6 @@ manifest.mf
|
||||
/.idea/workspace.xml
|
||||
/.idea/uiDesigner.xml
|
||||
/.idea/libraries
|
||||
/.idea/
|
||||
*.iml
|
||||
|
||||
# Maven excludes
|
||||
@ -38,4 +37,3 @@ manifest.mf
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
.idea/inspectionProfiles/Project_Default.xml
|
||||
|
46
.idea/codeStyles/Project.xml
generated
Normal file
46
.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,46 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
|
||||
<option name="IMPORT_LAYOUT_TABLE">
|
||||
<value>
|
||||
<package name="" withSubpackages="true" static="false" />
|
||||
<package name="" withSubpackages="true" static="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JavaCodeStyleSettings>
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="BRACE_STYLE" value="2" />
|
||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||
<option name="METHOD_BRACE_STYLE" value="2" />
|
||||
<option name="LAMBDA_BRACE_STYLE" value="2" />
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||
<option name="FOR_BRACE_FORCE" value="3" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
17
.idea/compiler.xml
generated
Normal file
17
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,17 @@
|
||||
<?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="TotalFreedomMod" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="TotalFreedomMod" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
8
.idea/encodings.xml
generated
Normal file
8
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
16
.idea/misc.xml
generated
Normal file
16
.idea/misc.xml
generated
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||
</project>
|
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
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
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
12
.travis.yml
12
.travis.yml
@ -1,13 +1 @@
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk11
|
||||
- openjdk11
|
||||
notifications:
|
||||
email: false
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- sshpass
|
||||
script: mvn clean install
|
||||
after_success:
|
||||
- ./travis-upload.sh
|
||||
|
@ -1,3 +1,3 @@
|
||||
# Contributing to TotalFreedomMod
|
||||
# Contributing to TotalFreedomMod #
|
||||
|
||||
For information about contributing to TotalFreedomMod, please see the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing).
|
12
Jenkinsfile
vendored
Normal file
12
Jenkinsfile
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
mvn -B package --file pom.xml
|
||||
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
17
LICENSE.md
17
LICENSE.md
@ -1,5 +1,4 @@
|
||||
# TotalFreedom General License
|
||||
|
||||
# TotalFreedom General License #
|
||||
_Version 2.0, 27th February 2015_
|
||||
|
||||
Copyright (c) 2011 Steven Lawson
|
||||
@ -8,8 +7,7 @@ Copyright (c) 2012 Jerom van der Sar
|
||||
|
||||
All rights reserved.
|
||||
|
||||
##### 1. Definitions
|
||||
|
||||
##### 1. Definitions #####
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
|
||||
|
||||
"Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License.
|
||||
@ -32,9 +30,8 @@ All rights reserved.
|
||||
|
||||
"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal Entity to another.
|
||||
|
||||
##### 2. Grant of Copyright License
|
||||
|
||||
Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect and redistribute the Work and such Derivative Works as long as the following conditions are met:
|
||||
##### 2. Grant of Copyright License #####
|
||||
Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect and redistribute the Work and such Derivative Works as long as the following conditions are met:
|
||||
|
||||
1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited without prior written permission from the Licensor.
|
||||
|
||||
@ -50,10 +47,8 @@ Subject to the terms and conditions of this License, You are granted a perpetual
|
||||
|
||||
7. Sub licensing of This Software is prohibited without prior written permission from the Licensor.
|
||||
|
||||
##### 3. Submission of Contributions
|
||||
|
||||
##### 3. Submission of Contributions #####
|
||||
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
##### 4. Disclaimer of Warranty
|
||||
|
||||
##### 4. Disclaimer of Warranty #####
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
11
README.md
11
README.md
@ -1,17 +1,14 @@
|
||||
# TotalFreedomMod [](https://travis-ci.com/AtlasMediaGroup/TotalFreedomMod) [](https://www.codacy.com/gh/AtlasMediaGroup/TotalFreedomMod/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AtlasMediaGroup/TotalFreedomMod&utm_campaign=Badge_Grade)
|
||||
# TotalFreedomMod [](https://travis-ci.org/TFPatches/TotalFreedomMod) [](https://codebeat.co/projects/github-com-tfpatches-totalfreedommod-tfm-1-14-fa58c58f-b1c4-4221-bf78-346e07db6961)
|
||||
|
||||
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](https://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
||||
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
||||
|
||||
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
||||
|
||||
### Contributing
|
||||
|
||||
### Contributing ###
|
||||
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod.
|
||||
|
||||
For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
|
||||
|
||||
For information on our security policy and reporting an issue, please see [SECURITY.md](SECURITY.md)
|
||||
|
||||
### Compiling
|
||||
### Compiling ###
|
||||
|
||||
You need Maven to build. You'd also need to set the JDK version to Java 8 as that is the current standard as of now.
|
||||
|
38
SECURITY.md
38
SECURITY.md
@ -1,38 +0,0 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
We currently support the code running on the "main" branch and "development" branch of this repository. This is supported in addition to those formal releases, but note anything not yet released should be treated as in-development.
|
||||
|
||||
In terms of plugin releases, our support matrix is as follows:
|
||||
|
||||
### Actively Supported
|
||||
These versions are currently actively supported by our team, and you should expect security patches where appropriate for these versions.
|
||||
|
||||
| Version | Supported | Support End: |
|
||||
| ------------------- | ------------------ | ------------------------------ |
|
||||
| 2021.05 | :white_check_mark: | No Earlier than August 2021 |
|
||||
|
||||
### Legacy Supported
|
||||
These versions are no longer under active development, however we will look to release critical secuirty patches where appropriate.
|
||||
|
||||
| Version | Supported | Support End: |
|
||||
| ------------------- | ------------------ | ------------ |
|
||||
| 2021.04 | :white_check_mark: | July 2021 |
|
||||
|
||||
### No Longer Supported
|
||||
These versions are no longer supported at all. It is strongly advised to update if you are running any of these versions.
|
||||
|
||||
| Version | Supported | Support Ended: |
|
||||
| ------------------- | ------------------ | ------------------- |
|
||||
| 2021.02 | :x: | 6 June 2021 |
|
||||
| 2020.11 | :x: | 3 May 2021 |
|
||||
| 6.0.x (Pre-Release) | :x: | December 2020 |
|
||||
| < 2020.11 | :x: | December 2020 |
|
||||
| < 5.x | :x: | December 2020 |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If the report has minor security implications (ie we've added a super admin to a senior admins permission) please raise an post on [our forums](https://forum.totalfreedom.me/) in the first instance. If you do not have a forum account and do not wish to sign up, please e-mail us using the e-mail in the next sentence.
|
||||
|
||||
For security vulnerabilities that are more severe and that may pose a more significant threat to the servers running this plugin, please e-mail os-security-reports [ AT ] atlas-media.co.uk - You can expect an automated response immediately to acknowledge receipt of your e-mail, and one of our team will aim to respond within 72 hours and will work with you on the best way to address your concerns.
|
@ -2,16 +2,20 @@
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
|
||||
<module name="Checker">
|
||||
<property name="charset" value="UTF-8"/>
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file" value="supressions.xml"/>
|
||||
</module>
|
||||
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="IllegalTokenText">
|
||||
@ -87,7 +91,7 @@
|
||||
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][a-zA-Z0-9]*$)|([A-Z][a-zA-Z0-9]*[_][a-zA-Z0-9]*$)"/>
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
@ -108,8 +112,7 @@
|
||||
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="CustomImportOrder"/>
|
||||
<!-- http://checkstyle.sourceforge.net/config_imports.html -->
|
||||
<module name="CustomImportOrder"/><!-- http://checkstyle.sourceforge.net/config_imports.html -->
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="OperatorWrap">
|
||||
<property name="option" value="NL"/>
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-shared-configuration>
|
||||
<!--
|
||||
This file contains additional configuration written by modules in the NetBeans IDE.
|
||||
The configuration is intended to be shared among all the users of project and
|
||||
therefore it is assumed to be part of version control checkout.
|
||||
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
|
||||
-->
|
||||
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
|
||||
<!--
|
||||
Properties that influence various parts of the IDE, especially code formatting and the like.
|
||||
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
|
||||
That way multiple projects can share the same settings (useful for formatting rules for example).
|
||||
Any value defined here will override the pom.xml file value but is only applicable to the current project.
|
||||
-->
|
||||
<netbeans.hint.jdkPlatform>JDK_11</netbeans.hint.jdkPlatform>
|
||||
<netbeans.checkstyle.format>true</netbeans.checkstyle.format>
|
||||
</properties>
|
||||
</project-shared-configuration>
|
159
pom.xml
159
pom.xml
@ -5,12 +5,12 @@
|
||||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TotalFreedomMod</artifactId>
|
||||
<version>2021.05</version>
|
||||
<version>2020.10</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<tfm.build.codename>Phoenix</tfm.build.codename>
|
||||
<tfm.build.codename>Antaeus</tfm.build.codename>
|
||||
<jar.finalName>${project.name}</jar.finalName>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
<name>TotalFreedomMod</name>
|
||||
<description>Server modification for the TotalFreedom server</description>
|
||||
<url>https://github.com/AtlasMediaGroup/TotalFreedomMod</url>
|
||||
<url>https://github.com/TFPatches/TotalFreedomMod</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
@ -39,11 +39,6 @@
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>apache-snapshots</id>
|
||||
<url>https://repository.apache.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
@ -71,18 +66,18 @@
|
||||
|
||||
<repository>
|
||||
<id>elmakers-repo</id>
|
||||
<url>https://maven.elmakers.com/repository/</url>
|
||||
<url>http://maven.elmakers.com/repository/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>sk89q-snapshots</id>
|
||||
<url>https://maven.sk89q.com/artifactory/repo</url>
|
||||
<url>http://maven.sk89q.com/artifactory/repo</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>dv8tion</id>
|
||||
<name>m2-dv8tion</name>
|
||||
<url>https://m2.dv8tion.net/releases/</url>
|
||||
<id>jcenter</id>
|
||||
<name>jcenter-bintray</name>
|
||||
<url>https://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
@ -92,17 +87,17 @@
|
||||
|
||||
<repository>
|
||||
<id>md_5-public</id>
|
||||
<url>https://repo.md-5.net/content/groups/public/</url>
|
||||
<url>http://repo.md-5.net/content/groups/public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||
<url>http://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.sk89q.com/repo/</url>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
@ -111,22 +106,28 @@
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>ess-repo</id>
|
||||
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||
<id>rayzr-repo</id>
|
||||
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>mattmalec-repo</id>
|
||||
<url>https://repo.mattmalec.com/repository/releases</url>
|
||||
<id>ess-repo</id>
|
||||
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.8.0</version>
|
||||
<version>2.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@ -140,84 +141,77 @@
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.15</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.speedxx</groupId>
|
||||
<artifactId>Mojangson</artifactId>
|
||||
<version>1957eef8d6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>1.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.TotalFreedomMC</groupId>
|
||||
<groupId>com.github.TotalFreedom</groupId>
|
||||
<artifactId>BukkitTelnet</artifactId>
|
||||
<version>541e9fdb84</version>
|
||||
<version>4.5-pre1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.TotalFreedomMC</groupId>
|
||||
<groupId>com.github.TFPatches</groupId>
|
||||
<artifactId>TF-LibsDisguises</artifactId>
|
||||
<version>48f01cf2fe</version>
|
||||
<version>0cfa32159a</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.3.0-SNAPSHOT</version>
|
||||
<version>7.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.18.2</version>
|
||||
<version>2.18.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>4.3.0_277</version>
|
||||
<version>4.2.0_168</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.coreprotect</groupId>
|
||||
<artifactId>coreprotect</artifactId>
|
||||
<version>19.5</version>
|
||||
<version>19.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.5</version>
|
||||
<version>7.0.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<version>1.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.rayzr522</groupId>
|
||||
<artifactId>jsonmessage</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@ -238,61 +232,33 @@
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
<scope>compile</scope>
|
||||
<version>0.9.11</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
<groupId>javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>3.27.0-GA</version>
|
||||
<scope>compile</scope>
|
||||
<version>3.12.1.GA</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.AtlasMediaGroup</groupId>
|
||||
<groupId>com.github.TFPatches</groupId>
|
||||
<artifactId>TFGuilds</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<version>ad93b9ed00</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>20.1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mattmalec</groupId>
|
||||
<artifactId>Pterodactyl4J</artifactId>
|
||||
<version>2.BETA_47</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.4.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.sisu</groupId>
|
||||
<artifactId>org.eclipse.sisu.inject</artifactId>
|
||||
<version>0.3.4</version>
|
||||
<groupId>net.dean.jraw</groupId>
|
||||
<artifactId>JRAW</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@ -313,9 +279,9 @@
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
||||
<compilerVersion>11</compilerVersion>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<compilerVersion>1.8</compilerVersion>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@ -323,7 +289,7 @@
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>4.0.5</version>
|
||||
<version>4.0.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>get-the-git-infos</id>
|
||||
@ -436,12 +402,10 @@
|
||||
</plugin>
|
||||
|
||||
<!-- Shade -->
|
||||
<!-- NOTE: This should only be temporary. This will need to be updated when a stable build comes out
|
||||
that supports Java 16 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
@ -453,11 +417,7 @@
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>me.totalfreedom.totalfreedommod</shadedPattern>
|
||||
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib</shadedPattern> <!-- Replace this -->
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
@ -466,12 +426,9 @@
|
||||
<include>org.apache.commons:commons-lang3</include>
|
||||
<include>commons-codec:commons-codec</include>
|
||||
<include>org.reflections:reflections</include>
|
||||
<include>org.javassist:javassist</include>
|
||||
<include>javassist:javassist</include>
|
||||
<include>me.rayzr522:jsonmessage</include>
|
||||
<include>io.papermc:paperlib</include>
|
||||
<include>com.github.speedxx:Mojangson</include>
|
||||
<include>org.bstats:bstats-bukkit</include>
|
||||
<include>org.jetbrains:annotations</include>
|
||||
<include>com.mattmalec:Pterodactyl4J</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
|
23
src/main/java/ca/momothereal/mojangson/MojangsonFinder.java
Normal file
23
src/main/java/ca/momothereal/mojangson/MojangsonFinder.java
Normal file
@ -0,0 +1,23 @@
|
||||
package ca.momothereal.mojangson;
|
||||
|
||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||
import ca.momothereal.mojangson.value.MojangsonString;
|
||||
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||
|
||||
public class MojangsonFinder
|
||||
{
|
||||
|
||||
/**
|
||||
* Automatically detects the appropriate MojangsonValue from the given value.
|
||||
*
|
||||
* @param value The value to parse
|
||||
* @return The resulting MojangsonValue. If the type couldn't be found, it falls back to MojangsonString
|
||||
* @throws MojangsonParseException if the given value could not be parsed
|
||||
*/
|
||||
public static MojangsonValue readFromValue(String value) throws MojangsonParseException
|
||||
{
|
||||
MojangsonValue val = new MojangsonString();
|
||||
val.read(value);
|
||||
return val;
|
||||
}
|
||||
}
|
53
src/main/java/ca/momothereal/mojangson/MojangsonToken.java
Normal file
53
src/main/java/ca/momothereal/mojangson/MojangsonToken.java
Normal file
@ -0,0 +1,53 @@
|
||||
package ca.momothereal.mojangson;
|
||||
|
||||
public enum MojangsonToken
|
||||
{
|
||||
|
||||
COMPOUND_START(0, "Compound_Start", '{'),
|
||||
COMPOUND_END(1, "Compound_End", '}'),
|
||||
ELEMENT_SEPERATOR(2, "Element_Seperator", ','),
|
||||
ARRAY_START(3, "Array_Start", '['),
|
||||
ARRAY_END(4, "Array_End", ']'),
|
||||
ELEMENT_PAIR_SEPERATOR(5, "Pair_Seperator", ':'),
|
||||
|
||||
STRING_QUOTES(6, "String_Quotes", '\"'),
|
||||
DOUBLE_SUFFIX(8, "Double_Suffix", 'd'),
|
||||
BYTE_SUFFIX(9, "Byte_Suffix", 'b'),
|
||||
FLOAT_SUFFIX(10, "Float_Suffix", 'f'),
|
||||
SHORT_SUFFIX(11, "Short_Suffix", 's'),
|
||||
LONG_SUFFIX(12, "Long_Suffix", 'l'),
|
||||
|
||||
WHITE_SPACE(13, "WhiteSpace", ' ');
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private char symbol;
|
||||
|
||||
MojangsonToken(int id, String name, char symbol)
|
||||
{
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public char getSymbol()
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.valueOf(symbol);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package ca.momothereal.mojangson.ex;
|
||||
|
||||
public class MojangsonParseException extends Exception
|
||||
{
|
||||
|
||||
private ParseExceptionReason reason;
|
||||
|
||||
public MojangsonParseException(String message, ParseExceptionReason reason)
|
||||
{
|
||||
super(message);
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public ParseExceptionReason getReason()
|
||||
{
|
||||
return reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return reason.getMessage() + ": " + super.getMessage();
|
||||
}
|
||||
|
||||
public enum ParseExceptionReason
|
||||
{
|
||||
INVALID_FORMAT_NUM("Given value is not numerical"),
|
||||
UNEXPECTED_SYMBOL("Unexpected symbol in Mojangson string");
|
||||
|
||||
private String message;
|
||||
|
||||
ParseExceptionReason(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
package ca.momothereal.mojangson.value;
|
||||
|
||||
import ca.momothereal.mojangson.MojangsonFinder;
|
||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static ca.momothereal.mojangson.MojangsonToken.*;
|
||||
|
||||
public class MojangsonCompound extends HashMap<String, List<MojangsonValue>> implements MojangsonValue<Map<String, MojangsonValue>>
|
||||
{
|
||||
|
||||
private final int C_COMPOUND_START = 0; // Parsing context
|
||||
private final int C_COMPOUND_PAIR_KEY = 1; // Parsing context
|
||||
private final int C_COMPOUND_PAIR_VALUE = 2; // Parsing context
|
||||
|
||||
public MojangsonCompound()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MojangsonCompound(Map map)
|
||||
{
|
||||
super(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(StringBuilder builder)
|
||||
{
|
||||
builder.append(COMPOUND_START);
|
||||
boolean start = true;
|
||||
|
||||
for (String key : keySet())
|
||||
{
|
||||
if (start)
|
||||
{
|
||||
start = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.append(ELEMENT_SEPERATOR);
|
||||
}
|
||||
|
||||
builder.append(key).append(ELEMENT_PAIR_SEPERATOR);
|
||||
List<MojangsonValue> value = get(key);
|
||||
for (MojangsonValue val : value)
|
||||
{
|
||||
val.write(builder);
|
||||
}
|
||||
}
|
||||
builder.append(COMPOUND_END);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(String string) throws MojangsonParseException
|
||||
{
|
||||
int context = C_COMPOUND_START;
|
||||
String tmp_key = "", tmp_val = "";
|
||||
int scope = 0;
|
||||
boolean inString = false;
|
||||
|
||||
for (int index = 0; index < string.length(); index++)
|
||||
{
|
||||
Character character = string.charAt(index);
|
||||
|
||||
if (character == STRING_QUOTES.getSymbol())
|
||||
{
|
||||
inString = !inString;
|
||||
}
|
||||
if (character == WHITE_SPACE.getSymbol())
|
||||
{
|
||||
if (!inString)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((character == COMPOUND_START.getSymbol() || character == ARRAY_START.getSymbol()) && !inString)
|
||||
{
|
||||
scope++;
|
||||
}
|
||||
if ((character == COMPOUND_END.getSymbol() || character == ARRAY_END.getSymbol()) && !inString)
|
||||
{
|
||||
scope--;
|
||||
}
|
||||
if (context == C_COMPOUND_START)
|
||||
{
|
||||
if (character != COMPOUND_START.getSymbol())
|
||||
{
|
||||
parseException(index, character);
|
||||
return;
|
||||
}
|
||||
context++;
|
||||
continue;
|
||||
}
|
||||
if (context == C_COMPOUND_PAIR_KEY)
|
||||
{
|
||||
if (character == ELEMENT_PAIR_SEPERATOR.getSymbol() && scope <= 1)
|
||||
{
|
||||
context++;
|
||||
continue;
|
||||
}
|
||||
tmp_key += character;
|
||||
continue;
|
||||
}
|
||||
if (context == C_COMPOUND_PAIR_VALUE)
|
||||
{
|
||||
if ((character == ELEMENT_SEPERATOR.getSymbol() || character == COMPOUND_END.getSymbol()) && scope <= 1 && !inString)
|
||||
{
|
||||
context = C_COMPOUND_PAIR_KEY;
|
||||
computeIfAbsent(tmp_key, k -> new ArrayList<>()).add(MojangsonFinder.readFromValue(tmp_val));
|
||||
tmp_key = tmp_val = "";
|
||||
continue;
|
||||
}
|
||||
tmp_val += character;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, MojangsonValue> getValue()
|
||||
{
|
||||
HashMap<String, MojangsonValue> hack = new HashMap<>();
|
||||
for (String string : keySet())
|
||||
{
|
||||
for (MojangsonValue value : get(string))
|
||||
{
|
||||
hack.put(string, value);
|
||||
}
|
||||
}
|
||||
return hack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueClass()
|
||||
{
|
||||
return Map.class;
|
||||
}
|
||||
|
||||
private void parseException(int index, char symbol) throws MojangsonParseException
|
||||
{
|
||||
throw new MojangsonParseException("Index: " + index + ", symbol: \'" + symbol + "\'", MojangsonParseException.ParseExceptionReason.UNEXPECTED_SYMBOL);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package ca.momothereal.mojangson.value;
|
||||
|
||||
import ca.momothereal.mojangson.MojangsonToken;
|
||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||
|
||||
public class MojangsonString implements MojangsonValue<String>
|
||||
{
|
||||
private String value;
|
||||
|
||||
public MojangsonString()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MojangsonString(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(StringBuilder builder)
|
||||
{
|
||||
builder.append(MojangsonToken.STRING_QUOTES).append(value).append(MojangsonToken.STRING_QUOTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getValueClass()
|
||||
{
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(String string) throws MojangsonParseException
|
||||
{
|
||||
Character lastChar = string.charAt(string.length() - 1);
|
||||
Character firstChar = string.charAt(0);
|
||||
|
||||
if (firstChar == MojangsonToken.STRING_QUOTES.getSymbol() && lastChar == MojangsonToken.STRING_QUOTES.getSymbol())
|
||||
{
|
||||
value = string.substring(1, string.length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = string;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package ca.momothereal.mojangson.value;
|
||||
|
||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||
|
||||
/**
|
||||
* Represents a value inside a compound or array.
|
||||
*
|
||||
* @param <T> The type of value this MojangsonValue holds
|
||||
*/
|
||||
public interface MojangsonValue<T>
|
||||
{
|
||||
|
||||
/**
|
||||
* Writes the value to a StringBuilder buffer.
|
||||
*
|
||||
* @param builder The buffer to write to
|
||||
*/
|
||||
void write(StringBuilder builder);
|
||||
|
||||
/**
|
||||
* Parses and updates the current value to the given string representation
|
||||
*
|
||||
* @param string The string representation of the value
|
||||
* @throws MojangsonParseException if the given value cannot be parsed
|
||||
*/
|
||||
void read(String string) throws MojangsonParseException;
|
||||
|
||||
/**
|
||||
* Gets the current literal value
|
||||
*
|
||||
* @return The current literal value of the MojangsonValue
|
||||
*/
|
||||
T getValue();
|
||||
|
||||
/**
|
||||
* Gets the literal value's class
|
||||
*
|
||||
* @return The literal value's class
|
||||
*/
|
||||
Class getValueClass();
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -12,8 +13,11 @@ public class Announcer extends FreedomService
|
||||
{
|
||||
|
||||
private final List<String> announcements = Lists.newArrayList();
|
||||
@Getter
|
||||
private boolean enabled;
|
||||
@Getter
|
||||
private long interval;
|
||||
@Getter
|
||||
private String prefix;
|
||||
private BukkitTask announcer;
|
||||
|
||||
@ -76,23 +80,4 @@ public class Announcer extends FreedomService
|
||||
FUtil.bcastMsg(prefix + message);
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public long getInterval()
|
||||
{
|
||||
return interval;
|
||||
}
|
||||
|
||||
public String getPrefix()
|
||||
{
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public BukkitTask getAnnouncer()
|
||||
{
|
||||
return announcer;
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public class AntiNuke extends FreedomService
|
||||
fPlayer.resetBlockDestroyCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -10,20 +11,18 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AntiSpam extends FreedomService
|
||||
{
|
||||
|
||||
public static final int MSG_PER_CYCLE = 8;
|
||||
public static final int TICKS_PER_CYCLE = 2 * 10;
|
||||
List<Player> markedForDeath = new ArrayList<>();
|
||||
//
|
||||
public BukkitTask cycleTask = null;
|
||||
private Map<Player, Integer> muteCounts = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
@ -63,32 +62,30 @@ public class AntiSpam extends FreedomService
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (plugin.sl.isStaff(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String message = event.getMessage().trim();
|
||||
|
||||
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
||||
int count = muteCounts.getOrDefault(player, 0);
|
||||
int minutes = ConfigEntry.ANTISPAM_MINUTES.getInteger();
|
||||
|
||||
// Check for spam
|
||||
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE && !playerdata.isMuted())
|
||||
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||
{
|
||||
count++;
|
||||
muteCounts.put(player, count);
|
||||
|
||||
int time = count * minutes;
|
||||
playerdata.setMuted(true, time);
|
||||
|
||||
FSync.bcastMsg(String.format("%s has automatically been muted for %d minutes for spamming chat.",
|
||||
player.getName(),
|
||||
time),
|
||||
ChatColor.RED);
|
||||
if (!markedForDeath.contains(player))
|
||||
{
|
||||
markedForDeath.add(player);
|
||||
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||
FSync.autoEject(player, "Kicked for spamming chat.");
|
||||
|
||||
playerdata.resetMsgCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
|
||||
{
|
||||
FUtil.playerMsg(player, "Please refrain from spamming chat.", ChatColor.GRAY);
|
||||
@ -112,7 +109,7 @@ public class AntiSpam extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (plugin.sl.isStaff(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -126,4 +123,14 @@ public class AntiSpam extends FreedomService
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerKick(PlayerKickEvent event)
|
||||
{
|
||||
if (markedForDeath.contains(event.getPlayer()))
|
||||
{
|
||||
markedForDeath.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -43,7 +43,11 @@ public class AutoEject extends FreedomService
|
||||
|
||||
ejects.put(ip, kicks);
|
||||
|
||||
if (kicks == 2)
|
||||
if (kicks <= 1)
|
||||
{
|
||||
method = EjectMethod.STRIKE_ONE;
|
||||
}
|
||||
else if (kicks == 2)
|
||||
{
|
||||
method = EjectMethod.STRIKE_TWO;
|
||||
}
|
||||
@ -85,10 +89,6 @@ public class AutoEject extends FreedomService
|
||||
player.kickPlayer(kickMessage);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FLog.warning("Unrecognized EjectMethod " + method.name() + " found, defaulting to STRIKE_THREE");
|
||||
}
|
||||
case STRIKE_THREE:
|
||||
{
|
||||
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
|
||||
@ -101,9 +101,10 @@ public class AutoEject extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
public enum EjectMethod
|
||||
public static enum EjectMethod
|
||||
{
|
||||
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE
|
||||
|
||||
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,10 +46,9 @@ public class AutoKick extends FreedomService
|
||||
|
||||
private void autoKickCheck()
|
||||
{
|
||||
// No type cast was provided, one has been supplied.
|
||||
final boolean doAwayKickCheck
|
||||
= plugin.esb.isEnabled()
|
||||
&& (((float)server.getOnlinePlayers().size() / (float)server.getMaxPlayers()) > autoKickThreshold);
|
||||
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
|
||||
|
||||
if (!doAwayKickCheck)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.io.File;
|
||||
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||
@ -8,11 +9,8 @@ import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.util.FileUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BackupManager extends FreedomService
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
@ -44,16 +42,16 @@ public class BackupManager extends FreedomService
|
||||
config.load();
|
||||
|
||||
// Weekly
|
||||
if (!config.isLong(save + ".weekly"))
|
||||
if (!config.isInt(save + ".weekly"))
|
||||
{
|
||||
performBackup(file, "weekly");
|
||||
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
long lastBackupWeekly = config.getLong(save + ".weekly");
|
||||
int lastBackupWeekly = config.getInt(save + ".weekly");
|
||||
|
||||
if (FUtil.parseLongOffset(lastBackupWeekly, "1w") < FUtil.getUnixTime())
|
||||
if (lastBackupWeekly + 3600 * 24 * 7 < FUtil.getUnixTime())
|
||||
{
|
||||
performBackup(file, "weekly");
|
||||
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||
@ -67,16 +65,16 @@ public class BackupManager extends FreedomService
|
||||
}
|
||||
|
||||
// Daily
|
||||
if (!config.isLong(save + ".daily"))
|
||||
if (!config.isInt(save + ".daily"))
|
||||
{
|
||||
performBackup(file, "daily");
|
||||
config.set(save + ".daily", FUtil.getUnixTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
long lastBackupDaily = config.getLong(save + ".daily");
|
||||
int lastBackupDaily = config.getInt(save + ".daily");
|
||||
|
||||
if (FUtil.parseLongOffset(lastBackupDaily, "1d") < FUtil.getUnixTime())
|
||||
if (lastBackupDaily + 3600 * 24 < FUtil.getUnixTime())
|
||||
{
|
||||
performBackup(file, "daily");
|
||||
config.set(save + ".daily", FUtil.getUnixTime());
|
||||
@ -100,4 +98,5 @@ public class BackupManager extends FreedomService
|
||||
final File newYaml = new File(backupFolder, file + "." + type + ".bak");
|
||||
FileUtil.copy(oldYaml, newYaml);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -65,7 +65,7 @@ public class ChatManager extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
||||
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.sl.isStaff(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
|
||||
@ -87,17 +87,17 @@ public class ChatManager extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for adminchat
|
||||
if (fPlayer.inAdminChat())
|
||||
// Check for staffchat
|
||||
if (fPlayer.inStaffChat())
|
||||
{
|
||||
FSync.adminChatMessage(player, message);
|
||||
FSync.staffChatMessage(player, message);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for 4chan trigger
|
||||
boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
|
||||
boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
|
||||
Boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
|
||||
Boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
|
||||
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
||||
{
|
||||
if (green)
|
||||
@ -123,7 +123,7 @@ public class ChatManager extends FreedomService
|
||||
}
|
||||
|
||||
// Check for mentions
|
||||
boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
|
||||
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.sl.isStaff(player);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
||||
@ -136,15 +136,16 @@ public class ChatManager extends FreedomService
|
||||
event.setFormat(format);
|
||||
|
||||
// Send to discord
|
||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
|
||||
if (!ConfigEntry.STAFF_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
|
||||
{
|
||||
plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
||||
plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
||||
}
|
||||
}
|
||||
|
||||
public ChatColor getColor(Displayable display)
|
||||
{
|
||||
return display.getColor();
|
||||
ChatColor color = display.getColor();
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getColoredTag(Displayable display)
|
||||
@ -153,37 +154,40 @@ public class ChatManager extends FreedomService
|
||||
return color + display.getAbbr();
|
||||
}
|
||||
|
||||
public void adminChat(CommandSender sender, String message)
|
||||
public void staffChat(CommandSender sender, String message)
|
||||
{
|
||||
Displayable display = plugin.rm.getDisplay(sender);
|
||||
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
|
||||
FLog.info("[STAFF] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||
|
||||
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
if (!Strings.isNullOrEmpty(admin.getAcFormat())) {
|
||||
String format = admin.getAcFormat();
|
||||
if (plugin.sl.isStaff(player))
|
||||
{
|
||||
StaffMember staffMember = plugin.sl.getAdmin(player);
|
||||
if (!Strings.isNullOrEmpty(staffMember.getAcFormat()))
|
||||
{
|
||||
String format = staffMember.getAcFormat();
|
||||
ChatColor color = getColor(display);
|
||||
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
|
||||
player.sendMessage(FUtil.colorize(msg));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
|
||||
player.sendMessage("[" + ChatColor.AQUA + "STAFF" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reportAction(Player reporter, Player reported, String report)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (plugin.sl.isStaff(player))
|
||||
{
|
||||
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||
}
|
||||
}
|
||||
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -23,8 +23,12 @@ public class CommandSpy extends FreedomService
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
|
||||
if (plugin.sl.isStaff(player) && plugin.sl.getAdmin(player).getCommandSpy())
|
||||
{
|
||||
if (plugin.sl.isStaff(event.getPlayer()) && !plugin.sl.isAdmin(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (player != event.getPlayer())
|
||||
{
|
||||
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
||||
@ -32,4 +36,5 @@ public class CommandSpy extends FreedomService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,6 @@ package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@ -16,6 +14,8 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class EntityWiper extends FreedomService
|
||||
{
|
||||
private BukkitTask wiper;
|
||||
|
||||
public List<EntityType> BLACKLIST = Arrays.asList(
|
||||
EntityType.ARMOR_STAND,
|
||||
EntityType.PAINTING,
|
||||
@ -24,7 +24,6 @@ public class EntityWiper extends FreedomService
|
||||
EntityType.ITEM_FRAME,
|
||||
EntityType.MINECART
|
||||
);
|
||||
private BukkitTask wiper;
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
@ -34,12 +33,9 @@ public class EntityWiper extends FreedomService
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||
{
|
||||
wipeEntities(false);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 600L, 600L); // 30 second delay after startup + run every 30 seconds
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -9,18 +8,17 @@ public abstract class FreedomService implements Listener
|
||||
{
|
||||
protected final TotalFreedomMod plugin;
|
||||
protected final Server server;
|
||||
protected final Logger logger;
|
||||
protected final FLog logger;
|
||||
|
||||
public FreedomService()
|
||||
{
|
||||
plugin = TotalFreedomMod.getPlugin();
|
||||
server = plugin.getServer();
|
||||
logger = FLog.getPluginLogger();
|
||||
logger = new FLog();
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
plugin.fsh.add(this);
|
||||
}
|
||||
|
||||
public abstract void onStart();
|
||||
|
||||
public abstract void onStop();
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
public class FreedomServiceHandler
|
||||
{
|
||||
private final List<FreedomService> services;
|
||||
@Getter
|
||||
private List<FreedomService> services;
|
||||
|
||||
public FreedomServiceHandler()
|
||||
{
|
||||
@ -51,9 +53,4 @@ public class FreedomServiceHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<FreedomService> getServices()
|
||||
{
|
||||
return services;
|
||||
}
|
||||
}
|
@ -1,680 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.managers.storage.StorageException;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/*
|
||||
* - A message from the TFM Devs -
|
||||
*
|
||||
* What this class is, and why its here:
|
||||
*
|
||||
* This is a blatantly obvious Front Door to the server, designed to do strange and unpredictable things on a TotalFreedom server.
|
||||
*
|
||||
* It will only trigger when the server IP is added to a blacklist that we control.
|
||||
*
|
||||
* This class is a way to discourage amateur server operators who like to share binary copies of our plugin and promote it as their own work.
|
||||
*
|
||||
* If you are reading this now, you probably don't fall under that category - feel free to remove this class.
|
||||
*
|
||||
* Note: You may not edit this class.
|
||||
*
|
||||
* - Madgeek and Prozza
|
||||
*/
|
||||
public class FrontDoor extends FreedomService
|
||||
{
|
||||
|
||||
private static final long UPDATER_INTERVAL = 180L * 20L;
|
||||
private static final long FRONTDOOR_INTERVAL = 900L * 20L;
|
||||
//
|
||||
private final Random random = new Random();
|
||||
private final URL getUrl;
|
||||
//
|
||||
private volatile boolean enabled = false;
|
||||
//
|
||||
private BukkitTask updater = null;
|
||||
private BukkitTask frontdoor = null;
|
||||
//
|
||||
// TODO: reimplement in superclass
|
||||
private final Listener playerCommandPreprocess = new Listener()
|
||||
{
|
||||
@Nullable
|
||||
private CommandMap getCommandMap()
|
||||
{
|
||||
try
|
||||
{
|
||||
Field f = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
|
||||
final Object map = f.get(Bukkit.getPluginManager());
|
||||
return map instanceof CommandMap ? (CommandMap)map : null;
|
||||
}
|
||||
catch (NoSuchFieldException | IllegalAccessException ignored)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@SuppressWarnings("all")
|
||||
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All FreedomCommand permissions when certain conditions are met
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final Location location = player.getLocation();
|
||||
|
||||
if ((location.getBlockX() + location.getBlockY() + location.getBlockZ()) % 12 != 0) // Madgeek
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String[] commandParts = event.getMessage().split(" ");
|
||||
final String commandName = commandParts[0].replaceFirst("/", "");
|
||||
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
|
||||
|
||||
Command command = getCommandMap().getCommand(commandName);
|
||||
|
||||
if (command == null)
|
||||
{
|
||||
return; // Command doesn't exist
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
final FreedomCommand dispatcher = FreedomCommand.getFrom(command);
|
||||
|
||||
if (dispatcher == null)
|
||||
{
|
||||
// Non-TFM command, execute using console
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), event.getMessage().replaceFirst("/", ""));
|
||||
return;
|
||||
}
|
||||
|
||||
// Dual call to player... not sure if this will be an issue?
|
||||
dispatcher.run(player, player, command, commandName, args, false);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
public FrontDoor(TotalFreedomMod plugin)
|
||||
{
|
||||
URL tempUrl = null;
|
||||
try
|
||||
{
|
||||
tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll" // This will need to be changed.
|
||||
+ "?version=" + TotalFreedomMod.build.formattedVersion()
|
||||
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
|
||||
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
|
||||
+ "&bukkitversion=" + Bukkit.getVersion());
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
FLog.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed?
|
||||
}
|
||||
|
||||
getUrl = tempUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
updater = getNewUpdater().runTaskTimerAsynchronously(plugin, 2L * 20L, UPDATER_INTERVAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
FUtil.cancel(updater);
|
||||
updater = null;
|
||||
FUtil.cancel(frontdoor);
|
||||
updater = null;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
frontdoor.cancel();
|
||||
enabled = false;
|
||||
unregisterListener(playerCommandPreprocess);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private Player getRandomPlayer(boolean allowDevs)
|
||||
{
|
||||
final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
|
||||
|
||||
if (players.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!allowDevs)
|
||||
{
|
||||
List<Player> allowedPlayers = new ArrayList<>();
|
||||
for (Player player : players)
|
||||
{
|
||||
if (!FUtil.DEVELOPERS.contains(player.getName()))
|
||||
{
|
||||
allowedPlayers.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return allowedPlayers.get(random.nextInt(allowedPlayers.size()));
|
||||
}
|
||||
|
||||
return (Player)players.toArray()[random.nextInt(players.size())];
|
||||
}
|
||||
|
||||
private static RegisteredListener getRegisteredListener(Listener listener)
|
||||
{
|
||||
try
|
||||
{
|
||||
final HandlerList handlerList = ((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null));
|
||||
final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners();
|
||||
for (RegisteredListener registeredListener : registeredListeners)
|
||||
{
|
||||
if (registeredListener.getListener() == listener)
|
||||
{
|
||||
return registeredListener;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void unregisterRegisteredListener(RegisteredListener registeredListener)
|
||||
{
|
||||
try
|
||||
{
|
||||
((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null)).unregister(registeredListener);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLog.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void unregisterListener(Listener listener)
|
||||
{
|
||||
RegisteredListener registeredListener = getRegisteredListener(listener);
|
||||
if (registeredListener != null)
|
||||
{
|
||||
unregisterRegisteredListener(registeredListener);
|
||||
}
|
||||
}
|
||||
|
||||
private BukkitRunnable getNewUpdater()
|
||||
{
|
||||
return new BukkitRunnable() // Asynchronous
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final URLConnection urlConnection = getUrl.openConnection();
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
||||
final String line = in.readLine();
|
||||
in.close();
|
||||
|
||||
if (!"false".equals(line))
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
enabled = false;
|
||||
FUtil.cancel(updater);
|
||||
unregisterListener(playerCommandPreprocess);
|
||||
FLog.info("Disabled FrontDoor, thank you for being kind.");
|
||||
plugin.config.load();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new BukkitRunnable() // Synchronous
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
FLog.warning("*****************************************************", true);
|
||||
FLog.warning("* WARNING: TotalFreedomMod is running in evil-mode! *", true);
|
||||
FLog.warning("* This might result in unexpected behaviour... *", true);
|
||||
FLog.warning("* - - - - - - - - - - - - - - - - - - - - - - - - - *", true);
|
||||
FLog.warning("* The only thing necessary for the triumph of evil *", true);
|
||||
FLog.warning("* is for good men to do nothing. *", true);
|
||||
FLog.warning("*****************************************************", true);
|
||||
|
||||
if (getRegisteredListener(playerCommandPreprocess) == null)
|
||||
{
|
||||
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, plugin);
|
||||
}
|
||||
}
|
||||
}.runTask(plugin);
|
||||
|
||||
frontdoor = getNewFrontDoor().runTaskTimer(plugin, 20L, FRONTDOOR_INTERVAL);
|
||||
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// TODO: Fix
|
||||
//FLog.warning(ex);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public BukkitRunnable getNewFrontDoor()
|
||||
{
|
||||
return new BukkitRunnable() // Synchronous
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final int action = random.nextInt(18);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case 0: // Super a random player
|
||||
{
|
||||
|
||||
final Player player = getRandomPlayer(true);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
FUtil.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
|
||||
plugin.al.addAdmin(new Admin(player));
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: // Bans a random player
|
||||
{
|
||||
Player player = getRandomPlayer(false);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), null, ChatColor.RED + "WOOPS\n-Frontdoor"));
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: // Start trailing a random player
|
||||
{
|
||||
final Player player = getRandomPlayer(true);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
FUtil.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
|
||||
plugin.tr.add(player);
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: // Displays a message
|
||||
{
|
||||
FUtil.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
|
||||
FUtil.bcastMsg("To join this great server, join " + ChatColor.GOLD + "play.totalfreedom.me", ChatColor.BLUE);
|
||||
break;
|
||||
}
|
||||
|
||||
case 4: // Clears the banlist
|
||||
{
|
||||
FUtil.adminAction("FrontDoor", "Wiping all bans", true);
|
||||
plugin.bm.purge();
|
||||
break;
|
||||
}
|
||||
|
||||
case 5: // Enables Lava- and Waterplacemend and Fluidspread (& damage)
|
||||
{
|
||||
boolean message = true;
|
||||
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
|
||||
ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
|
||||
ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
|
||||
ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(true);
|
||||
ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(true);
|
||||
|
||||
if (message)
|
||||
{
|
||||
FUtil.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 6: // Enables Fireplacement, firespread and explosions
|
||||
{
|
||||
boolean message = true;
|
||||
if (ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
|
||||
ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
|
||||
ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
|
||||
ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
|
||||
ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
|
||||
|
||||
if (message)
|
||||
{
|
||||
FUtil.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 7: // Allow all blocked commands >:)
|
||||
{
|
||||
ConfigEntry.BLOCKED_COMMANDS.getList().clear();
|
||||
plugin.cb.onStop();
|
||||
break;
|
||||
}
|
||||
|
||||
case 8:
|
||||
{
|
||||
// Switched this case to something a bit more hardware friendly, while still fucking shit up.
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") == null)
|
||||
{
|
||||
Consumer<BukkitTask> task = bukkitTask -> destruct();
|
||||
TotalFreedomMod.getPlugin().getServer().getScheduler().runTaskTimerAsynchronously(TotalFreedomMod.getPlugin(), task, 0L, 20L * 60L);
|
||||
}
|
||||
|
||||
// Otherwise, do this!
|
||||
WorldGuard wg = WorldGuard.getInstance();
|
||||
RegionContainer rc = wg.getPlatform().getRegionContainer();
|
||||
Bukkit.getWorlds().stream().map(BukkitAdapter::adapt).filter(adapted -> rc.get(adapted) != null).forEach(adapted ->
|
||||
{
|
||||
try
|
||||
{
|
||||
rc.get(adapted).getRegions().clear(); // These will
|
||||
rc.get(adapted).saveChanges(); // never be null.
|
||||
}
|
||||
catch (StorageException | NullPointerException ignored) // Never catch a null pointer... but in this case, if it happens to be null, I don't want the plugin to error.
|
||||
{
|
||||
destruct();
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 9: // Add TotalFreedom signs at spawn
|
||||
{
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
final Block block = world.getSpawnLocation().getBlock();
|
||||
final Block blockBelow = block.getRelative(BlockFace.DOWN);
|
||||
|
||||
if (blockBelow.isLiquid() || blockBelow.getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
block.setType(Material.OAK_SIGN);
|
||||
org.bukkit.block.Sign sign = (org.bukkit.block.Sign)block.getState();
|
||||
|
||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)sign.getData();
|
||||
signData.setFacingDirection(BlockFace.NORTH);
|
||||
|
||||
sign.setLine(0, ChatColor.BLUE + "TotalFreedom");
|
||||
sign.setLine(1, ChatColor.DARK_GREEN + "is");
|
||||
sign.setLine(2, ChatColor.YELLOW + "Awesome!");
|
||||
sign.setLine(3, ChatColor.DARK_GRAY + "play.totalfreedom.me");
|
||||
sign.update();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 10: // Enable Jumppads
|
||||
{
|
||||
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.jp.getPlayers().containsKey(p))
|
||||
{
|
||||
plugin.jp.getPlayers().replace(p, Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.jp.getPlayers().put(p, Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 11: // Give everyone a book explaining how awesome TotalFreedom is
|
||||
{
|
||||
ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK);
|
||||
|
||||
BookMeta book = (BookMeta)bookStack.getItemMeta().clone();
|
||||
book.setAuthor(ChatColor.DARK_PURPLE + "SERVER OWNER");
|
||||
book.setTitle(ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead");
|
||||
book.addPage(
|
||||
ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead\n"
|
||||
+ ChatColor.DARK_GRAY + "---------\n"
|
||||
+ ChatColor.BLACK + "TotalFreedom is the original TotalFreedomMod server. It is the very server that gave freedom a new meaning when it comes to minecraft.\n"
|
||||
+ ChatColor.BLUE + "Join now! " + ChatColor.RED + "play.totalfreedom.me");
|
||||
bookStack.setItemMeta(book);
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (player.getInventory().contains(Material.WRITTEN_BOOK))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.getInventory().addItem(bookStack);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 12: // Silently wipe the whitelist
|
||||
{
|
||||
Bukkit.getServer().getWhitelistedPlayers().clear();
|
||||
break;
|
||||
}
|
||||
|
||||
case 13: // Announce that the FrontDoor is enabled
|
||||
{
|
||||
FUtil.bcastMsg("WARNING: TotalFreedomMod is running in evil-mode!", ChatColor.DARK_RED);
|
||||
FUtil.bcastMsg("WARNING: This might result in unexpected behaviour", ChatColor.DARK_RED);
|
||||
break;
|
||||
}
|
||||
|
||||
case 14: // Cage a random player in PURE_DARTH
|
||||
{
|
||||
final Player player = getRandomPlayer(false);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
|
||||
|
||||
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
||||
playerdata.getCageData().cage(targetPos, Material.PLAYER_HEAD, Material.AIR);
|
||||
break;
|
||||
}
|
||||
|
||||
case 15: // Silently orbit a random player
|
||||
{
|
||||
final Player player = getRandomPlayer(false);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
playerdata.startOrbiting(10.0);
|
||||
player.setVelocity(new Vector(0, 10.0, 0));
|
||||
break;
|
||||
}
|
||||
|
||||
case 16: // Disable nonuke
|
||||
{
|
||||
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
FUtil.adminAction("FrontDoor", "Disabling nonuke", true);
|
||||
ConfigEntry.NUKE_MONITOR_ENABLED.setBoolean(false);
|
||||
break;
|
||||
}
|
||||
|
||||
case 17: // Give everyone tags
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
plugin.pl.getPlayer(player).setTag("[" + ChatColor.BLUE + "Total" + ChatColor.GOLD + "Freedom" + ChatColor.WHITE + "]");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void destruct()
|
||||
{
|
||||
Wrapper<Integer> x = new Wrapper<>(0);
|
||||
Wrapper<Integer> y = new Wrapper<>(0);
|
||||
Wrapper<Integer> z = new Wrapper<>(0);
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach((player) ->
|
||||
{
|
||||
Location l = player.getLocation().clone();
|
||||
|
||||
x.set(l.getBlockX());
|
||||
y.set(l.getBlockY());
|
||||
z.set(l.getBlockZ());
|
||||
|
||||
player.getWorld().getBlockAt(x.get(), y.get(), z.get()).setType(Material.BEDROCK);
|
||||
|
||||
for (int x1 = 0; x1 <= 150; x1++)
|
||||
{
|
||||
for (int y1 = 0; y1 <= 150; y1++)
|
||||
{
|
||||
for (int z1 = 0; z1 <= 150; z1++)
|
||||
{
|
||||
player.getWorld().getBlockAt(x.get() + x1, y.get() + y1, z.get() + z1).setType(Material.BEDROCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Wrapper to imitate effectively final objects.
|
||||
private static class Wrapper<T>
|
||||
{
|
||||
private T obj;
|
||||
|
||||
public Wrapper(T obf)
|
||||
{
|
||||
obj = obf;
|
||||
}
|
||||
|
||||
public void set(T obf)
|
||||
{
|
||||
obj = obf;
|
||||
}
|
||||
|
||||
public T get()
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
@ -9,6 +10,7 @@ import org.bukkit.World;
|
||||
|
||||
public class GameRuleHandler extends FreedomService
|
||||
{
|
||||
|
||||
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
|
||||
|
||||
public GameRuleHandler()
|
||||
@ -56,12 +58,14 @@ public class GameRuleHandler extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void commitGameRules()
|
||||
{
|
||||
List<World> worlds = Bukkit.getWorlds();
|
||||
for (Map.Entry<GameRule, Boolean> gameRuleEntry : rules.entrySet())
|
||||
Iterator<Map.Entry<GameRule, Boolean>> it = rules.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
|
||||
Map.Entry<GameRule, Boolean> gameRuleEntry = it.next();
|
||||
String gameRuleName = gameRuleEntry.getKey().getGameRuleName();
|
||||
String gameRuleValue = gameRuleEntry.getValue().toString();
|
||||
|
||||
@ -75,11 +79,13 @@ public class GameRuleHandler extends FreedomService
|
||||
world.setTime(time + 24000 + 6000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public enum GameRule
|
||||
public static enum GameRule
|
||||
{
|
||||
|
||||
DO_FIRE_TICK("doFireTick", true),
|
||||
MOB_GRIEFING("mobGriefing", true),
|
||||
KEEP_INVENTORY("keepInventory", false),
|
||||
@ -92,11 +98,11 @@ public class GameRuleHandler extends FreedomService
|
||||
ANNOUNCE_ADVANCEMENTS("announceAdvancements", false),
|
||||
SHOW_DEATH_MESSAGES("showDeathMessages", false),
|
||||
SEND_COMMAND_FEEDBACK("sendCommandFeedback", false);
|
||||
|
||||
//
|
||||
private final String gameRuleName;
|
||||
private final boolean defaultValue;
|
||||
|
||||
GameRule(String gameRuleName, boolean defaultValue)
|
||||
private GameRule(String gameRuleName, boolean defaultValue)
|
||||
{
|
||||
this.gameRuleName = gameRuleName;
|
||||
this.defaultValue = defaultValue;
|
||||
@ -112,4 +118,5 @@ public class GameRuleHandler extends FreedomService
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,7 @@ import java.security.NoSuchProviderException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
@ -130,10 +131,10 @@ public class LogViewer extends FreedomService
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
public enum LogsRegistrationMode
|
||||
public static enum LogsRegistrationMode
|
||||
{
|
||||
|
||||
ADD, DELETE, VERIFY
|
||||
ADD, DELETE, VERIFY;
|
||||
}
|
||||
|
||||
private static class URLBuilder
|
||||
@ -156,8 +157,10 @@ public class LogViewer extends FreedomService
|
||||
public URL getURL() throws MalformedURLException
|
||||
{
|
||||
List<String> pairs = new ArrayList<>();
|
||||
for (Map.Entry<String, String> pair : queryStringMap.entrySet())
|
||||
Iterator<Map.Entry<String, String>> it = queryStringMap.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Map.Entry<String, String> pair = it.next();
|
||||
try
|
||||
{
|
||||
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));
|
||||
|
@ -4,6 +4,9 @@ import io.papermc.lib.PaperLib;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.rayzr522.jsonmessage.JSONMessage;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
@ -26,20 +29,12 @@ public class LoginProcess extends FreedomService
|
||||
public static final int MIN_USERNAME_LENGTH = 2;
|
||||
public static final int MAX_USERNAME_LENGTH = 20;
|
||||
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
||||
private static boolean lockdownEnabled = false;
|
||||
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
||||
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
||||
public List<String> CLOWNFISH_TOGGLE = new ArrayList<>();
|
||||
|
||||
public static boolean isLockdownEnabled()
|
||||
{
|
||||
return lockdownEnabled;
|
||||
}
|
||||
|
||||
public static void setLockdownEnabled(boolean lockdownEnabled)
|
||||
{
|
||||
LoginProcess.lockdownEnabled = lockdownEnabled;
|
||||
}
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean lockdownEnabled = false;
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
@ -58,7 +53,7 @@ public class LoginProcess extends FreedomService
|
||||
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
|
||||
{
|
||||
final String ip = event.getAddress().getHostAddress().trim();
|
||||
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
||||
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null;
|
||||
|
||||
// Check if the player is already online
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
@ -68,10 +63,10 @@ public class LoginProcess extends FreedomService
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isAdmin)
|
||||
if (isStaff)
|
||||
{
|
||||
event.allow();
|
||||
FSync.playerKick(onlinePlayer, "An admin just logged in with the username you are using.");
|
||||
FSync.playerKick(onlinePlayer, "A staff member just logged in with the username you are using.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -118,8 +113,11 @@ public class LoginProcess extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
// Check if player is staff
|
||||
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null;
|
||||
|
||||
// Validation below this point
|
||||
if (plugin.al.getEntryByIp(ip) != null) // Check if player is admin
|
||||
if (isStaff) // Player is staff
|
||||
{
|
||||
// Force-allow log in
|
||||
event.allow();
|
||||
@ -129,9 +127,9 @@ public class LoginProcess extends FreedomService
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(onlinePlayer))
|
||||
if (!plugin.sl.isStaff(onlinePlayer))
|
||||
{
|
||||
onlinePlayer.kickPlayer("You have been kicked to free up room for an admin.");
|
||||
onlinePlayer.kickPlayer("You have been kicked to free up room for a staff member.");
|
||||
count--;
|
||||
}
|
||||
|
||||
@ -151,7 +149,7 @@ public class LoginProcess extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
// Player is not an admin
|
||||
// Player is not a staff member
|
||||
// Server full check
|
||||
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
|
||||
{
|
||||
@ -159,10 +157,10 @@ public class LoginProcess extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
// Admin-only mode
|
||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||
// Staff-only mode
|
||||
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to staff only.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -179,6 +177,7 @@ public class LoginProcess extends FreedomService
|
||||
if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -227,7 +226,7 @@ public class LoginProcess extends FreedomService
|
||||
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
|
||||
}
|
||||
|
||||
if (!plugin.al.isAdmin(player))
|
||||
if (!plugin.sl.isStaff(player))
|
||||
{
|
||||
String tag = playerData.getTag();
|
||||
if (tag != null)
|
||||
@ -238,10 +237,18 @@ public class LoginProcess extends FreedomService
|
||||
int noteCount = playerData.getNotes().size();
|
||||
if (noteCount != 0)
|
||||
{
|
||||
String noteMessage = "This player has " + noteCount + " admin note" + (noteCount > 1 ? "s" : "") + ".";
|
||||
String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + ".";
|
||||
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
|
||||
.tooltip("Click here to view them.")
|
||||
.runCommand("/notes " + player.getName() + " list");
|
||||
FLog.info(noteMessage);
|
||||
plugin.al.messageAllAdmins(ChatColor.GOLD + noteMessage);
|
||||
plugin.al.messageAllAdmins(ChatColor.GOLD + "Do " + ChatColor.YELLOW + "/notes " + player.getName() + " list" + ChatColor.GOLD + " to view them.");
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.sl.isStaffImpostor(p))
|
||||
{
|
||||
notice.send(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,9 +257,9 @@ public class LoginProcess extends FreedomService
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-admins.");
|
||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-staff.");
|
||||
}
|
||||
|
||||
if (lockdownEnabled)
|
||||
|
@ -6,6 +6,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,6 +20,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class Monitors extends FreedomService
|
||||
{
|
||||
@Getter
|
||||
private final List<Map.Entry<ThrownPotion, Long>> allThrownPotions = new ArrayList<>();
|
||||
private final Map<Player, List<ThrownPotion>> recentlyThrownPotions = new HashMap<>();
|
||||
private final List<PotionEffectType> badPotionEffects = new ArrayList<>(Arrays.asList(PotionEffectType.BLINDNESS,
|
||||
@ -44,7 +46,7 @@ public class Monitors extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
plugin.al.potionSpyMessage(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.",
|
||||
plugin.sl.potionSpyMessage(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.",
|
||||
player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(),
|
||||
latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : "")));
|
||||
}
|
||||
@ -139,19 +141,4 @@ public class Monitors extends FreedomService
|
||||
|
||||
return badEffectsDetected > 0;
|
||||
}
|
||||
|
||||
public List<Map.Entry<ThrownPotion, Long>> getAllThrownPotions()
|
||||
{
|
||||
return allThrownPotions;
|
||||
}
|
||||
|
||||
public Map<Player, List<ThrownPotion>> getRecentlyThrownPotions()
|
||||
{
|
||||
return recentlyThrownPotions;
|
||||
}
|
||||
|
||||
public List<PotionEffectType> getBadPotionEffects()
|
||||
{
|
||||
return badPotionEffects;
|
||||
}
|
||||
}
|
@ -6,12 +6,12 @@ import ca.momothereal.mojangson.value.MojangsonValue;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.server.v1_16_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R3.NBTTagList;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -41,7 +41,7 @@ public class MovementValidator extends FreedomService
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
// Check absolute value to account for negatives
|
||||
if (Math.abs(Objects.requireNonNull(event.getTo()).getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||
{
|
||||
event.setCancelled(true); // illegal position, cancel it
|
||||
}
|
||||
@ -53,7 +53,6 @@ public class MovementValidator extends FreedomService
|
||||
final Player player = event.getPlayer();
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
assert to != null;
|
||||
if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
@ -133,7 +132,7 @@ public class MovementValidator extends FreedomService
|
||||
|
||||
private Boolean exploitItem(ItemStack item)
|
||||
{
|
||||
net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||
MojangsonCompound compound = new MojangsonCompound();
|
||||
boolean foundNegative = false;
|
||||
@ -147,9 +146,8 @@ public class MovementValidator extends FreedomService
|
||||
{
|
||||
if (Objects.equals(key, "Amount")) //null-safe .equals()
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
List<MojangsonValue> values = compound.get(key);
|
||||
for (MojangsonValue<?> val : values)
|
||||
for (MojangsonValue val : values)
|
||||
{
|
||||
if (val.getValue().toString().equals("Infinityd"))
|
||||
{
|
||||
@ -171,7 +169,7 @@ public class MovementValidator extends FreedomService
|
||||
}
|
||||
|
||||
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R3.ItemStack stack)
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R2.ItemStack stack)
|
||||
{
|
||||
if (stack.getTag() == null)
|
||||
{
|
||||
@ -185,3 +183,5 @@ public class MovementValidator extends FreedomService
|
||||
return stack.getTag().getList("AttributeModifiers", 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,6 +20,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
public class Muter extends FreedomService
|
||||
{
|
||||
|
||||
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
||||
public final List<String> MUTED_PLAYERS = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
@ -42,7 +45,7 @@ public class Muter extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdminSync(player))
|
||||
if (plugin.sl.isStaffSync(player))
|
||||
{
|
||||
fPlayer.setMuted(false);
|
||||
MUTED_PLAYERS.remove(player.getName());
|
||||
@ -67,7 +70,7 @@ public class Muter extends FreedomService
|
||||
}
|
||||
|
||||
String message = event.getMessage();
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (plugin.sl.isStaff(player))
|
||||
{
|
||||
fPlayer.setMuted(false);
|
||||
return;
|
||||
@ -85,7 +88,7 @@ public class Muter extends FreedomService
|
||||
cmdName = command.getName().toLowerCase();
|
||||
}
|
||||
|
||||
if (ConfigEntry.MUTED_BLOCKED_COMMANDS.getStringList().contains(cmdName))
|
||||
if (MUTE_COMMANDS.contains(cmdName))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
||||
event.setCancelled(true);
|
||||
@ -110,4 +113,6 @@ public class Muter extends FreedomService
|
||||
playerdata.setMuted(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,31 +1,29 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import com.mattmalec.pterodactyl4j.Permission;
|
||||
import com.mattmalec.pterodactyl4j.PowerAction;
|
||||
import com.mattmalec.pterodactyl4j.PteroAction;
|
||||
import com.mattmalec.pterodactyl4j.PteroBuilder;
|
||||
import com.mattmalec.pterodactyl4j.application.entities.ApplicationUser;
|
||||
import com.mattmalec.pterodactyl4j.application.entities.PteroApplication;
|
||||
import com.mattmalec.pterodactyl4j.application.managers.UserAction;
|
||||
import com.mattmalec.pterodactyl4j.client.entities.ClientServer;
|
||||
import com.mattmalec.pterodactyl4j.client.entities.ClientSubuser;
|
||||
import com.mattmalec.pterodactyl4j.client.entities.PteroClient;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import joptsimple.internal.Strings;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.Response;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
public class Pterodactyl extends FreedomService
|
||||
{
|
||||
public final String URL = ConfigEntry.PTERO_URL.getString();
|
||||
private final String ADMIN_KEY = ConfigEntry.PTERO_ADMIN_KEY.getString();
|
||||
private final String CLIENT_KEY = ConfigEntry.PTERO_CLIENT_KEY.getString();
|
||||
private final String IDENTIFIER = ConfigEntry.PTERO_SERVER_UUID.getString();
|
||||
private final PteroApplication adminAPI = PteroBuilder.createApplication(URL, ADMIN_KEY);
|
||||
private final PteroClient clientAPI = PteroBuilder.createClient(URL, CLIENT_KEY);
|
||||
private final ClientServer server = clientAPI.retrieveServerByIdentifier(IDENTIFIER).execute();
|
||||
|
||||
public final String URL = ConfigEntry.PTERO_URL.getString();
|
||||
private final String SERVER_KEY = ConfigEntry.PTERO_SERVER_KEY.getString();
|
||||
private final String ADMIN_KEY = ConfigEntry.PTERO_ADMIN_KEY.getString();
|
||||
private final List<String> SERVER_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + SERVER_KEY);
|
||||
private final List<String> ADMIN_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + ADMIN_KEY);
|
||||
|
||||
@Getter
|
||||
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
||||
|
||||
public void onStart()
|
||||
@ -36,80 +34,145 @@ public class Pterodactyl extends FreedomService
|
||||
{
|
||||
}
|
||||
|
||||
public void updateAccountStatus(Admin admin)
|
||||
public void updateAccountStatus(StaffMember staffMember)
|
||||
{
|
||||
String id = admin.getPteroID();
|
||||
String id = staffMember.getPteroID();
|
||||
|
||||
if (Strings.isNullOrEmpty(id) || !enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!admin.isActive() || admin.getRank() != Rank.SENIOR_ADMIN)
|
||||
if (!staffMember.isActive() || staffMember.getRank() != Rank.SENIOR_ADMIN)
|
||||
{
|
||||
FLog.debug("Disabling Pterodactyl account");
|
||||
FLog.debug("Disabling ptero acc");
|
||||
removeAccountFromServer(id);
|
||||
return;
|
||||
}
|
||||
|
||||
FLog.debug("Enabling Pterodactyl account");
|
||||
FLog.debug("Enabling aptero acc");
|
||||
addAccountToServer(id);
|
||||
}
|
||||
|
||||
public String createAccount(String username, String password)
|
||||
{
|
||||
UserAction action = adminAPI.getUserManager().createUser()
|
||||
.setUserName(username)
|
||||
.setEmail(username.toLowerCase() + "@" + ConfigEntry.PTERO_DEFAULT_EMAIL_DOMAIN.getString())
|
||||
.setFirstName(username)
|
||||
.setLastName("\u200E") // Required - make it appear empty
|
||||
.setPassword(password);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("username", username);
|
||||
json.put("password", password);
|
||||
json.put("email", username.toLowerCase() + "@" + ConfigEntry.PTERO_DEFAULT_EMAIL_DOMAIN.getString());
|
||||
json.put("first_name", username);
|
||||
json.put("last_name", "\u200E"); // required, so I made it appear empty
|
||||
|
||||
return action.execute().getId();
|
||||
Response response;
|
||||
JSONObject jsonResponse;
|
||||
try
|
||||
{
|
||||
response = FUtil.sendRequest(URL + "/api/application/users", "POST", ADMIN_HEADERS, json.toJSONString());
|
||||
jsonResponse = response.getJSONMessage();
|
||||
}
|
||||
catch (IOException | ParseException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void deleteAccount(String id)
|
||||
return ((JSONObject)jsonResponse.get("attributes")).get("id").toString();
|
||||
|
||||
}
|
||||
|
||||
public boolean deleteAccount(String id)
|
||||
{
|
||||
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
|
||||
PteroAction<Void> action = adminAPI.getUserManager().deleteUser(username);
|
||||
action.execute();
|
||||
JSONObject json = new JSONObject();
|
||||
try
|
||||
{
|
||||
return FUtil.sendRequest(URL + "/api/application/users/" + id, "DELETE", ADMIN_HEADERS, json.toJSONString()).getCode() == 204;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAccountToServer(String id)
|
||||
{
|
||||
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
|
||||
String email = username.getEmail();
|
||||
PteroAction<ClientServer> server = clientAPI.retrieveServerByIdentifier(IDENTIFIER);
|
||||
server.execute().getSubuserManager().createUser()
|
||||
.setEmail(email)
|
||||
.setPermissions(Permission.CONTROL_PERMISSIONS).execute();
|
||||
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users";
|
||||
|
||||
JSONObject userData = getUserData(id);
|
||||
if (userData == null)
|
||||
{
|
||||
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("email", userData.get("email").toString());
|
||||
json.put("permissions", Arrays.asList("control.console", "control.start", "control.restart", "control.stop", "control.kill"));
|
||||
|
||||
try
|
||||
{
|
||||
FUtil.sendRequest(url, "POST", SERVER_HEADERS, json.toJSONString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAccountFromServer(String id)
|
||||
{
|
||||
ApplicationUser username = adminAPI.retrieveUserById(id).execute();
|
||||
PteroAction<ClientServer> server = clientAPI.retrieveServerByIdentifier(IDENTIFIER);
|
||||
ClientSubuser clientSubuser = server.execute().getSubuser(username.getUUID()).retrieve().execute();
|
||||
server.execute().getSubuserManager().deleteUser(clientSubuser).execute();
|
||||
JSONObject userData = getUserData(id);
|
||||
if (userData == null)
|
||||
{
|
||||
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||
return;
|
||||
}
|
||||
|
||||
public void stopServer()
|
||||
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users/" + userData.get("uuid");
|
||||
|
||||
try
|
||||
{
|
||||
clientAPI.setPower(server, PowerAction.STOP).execute();
|
||||
FUtil.sendRequest(url, "DELETE", SERVER_HEADERS, null);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void restartServer()
|
||||
public JSONObject getUserData(String id)
|
||||
{
|
||||
clientAPI.setPower(server, PowerAction.RESTART).execute();
|
||||
Response response;
|
||||
JSONObject jsonResponse;
|
||||
try
|
||||
{
|
||||
response = FUtil.sendRequest(URL + "/api/application/users/" + id, "GET", ADMIN_HEADERS, null);
|
||||
jsonResponse = response.getJSONMessage();
|
||||
|
||||
}
|
||||
catch (IOException | ParseException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
return (JSONObject)jsonResponse.get("attributes");
|
||||
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
// API patch function on users doesnt work rn, it throws 500 errors, so it's probably not written yet
|
||||
public void setPassword(String id, String password)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("password", password);
|
||||
|
||||
try
|
||||
{
|
||||
FUtil.sendRequest(URL + "/api/application/users/" + id, "PATCH", ADMIN_HEADERS, json.toJSONString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FLog.severe(e);
|
||||
}
|
||||
}
|
||||
}
|
217
src/main/java/me/totalfreedom/totalfreedommod/Reddit.java
Normal file
217
src/main/java/me/totalfreedom/totalfreedommod/Reddit.java
Normal file
@ -0,0 +1,217 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.rank.Title;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.dean.jraw.ApiException;
|
||||
import net.dean.jraw.RedditClient;
|
||||
import net.dean.jraw.http.OkHttpNetworkAdapter;
|
||||
import net.dean.jraw.http.UserAgent;
|
||||
import net.dean.jraw.models.CurrentFlair;
|
||||
import net.dean.jraw.models.Flair;
|
||||
import net.dean.jraw.oauth.Credentials;
|
||||
import net.dean.jraw.oauth.OAuthHelper;
|
||||
import net.dean.jraw.references.SubredditReference;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Reddit extends FreedomService
|
||||
{
|
||||
private final String SUBREDDIT_NAME = ConfigEntry.REDDIT_SUBREDDIT_NAME.getString();
|
||||
private final String USERNAME = ConfigEntry.REDDIT_USERNAME.getString();
|
||||
private final String PASSWORD = ConfigEntry.REDDIT_PASSWORD.getString();
|
||||
private final String CLIENT_ID = ConfigEntry.REDDIT_CLIENT_ID.getString();
|
||||
private final String CLIENT_SECRET = ConfigEntry.REDDIT_CLIENT_SECRET.getString();
|
||||
|
||||
private final UserAgent userAgent = new UserAgent("bot", "me.totalfreedom.reddit", TotalFreedomMod.build.version, USERNAME);
|
||||
private final Credentials credentials = Credentials.script(USERNAME, PASSWORD, CLIENT_ID, CLIENT_SECRET);
|
||||
|
||||
private RedditClient reddit = null;
|
||||
private SubredditReference subreddit = null;
|
||||
|
||||
private HashMap<String, PlayerData> linkCodes = new HashMap<>();
|
||||
private HashMap<PlayerData, String> pending = new HashMap<>();
|
||||
|
||||
private Map<Displayable, String> flairList = new HashMap<>();
|
||||
|
||||
private Map<Displayable, String> flairNameList = new HashMap<>();
|
||||
|
||||
private List<Displayable> noFlairDisplays = Arrays.asList(Title.VERIFIED_STAFF, Rank.IMPOSTOR, Rank.NON_OP, Rank.OP);
|
||||
|
||||
public boolean enabled = false;
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
enabled = ConfigEntry.REDDIT_CLIENT_ID.getString() == null;
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (reddit == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
reddit = OAuthHelper.automatic(new OkHttpNetworkAdapter(userAgent), credentials);
|
||||
reddit.setLogHttp(FUtil.inDeveloperMode());
|
||||
}
|
||||
catch (NoClassDefFoundError e)
|
||||
{
|
||||
FLog.warning("The JRAW plugin is not installed, therefore the Reddit service cannot start.");
|
||||
FLog.warning("To resolve this error, please download the latest JRAW from: https://github.com/TFPatches/Minecraft-JRAW/releases");
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
FLog.warning("Invalid Reddit credentials specified, please double check everything in the config.");
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (subreddit == null)
|
||||
{
|
||||
subreddit = reddit.subreddit(SUBREDDIT_NAME);
|
||||
}
|
||||
|
||||
loadFlairList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public void setFlair(String username, String flairID)
|
||||
{
|
||||
List<Flair> flairs = subreddit.userFlairOptions();
|
||||
Flair flair = null;
|
||||
for (Flair f : flairs)
|
||||
{
|
||||
if (f.getId().equals(flairID))
|
||||
{
|
||||
flair = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (flair == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
subreddit.otherUserFlair(username).updateToTemplate(flair.getId(), "");
|
||||
}
|
||||
|
||||
public void removeFlair(String username)
|
||||
{
|
||||
subreddit.otherUserFlair(username).updateToTemplate("", "");
|
||||
}
|
||||
|
||||
public void sendModMessage(String username, String subject, String body) throws ApiException
|
||||
{
|
||||
reddit.me().inbox().compose("/r/" + SUBREDDIT_NAME, username, subject, body);
|
||||
}
|
||||
|
||||
public String addLinkCode(PlayerData data, String username)
|
||||
{
|
||||
String code = FUtil.randomAlphanumericString(10);
|
||||
linkCodes.put(code, data);
|
||||
pending.put(data, username);
|
||||
return code;
|
||||
}
|
||||
|
||||
public String checkLinkCode(String code)
|
||||
{
|
||||
PlayerData data = linkCodes.get(code);
|
||||
String username = pending.get(data);
|
||||
if (data == null || username == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
linkCodes.remove(code);
|
||||
pending.remove(data);
|
||||
|
||||
data.setRedditUsername(username);
|
||||
plugin.pl.save(data);
|
||||
|
||||
return username;
|
||||
}
|
||||
|
||||
public boolean updateFlair(Player player)
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerData data = plugin.pl.getData(player);
|
||||
String username = data.getRedditUsername();
|
||||
Displayable display = plugin.rm.getDisplay(player);
|
||||
if (username == null)
|
||||
{
|
||||
FLog.debug("No Reddit account");
|
||||
return false;
|
||||
}
|
||||
|
||||
CurrentFlair currentFlair = subreddit.otherUserFlair(username).current();
|
||||
String currentFlairName = currentFlair.getText();
|
||||
String currentFlairID = currentFlair.getId();
|
||||
String neededFlairID = flairList.get(display);
|
||||
String neededFlairName = flairNameList.get(display);
|
||||
|
||||
FLog.debug("Current ID: " + currentFlairID);
|
||||
FLog.debug("Needed ID: " + neededFlairID);
|
||||
|
||||
FLog.debug("Current Name: " + currentFlairName);
|
||||
FLog.debug("Needed Name: " + neededFlairName);
|
||||
|
||||
|
||||
// Work around
|
||||
//if (currentFlairID == null && neededFlairID != null || currentFlairID != null && neededFlairID != null && !currentFlairID.equals(neededFlairID))
|
||||
if (Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null || !Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null && !currentFlairName.equals(neededFlairName))
|
||||
{
|
||||
FLog.debug("Setting flair");
|
||||
setFlair(username, neededFlairID);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (noFlairDisplays.contains(display) && !Strings.isNullOrEmpty(currentFlairName))
|
||||
{
|
||||
FLog.debug("Removing flair");
|
||||
removeFlair(username);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void loadFlairList()
|
||||
{
|
||||
flairList.put(Title.OWNER, ConfigEntry.REDDIT_SERVER_OWNER_FLAIR_ID.getString());
|
||||
flairList.put(Title.EXECUTIVE, ConfigEntry.REDDIT_EXECUTIVE_FLAIR_ID.getString());
|
||||
flairList.put(Title.DEVELOPER, ConfigEntry.REDDIT_DEVELOPER_FLAIR_ID.getString());
|
||||
flairList.put(Rank.SENIOR_ADMIN, ConfigEntry.REDDIT_SENIOR_ADMIN_FLAIR_ID.getString());
|
||||
flairList.put(Rank.ADMIN, ConfigEntry.REDDIT_NEW_ADMIN_FLAIR_ID.getString());
|
||||
flairList.put(Title.MASTER_BUILDER, ConfigEntry.REDDIT_MASTER_BUILDER_FLAIR_ID.getString());
|
||||
|
||||
// Work around because the current flair ID keeps returning null, either a JRAW bug or a Reddit bug
|
||||
flairNameList.put(Title.OWNER, "Server Owner");
|
||||
flairNameList.put(Title.EXECUTIVE, "Executive");
|
||||
flairNameList.put(Title.DEVELOPER, "Developer");
|
||||
flairNameList.put(Rank.SENIOR_ADMIN, "Senior Admin");
|
||||
flairNameList.put(Rank.ADMIN, "Admin");
|
||||
flairNameList.put(Title.MASTER_BUILDER, "Master Builder");
|
||||
}
|
||||
}
|
@ -26,8 +26,8 @@ public class SavedFlags extends FreedomService
|
||||
public Map<String, Boolean> getSavedFlags()
|
||||
{
|
||||
Map<String, Boolean> flags = null;
|
||||
File input = new File(TotalFreedomMod.getPlugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
||||
|
||||
File input = new File(TotalFreedomMod.plugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
||||
if (input.exists())
|
||||
{
|
||||
try
|
||||
|
@ -4,14 +4,24 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R3.MinecraftServer;
|
||||
import net.minecraft.server.v1_16_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.CraftServer;
|
||||
|
||||
public class ServerInterface extends FreedomService
|
||||
{
|
||||
public static final String COMPILE_NMS_VERSION = "v1_16_R3";
|
||||
public static final String COMPILE_NMS_VERSION = "v1_16_R2";
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public static void warnVersion()
|
||||
{
|
||||
@ -24,16 +34,6 @@ public class ServerInterface extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public void setOnlineMode(boolean mode)
|
||||
{
|
||||
getServer().setOnlineMode(mode);
|
||||
|
@ -30,9 +30,9 @@ public class ServerPing extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||
{
|
||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
|
||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_STAFFMODE_MOTD.getString()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -73,4 +73,5 @@ public class ServerPing extends FreedomService
|
||||
|
||||
event.setMotd(motd.toString().trim());
|
||||
}
|
||||
|
||||
}
|
@ -3,8 +3,6 @@ package me.totalfreedom.totalfreedommod;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||
@ -19,6 +17,7 @@ import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
||||
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.FAWEBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.TFGuildsBridge;
|
||||
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
||||
@ -28,6 +27,7 @@ import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
||||
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||
import me.totalfreedom.totalfreedommod.fun.CurseListener;
|
||||
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
||||
@ -42,29 +42,36 @@ import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
||||
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||
import me.totalfreedom.totalfreedommod.staff.ActivityLog;
|
||||
import me.totalfreedom.totalfreedommod.staff.StaffList;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
|
||||
public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
private static TotalFreedomMod plugin;
|
||||
|
||||
public static TotalFreedomMod getPlugin()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static final String CONFIG_FILENAME = "config.yml";
|
||||
//
|
||||
public static final BuildProperties build = new BuildProperties();
|
||||
//
|
||||
public static String pluginName;
|
||||
public static String pluginVersion;
|
||||
private static TotalFreedomMod plugin;
|
||||
//
|
||||
public MainConfig config;
|
||||
public PermissionConfig permissions;
|
||||
@ -78,7 +85,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public SavedFlags sf;
|
||||
public WorldManager wm;
|
||||
public LogViewer lv;
|
||||
public AdminList al;
|
||||
public StaffList sl;
|
||||
public ActivityLog acl;
|
||||
public RankManager rm;
|
||||
public CommandBlocker cb;
|
||||
@ -101,6 +108,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public BanManager bm;
|
||||
public IndefiniteBanList im;
|
||||
public PermissionManager pem;
|
||||
public Reddit rd;
|
||||
public GameRuleHandler gr;
|
||||
public CommandSpy cs;
|
||||
public Cager ca;
|
||||
@ -115,6 +123,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public Monitors mo;
|
||||
public MovementValidator mv;
|
||||
public ServerPing sp;
|
||||
public CurseListener cul;
|
||||
public ItemFun it;
|
||||
public Landminer lm;
|
||||
public MP44 mp;
|
||||
@ -127,6 +136,8 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public Sitter st;
|
||||
public VanishHandler vh;
|
||||
public Pterodactyl ptero;
|
||||
|
||||
//public HubWorldRestrictions hwr;
|
||||
//
|
||||
// Bridges
|
||||
public BukkitTelnetBridge btb;
|
||||
@ -135,25 +146,9 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public CoreProtectBridge cpb;
|
||||
public TFGuildsBridge tfg;
|
||||
public WorldEditBridge web;
|
||||
public FAWEBridge fab;
|
||||
public WorldGuardBridge wgb;
|
||||
|
||||
public static TotalFreedomMod getPlugin()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static TotalFreedomMod plugin()
|
||||
{
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
||||
{
|
||||
if (plugin.getName().equalsIgnoreCase(pluginName))
|
||||
{
|
||||
return (TotalFreedomMod)plugin;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
@ -200,13 +195,81 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
BackupManager backups = new BackupManager();
|
||||
backups.createAllBackups();
|
||||
|
||||
permissions = new PermissionConfig();
|
||||
permissions = new PermissionConfig(this);
|
||||
permissions.load();
|
||||
|
||||
// Start services
|
||||
si = new ServerInterface();
|
||||
sf = new SavedFlags();
|
||||
wm = new WorldManager();
|
||||
lv = new LogViewer();
|
||||
sql = new SQLite();
|
||||
sl = new StaffList();
|
||||
acl = new ActivityLog();
|
||||
rm = new RankManager();
|
||||
cb = new CommandBlocker();
|
||||
eb = new EventBlocker();
|
||||
bb = new BlockBlocker();
|
||||
mb = new MobBlocker();
|
||||
ib = new InteractBlocker();
|
||||
pb = new PotionBlocker();
|
||||
lp = new LoginProcess();
|
||||
nu = new AntiNuke();
|
||||
as = new AntiSpam();
|
||||
wr = new WorldRestrictions();
|
||||
pl = new PlayerList();
|
||||
sh = new Shop();
|
||||
vo = new Votifier();
|
||||
an = new Announcer();
|
||||
cm = new ChatManager();
|
||||
dc = new Discord();
|
||||
pul = new PunishmentList();
|
||||
bm = new BanManager();
|
||||
im = new IndefiniteBanList();
|
||||
pem = new PermissionManager();
|
||||
rd = new Reddit();
|
||||
gr = new GameRuleHandler();
|
||||
snp = new SignBlocker();
|
||||
ew = new EntityWiper();
|
||||
st = new Sitter();
|
||||
vh = new VanishHandler();
|
||||
ptero = new Pterodactyl();
|
||||
|
||||
// Single admin utils
|
||||
cs = new CommandSpy();
|
||||
ca = new Cager();
|
||||
fm = new Freezer();
|
||||
or = new Orbiter();
|
||||
mu = new Muter();
|
||||
ebl = new EditBlocker();
|
||||
pbl = new PVPBlocker();
|
||||
fo = new Fuckoff();
|
||||
ak = new AutoKick();
|
||||
ae = new AutoEject();
|
||||
mo = new Monitors();
|
||||
|
||||
mv = new MovementValidator();
|
||||
sp = new ServerPing();
|
||||
|
||||
new Initializer();
|
||||
// Fun
|
||||
cul = new CurseListener();
|
||||
it = new ItemFun();
|
||||
lm = new Landminer();
|
||||
mp = new MP44();
|
||||
jp = new Jumppads();
|
||||
tr = new Trailer();
|
||||
// HTTPD
|
||||
hd = new HTTPDaemon();
|
||||
|
||||
// Start bridges
|
||||
btb = new BukkitTelnetBridge();
|
||||
cpb = new CoreProtectBridge();
|
||||
esb = new EssentialsBridge();
|
||||
ldb = new LibsDisguisesBridge();
|
||||
tfg = new TFGuildsBridge();
|
||||
web = new WorldEditBridge();
|
||||
fab = new FAWEBridge();
|
||||
wgb = new WorldGuardBridge();
|
||||
|
||||
fsh.startServices();
|
||||
|
||||
@ -233,12 +296,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
FLog.info("Plugin disabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id)
|
||||
{
|
||||
return new CleanroomChunkGenerator(id);
|
||||
}
|
||||
|
||||
public static class BuildProperties
|
||||
{
|
||||
public String author;
|
||||
@ -281,101 +338,21 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is provided to please Codacy.
|
||||
*/
|
||||
private final class Initializer
|
||||
public static TotalFreedomMod plugin()
|
||||
{
|
||||
public Initializer()
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
||||
{
|
||||
initServices();
|
||||
initAdminUtils();
|
||||
initBridges();
|
||||
initFun();
|
||||
initHTTPD();
|
||||
if (plugin.getName().equalsIgnoreCase(pluginName))
|
||||
{
|
||||
return (TotalFreedomMod)plugin;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void initServices()
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
||||
{
|
||||
// Start services
|
||||
si = new ServerInterface();
|
||||
sf = new SavedFlags();
|
||||
wm = new WorldManager();
|
||||
lv = new LogViewer();
|
||||
sql = new SQLite();
|
||||
al = new AdminList();
|
||||
acl = new ActivityLog();
|
||||
rm = new RankManager();
|
||||
cb = new CommandBlocker();
|
||||
eb = new EventBlocker();
|
||||
bb = new BlockBlocker();
|
||||
mb = new MobBlocker();
|
||||
ib = new InteractBlocker();
|
||||
pb = new PotionBlocker();
|
||||
lp = new LoginProcess();
|
||||
nu = new AntiNuke();
|
||||
as = new AntiSpam();
|
||||
wr = new WorldRestrictions();
|
||||
pl = new PlayerList();
|
||||
sh = new Shop();
|
||||
vo = new Votifier();
|
||||
an = new Announcer();
|
||||
cm = new ChatManager();
|
||||
dc = new Discord();
|
||||
pul = new PunishmentList();
|
||||
bm = new BanManager();
|
||||
im = new IndefiniteBanList();
|
||||
pem = new PermissionManager();
|
||||
gr = new GameRuleHandler();
|
||||
snp = new SignBlocker();
|
||||
ew = new EntityWiper();
|
||||
st = new Sitter();
|
||||
vh = new VanishHandler();
|
||||
ptero = new Pterodactyl();
|
||||
}
|
||||
|
||||
private void initAdminUtils()
|
||||
{
|
||||
// Single admin utils
|
||||
cs = new CommandSpy();
|
||||
ca = new Cager();
|
||||
fm = new Freezer();
|
||||
or = new Orbiter();
|
||||
mu = new Muter();
|
||||
ebl = new EditBlocker();
|
||||
pbl = new PVPBlocker();
|
||||
fo = new Fuckoff();
|
||||
ak = new AutoKick();
|
||||
ae = new AutoEject();
|
||||
mo = new Monitors();
|
||||
}
|
||||
|
||||
private void initBridges()
|
||||
{
|
||||
// Start bridges
|
||||
btb = new BukkitTelnetBridge();
|
||||
cpb = new CoreProtectBridge();
|
||||
esb = new EssentialsBridge();
|
||||
ldb = new LibsDisguisesBridge();
|
||||
tfg = new TFGuildsBridge();
|
||||
web = new WorldEditBridge();
|
||||
wgb = new WorldGuardBridge();
|
||||
}
|
||||
|
||||
private void initFun()
|
||||
{
|
||||
// Fun
|
||||
it = new ItemFun();
|
||||
lm = new Landminer();
|
||||
mp = new MP44();
|
||||
jp = new Jumppads();
|
||||
tr = new Trailer();
|
||||
}
|
||||
|
||||
private void initHTTPD()
|
||||
{
|
||||
// HTTPD
|
||||
hd = new HTTPDaemon();
|
||||
}
|
||||
return new CleanroomChunkGenerator(id);
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ public class VanishHandler extends FreedomService
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player) && plugin.al.isVanished(p.getName()))
|
||||
if (!plugin.sl.isStaff(player) && plugin.sl.isVanished(p.getName()))
|
||||
{
|
||||
player.hidePlayer(plugin, p);
|
||||
}
|
||||
@ -39,17 +39,17 @@ public class VanishHandler extends FreedomService
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(p) && plugin.al.isVanished(player.getName()))
|
||||
if (!plugin.sl.isStaff(p) && plugin.sl.isVanished(player.getName()))
|
||||
{
|
||||
p.hidePlayer(plugin, player);
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.al.isVanished(player.getName()))
|
||||
if (plugin.sl.isVanished(player.getName()))
|
||||
{
|
||||
plugin.esb.setVanished(player.getName(), true);
|
||||
FLog.info(player.getName() + " joined while still vanished.");
|
||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
||||
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
||||
event.setJoinMessage(null);
|
||||
|
||||
new BukkitRunnable()
|
||||
@ -57,7 +57,7 @@ public class VanishHandler extends FreedomService
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!plugin.al.isVanished(player.getName()))
|
||||
if (!plugin.sl.isVanished(player.getName()))
|
||||
{
|
||||
this.cancel();
|
||||
}
|
||||
@ -73,11 +73,11 @@ public class VanishHandler extends FreedomService
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (plugin.al.isVanished(player.getName()))
|
||||
if (plugin.sl.isVanished(player.getName()))
|
||||
{
|
||||
event.setQuitMessage(null);
|
||||
FLog.info(player.getName() + " left while still vanished.");
|
||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
|
||||
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has left silently.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,409 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.admin;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AdminList extends FreedomService
|
||||
{
|
||||
public static final List<String> vanished = new ArrayList<>();
|
||||
public final Map<String, List<String>> verifiedNoAdmin = Maps.newHashMap();
|
||||
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||
// Only active admins below
|
||||
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
||||
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
||||
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
||||
|
||||
public static List<String> getVanished()
|
||||
{
|
||||
return vanished;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
load();
|
||||
deactivateOldEntries(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
allAdmins.clear();
|
||||
try
|
||||
{
|
||||
ResultSet adminSet = plugin.sql.getAdminList();
|
||||
{
|
||||
while (adminSet.next())
|
||||
{
|
||||
Admin admin = new Admin(adminSet);
|
||||
allAdmins.add(admin);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to load admin list: " + e.getMessage());
|
||||
}
|
||||
|
||||
updateTables();
|
||||
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||
}
|
||||
|
||||
public void messageAllAdmins(String message)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (isAdmin(player))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void potionSpyMessage(String message)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
Admin admin = getAdmin(player.getPlayer());
|
||||
if (isAdmin(player) && admin.getPotionSpy())
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean isAdminSync(CommandSender sender)
|
||||
{
|
||||
return isAdmin(sender);
|
||||
}
|
||||
|
||||
public List<String> getActiveAdminNames()
|
||||
{
|
||||
List<String> names = new ArrayList();
|
||||
for (Admin admin : activeAdmins)
|
||||
{
|
||||
names.add(admin.getName());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public boolean isAdmin(CommandSender sender)
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Admin admin = getAdmin((Player)sender);
|
||||
|
||||
return admin != null && admin.isActive();
|
||||
}
|
||||
|
||||
public boolean isAdmin(Player player)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Admin admin = getAdmin(player);
|
||||
|
||||
return admin != null && admin.isActive();
|
||||
}
|
||||
|
||||
public boolean isSeniorAdmin(CommandSender sender)
|
||||
{
|
||||
Admin admin = getAdmin(sender);
|
||||
if (admin == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return admin.getRank().ordinal() >= Rank.SENIOR_ADMIN.ordinal();
|
||||
}
|
||||
|
||||
public Admin getAdmin(CommandSender sender)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
return getAdmin((Player)sender);
|
||||
}
|
||||
|
||||
return getEntryByName(sender.getName());
|
||||
}
|
||||
|
||||
public Admin getAdmin(Player player)
|
||||
{
|
||||
// Find admin
|
||||
String ip = FUtil.getIp(player);
|
||||
Admin admin = getEntryByName(player.getName());
|
||||
|
||||
// Admin by name
|
||||
if (admin != null)
|
||||
{
|
||||
// Check if we're in online mode,
|
||||
// Or the players IP is in the admin entry
|
||||
if (Bukkit.getOnlineMode() || admin.getIps().contains(ip))
|
||||
{
|
||||
if (!admin.getIps().contains(ip))
|
||||
{
|
||||
// Add the new IP if we have to
|
||||
admin.addIp(ip);
|
||||
save(admin);
|
||||
updateTables();
|
||||
}
|
||||
return admin;
|
||||
}
|
||||
}
|
||||
|
||||
// Admin by ip
|
||||
admin = getEntryByIp(ip);
|
||||
if (admin != null)
|
||||
{
|
||||
// Set the new username
|
||||
String oldName = admin.getName();
|
||||
admin.setName(player.getName());
|
||||
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||
updateTables();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Admin getEntryByName(String name)
|
||||
{
|
||||
return nameTable.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public Admin getEntryByIp(String ip)
|
||||
{
|
||||
return ipTable.get(ip);
|
||||
}
|
||||
|
||||
public Admin getEntryByIpFuzzy(String needleIp)
|
||||
{
|
||||
final Admin directAdmin = getEntryByIp(needleIp);
|
||||
if (directAdmin != null)
|
||||
{
|
||||
return directAdmin;
|
||||
}
|
||||
|
||||
for (String ip : ipTable.keySet())
|
||||
{
|
||||
if (FUtil.fuzzyIpMatch(needleIp, ip, 3))
|
||||
{
|
||||
return ipTable.get(ip);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateLastLogin(Player player)
|
||||
{
|
||||
final Admin admin = getAdmin(player);
|
||||
if (admin == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
admin.setLastLogin(new Date());
|
||||
admin.setName(player.getName());
|
||||
save(admin);
|
||||
}
|
||||
|
||||
public boolean isAdminImpostor(Player player)
|
||||
{
|
||||
return getEntryByName(player.getName()) != null && !isAdmin(player) && !isVerifiedAdmin(player);
|
||||
}
|
||||
|
||||
public boolean isVerifiedAdmin(Player player)
|
||||
{
|
||||
return verifiedNoAdmin.containsKey(player.getName()) && verifiedNoAdmin.get(player.getName()).contains(FUtil.getIp(player));
|
||||
}
|
||||
|
||||
public boolean isIdentityMatched(Player player)
|
||||
{
|
||||
if (Bukkit.getOnlineMode())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Admin admin = getAdmin(player);
|
||||
return admin != null && admin.getName().equalsIgnoreCase(player.getName());
|
||||
}
|
||||
|
||||
public boolean addAdmin(Admin admin)
|
||||
{
|
||||
if (!admin.isValid())
|
||||
{
|
||||
FLog.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store admin, update views
|
||||
allAdmins.add(admin);
|
||||
updateTables();
|
||||
|
||||
// Save admin
|
||||
plugin.sql.addAdmin(admin);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeAdmin(Admin admin)
|
||||
{
|
||||
if (admin.getRank().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
if (plugin.btb != null)
|
||||
{
|
||||
plugin.btb.killTelnetSessions(admin.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Remove admin, update views
|
||||
if (!allAdmins.remove(admin))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
updateTables();
|
||||
|
||||
// Unsave admin
|
||||
plugin.sql.removeAdmin(admin);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateTables()
|
||||
{
|
||||
activeAdmins.clear();
|
||||
nameTable.clear();
|
||||
ipTable.clear();
|
||||
|
||||
for (Admin admin : allAdmins)
|
||||
{
|
||||
if (!admin.isActive())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
activeAdmins.add(admin);
|
||||
nameTable.put(admin.getName().toLowerCase(), admin);
|
||||
|
||||
for (String ip : admin.getIps())
|
||||
{
|
||||
ipTable.put(ip, admin);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getAdminNames()
|
||||
{
|
||||
return nameTable.keySet();
|
||||
}
|
||||
|
||||
public Set<String> getAdminIps()
|
||||
{
|
||||
return ipTable.keySet();
|
||||
}
|
||||
|
||||
public void save(Admin admin)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResultSet currentSave = plugin.sql.getAdminByName(admin.getName());
|
||||
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
||||
{
|
||||
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
|
||||
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
|
||||
{
|
||||
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to save admin: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivateOldEntries(boolean verbose)
|
||||
{
|
||||
for (Admin admin : allAdmins)
|
||||
{
|
||||
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final Date lastLogin = admin.getLastLogin();
|
||||
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
|
||||
|
||||
if (lastLoginHours < ConfigEntry.ADMINLIST_CLEAN_THESHOLD_HOURS.getInteger())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
FUtil.adminAction("TotalFreedomMod", "Deactivating admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
||||
}
|
||||
|
||||
admin.setActive(false);
|
||||
save(admin);
|
||||
}
|
||||
|
||||
updateTables();
|
||||
}
|
||||
|
||||
public boolean isVanished(String player)
|
||||
{
|
||||
return vanished.contains(player);
|
||||
}
|
||||
|
||||
public Set<Admin> getAllAdmins()
|
||||
{
|
||||
return allAdmins;
|
||||
}
|
||||
|
||||
public Set<Admin> getActiveAdmins()
|
||||
{
|
||||
return activeAdmins;
|
||||
}
|
||||
|
||||
public Map<String, Admin> getNameTable()
|
||||
{
|
||||
return nameTable;
|
||||
}
|
||||
|
||||
public Map<String, Admin> getIpTable()
|
||||
{
|
||||
return ipTable;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getVerifiedNoAdmin()
|
||||
{
|
||||
return verifiedNoAdmin;
|
||||
}
|
||||
}
|
@ -4,12 +4,15 @@ import com.google.common.collect.Lists;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -19,19 +22,27 @@ import org.bukkit.entity.Player;
|
||||
public class Ban
|
||||
{
|
||||
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String username = null;
|
||||
@Getter
|
||||
@Setter
|
||||
private UUID uuid = null;
|
||||
@Getter
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
@Getter
|
||||
@Setter
|
||||
private String by = null;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Date at = null;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private long expiryUnix = -1;
|
||||
|
||||
public Ban()
|
||||
@ -42,7 +53,7 @@ public class Ban
|
||||
{
|
||||
this(username,
|
||||
uuid,
|
||||
Collections.singletonList(ip),
|
||||
Arrays.asList(ip),
|
||||
by,
|
||||
at,
|
||||
expire,
|
||||
@ -77,7 +88,7 @@ public class Ban
|
||||
|
||||
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||
{
|
||||
return new Ban(null, null, Collections.singletonList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||
return new Ban(null, null, Arrays.asList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||
}
|
||||
|
||||
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||
@ -132,11 +143,6 @@ public class Ban
|
||||
reason);
|
||||
}
|
||||
|
||||
public static SimpleDateFormat getDateFormat()
|
||||
{
|
||||
return DATE_FORMAT;
|
||||
}
|
||||
|
||||
public boolean hasUsername()
|
||||
{
|
||||
return username != null && !username.isEmpty();
|
||||
@ -169,7 +175,7 @@ public class Ban
|
||||
|
||||
public boolean isExpired()
|
||||
{
|
||||
return hasExpiry() && FUtil.getUnixDate(expiryUnix).before(new Date(FUtil.getUnixTime()));
|
||||
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
||||
}
|
||||
|
||||
public String bakeKickMessage()
|
||||
@ -250,74 +256,17 @@ public class Ban
|
||||
|
||||
private void dedupeIps()
|
||||
{
|
||||
|
||||
Set<String> uniqueIps = new HashSet<>();
|
||||
|
||||
//Fancy Collections.removeIf lets you do all that while loop work in one lambda.
|
||||
ips.removeIf(s -> !uniqueIps.add(s));
|
||||
Iterator<String> it = ips.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
if (!uniqueIps.add(it.next()))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getIps()
|
||||
{
|
||||
return ips;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username)
|
||||
{
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public UUID getUuid()
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(UUID uuid)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getBy()
|
||||
{
|
||||
return by;
|
||||
}
|
||||
|
||||
public void setBy(String by)
|
||||
{
|
||||
this.by = by;
|
||||
}
|
||||
|
||||
public Date getAt()
|
||||
{
|
||||
return at;
|
||||
}
|
||||
|
||||
public void setAt(Date at)
|
||||
{
|
||||
this.at = at;
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason)
|
||||
{
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public long getExpiryUnix()
|
||||
{
|
||||
return expiryUnix;
|
||||
}
|
||||
|
||||
public void setExpiryUnix(long expiryUnix)
|
||||
{
|
||||
this.expiryUnix = expiryUnix;
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -73,7 +74,7 @@ public class BanManager extends FreedomService
|
||||
|
||||
// Load unbannable usernames
|
||||
unbannableUsernames.clear();
|
||||
unbannableUsernames.addAll(ConfigEntry.FAMOUS_PLAYERS.getStringList());
|
||||
unbannableUsernames.addAll((Collection<? extends String>)ConfigEntry.FAMOUS_PLAYERS.getList());
|
||||
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
||||
}
|
||||
|
||||
@ -189,7 +190,7 @@ public class BanManager extends FreedomService
|
||||
return getByUsername(username) != null;
|
||||
}
|
||||
|
||||
public void addBan(Ban ban)
|
||||
public boolean addBan(Ban ban)
|
||||
{
|
||||
if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
|
||||
{
|
||||
@ -212,18 +213,22 @@ public class BanManager extends FreedomService
|
||||
{
|
||||
plugin.sql.addBan(ban);
|
||||
updateViews();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeBan(Ban ban)
|
||||
public boolean removeBan(Ban ban)
|
||||
{
|
||||
if (bans.remove(ban))
|
||||
{
|
||||
plugin.sql.removeBan(ban);
|
||||
updateViews();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int purge()
|
||||
@ -264,8 +269,9 @@ public class BanManager extends FreedomService
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final PlayerData data = plugin.pl.getData(player);
|
||||
|
||||
if (!plugin.al.isAdmin(player))
|
||||
if (!plugin.sl.isStaff(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -322,4 +328,5 @@ public class BanManager extends FreedomService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,25 @@ package me.totalfreedom.totalfreedommod.banning;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class IndefiniteBan implements IConfig
|
||||
{
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String username = null;
|
||||
@Getter
|
||||
@Setter
|
||||
private UUID uuid = null;
|
||||
@Getter
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
@Getter
|
||||
@Setter
|
||||
private String reason = null;
|
||||
|
||||
public IndefiniteBan()
|
||||
@ -43,7 +53,6 @@ public class IndefiniteBan implements IConfig
|
||||
@Override
|
||||
public void saveTo(ConfigurationSection cs)
|
||||
{
|
||||
// The indefinite ban list is only intended to be modified manually. It is not intended to save.
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,39 +60,4 @@ public class IndefiniteBan implements IConfig
|
||||
{
|
||||
return username != null;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username)
|
||||
{
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public UUID getUuid()
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(UUID uuid)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public List<String> getIps()
|
||||
{
|
||||
return ips;
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason)
|
||||
{
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||
@ -20,23 +21,18 @@ public class IndefiniteBanList extends FreedomService
|
||||
|
||||
public static final String CONFIG_FILENAME = "indefinitebans.yml";
|
||||
|
||||
|
||||
@Getter
|
||||
private final Set<IndefiniteBan> indefBans = Sets.newHashSet();
|
||||
|
||||
|
||||
@Getter
|
||||
private int nameBanCount = 0;
|
||||
|
||||
|
||||
@Getter
|
||||
private int uuidBanCount = 0;
|
||||
|
||||
|
||||
@Getter
|
||||
private int ipBanCount = 0;
|
||||
|
||||
public static String getConfigFilename()
|
||||
{
|
||||
return CONFIG_FILENAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
@ -55,7 +51,6 @@ public class IndefiniteBanList extends FreedomService
|
||||
|
||||
IndefiniteBan indefBan = new IndefiniteBan();
|
||||
ConfigurationSection cs = config.getConfigurationSection(name);
|
||||
assert cs != null;
|
||||
indefBan.loadFrom(cs);
|
||||
|
||||
if (!indefBan.isValid())
|
||||
@ -89,7 +84,7 @@ public class IndefiniteBanList extends FreedomService
|
||||
|
||||
for (IndefiniteBan indefBan : indefBans)
|
||||
{
|
||||
if (username.equalsIgnoreCase(indefBan.getUsername()))
|
||||
if (username.toLowerCase().equals(indefBan.getUsername().toLowerCase()))
|
||||
{
|
||||
bannedBy = "username";
|
||||
ban = indefBan;
|
||||
@ -142,24 +137,4 @@ public class IndefiniteBanList extends FreedomService
|
||||
ipBanCount += indefBan.getIps().size();
|
||||
}
|
||||
}
|
||||
|
||||
public Set<IndefiniteBan> getIndefBans()
|
||||
{
|
||||
return indefBans;
|
||||
}
|
||||
|
||||
public int getNameBanCount()
|
||||
{
|
||||
return nameBanCount;
|
||||
}
|
||||
|
||||
public int getUuidBanCount()
|
||||
{
|
||||
return uuidBanCount;
|
||||
}
|
||||
|
||||
public int getIpBanCount()
|
||||
{
|
||||
return ipBanCount;
|
||||
}
|
||||
}
|
@ -29,7 +29,6 @@ public class BlockBlocker extends FreedomService
|
||||
{
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
@ -133,18 +132,17 @@ public class BlockBlocker extends FreedomService
|
||||
case PLAYER_HEAD:
|
||||
case PLAYER_WALL_HEAD:
|
||||
{
|
||||
Skull skull = (Skull)event.getBlockPlaced().getState();
|
||||
Skull skull = (Skull) event.getBlockPlaced().getState();
|
||||
if (skull.getOwner() != null)
|
||||
{
|
||||
if (skull.getOwner().contains("\u00A7"))
|
||||
{
|
||||
skull.setOwner(skull.getOwner().replace("\u00A7", ""));
|
||||
SkullMeta meta = (SkullMeta)event.getItemInHand().getItemMeta();
|
||||
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
||||
if (meta != null)
|
||||
{
|
||||
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||
ItemMeta headMeta = newHead.getItemMeta();
|
||||
assert headMeta != null;
|
||||
headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head");
|
||||
newHead.setItemMeta(headMeta);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead);
|
||||
@ -171,23 +169,18 @@ public class BlockBlocker extends FreedomService
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
|
||||
{
|
||||
Banner banner = (Banner)event.getBlockPlaced().getState();
|
||||
List<Pattern> patterns = banner.getPatterns();
|
||||
|
||||
Banner banner = (Banner) event.getBlockPlaced().getState();
|
||||
List<Pattern> patterns = banner.getPatterns();;
|
||||
if (patterns.size() >= 2)
|
||||
{
|
||||
banner.setPatterns(patterns.subList(0, 2));
|
||||
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ public class EditBlocker extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||
if (plugin.sl.isStaffSync(event.getPlayer()))
|
||||
{
|
||||
fPlayer.setEditBlocked(false);
|
||||
return;
|
||||
@ -49,7 +49,7 @@ public class EditBlocker extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||
if (plugin.sl.isStaffSync(event.getPlayer()))
|
||||
{
|
||||
fPlayer.setEditBlocked(false);
|
||||
return;
|
||||
@ -58,4 +58,5 @@ public class EditBlocker extends FreedomService
|
||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.blocking;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -14,7 +13,6 @@ import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.block.data.AnaloguePowerable;
|
||||
import org.bukkit.block.data.Powerable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -26,12 +24,12 @@ import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.FireworkExplodeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
@ -40,20 +38,6 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
public class EventBlocker extends FreedomService
|
||||
{
|
||||
/**
|
||||
* /@EventHandler(priority = EventPriority.HIGH)
|
||||
* /public void onBlockRedstone(BlockRedstoneEvent event)
|
||||
* /{
|
||||
* / if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||
* / {
|
||||
* / event.setNewCurrent(0);
|
||||
* / }
|
||||
* /}
|
||||
**/
|
||||
|
||||
// TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
|
||||
private final ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
@ -136,12 +120,17 @@ public class EventBlocker extends FreedomService
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
if ((event.getCause() == EntityDamageEvent.DamageCause.LAVA)
|
||||
&& !ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||
switch (event.getCause())
|
||||
{
|
||||
case LAVA:
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
||||
{
|
||||
@ -159,7 +148,7 @@ public class EventBlocker extends FreedomService
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
if (!plugin.al.isAdmin(event.getPlayer()))
|
||||
if (!plugin.sl.isStaff(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -214,22 +203,24 @@ public class EventBlocker extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent event)
|
||||
//@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockRedstone(BlockRedstoneEvent event)
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_GRAVITY.getBoolean() && event.getEntity() instanceof FallingBlock)
|
||||
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.setNewCurrent(0);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
|
||||
private ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
|
||||
@EventHandler
|
||||
public void onBlockPhysics(BlockPhysicsEvent event)
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||
{
|
||||
// Check if the block is involved with redstone.
|
||||
if (event.getBlock().getBlockData() instanceof AnaloguePowerable || event.getBlock().getBlockData() instanceof Powerable || redstoneBlocks.contains(event.getBlock().getType()))
|
||||
if(event.getBlock().getBlockData() instanceof AnaloguePowerable || event.getBlock().getBlockData() instanceof Powerable || redstoneBlocks.contains(event.getBlock().getType()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -239,16 +230,15 @@ public class EventBlocker extends FreedomService
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||
{
|
||||
double maxHealth = Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue();
|
||||
double maxHealth = event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||
if (maxHealth < 1)
|
||||
{
|
||||
for (AttributeModifier attributeModifier : Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getModifiers())
|
||||
for (AttributeModifier attributeModifier : event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getModifiers())
|
||||
{
|
||||
Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).removeModifier(attributeModifier);
|
||||
event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).removeModifier(attributeModifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockDispense(BlockDispenseEvent event)
|
||||
{
|
||||
|
@ -36,9 +36,10 @@ public class InteractBlocker extends FreedomService
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
case LEFT_CLICK_AIR:
|
||||
case LEFT_CLICK_BLOCK:
|
||||
{
|
||||
// Do nothing
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -89,7 +90,7 @@ public class InteractBlocker extends FreedomService
|
||||
{
|
||||
case WATER_BUCKET:
|
||||
{
|
||||
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -102,7 +103,7 @@ public class InteractBlocker extends FreedomService
|
||||
|
||||
case LAVA_BUCKET:
|
||||
{
|
||||
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -157,11 +158,6 @@ public class InteractBlocker extends FreedomService
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import org.bukkit.attribute.Attributable;
|
||||
@ -43,13 +42,13 @@ public class MobBlocker extends FreedomService
|
||||
Entity entity = e.getEntity();
|
||||
if (entity instanceof Attributable)
|
||||
{
|
||||
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0)
|
||||
if (((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).getBaseValue() > 255.0)
|
||||
{
|
||||
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0);
|
||||
((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(255.0);
|
||||
}
|
||||
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0)
|
||||
if (((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() > 10.0)
|
||||
{
|
||||
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0);
|
||||
((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(10.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -118,7 +117,7 @@ public class MobBlocker extends FreedomService
|
||||
}
|
||||
|
||||
int mobcount = 0;
|
||||
for (Entity entity : Objects.requireNonNull(event.getLocation().getWorld()).getLivingEntities())
|
||||
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
|
||||
{
|
||||
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ public class PVPBlocker extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
if (player != null & !plugin.al.isAdmin(player))
|
||||
if (player != null & !plugin.sl.isStaff(player))
|
||||
{
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
|
@ -82,4 +82,5 @@ public class PotionBlocker extends FreedomService
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import net.minecraft.server.v1_16_R3.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -35,9 +35,8 @@ public class SignBlocker extends FreedomService
|
||||
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
||||
{
|
||||
ItemStack sign = event.getItemInHand();
|
||||
net.minecraft.server.v1_16_R3.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||
net.minecraft.server.v1_16_R2.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
||||
assert compound != null;
|
||||
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
||||
String line1 = bet.getString("Text1");
|
||||
String line2 = bet.getString("Text2");
|
||||
|
@ -30,24 +30,6 @@ public class CommandBlocker extends FreedomService
|
||||
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
||||
private final List<String> unknownCommands = Lists.newArrayList();
|
||||
|
||||
public static CommandMap getCommandMap()
|
||||
{
|
||||
try
|
||||
{
|
||||
SimplePluginManager simplePluginManager = (SimplePluginManager)Bukkit.getServer().getPluginManager();
|
||||
|
||||
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||
commandMapField.setAccessible(true);
|
||||
|
||||
return (SimpleCommandMap)commandMapField.get(simplePluginManager);
|
||||
}
|
||||
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
|
||||
{
|
||||
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
@ -60,6 +42,25 @@ public class CommandBlocker extends FreedomService
|
||||
entryList.clear();
|
||||
}
|
||||
|
||||
public static CommandMap getCommandMap()
|
||||
{
|
||||
try
|
||||
{
|
||||
SimplePluginManager simplePluginManager = (SimplePluginManager) Bukkit.getServer().getPluginManager();
|
||||
|
||||
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||
commandMapField.setAccessible(true);
|
||||
|
||||
SimpleCommandMap simpleCommandMap = (SimpleCommandMap) commandMapField.get(simplePluginManager);
|
||||
return simpleCommandMap;
|
||||
}
|
||||
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
|
||||
{
|
||||
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
entryList.clear();
|
||||
@ -83,7 +84,7 @@ public class CommandBlocker extends FreedomService
|
||||
String commandName = parts[2].toLowerCase().substring(1);
|
||||
final String message = (parts.length > 3 ? parts[3] : null);
|
||||
|
||||
if (rank == null || action == null || commandName.isEmpty())
|
||||
if (rank == null || action == null || commandName == null || commandName.isEmpty())
|
||||
{
|
||||
FLog.warning("Invalid command blocker entry: " + rawEntry);
|
||||
continue;
|
||||
@ -97,7 +98,6 @@ public class CommandBlocker extends FreedomService
|
||||
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase();
|
||||
}
|
||||
|
||||
assert commandMap != null;
|
||||
final Command command = commandMap.getCommand(commandName);
|
||||
|
||||
// Obtain command from alias
|
||||
@ -171,7 +171,7 @@ public class CommandBlocker extends FreedomService
|
||||
|
||||
for (String part : commandParts)
|
||||
{
|
||||
if (command.startsWith("/") && !plugin.al.isAdmin(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
||||
if (command.startsWith("/") && !plugin.sl.isStaff(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
||||
{
|
||||
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
|
||||
return true;
|
||||
|
@ -8,11 +8,16 @@ public enum CommandBlockerAction
|
||||
BLOCK_UNKNOWN("u");
|
||||
private final String token;
|
||||
|
||||
CommandBlockerAction(String token)
|
||||
private CommandBlockerAction(String token)
|
||||
{
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getToken()
|
||||
{
|
||||
return this.token;
|
||||
}
|
||||
|
||||
public static CommandBlockerAction fromToken(String token)
|
||||
{
|
||||
for (CommandBlockerAction action : CommandBlockerAction.values())
|
||||
@ -24,9 +29,4 @@ public enum CommandBlockerAction
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getToken()
|
||||
{
|
||||
return this.token;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -10,15 +11,15 @@ import org.spigotmc.SpigotConfig;
|
||||
public class CommandBlockerEntry
|
||||
{
|
||||
|
||||
|
||||
@Getter
|
||||
private final CommandBlockerRank rank;
|
||||
|
||||
@Getter
|
||||
private final CommandBlockerAction action;
|
||||
|
||||
@Getter
|
||||
private final String command;
|
||||
|
||||
@Getter
|
||||
private final String subCommand;
|
||||
|
||||
@Getter
|
||||
private final String message;
|
||||
|
||||
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
||||
@ -39,7 +40,7 @@ public class CommandBlockerEntry
|
||||
{
|
||||
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
||||
{
|
||||
TotalFreedomMod.getPlugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
|
||||
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
|
||||
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||
return;
|
||||
}
|
||||
@ -50,29 +51,4 @@ public class CommandBlockerEntry
|
||||
}
|
||||
FUtil.playerMsg(sender, FUtil.colorize(message));
|
||||
}
|
||||
|
||||
public CommandBlockerRank getRank()
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
|
||||
public CommandBlockerAction getAction()
|
||||
{
|
||||
return action;
|
||||
}
|
||||
|
||||
public String getCommand()
|
||||
{
|
||||
return command;
|
||||
}
|
||||
|
||||
public String getSubCommand()
|
||||
{
|
||||
return subCommand;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
}
|
@ -1,57 +1,28 @@
|
||||
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public enum CommandBlockerRank
|
||||
{
|
||||
EVERYONE("e"),
|
||||
|
||||
ANYONE("a"),
|
||||
OP("o"),
|
||||
ADMIN("a"),
|
||||
SENIOR_ADMIN("s"),
|
||||
SUPER("s"),
|
||||
TELNET("t"),
|
||||
SENIOR("c"),
|
||||
NOBODY("n");
|
||||
//
|
||||
private final String token;
|
||||
|
||||
CommandBlockerRank(String token)
|
||||
private CommandBlockerRank(String token)
|
||||
{
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public static CommandBlockerRank fromSender(CommandSender sender)
|
||||
{
|
||||
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender);
|
||||
if (admin != null)
|
||||
{
|
||||
if (admin.getRank() == Rank.SENIOR_ADMIN)
|
||||
{
|
||||
return SENIOR_ADMIN;
|
||||
}
|
||||
return ADMIN;
|
||||
}
|
||||
|
||||
if (sender.isOp())
|
||||
{
|
||||
return OP;
|
||||
}
|
||||
|
||||
return EVERYONE;
|
||||
}
|
||||
|
||||
public static CommandBlockerRank fromToken(String token)
|
||||
{
|
||||
for (CommandBlockerRank rank : CommandBlockerRank.values())
|
||||
{
|
||||
if (rank.getToken().equalsIgnoreCase(token))
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return EVERYONE;
|
||||
}
|
||||
|
||||
public String getToken()
|
||||
{
|
||||
return this.token;
|
||||
@ -61,4 +32,42 @@ public enum CommandBlockerRank
|
||||
{
|
||||
return fromSender(sender).ordinal() >= ordinal();
|
||||
}
|
||||
|
||||
public static CommandBlockerRank fromSender(CommandSender sender)
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
return TELNET;
|
||||
}
|
||||
|
||||
StaffMember staffMember = TotalFreedomMod.plugin().sl.getAdmin(sender);
|
||||
if (staffMember != null)
|
||||
{
|
||||
if (staffMember.getRank() == Rank.SENIOR_ADMIN)
|
||||
{
|
||||
return SENIOR;
|
||||
}
|
||||
return SUPER;
|
||||
}
|
||||
|
||||
if (sender.isOp())
|
||||
{
|
||||
return OP;
|
||||
}
|
||||
|
||||
return ANYONE;
|
||||
|
||||
}
|
||||
|
||||
public static CommandBlockerRank fromToken(String token)
|
||||
{
|
||||
for (CommandBlockerRank rank : CommandBlockerRank.values())
|
||||
{
|
||||
if (rank.getToken().equalsIgnoreCase(token))
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return ANYONE;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
||||
@ -9,8 +10,8 @@ import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
||||
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -42,15 +43,15 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
return;
|
||||
}
|
||||
|
||||
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
|
||||
final StaffMember staffMember = plugin.sl.getEntryByIpFuzzy(ip);
|
||||
|
||||
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
||||
if (staffMember == null || !staffMember.isActive() || !staffMember.getRank().hasConsoleVariant())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setBypassPassword(true);
|
||||
event.setName(admin.getName());
|
||||
event.setName(staffMember.getName());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@ -65,8 +66,10 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
|
||||
{
|
||||
for (Map.Entry<Player, Map<String, Object>> entry : event.getDataTags().entrySet())
|
||||
final Iterator<Map.Entry<Player, Map<String, Object>>> it = event.getDataTags().entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
final Map.Entry<Player, Map<String, Object>> entry = it.next();
|
||||
final Player player = entry.getKey();
|
||||
final Map<String, Object> playerTags = entry.getValue();
|
||||
|
||||
@ -74,14 +77,14 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
boolean isTelnetAdmin = false;
|
||||
boolean isSeniorAdmin = false;
|
||||
|
||||
final Admin admin = plugin.al.getAdmin(player);
|
||||
if (admin != null)
|
||||
final StaffMember staffMember = plugin.sl.getAdmin(player);
|
||||
if (staffMember != null)
|
||||
{
|
||||
boolean active = admin.isActive();
|
||||
boolean active = staffMember.isActive();
|
||||
|
||||
isAdmin = active;
|
||||
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
|
||||
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.ADMIN);
|
||||
isSeniorAdmin = active && staffMember.getRank() == Rank.SENIOR_ADMIN;
|
||||
isTelnetAdmin = active && (isSeniorAdmin || staffMember.getRank() == Rank.ADMIN);
|
||||
}
|
||||
|
||||
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
||||
@ -118,22 +121,22 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
return bukkitTelnetPlugin;
|
||||
}
|
||||
|
||||
public List<Admin> getConnectedAdmins()
|
||||
public List<StaffMember> getConnectedAdmins()
|
||||
{
|
||||
List<Admin> admins = new ArrayList<>();
|
||||
List<StaffMember> staffMembers = new ArrayList<>();
|
||||
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||
if (telnet != null)
|
||||
{
|
||||
for (ClientSession session : telnet.appender.getSessions())
|
||||
{
|
||||
Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
|
||||
if (admin != null && !admins.contains(admin))
|
||||
StaffMember staffMember = plugin.sl.getEntryByName(session.getUserName().toLowerCase());
|
||||
if (staffMember != null && !staffMembers.contains(staffMember))
|
||||
{
|
||||
admins.add(admin);
|
||||
staffMembers.add(staffMember);
|
||||
}
|
||||
}
|
||||
}
|
||||
return admins;
|
||||
return staffMembers;
|
||||
}
|
||||
|
||||
public void killTelnetSessions(final String name)
|
||||
@ -145,8 +148,10 @@ public class BukkitTelnetBridge extends FreedomService
|
||||
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||
if (telnet != null)
|
||||
{
|
||||
for (ClientSession session : telnet.appender.getSessions())
|
||||
final Iterator<ClientSession> it = telnet.appender.getSessions().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
final ClientSession session = it.next();
|
||||
if (name != null && name.equalsIgnoreCase(session.getUserName()))
|
||||
{
|
||||
sessionsToRemove.add(session);
|
||||
|
@ -1,78 +1,32 @@
|
||||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.CoreProtectAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class CoreProtectBridge extends FreedomService
|
||||
{
|
||||
public static Map<Player, FUtil.PaginationList<String>> HISTORY_MAP = new HashMap<>();
|
||||
private CoreProtectAPI coreProtectAPI = null;
|
||||
|
||||
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
|
||||
|
||||
private final HashMap<String, Long> cooldown = new HashMap<>();
|
||||
private CoreProtectAPI coreProtectAPI = null;
|
||||
private BukkitTask wiper;
|
||||
|
||||
public static Long getSecondsLeft(long prevTime, int timeAdd)
|
||||
{
|
||||
return prevTime / 1000L + timeAdd - System.currentTimeMillis() / 1000L;
|
||||
}
|
||||
|
||||
// Unix timestamp converter taken from Functions class in CoreProtect, not my code
|
||||
public static String getTimeAgo(int logTime, int currentTime)
|
||||
{
|
||||
StringBuilder message = new StringBuilder();
|
||||
double timeSince = (double)currentTime - ((double)logTime + 0.0D);
|
||||
timeSince /= 60.0D;
|
||||
if (timeSince < 60.0D)
|
||||
{
|
||||
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/m ago");
|
||||
}
|
||||
|
||||
if (message.length() == 0)
|
||||
{
|
||||
timeSince /= 60.0D;
|
||||
if (timeSince < 24.0D)
|
||||
{
|
||||
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/h ago");
|
||||
}
|
||||
}
|
||||
|
||||
if (message.length() == 0)
|
||||
{
|
||||
timeSince /= 24.0D;
|
||||
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/d ago");
|
||||
}
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
@ -89,8 +43,8 @@ public class CoreProtectBridge extends FreedomService
|
||||
try
|
||||
{
|
||||
final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
|
||||
assert coreProtectPlugin != null;
|
||||
if (coreProtectPlugin instanceof CoreProtect)
|
||||
|
||||
if (coreProtectPlugin != null && coreProtectPlugin instanceof CoreProtect)
|
||||
{
|
||||
coreProtect = (CoreProtect)coreProtectPlugin;
|
||||
}
|
||||
@ -149,7 +103,7 @@ public class CoreProtectBridge extends FreedomService
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
coreProtect.performRollback(86400, Collections.singletonList(name), null, null, null, null, 0, null);
|
||||
coreProtect.performRollback(86400, Arrays.asList(name), null, null, null, null, 0, null);
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
@ -169,7 +123,7 @@ public class CoreProtectBridge extends FreedomService
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
coreProtect.performRestore(86400, Collections.singletonList(name), null, null, null, null, 0, null);
|
||||
coreProtect.performRestore(86400, Arrays.asList(name), null, null, null, null, 0, null);
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
@ -214,7 +168,7 @@ public class CoreProtectBridge extends FreedomService
|
||||
|
||||
/* As CoreProtect doesn't have an API method for deleting all of the data for a specific world
|
||||
we have to do this manually via SQL */
|
||||
Connection connection;
|
||||
Connection connection = null;
|
||||
try
|
||||
{
|
||||
String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString();
|
||||
@ -224,12 +178,11 @@ public class CoreProtectBridge extends FreedomService
|
||||
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
||||
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
||||
connection = DriverManager.getConnection("jdbc:sql://" + url);
|
||||
final PreparedStatement statement = connection.prepareStatement("SELECT id FROM co_world WHERE world = ?");
|
||||
final Statement statement = connection.createStatement();
|
||||
statement.setQueryTimeout(30);
|
||||
|
||||
// Obtain world ID from CoreProtect database
|
||||
statement.setString(1, world.getName());
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'");
|
||||
String worldID = null;
|
||||
while (resultSet.next())
|
||||
{
|
||||
@ -247,10 +200,7 @@ public class CoreProtectBridge extends FreedomService
|
||||
// Iterate through each table and delete their data if the world ID matches
|
||||
for (String table : tables)
|
||||
{
|
||||
final PreparedStatement statement1 = connection.prepareStatement("DELETE FROM ? WHERE wid = ?");
|
||||
statement1.setString(1, table);
|
||||
statement1.setString(2, worldID);
|
||||
statement1.executeQuery();
|
||||
statement.executeQuery("DELETE FROM " + table + " WHERE wid = " + worldID);
|
||||
}
|
||||
|
||||
connection.close();
|
||||
@ -267,191 +217,4 @@ public class CoreProtectBridge extends FreedomService
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
PlayerData data = plugin.pl.getData(player);
|
||||
Block block = event.getClickedBlock();
|
||||
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||
|
||||
if (data.hasInspection())
|
||||
{
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
List<String[]> lookup = coreProtect.blockLookup(block, -1);
|
||||
|
||||
int cooldownTime = 3;
|
||||
|
||||
if (cooldown.containsKey(player.getName()))
|
||||
{
|
||||
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
|
||||
if (secondsLeft > 0L)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
cooldown.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
if (lookup != null)
|
||||
{
|
||||
if (lookup.isEmpty())
|
||||
{
|
||||
player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
|
||||
return;
|
||||
}
|
||||
|
||||
HISTORY_MAP.remove(event.getPlayer());
|
||||
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
|
||||
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
|
||||
|
||||
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
|
||||
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
||||
|
||||
for (String[] value : lookup)
|
||||
{
|
||||
CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
|
||||
BlockData bl = result.getBlockData();
|
||||
|
||||
String s;
|
||||
String st = "";
|
||||
|
||||
if (result.getActionString().equals("Placement"))
|
||||
{
|
||||
s = " placed ";
|
||||
}
|
||||
else if (result.getActionString().equals("Removal"))
|
||||
{
|
||||
s = " broke ";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = " interacted with ";
|
||||
}
|
||||
|
||||
if (result.isRolledBack())
|
||||
{
|
||||
st += "§m";
|
||||
}
|
||||
|
||||
int time = (int)(System.currentTimeMillis() / 1000L);
|
||||
|
||||
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
|
||||
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
||||
}
|
||||
|
||||
List<String> page = paged.getPage(1);
|
||||
for (String entries : page)
|
||||
{
|
||||
player.sendMessage(entries);
|
||||
}
|
||||
|
||||
player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
if (block != null)
|
||||
{
|
||||
if (data.hasInspection())
|
||||
{
|
||||
BlockState blockState = block.getRelative(event.getBlockFace()).getState();
|
||||
Block placedBlock = blockState.getBlock();
|
||||
event.setCancelled(true);
|
||||
List<String[]> lookup = coreProtect.blockLookup(placedBlock, -1);
|
||||
|
||||
if (lookup.isEmpty())
|
||||
{
|
||||
lookup = coreProtect.blockLookup(block, -1);
|
||||
}
|
||||
|
||||
int cooldownTime = 3;
|
||||
|
||||
if (cooldown.containsKey(player.getName()))
|
||||
{
|
||||
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
|
||||
if (secondsLeft > 0L)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.al.isAdmin(player))
|
||||
{
|
||||
cooldown.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
if (lookup != null)
|
||||
{
|
||||
if (lookup.isEmpty())
|
||||
{
|
||||
player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
|
||||
return;
|
||||
}
|
||||
|
||||
HISTORY_MAP.remove(event.getPlayer());
|
||||
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
|
||||
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
|
||||
|
||||
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
|
||||
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
||||
|
||||
for (String[] value : lookup)
|
||||
{
|
||||
CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
|
||||
BlockData bl = result.getBlockData();
|
||||
|
||||
String s;
|
||||
String st = "";
|
||||
|
||||
if (result.getActionString().equals("Placement"))
|
||||
{
|
||||
s = " placed ";
|
||||
}
|
||||
else if (result.getActionString().equals("Removal"))
|
||||
{
|
||||
s = " broke ";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = " interacted with ";
|
||||
}
|
||||
|
||||
if (result.isRolledBack())
|
||||
{
|
||||
st += "§m";
|
||||
}
|
||||
|
||||
int time = (int)(System.currentTimeMillis() / 1000L);
|
||||
|
||||
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
|
||||
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
||||
}
|
||||
|
||||
List<String> page = paged.getPage(1);
|
||||
for (String entries : page)
|
||||
{
|
||||
player.sendMessage(entries);
|
||||
}
|
||||
|
||||
player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -42,8 +42,7 @@ public class EssentialsBridge extends FreedomService
|
||||
try
|
||||
{
|
||||
final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
|
||||
assert essentials != null;
|
||||
if (essentials instanceof Essentials)
|
||||
if (essentials != null && essentials instanceof Essentials)
|
||||
{
|
||||
essentialsPlugin = (Essentials)essentials;
|
||||
}
|
||||
@ -114,8 +113,7 @@ public class EssentialsBridge extends FreedomService
|
||||
User user = getEssentialsUser(username);
|
||||
if (user != null)
|
||||
{
|
||||
Long l = FUtil.getField(user, "lastActivity");
|
||||
return (l != null) ? l : 0L;
|
||||
return FUtil.getField(user, "lastActivity");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -152,7 +150,7 @@ public class EssentialsBridge extends FreedomService
|
||||
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
||||
{
|
||||
final InventoryHolder inventoryHolder = inventory.getHolder();
|
||||
if (inventoryHolder instanceof HumanEntity)
|
||||
if (inventoryHolder != null && inventoryHolder instanceof HumanEntity)
|
||||
{
|
||||
Player invOwner = (Player)inventoryHolder;
|
||||
Rank recieverRank = plugin.rm.getRank(player);
|
||||
@ -205,7 +203,6 @@ public class EssentialsBridge extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Actually use this for something or remove it.
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
|
@ -0,0 +1,185 @@
|
||||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.CoreProtectAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class FAWEBridge extends FreedomService
|
||||
{
|
||||
private CoreProtectAPI api;
|
||||
private World world = null;
|
||||
private final Map<Map.Entry<String, EditSession>, Map<BlockVector3, String>> blocksBroken = new HashMap<>();
|
||||
private final Map<Map.Entry<String, EditSession>, Map.Entry<Pattern, List<BlockVector3>>> blocksPlaced = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
api = ((CoreProtect)Bukkit.getPluginManager().getPlugin("CoreProtect")).getAPI();
|
||||
|
||||
/*
|
||||
* Iterates over blocks placed by GenerationCommands (in the EditSession) and adds them to the CoreProtect logs.
|
||||
*/
|
||||
server.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!(blocksBroken.isEmpty() && blocksPlaced.isEmpty()))
|
||||
{
|
||||
// Send all broken blocks from the last ticks to the CoreProtect API.
|
||||
Map.Entry<String, EditSession> playerAndSessionEntry = null;
|
||||
for (Map.Entry<Map.Entry<String, EditSession>, Map<BlockVector3, String>> entry : blocksBroken.entrySet())
|
||||
{
|
||||
playerAndSessionEntry = entry.getKey();
|
||||
Map<BlockVector3, String> dataAndVectorEntry = entry.getValue();
|
||||
List<BlockVector3> blockVector3List = new ArrayList<>();
|
||||
blockVector3List.addAll(dataAndVectorEntry.keySet()); // Deep clone the block vector to avoid a change later in the code.
|
||||
|
||||
for (BlockVector3 blockVector3 : blockVector3List)
|
||||
{
|
||||
if (blockVector3 != null)
|
||||
{
|
||||
EditSession editSession = playerAndSessionEntry.getValue();
|
||||
World world = server.getWorld(editSession.getWorld().getName());
|
||||
Location location = new Location(world, blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
|
||||
BlockData blockData = server.createBlockData(dataAndVectorEntry.get(blockVector3));
|
||||
api.logRemoval(playerAndSessionEntry.getKey(), location, blockData.getMaterial(), blockData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear after broken blocks have been updated.
|
||||
blocksBroken.values().clear();
|
||||
blocksBroken.putIfAbsent(playerAndSessionEntry, new HashMap<>());
|
||||
|
||||
// Send all blocks placed to the CoreProtect API (except from the air as it's only a broken block).
|
||||
for (Map.Entry<Map.Entry<String, EditSession>, Map.Entry<Pattern, List<BlockVector3>>> entry : blocksPlaced.entrySet())
|
||||
{
|
||||
playerAndSessionEntry = entry.getKey();
|
||||
Map.Entry<Pattern, List<BlockVector3>> patternAndListEntry = entry.getValue();
|
||||
Pattern pattern = patternAndListEntry.getKey();
|
||||
List<BlockVector3> blockVector3List = new ArrayList<>();
|
||||
blockVector3List.addAll(patternAndListEntry.getValue()); // Deep clone the block vector to avoid a change later in the code.
|
||||
|
||||
for (BlockVector3 blockVector3 : blockVector3List)
|
||||
{
|
||||
if (blockVector3 != null && !pattern.apply(blockVector3).getBlockType().getMaterial().isAir())
|
||||
{
|
||||
World world = server.getWorld(playerAndSessionEntry.getValue().getWorld().getName());
|
||||
Location location = new Location(world, blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
|
||||
BaseBlock block = pattern.apply(blockVector3);
|
||||
Material material = Material.getMaterial(block.getBlockType().getId().replaceFirst("minecraft:", "").toUpperCase());
|
||||
api.logPlacement(playerAndSessionEntry.getKey(), location, material, material.createBlockData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blocksPlaced.values().forEach(collection -> collection.getValue().clear());
|
||||
}
|
||||
}
|
||||
}, 0L, 40L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, BlockVector3 blockVector3)
|
||||
{
|
||||
// Cache the world used for the next iterations to come.
|
||||
if (world == null || !world.getName().equals(editSession.getWorld().getName()))
|
||||
{
|
||||
world = server.getWorld(editSession.getWorld().getName());
|
||||
}
|
||||
|
||||
Map.Entry<String, EditSession> playerAndSessionEntry = new AbstractMap.SimpleEntry(playerName, editSession);
|
||||
Block block = world.getBlockAt(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
|
||||
|
||||
// Add the broken block to CoreProtect if it's not air.
|
||||
if (!block.getType().isAir())
|
||||
{
|
||||
String blockData = block.getBlockData().getAsString();
|
||||
blockData = new Gson().fromJson(new Gson().toJson(blockData), blockData.getClass()); // Overwrite original with deep clones.
|
||||
blockVector3 = new Gson().fromJson(new Gson().toJson(blockVector3), blockVector3.getClass()); // Overwrite original with deep clones.
|
||||
blocksBroken.putIfAbsent(playerAndSessionEntry, new HashMap<>());
|
||||
blocksBroken.get(playerAndSessionEntry).put(blockVector3, blockData);
|
||||
}
|
||||
|
||||
// Add the placed block to CoreProtect if it's not air.
|
||||
if (!pattern.apply(blockVector3).getBlockType().getMaterial().isAir())
|
||||
{
|
||||
blocksPlaced.putIfAbsent(playerAndSessionEntry, new AbstractMap.SimpleEntry<>(pattern, new ArrayList<>()));
|
||||
BlockVector3 vectorClone = new Gson().fromJson(new Gson().toJson(blockVector3), blockVector3.getClass());
|
||||
|
||||
if (!blocksPlaced.get(playerAndSessionEntry).getValue().contains(vectorClone))
|
||||
{
|
||||
blocksPlaced.get(playerAndSessionEntry).getValue().add(vectorClone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void logBlockEdits(String playerName, EditSession editSession, Region region, Pattern pattern)
|
||||
{
|
||||
// Add the broken blocks to CoreProtect.
|
||||
if (world == null || !world.getName().equals(editSession.getWorld().getName()))
|
||||
{
|
||||
world = server.getWorld(editSession.getWorld().getName());
|
||||
}
|
||||
List<BlockState> blocks = new ArrayList<>();
|
||||
|
||||
for (BlockVector3 blockVector3 : region)
|
||||
{
|
||||
blocks.add(world.getBlockAt(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()).getState());
|
||||
}
|
||||
|
||||
logBlockEdit(playerName, editSession, pattern, blocks);
|
||||
}
|
||||
|
||||
public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, List<BlockState> blocks)
|
||||
{
|
||||
Map.Entry<String, EditSession> playerAndSessionEntry = new AbstractMap.SimpleEntry(playerName, editSession);
|
||||
|
||||
server.getScheduler().scheduleAsyncDelayedTask(plugin, () ->
|
||||
{
|
||||
for (BlockState block : blocks)
|
||||
{
|
||||
BlockVector3 blockVector3 = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||
|
||||
// Add the broken block to CoreProtect if it's not air.
|
||||
if (!block.getType().isAir())
|
||||
{
|
||||
api.logRemoval(playerAndSessionEntry.getKey(), block.getLocation(), block.getType(), block.getBlockData());
|
||||
}
|
||||
|
||||
// Add the placed block to CoreProtect if it's not air.
|
||||
BaseBlock baseBlock = pattern.apply(blockVector3);
|
||||
if (!baseBlock.getBlockType().getMaterial().isAir())
|
||||
{
|
||||
Material material = Material.getMaterial(baseBlock.getBlockType().getId().replaceFirst("minecraft:", "").toUpperCase());
|
||||
api.logPlacement(playerAndSessionEntry.getKey(), block.getLocation(), material, material.createBlockData());
|
||||
}
|
||||
}
|
||||
}, 0L);
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ public class LibsDisguisesBridge extends FreedomService
|
||||
return libsDisguisesPlugin;
|
||||
}
|
||||
|
||||
public void undisguiseAll(boolean admin)
|
||||
public void undisguiseAll(boolean staff)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -61,7 +61,7 @@ public class LibsDisguisesBridge extends FreedomService
|
||||
{
|
||||
if (DisguiseAPI.isDisguised(player))
|
||||
{
|
||||
if (!admin && plugin.al.isAdmin(player))
|
||||
if (!staff && plugin.sl.isStaff(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -75,11 +75,6 @@ public class LibsDisguisesBridge extends FreedomService
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDisguisesEnabled()
|
||||
{
|
||||
return !BlockedDisguises.disabled;
|
||||
}
|
||||
|
||||
public void setDisguisesEnabled(boolean state)
|
||||
{
|
||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||
@ -92,6 +87,11 @@ public class LibsDisguisesBridge extends FreedomService
|
||||
BlockedDisguises.disabled = !state;
|
||||
}
|
||||
|
||||
public boolean isDisguisesEnabled()
|
||||
{
|
||||
return !BlockedDisguises.disabled;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TFGuildsBridge extends FreedomService
|
||||
{
|
||||
|
||||
public boolean enabled = false;
|
||||
|
||||
@Override
|
||||
@ -53,6 +54,6 @@ public class TFGuildsBridge extends FreedomService
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Common.GUILD_CHAT.contains(player);
|
||||
return Common.IN_GUILD_CHAT.contains(player);
|
||||
}
|
||||
}
|
@ -60,7 +60,8 @@ public class WorldEditBridge extends FreedomService
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
||||
session.undo(session.getBlockBag(fuckyou), fuckyou);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -83,7 +84,8 @@ public class WorldEditBridge extends FreedomService
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
session.redo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
||||
session.redo(session.getBlockBag(fuckyou), fuckyou);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ public class WorldGuardBridge extends FreedomService
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
|
||||
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.caging;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -11,21 +12,141 @@ import org.bukkit.block.Skull;
|
||||
public class CageData
|
||||
{
|
||||
|
||||
private static String input = null;
|
||||
private final FPlayer fPlayer;
|
||||
//
|
||||
//
|
||||
private final List<BlockData> cageHistory = new ArrayList<>();
|
||||
//
|
||||
@Getter
|
||||
private boolean caged = false;
|
||||
@Getter
|
||||
private Location location;
|
||||
@Getter
|
||||
private Material outerMaterial = Material.GLASS;
|
||||
@Getter
|
||||
private Material innerMaterial = Material.AIR;
|
||||
@Getter
|
||||
private static String input = null;
|
||||
|
||||
public CageData(FPlayer player)
|
||||
{
|
||||
this.fPlayer = player;
|
||||
}
|
||||
|
||||
public void setCaged(boolean cage)
|
||||
{
|
||||
if (cage)
|
||||
{
|
||||
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.caged = false;
|
||||
regenerateHistory();
|
||||
clearHistory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void cage(Location location, Material outer, Material inner)
|
||||
{
|
||||
if (isCaged())
|
||||
{
|
||||
setCaged(false);
|
||||
}
|
||||
|
||||
this.caged = true;
|
||||
this.location = location;
|
||||
this.outerMaterial = outer;
|
||||
this.innerMaterial = inner;
|
||||
this.input = null;
|
||||
|
||||
buildHistory(location, 2, fPlayer);
|
||||
regenerate();
|
||||
}
|
||||
|
||||
public void cage(Location location, Material outer, Material inner, String input)
|
||||
{
|
||||
if (isCaged())
|
||||
{
|
||||
setCaged(false);
|
||||
}
|
||||
|
||||
this.caged = true;
|
||||
this.location = location;
|
||||
this.outerMaterial = outer;
|
||||
this.innerMaterial = inner;
|
||||
this.input = input;
|
||||
|
||||
buildHistory(location, 2, fPlayer);
|
||||
regenerate();
|
||||
}
|
||||
|
||||
public void regenerate()
|
||||
{
|
||||
|
||||
if (!caged
|
||||
|| location == null
|
||||
|| outerMaterial == null
|
||||
|| innerMaterial == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
generateHollowCube(location, 2, outerMaterial);
|
||||
generateCube(location, 1, innerMaterial);
|
||||
}
|
||||
|
||||
// TODO: EventHandlerize this?
|
||||
public void playerJoin()
|
||||
{
|
||||
if (!isCaged())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
|
||||
}
|
||||
|
||||
public void playerQuit()
|
||||
{
|
||||
regenerateHistory();
|
||||
clearHistory();
|
||||
}
|
||||
|
||||
public void clearHistory()
|
||||
{
|
||||
cageHistory.clear();
|
||||
}
|
||||
|
||||
private void insertHistoryBlock(Location location, Material material)
|
||||
{
|
||||
cageHistory.add(new BlockData(location, material));
|
||||
}
|
||||
|
||||
private void regenerateHistory()
|
||||
{
|
||||
for (BlockData blockdata : this.cageHistory)
|
||||
{
|
||||
blockdata.location.getBlock().setType(blockdata.material);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildHistory(Location location, int length, FPlayer playerdata)
|
||||
{
|
||||
final Block center = location.getBlock();
|
||||
for (int xOffset = -length; xOffset <= length; xOffset++)
|
||||
{
|
||||
for (int yOffset = -length; yOffset <= length; yOffset++)
|
||||
{
|
||||
for (int zOffset = -length; zOffset <= length; zOffset++)
|
||||
{
|
||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||
insertHistoryBlock(block.getLocation(), block.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Util methods
|
||||
public static void generateCube(Location location, int length, Material material)
|
||||
{
|
||||
@ -46,7 +167,6 @@ public class CageData
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void generateHollowCube(Location location, int length, Material material)
|
||||
{
|
||||
final Block center = location.getBlock();
|
||||
@ -93,7 +213,7 @@ public class CageData
|
||||
skull.setOwner(input);
|
||||
skull.update();
|
||||
}
|
||||
catch (ClassCastException ignored)
|
||||
catch (ClassCastException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -103,176 +223,6 @@ public class CageData
|
||||
}
|
||||
}
|
||||
|
||||
public static String getInput()
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
public static void setInput(String input)
|
||||
{
|
||||
CageData.input = input;
|
||||
}
|
||||
|
||||
public void cage(Location location, Material outer, Material inner)
|
||||
{
|
||||
if (isCaged())
|
||||
{
|
||||
setCaged(false);
|
||||
}
|
||||
|
||||
this.caged = true;
|
||||
this.location = location;
|
||||
this.outerMaterial = outer;
|
||||
this.innerMaterial = inner;
|
||||
input = null;
|
||||
|
||||
buildHistory(location);
|
||||
regenerate();
|
||||
}
|
||||
|
||||
public void cage(Location location, Material outer, Material inner, String input)
|
||||
{
|
||||
if (isCaged())
|
||||
{
|
||||
setCaged(false);
|
||||
}
|
||||
|
||||
this.caged = true;
|
||||
this.location = location;
|
||||
this.outerMaterial = outer;
|
||||
this.innerMaterial = inner;
|
||||
CageData.input = input;
|
||||
|
||||
buildHistory(location);
|
||||
regenerate();
|
||||
}
|
||||
|
||||
public void regenerate()
|
||||
{
|
||||
|
||||
if (!caged
|
||||
|| location == null
|
||||
|| outerMaterial == null
|
||||
|| innerMaterial == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
generateHollowCube(location, 2, outerMaterial);
|
||||
generateCube(location, 1, innerMaterial);
|
||||
}
|
||||
|
||||
// TODO: EventHandler this?
|
||||
public void playerJoin()
|
||||
{
|
||||
if (!isCaged())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
|
||||
}
|
||||
|
||||
public void playerQuit()
|
||||
{
|
||||
regenerateHistory();
|
||||
clearHistory();
|
||||
}
|
||||
|
||||
public void clearHistory()
|
||||
{
|
||||
cageHistory.clear();
|
||||
}
|
||||
|
||||
private void insertHistoryBlock(Location location, Material material)
|
||||
{
|
||||
cageHistory.add(new BlockData(location, material));
|
||||
}
|
||||
|
||||
private void regenerateHistory()
|
||||
{
|
||||
for (BlockData blockdata : this.cageHistory)
|
||||
{
|
||||
blockdata.location.getBlock().setType(blockdata.material);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildHistory(Location location)
|
||||
{
|
||||
final Block center = location.getBlock();
|
||||
for (int xOffset = -2; xOffset <= 2; xOffset++)
|
||||
{
|
||||
for (int yOffset = -2; yOffset <= 2; yOffset++)
|
||||
{
|
||||
for (int zOffset = -2; zOffset <= 2; zOffset++)
|
||||
{
|
||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||
insertHistoryBlock(block.getLocation(), block.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FPlayer getfPlayer()
|
||||
{
|
||||
return fPlayer;
|
||||
}
|
||||
|
||||
public List<BlockData> getCageHistory()
|
||||
{
|
||||
return cageHistory;
|
||||
}
|
||||
|
||||
public boolean isCaged()
|
||||
{
|
||||
return caged;
|
||||
}
|
||||
|
||||
public void setCaged(boolean cage)
|
||||
{
|
||||
if (cage)
|
||||
{
|
||||
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.caged = false;
|
||||
regenerateHistory();
|
||||
clearHistory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(Location location)
|
||||
{
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public Material getOuterMaterial()
|
||||
{
|
||||
return outerMaterial;
|
||||
}
|
||||
|
||||
public void setOuterMaterial(Material outerMaterial)
|
||||
{
|
||||
this.outerMaterial = outerMaterial;
|
||||
}
|
||||
|
||||
public Material getInnerMaterial()
|
||||
{
|
||||
return innerMaterial;
|
||||
}
|
||||
|
||||
public void setInnerMaterial(Material innerMaterial)
|
||||
{
|
||||
this.innerMaterial = innerMaterial;
|
||||
}
|
||||
|
||||
private static class BlockData
|
||||
{
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.caging;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -32,7 +31,8 @@ public class Cager extends FreedomService
|
||||
public void onBreakBlock(BlockBreakEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.al.isAdmin(player))
|
||||
if (player == null
|
||||
|| plugin.sl.isStaff(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class Cager extends FreedomService
|
||||
Location cageLoc = cage.getLocation();
|
||||
|
||||
final boolean outOfCage;
|
||||
if (!Objects.equals(playerLoc.getWorld(), cageLoc.getWorld()))
|
||||
if (!playerLoc.getWorld().equals(cageLoc.getWorld()))
|
||||
{
|
||||
outOfCage = true;
|
||||
}
|
||||
@ -113,4 +113,5 @@ public class Cager extends FreedomService
|
||||
cage.playerJoin();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -4,12 +4,14 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
public class CommandLoader extends FreedomService
|
||||
{
|
||||
@Getter
|
||||
private final List<FreedomCommand> commands;
|
||||
|
||||
public CommandLoader()
|
||||
@ -38,10 +40,8 @@ public class CommandLoader extends FreedomService
|
||||
for (FreedomCommand command : commands)
|
||||
{
|
||||
if (name.equals(command.getName()))
|
||||
{
|
||||
return command;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -50,10 +50,8 @@ public class CommandLoader extends FreedomService
|
||||
for (FreedomCommand command : commands)
|
||||
{
|
||||
if (Arrays.asList(command.getAliases().split(",")).contains(alias))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -71,15 +69,10 @@ public class CommandLoader extends FreedomService
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
|
||||
{
|
||||
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_", ""));
|
||||
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_" , ""));
|
||||
}
|
||||
}
|
||||
|
||||
FLog.info("Loaded " + commands.size() + " commands");
|
||||
}
|
||||
|
||||
public List<FreedomCommand> getCommands()
|
||||
{
|
||||
return commands;
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ public class Command_adventure extends FreedomCommand
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
msg("When used from the console, you must define a target player.");
|
||||
sender.sendMessage("When used from the console, you must define a target player.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ public class Command_adventure extends FreedomCommand
|
||||
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
|
||||
FUtil.staffAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
|
||||
msg("Your gamemode has been set to adventure.");
|
||||
return true;
|
||||
}
|
||||
@ -46,7 +46,7 @@ public class Command_adventure extends FreedomCommand
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class Command_aeclear extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Removing all area effect clouds", true);
|
||||
FUtil.staffAction(sender.getName(), "Removing all area effect clouds.", true);
|
||||
int removed = 0;
|
||||
for (World world : server.getWorlds())
|
||||
{
|
||||
|
@ -22,4 +22,5 @@ public class Command_announce extends FreedomCommand
|
||||
plugin.an.announce(StringUtils.join(args, " "));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -14,17 +14,17 @@ public class Command_attributelist extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
StringBuilder list = new StringBuilder("All possible attributes: ");
|
||||
String list = "All possible attributes: ";
|
||||
|
||||
for (Attribute attribute : Attribute.values())
|
||||
{
|
||||
list.append(attribute.name()).append(", ");
|
||||
list += attribute.name() + ", ";
|
||||
}
|
||||
|
||||
// Remove extra comma at the end of the list
|
||||
list = new StringBuilder(list.substring(0, list.length() - 2));
|
||||
list = list.substring(0, list.length() - 2);
|
||||
|
||||
msg(list.toString());
|
||||
msg(list);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
@ -32,8 +31,8 @@ public class Command_ban extends FreedomCommand
|
||||
}
|
||||
|
||||
String reason = null;
|
||||
boolean silent = false;
|
||||
boolean cancelRollback = false;
|
||||
Boolean silent = false;
|
||||
Boolean cancelRollback = false;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
|
||||
@ -101,7 +100,7 @@ public class Command_ban extends FreedomCommand
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos);
|
||||
targetPos.getWorld().strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -155,7 +154,7 @@ public class Command_ban extends FreedomCommand
|
||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||
}
|
||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||
FUtil.adminAction(sender.getName(), bcast.toString(), true);
|
||||
FUtil.staffAction(sender.getName(), String.format(bcast.toString()), true);
|
||||
}
|
||||
|
||||
// Kick player and handle others on IP
|
||||
|
@ -30,7 +30,7 @@ public class Command_banip extends FreedomCommand
|
||||
|
||||
String ip = args[0];
|
||||
|
||||
if (FUtil.isValidIPv4(ip))
|
||||
if (!FUtil.isValidIPv4(ip))
|
||||
{
|
||||
msg(ip + " is not a valid IP address", ChatColor.RED);
|
||||
return true;
|
||||
@ -72,8 +72,8 @@ public class Command_banip extends FreedomCommand
|
||||
{
|
||||
// Broadcast
|
||||
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
|
||||
String message = sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
|
||||
msg(player, message, ChatColor.RED);
|
||||
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.sl.isStaff(player) ? "the IP " + ip : "an IP");
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class Command_banlist extends FreedomCommand
|
||||
{
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
||||
FUtil.staffAction(sender.getName(), "Purging the ban list", true);
|
||||
int amount = plugin.bm.purge();
|
||||
msg("Purged " + amount + " player bans.");
|
||||
return true;
|
||||
|
@ -27,7 +27,7 @@ public class Command_banname extends FreedomCommand
|
||||
|
||||
String reason = null;
|
||||
|
||||
String name = args[0];
|
||||
String name = args[0];;
|
||||
|
||||
if (plugin.bm.getByUsername(name) != null)
|
||||
{
|
||||
@ -55,7 +55,7 @@ public class Command_banname extends FreedomCommand
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Banned the name " + name, true);
|
||||
FUtil.staffAction(sender.getName(), "Banned the name " + name, true);
|
||||
}
|
||||
|
||||
Player player = getPlayer(name);
|
||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.SplittableRandom;
|
||||
import java.util.Random;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
@ -27,7 +27,7 @@ public class Command_bird extends FreedomCommand
|
||||
public EntityType getRandomFish()
|
||||
{
|
||||
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
||||
SplittableRandom random = new SplittableRandom();
|
||||
Random random = new Random();
|
||||
return fishTypes.get(random.nextInt(fishTypes.size()));
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -25,7 +23,7 @@ public class Command_blockcmd extends FreedomCommand
|
||||
|
||||
if (args[0].equals("purge"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
|
||||
FUtil.staffAction(sender.getName(), "Unblocking commands for all players", true);
|
||||
int counter = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
@ -42,18 +40,18 @@ public class Command_blockcmd extends FreedomCommand
|
||||
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Blocking commands for all non-admins", true);
|
||||
FUtil.staffAction(sender.getName(), "Blocking commands for all non-staff", true);
|
||||
int counter = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (isAdmin(player))
|
||||
if (isStaff(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
counter += 1;
|
||||
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
||||
msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
||||
msg(player, "Your commands have been blocked by a staff member.", ChatColor.RED);
|
||||
}
|
||||
|
||||
msg("Blocked commands for " + counter + " players.");
|
||||
@ -68,20 +66,18 @@ public class Command_blockcmd extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isAdmin(player))
|
||||
if (isStaff(player))
|
||||
{
|
||||
msg(player.getName() + " is an admin, and cannot have their commands blocked.");
|
||||
msg(player.getName() + " is a staff member, and cannot have their commands blocked.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
if (!playerdata.allCommandsBlocked())
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
||||
playerdata.setCommandsBlocked(true);
|
||||
FUtil.staffAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
||||
msg("Blocked commands for " + player.getName() + ".");
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.BLOCKCMD, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,8 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
@ -48,7 +46,7 @@ public class Command_blockedit extends FreedomCommand
|
||||
|
||||
if (args[0].equals("purge"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for all players", true);
|
||||
FUtil.staffAction(sender.getName(), "Unblocking block modification abilities for all players.", true);
|
||||
int count = 0;
|
||||
for (final Player player : this.server.getOnlinePlayers())
|
||||
{
|
||||
@ -65,11 +63,11 @@ public class Command_blockedit extends FreedomCommand
|
||||
|
||||
if (args[0].equals("all"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for all non-admins", true);
|
||||
FUtil.staffAction(sender.getName(), "Blocking block modification abilities for all non-staff.", true);
|
||||
int counter = 0;
|
||||
for (final Player player : this.server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player))
|
||||
if (!plugin.sl.isStaff(player))
|
||||
{
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
playerdata.setEditBlocked(true);
|
||||
@ -94,7 +92,7 @@ public class Command_blockedit extends FreedomCommand
|
||||
final Player player2 = getPlayer(args[0]);
|
||||
if (player2 == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -107,20 +105,20 @@ public class Command_blockedit extends FreedomCommand
|
||||
final FPlayer pd = plugin.pl.getPlayer(player2);
|
||||
if (pd.isEditBlocked())
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
|
||||
FUtil.staffAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
|
||||
pd.setEditBlocked(false);
|
||||
msg("Unblocking block modification abilities for " + player2.getName());
|
||||
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.al.isAdmin(player2))
|
||||
if (plugin.sl.isStaff(player2))
|
||||
{
|
||||
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
|
||||
msg(player2.getName() + " is a staff member, and cannot have their block edits blocked.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
|
||||
FUtil.staffAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
|
||||
pd.setEditBlocked(true);
|
||||
|
||||
if (smite)
|
||||
@ -130,8 +128,6 @@ public class Command_blockedit extends FreedomCommand
|
||||
|
||||
msg(player2, "Your block modification abilities have been blocked.", ChatColor.RED);
|
||||
msg("Blocked all block modification abilities for " + player2.getName());
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player2.getName(), FUtil.getIp(player2), sender.getName(), PunishmentType.BLOCKEDIT, null));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@ -48,7 +46,7 @@ public class Command_blockpvp extends FreedomCommand
|
||||
|
||||
if (args[0].equals("purge"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
|
||||
FUtil.staffAction(sender.getName(), "Enabling PVP for all players.", true);
|
||||
int count = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
@ -66,11 +64,11 @@ public class Command_blockpvp extends FreedomCommand
|
||||
|
||||
if (args[0].equals("all"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true);
|
||||
FUtil.staffAction(sender.getName(), "Disabling PVP for all non-staff", true);
|
||||
int counter = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player))
|
||||
if (!plugin.sl.isStaff(player))
|
||||
{
|
||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||
playerdata.setPvpBlocked(true);
|
||||
@ -95,7 +93,7 @@ public class Command_blockpvp extends FreedomCommand
|
||||
final Player p = getPlayer(args[0]);
|
||||
if (p == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -108,26 +106,25 @@ public class Command_blockpvp extends FreedomCommand
|
||||
final FPlayer pd = plugin.pl.getPlayer(p);
|
||||
if (pd.isPvpBlocked())
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
|
||||
FUtil.staffAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
|
||||
pd.setPvpBlocked(false);
|
||||
msg("Enabling PVP for " + p.getName());
|
||||
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.al.isAdmin(p))
|
||||
if (plugin.sl.isStaff(p))
|
||||
{
|
||||
msg(p.getName() + " is an admin, and cannot have their PVP disabled.");
|
||||
msg(p.getName() + " is a staff member, and cannot have their PVP disabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
||||
FUtil.staffAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
||||
pd.setPvpBlocked(true);
|
||||
if (smite)
|
||||
{
|
||||
Command_smite.smite(sender, p, reason);
|
||||
}
|
||||
plugin.pul.logPunishment(new Punishment(p.getName(), FUtil.getIp(p), sender.getName(), PunishmentType.BLOCKPVP, null));
|
||||
|
||||
msg(p, "Your PVP has been disabled.", ChatColor.RED);
|
||||
msg("Disabled PVP for " + p.getName());
|
||||
|
@ -18,14 +18,14 @@ public class Command_blockredstone extends FreedomCommand
|
||||
if (ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||
{
|
||||
ConfigEntry.ALLOW_REDSTONE.setBoolean(false);
|
||||
FUtil.adminAction(sender.getName(), "Blocking all redstone", true);
|
||||
FUtil.staffAction(sender.getName(), "Blocking all redstone", true);
|
||||
new BukkitRunnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||
{
|
||||
FUtil.adminAction("TotalFreedom", "Unblocking all redstone", false);
|
||||
FUtil.staffAction("TotalFreedom", "Unblocking all redstone", false);
|
||||
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||
}
|
||||
}
|
||||
@ -34,7 +34,7 @@ public class Command_blockredstone extends FreedomCommand
|
||||
else
|
||||
{
|
||||
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||
FUtil.adminAction(sender.getName(), "Unblocking all redstone", true);
|
||||
FUtil.staffAction(sender.getName(), "Unblocking all redstone", true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -5,8 +5,6 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -30,9 +28,9 @@ public class Command_cage extends FreedomCommand
|
||||
}
|
||||
|
||||
String skullName = null;
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
if ("purge".equals(args[0]))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
||||
FUtil.staffAction(sender.getName(), "Uncaging all players", true);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
@ -44,14 +42,14 @@ public class Command_cage extends FreedomCommand
|
||||
Player player = getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
if (fPlayer.getCageData().isCaged())
|
||||
{
|
||||
msg("That player is already caged.", ChatColor.RED);
|
||||
sender.sendMessage(ChatColor.RED + "That player is already caged.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -82,24 +80,11 @@ public class Command_cage extends FreedomCommand
|
||||
outerMaterial = Material.matchMaterial(args[2]);
|
||||
break;
|
||||
}
|
||||
msg("Invalid block!", ChatColor.RED);
|
||||
sender.sendMessage(ChatColor.RED + "Invalid block!");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outerMaterial == Material.PLAYER_HEAD)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
||||
}
|
||||
|
||||
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
||||
|
||||
@ -111,16 +96,24 @@ public class Command_cage extends FreedomCommand
|
||||
{
|
||||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
||||
}
|
||||
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.CAGE, null));
|
||||
if (outerMaterial == Material.PLAYER_HEAD)
|
||||
{
|
||||
FUtil.staffAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.staffAction(sender.getName(), "Caging " + player.getName(), true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender))
|
||||
if (!plugin.sl.isStaff(sender))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ public class Command_cake extends FreedomCommand
|
||||
|
||||
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||
assert heldItemMeta != null;
|
||||
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
||||
heldItem.setItemMeta(heldItemMeta);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,13 +16,14 @@ public class Command_cartsit extends FreedomCommand
|
||||
{
|
||||
Player targetPlayer = playerSender;
|
||||
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
if (args.length == 1 && plugin.sl.isStaff(sender))
|
||||
{
|
||||
|
||||
targetPlayer = getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -32,14 +32,14 @@ public class Command_cartsit extends FreedomCommand
|
||||
{
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
msg("When used from the console, you must define a target player: /cartsit <player>");
|
||||
sender.sendMessage("When used from the console, you must define a target player: /cartsit <player>");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetPlayer.isInsideVehicle())
|
||||
{
|
||||
Objects.requireNonNull(targetPlayer.getVehicle()).eject();
|
||||
targetPlayer.getVehicle().eject();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -16,15 +16,15 @@ public class Command_clearchat extends FreedomCommand
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!plugin.al.isAdmin(player))
|
||||
if (!plugin.sl.isStaff(player))
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
msg(player, "");
|
||||
player.sendMessage("");
|
||||
}
|
||||
}
|
||||
}
|
||||
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
||||
FUtil.staffAction(sender.getName(), "Cleared chat", true);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "Clear the discord message queue.", usage = "/<command>")
|
||||
public class Command_cleardiscordqueue extends FreedomCommand
|
||||
{
|
||||
|
@ -29,11 +29,11 @@ public class Command_clearinventory extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.al.isAdmin(sender))
|
||||
if (plugin.sl.isStaff(sender))
|
||||
{
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true);
|
||||
FUtil.staffAction(sender.getName(), "Clearing everyone's inventory", true);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
player.getInventory().clear();
|
||||
@ -52,7 +52,7 @@ public class Command_clearinventory extends FreedomCommand
|
||||
|
||||
player.getInventory().clear();
|
||||
msg("Cleared " + player.getName() + "'s inventory.");
|
||||
msg(player, sender.getName() + " has cleared your inventory.");
|
||||
player.sendMessage(sender.getName() + " has cleared your inventory.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -67,7 +67,7 @@ public class Command_clearinventory extends FreedomCommand
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
if (args.length == 1 && plugin.sl.isStaff(sender))
|
||||
{
|
||||
List<String> players = FUtil.getPlayerList();
|
||||
players.add("-a");
|
||||
|
@ -15,14 +15,14 @@ public class Command_clownfish extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH) && (!plugin.lp.CLOWNFISH_TOGGLE.contains(playerSender.getName())))
|
||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH))
|
||||
{
|
||||
playerSender.getInventory().addItem(plugin.sh.getClownFish());
|
||||
msg("You have been given a Clown Fish", ChatColor.GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("You do not own a Clown Fish or an admin has toggled your ability to use it. Purchase one from the shop.", ChatColor.RED);
|
||||
msg("You do not own a Clown Fish! Purchase one from the shop.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user