for setlever

This commit is contained in:
Telesphoreo 2021-06-23 16:25:54 -05:00
commit 7613ea22e7
277 changed files with 7546 additions and 4517 deletions

View file

@ -1,4 +1,4 @@
name: build
name: Maven-Build
on: [push]
@ -12,6 +12,6 @@ jobs:
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Build with Maven
run: mvn -B package --file pom.xml

2
.gitignore vendored
View file

@ -25,6 +25,7 @@ manifest.mf
/.idea/workspace.xml
/.idea/uiDesigner.xml
/.idea/libraries
/.idea/
*.iml
# Maven excludes
@ -37,3 +38,4 @@ manifest.mf
.Trashes
ehthumbs.db
Thumbs.db
.idea/inspectionProfiles/Project_Default.xml

View file

@ -1,46 +0,0 @@
<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>

View file

@ -1,5 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View file

@ -1,17 +0,0 @@
<?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>

View file

@ -1,8 +0,0 @@
<?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>

View file

@ -1,16 +0,0 @@
<?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>

View file

@ -1,124 +0,0 @@
<?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>

View file

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

13
.travis.yml Normal file
View file

@ -0,0 +1,13 @@
language: java
jdk:
- oraclejdk11
- openjdk11
notifications:
email: false
addons:
apt:
packages:
- sshpass
script: mvn clean install
after_success:
- ./travis-upload.sh

View file

@ -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).
For information about contributing to TotalFreedomMod, please see the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing).

View file

@ -1,4 +1,5 @@
# TotalFreedom General License #
# TotalFreedom General License
_Version 2.0, 27th February 2015_
Copyright (c) 2011 Steven Lawson
@ -7,7 +8,8 @@ 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.
@ -30,12 +32,13 @@ 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.
2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code.
2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code.
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission.
@ -47,8 +50,10 @@ All rights reserved.
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.

View file

@ -2,20 +2,16 @@
<!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">
@ -91,7 +87,7 @@
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<property name="format" value="(^[A-Z][a-zA-Z0-9]*$)|([A-Z][a-zA-Z0-9]*[_][a-zA-Z0-9]*$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module>
@ -112,7 +108,8 @@
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"/>

91
pom.xml
View file

@ -5,12 +5,12 @@
<groupId>me.totalfreedom</groupId>
<artifactId>TotalFreedomMod</artifactId>
<version>6.0</version>
<version>2021.05</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tfm.build.codename>Mirror</tfm.build.codename>
<tfm.build.codename>Phoenix</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/TFPatches/TotalFreedomMod</url>
<url>https://github.com/AtlasMediaGroup/TotalFreedomMod</url>
<licenses>
<license>
@ -33,9 +33,9 @@
</organization>
<scm>
<connection>scm:git:git@github.com:TotalFreedomMC/TotalFreedomMod.git</connection>
<developerConnection>scm:git:git@github.com:TotalFreedomMC/TotalFreedomMod.git</developerConnection>
<url>git@github.com:TotalFreedomMC/TotalFreedomMod.git</url>
<connection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</connection>
<developerConnection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</developerConnection>
<url>git@github.com:TFPatches/TotalFreedomMod.git</url>
</scm>
<repositories>
@ -66,18 +66,18 @@
<repository>
<id>elmakers-repo</id>
<url>http://maven.elmakers.com/repository/</url>
<url>https://maven.elmakers.com/repository/</url>
</repository>
<repository>
<id>sk89q-snapshots</id>
<url>http://maven.sk89q.com/artifactory/repo</url>
<url>https://maven.sk89q.com/artifactory/repo</url>
</repository>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases/</url>
</repository>
<repository>
@ -87,17 +87,17 @@
<repository>
<id>md_5-public</id>
<url>http://repo.md-5.net/content/groups/public/</url>
<url>https://repo.md-5.net/content/groups/public/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/nexus/repository/public/</url>
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url>
<url>https://maven.sk89q.com/repo/</url>
</repository>
<repository>
@ -114,20 +114,9 @@
<id>ess-repo</id>
<url>https://ci.ender.zone/plugin/repository/everything/</url>
</repository>
<repository>
<id>telesphoreo-repo</id>
<url>https://telesphoreo.me/repo/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
@ -151,23 +140,23 @@
</dependency>
<dependency>
<groupId>me.telesphoreo</groupId>
<artifactId>mojangson</artifactId>
<version>1.0</version>
<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>1.7</version>
<version>1.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@ -202,14 +191,14 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_168</version>
<version>4.2.1_255</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.coreprotect</groupId>
<artifactId>coreprotect</artifactId>
<version>19.1</version>
<version>19.3</version>
<scope>provided</scope>
</dependency>
@ -223,7 +212,7 @@
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.5</version>
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
@ -263,18 +252,36 @@
</dependency>
<dependency>
<groupId>com.github.TotalFreedomMC</groupId>
<groupId>com.github.AtlasMediaGroup</groupId>
<artifactId>TFGuilds</artifactId>
<version>db036fb187</version>
<version>master-SNAPSHOT</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>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>
</dependency>
</dependencies>
<build>
@ -294,9 +301,9 @@
<version>3.8.1</version>
<configuration>
<outputFileName>TotalFreedomMod.jar</outputFileName>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
<compilerVersion>11</compilerVersion>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
@ -432,7 +439,8 @@
<relocations>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib</shadedPattern> <!-- Replace this -->
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib
</shadedPattern> <!-- Replace this -->
</relocation>
<relocation>
<pattern>org.bstats</pattern>
@ -448,8 +456,9 @@
<include>org.javassist:javassist</include>
<include>me.rayzr522:jsonmessage</include>
<include>io.papermc:paperlib</include>
<include>me.telesphoreo:mojangson</include>
<include>com.github.speedxx:Mojangson</include>
<include>org.bstats:bstats-bukkit</include>
<include>org.jetbrains:annotations</include>
</includes>
</artifactSet>
</configuration>
@ -476,4 +485,4 @@
</plugin>
</plugins>
</reporting>
</project>
</project>

View file

@ -3,7 +3,6 @@ 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;
@ -13,11 +12,8 @@ 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;
@ -80,4 +76,23 @@ 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;
}
}

View file

@ -42,7 +42,6 @@ public class AntiNuke extends FreedomService
fPlayer.resetBlockDestroyCount();
event.setCancelled(true);
return;
}
}

View file

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -11,18 +10,20 @@ 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()
@ -67,31 +68,33 @@ public class AntiSpam extends FreedomService
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)
{
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.");
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE && !playerdata.isMuted())
{
count++;
muteCounts.put(player, count);
playerdata.resetMsgCount();
int time = count * minutes;
playerdata.setMuted(true, time);
event.setCancelled(true);
}
return;
FSync.bcastMsg(String.format("%s has automatically been muted for %d minutes for spamming chat.",
player.getName(),
time),
ChatColor.RED);
playerdata.resetMsgCount();
event.setCancelled(true);
}
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
{
FUtil.playerMsg(player, "Please refrain from spamming chat.", ChatColor.GRAY);
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOW)
@ -123,14 +126,4 @@ 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());
}
}
}
}

View file

@ -43,11 +43,7 @@ public class AutoEject extends FreedomService
ejects.put(ip, kicks);
if (kicks <= 1)
{
method = EjectMethod.STRIKE_ONE;
}
else if (kicks == 2)
if (kicks == 2)
{
method = EjectMethod.STRIKE_TWO;
}
@ -101,10 +97,9 @@ public class AutoEject extends FreedomService
}
}
public static enum EjectMethod
public enum EjectMethod
{
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE
}
}

View file

