mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-23 16:08:18 -05:00
Target Java 7
This commit is contained in:
parent
d3d5140fe4
commit
87ef009ba6
12 changed files with 108 additions and 600 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
|||
.settings/
|
||||
bin/
|
||||
target/
|
||||
.checkstyle
|
||||
.classpath
|
||||
.project
|
||||
.project
|
||||
|
|
2
build.sh
2
build.sh
|
@ -1,2 +0,0 @@
|
|||
#!/bin/sh
|
||||
mvn package
|
521
checkstyle.xml
521
checkstyle.xml
|
@ -1,521 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
<module name="Checker">
|
||||
<!--
|
||||
If you set the basedir property below, then all reported file
|
||||
names will be relative to the specified directory. See
|
||||
https://checkstyle.org/config.html#Checker
|
||||
|
||||
<property name="basedir" value="${basedir}"/>
|
||||
-->
|
||||
|
||||
<metadata name="org.checkstyle.principle" value="Practice What You Preach"/>
|
||||
<metadata name="org.checkstyle.principle.description"
|
||||
value="In our config we should use all Checks that Checkstyle has"/>
|
||||
|
||||
<property name="cacheFile" value="${checkstyle.cache.file}"/>
|
||||
|
||||
<property name="severity" value="error"/>
|
||||
|
||||
<property name="fileExtensions" value="java, properties, xml, vm, g, g4, dtd"/>
|
||||
|
||||
<!-- BeforeExecutionFileFilters is required for sources that are based on java9 -->
|
||||
<module name="BeforeExecutionExclusionFileFilter">
|
||||
<property name="fileNamePattern" value="module\-info\.java$" />
|
||||
</module>
|
||||
|
||||
<!-- Filters -->
|
||||
<module name="SeverityMatchFilter">
|
||||
<!-- report all violations except ignore -->
|
||||
<property name="severity" value="ignore"/>
|
||||
<property name="acceptOnMatch" value="false"/>
|
||||
</module>
|
||||
<module name="SuppressWithPlainTextCommentFilter">
|
||||
<!--
|
||||
Use suppressions.xml for suppressions, this is only example.
|
||||
checkFormat will prevent suppression comments from being valid.
|
||||
-->
|
||||
<property name="checkFormat" value="IGNORETHIS"/>
|
||||
<property name="offCommentFormat" value="CSOFF\: .*"/>
|
||||
<property name="onCommentFormat" value="CSON\: .*"/>
|
||||
</module>
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<module name="NewlineAtEndOfFile"/>
|
||||
<module name="Translation">
|
||||
<property name="requiredTranslations" value="de, fr, fi, es, pt, ja, tr, zh"/>
|
||||
</module>
|
||||
<module name="UniqueProperties"/>
|
||||
|
||||
<!-- Regexp -->
|
||||
<module name="RegexpMultiline"/>
|
||||
<module name="RegexpMultiline">
|
||||
<property name="format" value="\r?\n[\t ]*\r?\n[\t ]*\r?\n"/>
|
||||
<property name="fileExtensions" value="java,xml,properties"/>
|
||||
<property name="message" value="Unnecessary consecutive lines"/>
|
||||
</module>
|
||||
<module name="RegexpMultiline">
|
||||
<property name="format" value="/\*\*\W+\* +\p{javaLowerCase}"/>
|
||||
<property name="fileExtensions" value="java"/>
|
||||
<property name="message"
|
||||
value="First sentence in a comment should start with a capital letter"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\s+$"/>
|
||||
<property name="minimum" value="0"/>
|
||||
<property name="maximum" value="0"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="/\*\* +\p{javaLowerCase}"/>
|
||||
<property name="fileExtensions" value="java"/>
|
||||
<property name="message"
|
||||
value="First sentence in a comment should start with a capital letter"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="^(?!(.*http|import)).{101,}$"/>
|
||||
<property name="fileExtensions" value="g, g4"/>
|
||||
<property name="message" value="Line should not be longer than 100 symbols"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="^(?!(\s*<a href="[^"]+">|.*http)).{101,}$"/>
|
||||
<property name="fileExtensions" value="xml, vm"/>
|
||||
<property name="message" value="Line should not be longer than 100 symbols"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="id" value="noSourceforgeNetLinks"/>
|
||||
<property name="format" value="checkstyle\.sourceforge\.net"/>
|
||||
<property name="message"
|
||||
value="Old site links should not be used, please use https://checkstyle.org"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="id" value="noSourceforgeIoLinks"/>
|
||||
<property name="format" value="checkstyle\.sourceforge\.io"/>
|
||||
<property name="message"
|
||||
value="Old site links should not be used, please use https://checkstyle.org"/>
|
||||
</module>
|
||||
<module name="RegexpOnFilename" />
|
||||
<module name="RegexpOnFilename">
|
||||
<property name="folderPattern" value="[\\/]src[\\/]\w+[\\/]java[\\/]"/>
|
||||
<property name="fileNamePattern" value="\.java$"/>
|
||||
<property name="match" value="false"/>
|
||||
<message key="regexp.filepath.mismatch"
|
||||
value="Only java files should be located in the ''src/*/java'' folders."/>
|
||||
</module>
|
||||
<module name="RegexpOnFilename">
|
||||
<property name="folderPattern" value="[\\/]src[\\/]xdocs[\\/]"/>
|
||||
<property name="fileNamePattern" value="\.(xml)|(vm)$"/>
|
||||
<property name="match" value="false"/>
|
||||
<message key="regexp.filepath.mismatch"
|
||||
value="All files in the ''src/xdocs'' folder should have the ''xml'' or ''vm'' extension."/>
|
||||
</module>
|
||||
<module name="RegexpOnFilename">
|
||||
<property name="folderPattern" value="[\\/]src[\\/]it[\\/]java[\\/]"/>
|
||||
<property name="fileNamePattern" value="^((\w+Test)|(\w+TestSupport)|(Abstract\w+))\.java$"/>
|
||||
<property name="match" value="false"/>
|
||||
<message key="regexp.filepath.mismatch"
|
||||
value="All files in the ''src/it/java'' folder
|
||||
should be named ''*Test.java'' or ''Abstract*.java''."/>
|
||||
</module>
|
||||
|
||||
<!-- Size Violations -->
|
||||
<module name="FileLength">
|
||||
<property name="fileExtensions" value="java"/>
|
||||
</module>
|
||||
|
||||
<!-- Whitespace -->
|
||||
<module name="TreeWalker">
|
||||
<property name="tabWidth" value="4"/>
|
||||
|
||||
<!-- Annotations -->
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="ANNOTATION_DEF"/>
|
||||
<property name="tokens" value="ANNOTATION_FIELD_DEF"/>
|
||||
<property name="tokens" value="PACKAGE_DEF"/>
|
||||
<property name="tokens" value="ENUM_CONSTANT_DEF"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="allowSamelineSingleParameterlessAnnotation" value="false"/>
|
||||
</module>
|
||||
<module name="AnnotationOnSameLine">
|
||||
<!-- we can not use it as it conflicts with AnnotationLocation -->
|
||||
<property name="severity" value="ignore"/>
|
||||
<property name="tokens" value="METHOD_DEF"/>
|
||||
<property name="tokens" value="CTOR_DEF"/>
|
||||
<property name="tokens" value="TYPECAST"/>
|
||||
<property name="tokens" value="DOT"/>
|
||||
<property name="tokens" value="CLASS_DEF"/>
|
||||
<property name="tokens" value="ENUM_DEF"/>
|
||||
<property name="tokens" value="INTERFACE_DEF"/>
|
||||
<property name="tokens" value="TYPE_ARGUMENT"/>
|
||||
<property name="tokens" value="ANNOTATION_DEF"/>
|
||||
<property name="tokens" value="LITERAL_NEW"/>
|
||||
<property name="tokens" value="LITERAL_THROWS"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="tokens" value="PARAMETER_DEF"/>
|
||||
<property name="tokens" value="IMPLEMENTS_CLAUSE"/>
|
||||
<property name="tokens" value="ANNOTATION_FIELD_DEF"/>
|
||||
</module>
|
||||
<module name="AnnotationUseStyle"/>
|
||||
<module name="MissingDeprecated"/>
|
||||
<module name="MissingOverride"/>
|
||||
<module name="PackageAnnotation"/>
|
||||
<module name="SuppressWarnings">
|
||||
<property name="format" value="^((?!unchecked|deprecation|rawtypes|resource).)*$"/>
|
||||
<message key="suppressed.warning.not.allowed"
|
||||
value="The warning ''{0}'' cannot be suppressed at this location.
|
||||
Only few javac warnings are allowed to suppress.
|
||||
If try to suppress checkstyle/pmd/..... violation please do this in their config file.
|
||||
If you try to suppress IntelliJ IDEA inspection,
|
||||
please use javadoc block tag @noinspection"
|
||||
/>
|
||||
</module>
|
||||
<module name="SuppressWarningsHolder"/>
|
||||
|
||||
<!-- Block Checks -->
|
||||
<module name="AvoidNestedBlocks">
|
||||
<property name="allowInSwitchCase" value="true"/>
|
||||
</module>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="NeedBraces">
|
||||
<property name="tokens" value="LAMBDA"/>
|
||||
<property name="allowSingleLineStatement" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- Class Design -->
|
||||
<module name="DesignForExtension">
|
||||
<property name="ignoredAnnotations"
|
||||
value="Override, Test, Before, After, BeforeClass, AfterClass"/>
|
||||
</module>
|
||||
<module name="FinalClass"/>
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="InnerTypeLast"/>
|
||||
<module name="InterfaceIsType"/>
|
||||
<module name="MutableException"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="ThrowsCount">
|
||||
<property name="max" value="2"/>
|
||||
</module>
|
||||
<module name="VisibilityModifier"/>
|
||||
|
||||
<!-- Coding -->
|
||||
<module name="ArrayTrailingComma"/>
|
||||
<module name="AvoidInlineConditionals"/>
|
||||
<module name="CovariantEquals"/>
|
||||
<module name="DeclarationOrder"/>
|
||||
<module name="DefaultComesLast"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="EqualsAvoidNull"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
<module name="ExplicitInitialization"/>
|
||||
<module name="FallThrough"/>
|
||||
<module name="FinalLocalVariable"/>
|
||||
<module name="HiddenField">
|
||||
<property name="ignoreConstructorParameter" value="true"/>
|
||||
<property name="ignoreSetter" value="true"/>
|
||||
<property name="setterCanReturnItsClass" value="true"/>
|
||||
</module>
|
||||
<module name="IllegalInstantiation">
|
||||
<property name="classes"
|
||||
value="org.xml.sax.SAXException, org.xml.sax.SAXParseException,
|
||||
org.apache.commons.beanutils.ConversionException,
|
||||
org.antlr.v4.runtime.misc.ParseCancellationException,
|
||||
antlr.RecognitionException, antlr.TokenStreamException,
|
||||
antlr.TokenStreamRecognitionException, antlr.ANTLRException,
|
||||
java.lang.StringBuffer"/>
|
||||
</module>
|
||||
<module name="IllegalThrows"/>
|
||||
<module name="IllegalToken">
|
||||
<property name="tokens" value="LABELED_STAT"/>
|
||||
<property name="tokens" value="LITERAL_NATIVE"/>
|
||||
<property name="tokens" value="LITERAL_VOLATILE"/>
|
||||
<property name="tokens" value="LITERAL_ASSERT"/>
|
||||
</module>
|
||||
<module name="IllegalTokenText">
|
||||
<property name="tokens" value="STRING_LITERAL"/>
|
||||
<property name="format" value="^(US-ASCII|ISO-8859-1|UTF-8|UTF-16BE|UTF-16LE|UTF-16)$"/>
|
||||
<property name="ignoreCase" value="true"/>
|
||||
</module>
|
||||
<module name="IllegalType">
|
||||
<property name="illegalClassNames"
|
||||
value="java.util.HashSet, HashSet, java.util.LinkedHashMap, LinkedHashMap,
|
||||
java.util.TreeMap, TreeMap, java.util.HashMap, HashMap,
|
||||
java.util.LinkedHashSet, LinkedHashSet, java.util.TreeSet, TreeSet,
|
||||
java.lang.StringBuffer, StringBuffer"/>
|
||||
</module>
|
||||
<module name="InnerAssignment"/>
|
||||
<module name="MissingCtor">
|
||||
<!--
|
||||
we will not use that fanatic validation, extra code is not good
|
||||
But this Check will exists as it was created by community demand.
|
||||
-->
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="ModifiedControlVariable"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="NestedForDepth">
|
||||
<property name="max" value="2"/>
|
||||
</module>
|
||||
<module name="NestedIfDepth">
|
||||
<property name="max" value="3"/>
|
||||
</module>
|
||||
<module name="NestedTryDepth"/>
|
||||
<module name="NoClone"/>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="PackageDeclaration"/>
|
||||
<module name="ParameterAssignment"/>
|
||||
<module name="RequireThis"/>
|
||||
<module name="ReturnCount">
|
||||
<property name="max" value="1"/>
|
||||
<property name="maxForVoid" value="0"/>
|
||||
</module>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
<module name="StringLiteralEquality"/>
|
||||
<module name="SuperClone"/>
|
||||
<module name="SuperFinalize"/>
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
<module name="VariableDeclarationUsageDistance"/>
|
||||
|
||||
<!-- Filters-->
|
||||
<module name="SuppressionCommentFilter">
|
||||
<!--
|
||||
Use suppressions.xml for suppressions, this is only example.
|
||||
checkFormat will prevent suppression comments from being valid.
|
||||
-->
|
||||
<property name="checkFormat" value="IGNORETHIS"/>
|
||||
<property name="offCommentFormat" value="CSOFF\: .*"/>
|
||||
<property name="onCommentFormat" value="CSON\: .*"/>
|
||||
</module>
|
||||
<!-- Tone down the checking for test code -->
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<property name="files" value="[\\/]internal[\\/].*[\\/]\w+Util\.java"/>
|
||||
<property name="checks" value="IllegalCatch"/>
|
||||
</module>
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<property name="files" value=".*[\\/]src[\\/]test[\\/]"/>
|
||||
<property name="checks" value="EmptyBlock"/>
|
||||
</module>
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<property name="files" value=".*[\\/]src[\\/](test|it)[\\/]"/>
|
||||
<property name="checks" value="JavadocVariable"/>
|
||||
</module>
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<property name="files" value=".*[\\/]src[\\/](test|it)[\\/]"/>
|
||||
<property name="checks" value="JavadocType"/>
|
||||
</module>
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<property name="files" value=".*[\\/]src[\\/](test|it)[\\/]"/>
|
||||
<property name="checks" value="MagicNumber"/>
|
||||
</module>
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<property name="files" value=".*[\\/]src[\\/](test|it)[\\/]"/>
|
||||
<property name="checks" value="AvoidStaticImport"/>
|
||||
</module>
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<property name="files" value=".*[\\/]src[\\/](test|it)[\\/]"/>
|
||||
<property name="checks" value="WriteTag"/>
|
||||
</module>
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<property name="files" value=".*[\\/]src[\\/](test|it)[\\/]"/>
|
||||
<property name="checks" value="MethodCount"/>
|
||||
</module>
|
||||
<!-- Fixing these cases will decrease code readability -->
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<property name="files" value=".*[\\/]src[\\/](test|it)[\\/]"/>
|
||||
<property name="checks" value="MultipleStringLiterals"/>
|
||||
</module>
|
||||
<module name="SuppressWithNearbyCommentFilter">
|
||||
<property name="commentFormat"
|
||||
value="-@cs\[(\w{8,}(\|\w{8,})*)\] \w[\(\)\-\.\'\`\,\:\;\w ]{10,}"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
<property name="influenceFormat" value="3"/>
|
||||
</module>
|
||||
|
||||
<!-- Imports -->
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="AvoidStaticImport"/>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="customImportOrderRules"
|
||||
value="STATIC###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS"/>
|
||||
<property name="specialImportsRegExp" value="^org\."/>
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
<property name="separateLineBetweenGroups" value="true"/>
|
||||
</module>
|
||||
<module name="IllegalImport"/>
|
||||
<module name="ImportOrder">
|
||||
<property name="groups" value="/^java\./,javax,org"/>
|
||||
<property name="ordered" value="true"/>
|
||||
<property name="separated" value="true"/>
|
||||
<property name="option" value="top"/>
|
||||
<property name="sortStaticImportsAlphabetically" value="true"/>
|
||||
</module>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports"/>
|
||||
|
||||
<!-- Metrics -->
|
||||
<module name="BooleanExpressionComplexity">
|
||||
<property name="max" value="7"/>
|
||||
</module>
|
||||
<module name="ClassDataAbstractionCoupling">
|
||||
<!-- Default classes are also listed-->
|
||||
<property name="excludedClasses"
|
||||
value="boolean, byte, char, double, float, int, long, short, void,
|
||||
Boolean, Byte, Character, Double, Float, Integer, Long, Short, Void,
|
||||
Object, Class, String, StringBuffer, StringBuilder,
|
||||
ArrayIndexOutOfBoundsException, Exception, RuntimeException,
|
||||
IllegalArgumentException, IllegalStateException,
|
||||
IndexOutOfBoundsException, NullPointerException, Throwable,
|
||||
SecurityException, UnsupportedOperationException, List, ArrayList,
|
||||
Deque, Queue, LinkedList, Set, HashSet, SortedSet, TreeSet, Map,
|
||||
HashMap, SortedMap, TreeMap, DetailsAST,
|
||||
UnsupportedEncodingException, BuildException, ConversionException,
|
||||
FileNotFoundException, TestException"/>
|
||||
</module>
|
||||
<module name="NPathComplexity"/>
|
||||
|
||||
<!-- Misc -->
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="AvoidEscapedUnicodeCharacters">
|
||||
<property name="allowIfAllCharactersEscaped" value="true"/>
|
||||
</module>
|
||||
<module name="CommentsIndentation"/>
|
||||
<module name="DescendantToken"/>
|
||||
<module name="FinalParameters">
|
||||
<!--
|
||||
we will not use that fanatic validation, extra modifiers pollute a code
|
||||
it is better to use extra validation(Check) that argument is reassigned
|
||||
But this Check will exists as it was created by community demand.
|
||||
-->
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="braceAdjustment" value="0"/>
|
||||
<property name="caseIndent" value="4"/>
|
||||
<property name="throwsIndent" value="8"/>
|
||||
</module>
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="TodoComment">
|
||||
<property name="format" value="(TODO)|(FIXME)" />
|
||||
</module>
|
||||
<module name="TrailingComment"/>
|
||||
<module name="UncommentedMain">
|
||||
<property name="excludedClasses" value="\.(Main|JavadocPropertiesGenerator)$"/>
|
||||
</module>
|
||||
<module name="UpperEll"/>
|
||||
|
||||
<!-- Modifiers -->
|
||||
<module name="ClassMemberImpliedModifier">
|
||||
<!-- effectively the opposite of RedundantModifier, so output must be ignored -->
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
<module name="InterfaceMemberImpliedModifier">
|
||||
<!-- effectively the opposite of RedundantModifier, so output must be ignored -->
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="RedundantModifier"/>
|
||||
|
||||
<!-- Naming Conventions -->
|
||||
<module name="AbstractClassName"/>
|
||||
<module name="ClassTypeParameterName"/>
|
||||
<module name="ConstantName"/>
|
||||
<module name="InterfaceTypeParameterName"/>
|
||||
<module name="LocalFinalVariableName"/>
|
||||
<module name="LocalVariableName">
|
||||
<property name="format" value="^(id)|([a-z][a-z0-9][a-zA-Z0-9]+)$"/>
|
||||
<property name="allowOneCharVarInForLoop" value="true"/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^(id)|([a-z][a-z0-9][a-zA-Z0-9]+)$"/>
|
||||
</module>
|
||||
<module name="MethodName"/>
|
||||
<module name="MethodTypeParameterName"/>
|
||||
<module name="PackageName"/>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^(id)|([a-z][a-z0-9][a-zA-Z0-9]+)$"/>
|
||||
<property name="ignoreOverridden" value="true"/>
|
||||
</module>
|
||||
<module name="LambdaParameterName">
|
||||
<property name="format" value="^(id)|([a-z][a-z0-9][a-zA-Z0-9]+)$"/>
|
||||
</module>
|
||||
<module name="CatchParameterName">
|
||||
<property name="format" value="^(ex|[a-z][a-z][a-zA-Z]+)$"/>
|
||||
</module>
|
||||
<module name="StaticVariableName">
|
||||
<property name="format" value="^(id)|([a-z][a-z0-9][a-zA-Z0-9]+)$"/>
|
||||
</module>
|
||||
<module name="TypeName"/>
|
||||
|
||||
<!-- Regexp -->
|
||||
<module name="Regexp"/>
|
||||
<module name="RegexpSinglelineJava"/>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="[^\p{ASCII}]"/>
|
||||
<property name="ignoreComments" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- Size Violations -->
|
||||
<module name="AnonInnerLength"/>
|
||||
<module name="ExecutableStatementCount">
|
||||
<property name="max" value="30"/>
|
||||
</module>
|
||||
<module name="MethodCount">
|
||||
<property name="maxTotal" value="34"/>
|
||||
</module>
|
||||
<module name="MethodLength"/>
|
||||
<module name="OuterTypeNumber"/>
|
||||
<module name="ParameterNumber"/>
|
||||
|
||||
<!-- Whitespace -->
|
||||
<module name="EmptyForInitializerPad"/>
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
|
||||
</module>
|
||||
<module name="GenericWhitespace"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="NoLineWrap"/>
|
||||
<module name="NoWhitespaceAfter">
|
||||
<property name="tokens" value="ARRAY_INIT"/>
|
||||
<property name="tokens" value="AT"/>
|
||||
<property name="tokens" value="BNOT"/>
|
||||
<property name="tokens" value="DEC"/>
|
||||
<property name="tokens" value="DOT"/>
|
||||
<property name="tokens" value="INC"/>
|
||||
<property name="tokens" value="LNOT"/>
|
||||
<property name="tokens" value="UNARY_MINUS"/>
|
||||
<property name="tokens" value="UNARY_PLUS"/>
|
||||
<property name="tokens" value="ARRAY_DECLARATOR"/>
|
||||
<property name="tokens" value="INDEX_OP"/>
|
||||
<property name="tokens" value="METHOD_REF"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="tokens" value="DOT"/>
|
||||
<property name="tokens" value="METHOD_REF"/>
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
</module>
|
||||
<module name="ParenPad"/>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="tokens" value="DOT"/>
|
||||
<property name="tokens" value="AT"/>
|
||||
<property name="tokens" value="METHOD_REF"/>
|
||||
<property name="option" value="nl"/>
|
||||
</module>
|
||||
<module name="SingleSpaceSeparator">
|
||||
<property name="validateComments" value="false"/>
|
||||
</module>
|
||||
<module name="TypecastParenPad"/>
|
||||
<module name="WhitespaceAfter"/>
|
||||
<module name="WhitespaceAround"/>
|
||||
|
||||
</module>
|
||||
|
||||
</module>
|
40
pom.xml
40
pom.xml
|
@ -3,11 +3,13 @@
|
|||
<groupId>pw.kaboom</groupId>
|
||||
<artifactId>Extras</artifactId>
|
||||
<version>master</version>
|
||||
<properties>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
</properties>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -31,21 +33,21 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<configLocation>${basedir}/checkstyle.xml</configLocation>
|
||||
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||
<enableRulesSummary>false</enableRulesSummary>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<compilerArgs>
|
||||
<arg>-Xlint:all</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>checkstyle</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<suppressionsLocation>
|
||||
suppressions.xml
|
||||
</suppressionsLocation>
|
||||
<failOnViolation>false</failOnViolation>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
|
@ -7,22 +7,43 @@ import java.util.UUID;
|
|||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import pw.kaboom.extras.commands.*;
|
||||
import pw.kaboom.extras.modules.block.*;
|
||||
import pw.kaboom.extras.modules.entity.*;
|
||||
import pw.kaboom.extras.modules.player.*;
|
||||
import pw.kaboom.extras.modules.server.*;
|
||||
import pw.kaboom.extras.commands.CommandClearChat;
|
||||
import pw.kaboom.extras.commands.CommandConsole;
|
||||
import pw.kaboom.extras.commands.CommandDestroyEntities;
|
||||
import pw.kaboom.extras.commands.CommandEnchantAll;
|
||||
import pw.kaboom.extras.commands.CommandJumpscare;
|
||||
import pw.kaboom.extras.commands.CommandPrefix;
|
||||
import pw.kaboom.extras.commands.CommandPumpkin;
|
||||
import pw.kaboom.extras.commands.CommandServerInfo;
|
||||
import pw.kaboom.extras.commands.CommandSkin;
|
||||
import pw.kaboom.extras.commands.CommandSpawn;
|
||||
import pw.kaboom.extras.commands.CommandSpidey;
|
||||
import pw.kaboom.extras.commands.CommandTellraw;
|
||||
import pw.kaboom.extras.commands.CommandUnloadChunks;
|
||||
import pw.kaboom.extras.commands.CommandUsername;
|
||||
import pw.kaboom.extras.modules.block.BlockCheck;
|
||||
import pw.kaboom.extras.modules.block.BlockPhysics;
|
||||
import pw.kaboom.extras.modules.entity.EntityExplosion;
|
||||
import pw.kaboom.extras.modules.entity.EntityKnockback;
|
||||
import pw.kaboom.extras.modules.entity.EntitySpawn;
|
||||
import pw.kaboom.extras.modules.entity.EntityTeleport;
|
||||
import pw.kaboom.extras.modules.player.PlayerChat;
|
||||
import pw.kaboom.extras.modules.player.PlayerCommand;
|
||||
import pw.kaboom.extras.modules.player.PlayerConnection;
|
||||
import pw.kaboom.extras.modules.player.PlayerDamage;
|
||||
import pw.kaboom.extras.modules.player.PlayerInteract;
|
||||
import pw.kaboom.extras.modules.player.PlayerTeleport;
|
||||
import pw.kaboom.extras.modules.server.ServerCommand;
|
||||
import pw.kaboom.extras.modules.server.ServerPing;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
public static HashSet<UUID> skinInProgress = new HashSet<>();
|
||||
|
||||
public static HashSet<String> consoleCommandBlacklist = new HashSet<>();
|
||||
public static HashSet<BlockFace> faces = new HashSet<>();
|
||||
public static HashSet<UUID> skinInProgress = new HashSet<UUID>();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
/* Fill lists */
|
||||
Collections.addAll(
|
||||
consoleCommandBlacklist,
|
||||
ServerCommand.consoleCommandBlacklist,
|
||||
"bukkit:about",
|
||||
"bukkit:ver",
|
||||
"bukkit:version",
|
||||
|
@ -388,7 +409,7 @@ public class Main extends JavaPlugin {
|
|||
);
|
||||
|
||||
Collections.addAll(
|
||||
faces,
|
||||
BlockPhysics.blockFaces,
|
||||
BlockFace.NORTH,
|
||||
BlockFace.SOUTH,
|
||||
BlockFace.WEST,
|
||||
|
@ -401,6 +422,7 @@ public class Main extends JavaPlugin {
|
|||
saveConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
/* Commands */
|
||||
this.getCommand("clearchat").setExecutor(new CommandClearChat());
|
||||
|
|
|
@ -2,17 +2,15 @@ package pw.kaboom.extras.helpers;
|
|||
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
|
@ -26,9 +24,10 @@ public class SkinDownloader {
|
|||
Main.skinInProgress.add(player.getUniqueId());
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PlayerProfile profile = player.getPlayerProfile();
|
||||
|
||||
|
||||
if (shouldChangeName && shouldSendMessage) {
|
||||
profile.setName(name);
|
||||
player.sendMessage("Changing your username. Please wait...");
|
||||
|
@ -46,11 +45,12 @@ public class SkinDownloader {
|
|||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (player.isOnline()) {
|
||||
player.setPlayerProfile(profile);
|
||||
|
||||
|
||||
if (shouldChangeName && shouldSendMessage) {
|
||||
player.sendMessage("Successfully set your username to \"" + name + "\"");
|
||||
}
|
||||
|
|
|
@ -1,32 +1,28 @@
|
|||
package pw.kaboom.extras.modules.block;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.destroystokyo.paper.event.block.BlockDestroyEvent;
|
||||
|
||||
import pw.kaboom.extras.Main;
|
||||
|
||||
public class BlockPhysics implements Listener {
|
||||
public static HashSet<BlockFace> blockFaces = new HashSet<BlockFace>();
|
||||
|
||||
@EventHandler
|
||||
void onBlockForm(BlockFormEvent event) {
|
||||
if (event.getBlock().getType() == Material.LAVA ||
|
||||
event.getBlock().getType() == Material.WATER) {
|
||||
for (BlockFace face : Main.faces) {
|
||||
for (BlockFace face : blockFaces) {
|
||||
if (event.getBlock().getRelative(face).getType() != Material.LAVA &&
|
||||
event.getBlock().getRelative(face).getType() != Material.WATER) {
|
||||
return;
|
||||
|
@ -43,24 +39,24 @@ public class BlockPhysics implements Listener {
|
|||
boolean lavaFound = false;
|
||||
boolean waterFound = false;
|
||||
|
||||
for (BlockFace face : Main.faces) {
|
||||
for (BlockFace face : blockFaces) {
|
||||
if (event.getBlock().getRelative(face).getType() == Material.LAVA) {
|
||||
lavaFound = true;
|
||||
} else if (event.getBlock().getRelative(face).getType() == Material.WATER) {
|
||||
waterFound = true;
|
||||
}
|
||||
|
||||
|
||||
if (lavaFound && waterFound) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
void onBlockDestroy(BlockDestroyEvent event) {
|
||||
if (!event.getBlock().getType().isSolid()) {
|
||||
for (BlockFace face : Main.faces) {
|
||||
for (BlockFace face : blockFaces) {
|
||||
if (event.getBlock().getRelative(face).getType() != event.getBlock().getType()) {
|
||||
return;
|
||||
}
|
||||
|
@ -78,9 +74,9 @@ public class BlockPhysics implements Listener {
|
|||
event.setNewCurrent(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int fallingBlockCount;
|
||||
|
||||
|
||||
@EventHandler
|
||||
void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
if (event.getEntityType() == EntityType.FALLING_BLOCK &&
|
||||
|
|
|
@ -4,35 +4,33 @@ import java.util.HashMap;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import pw.kaboom.extras.modules.server.ServerCommand;
|
||||
|
||||
public class PlayerCommand implements Listener {
|
||||
static HashMap<UUID, Long> commandMillisList = new HashMap<>();
|
||||
static HashMap<UUID, Long> commandMillisList = new HashMap<UUID, Long>();
|
||||
|
||||
@EventHandler
|
||||
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
|
||||
if (commandMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - commandMillisList.get(playerUuid);
|
||||
|
||||
|
||||
if (millisDifference < 75) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
commandMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final CommandSender sender = event.getPlayer();
|
||||
final String command = event.getMessage();
|
||||
final boolean isConsoleCommand = false;
|
||||
|
|
|
@ -5,24 +5,23 @@ import java.util.UUID;
|
|||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class PlayerInteract implements Listener {
|
||||
static HashMap<UUID, Long> interactMillisList = new HashMap<>();
|
||||
static HashMap<UUID, Long> interactMillisList = new HashMap<UUID, Long>();
|
||||
|
||||
@EventHandler
|
||||
void onPlayerInteract(PlayerInteractEvent event) {
|
||||
final UUID playerUuid = event.getPlayer().getUniqueId();
|
||||
|
||||
|
||||
if (interactMillisList.get(playerUuid) != null) {
|
||||
final long millisDifference = System.currentTimeMillis() - interactMillisList.get(playerUuid);
|
||||
|
||||
|
||||
if (millisDifference < 150) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interactMillisList.put(playerUuid, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,33 @@
|
|||
package pw.kaboom.extras.modules.server;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
import pw.kaboom.extras.Main;
|
||||
|
||||
public class ServerCommand implements Listener {
|
||||
public static HashSet<String> consoleCommandBlacklist = new HashSet<String>();
|
||||
|
||||
public static String checkCommand(CommandSender sender, String command, boolean isConsoleCommand) {
|
||||
final String[] arr = command.split(" ");
|
||||
String commandName = arr[0].toLowerCase();
|
||||
|
||||
|
||||
if (isConsoleCommand) {
|
||||
commandName = "/" + arr[0].toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
switch (commandName) {
|
||||
case "/minecraft:execute":
|
||||
case "/execute":
|
||||
if (arr.length >= 2) {
|
||||
int asAtCount = 0;
|
||||
|
||||
|
||||
for (int i = 1; i < arr.length; i++) {
|
||||
if ("run".equalsIgnoreCase(arr[i])) {
|
||||
if (i+1 < arr.length) {
|
||||
|
@ -57,13 +56,13 @@ public class ServerCommand implements Listener {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ("as".equalsIgnoreCase(arr[i]) ||
|
||||
"at".equalsIgnoreCase(arr[i])) {
|
||||
asAtCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (asAtCount >= 2) {
|
||||
Command.broadcastCommandMessage(sender, "Forbidden execute pattern detected");
|
||||
return "cancel";
|
||||
|
@ -155,7 +154,7 @@ public class ServerCommand implements Listener {
|
|||
final String[] arr = event.getCommand().split(" ");
|
||||
|
||||
if (sender instanceof BlockCommandSender) {
|
||||
if (Main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
|
||||
if (consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +162,7 @@ public class ServerCommand implements Listener {
|
|||
final String command = event.getCommand();
|
||||
final boolean isConsoleCommand = true;
|
||||
final String checkedCommand = checkCommand(sender, command, isConsoleCommand);
|
||||
|
||||
|
||||
if (checkedCommand != null) {
|
||||
if (checkedCommand.equals("cancel")) {
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -13,6 +13,6 @@ public class ServerPing implements Listener {
|
|||
} else {
|
||||
event.setProtocolVersion(event.getClient().getProtocolVersion());
|
||||
}
|
||||
event.setVersion("1.15");
|
||||
event.setVersion("1.15.1");
|
||||
}
|
||||
}
|
||||
|
|
13
suppressions.xml
Normal file
13
suppressions.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE suppressions PUBLIC
|
||||
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
|
||||
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
|
||||
|
||||
<suppressions>
|
||||
<suppress checks="AvoidStarImport" files="."/>
|
||||
<suppress checks="FileTabCharacter" files="."/>
|
||||
<suppress checks="Javadoc" files="."/>
|
||||
<suppress checks="LineLength" files="."/>
|
||||
<suppress checks="NewlineAtEndOfFile" files="."/>
|
||||
</suppressions>
|
Loading…
Reference in a new issue