Code formatting fixes
This commit is contained in:
parent
81240a1763
commit
ef230a47c4
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false">
|
||||
<local-check-config name="maven-checkstyle-plugin checkstyle" location="jar:file:/C:/Users/default.DESKTOP-T6B8368/.m2/repository/com/puppycrawl/tools/checkstyle/8.19/checkstyle-8.19.jar!/sun_checks.xml" type="remote" description="maven-checkstyle-plugin configuration checkstyle">
|
||||
<property name="checkstyle.cache.file" value="${project_loc}/target/checkstyle-cachefile"/>
|
||||
<property name="checkstyle.suppressions.file" value="C:\Users\default.DESKTOP-T6B8368\Documents\Java\eclipse-workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\weapons\com.basistech.m2e.code.quality.checkstyleConfigurator\checkstyle-suppressions-checkstyle.xml"/>
|
||||
<property name="checkstyle.header.file" value="C:\Users\default.DESKTOP-T6B8368\Documents\Java\eclipse-workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\weapons\com.basistech.m2e.code.quality.checkstyleConfigurator\checkstyle-header-checkstyle.txt"/>
|
||||
</local-check-config>
|
||||
<fileset name="java-sources-checkstyle" enabled="true" check-config-name="maven-checkstyle-plugin checkstyle" local="true">
|
||||
<file-match-pattern match-pattern="^src/main/java/.*\.java" include-pattern="true"/>
|
||||
<file-match-pattern match-pattern="^src/main/resources/.*\.properties" include-pattern="true"/>
|
||||
<file-match-pattern match-pattern="^src/test/resources.*\.properties" include-pattern="true"/>
|
||||
</fileset>
|
||||
</fileset-config>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>weapons</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,8 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
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>
|
|
@ -7,6 +7,8 @@
|
|||
<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>
|
||||
|
@ -31,11 +33,6 @@
|
|||
<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>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>checkstyle</id>
|
||||
|
@ -44,21 +41,14 @@
|
|||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<failOnViolation>false</failOnViolation>
|
||||
<suppressionsLocation>
|
||||
suppressions.xml
|
||||
</suppressionsLocation>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</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>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -4,23 +4,24 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
HashSet<BlockFace> faces = new HashSet<>();
|
||||
HashSet<UUID> machineGunActive = new HashSet<>();
|
||||
List<Material> colors = new ArrayList<>();
|
||||
import pw.kaboom.weapons.commands.CommandWeapons;
|
||||
import pw.kaboom.weapons.modules.player.PlayerReceiveWeapon;
|
||||
import pw.kaboom.weapons.modules.player.PlayerUseWeapon;
|
||||
import pw.kaboom.weapons.modules.weapons.*;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
private static HashSet<BlockFace> blockFaces = new HashSet<>();
|
||||
private static List<Material> colors = new ArrayList<>();
|
||||
|
||||
public void onLoad() {
|
||||
/* Fill lists */
|
||||
Collections.addAll(
|
||||
faces,
|
||||
blockFaces,
|
||||
BlockFace.NORTH,
|
||||
BlockFace.SOUTH,
|
||||
BlockFace.WEST,
|
||||
|
@ -61,8 +62,16 @@ public class Main extends JavaPlugin {
|
|||
/* Weapon Events */
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponArcher(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponArmageddon(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponBlobinator(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponBlobinator(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponGrenade(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponMachineGun(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new WeaponMachineGun(), this);
|
||||
}
|
||||
|
||||
public static HashSet<BlockFace> getBlockFaces() {
|
||||
return blockFaces;
|
||||
}
|
||||
|
||||
public static List<Material> getColors() {
|
||||
return colors;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
class CommandWeapons implements CommandExecutor {
|
||||
private void addWeapon(Inventory inventory, Material material, String name) {
|
||||
final ItemStack item = new ItemStack(material, 1);
|
||||
public final class CommandWeapons implements CommandExecutor {
|
||||
private void addWeapon(final Inventory inventory, final Material material, final String name) {
|
||||
final ItemStack item = new ItemStack(material, 1);
|
||||
final ItemMeta itemMeta = item.getItemMeta();
|
||||
|
||||
itemMeta.setDisplayName(name);
|
||||
|
@ -24,23 +21,23 @@ class CommandWeapons implements CommandExecutor {
|
|||
inventory.addItem(item);
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
sender.sendMessage("Command has to be run by a player");
|
||||
} else {
|
||||
final Player player = (Player) sender;
|
||||
final Inventory inventory = Bukkit.createInventory(null, 18, "Weapons");
|
||||
|
||||
addWeapon(inventory, Material.ANVIL, "§rAnvil Dropper");
|
||||
addWeapon(inventory, Material.SPECTRAL_ARROW, "§rArcher");
|
||||
addWeapon(inventory, Material.FIRE_CHARGE, "§rArmageddon");
|
||||
addWeapon(inventory, Material.MAGMA_CREAM, "§rBlobinator");
|
||||
addWeapon(inventory, Material.EGG, "§rGrenade");
|
||||
addWeapon(inventory, Material.BLAZE_POWDER, "§rLaser");
|
||||
addWeapon(inventory, Material.STICK, "§rLightning Stick");
|
||||
addWeapon(inventory, Material.GOLDEN_HORSE_ARMOR, "§rMachine Gun");
|
||||
addWeapon(inventory, Material.BLAZE_ROD, "§rNuker");
|
||||
addWeapon(inventory, Material.IRON_HORSE_ARMOR, "§rSniper");
|
||||
|
||||
addWeapon(inventory, Material.ANVIL, "\\\\u00A7rAnvil Dropper");
|
||||
addWeapon(inventory, Material.SPECTRAL_ARROW, "\\\\u00A7rArcher");
|
||||
addWeapon(inventory, Material.FIRE_CHARGE, "\\\\u00A7rArmageddon");
|
||||
addWeapon(inventory, Material.MAGMA_CREAM, "\\\\u00A7rBlobinator");
|
||||
addWeapon(inventory, Material.EGG, "\\\\u00A7rGrenade");
|
||||
addWeapon(inventory, Material.BLAZE_POWDER, "\\\\u00A7rLaser");
|
||||
addWeapon(inventory, Material.STICK, "\\\\u00A7rLightning Stick");
|
||||
addWeapon(inventory, Material.GOLDEN_HORSE_ARMOR, "\\\\u00A7rMachine Gun");
|
||||
addWeapon(inventory, Material.BLAZE_ROD, "\\\\u00A7rNuker");
|
||||
addWeapon(inventory, Material.IRON_HORSE_ARMOR, "\\\\u00A7rSniper");
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
class PlayerReceiveWeapon implements Listener {
|
||||
public final class PlayerReceiveWeapon implements Listener {
|
||||
@EventHandler
|
||||
void onInventoryClick(InventoryClickEvent event) {
|
||||
void onInventoryClick(final InventoryClickEvent event) {
|
||||
if ("Weapons".equals(event.getView().getTitle())) {
|
||||
final ItemStack item = event.getCurrentItem();
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
|
@ -21,3 +19,4 @@ class PlayerReceiveWeapon implements Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.player;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
class PlayerUseWeapon implements Listener {
|
||||
import pw.kaboom.weapons.modules.weapons.*;
|
||||
|
||||
public final class PlayerUseWeapon implements Listener {
|
||||
@EventHandler
|
||||
void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.hasItem() &&
|
||||
event.getItem().getItemMeta().hasDisplayName()) {
|
||||
void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
if (event.hasItem()
|
||||
&& event.getItem().getItemMeta().hasDisplayName()) {
|
||||
final Action action = event.getAction();
|
||||
final Material item = event.getMaterial();
|
||||
final String name = event.getItem().getItemMeta().getDisplayName();
|
||||
|
||||
if (action == Action.LEFT_CLICK_AIR ||
|
||||
action == Action.LEFT_CLICK_BLOCK) {
|
||||
if (action == Action.LEFT_CLICK_AIR
|
||||
|| action == Action.LEFT_CLICK_BLOCK) {
|
||||
WeaponAnvilDropper.leftClick(item, name, event);
|
||||
WeaponArcher.leftClick(item, name, event);
|
||||
WeaponArmageddon.leftClick(item, name, event);
|
||||
|
@ -27,8 +26,8 @@ class PlayerUseWeapon implements Listener {
|
|||
WeaponLightningStick.leftClick(item, name, event);
|
||||
WeaponNuker.leftClick(item, name, event);
|
||||
WeaponSniper.leftClick(item, name, event);
|
||||
} else if (action == Action.RIGHT_CLICK_AIR ||
|
||||
action == Action.RIGHT_CLICK_BLOCK) {
|
||||
} else if (action == Action.RIGHT_CLICK_AIR
|
||||
|| action == Action.RIGHT_CLICK_BLOCK) {
|
||||
WeaponGrenade.rightClick(item, name, event);
|
||||
WeaponLaser.rightClick(item, name, event);
|
||||
WeaponMachineGun.rightClick(item, name, event);
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
class WeaponAnvilDropper {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.ANVIL &&
|
||||
"§rAnvil Dropper".equals(name)) {
|
||||
for (int x = -2; x <= 2; x++) {
|
||||
for (int z = -2; z <= 2; z++) {
|
||||
public final class WeaponAnvilDropper {
|
||||
private WeaponAnvilDropper() {
|
||||
}
|
||||
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.ANVIL
|
||||
&& "\\\\u00A7rAnvil Dropper".equals(name)) {
|
||||
final int min = -2;
|
||||
final int max = 2;
|
||||
|
||||
for (int x = min; x <= max; x++) {
|
||||
for (int z = min; z <= max; z++) {
|
||||
final Location blockLocation = event.getPlayer().getLocation().subtract(x, 0, z);
|
||||
final World world = event.getPlayer().getWorld();
|
||||
|
||||
|
@ -24,4 +29,4 @@ class WeaponAnvilDropper {
|
|||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,31 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.SpectralArrow;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
|
||||
class WeaponArcher implements Listener {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.SPECTRAL_ARROW &&
|
||||
"§rArcher".equals(name)) {
|
||||
public final class WeaponArcher implements Listener {
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.SPECTRAL_ARROW
|
||||
&& "\\\\u00A7rArcher".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final World world = player.getWorld();
|
||||
|
||||
for (int i = 0; i <= 20; i++) {
|
||||
final int maxArrowCount = 20;
|
||||
|
||||
for (int i = 0; i <= maxArrowCount; i++) {
|
||||
final double randomX = (Math.random() * ((15 + 15) + 1)) - 15;
|
||||
final double randomY = (Math.random() * ((15 + 15) + 1)) - 15;
|
||||
final double randomZ = (Math.random() * ((15 + 15) + 1)) - 15;
|
||||
|
@ -61,16 +60,16 @@ class WeaponArcher implements Listener {
|
|||
|
||||
/* Make shooter invulnerable to weapon projectiles */
|
||||
@EventHandler
|
||||
void onProjectileCollide(ProjectileCollideEvent event) {
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.SPECTRAL_ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponArcherArrow".equals(projectile.getCustomName())) {
|
||||
final Entity collidedWith = event.getCollidedWith();
|
||||
|
||||
if (collidedWith.getType() == EntityType.PLAYER &&
|
||||
projectile.getShooter() instanceof Player &&
|
||||
((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
|
||||
if (collidedWith.getType() == EntityType.PLAYER
|
||||
&& projectile.getShooter() instanceof Player
|
||||
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +1,40 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
|
||||
class WeaponArmageddon implements Listener {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.FIRE_CHARGE &&
|
||||
"§rArmageddon".equals(name)) {
|
||||
public final class WeaponArmageddon implements Listener {
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.FIRE_CHARGE
|
||||
&& "\\\\u00A7rArmageddon".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final World world = player.getWorld();
|
||||
|
||||
for (int i = -12; i <= 12; i += 4) {
|
||||
final int min = -12;
|
||||
final int max = 12;
|
||||
final int iteratorSpacing = 4;
|
||||
|
||||
for (int i = min; i <= max; i += iteratorSpacing) {
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
|
||||
final double x = i * Math.cos(Math.toRadians(eyeLocation.getYaw()));
|
||||
final double z = i * Math.sin(Math.toRadians(eyeLocation.getYaw()));
|
||||
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
final int yield = 5;
|
||||
|
||||
final Fireball fireball = (Fireball) world.spawnEntity(
|
||||
eyeLocation.add(x, 0, z),
|
||||
|
@ -43,7 +45,7 @@ class WeaponArmageddon implements Listener {
|
|||
fireball.setCustomName("WeaponArmegaddonCharge");
|
||||
fireball.setDirection(velocity);
|
||||
fireball.setShooter(player);
|
||||
fireball.setYield(5);
|
||||
fireball.setYield(yield);
|
||||
}
|
||||
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
|
@ -62,17 +64,17 @@ class WeaponArmageddon implements Listener {
|
|||
|
||||
/* Make shooter invulnerable to weapon projectiles, and prevent charges from colliding with each other */
|
||||
@EventHandler
|
||||
void onProjectileCollide(ProjectileCollideEvent event) {
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.FIREBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponArmegaddonCharge".equals(projectile.getCustomName())) {
|
||||
final Entity collidedWith = event.getCollidedWith();
|
||||
|
||||
if ((collidedWith.getType() == EntityType.PLAYER &&
|
||||
projectile.getShooter() instanceof Player &&
|
||||
((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) ||
|
||||
collidedWith.getType() == EntityType.FIREBALL) {
|
||||
if ((collidedWith.getType() == EntityType.PLAYER
|
||||
&& projectile.getShooter() instanceof Player
|
||||
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId()))
|
||||
|| collidedWith.getType() == EntityType.FIREBALL) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
42
src/main/java/pw/kaboom/weapons/modules/weapons/WeaponBlobinator.java
Normal file → Executable file
42
src/main/java/pw/kaboom/weapons/modules/weapons/WeaponBlobinator.java
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -6,33 +6,25 @@ import org.bukkit.Location;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Snowball;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
import pw.kaboom.weapons.Main;
|
||||
|
||||
class WeaponBlobinator implements Listener {
|
||||
Main main;
|
||||
WeaponBlobinator(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.MAGMA_CREAM &&
|
||||
"§rBlobinator".equals(name)) {
|
||||
public final class WeaponBlobinator implements Listener {
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.MAGMA_CREAM
|
||||
&& "\\\\u00A7rBlobinator".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(8);
|
||||
|
@ -56,17 +48,17 @@ class WeaponBlobinator implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
private void createBlobSplash(World world, int x, int y, int z, int radius, Block hitBlock, Material color) {
|
||||
private void createBlobSplash(final World world, final int x, final int y, final int z, final int radius, final Block hitBlock, final Material color) {
|
||||
final Location blockLocation = hitBlock.getLocation().add(x, y, z);
|
||||
|
||||
if (blockLocation.distance(hitBlock.getLocation()) <= radius) {
|
||||
final Block block = world.getBlockAt(blockLocation);
|
||||
|
||||
if (block.getType() != Material.AIR &&
|
||||
block.getType() != Material.CAVE_AIR) {
|
||||
for (BlockFace face : main.faces) {
|
||||
if (block.getRelative(face).getType() == Material.AIR ||
|
||||
block.getRelative(face).getType() == Material.CAVE_AIR) {
|
||||
if (block.getType() != Material.AIR
|
||||
&& block.getType() != Material.CAVE_AIR) {
|
||||
for (BlockFace face : Main.getBlockFaces()) {
|
||||
if (block.getRelative(face).getType() == Material.AIR
|
||||
|| block.getRelative(face).getType() == Material.CAVE_AIR) {
|
||||
block.setType(color);
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +67,7 @@ class WeaponBlobinator implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onProjectileCollide(ProjectileCollideEvent event) {
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.SNOWBALL) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
|
@ -86,17 +78,17 @@ class WeaponBlobinator implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onProjectileHit(ProjectileHitEvent event) {
|
||||
private void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.SNOWBALL) {
|
||||
final Block hitBlock = event.getHitBlock();
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if (hitBlock != null &&
|
||||
"WeaponBlobinatorBall".equals(projectile.getCustomName())) {
|
||||
if (hitBlock != null
|
||||
&& "WeaponBlobinatorBall".equals(projectile.getCustomName())) {
|
||||
final int radius = 4;
|
||||
final World world = projectile.getWorld();
|
||||
final Random random = new Random();
|
||||
final Material color = main.colors.get(random.nextInt(main.colors.size()));
|
||||
final Material color = Main.getColors().get(random.nextInt(Main.getColors().size()));
|
||||
|
||||
for (int x = -radius; x < radius; x++) {
|
||||
for (int y = -radius; y < radius; y++) {
|
||||
|
|
|
@ -1,27 +1,23 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class WeaponGrenade implements Listener {
|
||||
static void rightClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.EGG &&
|
||||
"§rGrenade".equals(name)) {
|
||||
public final class WeaponGrenade implements Listener {
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.EGG
|
||||
&& "\\u00A7rGrenade".equals(name)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
|
@ -30,7 +26,7 @@ class WeaponGrenade implements Listener {
|
|||
final Egg egg = player.launchProjectile(Egg.class);
|
||||
egg.setCustomName("WeaponGrenade");
|
||||
egg.setShooter(player);
|
||||
|
||||
|
||||
final World world = player.getWorld();
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 1.0F;
|
||||
|
@ -45,14 +41,14 @@ class WeaponGrenade implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
||||
private void onPlayerEggThrow(final PlayerEggThrowEvent event) {
|
||||
if ("WeaponGrenade".equals(event.getEgg().getCustomName())) {
|
||||
event.setHatching(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
void onProjectileHit(ProjectileHitEvent event) {
|
||||
private void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.EGG) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -11,16 +9,18 @@ import org.bukkit.Sound;
|
|||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class WeaponLaser {
|
||||
static void rightClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_POWDER &&
|
||||
"§rLaser".equals(name)) {
|
||||
public final class WeaponLaser {
|
||||
private WeaponLaser() {
|
||||
}
|
||||
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_POWDER
|
||||
&& "\\\\u00A7rLaser".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector direction = eyeLocation.getDirection();
|
||||
|
@ -64,13 +64,13 @@ class WeaponLaser {
|
|||
yOffset,
|
||||
distance
|
||||
);
|
||||
|
||||
|
||||
while (blockIterator.hasNext()) {
|
||||
blockIterator.next().breakNaturally();
|
||||
}
|
||||
|
||||
float volume = 0.8F;
|
||||
float pitch = 63.0F;
|
||||
final float volume = 0.8F;
|
||||
final float pitch = 63.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
|
@ -79,14 +79,14 @@ class WeaponLaser {
|
|||
pitch
|
||||
);
|
||||
|
||||
volume = 1.0F;
|
||||
pitch = 20.0F;
|
||||
final float volume2 = 1.0F;
|
||||
final float pitch2 = 20.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_FIREWORK_ROCKET_BLAST,
|
||||
volume,
|
||||
pitch
|
||||
volume2,
|
||||
pitch2
|
||||
);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
|
17
src/main/java/pw/kaboom/weapons/modules/weapons/WeaponLightningStick.java
Normal file → Executable file
17
src/main/java/pw/kaboom/weapons/modules/weapons/WeaponLightningStick.java
Normal file → Executable file
|
@ -1,18 +1,21 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
class WeaponLightningStick {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.STICK &&
|
||||
"§rLightning Stick".equals(name)) {
|
||||
final Location lookLocation = event.getPlayer().getTargetBlock((Set<Material>) null, 100).getLocation();
|
||||
public final class WeaponLightningStick {
|
||||
private WeaponLightningStick() {
|
||||
}
|
||||
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.STICK
|
||||
&& "\\\\u00A7rLightning Stick".equals(name)) {
|
||||
final int maxDistance = 100;
|
||||
final Location lookLocation = event.getPlayer().getTargetBlock((Set<Material>) null, maxDistance).getLocation();
|
||||
final World world = event.getPlayer().getWorld();
|
||||
|
||||
world.strikeLightning(lookLocation);
|
||||
|
|
123
src/main/java/pw/kaboom/weapons/modules/weapons/WeaponMachineGun.java
Normal file → Executable file
123
src/main/java/pw/kaboom/weapons/modules/weapons/WeaponMachineGun.java
Normal file → Executable file
|
@ -1,95 +1,84 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TippedArrow;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
|
||||
import pw.kaboom.weapons.Main;
|
||||
|
||||
class WeaponMachineGun implements Listener {
|
||||
static Main main;
|
||||
WeaponMachineGun(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
public final class WeaponMachineGun implements Listener {
|
||||
private static HashSet<UUID> machineGunActive = new HashSet<>();
|
||||
|
||||
static void rightClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.GOLDEN_HORSE_ARMOR &&
|
||||
"§rMachine Gun".equals(name)) {
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.GOLDEN_HORSE_ARMOR
|
||||
&& "\\\\u00A7rMachine Gun".equals(name)) {
|
||||
final UUID playerUUID = event.getPlayer().getUniqueId();
|
||||
|
||||
if (!main.machineGunActive.contains(playerUUID)) {
|
||||
main.machineGunActive.add(playerUUID);
|
||||
final PlayerInteractEvent eventMachine = event;
|
||||
if (!machineGunActive.contains(playerUUID)) {
|
||||
machineGunActive.add(playerUUID);
|
||||
final int maxBulletCount = 20;
|
||||
|
||||
new BukkitRunnable() {
|
||||
int i = 0;
|
||||
public void run() {
|
||||
i++;
|
||||
for (int i = 0; i < maxBulletCount; i++) {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
|
||||
final Player player = eventMachine.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final World world = player.getWorld();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
final TippedArrow arrow = player.launchProjectile(TippedArrow.class);
|
||||
|
||||
final TippedArrow arrow = player.launchProjectile(TippedArrow.class);
|
||||
|
||||
final int duration = 90000;
|
||||
final int amplifier = 3;
|
||||
final boolean ambient = true;
|
||||
final boolean particles = false;
|
||||
|
||||
final PotionEffect harm = new PotionEffect(
|
||||
PotionEffectType.HARM,
|
||||
duration,
|
||||
amplifier,
|
||||
ambient,
|
||||
particles
|
||||
);
|
||||
|
||||
arrow.setCustomName("WeaponMachineGunBullet");
|
||||
arrow.addCustomEffect(harm, true);
|
||||
arrow.setShooter(player);
|
||||
arrow.setVelocity(velocity);
|
||||
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 63.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GENERIC_EXPLODE,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
|
||||
if (i == 20) {
|
||||
main.machineGunActive.remove(playerUUID);
|
||||
cancel();
|
||||
final int duration = 90000;
|
||||
final int amplifier = 3;
|
||||
final boolean ambient = true;
|
||||
final boolean particles = false;
|
||||
|
||||
final PotionEffect harm = new PotionEffect(
|
||||
PotionEffectType.HARM,
|
||||
duration,
|
||||
amplifier,
|
||||
ambient,
|
||||
particles
|
||||
);
|
||||
|
||||
arrow.setCustomName("WeaponMachineGunBullet");
|
||||
arrow.addCustomEffect(harm, true);
|
||||
arrow.setShooter(player);
|
||||
arrow.setVelocity(velocity);
|
||||
|
||||
final float volume = 1.0F;
|
||||
final float pitch = 63.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GENERIC_EXPLODE,
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(main, 0L, 1L);
|
||||
}.runTask(JavaPlugin.getPlugin(Main.class));
|
||||
}
|
||||
|
||||
machineGunActive.remove(playerUUID);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -97,16 +86,16 @@ class WeaponMachineGun implements Listener {
|
|||
|
||||
/* Make shooter invulnerable to weapon projectiles */
|
||||
@EventHandler
|
||||
void onProjectileCollide(ProjectileCollideEvent event) {
|
||||
private void onProjectileCollide(final ProjectileCollideEvent event) {
|
||||
if (event.getEntityType() == EntityType.TIPPED_ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
if ("WeaponMachineGunBullet".equals(projectile.getCustomName())) {
|
||||
final Entity collidedWith = event.getCollidedWith();
|
||||
|
||||
if (collidedWith.getType() == EntityType.PLAYER &&
|
||||
projectile.getShooter() instanceof Player &&
|
||||
((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
|
||||
if (collidedWith.getType() == EntityType.PLAYER
|
||||
&& projectile.getShooter() instanceof Player
|
||||
&& ((Player) projectile.getShooter()).getUniqueId().equals(collidedWith.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +103,7 @@ class WeaponMachineGun implements Listener {
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
void onProjectileHit(ProjectileHitEvent event) {
|
||||
private void onProjectileHit(final ProjectileHitEvent event) {
|
||||
if (event.getEntityType() == EntityType.TIPPED_ARROW) {
|
||||
final Projectile projectile = event.getEntity();
|
||||
|
||||
|
|
|
@ -1,43 +1,45 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class WeaponNuker {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_ROD &&
|
||||
"§rNuker".equals(name)) {
|
||||
public final class WeaponNuker {
|
||||
private WeaponNuker() {
|
||||
}
|
||||
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.BLAZE_ROD
|
||||
&& "\\\\u00A7rNuker".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(10);
|
||||
final int yield = 8;
|
||||
|
||||
final Fireball fireball = player.launchProjectile(Fireball.class);
|
||||
fireball.setShooter(player);
|
||||
fireball.setVelocity(velocity);
|
||||
fireball.setYield(8);
|
||||
fireball.setYield(yield);
|
||||
|
||||
final World world = player.getWorld();
|
||||
final float volume1 = 0.9F;
|
||||
final float pitch1 = 1.5F;
|
||||
final float volume2 = 0.8F;
|
||||
final float pitch2 = 2.0F;
|
||||
final float volume = 0.9F;
|
||||
final float pitch = 1.5F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_GHAST_SHOOT,
|
||||
volume1,
|
||||
pitch1
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
|
||||
|
||||
final float volume2 = 0.8F;
|
||||
final float pitch2 = 2.0F;
|
||||
|
||||
world.playSound(
|
||||
eyeLocation,
|
||||
Sound.ENTITY_BAT_TAKEOFF,
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
package pw.kaboom.weapons;
|
||||
package pw.kaboom.weapons.modules.weapons;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowball;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class WeaponSniper {
|
||||
static void leftClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR &&
|
||||
"§rSniper".equals(name)) {
|
||||
public final class WeaponSniper {
|
||||
private WeaponSniper() {
|
||||
}
|
||||
|
||||
public static void leftClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR
|
||||
&& "\\\\u00A7rSniper".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final Vector velocity = eyeLocation.getDirection().multiply(12);
|
||||
|
@ -41,11 +40,11 @@ class WeaponSniper {
|
|||
}
|
||||
}
|
||||
|
||||
static void rightClick(Material item, String name, PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR &&
|
||||
"§rSniper".equals(name)) {
|
||||
public static void rightClick(final Material item, final String name, final PlayerInteractEvent event) {
|
||||
if (item == Material.IRON_HORSE_ARMOR
|
||||
&& "\\\\u00A7rSniper".equals(name)) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
|
||||
if (player.hasPotionEffect(PotionEffectType.SLOW)) {
|
||||
player.removePotionEffect(PotionEffectType.SLOW);
|
||||
} else {
|
||||
|
|
|
@ -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 New Issue