@ -46,9 +46,10 @@ public class AutoKick extends FreedomService
private void autoKickCheck()
{
// No type cast was provided, one has been supplied.
final boolean doAwayKickCheck
= plugin.esb.isEnabled()
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
&& (((float)server.getOnlinePlayers().size() / (float)server.getMaxPlayers()) > autoKickThreshold);
if (!doAwayKickCheck)
{

View file

@ -1,6 +1,5 @@
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;
@ -9,8 +8,11 @@ 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()
{
@ -42,16 +44,16 @@ public class BackupManager extends FreedomService
config.load();
// Weekly
if (!config.isInt(save + ".weekly"))
if (!config.isLong(save + ".weekly"))
{
performBackup(file, "weekly");
config.set(save + ".weekly", FUtil.getUnixTime());
}
else
{
int lastBackupWeekly = config.getInt(save + ".weekly");
long lastBackupWeekly = config.getLong(save + ".weekly");
if (lastBackupWeekly + 3600 * 24 * 7 < FUtil.getUnixTime())
if (FUtil.parseLongOffset(lastBackupWeekly, "1w") < FUtil.getUnixTime())
{
performBackup(file, "weekly");
config.set(save + ".weekly", FUtil.getUnixTime());
@ -65,16 +67,16 @@ public class BackupManager extends FreedomService
}
// Daily
if (!config.isInt(save + ".daily"))
if (!config.isLong(save + ".daily"))
{
performBackup(file, "daily");
config.set(save + ".daily", FUtil.getUnixTime());
}
else
{
int lastBackupDaily = config.getInt(save + ".daily");
long lastBackupDaily = config.getLong(save + ".daily");
if (lastBackupDaily + 3600 * 24 < FUtil.getUnixTime())
if (FUtil.parseLongOffset(lastBackupDaily, "1d") < FUtil.getUnixTime())
{
performBackup(file, "daily");
config.set(save + ".daily", FUtil.getUnixTime());
@ -98,5 +100,4 @@ public class BackupManager extends FreedomService
final File newYaml = new File(backupFolder, file + "." + type + ".bak");
FileUtil.copy(oldYaml, newYaml);
}
}

View file

@ -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.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -95,6 +95,21 @@ public class ChatManager extends FreedomService
return;
}
// Check for 4chan trigger
boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
{
if (green)
{
message = ChatColor.GREEN + message;
}
else if (orange)
{
message = ChatColor.GOLD + message;
}
}
// Finally, set message
event.setMessage(message);
@ -108,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.al.isAdmin(player);
for (Player p : server.getOnlinePlayers())
{
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
@ -120,10 +135,10 @@ public class ChatManager extends FreedomService
// Set format
event.setFormat(format);
// Send to Discord
// Send to discord
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
{
plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
}
}
@ -144,24 +159,20 @@ public class ChatManager extends FreedomService
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
for (Player player : server.getOnlinePlayers())
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
{
if (plugin.al.isAdmin(player))
{
Admin admin = plugin.al.getAdmin(player);
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
{
String format = admin.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));
}
Admin admin = plugin.al.getAdmin(player);
if (!Strings.isNullOrEmpty(admin.getAcFormat())) {
String format = admin.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));
}
});
}
public void reportAction(Player reporter, Player reported, String report)

View file

@ -29,6 +29,7 @@ public class CommandSpy extends FreedomService
{
continue;
}
if (player != event.getPlayer())
{
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
@ -36,5 +37,4 @@ public class CommandSpy extends FreedomService
}
}
}
}
}

View file

@ -14,8 +14,6 @@ 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,6 +22,7 @@ public class EntityWiper extends FreedomService
EntityType.ITEM_FRAME,
EntityType.MINECART
);
private BukkitTask wiper;
@Override
public void onStart()

View file

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod;
import java.util.logging.Logger;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Server;
import org.bukkit.event.Listener;
@ -8,17 +9,18 @@ public abstract class FreedomService implements Listener
{
protected final TotalFreedomMod plugin;
protected final Server server;
protected final FLog logger;
protected final Logger logger;
public FreedomService()
{
plugin = TotalFreedomMod.getPlugin();
server = plugin.getServer();
logger = new FLog();
logger = FLog.getPluginLogger();
plugin.getServer().getPluginManager().registerEvents(this, plugin);
plugin.fsh.add(this);
}
public abstract void onStart();
public abstract void onStop();
}

View file

@ -2,12 +2,10 @@ package me.totalfreedom.totalfreedommod;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
public class FreedomServiceHandler
{
@Getter
private List<FreedomService> services;
private final List<FreedomService> services;
public FreedomServiceHandler()
{
@ -53,4 +51,9 @@ public class FreedomServiceHandler
}
}
}
public List<FreedomService> getServices()
{
return services;
}
}

View file

@ -0,0 +1,680 @@
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;
}
}
}

View file

@ -56,6 +56,7 @@ public class GameRuleHandler extends FreedomService
}
}
@SuppressWarnings("deprecation")
public void commitGameRules()
{
List<World> worlds = Bukkit.getWorlds();
@ -95,7 +96,7 @@ public class GameRuleHandler extends FreedomService
private final String gameRuleName;
private final boolean defaultValue;
private GameRule(String gameRuleName, boolean defaultValue)
GameRule(String gameRuleName, boolean defaultValue)
{
this.gameRuleName = gameRuleName;
this.defaultValue = defaultValue;
@ -111,4 +112,4 @@ public class GameRuleHandler extends FreedomService
return defaultValue;
}
}
}
}

View file

@ -0,0 +1,201 @@
package me.totalfreedom.totalfreedommod;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class LogViewer extends FreedomService
{
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
{
updateLogsRegistration(sender, target.getName(), mode);
}
public void updateLogsRegistration(final CommandSender sender, final String targetName, final LogsRegistrationMode mode)
{
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
if (logsRegisterUrl == null || logsRegisterPassword == null || logsRegisterUrl.isEmpty() || logsRegisterPassword.isEmpty())
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
try
{
if (sender != null)
{
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
}
final String key = SecureCodeGenerator.generateCode(20);
final URL urlAdd = new URLBuilder(logsRegisterUrl)
.addQueryParameter("mode", mode.name())
.addQueryParameter("password", logsRegisterPassword)
.addQueryParameter("name", targetName)
.addQueryParameter("key", key)
.getURL();
final HttpURLConnection connection = (HttpURLConnection)urlAdd.openConnection();
connection.setConnectTimeout(1000 * 5);
connection.setReadTimeout(1000 * 5);
connection.setUseCaches(false);
connection.setRequestMethod("HEAD");
final int responseCode = connection.getResponseCode();
if (sender != null)
{
if (!plugin.isEnabled())
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
if (responseCode == 200)
{
if (mode == LogsRegistrationMode.ADD)
{
String link = null;
try
{
final URL urlVerify = new URLBuilder(logsRegisterUrl)
.addQueryParameter("mode", LogsRegistrationMode.VERIFY.name())
.addQueryParameter("name", targetName)
.addQueryParameter("key", key)
.getURL();
link = urlVerify.toString();
}
catch (Exception ex)
{
FLog.severe(ex);
}
sender.sendMessage(ChatColor.GREEN + "Open this link to verify your logviewer registration:\n" + ChatColor.DARK_GREEN + link);
}
else
{
sender.sendMessage(ChatColor.GREEN + "Logviewer access revoked successfully.");
}
}
else
{
sender.sendMessage(ChatColor.RED + "Error contacting logs registration server.");
}
}
}.runTask(plugin);
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
}.runTaskAsynchronously(plugin);
}
public enum LogsRegistrationMode
{
ADD, DELETE, VERIFY
}
private static class URLBuilder
{
private final String requestPath;
private final Map<String, String> queryStringMap = new HashMap<>();
private URLBuilder(String requestPath)
{
this.requestPath = requestPath;
}
public URLBuilder addQueryParameter(String key, String value)
{
queryStringMap.put(key, value);
return this;
}
public URL getURL() throws MalformedURLException
{
List<String> pairs = new ArrayList<>();
for (Map.Entry<String, String> pair : queryStringMap.entrySet())
{
try
{
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));
}
catch (UnsupportedEncodingException ex)
{
FLog.severe(ex);
}
}
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
}
}
private static class SecureCodeGenerator
{
private static final String CHARACTER_SET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
public static String generateCode(final int length)
{
SecureRandom random;
try
{
random = SecureRandom.getInstance("SHA1PRNG", "SUN");
}
catch (NoSuchAlgorithmException | NoSuchProviderException ex)
{
random = new SecureRandom();
FLog.severe(ex);
}
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++)
{
sb.append(CHARACTER_SET.charAt(random.nextInt(CHARACTER_SET.length())));
}
return sb.toString();
}
}
}

View file

@ -4,8 +4,6 @@ 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;
@ -29,12 +27,20 @@ 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<>();
@Getter
@Setter
private static boolean lockdownEnabled = false;
public static boolean isLockdownEnabled()
{
return lockdownEnabled;
}
public static void setLockdownEnabled(boolean lockdownEnabled)
{
LoginProcess.lockdownEnabled = lockdownEnabled;
}
@Override
public void onStart()
@ -113,11 +119,8 @@ public class LoginProcess extends FreedomService
}
}
// Check if player is admin
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
// Validation below this point
if (isAdmin) // Player is admin
if (plugin.al.getEntryByIp(ip) != null) // Check if player is admin
{
// Force-allow log in
event.allow();
@ -177,7 +180,6 @@ 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;
}
}
}
@ -237,18 +239,10 @@ public class LoginProcess extends FreedomService
int noteCount = playerData.getNotes().size();
if (noteCount != 0)
{
String noteMessage = "This player has " + noteCount + " 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");
String noteMessage = "This player has " + noteCount + " admin note" + (noteCount > 1 ? "s" : "") + ".";
FLog.info(noteMessage);
for (Player p : server.getOnlinePlayers())
{
if (plugin.al.isAdminImpostor(p))
{
notice.send(p);
}
}
plugin.al.messageAllAdmins(ChatColor.GOLD + noteMessage);
plugin.al.messageAllAdmins(ChatColor.GOLD + "Do " + ChatColor.YELLOW + "/notes " + player.getName() + " list" + ChatColor.GOLD + " to view them.");
}
}
@ -264,7 +258,7 @@ public class LoginProcess extends FreedomService
if (lockdownEnabled)
{
FUtil.playerMsg(player, "Warning: Server is currently in lockdown-mode, new players will not be able to join!", ChatColor.RED);
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
}
}
}.runTaskLater(plugin, 20L);

View file

@ -6,7 +6,6 @@ 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;
@ -20,7 +19,6 @@ 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,
@ -48,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.",
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") : "")));
latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : "")));
}
recentlyThrownPotions.clear();
}, 0L, 40L);
@ -141,4 +139,19 @@ 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;
}
}

View file

@ -40,7 +40,7 @@ public class MovementValidator extends FreedomService
public void onPlayerTeleport(PlayerTeleportEvent event)
{
// Check absolute value to account for negatives
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)
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)
{
event.setCancelled(true); // illegal position, cancel it
}
@ -52,6 +52,7 @@ 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);
@ -145,8 +146,9 @@ 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"))
{
@ -181,6 +183,4 @@ public class MovementValidator extends FreedomService
}
return stack.getTag().getList("AttributeModifiers", 10);
}
}
}

View file

@ -1,13 +1,11 @@
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;
@ -20,7 +18,6 @@ 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
@ -88,7 +85,7 @@ public class Muter extends FreedomService
cmdName = command.getName().toLowerCase();
}
if (MUTE_COMMANDS.contains(cmdName))
if (ConfigEntry.MUTED_BLOCKED_COMMANDS.getStringList().contains(cmdName))
{
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
event.setCancelled(true);
@ -113,6 +110,4 @@ public class Muter extends FreedomService
playerdata.setMuted(true);
}
}
}
}

View file

@ -4,10 +4,9 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import joptsimple.internal.Strings;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Response;
@ -23,7 +22,6 @@ public class Pterodactyl extends FreedomService
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()
@ -50,10 +48,11 @@ public class Pterodactyl extends FreedomService
return;
}
FLog.debug("Enabling aptero acc");
FLog.debug("Enabling ptero acc");
addAccountToServer(id);
}
@SuppressWarnings("unchecked")
public String createAccount(String username, String password)
{
JSONObject json = new JSONObject();
@ -94,6 +93,7 @@ public class Pterodactyl extends FreedomService
}
}
@SuppressWarnings("unchecked")
public void addAccountToServer(String id)
{
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users";
@ -161,6 +161,7 @@ public class Pterodactyl extends FreedomService
}
// API patch function on users doesnt work rn, it throws 500 errors, so it's probably not written yet
@SuppressWarnings("unchecked")
public void setPassword(String id, String password)
{
JSONObject json = new JSONObject();
@ -175,4 +176,39 @@ public class Pterodactyl extends FreedomService
FLog.severe(e);
}
}
}
public String getURL()
{
return URL;
}
public String getServerKey()
{
return SERVER_KEY;
}
public String getAdminKey()
{
return ADMIN_KEY;
}
public List<String> getServerHeaders()
{
return SERVER_HEADERS;
}
public List<String> getAdminHeaders()
{
return ADMIN_HEADERS;
}
public boolean isEnabled()
{
return enabled;
}
public void setEnabled(boolean enabled)
{
this.enabled = enabled;
}
}

View file

@ -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

View file

@ -13,16 +13,6 @@ public class ServerInterface extends FreedomService
{
public static final String COMPILE_NMS_VERSION = "v1_16_R3";
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
public static void warnVersion()
{
final String nms = FUtil.getNMSVersion();
@ -34,6 +24,16 @@ public class ServerInterface extends FreedomService
}
}
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
public void setOnlineMode(boolean mode)
{
getServer().setOnlineMode(mode);

View file

@ -30,7 +30,7 @@ public class ServerPing extends FreedomService
return;
}
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
return;
@ -73,5 +73,4 @@ public class ServerPing extends FreedomService
event.setMotd(motd.toString().trim());
}
}
}

View file

@ -3,6 +3,8 @@ 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;
@ -28,6 +30,8 @@ import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.freeze.Freezer;
import me.totalfreedom.totalfreedommod.fun.ItemFun;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.fun.Landminer;
import me.totalfreedom.totalfreedommod.fun.MP44;
import me.totalfreedom.totalfreedommod.fun.Trailer;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
@ -38,8 +42,6 @@ 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.admin.ActivityLog;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.MethodTimer;
@ -51,23 +53,18 @@ 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;
@ -80,6 +77,7 @@ public class TotalFreedomMod extends JavaPlugin
public ServerInterface si;
public SavedFlags sf;
public WorldManager wm;
public LogViewer lv;
public AdminList al;
public ActivityLog acl;
public RankManager rm;
@ -118,15 +116,18 @@ public class TotalFreedomMod extends JavaPlugin
public MovementValidator mv;
public ServerPing sp;
public ItemFun it;
public Landminer lm;
public MP44 mp;
public Jumppads jp;
public Trailer tr;
public HTTPDaemon hd;
public WorldRestrictions wr;
public SignBlocker snp;
public EntityWiper ew;
public Sitter st;
public VanishHandler vh;
public Pterodactyl ptero;
//
// Bridges
public BukkitTelnetBridge btb;
public EssentialsBridge esb;
@ -136,6 +137,23 @@ public class TotalFreedomMod extends JavaPlugin
public WorldEditBridge web;
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()
{
@ -182,74 +200,13 @@ public class TotalFreedomMod extends JavaPlugin
BackupManager backups = new BackupManager();
backups.createAllBackups();
permissions = new PermissionConfig(this);
permissions = new PermissionConfig();
permissions.load();
// Start services
si = new ServerInterface();
sf = new SavedFlags();
wm = new WorldManager();
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();
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();
// Fun
it = new ItemFun();
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();
wgb = new WorldGuardBridge();
new Initializer();
fsh.startServices();
@ -276,6 +233,12 @@ 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;
@ -318,21 +281,101 @@ public class TotalFreedomMod extends JavaPlugin
}
}
public static TotalFreedomMod plugin()
/**
* This class is provided to please Codacy.
*/
private final class Initializer
{
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
public Initializer()
{
if (plugin.getName().equalsIgnoreCase(pluginName))
{
return (TotalFreedomMod)plugin;
}
initServices();
initAdminUtils();
initBridges();
initFun();
initHTTPD();
}
return null;
}
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
{
return new CleanroomChunkGenerator(id);
private void initServices()
{
// 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();
}
}
}

View file

@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Maps;
import java.util.Map;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.YamlConfig;
import me.totalfreedom.totalfreedommod.util.FLog;
@ -19,7 +18,6 @@ public class ActivityLog extends FreedomService
{
public static final String FILENAME = "activitylog.yml";
@Getter
private final Map<String, ActivityLogEntry> allActivityLogs = Maps.newHashMap();
private final Map<String, ActivityLogEntry> nameTable = Maps.newHashMap();
private final Map<String, ActivityLogEntry> ipTable = Maps.newHashMap();
@ -31,6 +29,11 @@ public class ActivityLog extends FreedomService
this.config = new YamlConfig(plugin, FILENAME, true);
}
public static String getFILENAME()
{
return FILENAME;
}
@Override
public void onStart()
{
@ -55,7 +58,7 @@ public class ActivityLog extends FreedomService
ConfigurationSection section = config.getConfigurationSection(key);
if (section == null)
{
logger.warning("Invalid activity log format: " + key);
FLog.warning("Invalid activity log format: " + key);
continue;
}
@ -110,10 +113,10 @@ public class ActivityLog extends FreedomService
activityLog = getEntryByIp(ip);
if (activityLog != null)
{
// Set the new username
activityLog.setName(player.getName());
save();
updateTables();
// Set the new username
activityLog.setName(player.getName());
save();
updateTables();
}
else
{
@ -185,4 +188,24 @@ public class ActivityLog extends FreedomService
plugin.acl.updateTables();
}
}
}
public Map<String, ActivityLogEntry> getAllActivityLogs()
{
return allActivityLogs;
}
public Map<String, ActivityLogEntry> getNameTable()
{
return nameTable;
}
public Map<String, ActivityLogEntry> getIpTable()
{
return ipTable;
}
public YamlConfig getConfig()
{
return config;
}
}

View file

@ -4,8 +4,6 @@ import com.google.common.collect.Lists;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.config.IConfig;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.Validate;
@ -14,21 +12,13 @@ import org.bukkit.entity.Player;
public class ActivityLogEntry implements IConfig
{
@Getter
private String configKey;
@Getter
@Setter
private String name;
@Getter
private final List<String> ips = Lists.newArrayList();
@Getter
@Setter
private List<String> timestamps = Lists.newArrayList();
@Getter
@Setter
private List<String> durations = Lists.newArrayList();
public static final String FILENAME = "activitylog.yml";
private final List<String> ips = Lists.newArrayList();
private final List<String> timestamps = Lists.newArrayList();
private final List<String> durations = Lists.newArrayList();
private String configKey;
private String name;
public ActivityLogEntry(Player player)
{
@ -41,6 +31,11 @@ public class ActivityLogEntry implements IConfig
this.configKey = configKey;
}
public static String getFILENAME()
{
return FILENAME;
}
public void loadFrom(Player player)
{
configKey = player.getName().toLowerCase();
@ -77,7 +72,15 @@ public class ActivityLogEntry implements IConfig
public void addLogout()
{
String lastLoginString = timestamps.get(timestamps.size() - 1); // there's a bug with subtracting the -1 here
// Fix of Array index out of bonds issue: FS-131
String lastLoginString;
if(timestamps.size() > 1)
{
lastLoginString = timestamps.get(timestamps.size() - 1);
}else
{
lastLoginString = timestamps.get(0);
}
Date currentTime = Date.from(Instant.now());
timestamps.add("Logout: " + FUtil.dateToString(currentTime));
lastLoginString = lastLoginString.replace("Login: ", "");
@ -108,10 +111,7 @@ public class ActivityLogEntry implements IConfig
public void removeIp(String ip)
{
if (ips.contains(ip))
{
ips.remove(ip);
}
ips.remove(ip);
}
public void clearIPs()
@ -138,4 +138,39 @@ public class ActivityLogEntry implements IConfig
return configKey != null
&& name != null;
}
public String getConfigKey()
{
return configKey;
}
public void setConfigKey(String configKey)
{
this.configKey = configKey;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public List<String> getIps()
{
return ips;
}
public List<String> getTimestamps()
{
return timestamps;
}
public List<String> getDurations()
{
return durations;
}
}

View file

@ -7,41 +7,27 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class Admin
{
@Getter
@Setter
private String name;
@Getter
private boolean active = true;
@Getter
@Setter
private Rank rank = Rank.ADMIN;
@Getter
private final List<String> ips = new ArrayList<>();
@Getter
@Setter
private String name;
private boolean active = true;
private Rank rank = Rank.ADMIN;
private Date lastLogin = new Date();
@Getter
@Setter
private Boolean commandSpy = false;
@Getter
@Setter
private Boolean potionSpy = false;
@Getter
@Setter
private String acFormat = null;
@Getter
@Setter
private String pteroID = null;
public Admin(Player player)
@ -124,10 +110,7 @@ public class Admin
public void removeIp(String ip)
{
if (ips.contains(ip))
{
ips.remove(ip);
}
ips.remove(ip);
}
public void clearIPs()
@ -135,11 +118,41 @@ public class Admin
ips.clear();
}
public boolean isValid()
{
return name != null
&& rank != null
&& !ips.isEmpty()
&& lastLogin != null;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public boolean isActive()
{
return active;
}
public void setActive(boolean active)
{
this.active = active;
final TotalFreedomMod plugin = TotalFreedomMod.plugin();
final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
// Avoiding stupid NPE compiler warnings
if (plugin == null)
{
Bukkit.getLogger().severe("The plugin is null!! This is a major issue and WILL break the plugin!");
return;
}
if (!active)
{
@ -150,14 +163,73 @@ public class Admin
plugin.btb.killTelnetSessions(getName());
}
}
plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
}
}
public boolean isValid()
public Rank getRank()
{
return name != null
&& rank != null
&& !ips.isEmpty()
&& lastLogin != null;
return rank;
}
public void setRank(Rank rank)
{
this.rank = rank;
}
public List<String> getIps()
{
return ips;
}
public Date getLastLogin()
{
return lastLogin;
}
public void setLastLogin(Date lastLogin)
{
this.lastLogin = lastLogin;
}
public Boolean getCommandSpy()
{
return commandSpy;
}
public void setCommandSpy(Boolean commandSpy)
{
this.commandSpy = commandSpy;
}
public Boolean getPotionSpy()
{
return potionSpy;
}
public void setPotionSpy(Boolean potionSpy)
{
this.potionSpy = potionSpy;
}
public String getAcFormat()
{
return acFormat;
}
public void setAcFormat(String acFormat)
{
this.acFormat = acFormat;
}
public String getPteroID()
{
return pteroID;
}
public void setPteroID(String pteroID)
{
this.pteroID = pteroID;
}
}

View file

@ -10,7 +10,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
@ -22,16 +21,18 @@ import org.bukkit.entity.Player;
public class AdminList extends FreedomService
{
@Getter
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
@Getter
private final Set<Admin> activeAdmins = Sets.newHashSet();
private final Map<String, Admin> nameTable = Maps.newHashMap();
private final Map<String, Admin> ipTable = Maps.newHashMap();
public final List<String> verifiedNoAdmin = new ArrayList<>();
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
public static final List<String> vanished = new ArrayList<>();
public static List<String> getVanished()
{
return vanished;
}
@Override
public void onStart()
@ -50,7 +51,7 @@ public class AdminList extends FreedomService
allAdmins.clear();
try
{
ResultSet adminSet = plugin.sql.getAdminlist();
ResultSet adminSet = plugin.sql.getAdminList();
{
while (adminSet.next())
{
@ -65,7 +66,7 @@ public class AdminList extends FreedomService
}
updateTables();
FLog.info("Loaded " + allAdmins.size() + " admin members (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
}
public void messageAllAdmins(String message)
@ -238,7 +239,7 @@ public class AdminList extends FreedomService
public boolean isVerifiedAdmin(Player player)
{
return verifiedNoAdmin.contains(player.getName()) && verifiedNoAdminIps.get(player.getName()).contains(FUtil.getIp(player));
return verifiedNoAdmin.containsKey(player.getName()) && verifiedNoAdmin.get(player.getName()).contains(FUtil.getIp(player));
}
public boolean isIdentityMatched(Player player)
@ -252,12 +253,12 @@ public class AdminList extends FreedomService
return admin != null && admin.getName().equalsIgnoreCase(player.getName());
}
public void addAdmin(Admin admin)
public boolean addAdmin(Admin admin)
{
if (!admin.isValid())
{
FLog.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
return;
return false;
}
// Store admin, update views
@ -266,6 +267,8 @@ public class AdminList extends FreedomService
// Save admin
plugin.sql.addAdmin(admin);
return true;
}
public boolean removeAdmin(Admin admin)
@ -378,4 +381,29 @@ public class AdminList extends FreedomService
{
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;
}
}

View file

@ -4,15 +4,12 @@ import com.google.common.collect.Lists;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
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;
@ -22,27 +19,19 @@ import org.bukkit.entity.Player;
public class Ban
{
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
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
private final List<String> ips = Lists.newArrayList();
@Getter
@Setter
private String username = null;
private UUID uuid = null;
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()
@ -53,7 +42,7 @@ public class Ban
{
this(username,
uuid,
Arrays.asList(ip),
Collections.singletonList(ip),
by,
at,
expire,
@ -88,7 +77,7 @@ public class Ban
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
{
return new Ban(null, null, Arrays.asList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
return new Ban(null, null, Collections.singletonList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
}
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
@ -143,6 +132,11 @@ public class Ban
reason);
}
public static SimpleDateFormat getDateFormat()
{
return DATE_FORMAT;
}
public boolean hasUsername()
{
return username != null && !username.isEmpty();
@ -175,7 +169,7 @@ public class Ban
public boolean isExpired()
{
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
return hasExpiry() && FUtil.getUnixDate(expiryUnix).before(new Date(FUtil.getUnixTime()));
}
public String bakeKickMessage()
@ -256,17 +250,74 @@ public class Ban
private void dedupeIps()
{
Set<String> uniqueIps = new HashSet<>();
Iterator<String> it = ips.iterator();
while (it.hasNext())
{
if (!uniqueIps.add(it.next()))
{
it.remove();
}
}
//Fancy Collections.removeIf lets you do all that while loop work in one lambda.
ips.removeIf(s -> !uniqueIps.add(s));
}
}
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;
}
}

View file

@ -15,7 +15,6 @@ 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;
@ -74,7 +73,7 @@ public class BanManager extends FreedomService
// Load unbannable usernames
unbannableUsernames.clear();
unbannableUsernames.addAll((Collection<? extends String>)ConfigEntry.FAMOUS_PLAYERS.getList());
unbannableUsernames.addAll(ConfigEntry.FAMOUS_PLAYERS.getStringList());
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
}
@ -190,7 +189,7 @@ public class BanManager extends FreedomService
return getByUsername(username) != null;
}
public boolean addBan(Ban ban)
public void addBan(Ban ban)
{
if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
{
@ -213,22 +212,18 @@ public class BanManager extends FreedomService
{
plugin.sql.addBan(ban);
updateViews();
return true;
}
return false;
}
public boolean removeBan(Ban ban)
public void removeBan(Ban ban)
{
if (bans.remove(ban))
{
plugin.sql.removeBan(ban);
updateViews();
return true;
}
return false;
}
public int purge()
@ -269,7 +264,6 @@ 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))
{
@ -328,5 +322,4 @@ public class BanManager extends FreedomService
}
}
}
}
}

View file

@ -3,25 +3,15 @@ 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
{
@Getter
@Setter
private String username = null;
@Getter
@Setter
private UUID uuid = null;
@Getter
private final List<String> ips = Lists.newArrayList();
@Getter
@Setter
private String username = null;
private UUID uuid = null;
private String reason = null;
public IndefiniteBan()
@ -60,4 +50,39 @@ 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;
}
}

View file

@ -4,7 +4,6 @@ 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;
@ -21,18 +20,23 @@ 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()
{
@ -51,6 +55,7 @@ public class IndefiniteBanList extends FreedomService
IndefiniteBan indefBan = new IndefiniteBan();
ConfigurationSection cs = config.getConfigurationSection(name);
assert cs != null;
indefBan.loadFrom(cs);
if (!indefBan.isValid())
@ -84,7 +89,7 @@ public class IndefiniteBanList extends FreedomService
for (IndefiniteBan indefBan : indefBans)
{
if (username.toLowerCase().equals(indefBan.getUsername().toLowerCase()))
if (username.equalsIgnoreCase(indefBan.getUsername()))
{
bannedBy = "username";
ban = indefBan;
@ -137,4 +142,24 @@ 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;
}
}

View file

@ -29,6 +29,7 @@ public class BlockBlocker extends FreedomService
{
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event)
{
@ -132,17 +133,18 @@ 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);
@ -173,8 +175,9 @@ public class BlockBlocker extends FreedomService
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));
@ -182,4 +185,4 @@ public class BlockBlocker extends FreedomService
}
}
}
}
}

View file

@ -58,5 +58,4 @@ public class EditBlocker extends FreedomService
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
event.setCancelled(true);
}
}
}

View file

@ -3,6 +3,7 @@ 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;
@ -13,6 +14,7 @@ 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;
@ -24,12 +26,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;
@ -38,6 +40,20 @@ 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()
{
@ -120,16 +136,11 @@ public class EventBlocker extends FreedomService
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event)
{
switch (event.getCause())
if ((event.getCause() == EntityDamageEvent.DamageCause.LAVA)
&& !ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{
case LAVA:
{
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{
event.setCancelled(true);
return;
}
}
event.setCancelled(true);
return;
}
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
@ -148,6 +159,11 @@ public class EventBlocker extends FreedomService
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (!plugin.al.isAdmin(event.getPlayer()))
{
event.setCancelled(true);
}
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
return;
@ -198,18 +214,15 @@ public class EventBlocker extends FreedomService
}
}
//@EventHandler(priority = EventPriority.HIGH)
public void onBlockRedstone(BlockRedstoneEvent event)
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event)
{
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
if (!ConfigEntry.ALLOW_GRAVITY.getBoolean() && event.getEntity() instanceof FallingBlock)
{
event.setNewCurrent(0);
event.setCancelled(true);
}
}
// 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));
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event)
{
@ -226,12 +239,12 @@ public class EventBlocker extends FreedomService
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerRespawn(PlayerRespawnEvent event)
{
double maxHealth = event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
double maxHealth = Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue();
if (maxHealth < 1)
{
for (AttributeModifier attributeModifier : event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getModifiers())
for (AttributeModifier attributeModifier : Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getModifiers())
{
event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).removeModifier(attributeModifier);
Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).removeModifier(attributeModifier);
}
}
}

View file

@ -126,7 +126,7 @@ public class InteractBlocker extends FreedomService
event.setCancelled(true);
break;
}
case ARMOR_STAND:
{
if (ConfigEntry.ALLOW_ARMOR_STANDS.getBoolean())
@ -160,4 +160,4 @@ public class InteractBlocker extends FreedomService
}
}
}
}
}

View file

@ -1,5 +1,6 @@
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;
@ -42,13 +43,13 @@ public class MobBlocker extends FreedomService
Entity entity = e.getEntity();
if (entity instanceof Attributable)
{
if (((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).getBaseValue() > 255.0)
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0)
{
((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(255.0);
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0);
}
if (((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() > 10.0)
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0)
{
((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(10.0);
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0);
}
}
}
@ -117,7 +118,7 @@ public class MobBlocker extends FreedomService
}
int mobcount = 0;
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
for (Entity entity : Objects.requireNonNull(event.getLocation().getWorld()).getLivingEntities())
{
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
{
@ -130,4 +131,4 @@ public class MobBlocker extends FreedomService
event.setCancelled(true);
}
}
}
}

View file

@ -82,5 +82,4 @@ public class PotionBlocker extends FreedomService
}
return false;
}
}
}

View file

@ -37,6 +37,7 @@ public class SignBlocker extends FreedomService
ItemStack sign = event.getItemInHand();
net.minecraft.server.v1_16_R3.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");
@ -63,4 +64,4 @@ public class SignBlocker extends FreedomService
event.setCancelled(true);
}
}
}
}

View file

@ -29,6 +29,24 @@ 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()
{
@ -41,25 +59,6 @@ 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 +82,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 == null || commandName.isEmpty())
if (rank == null || action == null || commandName.isEmpty())
{
FLog.warning("Invalid command blocker entry: " + rawEntry);
continue;
@ -97,6 +96,7 @@ 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

View file

@ -7,16 +7,11 @@ public enum CommandBlockerAction
BLOCK_UNKNOWN("u");
private final String token;
private CommandBlockerAction(String token)
CommandBlockerAction(String token)
{
this.token = token;
}
public String getToken()
{
return this.token;
}
public static CommandBlockerAction fromToken(String token)
{
for (CommandBlockerAction action : CommandBlockerAction.values())
@ -28,4 +23,9 @@ public enum CommandBlockerAction
}
return null;
}
}
public String getToken()
{
return this.token;
}
}

View file

@ -1,6 +1,5 @@
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 +9,16 @@ 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 +39,7 @@ public class CommandBlockerEntry
{
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
TotalFreedomMod.getPlugin().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,4 +50,29 @@ 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;
}
}

View file

@ -1,13 +1,13 @@
package me.totalfreedom.totalfreedommod.blocking.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.CommandSender;
public enum CommandBlockerRank
{
ANYONE("a"),
EVERYONE("e"),
OP("o"),
ADMIN("a"),
SENIOR_ADMIN("s"),
@ -15,24 +15,14 @@ public enum CommandBlockerRank
//
private final String token;
private CommandBlockerRank(String token)
CommandBlockerRank(String token)
{
this.token = token;
}
public String getToken()
{
return this.token;
}
public boolean hasPermission(CommandSender sender)
{
return fromSender(sender).ordinal() >= ordinal();
}
public static CommandBlockerRank fromSender(CommandSender sender)
{
Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender);
if (admin != null)
{
if (admin.getRank() == Rank.SENIOR_ADMIN)
@ -47,8 +37,7 @@ public enum CommandBlockerRank
return OP;
}
return ANYONE;
return EVERYONE;
}
public static CommandBlockerRank fromToken(String token)
@ -60,6 +49,16 @@ public enum CommandBlockerRank
return rank;
}
}
return ANYONE;
return EVERYONE;
}
}
public String getToken()
{
return this.token;
}
public boolean hasPermission(CommandSender sender)
{
return fromSender(sender).ordinal() >= ordinal();
}
}

View file

@ -1,7 +1,6 @@
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;
@ -10,8 +9,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.rank.Rank;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -66,10 +65,8 @@ public class BukkitTelnetBridge extends FreedomService
@EventHandler(priority = EventPriority.NORMAL)
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
{
final Iterator<Map.Entry<Player, Map<String, Object>>> it = event.getDataTags().entrySet().iterator();
while (it.hasNext())
for (Map.Entry<Player, Map<String, Object>> entry : event.getDataTags().entrySet())
{
final Map.Entry<Player, Map<String, Object>> entry = it.next();
final Player player = entry.getKey();
final Map<String, Object> playerTags = entry.getValue();
@ -177,4 +174,4 @@ public class BukkitTelnetBridge extends FreedomService
FLog.severe("Error removing telnet sessions: " + ex.getMessage());
}
}
}
}

View file

@ -1,33 +1,78 @@
package me.totalfreedom.totalfreedommod.bridge;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import java.text.DecimalFormat;
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
{
private CoreProtectAPI coreProtectAPI = null;
public static Map<Player, FUtil.PaginationList<String>> HISTORY_MAP = new HashMap<>();
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()
{
@ -44,8 +89,8 @@ public class CoreProtectBridge extends FreedomService
try
{
final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
if (coreProtectPlugin != null && coreProtectPlugin instanceof CoreProtect)
assert coreProtectPlugin != null;
if (coreProtectPlugin instanceof CoreProtect)
{
coreProtect = (CoreProtect)coreProtectPlugin;
}
@ -169,7 +214,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 = null;
Connection connection;
try
{
String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString();
@ -179,11 +224,12 @@ 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 Statement statement = connection.createStatement();
final PreparedStatement statement = connection.prepareStatement("SELECT id FROM co_world WHERE world = ?");
statement.setQueryTimeout(30);
// Obtain world ID from CoreProtect database
ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'");
statement.setString(1, world.getName());
ResultSet resultSet = statement.executeQuery();
String worldID = null;
while (resultSet.next())
{
@ -201,7 +247,10 @@ public class CoreProtectBridge extends FreedomService
// Iterate through each table and delete their data if the world ID matches
for (String table : tables)
{
statement.executeQuery("DELETE FROM " + table + " WHERE wid = " + worldID);
final PreparedStatement statement1 = connection.prepareStatement("DELETE FROM ? WHERE wid = ?");
statement1.setString(1, table);
statement1.setString(2, worldID);
statement1.executeQuery();
}
connection.close();
@ -218,4 +267,191 @@ 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>");
}
}
}
}
}
}
}

View file

@ -42,7 +42,8 @@ public class EssentialsBridge extends FreedomService
try
{
final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
if (essentials != null && essentials instanceof Essentials)
assert essentials != null;
if (essentials instanceof Essentials)
{
essentialsPlugin = (Essentials)essentials;
}
@ -113,7 +114,8 @@ public class EssentialsBridge extends FreedomService
User user = getEssentialsUser(username);
if (user != null)
{
return FUtil.getField(user, "lastActivity");
Long l = FUtil.getField(user, "lastActivity");
return (l != null) ? l : 0L;
}
}
catch (Exception ex)
@ -150,7 +152,7 @@ public class EssentialsBridge extends FreedomService
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
{
final InventoryHolder inventoryHolder = inventory.getHolder();
if (inventoryHolder != null && inventoryHolder instanceof HumanEntity)
if (inventoryHolder instanceof HumanEntity)
{
Player invOwner = (Player)inventoryHolder;
Rank recieverRank = plugin.rm.getRank(player);
@ -203,6 +205,7 @@ public class EssentialsBridge extends FreedomService
}
}
// TODO: Actually use this for something or remove it.
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event)
{
@ -215,4 +218,4 @@ public class EssentialsBridge extends FreedomService
return ess != null && ess.isEnabled();
}
}
}

View file

@ -46,7 +46,7 @@ public class LibsDisguisesBridge extends FreedomService
return libsDisguisesPlugin;
}
public void undisguiseAll(boolean admins)
public void undisguiseAll(boolean admin)
{
try
{
@ -61,7 +61,7 @@ public class LibsDisguisesBridge extends FreedomService
{
if (DisguiseAPI.isDisguised(player))
{
if (!admins && plugin.al.isAdmin(player))
if (!admin && plugin.al.isAdmin(player))
{
continue;
}
@ -75,6 +75,11 @@ public class LibsDisguisesBridge extends FreedomService
}
}
public boolean isDisguisesEnabled()
{
return !BlockedDisguises.disabled;
}
public void setDisguisesEnabled(boolean state)
{
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
@ -87,11 +92,6 @@ public class LibsDisguisesBridge extends FreedomService
BlockedDisguises.disabled = !state;
}
public boolean isDisguisesEnabled()
{
return !BlockedDisguises.disabled;
}
public boolean isEnabled()
{
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();

View file

@ -53,6 +53,6 @@ public class TFGuildsBridge extends FreedomService
{
return false;
}
return Common.IN_GUILD_CHAT.contains(player);
return Common.GUILD_CHAT.contains(player);
}
}
}

View file

@ -60,8 +60,7 @@ public class WorldEditBridge extends FreedomService
{
for (int i = 0; i < count; i++)
{
com.sk89q.worldedit.entity.Player fuckyou = bukkitPlayer;
session.undo(session.getBlockBag(fuckyou), fuckyou);
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
}
}
}
@ -84,8 +83,7 @@ public class WorldEditBridge extends FreedomService
{
for (int i = 0; i < count; i++)
{
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
session.redo(session.getBlockBag(fuckyou), fuckyou);
session.redo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
}
}
}

View file

@ -15,7 +15,6 @@ public class WorldGuardBridge extends FreedomService
@Override
public void onStart()
{
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
}

View file

@ -2,7 +2,6 @@ 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;
@ -12,141 +11,21 @@ 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 final List<BlockData> cageHistory = new ArrayList<>();
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)
{
@ -167,6 +46,7 @@ public class CageData
}
}
@SuppressWarnings("deprecation")
public static void generateHollowCube(Location location, int length, Material material)
{
final Block center = location.getBlock();
@ -213,7 +93,7 @@ public class CageData
skull.setOwner(input);
skull.update();
}
catch (ClassCastException e)
catch (ClassCastException ignored)
{
}
}
@ -223,6 +103,176 @@ 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
{

View file

@ -1,6 +1,7 @@
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;
@ -31,8 +32,7 @@ public class Cager extends FreedomService
public void onBreakBlock(BlockBreakEvent event)
{
Player player = event.getPlayer();
if (player == null
|| plugin.al.isAdmin(player))
if (plugin.al.isAdmin(player))
{
return;
}
@ -61,7 +61,7 @@ public class Cager extends FreedomService
Location cageLoc = cage.getLocation();
final boolean outOfCage;
if (!playerLoc.getWorld().equals(cageLoc.getWorld()))
if (!Objects.equals(playerLoc.getWorld(), cageLoc.getWorld()))
{
outOfCage = true;
}
@ -113,5 +113,4 @@ public class Cager extends FreedomService
cage.playerJoin();
}
}
}
}

View file

@ -4,14 +4,12 @@ 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()
@ -40,7 +38,9 @@ public class CommandLoader extends FreedomService
for (FreedomCommand command : commands)
{
if (name.equals(command.getName()))
{
return command;
}
}
return null;
}
@ -50,7 +50,9 @@ public class CommandLoader extends FreedomService
for (FreedomCommand command : commands)
{
if (Arrays.asList(command.getAliases().split(",")).contains(alias))
{
return true;
}
}
return false;
}
@ -69,10 +71,15 @@ 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;
}
}

View file

@ -8,9 +8,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Talk privately with other admins on the server.", usage = "/<command> [message]", aliases = "o,sc")
@CommandParameters(description = "Talk privately with other admins on the server.", usage = "/<command> [message]", aliases = "o,sc,ac,staffchat")
public class Command_adminchat extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -24,7 +25,7 @@ public class Command_adminchat extends FreedomCommand
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
userinfo.setAdminChat(!userinfo.inAdminChat());
msg("Toggled your admin chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
msg("Admin chat turned " + (userinfo.inAdminChat() ? "on" : "off") + ".");
}
else
{
@ -32,4 +33,4 @@ public class Command_adminchat extends FreedomCommand
}
return true;
}
}
}

View file

@ -11,9 +11,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "ai")
@CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "si,ai,staffinfo")
public class Command_admininfo extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -21,7 +22,7 @@ public class Command_admininfo extends FreedomCommand
if (adminInfo.isEmpty())
{
msg("The admin information section in the config.yml file has not been configured.", ChatColor.RED);
msg("The admin information section of the config.yml file has not been configured.", ChatColor.RED);
}
else
{
@ -29,4 +30,4 @@ public class Command_admininfo extends FreedomCommand
}
return true;
}
}
}

View file

@ -11,9 +11,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]")
@CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]", aliases = "staffmode")
public class Command_adminmode extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -25,13 +26,13 @@ public class Command_adminmode extends FreedomCommand
if (args[0].equalsIgnoreCase("off"))
{
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
FUtil.adminAction(sender.getName(), "Opening the server to all players.", true);
FUtil.adminAction(sender.getName(), "Opening the server to all players", true);
return true;
}
else if (args[0].equalsIgnoreCase("on"))
{
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
FUtil.adminAction(sender.getName(), "Closing the server to non-admins.", true);
FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);
for (Player player : server.getOnlinePlayers())
{
if (!isAdmin(player))
@ -55,4 +56,4 @@ public class Command_adminmode extends FreedomCommand
return Collections.emptyList();
}
}
}

View file

@ -15,13 +15,9 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Allows for admins to configure time, and weather of the AdminWorld, and allows for admins and ops to go to the AdminWorld.",
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
aliases = "aw")
aliases = "sw,aw,staffworld")
public class Command_adminworld extends FreedomCommand
{
private enum CommandMode
{
TELEPORT, TIME, WEATHER
}
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
@ -65,7 +61,7 @@ public class Command_adminworld extends FreedomCommand
{
adminWorld = plugin.wm.adminworld.getWorld();
}
catch (Exception ex)
catch (Exception ignored)
{
}
@ -141,7 +137,7 @@ public class Command_adminworld extends FreedomCommand
{
return noPerms();
}
sender.sendMessage(ex.getMessage());
msg(ex.getMessage());
return true;
}
@ -157,22 +153,6 @@ public class Command_adminworld extends FreedomCommand
}
}
private class PermissionDeniedException extends Exception
{
private static final long serialVersionUID = 1L;
private PermissionDeniedException()
{
super("");
}
private PermissionDeniedException(String string)
{
super(string);
}
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
@ -197,4 +177,25 @@ public class Command_adminworld extends FreedomCommand
}
return Collections.emptyList();
}
private enum CommandMode
{
TELEPORT, TIME, WEATHER
}
private static class PermissionDeniedException extends Exception
{
private static final long serialVersionUID = 1L;
private PermissionDeniedException()
{
super("");
}
private PermissionDeniedException(String string)
{
super(string);
}
}
}

View file

@ -19,7 +19,7 @@ public class Command_adventure extends FreedomCommand
{
if (isConsole())
{
sender.sendMessage("When used from the console, you must define a target player.");
msg("When used from the console, you must define a target player.");
return true;
}
@ -46,7 +46,7 @@ public class Command_adventure extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}
@ -55,4 +55,4 @@ public class Command_adventure extends FreedomCommand
player.setGameMode(GameMode.ADVENTURE);
return true;
}
}
}

View file

@ -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.adminAction(sender.getName(), "Removing all area effect clouds", true);
int removed = 0;
for (World world : server.getWorlds())
{
@ -33,4 +33,4 @@ public class Command_aeclear extends FreedomCommand
msg(removed + " area effect clouds removed.");
return true;
}
}
}

View file

@ -22,5 +22,4 @@ public class Command_announce extends FreedomCommand
plugin.an.announce(StringUtils.join(args, " "));
return true;
}
}
}

View file

@ -0,0 +1,30 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.attribute.Attribute;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Lists all possible attributes.", usage = "/<command>")
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: ");
for (Attribute attribute : Attribute.values())
{
list.append(attribute.name()).append(", ");
}
// Remove extra comma at the end of the list
list = new StringBuilder(list.substring(0, list.length() - 2));
msg(list.toString());
return true;
}
}

View file

@ -2,6 +2,7 @@ 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;
@ -31,8 +32,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"))
@ -100,7 +101,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);
targetPos.getWorld().strikeLightning(strike_pos);
Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos);
}
}
}
@ -154,7 +155,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(), String.format(bcast.toString()), true);
FUtil.adminAction(sender.getName(), bcast.toString(), true);
}
// Kick player and handle others on IP

View file

@ -27,10 +27,10 @@ public class Command_banip extends FreedomCommand
boolean silent = false;
String reason = null;
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 = ChatColor.RED + sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
player.sendMessage(message);
String message = sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
msg(player, message, ChatColor.RED);
}
}

View file

@ -26,8 +26,8 @@ public class Command_banname extends FreedomCommand
boolean silent = false;
String reason = null;
String name = args[0];;
String name = args[0];
if (plugin.bm.getByUsername(name) != null)
{

View file

@ -0,0 +1,33 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.List;
import java.util.SplittableRandom;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
public class Command_bird extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
playerSender.getWorld().spawnEntity(location, getRandomFish());
msg(":goodbird:");
return true;
}
public EntityType getRandomFish()
{
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
SplittableRandom random = new SplittableRandom();
return fishTypes.get(random.nextInt(fishTypes.size()));
}
}

View file

@ -46,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.adminAction(sender.getName(), "Unblocking block modification abilities for all players", true);
int count = 0;
for (final Player player : this.server.getOnlinePlayers())
{
@ -63,7 +63,7 @@ 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.adminAction(sender.getName(), "Blocking block modification abilities for all non-admins", true);
int counter = 0;
for (final Player player : this.server.getOnlinePlayers())
{
@ -92,7 +92,7 @@ public class Command_blockedit extends FreedomCommand
final Player player2 = getPlayer(args[0]);
if (player2 == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}

View file

@ -93,7 +93,7 @@ public class Command_blockpvp extends FreedomCommand
final Player p = getPlayer(args[0]);
if (p == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}
@ -108,14 +108,14 @@ public class Command_blockpvp extends FreedomCommand
{
FUtil.adminAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
pd.setPvpBlocked(false);
msg("Enabling PVP for " + p.getName());
msg("Enabling PVP for " + p.getName());
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
}
else
{
if (plugin.al.isAdmin(p))
{
msg(p.getName() + " is an admin and cannot have their PVP disabled.");
msg(p.getName() + " is an admin, and cannot have their PVP disabled.");
return true;
}

View file

@ -38,4 +38,4 @@ public class Command_blockredstone extends FreedomCommand
}
return true;
}
}
}

View file

@ -28,7 +28,7 @@ public class Command_cage extends FreedomCommand
}
String skullName = null;
if ("purge".equals(args[0]))
if (args[0].equalsIgnoreCase("purge"))
{
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
for (Player player : server.getOnlinePlayers())
@ -42,14 +42,14 @@ public class Command_cage extends FreedomCommand
Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}
final FPlayer fPlayer = plugin.pl.getPlayer(player);
if (fPlayer.getCageData().isCaged())
{
sender.sendMessage(ChatColor.RED + "That player is already caged.");
msg("That player is already caged.", ChatColor.RED);
return true;
}
@ -80,7 +80,7 @@ public class Command_cage extends FreedomCommand
outerMaterial = Material.matchMaterial(args[2]);
break;
}
sender.sendMessage(ChatColor.RED + "Invalid block!");
msg("Invalid block!", ChatColor.RED);
break;
}
}
@ -146,4 +146,4 @@ public class Command_cage extends FreedomCommand
return Collections.emptyList();
}
}
}

View file

@ -29,6 +29,7 @@ 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);

View file

@ -1,5 +1,6 @@
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;
@ -18,12 +19,11 @@ public class Command_cartsit extends FreedomCommand
if (args.length == 1 && plugin.al.isAdmin(sender))
{
targetPlayer = getPlayer(args[0]);
if (targetPlayer == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}
}
@ -32,14 +32,14 @@ public class Command_cartsit extends FreedomCommand
{
if (targetPlayer == null)
{
sender.sendMessage("When used from the console, you must define a target player: /cartsit <player>");
msg("When used from the console, you must define a target player: /cartsit <player>");
return true;
}
}
if (targetPlayer.isInsideVehicle())
{
targetPlayer.getVehicle().eject();
Objects.requireNonNull(targetPlayer.getVehicle()).eject();
}
else
{
@ -74,4 +74,4 @@ public class Command_cartsit extends FreedomCommand
return true;
}
}
}

View file

@ -20,11 +20,11 @@ public class Command_clearchat extends FreedomCommand
{
for (int i = 0; i < 100; i++)
{
player.sendMessage("");
msg(player, "");
}
}
}
FUtil.adminAction(sender.getName(), "Cleared chat", true);
return true;
}
}
}

View file

@ -5,7 +5,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Clear the discord message queue.", usage = "/<command>")
public class Command_cleardiscordqueue extends FreedomCommand
{
@ -16,4 +16,4 @@ public class Command_cleardiscordqueue extends FreedomCommand
msg("Cleared the discord message queue.");
return true;
}
}
}

View file

@ -52,7 +52,7 @@ public class Command_clearinventory extends FreedomCommand
player.getInventory().clear();
msg("Cleared " + player.getName() + "'s inventory.");
player.sendMessage(sender.getName() + " has cleared your inventory.");
msg(player, sender.getName() + " has cleared your inventory.");
}
}
else
@ -76,4 +76,4 @@ public class Command_clearinventory extends FreedomCommand
return Collections.emptyList();
}
}
}

View file

@ -14,14 +14,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))
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH) && (!plugin.lp.CLOWNFISH_TOGGLE.contains(playerSender.getName())))
{
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! Purchase one from the shop.", ChatColor.RED);
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);
}
return true;
}

View file

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -19,7 +19,6 @@ public class Command_cmdspy extends FreedomCommand
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
plugin.al.save(admin);
plugin.al.updateTables();
return true;
}
}
}

View file

@ -0,0 +1,55 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Map;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Essentials Interface Command - Set your nickname to a certain color.", usage = "/<command> <color>")
public class Command_colorme extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (args[0].equalsIgnoreCase("list"))
{
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
return true;
}
final String needle = args[0].trim().toLowerCase();
ChatColor color = null;
for (Map.Entry<String, ChatColor> entry : FUtil.CHAT_COLOR_NAMES.entrySet())
{
if (entry.getKey().contains(needle))
{
color = entry.getValue();
break;
}
}
if (color == null)
{
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
return true;
}
final String newNick = color + ChatColor.stripColor(playerSender.getDisplayName()).trim() + ChatColor.WHITE;
plugin.esb.setNickname(sender.getName(), newNick);
msg("Your nickname is now: " + newNick);
return true;
}
}

View file

@ -0,0 +1,50 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>", aliases = "cmdlist")
public class Command_commandlist extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
List<String> commands = new ArrayList<>();
for (Plugin targetPlugin : server.getPluginManager().getPlugins())
{
try
{
PluginDescriptionFile desc = targetPlugin.getDescription();
Map<String, Map<String, Object>> map = desc.getCommands();
for (Entry<String, Map<String, Object>> entry : map.entrySet())
{
String command_name = entry.getKey();
commands.add(command_name);
}
}
catch (Throwable ignored)
{
}
}
Collections.sort(commands);
msg(StringUtils.join(commands, ", "));
return true;
}
}

View file

@ -23,7 +23,7 @@ public class Command_consolesay extends FreedomCommand
String message = StringUtils.join(args, " ");
FUtil.bcastMsg(String.format("§7[CONSOLE] §c%s §8\u00BB §f%s", sender.getName(), StringUtils.join(args, " ")));
plugin.dc.messageChatChannel("[CONSOLE] " + plugin.dc.deformat(sender.getName()) + " \u00BB " + ChatColor.stripColor(message));
plugin.dc.messageChatChannel("[CONSOLE] " + sender.getName() + " \u00BB " + ChatColor.stripColor(message));
return true;
}
}
}

View file

@ -28,15 +28,6 @@ public class Command_cookie extends FreedomCommand
output.append(FUtil.randomChatColor()).append(word).append(" ");
}
final StringBuilder name = new StringBuilder();
name.append(ChatColor.DARK_RED).append("C")
.append(ChatColor.GOLD).append("o")
.append(ChatColor.YELLOW).append("o")
.append(ChatColor.DARK_GREEN).append("k")
.append(ChatColor.DARK_BLUE).append("i")
.append(ChatColor.DARK_PURPLE).append("e");
final StringBuilder lore = new StringBuilder();
for (final String word : LORE.split(" "))
@ -46,7 +37,14 @@ public class Command_cookie extends FreedomCommand
final ItemStack heldItem = new ItemStack(Material.COOKIE);
final ItemMeta heldItemMeta = heldItem.getItemMeta();
heldItemMeta.setDisplayName(name.toString());
String name = ChatColor.DARK_RED + "C" +
ChatColor.GOLD + "o" +
ChatColor.YELLOW + "o" +
ChatColor.DARK_GREEN + "k" +
ChatColor.DARK_BLUE + "i" +
ChatColor.DARK_PURPLE + "e";
assert heldItemMeta != null;
heldItemMeta.setDisplayName(name);
heldItemMeta.setLore(Arrays.asList(lore.toString().split("\n")));
heldItem.setItemMeta(heldItemMeta);

View file

@ -19,7 +19,7 @@ public class Command_creative extends FreedomCommand
{
if (isConsole())
{
sender.sendMessage("When used from the console, you must define a target player.");
msg("When used from the console, you must define a target player.");
return true;
}
@ -46,7 +46,7 @@ public class Command_creative extends FreedomCommand
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
msg(PLAYER_NOT_FOUND);
return true;
}
@ -56,4 +56,4 @@ public class Command_creative extends FreedomCommand
return true;
}
}
}

View file

@ -1,6 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Random;
import java.util.SplittableRandom;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.Location;
import org.bukkit.Sound;
@ -14,8 +14,18 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Command_deafen extends FreedomCommand
{
private static final Random random = new Random();
public static final double STEPS = 10.0;
private static final SplittableRandom random = new SplittableRandom();
private static Location randomOffset(Location a)
{
return a.clone().add(randomDoubleRange() * 5.0, randomDoubleRange() * 5.0, randomDoubleRange() * 5.0);
}
private static Double randomDoubleRange()
{
return -1.0 + (random.nextDouble() * ((1.0 - -1.0) + 1.0));
}
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
@ -30,7 +40,7 @@ public class Command_deafen extends FreedomCommand
@Override
public void run()
{
playerSender.playSound(randomOffset(playerSender.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
playerSender.playSound(randomOffset(playerSender.getLocation()), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
}
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
}
@ -38,14 +48,4 @@ public class Command_deafen extends FreedomCommand
return true;
}
private static Location randomOffset(Location a, double magnitude)
{
return a.clone().add(randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude, randomDoubleRange(-1.0, 1.0) * magnitude);
}
private static Double randomDoubleRange(double min, double max)
{
return min + (random.nextDouble() * ((max - min) + 1.0));
}
}

View file

@ -21,6 +21,7 @@ public class Command_debugstick extends FreedomCommand
{
ItemStack itemStack = new ItemStack(Material.DEBUG_STICK);
ItemMeta itemMeta = itemStack.getItemMeta();
assert itemMeta != null;
itemMeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD.toString() + "Stick of Happiness");
List<String> lore = Arrays.asList(
ChatColor.RED + "This is the most powerful stick in the game.",

View file

@ -39,7 +39,8 @@ public class Command_deop extends FreedomCommand
{
matchedPlayerNames.add(player.getName());
player.setOp(false);
player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
msg(player, YOU_ARE_NOT_OP);
plugin.rm.updateDisplay(player);
}
}
}

View file

@ -19,7 +19,8 @@ public class Command_deopall extends FreedomCommand
for (Player player : server.getOnlinePlayers())
{
player.setOp(false);
player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
msg(player, YOU_ARE_NOT_OP);
plugin.rm.updateDisplay(player);
}
return true;

View file

@ -33,7 +33,6 @@ public class Command_disguisetoggle extends FreedomCommand
}
msg("Disguises are now " + (plugin.ldb.isDisguisesEnabled() ? "enabled." : "disabled."));
return true;
}
}
}

View file

@ -20,6 +20,16 @@ import org.bukkit.inventory.ItemStack;
public class Command_dispfill extends FreedomCommand
{
private static void setDispenserContents(final Block targetBlock, final ItemStack[] items)
{
if (targetBlock.getType() == Material.DISPENSER)
{
final Inventory dispenserInv = ((Dispenser)targetBlock.getState()).getInventory();
dispenserInv.clear();
dispenserInv.addItem(items);
}
}
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -33,7 +43,7 @@ public class Command_dispfill extends FreedomCommand
}
catch (NumberFormatException ex)
{
sender.sendMessage("Invalid radius.");
msg("Invalid radius.");
return true;
}
@ -50,11 +60,11 @@ public class Command_dispfill extends FreedomCommand
}
else
{
sender.sendMessage("Skipping invalid item: " + searchItem);
msg("Skipping invalid item: " + searchItem);
}
}
final ItemStack[] itemsArray = items.toArray(new ItemStack[items.size()]);
final ItemStack[] itemsArray = items.toArray(new ItemStack[0]);
int affected = 0;
final Location centerLocation = playerSender.getLocation();
@ -70,7 +80,8 @@ public class Command_dispfill extends FreedomCommand
{
if (targetBlock.getType().equals(Material.DISPENSER))
{
sender.sendMessage("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation()));
msg("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation()));
plugin.cpb.getCoreProtectAPI().logContainerTransaction(sender.getName(), targetBlock.getLocation());
setDispenserContents(targetBlock, itemsArray);
affected++;
}
@ -79,7 +90,7 @@ public class Command_dispfill extends FreedomCommand
}
}
sender.sendMessage("Done. " + affected + " dispenser(s) filled.");
msg("Done. " + affected + " dispenser(s) filled.");
}
else
{
@ -88,14 +99,4 @@ public class Command_dispfill extends FreedomCommand
return true;
}
private static void setDispenserContents(final Block targetBlock, final ItemStack[] items)
{
if (targetBlock.getType() == Material.DISPENSER)
{
final Inventory dispenserInv = ((Dispenser)targetBlock.getState()).getInventory();
dispenserInv.clear();
dispenserInv.addItem(items);
}
}
}

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