For Spigot 1.14.4+

## General Gameplay
### Additions
- Added default Suffocate cooldown: 6.5 seconds
- Added kinetic damage tracker to AirSweep
- Added self and others push strength options for AirSuction
- Added config option for multiple blocks to be changed per EarthTunnel run, allowing for much faster earth tunnels
- Added config to ignore ores completely for EarthTunnel (good for mining)
- Added AllowSnow config option for IceBlast
- Added AvatarStateCooldown config options for IceBlast and IceBullet
- Added config option for ice trapping abilities to not place blocks in players head or feet
### Fixes
- Fixed preset command not allowing page numbers higher than 1
- Fixed Catapult and MetalClips not respecting /b invincible
- Fixed Charged FireBlast radius and cooldown
- Fixed Suffocate being usable through walls
- Fixed FireBlast ignoring particle radius options
- Fixed FireBurst fragmenting (not looking like a single burst)
- Fixed AirSweep knockback to be more consistent (lessened friction)
- Fixed AirBlast knockback using wrong push options
- Fixed EarthSmash using nonexistent AvatarState options
- Fixed error when switching worlds with PhaseChange active
- Fixed server crash when hitting falling blocks with high-velocity abilities
- Fixed server crash when using EarthGrab over the void
- Fixed EarthTunnel not using configurable revert time
- Fixed EarthPillars persisting when no entities were around
### Changes
- Improved pathing for EarthBlast; works more consistently and can be used from ceilings
- Improved aiming for EarthBlast and IceBlast
- Changed AirSwipe and AirSweep to originate from the player’s main hand
- Changed AirBlast knockback calculations; made the push options affect knockback more directly
- Changed EarthTunnel to use tempblocks properly
- Moved core combo instructions to config
### Removals
- Removed being able to use Lightning while using FireJet
- Removed jukeboxes being tempblocks
- Removed bending.command.import permission from plugin.yml

## API
### Additions
- Added GeneralMethods#getMainHandLocation(Player)
- Added GeneralMethods#getClosestEntity(Location, double)
- Added GeneralMethods#getClosestLivingEntity(Location, double)
- Added "large" abilities collision with each other
- Added specific timings for hot spots in the code that should help server owners diagnose lag from PK
  + player move event
  + physics event
  + bending manager
- Created local folder repo and update pom for local jar files, this is necessary to use the maven shade plugin.
- Added check for concrete powder in move earth
- Added PlaceholderAPI support (hopefully more to come)
  + %projectkorra_slot<1-9>% ability on slot <1-9>
  + %projectkorra_element% element of the player
  + %projectkorra_elementcolor% color of the player’s element
  + %projectkorra_elements% elements the player has
- Added "bending" WorldGuard flag. 
  + Used for allowing or denying bending in worldguard regions. Will fall back to the old method of the build flag if the custom flag fails to register or isn't set
### Fixes
- Fixed calls to CoreAbility#isEnabled() causing NullPointerExceptions when a CoreAbility is not enabled
### Changes
- Changed CoreAbility#getAbility(..) Javadocs to state when it returns null
- Formatted codebase
- Changed GeneralMethods#getEntitiesAroundPoint() use spigot method for entities around point, should be more optimized
- Optimizations to water and air spout to not continually set flying
- Optimized revertchecker to not use block.getChunk; this will load the chunk on the server and instead use hashmap of coords
- Optimized revertchecker to use paperlib to allow servers running paperspigot to load the chunk for a revert block async
- Optimized tempblock revert to load chunk async before updating stateOptimize move event to ignore head movements without directional movement
- Optimized physics event to check for air prior to checking for tempblocks
- Optimized tempblock set/revert to not apply physics for blocks that don't emit light
- Optimize isWater to check for actual water blocks first
- Optimize PhaseChange list check, hot spot due to being called in physics event
### Removals
- Removed BindChangeEvent; never called or used
- Removed HorizontalVelocityTracker that has lasted over 30 seconds, also don't create a tracker for non-living entities
This commit is contained in:
Christopher Martin 2019-12-09 23:03:28 -08:00 committed by GitHub
parent 9ae9c07c7e
commit c12e0daebb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
214 changed files with 4942 additions and 5402 deletions

View file

@ -2,7 +2,7 @@ language: java
script: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V script: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
sudo: false sudo: false
jdk: jdk:
- oraclejdk8 - openjdk8
notifications: notifications:
slack: slack:
rooms: rooms:

View file

@ -1,7 +0,0 @@
<?xml version="1.0" ?>
<!-- Configuration of the Ant build system to generate a Jar file -->
<project name="ProjectKorra" default="CreateJar">
<target name="CreateJar" description="Create Jar file">
<jar jarfile="../../test/server/plugins/ProjectKorra.jar" basedir="../../bin/" includes="**/*" />
</target>
</project>

View file

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/ProjectKorra"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot; javaProject=&quot;ProjectKorra&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/ProjectKorra/test/server/spigot-1.8.8.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.bukkit.craftbukkit.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="ProjectKorra"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:ProjectKorra}/test/server/"/>
</launchConfiguration>

View file

@ -1,8 +0,0 @@
#Organize Import Order
#Sun Aug 02 18:33:53 NZST 2015
5=javax
4=java
3=org
2=com
1=
0=\#

View file

@ -1,295 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="ProjectKorra" version="12">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="100"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
</profile>
</profiles>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>br.net.fabiozumbi12</groupId>
<artifactId>RedProtect</artifactId>
<version>7.5.5</version>
<description>POM was created from install:install-file</description>
</project>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>br.net.fabiozumbi12</groupId>
<artifactId>RedProtect</artifactId>
<versioning>
<release>7.5.5</release>
<versions>
<version>7.5.5</version>
</versions>
<lastUpdated>20190223101710</lastUpdated>
</versioning>
</metadata>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bekvon.bukkit</groupId>
<artifactId>residence</artifactId>
<version>4.8.3.1</version>
<description>POM was created from install:install-file</description>
</project>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.bekvon.bukkit</groupId>
<artifactId>residence</artifactId>
<versioning>
<release>4.8.3.1</release>
<versions>
<version>4.8.3.1</version>
</versions>
<lastUpdated>20190223101425</lastUpdated>
</versioning>
</metadata>

Binary file not shown.

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.griefcraft</groupId>
<artifactId>lwc</artifactId>
<version>2.1.2</version>
<description>POM was created from install:install-file</description>
</project>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.griefcraft</groupId>
<artifactId>lwc</artifactId>
<versioning>
<release>2.1.2</release>
<versions>
<version>2.1.2</version>
</versions>
<lastUpdated>20190223101300</lastUpdated>
</versioning>
</metadata>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.palmergames</groupId>
<artifactId>Towny</artifactId>
<version>0.93.0.0</version>
<description>POM was created from install:install-file</description>
</project>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.palmergames</groupId>
<artifactId>Towny</artifactId>
<versioning>
<release>0.93.0.0</release>
<versions>
<version>0.93.0.0</version>
</versions>
<lastUpdated>20190223101606</lastUpdated>
</versioning>
</metadata>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>kingdoms</artifactId>
<version>1.2.3</version>
<description>POM was created from install:install-file</description>
</project>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.songoda</groupId>
<artifactId>kingdoms</artifactId>
<versioning>
<release>1.2.3</release>
<versions>
<version>1.2.3</version>
</versions>
<lastUpdated>20190223101813</lastUpdated>
</versioning>
</metadata>

View file

@ -0,0 +1 @@
333673ff2f0740caad4889dcaa4840d4

View file

@ -0,0 +1 @@
3869ec4128db113162c54a11d0010a002ed3b5ee

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>me.markeh</groupId>
<artifactId>factionsframework</artifactId>
<version>1.2.0</version>
</project>

View file

@ -0,0 +1 @@
1fe23316d4e93edea247dd0e49a73cee

View file

@ -0,0 +1 @@
fa0e391fae40a538a5b3223ad3b3b01990c0afe6

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>me.markeh</groupId>
<artifactId>factionsframework</artifactId>
<versioning>
<release>1.2.0</release>
<versions>
<version>1.2.0</version>
</versions>
<lastUpdated>20190223095944</lastUpdated>
</versioning>
</metadata>

View file

@ -0,0 +1 @@
f381f9c9b67641659a289a4e6ed63a25

View file

@ -0,0 +1 @@
8ced509852cc7dd171ce85c9eb439969b9af1ce1

283
pom.xml
View file

@ -1,143 +1,178 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.projectkorra</groupId> <groupId>com.projectkorra</groupId>
<artifactId>projectkorra</artifactId> <artifactId>projectkorra</artifactId>
<version>1.8.7</version> <version>1.8.9</version>
<packaging>jar</packaging>
<name>ProjectKorra</name> <name>ProjectKorra</name>
<repositories> <repositories>
<!-- local jar files, add more using: mvn install:install-file -Dfile=aaa.jar -DgroupId=aaa -DartifactId=aaa -Dversion=aaa -Dpackaging=jar -DlocalRepositoryPath=path/to/ProjectKorra/localrepo/ -->
<repository>
<id>project.local</id>
<name>project</name>
<url>file://${project.basedir}/localrepo/</url>
</repository>
<!-- WorldGuard and WorldEdit Repo -->
<repository>
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
<!-- GriefPrevention Repo -->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<!-- NoCheat Repo -->
<repository>
<id>md_5-snapshots</id>
<url>https://repo.md-5.net/content/repositories/snapshots/</url>
</repository>
<!-- Spigot Repo -->
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<!-- Aikars Repo -->
<repository>
<id>aikar</id>
<url>http://repo.aikar.co/nexus/content/groups/aikar/</url>
</repository>
<!-- Paper Repo -->
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<!-- Placeholder API Repo -->
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<!-- Spigot API --> <!-- PaperLib -->
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>io.papermc</groupId>
<artifactId>Spigot-Server</artifactId> <artifactId>paperlib</artifactId>
<version>LATEST</version> <version>1.0.1</version>
<scope>system</scope> </dependency>
<systemPath>${project.basedir}/lib/spigot-1.12.1.jar</systemPath> <!-- Minecraft Timings -->
<dependency>
<groupId>co.aikar</groupId>
<artifactId>minecraft-timings</artifactId>
<version>1.0.4</version>
</dependency>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency> </dependency>
<!-- Factions --> <!-- Factions -->
<dependency> <dependency>
<groupId>com.massivecraft</groupId> <groupId>me.markeh</groupId>
<artifactId>factions</artifactId> <artifactId>factionsframework</artifactId>
<version>LATEST</version> <version>1.2.0</version>
<scope>system</scope> <scope>provided</scope>
<systemPath>${project.basedir}/lib/Factions 2.7.5.jar</systemPath> </dependency>
</dependency> <!-- GriefPrevention -->
<!-- GriefPrevention -->
<dependency> <dependency>
<groupId>me.ryanhamshire</groupId> <groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId> <artifactId>GriefPrevention</artifactId>
<version>LATEST</version> <version>16.7.1</version>
<scope>system</scope> <scope>provided</scope>
<systemPath>${project.basedir}/lib/GriefPrevention 10.5.3.jar</systemPath>
</dependency> </dependency>
<!-- LWC --> <!-- LWC -->
<dependency> <dependency>
<groupId>com.griefcraft</groupId> <groupId>com.griefcraft</groupId>
<artifactId>lwc</artifactId> <artifactId>lwc</artifactId>
<version>LATEST</version> <version>2.1.2</version>
<scope>system</scope> <scope>provided</scope>
<systemPath>${project.basedir}/lib/LWC.jar</systemPath>
</dependency>
<!-- MassiveCore -->
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>massivecore</artifactId>
<version>LATEST</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/MassiveCore 2.7.5.jar</systemPath>
</dependency> </dependency>
<!-- NoCheatPlus --> <!-- NoCheatPlus -->
<dependency> <dependency>
<groupId>fr.neatmonster</groupId> <groupId>fr.neatmonster</groupId>
<artifactId>nocheatplus</artifactId> <artifactId>nocheatplus</artifactId>
<version>LATEST</version> <version>3.16.1-SNAPSHOT</version>
<scope>system</scope> <scope>provided</scope>
<systemPath>${project.basedir}/lib/NoCheatPlus.jar</systemPath>
</dependency> </dependency>
<!-- PreciousStones --> <!-- PreciousStones -->
<dependency> <!-- outdated
<groupId>net.sacredlabyrinth.Phaed</groupId> <dependency>
<artifactId>PreciousStones</artifactId> <groupId>net.sacredlabyrinth.Phaed</groupId>
<version>LATEST</version> <artifactId>PreciousStones</artifactId>
<scope>system</scope> <version>LATEST</version>
<systemPath>${project.basedir}/lib/PreciousStones 10.6.1.jar</systemPath> <scope>system</scope>
</dependency> <systemPath>${project.basedir}/lib/PreciousStones 10.6.1.jar</systemPath>
<!-- PK RPG --> </dependency>
<dependency> -->
<groupId>com.projectkorra</groupId>
<artifactId>rpg</artifactId>
<version>LATEST</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ProjectKorraRPG.jar</systemPath>
</dependency>
<!-- PK ITEMS -->
<dependency>
<groupId>com.projectkorra</groupId>
<artifactId>items</artifactId>
<version>LATEST</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ProjectKorraItems.jar</systemPath>
</dependency>
<!-- PK Spirits -->
<dependency>
<groupId>com.projectkorra</groupId>
<artifactId>spirits</artifactId>
<version>LATEST</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ProjectKorraSpirits.jar</systemPath>
</dependency>
<!-- Residence --> <!-- Residence -->
<dependency> <dependency>
<groupId>com.bekvon.bukkit</groupId> <groupId>com.bekvon.bukkit</groupId>
<artifactId>residence</artifactId> <artifactId>residence</artifactId>
<version>LATEST</version> <version>4.8.3.1</version>
<scope>system</scope> <scope>provided</scope>
<systemPath>${project.basedir}/lib/Residence4.0.0.4.jar</systemPath>
</dependency> </dependency>
<!-- Towny --> <!-- Towny -->
<dependency> <dependency>
<groupId>com.plamergames.bukkit</groupId> <groupId>com.palmergames</groupId>
<artifactId>Towny</artifactId> <artifactId>Towny</artifactId>
<version>LATEST</version> <version>0.93.0.0</version>
<scope>system</scope> <scope>provided</scope>
<systemPath>${project.basedir}/lib/Towny.jar</systemPath>
</dependency> </dependency>
<!-- WorldGuard --> <!-- WorldEdit / WorldGuard -->
<dependency> <dependency>
<groupId>com.sk89q</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldguard</artifactId> <artifactId>worldedit-core</artifactId>
<version>LATEST</version> <version>7.0.0-SNAPSHOT</version>
<scope>system</scope> <scope>provided</scope>
<systemPath>${project.basedir}/lib/worldguard-6.1.jar</systemPath> </dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId>
<version>7.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
<version>7.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- RedProtect -->
<dependency>
<groupId>br.net.fabiozumbi12</groupId>
<artifactId>RedProtect</artifactId>
<version>7.5.5</version>
<scope>provided</scope>
</dependency> </dependency>
<!-- Kingdoms --> <!-- Kingdoms -->
<dependency> <dependency>
<groupId>org.kingdoms</groupId> <groupId>com.songoda</groupId>
<artifactId>Kingdoms</artifactId> <artifactId>kingdoms</artifactId>
<version>LATEST</version> <version>1.2.3</version>
<scope>system</scope> <scope>provided</scope>
<systemPath>${project.basedir}/lib/Kingdoms.jar</systemPath>
</dependency> </dependency>
<!-- GLib --> <!-- PlaceholderAPI -->
<dependency> <dependency>
<groupId>org.generallib</groupId> <groupId>me.clip</groupId>
<artifactId>GLib</artifactId> <artifactId>placeholderapi</artifactId>
<version>LATEST</version> <version>2.9.2</version>
<scope>system</scope> <scope>provided</scope>
<systemPath>${project.basedir}/lib/GLib.jar</systemPath>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<defaultGoal>clean package install</defaultGoal> <defaultGoal>clean package install</defaultGoal>
<finalName>${project.name}-${project.version}</finalName> <finalName>${project.name}-${project.version}</finalName>
@ -156,29 +191,57 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <version>3.8.0</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-shade-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>2.3</version> <artifactId>maven-jar-plugin</artifactId>
<executions> <version>3.1.1</version>
<execution> <configuration>
<phase>package</phase> <outputDirectory>${dir}</outputDirectory>
<goals> </configuration>
<goal>shade</goal> </plugin>
</goals> <plugin>
</execution> <groupId>org.apache.maven.plugins</groupId>
</executions> <artifactId>maven-shade-plugin</artifactId>
<configuration /> <version>3.2.1</version>
</plugin> <configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>co.aikar.timings.lib</pattern>
<shadedPattern>timingslib.projectkorra</shadedPattern>
</relocation>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>paperlib.projectkorra</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>commonslang3.projectkorra</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<properties> <properties>
<dir>${project.build.directory}</dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
</project> </project>

View file

@ -3,6 +3,8 @@ package com.projectkorra.projectkorra;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
import co.aikar.timings.lib.MCTiming;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.World; import org.bukkit.World;
@ -18,7 +20,6 @@ import com.projectkorra.projectkorra.util.RevertChecker;
import com.projectkorra.projectkorra.util.TempArmor; import com.projectkorra.projectkorra.util.TempArmor;
import com.projectkorra.projectkorra.util.TempPotionEffect; import com.projectkorra.projectkorra.util.TempPotionEffect;
import com.projectkorra.projectkorra.waterbending.blood.Bloodbending; import com.projectkorra.projectkorra.waterbending.blood.Bloodbending;
import com.projectkorra.rpg.RPGMethods;
public class BendingManager implements Runnable { public class BendingManager implements Runnable {
@ -29,9 +30,19 @@ public class BendingManager implements Runnable {
long interval; long interval;
private final HashMap<World, Boolean> times = new HashMap<World, Boolean>(); // true if day time private final HashMap<World, Boolean> times = new HashMap<World, Boolean>(); // true if day time
private final MCTiming CORE_ABILITY_TIMING, TEMP_POTION_TIMING, DAY_NIGHT_TIMING, HORIZONTAL_VELOCITY_TRACKER_TIMING, COOLDOWN_TIMING, TEMP_ARMOR_TIMING, ACTIONBAR_STATUS_TIMING;
public BendingManager() { public BendingManager() {
instance = this; instance = this;
this.time = System.currentTimeMillis(); this.time = System.currentTimeMillis();
this.CORE_ABILITY_TIMING = ProjectKorra.timing("CoreAbility#ProgressAll");
this.TEMP_POTION_TIMING = ProjectKorra.timing("TempPotion#ProgressAll");
this.DAY_NIGHT_TIMING = ProjectKorra.timing("HandleDayNight");
this.HORIZONTAL_VELOCITY_TRACKER_TIMING = ProjectKorra.timing("HorizontalVelocityTracker#UpdateAll");
this.COOLDOWN_TIMING = ProjectKorra.timing("HandleCooldowns");
this.TEMP_ARMOR_TIMING = ProjectKorra.timing("TempArmor#Cleanup");
this.ACTIONBAR_STATUS_TIMING = ProjectKorra.timing("ActionBarCheck");
} }
public static BendingManager getInstance() { public static BendingManager getInstance() {
@ -58,11 +69,6 @@ public class BendingManager implements Runnable {
this.times.put(world, false); this.times.put(world, false);
} }
} else { } else {
if (GeneralMethods.hasRPG()) {
if (RPGMethods.isFullMoon(world) || RPGMethods.isLunarEclipse(world) || RPGMethods.isSolarEclipse(world) || RPGMethods.isSozinsComet(world)) {
continue;
}
}
if (this.times.get(world) && !ElementalAbility.isDay(world)) { if (this.times.get(world) && !ElementalAbility.isDay(world)) {
// The hashmap says it is day, but it is not. // The hashmap says it is day, but it is not.
this.times.put(world, false); // Sets time to night. this.times.put(world, false); // Sets time to night.
@ -103,19 +109,37 @@ public class BendingManager implements Runnable {
@Override @Override
public void run() { public void run() {
try { this.interval = System.currentTimeMillis() - this.time;
this.interval = System.currentTimeMillis() - this.time; this.time = System.currentTimeMillis();
this.time = System.currentTimeMillis(); ProjectKorra.time_step = this.interval;
ProjectKorra.time_step = this.interval;
try (MCTiming timing = this.CORE_ABILITY_TIMING.startTiming()) {
CoreAbility.progressAll(); CoreAbility.progressAll();
TempPotionEffect.progressAll(); }
this.handleDayNight();
RevertChecker.revertAirBlocks();
HorizontalVelocityTracker.updateAll();
this.handleCooldowns();
TempArmor.cleanup();
try (MCTiming timing = this.TEMP_POTION_TIMING.startTiming()) {
TempPotionEffect.progressAll();
}
try (MCTiming timing = this.DAY_NIGHT_TIMING.startTiming()) {
this.handleDayNight();
}
RevertChecker.revertAirBlocks();
try (MCTiming timing = this.HORIZONTAL_VELOCITY_TRACKER_TIMING.startTiming()) {
HorizontalVelocityTracker.updateAll();
}
try (MCTiming timing = this.COOLDOWN_TIMING.startTiming()) {
this.handleCooldowns();
}
try (MCTiming timing = this.TEMP_ARMOR_TIMING.startTiming()) {
TempArmor.cleanup();
}
try (MCTiming timing = this.ACTIONBAR_STATUS_TIMING.startTiming()) {
for (final Player player : Bukkit.getOnlinePlayers()) { for (final Player player : Bukkit.getOnlinePlayers()) {
if (Bloodbending.isBloodbent(player)) { if (Bloodbending.isBloodbent(player)) {
ActionBar.sendActionBar(Element.BLOOD.getColor() + "* Bloodbent *", player); ActionBar.sendActionBar(Element.BLOOD.getColor() + "* Bloodbent *", player);
@ -124,9 +148,6 @@ public class BendingManager implements Runnable {
} }
} }
} }
catch (final Exception e) {
e.printStackTrace();
}
} }
public static String getSunriseMessage() { public static String getSunriseMessage() {

View file

@ -10,6 +10,9 @@ import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -22,9 +25,6 @@ import com.projectkorra.projectkorra.ability.Ability;
import com.projectkorra.projectkorra.ability.AvatarAbility; import com.projectkorra.projectkorra.ability.AvatarAbility;
import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.ability.FireAbility;
import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.ability.util.PassiveManager; import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.command.Commands;
@ -34,6 +34,7 @@ import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent;
import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent.Result; import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent.Result;
import com.projectkorra.projectkorra.storage.DBConnection; import com.projectkorra.projectkorra.storage.DBConnection;
import com.projectkorra.projectkorra.util.Cooldown; import com.projectkorra.projectkorra.util.Cooldown;
import com.projectkorra.projectkorra.util.DBCooldownManager;
import com.projectkorra.projectkorra.waterbending.blood.Bloodbending; import com.projectkorra.projectkorra.waterbending.blood.Bloodbending;
/** /**
@ -58,6 +59,7 @@ public class BendingPlayer {
private final UUID uuid; private final UUID uuid;
private final String name; private final String name;
private ChiAbility stance; private ChiAbility stance;
private final DBCooldownManager cooldownManager;
private final ArrayList<Element> elements; private final ArrayList<Element> elements;
private final ArrayList<SubElement> subelements; private final ArrayList<SubElement> subelements;
private HashMap<Integer, String> abilities; private HashMap<Integer, String> abilities;
@ -76,6 +78,7 @@ public class BendingPlayer {
public BendingPlayer(final UUID uuid, final String playerName, final ArrayList<Element> elements, final ArrayList<SubElement> subelements, final HashMap<Integer, String> abilities, final boolean permaRemoved) { public BendingPlayer(final UUID uuid, final String playerName, final ArrayList<Element> elements, final ArrayList<SubElement> subelements, final HashMap<Integer, String> abilities, final boolean permaRemoved) {
this.uuid = uuid; this.uuid = uuid;
this.name = playerName; this.name = playerName;
this.cooldownManager = Manager.getManager(DBCooldownManager.class);
this.elements = elements; this.elements = elements;
this.subelements = subelements; this.subelements = subelements;
this.setAbilities(abilities); this.setAbilities(abilities);
@ -152,17 +155,18 @@ public class BendingPlayer {
public Map<String, Cooldown> loadCooldowns() { public Map<String, Cooldown> loadCooldowns() {
final Map<String, Cooldown> cooldowns = new ConcurrentHashMap<>(); final Map<String, Cooldown> cooldowns = new ConcurrentHashMap<>();
try (ResultSet rs = DBConnection.sql.readQuery("SELECT * FROM pk_cooldowns WHERE uuid = '" + this.uuid.toString() + "'")) { if (ProjectKorra.isDatabaseCooldownsEnabled()) {
while (rs.next()) { try (ResultSet rs = DBConnection.sql.readQuery("SELECT * FROM pk_cooldowns WHERE uuid = '" + this.uuid.toString() + "'")) {
final int cooldownId = rs.getInt("cooldown_id"); while (rs.next()) {
final long value = rs.getLong("value"); final int cooldownId = rs.getInt("cooldown_id");
final String name = ProjectKorra.cooldowns.getCooldownName(cooldownId); final long value = rs.getLong("value");
cooldowns.put(name, new Cooldown(value, true)); final String name = this.cooldownManager.getCooldownName(cooldownId);
cooldowns.put(name, new Cooldown(value, true));
}
} catch (final SQLException e) {
e.printStackTrace();
} }
} }
catch (final SQLException e) {
e.printStackTrace();
}
return cooldowns; return cooldowns;
} }
@ -171,15 +175,14 @@ public class BendingPlayer {
for (final Entry<String, Cooldown> entry : this.cooldowns.entrySet()) { for (final Entry<String, Cooldown> entry : this.cooldowns.entrySet()) {
final String name = entry.getKey(); final String name = entry.getKey();
final Cooldown cooldown = entry.getValue(); final Cooldown cooldown = entry.getValue();
final int cooldownId = ProjectKorra.cooldowns.getCooldownId(name, false); final int cooldownId = this.cooldownManager.getCooldownId(name, false);
try (ResultSet rs = DBConnection.sql.readQuery("SELECT value FROM pk_cooldowns WHERE uuid = '" + this.uuid.toString() + "' AND cooldown_id = " + cooldownId)) { try (ResultSet rs = DBConnection.sql.readQuery("SELECT value FROM pk_cooldowns WHERE uuid = '" + this.uuid.toString() + "' AND cooldown_id = " + cooldownId)) {
if (rs.next()) { if (rs.next()) {
DBConnection.sql.modifyQuery("UPDATE pk_cooldowns SET value = " + cooldown.getCooldown() + " WHERE uuid = '" + this.uuid.toString() + "' AND cooldown_id = " + cooldownId, false); DBConnection.sql.modifyQuery("UPDATE pk_cooldowns SET value = " + cooldown.getCooldown() + " WHERE uuid = '" + this.uuid.toString() + "' AND cooldown_id = " + cooldownId, false);
} else { } else {
DBConnection.sql.modifyQuery("INSERT INTO pk_cooldowns (uuid, cooldown_id, value) VALUES ('" + this.uuid.toString() + "', " + cooldownId + ", " + cooldown.getCooldown() + ")", false); DBConnection.sql.modifyQuery("INSERT INTO pk_cooldowns (uuid, cooldown_id, value) VALUES ('" + this.uuid.toString() + "', " + cooldownId + ", " + cooldown.getCooldown() + ")", false);
} }
} } catch (final SQLException e) {
catch (final SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -275,10 +278,6 @@ public class BendingPlayer {
return false; return false;
} else if (GeneralMethods.isRegionProtectedFromBuild(this.player, ability.getName(), playerLoc)) { } else if (GeneralMethods.isRegionProtectedFromBuild(this.player, ability.getName(), playerLoc)) {
return false; return false;
} else if (ability instanceof FireAbility && ElementalAbility.isSolarEclipse(this.player.getWorld())) {
return false;
} else if (ability instanceof WaterAbility && ElementalAbility.isLunarEclipse(this.player.getWorld())) {
return false;
} }
return true; return true;
@ -913,4 +912,8 @@ public class BendingPlayer {
this.chiBlocked = false; this.chiBlocked = false;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} }

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,124 @@
package com.projectkorra.projectkorra;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import com.projectkorra.projectkorra.util.DBCooldownManager;
import com.projectkorra.projectkorra.util.FlightHandler;
import com.projectkorra.projectkorra.util.StatisticsManager;
public abstract class Manager implements Listener {
/**
* {@link Map} containing all {@link Manager} instances by their
* {@link Class} as key
*/
private static final Map<Class<? extends Manager>, Manager> MANAGERS = new HashMap<>();
/**
* Register a new {@link Manager} instance.
*
* @param managerClass {@link Class} of the {@link Manager} to be registered
* @throws NullPointerException if managerClass is null
* @throws IllegalArgumentException if managerClass has already been
* registered
*/
public static void registerManager(final Class<? extends Manager> managerClass) {
Validate.notNull(managerClass, "Manager class cannot be null");
Validate.isTrue(!MANAGERS.containsKey(managerClass), "Manager has already been registered");
try {
final Constructor<? extends Manager> constructor = managerClass.getDeclaredConstructor();
final boolean accessible = constructor.isAccessible();
constructor.setAccessible(true);
final Manager manager = constructor.newInstance();
constructor.setAccessible(accessible);
manager.activate();
MANAGERS.put(managerClass, manager);
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}
/**
* Get a registered {@link Manager} by its {@link Class}.
*
* @param managerClass {@link Class} of the registered {@link Manager}
* @return instance of the {@link Manager} class
* @throws NullPointerException if managerClass is null
* @throws IllegalArgumentException if managerClass has not yet been
* registered
*/
public static <T extends Manager> T getManager(final Class<T> managerClass) {
Validate.notNull(managerClass, "Manager class cannot be null");
Validate.isTrue(MANAGERS.containsKey(managerClass), "Manager has not yet been registered");
final Manager registered = MANAGERS.get(managerClass);
return managerClass.cast(registered);
}
/**
* Get this plugin instance
*
* @return {@link ProjectKorra} plugin instance
*/
protected ProjectKorra getPlugin() {
return JavaPlugin.getPlugin(ProjectKorra.class);
}
/**
* Activate this {@link Manager}
*/
public final void activate() {
Bukkit.getPluginManager().registerEvents(this, ProjectKorra.plugin);
this.onActivate();
}
/**
* Overridable method to execute code when this {@link Manager} is activated
*/
public void onActivate() {
}
/**
* Deactivate this {@link Manager}
*/
public final void deactivate() {
HandlerList.unregisterAll(this);
this.onDeactivate();
}
/**
* Overridable method to execute code when this {@link Manager} is
* deactivated
*/
public void onDeactivate() {
}
/**
* Activates core {@link Manager} instances
*/
public static void startup() {
registerManager(StatisticsManager.class);
registerManager(DBCooldownManager.class);
registerManager(FlightHandler.class);
}
/**
* Deactivates and clears all {@link Manager} instances
*/
public static void shutdown() {
MANAGERS.values().forEach(Manager::deactivate);
MANAGERS.clear();
}
}

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import co.aikar.timings.lib.MCTiming;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -30,7 +31,10 @@ import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.FluidLevelChangeEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByBlockEvent;
@ -41,18 +45,20 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityInteractEvent; import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.entity.EntityTeleportEvent; import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.entity.EntityToggleGlideEvent; import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.event.entity.ItemMergeEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.entity.SlimeSplitEvent; import org.bukkit.event.entity.SlimeSplitEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent;
@ -135,7 +141,6 @@ import com.projectkorra.projectkorra.earthbending.passive.FerroControl;
import com.projectkorra.projectkorra.event.EntityBendingDeathEvent; import com.projectkorra.projectkorra.event.EntityBendingDeathEvent;
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent; import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent; import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
import com.projectkorra.projectkorra.event.PlayerJumpEvent; import com.projectkorra.projectkorra.event.PlayerJumpEvent;
import com.projectkorra.projectkorra.firebending.Blaze; import com.projectkorra.projectkorra.firebending.Blaze;
import com.projectkorra.projectkorra.firebending.BlazeArc; import com.projectkorra.projectkorra.firebending.BlazeArc;
@ -160,9 +165,11 @@ import com.projectkorra.projectkorra.object.Preset;
import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.FlightHandler;
import com.projectkorra.projectkorra.util.FlightHandler.Flight; import com.projectkorra.projectkorra.util.FlightHandler.Flight;
import com.projectkorra.projectkorra.util.MovementHandler; import com.projectkorra.projectkorra.util.MovementHandler;
import com.projectkorra.projectkorra.util.PassiveHandler; import com.projectkorra.projectkorra.util.PassiveHandler;
import com.projectkorra.projectkorra.util.StatisticsManager;
import com.projectkorra.projectkorra.util.StatisticsMethods; import com.projectkorra.projectkorra.util.StatisticsMethods;
import com.projectkorra.projectkorra.util.TempArmor; import com.projectkorra.projectkorra.util.TempArmor;
import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempBlock;
@ -174,6 +181,7 @@ import com.projectkorra.projectkorra.waterbending.WaterBubble;
import com.projectkorra.projectkorra.waterbending.WaterManipulation; import com.projectkorra.projectkorra.waterbending.WaterManipulation;
import com.projectkorra.projectkorra.waterbending.WaterSpout; import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.projectkorra.waterbending.blood.Bloodbending; import com.projectkorra.projectkorra.waterbending.blood.Bloodbending;
import com.projectkorra.projectkorra.waterbending.combo.IceBullet;
import com.projectkorra.projectkorra.waterbending.healing.HealingWaters; import com.projectkorra.projectkorra.waterbending.healing.HealingWaters;
import com.projectkorra.projectkorra.waterbending.ice.IceBlast; import com.projectkorra.projectkorra.waterbending.ice.IceBlast;
import com.projectkorra.projectkorra.waterbending.ice.IceSpikeBlast; import com.projectkorra.projectkorra.waterbending.ice.IceSpikeBlast;
@ -182,7 +190,6 @@ import com.projectkorra.projectkorra.waterbending.ice.PhaseChange.PhaseChangeTyp
import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms;
import com.projectkorra.projectkorra.waterbending.passive.FastSwim; import com.projectkorra.projectkorra.waterbending.passive.FastSwim;
import com.projectkorra.projectkorra.waterbending.passive.HydroSink; import com.projectkorra.projectkorra.waterbending.passive.HydroSink;
import com.projectkorra.rpg.RPGMethods;
public class PKListener implements Listener { public class PKListener implements Listener {
ProjectKorra plugin; ProjectKorra plugin;
@ -193,8 +200,25 @@ public class PKListener implements Listener {
private static final ArrayList<UUID> TOGGLED_OUT = new ArrayList<>(); // Stands for toggled = false while logging out. private static final ArrayList<UUID> TOGGLED_OUT = new ArrayList<>(); // Stands for toggled = false while logging out.
private static final Map<Player, Integer> JUMPS = new HashMap<>(); private static final Map<Player, Integer> JUMPS = new HashMap<>();
private static MCTiming TimingPhysicsWaterManipulationCheck, TimingPhysicsEarthPassiveCheck, TimingPhysicsIlluminationTorchCheck, TimingPhysicsEarthAbilityCheck, TimingPhysicsAirTempBlockBelowFallingBlockCheck;
private static MCTiming TimingPlayerMoveMovementHandlerCheck, TimingPlayerMoveSpoutCheck, TimingPlayerMoveBloodbentCheck, TimingPlayerMoveAirChiPassiveCheck, TimingPlayerMoveFirePassiveCheck, TimingPlayerMoveJumpCheck;
public PKListener(final ProjectKorra plugin) { public PKListener(final ProjectKorra plugin) {
this.plugin = plugin; this.plugin = plugin;
TimingPhysicsWaterManipulationCheck = ProjectKorra.timing("PhysicsWaterManipulationCheck");
TimingPhysicsEarthPassiveCheck = ProjectKorra.timing("PhysicsEarthPassiveCheck");
TimingPhysicsIlluminationTorchCheck = ProjectKorra.timing("PhysicsIlluminationTorchCheck");
TimingPhysicsEarthAbilityCheck = ProjectKorra.timing("PhysicsEarthAbilityCheck");
TimingPhysicsAirTempBlockBelowFallingBlockCheck = ProjectKorra.timing("PhysicsAirTempBlockBelowFallingBlockCheck");
TimingPlayerMoveMovementHandlerCheck = ProjectKorra.timing("PlayerMoveMovementHandlerCheck");
TimingPlayerMoveSpoutCheck = ProjectKorra.timing("PlayerMoveSpoutCheck");
TimingPlayerMoveBloodbentCheck = ProjectKorra.timing("PlayerMoveBloodbentCheck");
TimingPlayerMoveAirChiPassiveCheck = ProjectKorra.timing("PlayerMoveAirChiPassiveCheck");
TimingPlayerMoveFirePassiveCheck = ProjectKorra.timing("PlayerMoveFirePassiveCheck");
TimingPlayerMoveJumpCheck = ProjectKorra.timing("PlayerMoveJumpCheck");
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -245,6 +269,8 @@ public class PKListener implements Listener {
TempBlock.revertBlock(block, Material.AIR); TempBlock.revertBlock(block, Material.AIR);
} else if (DensityShift.isPassiveSand(block)) { } else if (DensityShift.isPassiveSand(block)) {
DensityShift.revertSand(block); DensityShift.revertSand(block);
} else if (WaterBubble.isAir(block)) {
event.setCancelled(true);
} }
} }
@ -252,24 +278,36 @@ public class PKListener implements Listener {
public void onBlockFlowTo(final BlockFromToEvent event) { public void onBlockFlowTo(final BlockFromToEvent event) {
final Block toblock = event.getToBlock(); final Block toblock = event.getToBlock();
final Block fromblock = event.getBlock(); final Block fromblock = event.getBlock();
if (ElementalAbility.isLava(fromblock)) {
event.setCancelled(!EarthPassive.canFlowFromTo(fromblock, toblock));
}
if (ElementalAbility.isWater(fromblock)) { if (TempBlock.isTempBlock(fromblock) || TempBlock.isTempBlock(toblock)) {
event.setCancelled(!WaterBubble.isAir(toblock)); event.setCancelled(true);
if (!event.isCancelled()) { } else {
event.setCancelled(!WaterManipulation.canFlowFromTo(fromblock, toblock)); if (ElementalAbility.isLava(fromblock)) {
} event.setCancelled(!EarthPassive.canFlowFromTo(fromblock, toblock));
} else if (ElementalAbility.isWater(fromblock)) {
event.setCancelled(WaterBubble.isAir(toblock));
if (!event.isCancelled()) {
event.setCancelled(!WaterManipulation.canFlowFromTo(fromblock, toblock));
}
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (Illumination.isIlluminationTorch(toblock)) { if (Illumination.isIlluminationTorch(toblock)) {
toblock.setType(Material.AIR); toblock.setType(Material.AIR);
}
} }
} }
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onFluidLevelChange(final FluidLevelChangeEvent event) {
if (TempBlock.isTempBlock(event.getBlock())) {
event.setCancelled(true);
} else if (TempBlock.isTouchingTempBlock(event.getBlock())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockForm(final BlockFormEvent event) { public void onBlockForm(final BlockFormEvent event) {
if (TempBlock.isTempBlock(event.getBlock())) { if (TempBlock.isTempBlock(event.getBlock())) {
@ -290,7 +328,7 @@ public class PKListener implements Listener {
boolean marked = true; boolean marked = true;
for (final BlockFace face : faces) { for (final BlockFace face : faces) {
final Block b = event.getBlock().getRelative(face); final Block b = event.getBlock().getRelative(face);
if (b.getType() == Material.WATER || b.getType() == Material.STATIONARY_WATER) { if (b.getType() == Material.WATER) {
if (!TempBlock.isTempBlock(b)) { if (!TempBlock.isTempBlock(b)) {
marked = false; // if there is any normal water around it, prevent it. marked = false; // if there is any normal water around it, prevent it.
break; break;
@ -305,8 +343,7 @@ public class PKListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockIgnite(final BlockIgniteEvent event) { public void onBlockIgnite(final BlockIgniteEvent event) {}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockMeltEvent(final BlockFadeEvent event) { public void onBlockMeltEvent(final BlockFadeEvent event) {
@ -345,13 +382,39 @@ public class PKListener implements Listener {
public void onBlockPhysics(final BlockPhysicsEvent event) { public void onBlockPhysics(final BlockPhysicsEvent event) {
final Block block = event.getBlock(); final Block block = event.getBlock();
if (!WaterManipulation.canPhysicsChange(block) || !EarthPassive.canPhysicsChange(block) || Illumination.isIlluminationTorch(block) || EarthAbility.getPreventPhysicsBlocks().contains(block)) { try (MCTiming timing = TimingPhysicsWaterManipulationCheck.startTiming()) {
event.setCancelled(true); if (!WaterManipulation.canPhysicsChange(block)) {
event.setCancelled(true);
return;
}
}
try (MCTiming timing = TimingPhysicsEarthPassiveCheck.startTiming()) {
if (!EarthPassive.canPhysicsChange(block)) {
event.setCancelled(true);
return;
}
}
try (MCTiming timing = TimingPhysicsIlluminationTorchCheck.startTiming()) {
if (Illumination.isIlluminationTorch(block)) {
event.setCancelled(true);
return;
}
}
try (MCTiming timing = TimingPhysicsEarthAbilityCheck.startTiming()) {
if (EarthAbility.getPreventPhysicsBlocks().contains(block)) {
event.setCancelled(true);
return;
}
} }
// If there is a TempBlock of Air bellow FallingSand blocks, prevent it from updating. // If there is a TempBlock of Air bellow FallingSand blocks, prevent it from updating.
if (!event.isCancelled() && (block.getType() == Material.SAND || block.getType() == Material.GRAVEL || block.getType() == Material.ANVIL || block.getType() == Material.DRAGON_EGG) && TempBlock.isTempBlock(block.getRelative(BlockFace.DOWN)) && block.getRelative(BlockFace.DOWN).getType() == Material.AIR) { try (MCTiming timing = TimingPhysicsAirTempBlockBelowFallingBlockCheck.startTiming()) {
event.setCancelled(true); if ((block.getType() == Material.SAND || block.getType() == Material.RED_SAND || block.getType() == Material.GRAVEL || block.getType() == Material.ANVIL || block.getType() == Material.DRAGON_EGG) && ElementalAbility.isAir(block.getRelative(BlockFace.DOWN).getType()) && TempBlock.isTempBlock(block.getRelative(BlockFace.DOWN))) {
event.setCancelled(true);
}
} }
} }
@ -363,19 +426,8 @@ public class PKListener implements Listener {
return; return;
} }
if (TempBlock.isTempBlock(event.getBlock())) { if (TempBlock.isTempBlock(event.getBlock()) && event.getItemInHand().getType() != Material.FLINT_AND_STEEL) {
final TempBlock tb = TempBlock.get(event.getBlock()); TempBlock.removeBlock(event.getBlock());
tb.revertBlock();
event.getBlock().setType(event.getItemInHand().getType());
if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
if (event.getItemInHand().getAmount() <= 0) {
event.getItemInHand().setType(Material.AIR);
event.getItemInHand().setAmount(1);
} else {
event.getItemInHand().setAmount(event.getItemInHand().getAmount() - 1);
}
}
return;
} }
} }
@ -404,12 +456,6 @@ public class PKListener implements Listener {
player.setDisplayName(player.getName()); player.setDisplayName(player.getName());
player.setDisplayName(prefix + ChatColor.RESET + player.getDisplayName()); player.setDisplayName(prefix + ChatColor.RESET + player.getDisplayName());
} }
if (event.getResult() == Result.REMOVE) {
if (GeneralMethods.hasRPG()) {
RPGMethods.revokeAvatar(player.getUniqueId());
}
}
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -437,8 +483,7 @@ public class PKListener implements Listener {
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamageBlock(final EntityDamageByBlockEvent event) { public void onEntityDamageBlock(final EntityDamageByBlockEvent event) {}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDamageByBlock(final EntityDamageByBlockEvent event) { public void onEntityDamageByBlock(final EntityDamageByBlockEvent event) {
@ -469,7 +514,9 @@ public class PKListener implements Listener {
} }
if (entity instanceof LivingEntity && TempArmor.hasTempArmor((LivingEntity) entity)) { if (entity instanceof LivingEntity && TempArmor.hasTempArmor((LivingEntity) entity)) {
event.setDamage(DamageModifier.ARMOR, 0); if (event.isApplicable(DamageModifier.ARMOR)) {
event.setDamage(DamageModifier.ARMOR, 0);
}
} }
if (entity instanceof Player) { if (entity instanceof Player) {
@ -484,6 +531,10 @@ public class PKListener implements Listener {
abil.remove(); abil.remove();
} }
if (CoreAbility.getAbility(player, FireJet.class) != null && event.getCause() == DamageCause.FLY_INTO_WALL) {
event.setCancelled(true);
}
if (bPlayer.isElementToggled(Element.FIRE)) { if (bPlayer.isElementToggled(Element.FIRE)) {
return; return;
} }
@ -502,10 +553,12 @@ public class PKListener implements Listener {
if (TempArmor.hasTempArmor(event.getEntity())) { if (TempArmor.hasTempArmor(event.getEntity())) {
final TempArmor armor = TempArmor.getVisibleTempArmor(event.getEntity()); final TempArmor armor = TempArmor.getVisibleTempArmor(event.getEntity());
final List<ItemStack> newDrops = armor.filterArmor(event.getDrops()); if (armor != null) {
final List<ItemStack> newDrops = armor.filterArmor(event.getDrops());
event.getDrops().clear();
event.getDrops().addAll(newDrops);
}
event.getDrops().clear();
event.getDrops().addAll(newDrops);
if (MetalClips.isControlled(event.getEntity())) { if (MetalClips.isControlled(event.getEntity())) {
event.getDrops().add(new ItemStack(Material.IRON_INGOT, MetalClips.getTargetToAbility().get(event.getEntity()).getMetalClipsCount())); event.getDrops().add(new ItemStack(Material.IRON_INGOT, MetalClips.getTargetToAbility().get(event.getEntity()).getMetalClipsCount()));
} }
@ -527,22 +580,17 @@ public class PKListener implements Listener {
ItemStack cooked = drops.get(i); ItemStack cooked = drops.get(i);
final Material material = drops.get(i).getType(); final Material material = drops.get(i).getType();
switch (material) { switch (material) {
case RAW_BEEF: case BEEF:
cooked = new ItemStack(Material.COOKED_BEEF, 1); cooked = new ItemStack(Material.COOKED_BEEF);
break; break;
case RAW_FISH: case SALMON:
final ItemStack salmon = new ItemStack(Material.RAW_FISH, 1, (short) 1); cooked = new ItemStack(Material.COOKED_SALMON);
if (drops.get(i).getDurability() == salmon.getDurability()) {
cooked = new ItemStack(Material.COOKED_FISH, 1, (short) 1);
} else {
cooked = new ItemStack(Material.COOKED_FISH, 1);
}
break; break;
case RAW_CHICKEN: case CHICKEN:
cooked = new ItemStack(Material.COOKED_CHICKEN, 1); cooked = new ItemStack(Material.COOKED_CHICKEN);
break; break;
case PORK: case PORKCHOP:
cooked = new ItemStack(Material.GRILLED_PORK, 1); cooked = new ItemStack(Material.COOKED_PORKCHOP);
break; break;
case MUTTON: case MUTTON:
cooked = new ItemStack(Material.COOKED_MUTTON); cooked = new ItemStack(Material.COOKED_MUTTON);
@ -550,6 +598,9 @@ public class PKListener implements Listener {
case RABBIT: case RABBIT:
cooked = new ItemStack(Material.COOKED_RABBIT); cooked = new ItemStack(Material.COOKED_RABBIT);
break; break;
case COD:
cooked = new ItemStack(Material.COOKED_COD);
break;
default: default:
break; break;
} }
@ -662,7 +713,7 @@ public class PKListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityTeleportEvent(final EntityTeleportEvent event) { public void onEntityTeleportEvent(final EntityTeleportEvent event) {
final Entity entity = event.getEntity(); final Entity entity = event.getEntity();
if (MovementHandler.isStopped(entity) || Bloodbending.isBloodbent(entity) || Suffocate.isBreathbent(entity) || MetalClips.isControlled((LivingEntity) entity)) { if (MovementHandler.isStopped(entity) || Bloodbending.isBloodbent(entity) || Suffocate.isBreathbent(entity) || (entity instanceof LivingEntity && MetalClips.isControlled((LivingEntity) entity))) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -735,10 +786,13 @@ public class PKListener implements Listener {
} }
}.runTaskLater(ProjectKorra.plugin, 20); }.runTaskLater(ProjectKorra.plugin, 20);
} }
if (event.getAttacker() != null && ProjectKorra.isStatisticsEnabled()) {
StatisticsMethods.addStatisticAbility(event.getAttacker().getUniqueId(), CoreAbility.getAbility(event.getAbility().getName()), com.projectkorra.projectkorra.util.Statistic.PLAYER_KILLS, 1); StatisticsMethods.addStatisticAbility(event.getAttacker().getUniqueId(), CoreAbility.getAbility(event.getAbility().getName()), com.projectkorra.projectkorra.util.Statistic.PLAYER_KILLS, 1);
}
}
if (event.getAttacker() != null && ProjectKorra.isStatisticsEnabled()) {
StatisticsMethods.addStatisticAbility(event.getAttacker().getUniqueId(), CoreAbility.getAbility(event.getAbility().getName()), com.projectkorra.projectkorra.util.Statistic.TOTAL_KILLS, 1);
} }
StatisticsMethods.addStatisticAbility(event.getAttacker().getUniqueId(), CoreAbility.getAbility(event.getAbility().getName()), com.projectkorra.projectkorra.util.Statistic.TOTAL_KILLS, 1);
} }
@EventHandler @EventHandler
@ -756,9 +810,18 @@ public class PKListener implements Listener {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
final String e = bPlayer == null || bPlayer.getElements().size() == 0 ? "Nonbender" : (bPlayer.getElements().size() > 1 ? "Avatar" : bPlayer.getElements().get(0).getName()); String e = "Nonbender";
ChatColor c = ChatColor.WHITE;
if (bPlayer != null) {
if (player.hasPermission("bending.avatar") || (bPlayer.hasElement(Element.AIR) && bPlayer.hasElement(Element.EARTH) && bPlayer.hasElement(Element.FIRE) && bPlayer.hasElement(Element.WATER))) {
c = Element.AVATAR.getColor();
e = Element.AVATAR.getName();
} else if (bPlayer.getElements().size() > 0) {
c = bPlayer.getElements().get(0).getColor();
e = bPlayer.getElements().get(0).getName();
}
}
final String element = ConfigManager.languageConfig.get().getString("Chat.Prefixes." + e); final String element = ConfigManager.languageConfig.get().getString("Chat.Prefixes." + e);
final ChatColor c = bPlayer == null || bPlayer.getElements().size() == 0 ? ChatColor.WHITE : (bPlayer.getElements().size() > 1 ? Element.AVATAR.getColor() : bPlayer.getElements().get(0).getColor());
event.setFormat(event.getFormat().replace("{element}", c + element + ChatColor.RESET).replace("{ELEMENT}", c + element + ChatColor.RESET).replace("{elementcolor}", c + "").replace("{ELEMENTCOLOR}", c + "")); event.setFormat(event.getFormat().replace("{element}", c + element + ChatColor.RESET).replace("{ELEMENT}", c + element + ChatColor.RESET).replace("{elementcolor}", c + "").replace("{ELEMENTCOLOR}", c + ""));
if (!ConfigManager.languageConfig.get().getBoolean("Chat.Enable")) { if (!ConfigManager.languageConfig.get().getBoolean("Chat.Enable")) {
@ -771,15 +834,10 @@ public class PKListener implements Listener {
return; return;
} }
if (player.hasPermission("bending.avatar") || bPlayer.getElements().size() > 1) { if (player.hasPermission("bending.avatar") || (bPlayer.hasElement(Element.AIR) && bPlayer.hasElement(Element.EARTH) && bPlayer.hasElement(Element.FIRE) && bPlayer.hasElement(Element.WATER))) {
color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Colors.Avatar")); color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Colors.Avatar"));
} else { } else if (bPlayer.getElements().size() > 0) {
for (final Element element_ : Element.getMainElements()) { color = bPlayer.getElements().get(0).getColor();
if (bPlayer.hasElement(element_)) {
color = element_.getColor();
break;
}
}
} }
String format = ConfigManager.languageConfig.get().getString("Chat.Format"); String format = ConfigManager.languageConfig.get().getString("Chat.Format");
@ -818,23 +876,28 @@ public class PKListener implements Listener {
new AirBurst(player, true); new AirBurst(player, true);
} }
} }
CoreAbility gd = CoreAbility.getAbility(GracefulDescent.class);
CoreAbility ds = CoreAbility.getAbility(DensityShift.class);
CoreAbility hs = CoreAbility.getAbility(HydroSink.class);
CoreAbility ab = CoreAbility.getAbility(Acrobatics.class);
if (bPlayer.hasElement(Element.AIR) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(CoreAbility.getAbility(GracefulDescent.class)) && bPlayer.canUsePassive(CoreAbility.getAbility(GracefulDescent.class)) && CoreAbility.getAbility(GracefulDescent.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(GracefulDescent.class))) { if (gd != null && bPlayer.hasElement(Element.AIR) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(gd) && bPlayer.canUsePassive(gd) && gd.isEnabled() && PassiveManager.hasPassive(player, gd)) {
event.setDamage(0D); event.setDamage(0D);
event.setCancelled(true); event.setCancelled(true);
} else if (bPlayer.hasElement(Element.EARTH) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(CoreAbility.getAbility(DensityShift.class)) && bPlayer.canUsePassive(CoreAbility.getAbility(DensityShift.class)) && CoreAbility.getAbility(DensityShift.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(DensityShift.class))) { } else if (ds != null && bPlayer.hasElement(Element.EARTH) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(ds) && bPlayer.canUsePassive(ds) && ds.isEnabled() && PassiveManager.hasPassive(player, ds)) {
if (DensityShift.softenLanding(player)) { if (DensityShift.softenLanding(player)) {
event.setDamage(0D); event.setDamage(0D);
event.setCancelled(true); event.setCancelled(true);
} }
} else if (bPlayer.hasElement(Element.WATER) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(CoreAbility.getAbility(HydroSink.class)) && bPlayer.canUsePassive(CoreAbility.getAbility(HydroSink.class)) && CoreAbility.getAbility(HydroSink.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(HydroSink.class))) { } else if (hs != null && bPlayer.hasElement(Element.WATER) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(hs) && bPlayer.canUsePassive(hs) && hs.isEnabled() && PassiveManager.hasPassive(player, hs)) {
if (HydroSink.applyNoFall(player)) { if (HydroSink.applyNoFall(player)) {
event.setDamage(0D); event.setDamage(0D);
event.setCancelled(true); event.setCancelled(true);
} }
} }
if (bPlayer.hasElement(Element.CHI) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(CoreAbility.getAbility(Acrobatics.class)) && bPlayer.canUsePassive(CoreAbility.getAbility(Acrobatics.class)) && CoreAbility.getAbility(Acrobatics.class).isEnabled() && PassiveManager.hasPassive(player, CoreAbility.getAbility(Acrobatics.class))) { if (ab != null && bPlayer.hasElement(Element.CHI) && event.getCause() == DamageCause.FALL && bPlayer.canBendPassive(ab) && bPlayer.canUsePassive(ab) && ab.isEnabled() && PassiveManager.hasPassive(player, ab)) {
final double initdamage = event.getDamage(); final double initdamage = event.getDamage();
final double newdamage = event.getDamage() * Acrobatics.getFallReductionFactor(); final double newdamage = event.getDamage() * Acrobatics.getFallReductionFactor();
final double finaldamage = initdamage - newdamage; final double finaldamage = initdamage - newdamage;
@ -845,7 +908,7 @@ public class PKListener implements Listener {
} }
if (event.getCause() == DamageCause.FALL) { if (event.getCause() == DamageCause.FALL) {
final Flight flight = ProjectKorra.flightHandler.getInstance(player); final Flight flight = Manager.getManager(FlightHandler.class).getInstance(player);
if (flight != null) { if (flight != null) {
if (flight.getPlayer() == flight.getSource()) { if (flight.getPlayer() == flight.getSource()) {
event.setCancelled(true); event.setCancelled(true);
@ -853,7 +916,9 @@ public class PKListener implements Listener {
} }
} }
if (bPlayer.canBendPassive(CoreAbility.getAbility(HeatControl.class)) && bPlayer.hasElement(Element.FIRE) && bPlayer.canUsePassive(CoreAbility.getAbility(HeatControl.class)) && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) { CoreAbility hc = CoreAbility.getAbility(HeatControl.class);
if (hc != null && bPlayer.hasElement(Element.FIRE) && bPlayer.canBendPassive(hc) && bPlayer.canUsePassive(hc) && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) {
event.setCancelled(!HeatControl.canBurn(player)); event.setCancelled(!HeatControl.canBurn(player));
} }
@ -900,7 +965,7 @@ public class PKListener implements Listener {
return; return;
} }
final String boundAbil = sourceBPlayer.getBoundAbilityName(); final Ability boundAbil = sourceBPlayer.getBoundAbility();
if (sourceBPlayer.getBoundAbility() != null) { if (sourceBPlayer.getBoundAbility() != null) {
if (!sourceBPlayer.isOnCooldown(boundAbil)) { if (!sourceBPlayer.isOnCooldown(boundAbil)) {
@ -909,15 +974,15 @@ public class PKListener implements Listener {
if (sourceBPlayer.getBoundAbility() instanceof ChiAbility) { if (sourceBPlayer.getBoundAbility() instanceof ChiAbility) {
if (sourceBPlayer.canCurrentlyBendWithWeapons()) { if (sourceBPlayer.canCurrentlyBendWithWeapons()) {
if (sourceBPlayer.isElementToggled(Element.CHI)) { if (sourceBPlayer.isElementToggled(Element.CHI)) {
if (boundAbil.equalsIgnoreCase("Paralyze")) { if (boundAbil.equals(CoreAbility.getAbility(Paralyze.class))) {
new Paralyze(sourcePlayer, entity); new Paralyze(sourcePlayer, entity);
} else if (boundAbil.equalsIgnoreCase("QuickStrike")) { } else if (boundAbil.equals(CoreAbility.getAbility(QuickStrike.class))) {
new QuickStrike(sourcePlayer, entity); new QuickStrike(sourcePlayer, entity);
e.setCancelled(true); e.setCancelled(true);
} else if (boundAbil.equalsIgnoreCase("SwiftKick")) { } else if (boundAbil.equals(CoreAbility.getAbility(SwiftKick.class))) {
new SwiftKick(sourcePlayer, entity); new SwiftKick(sourcePlayer, entity);
e.setCancelled(true); e.setCancelled(true);
} else if (boundAbil.equalsIgnoreCase("RapidPunch")) { } else if (boundAbil.equals(CoreAbility.getAbility(RapidPunch.class))) {
new RapidPunch(sourcePlayer, entity); new RapidPunch(sourcePlayer, entity);
e.setCancelled(true); e.setCancelled(true);
} }
@ -1035,6 +1100,14 @@ public class PKListener implements Listener {
} }
} }
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
if (bPlayer.getBoundAbilityName().equalsIgnoreCase("IceBlast")) {
if (CoreAbility.hasAbility(player, IceBullet.class)) {
CoreAbility.getAbility(player, IceBullet.class).doRightClick();
}
}
}
if (MovementHandler.isStopped(player) || Bloodbending.isBloodbent(player) || Suffocate.isBreathbent(player)) { if (MovementHandler.isStopped(player) || Bloodbending.isBloodbent(player) || Suffocate.isBreathbent(player)) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -1074,6 +1147,7 @@ public class PKListener implements Listener {
return; return;
} }
} }
if (!RIGHT_CLICK_INTERACT.contains(player.getUniqueId())) { if (!RIGHT_CLICK_INTERACT.contains(player.getUniqueId())) {
if (event.getRightClicked() instanceof Player) { if (event.getRightClicked() instanceof Player) {
final Player target = (Player) event.getRightClicked(); final Player target = (Player) event.getRightClicked();
@ -1116,32 +1190,25 @@ public class PKListener implements Listener {
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
if (ProjectKorra.isStatisticsEnabled()) { if (ProjectKorra.isStatisticsEnabled()) {
ProjectKorra.statistics.load(player.getUniqueId()); Manager.getManager(StatisticsManager.class).load(player.getUniqueId());
} }
Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, new Runnable() { Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, (Runnable) () -> {
PassiveManager.registerPassives(player);
@Override GeneralMethods.removeUnusableAbilities(player.getName());
public void run() {
PassiveManager.registerPassives(player);
GeneralMethods.removeUnusableAbilities(player.getName());
}
}, 5); }, 5);
if (ConfigManager.languageConfig.get().getBoolean("Chat.Branding.JoinMessage.Enabled")) { if (ConfigManager.languageConfig.get().getBoolean("Chat.Branding.JoinMessage.Enabled")) {
Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, new Runnable() { Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, (Runnable) () -> {
@Override ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase());
public void run() { color = color == null ? ChatColor.GOLD : color;
ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase()); final String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder");
color = color == null ? ChatColor.GOLD : color; final String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.BottomBorder");
final String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder"); if (!topBorder.isEmpty()) {
final String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.BottomBorder"); player.sendMessage(ChatColor.translateAlternateColorCodes('&', topBorder));
if (!topBorder.isEmpty()) { }
player.sendMessage(ChatColor.translateAlternateColorCodes('&', topBorder)); player.sendMessage(color + "This server is running ProjectKorra version " + ProjectKorra.plugin.getDescription().getVersion() + " for bending! Find out more at http://www.projectkorra.com!");
} if (!bottomBorder.isEmpty()) {
player.sendMessage(color + "This server is running ProjectKorra version " + ProjectKorra.plugin.getDescription().getVersion() + " for bending! Find out more at http://www.projectkorra.com!"); player.sendMessage(ChatColor.translateAlternateColorCodes('&', bottomBorder));
if (!bottomBorder.isEmpty()) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', bottomBorder));
}
} }
}, 20 * 4); }, 20 * 4);
} }
@ -1159,75 +1226,86 @@ public class PKListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event) { public void onPlayerMove(final PlayerMoveEvent event) {
if (event.getTo().getX() == event.getFrom().getX() && event.getTo().getY() == event.getFrom().getY() && event.getTo().getZ() == event.getFrom().getZ()) {
return;
}
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (MovementHandler.isStopped(player)) {
if (event.getTo().getX() != event.getFrom().getX() || event.getTo().getZ() != event.getFrom().getZ() || event.getTo().getY() > event.getFrom().getY()) { try (MCTiming timing = TimingPlayerMoveMovementHandlerCheck.startTiming()) {
event.setCancelled(true); if (MovementHandler.isStopped(player)) {
if (event.getTo().getX() != event.getFrom().getX() || event.getTo().getZ() != event.getFrom().getZ() || event.getTo().getY() > event.getFrom().getY()) {
event.setCancelled(true);
}
return; return;
} }
} else if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class)) { }
Vector vel = new Vector();
vel.setX(event.getTo().getX() - event.getFrom().getX());
vel.setZ(event.getTo().getZ() - event.getFrom().getZ());
final double currspeed = vel.length(); try (MCTiming timing = TimingPlayerMoveSpoutCheck.startTiming()) {
final double maxspeed = .2; if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class)) {
if (currspeed > maxspeed) { Vector vel = new Vector();
// apply only if moving set a factor vel.setX(event.getTo().getX() - event.getFrom().getX());
vel = vel.normalize().multiply(maxspeed); vel.setZ(event.getTo().getZ() - event.getFrom().getZ());
// apply the new velocity
event.getPlayer().setVelocity(vel); final double currspeed = vel.length();
} final double maxspeed = .2;
} else if (Bloodbending.isBloodbent(player)) { if (currspeed > maxspeed) {
final BendingPlayer bender = Bloodbending.getBloodbender(player); // apply only if moving set a factor
if (bender.isAvatarState()) { vel = vel.normalize().multiply(maxspeed);
event.setCancelled(true); // apply the new velocity
event.getPlayer().setVelocity(vel);
}
return; return;
} }
}
double distance1 = 0; try (MCTiming timing = TimingPlayerMoveBloodbentCheck.startTiming()) {
double distance2 = 0; if (Bloodbending.isBloodbent(player)) {
final Location loc = Bloodbending.getBloodbendingLocation(player); final BendingPlayer bender = Bloodbending.getBloodbender(player);
if (player.getWorld().equals(loc.getWorld())) { if (bender.isAvatarState()) {
distance1 = event.getFrom().distanceSquared(loc); event.setCancelled(true);
distance2 = event.getTo().distanceSquared(loc);
}
if (distance1 == 0 && distance2 == 0) {
return;
} else if (distance1 > distance2 || distance1 < distance2) {
if (!player.getVelocity().equals(Bloodbending.getBloodbendingVector(player))) {
player.setVelocity(Bloodbending.getBloodbendingVector(player));
return; return;
} }
}
} else { final Location loc = Bloodbending.getBloodbendingLocation(player);
if (bPlayer != null) { if (player.getWorld().equals(loc.getWorld())) {
if (event.getTo().getX() != event.getFrom().getX() || event.getTo().getY() != event.getFrom().getY() || event.getTo().getZ() != event.getFrom().getZ()) { if (!player.getVelocity().equals(Bloodbending.getBloodbendingVector(player))) {
if (bPlayer.hasElement(Element.AIR) || bPlayer.hasElement(Element.CHI)) { player.setVelocity(Bloodbending.getBloodbendingVector(player));
PassiveHandler.checkExhaustionPassives(player);
} }
} }
return;
}
}
if (bPlayer != null) {
try (MCTiming timing = TimingPlayerMoveAirChiPassiveCheck) {
if (bPlayer.hasElement(Element.AIR) || bPlayer.hasElement(Element.CHI)) {
PassiveHandler.checkExhaustionPassives(player);
}
}
try (MCTiming timing = TimingPlayerMoveFirePassiveCheck.startTiming()) {
if (event.getTo().getBlock() != event.getFrom().getBlock()) { if (event.getTo().getBlock() != event.getFrom().getBlock()) {
FirePassive.handle(player); FirePassive.handle(player);
} }
} }
} }
if (event.getTo().getY() > event.getFrom().getY()) { try (MCTiming timing = TimingPlayerMoveJumpCheck.startTiming()) {
if (!(player.getLocation().getBlock().getType() == Material.VINE) && !(player.getLocation().getBlock().getType() == Material.LADDER)) { if (event.getTo().getY() > event.getFrom().getY()) {
final int current = player.getStatistic(Statistic.JUMP); if (!(player.getLocation().getBlock().getType() == Material.VINE) && !(player.getLocation().getBlock().getType() == Material.LADDER)) {
final int last = JUMPS.get(player); final int current = player.getStatistic(Statistic.JUMP);
final int last = JUMPS.get(player);
if (last != current) { if (last != current) {
JUMPS.put(player, current); JUMPS.put(player, current);
final double yDif = event.getTo().getY() - event.getFrom().getY(); final double yDif = event.getTo().getY() - event.getFrom().getY();
if ((yDif < 0.035 || yDif > 0.037) && (yDif < 0.116 || yDif > 0.118)) { if ((yDif < 0.035 || yDif > 0.037) && (yDif < 0.116 || yDif > 0.118)) {
Bukkit.getServer().getPluginManager().callEvent(new PlayerJumpEvent(player, yDif)); Bukkit.getServer().getPluginManager().callEvent(new PlayerJumpEvent(player, yDif));
}
} }
} }
} }
@ -1253,10 +1331,12 @@ public class PKListener implements Listener {
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (ProjectKorra.isStatisticsEnabled()) { if (ProjectKorra.isStatisticsEnabled()) {
ProjectKorra.statistics.store(player.getUniqueId()); Manager.getManager(StatisticsManager.class).store(player.getUniqueId());
} }
if (bPlayer != null) { if (bPlayer != null) {
bPlayer.saveCooldowns(); if (ProjectKorra.isDatabaseCooldownsEnabled()) {
bPlayer.saveCooldowns();
}
if (TOGGLED_OUT.contains(player.getUniqueId()) && bPlayer.isToggled()) { if (TOGGLED_OUT.contains(player.getUniqueId()) && bPlayer.isToggled()) {
TOGGLED_OUT.remove(player.getUniqueId()); TOGGLED_OUT.remove(player.getUniqueId());
@ -1335,18 +1415,22 @@ public class PKListener implements Listener {
BlockSource.update(player, ClickType.SHIFT_DOWN); BlockSource.update(player, ClickType.SHIFT_DOWN);
} }
if (PassiveManager.hasPassive(player, CoreAbility.getAbility(FerroControl.class))) {
new FerroControl(player);
} else if (PassiveManager.hasPassive(player, CoreAbility.getAbility(FastSwim.class))) {
new FastSwim(player);
}
AirScooter.check(player); AirScooter.check(player);
final CoreAbility coreAbil = bPlayer.getBoundAbility(); final CoreAbility coreAbil = bPlayer.getBoundAbility();
final String abil = bPlayer.getBoundAbilityName(); final String abil = bPlayer.getBoundAbilityName();
if (coreAbil == null) {
if (coreAbil == null || !coreAbil.isSneakAbility()) {
if (PassiveManager.hasPassive(player, CoreAbility.getAbility(FerroControl.class))) {
new FerroControl(player);
}
if (PassiveManager.hasPassive(player, CoreAbility.getAbility(FastSwim.class))) {
new FastSwim(player);
}
}
if (coreAbil == null) {
return; return;
} }
@ -1364,7 +1448,7 @@ public class PKListener implements Listener {
} else if (abil.equalsIgnoreCase("AirBurst")) { } else if (abil.equalsIgnoreCase("AirBurst")) {
new AirBurst(player, false); new AirBurst(player, false);
} else if (abil.equalsIgnoreCase("AirSuction")) { } else if (abil.equalsIgnoreCase("AirSuction")) {
AirSuction.setOrigin(player); new AirSuction(player);
} else if (abil.equalsIgnoreCase("AirSwipe")) { } else if (abil.equalsIgnoreCase("AirSwipe")) {
new AirSwipe(player, true); new AirSwipe(player, true);
} else if (abil.equalsIgnoreCase("AirShield")) { } else if (abil.equalsIgnoreCase("AirShield")) {
@ -1506,9 +1590,18 @@ public class PKListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerSwing(final PlayerAnimationEvent event) { public void onPlayerSwing(final PlayerInteractEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (event.getHand() != EquipmentSlot.HAND) {
return;
}
if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_AIR) {
return;
}
if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.isCancelled()) {
return;
}
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) { if (bPlayer == null) {
return; return;
@ -1543,11 +1636,6 @@ public class PKListener implements Listener {
} else if (bPlayer.isChiBlocked()) { } else if (bPlayer.isChiBlocked()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} else if (GeneralMethods.isInteractable(player.getTargetBlock(new HashSet<Material>(), 5))) {
event.setCancelled(true);
return;
} else if (player.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {
return;
} }
BlockSource.update(player, ClickType.LEFT_CLICK); BlockSource.update(player, ClickType.LEFT_CLICK);
@ -1568,7 +1656,7 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("AirBlast")) { if (abil.equalsIgnoreCase("AirBlast")) {
new AirBlast(player); new AirBlast(player);
} else if (abil.equalsIgnoreCase("AirSuction")) { } else if (abil.equalsIgnoreCase("AirSuction")) {
new AirSuction(player); AirSuction.shoot(player);
} else if (abil.equalsIgnoreCase("AirBurst")) { } else if (abil.equalsIgnoreCase("AirBurst")) {
AirBurst.coneBurst(player); AirBurst.coneBurst(player);
} else if (abil.equalsIgnoreCase("AirScooter")) { } else if (abil.equalsIgnoreCase("AirScooter")) {
@ -1589,7 +1677,11 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("Bloodbending")) { if (abil.equalsIgnoreCase("Bloodbending")) {
Bloodbending.launch(player); Bloodbending.launch(player);
} else if (abil.equalsIgnoreCase("IceBlast")) { } else if (abil.equalsIgnoreCase("IceBlast")) {
IceBlast.activate(player); if (CoreAbility.hasAbility(player, IceBullet.class)) {
CoreAbility.getAbility(player, IceBullet.class).doLeftClick();
} else {
IceBlast.activate(player);
}
} else if (abil.equalsIgnoreCase("IceSpike")) { } else if (abil.equalsIgnoreCase("IceSpike")) {
IceSpikeBlast.activate(player); IceSpikeBlast.activate(player);
} else if (abil.equalsIgnoreCase("OctopusForm")) { } else if (abil.equalsIgnoreCase("OctopusForm")) {
@ -1754,6 +1846,11 @@ public class PKListener implements Listener {
return; return;
} }
} }
if (ConfigManager.getConfig().getBoolean("Abilities.Fire.FireJet.ShowGliding")) {
if (CoreAbility.getAbility(player, FireJet.class) != null) {
event.setCancelled(true);
}
}
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -1771,6 +1868,53 @@ public class PKListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPickupItem(final EntityPickupItemEvent event) {
for (final MetalClips metalClips : CoreAbility.getAbilities(MetalClips.class)) {
if (metalClips.getTrackedIngots().contains(event.getItem())) {
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryPickupItem(final InventoryPickupItemEvent event) {
for (final MetalClips metalClips : CoreAbility.getAbilities(MetalClips.class)) {
if (metalClips.getTrackedIngots().contains(event.getItem())) {
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onItemMerge(final ItemMergeEvent event) {
for (final MetalClips metalClips : CoreAbility.getAbilities(MetalClips.class)) {
if (metalClips.getTrackedIngots().contains(event.getEntity()) || metalClips.getTrackedIngots().contains(event.getTarget())) {
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPistonExtendEvent(final BlockPistonExtendEvent event) {
for (final Block b : event.getBlocks()) {
if (TempBlock.isTempBlock(b)) {
event.setCancelled(true);
break;
}
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPistonRetractEvent(final BlockPistonRetractEvent event) {
for (final Block b : event.getBlocks()) {
if (TempBlock.isTempBlock(b)) {
event.setCancelled(true);
break;
}
}
}
public static HashMap<Player, String> getBendingPlayerDeath() { public static HashMap<Player, String> getBendingPlayerDeath() {
return BENDING_PLAYER_DEATH; return BENDING_PLAYER_DEATH;
} }

View file

@ -3,13 +3,18 @@ package com.projectkorra.projectkorra;
import java.util.HashMap; import java.util.HashMap;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.bekvon.bukkit.residence.protection.FlagPermissions;
import co.aikar.timings.lib.MCTiming;
import co.aikar.timings.lib.TimingManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import com.bekvon.bukkit.residence.protection.FlagPermissions;
import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.CollisionInitializer; import com.projectkorra.projectkorra.ability.util.CollisionInitializer;
import com.projectkorra.projectkorra.ability.util.CollisionManager; import com.projectkorra.projectkorra.ability.util.CollisionManager;
@ -22,10 +27,10 @@ import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.util.EarthbendingManager; import com.projectkorra.projectkorra.earthbending.util.EarthbendingManager;
import com.projectkorra.projectkorra.firebending.util.FirebendingManager; import com.projectkorra.projectkorra.firebending.util.FirebendingManager;
import com.projectkorra.projectkorra.hooks.PlaceholderAPIHook;
import com.projectkorra.projectkorra.hooks.WorldGuardFlag;
import com.projectkorra.projectkorra.object.Preset; import com.projectkorra.projectkorra.object.Preset;
import com.projectkorra.projectkorra.storage.DBConnection; import com.projectkorra.projectkorra.storage.DBConnection;
import com.projectkorra.projectkorra.util.DBCooldownManager;
import com.projectkorra.projectkorra.util.FlightHandler;
import com.projectkorra.projectkorra.util.Metrics; import com.projectkorra.projectkorra.util.Metrics;
import com.projectkorra.projectkorra.util.RevertChecker; import com.projectkorra.projectkorra.util.RevertChecker;
import com.projectkorra.projectkorra.util.StatisticsManager; import com.projectkorra.projectkorra.util.StatisticsManager;
@ -39,17 +44,18 @@ public class ProjectKorra extends JavaPlugin {
public static Logger log; public static Logger log;
public static CollisionManager collisionManager; public static CollisionManager collisionManager;
public static CollisionInitializer collisionInitializer; public static CollisionInitializer collisionInitializer;
public static StatisticsManager statistics;
public static DBCooldownManager cooldowns;
public static FlightHandler flightHandler;
public static long time_step = 1; public static long time_step = 1;
public Updater updater; public Updater updater;
private BukkitTask revertChecker;
private static TimingManager timingManager;
@Override @Override
public void onEnable() { public void onEnable() {
plugin = this; plugin = this;
ProjectKorra.log = this.getLogger(); ProjectKorra.log = this.getLogger();
timingManager = TimingManager.of(this);
new ConfigManager(); new ConfigManager();
new GeneralMethods(this); new GeneralMethods(this);
final boolean checkUpdateOnStartup = ConfigManager.getConfig().getBoolean("Properties.UpdateChecker"); final boolean checkUpdateOnStartup = ConfigManager.getConfig().getBoolean("Properties.UpdateChecker");
@ -70,9 +76,7 @@ public class ProjectKorra extends JavaPlugin {
return; return;
} }
statistics = new StatisticsManager(); Manager.startup();
cooldowns = new DBCooldownManager();
flightHandler = new FlightHandler();
this.getServer().getPluginManager().registerEvents(new PKListener(this), this); this.getServer().getPluginManager().registerEvents(new PKListener(this), this);
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new BendingManager(), 0, 1); this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new BendingManager(), 0, 1);
@ -81,22 +85,19 @@ public class ProjectKorra extends JavaPlugin {
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new EarthbendingManager(this), 0, 1); this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new EarthbendingManager(this), 0, 1);
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new FirebendingManager(this), 0, 1); this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new FirebendingManager(this), 0, 1);
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new ChiblockingManager(this), 0, 1); this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new ChiblockingManager(this), 0, 1);
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new RevertChecker(this), 0, 200); this.revertChecker = this.getServer().getScheduler().runTaskTimerAsynchronously(this, new RevertChecker(this), 0, 200);
if (ConfigManager.languageConfig.get().getBoolean("Chat.Branding.AutoAnnouncer.Enabled")) { if (ConfigManager.languageConfig.get().getBoolean("Chat.Branding.AutoAnnouncer.Enabled")) {
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { this.getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
@Override ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding" + ".Color").toUpperCase());
public void run() { color = color == null ? ChatColor.GOLD : color;
ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding" + ".Color").toUpperCase()); final String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder");
color = color == null ? ChatColor.GOLD : color; final String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders" + ".BottomBorder");
final String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder"); if (!topBorder.isEmpty()) {
final String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders" + ".BottomBorder"); Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', topBorder));
if (!topBorder.isEmpty()) { }
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', topBorder)); Bukkit.broadcastMessage(color + "This server is running ProjectKorra version " + ProjectKorra.plugin.getDescription().getVersion() + " for bending! Find out more at http://www" + ".projectkorra.com!");
} if (!bottomBorder.isEmpty()) {
Bukkit.broadcastMessage(color + "This server is running ProjectKorra version " + ProjectKorra.plugin.getDescription().getVersion() + " for bending! Find out more at http://www" + ".projectkorra.com!"); Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', bottomBorder));
if (!bottomBorder.isEmpty()) {
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', bottomBorder));
}
} }
}, (long) (ConfigManager.languageConfig.get().getDouble("Chat.Branding.AutoAnnouncer.Interval") * 60 * 20), (long) (ConfigManager.languageConfig.get().getDouble("Chat.Branding.AutoAnnouncer.Interval") * 60 * 20)); }, (long) (ConfigManager.languageConfig.get().getDouble("Chat.Branding.AutoAnnouncer.Interval") * 60 * 20), (long) (ConfigManager.languageConfig.get().getDouble("Chat.Branding.AutoAnnouncer.Interval") * 60 * 20));
} }
@ -107,14 +108,11 @@ public class ProjectKorra extends JavaPlugin {
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
GeneralMethods.removeUnusableAbilities(player.getName()); GeneralMethods.removeUnusableAbilities(player.getName());
statistics.load(player.getUniqueId()); Manager.getManager(StatisticsManager.class).load(player.getUniqueId());
Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, new Runnable() { Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, (Runnable) () -> {
@Override PassiveManager.registerPassives(player);
public void run() { GeneralMethods.removeUnusableAbilities(player.getName());
PassiveManager.registerPassives(player); }, 30);
GeneralMethods.removeUnusableAbilities(player.getName());
}
}, 5);
} }
final Metrics metrics = new Metrics(this); final Metrics metrics = new Metrics(this);
@ -149,25 +147,38 @@ public class ProjectKorra extends JavaPlugin {
GeneralMethods.deserializeFile(); GeneralMethods.deserializeFile();
GeneralMethods.startCacheCleaner(cacheTime); GeneralMethods.startCacheCleaner(cacheTime);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderAPIHook(this).register();
}
} }
@Override @Override
public void onDisable() { public void onDisable() {
this.revertChecker.cancel();
GeneralMethods.stopBending(); GeneralMethods.stopBending();
for (final Player player : this.getServer().getOnlinePlayers()) { for (final Player player : this.getServer().getOnlinePlayers()) {
if (isStatisticsEnabled()) { if (isStatisticsEnabled()) {
statistics.save(player.getUniqueId(), false); Manager.getManager(StatisticsManager.class).save(player.getUniqueId(), false);
} }
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer != null) { if (bPlayer != null && isDatabaseCooldownsEnabled()) {
bPlayer.saveCooldowns(); bPlayer.saveCooldowns();
} }
} }
Manager.shutdown();
if (DBConnection.isOpen()) { if (DBConnection.isOpen()) {
DBConnection.sql.close(); DBConnection.sql.close();
} }
} }
@Override
public void onLoad() {
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
WorldGuardFlag.registerBendingWorldGuardFlag();
}
}
public static CollisionManager getCollisionManager() { public static CollisionManager getCollisionManager() {
return collisionManager; return collisionManager;
} }
@ -188,4 +199,11 @@ public class ProjectKorra extends JavaPlugin {
return ConfigManager.getConfig().getBoolean("Properties.Statistics"); return ConfigManager.getConfig().getBoolean("Properties.Statistics");
} }
public static boolean isDatabaseCooldownsEnabled() {
return ConfigManager.getConfig().getBoolean("Properties.DatabaseCooldowns");
}
public static MCTiming timing(final String name) {
return timingManager.of(name);
}
} }

View file

@ -16,7 +16,6 @@ import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.airbending.AirSpout; import com.projectkorra.projectkorra.airbending.AirSpout;
import com.projectkorra.projectkorra.airbending.Suffocate; import com.projectkorra.projectkorra.airbending.Suffocate;
import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
public abstract class AirAbility extends ElementalAbility { public abstract class AirAbility extends ElementalAbility {
@ -43,8 +42,7 @@ public abstract class AirAbility extends ElementalAbility {
public void handleCollision(final Collision collision) { public void handleCollision(final Collision collision) {
super.handleCollision(collision); super.handleCollision(collision);
if (collision.isRemovingFirst()) { if (collision.isRemovingFirst()) {
final ParticleData particleData = new ParticleEffect.BlockData(Material.WOOL, (byte) 0); ParticleEffect.BLOCK_CRACK.display(collision.getLocationFirst(), 10, 1, 1, 1, 0.1, Material.WHITE_WOOL.createBlockData());
ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50);
} }
} }
@ -80,7 +78,7 @@ public abstract class AirAbility extends ElementalAbility {
} else if (particle.equalsIgnoreCase("spell")) { } else if (particle.equalsIgnoreCase("spell")) {
return ParticleEffect.SPELL; return ParticleEffect.SPELL;
} else if (particle.equalsIgnoreCase("blacksmoke")) { } else if (particle.equalsIgnoreCase("blacksmoke")) {
return ParticleEffect.SMOKE; return ParticleEffect.SMOKE_NORMAL;
} else if (particle.equalsIgnoreCase("smoke")) { } else if (particle.equalsIgnoreCase("smoke")) {
return ParticleEffect.CLOUD; return ParticleEffect.CLOUD;
} else if (particle.equalsIgnoreCase("smallsmoke")) { } else if (particle.equalsIgnoreCase("smallsmoke")) {
@ -113,7 +111,7 @@ public abstract class AirAbility extends ElementalAbility {
* @param amount The amount of particles * @param amount The amount of particles
*/ */
public static void playAirbendingParticles(final Location loc, final int amount) { public static void playAirbendingParticles(final Location loc, final int amount) {
playAirbendingParticles(loc, amount, (float) Math.random(), (float) Math.random(), (float) Math.random()); playAirbendingParticles(loc, amount, Math.random(), Math.random(), Math.random());
} }
/** /**
@ -126,8 +124,8 @@ public abstract class AirAbility extends ElementalAbility {
* @param yOffset The yOffset to use * @param yOffset The yOffset to use
* @param zOffset The zOffset to use * @param zOffset The zOffset to use
*/ */
public static void playAirbendingParticles(final Location loc, final int amount, final float xOffset, final float yOffset, final float zOffset) { public static void playAirbendingParticles(final Location loc, final int amount, final double xOffset, final double yOffset, final double zOffset) {
getAirbendingParticles().display(loc, xOffset, yOffset, zOffset, 0, amount); getAirbendingParticles().display(loc, amount, xOffset, yOffset, zOffset);
} }
/** /**
@ -144,11 +142,9 @@ public abstract class AirAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Air.Sound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Air.Sound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Air.Sound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Air.Sound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }

View file

@ -37,11 +37,9 @@ public abstract class AvatarAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Abilities.Avatar.AvatarState.Sound.Sound")); sound = Sound.valueOf(getConfig().getString("Abilities.Avatar.AvatarState.Sound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Abilities.Avatar.AvatarState.Sound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Abilities.Avatar.AvatarState.Sound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }

View file

@ -3,10 +3,13 @@ package com.projectkorra.projectkorra.ability;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -17,17 +20,29 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListMap;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import sun.reflect.ReflectionFactory;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import co.aikar.timings.lib.MCTiming;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.SubElement; import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.Manager;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.util.AbilityLoader; import com.projectkorra.projectkorra.ability.util.AbilityLoader;
import com.projectkorra.projectkorra.ability.util.AddonAbilityLoader; import com.projectkorra.projectkorra.ability.util.AddonAbilityLoader;
@ -37,12 +52,15 @@ import com.projectkorra.projectkorra.ability.util.ComboManager;
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager; import com.projectkorra.projectkorra.ability.util.MultiAbilityManager;
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager.MultiAbilityInfo; import com.projectkorra.projectkorra.ability.util.MultiAbilityManager.MultiAbilityInfo;
import com.projectkorra.projectkorra.ability.util.PassiveManager; import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.attribute.AttributeModifier;
import com.projectkorra.projectkorra.attribute.AttributePriority;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.event.AbilityEndEvent; import com.projectkorra.projectkorra.event.AbilityEndEvent;
import com.projectkorra.projectkorra.event.AbilityProgressEvent; import com.projectkorra.projectkorra.event.AbilityProgressEvent;
import com.projectkorra.projectkorra.event.AbilityStartEvent; import com.projectkorra.projectkorra.event.AbilityStartEvent;
import com.projectkorra.projectkorra.util.FlightHandler;
import sun.reflect.ReflectionFactory; import com.projectkorra.projectkorra.util.TimeUtil;
/** /**
* CoreAbility provides default implementation of an Ability, including methods * CoreAbility provides default implementation of an Ability, including methods
@ -69,18 +87,23 @@ public abstract class CoreAbility implements Ability {
private static final Map<Class<? extends CoreAbility>, CoreAbility> ABILITIES_BY_CLASS = new ConcurrentHashMap<>(); private static final Map<Class<? extends CoreAbility>, CoreAbility> ABILITIES_BY_CLASS = new ConcurrentHashMap<>();
private static final double DEFAULT_COLLISION_RADIUS = 0.3; private static final double DEFAULT_COLLISION_RADIUS = 0.3;
private static final List<String> ADDON_PLUGINS = new ArrayList<>(); private static final List<String> ADDON_PLUGINS = new ArrayList<>();
private static final Map<Class<? extends CoreAbility>, Map<String, Field>> ATTRIBUTE_FIELDS = new HashMap<>();
private static int idCounter; private static int idCounter;
protected Player player; protected Player player;
protected BendingPlayer bPlayer; protected BendingPlayer bPlayer;
protected FlightHandler flightHandler;
private final Map<String, Map<AttributePriority, Set<Pair<Number, AttributeModifier>>>> attributeModifiers = new HashMap<>();
private final Map<String, Object> attributeValues = new HashMap<>();
private boolean started; private boolean started;
private boolean removed; private boolean removed;
private boolean hidden; private boolean hidden;
private int id; private int id;
private long startTime; private long startTime;
private long startTick; private long startTick;
private boolean attributesModified;
static { static {
idCounter = Integer.MIN_VALUE; idCounter = Integer.MIN_VALUE;
@ -98,6 +121,15 @@ public abstract class CoreAbility implements Ability {
* @see #getAbility(String) * @see #getAbility(String)
*/ */
public CoreAbility() { public CoreAbility() {
for (final Field field : this.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(Attribute.class)) {
final Attribute attribute = field.getAnnotation(Attribute.class);
if (!ATTRIBUTE_FIELDS.containsKey(this.getClass())) {
ATTRIBUTE_FIELDS.put(this.getClass(), new HashMap<>());
}
ATTRIBUTE_FIELDS.get(this.getClass()).put(attribute.value(), field);
}
}
} }
/** /**
@ -113,6 +145,7 @@ public abstract class CoreAbility implements Ability {
this.player = player; this.player = player;
this.bPlayer = BendingPlayer.getBendingPlayer(player); this.bPlayer = BendingPlayer.getBendingPlayer(player);
this.flightHandler = Manager.getManager(FlightHandler.class);
this.startTime = System.currentTimeMillis(); this.startTime = System.currentTimeMillis();
this.started = false; this.started = false;
this.id = CoreAbility.idCounter; this.id = CoreAbility.idCounter;
@ -145,6 +178,7 @@ public abstract class CoreAbility implements Ability {
this.remove(); this.remove();
return; return;
} }
this.started = true; this.started = true;
this.startTime = System.currentTimeMillis(); this.startTime = System.currentTimeMillis();
final Class<? extends CoreAbility> clazz = this.getClass(); final Class<? extends CoreAbility> clazz = this.getClass();
@ -231,16 +265,28 @@ public abstract class CoreAbility implements Ability {
} }
try { try {
abil.progress(); if (!abil.attributesModified) {
abil.modifyAttributes();
abil.attributesModified = true;
}
try (MCTiming timing = ProjectKorra.timing(abil.getName()).startTiming()) {
abil.progress();
}
Bukkit.getServer().getPluginManager().callEvent(new AbilityProgressEvent(abil)); Bukkit.getServer().getPluginManager().callEvent(new AbilityProgressEvent(abil));
} } catch (final Exception e) {
catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
Bukkit.getLogger().severe(abil.toString());
try {
abil.getPlayer().sendMessage(ChatColor.YELLOW + "[" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()) + "] " + ChatColor.RED + "There was an error running " + abil.getName() + ". please notify the server owner describing exactly what you were doing at this moment");
} catch (final Exception me) {
Bukkit.getLogger().severe("unable to notify ability user of error");
}
try { try {
abil.remove(); abil.remove();
} } catch (final Exception re) {
catch (final Exception re) { Bukkit.getLogger().severe("unable to fully remove ability of above error");
re.printStackTrace();
} }
} }
} }
@ -309,7 +355,7 @@ public abstract class CoreAbility implements Ability {
* Returns a "fake" instance for a CoreAbility with the specific class. * Returns a "fake" instance for a CoreAbility with the specific class.
* *
* @param clazz the class for the type of CoreAbility to be returned * @param clazz the class for the type of CoreAbility to be returned
* @return a "fake" CoreAbility instance or null * @return a "fake" CoreAbility instance or null if the ability doesn't exist or <b>isn't enabled</b>
*/ */
public static CoreAbility getAbility(final Class<? extends CoreAbility> clazz) { public static CoreAbility getAbility(final Class<? extends CoreAbility> clazz) {
return clazz != null ? ABILITIES_BY_CLASS.get(clazz) : null; return clazz != null ? ABILITIES_BY_CLASS.get(clazz) : null;
@ -546,16 +592,13 @@ public abstract class CoreAbility implements Ability {
final AddonAbility addon = (AddonAbility) ability; final AddonAbility addon = (AddonAbility) ability;
addon.load(); addon.load();
} }
} } catch (final Exception e) {
catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} } catch (final Error e) {
catch (final Error e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} } catch (final IOException e) {
catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -609,15 +652,14 @@ public abstract class CoreAbility implements Ability {
} }
if (coreAbil instanceof PassiveAbility) { if (coreAbil instanceof PassiveAbility) {
PassiveAbility passive = (PassiveAbility) coreAbil;
coreAbil.setHiddenAbility(true); coreAbil.setHiddenAbility(true);
PassiveManager.getPassives().put(name, coreAbil); PassiveManager.getPassives().put(name, coreAbil);
if (!PassiveManager.getPassiveClasses().containsKey(coreAbil)) { if (!PassiveManager.getPassiveClasses().containsKey(passive)) {
PassiveManager.getPassiveClasses().put((PassiveAbility) coreAbil, coreAbil.getClass()); PassiveManager.getPassiveClasses().put(passive, coreAbil.getClass());
} }
PassiveManager.getPassiveClasses().put((PassiveAbility) coreAbil, coreAbil.getClass());
} }
} } catch (Exception | Error e) {
catch (Exception | Error e) {
plugin.getLogger().warning("The ability " + coreAbil.getName() + " was not able to load, if this message shows again please remove it!"); plugin.getLogger().warning("The ability " + coreAbil.getName() + " was not able to load, if this message shows again please remove it!");
e.printStackTrace(); e.printStackTrace();
ABILITIES_BY_NAME.remove(name.toLowerCase()); ABILITIES_BY_NAME.remove(name.toLowerCase());
@ -678,14 +720,14 @@ public abstract class CoreAbility implements Ability {
} }
if (coreAbil instanceof PassiveAbility) { if (coreAbil instanceof PassiveAbility) {
PassiveAbility passive = (PassiveAbility) coreAbil;
coreAbil.setHiddenAbility(true); coreAbil.setHiddenAbility(true);
PassiveManager.getPassives().put(name, coreAbil); PassiveManager.getPassives().put(name, coreAbil);
if (!PassiveManager.getPassiveClasses().containsKey(coreAbil)) { if (!PassiveManager.getPassiveClasses().containsKey(passive)) {
PassiveManager.getPassiveClasses().put((PassiveAbility) coreAbil, coreAbil.getClass()); PassiveManager.getPassiveClasses().put(passive, coreAbil.getClass());
} }
} }
} } catch (Exception | Error e) {
catch (Exception | Error e) {
plugin.getLogger().warning("The ability " + coreAbil.getName() + " was not able to load, if this message shows again please remove it!"); plugin.getLogger().warning("The ability " + coreAbil.getName() + " was not able to load, if this message shows again please remove it!");
e.printStackTrace(); e.printStackTrace();
addon.stop(); addon.stop();
@ -766,6 +808,9 @@ public abstract class CoreAbility implements Ability {
if (this.getElement() instanceof SubElement) { if (this.getElement() instanceof SubElement) {
elementName = ((SubElement) this.getElement()).getParentElement().getName(); elementName = ((SubElement) this.getElement()).getParentElement().getName();
} }
if (this instanceof ComboAbility) {
elementName = elementName + ".Combo";
}
return ConfigManager.languageConfig.get().contains("Abilities." + elementName + "." + this.getName() + ".Instructions") ? ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + this.getName() + ".Instructions") : ""; return ConfigManager.languageConfig.get().contains("Abilities." + elementName + "." + this.getName() + ".Instructions") ? ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + this.getName() + ".Instructions") : "";
} }
@ -783,6 +828,22 @@ public abstract class CoreAbility implements Ability {
return ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + this.getName() + ".Description"); return ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + this.getName() + ".Description");
} }
public String getMovePreview(final Player player) {
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
String displayedMessage = "";
if (bPlayer.isOnCooldown(this)) {
final long cooldown = bPlayer.getCooldown(this.getName()) - System.currentTimeMillis();
displayedMessage = this.getElement().getColor() + "" + ChatColor.STRIKETHROUGH + this.getName() + "" + this.getElement().getColor() + " - " + TimeUtil.formatTime(cooldown);
} else {
if (bPlayer.getStance() != null && bPlayer.getStance().getName().equals(this.getName())) {
displayedMessage = this.getElement().getColor() + "" + ChatColor.UNDERLINE + this.getName();
} else {
displayedMessage = this.getElement().getColor() + this.getName();
}
}
return displayedMessage;
}
@Override @Override
public Player getPlayer() { public Player getPlayer() {
return this.player; return this.player;
@ -908,6 +969,71 @@ public abstract class CoreAbility implements Ability {
return locations; return locations;
} }
public CoreAbility addAttributeModifier(final String attribute, final Number value, final AttributeModifier modification) {
return this.addAttributeModifier(attribute, value, modification, AttributePriority.MEDIUM);
}
public CoreAbility addAttributeModifier(final String attribute, final Number value, final AttributeModifier modificationType, final AttributePriority priority) {
Validate.notNull(attribute, "attribute cannot be null");
Validate.notNull(value, "value cannot be null");
Validate.notNull(modificationType, "modifierMethod cannot be null");
Validate.notNull(priority, "priority cannot be null");
Validate.isTrue(ATTRIBUTE_FIELDS.containsKey(this.getClass()) && ATTRIBUTE_FIELDS.get(this.getClass()).containsKey(attribute), "Attribute " + attribute + " is not a defined Attribute for " + this.getName());
if (!this.attributeModifiers.containsKey(attribute)) {
this.attributeModifiers.put(attribute, new HashMap<>());
}
if (!this.attributeModifiers.get(attribute).containsKey(priority)) {
this.attributeModifiers.get(attribute).put(priority, new HashSet<>());
}
this.attributeModifiers.get(attribute).get(priority).add(Pair.of(value, modificationType));
return this;
}
public CoreAbility setAttribute(final String attribute, final Object value) {
Validate.notNull(attribute, "attribute cannot be null");
Validate.notNull(value, "value cannot be null");
Validate.isTrue(ATTRIBUTE_FIELDS.containsKey(this.getClass()) && ATTRIBUTE_FIELDS.get(this.getClass()).containsKey(attribute), "Attribute " + attribute + " is not a defined Attribute for " + this.getName());
this.attributeValues.put(attribute, value);
return this;
}
private void modifyAttributes() {
for (final String attribute : this.attributeModifiers.keySet()) {
final Field field = ATTRIBUTE_FIELDS.get(this.getClass()).get(attribute);
final boolean accessibility = field.isAccessible();
field.setAccessible(true);
try {
for (final AttributePriority priority : AttributePriority.values()) {
if (this.attributeModifiers.get(attribute).containsKey(priority)) {
for (final Pair<Number, AttributeModifier> pair : this.attributeModifiers.get(attribute).get(priority)) {
final Object get = field.get(this);
Validate.isTrue(get instanceof Number, "The field " + field.getName() + " cannot algebraically be modified.");
final Number oldValue = (Number) field.get(this);
final Number newValue = pair.getRight().performModification(oldValue, pair.getLeft());
field.set(this, newValue);
}
}
}
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
} finally {
field.setAccessible(accessibility);
}
}
this.attributeValues.forEach((attribute, value) -> {
final Field field = ATTRIBUTE_FIELDS.get(this.getClass()).get(attribute);
final boolean accessibility = field.isAccessible();
field.setAccessible(true);
try {
field.set(this, value);
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
} finally {
field.setAccessible(accessibility);
}
});
}
/** /**
* @return the current FileConfiguration for the plugin * @return the current FileConfiguration for the plugin
*/ */
@ -969,4 +1095,9 @@ public abstract class CoreAbility implements Ability {
return DEFAULT_COLLISION_RADIUS; return DEFAULT_COLLISION_RADIUS;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} }

View file

@ -11,6 +11,8 @@ import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Levelled;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -26,11 +28,9 @@ import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.RaiseEarth; import com.projectkorra.projectkorra.earthbending.RaiseEarth;
import com.projectkorra.projectkorra.earthbending.lava.LavaFlow; import com.projectkorra.projectkorra.earthbending.lava.LavaFlow;
import com.projectkorra.projectkorra.earthbending.passive.DensityShift; import com.projectkorra.projectkorra.earthbending.passive.DensityShift;
import com.projectkorra.projectkorra.firebending.Illumination;
import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.Information; import com.projectkorra.projectkorra.util.Information;
import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempBlock;
public abstract class EarthAbility extends ElementalAbility { public abstract class EarthAbility extends ElementalAbility {
@ -87,8 +87,7 @@ public abstract class EarthAbility extends ElementalAbility {
public void handleCollision(final Collision collision) { public void handleCollision(final Collision collision) {
super.handleCollision(collision); super.handleCollision(collision);
if (collision.isRemovingFirst()) { if (collision.isRemovingFirst()) {
final ParticleData particleData = new ParticleEffect.BlockData(Material.DIRT, (byte) 0); ParticleEffect.BLOCK_CRACK.display(collision.getLocationFirst(), 10, 1, 1, 1, 0.1, Material.DIRT.createBlockData());
ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50);
} }
} }
@ -124,12 +123,12 @@ public abstract class EarthAbility extends ElementalAbility {
return isSandbendable(this.player, material); return isSandbendable(this.player, material);
} }
public void moveEarth(final Block block, final Vector direction, final int chainlength) { public boolean moveEarth(final Block block, final Vector direction, final int chainlength) {
this.moveEarth(block, direction, chainlength, true); return this.moveEarth(block, direction, chainlength, true);
} }
public boolean moveEarth(Block block, final Vector direction, final int chainlength, final boolean throwplayer) { public boolean moveEarth(Block block, final Vector direction, final int chainlength, final boolean throwplayer) {
if (this.isEarthbendable(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { if (!TempBlock.isTempBlock(block) && this.isEarthbendable(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
boolean up = false; boolean up = false;
boolean down = false; boolean down = false;
final Vector norm = direction.clone().normalize(); final Vector norm = direction.clone().normalize();
@ -155,9 +154,12 @@ public abstract class EarthAbility extends ElementalAbility {
if (DensityShift.isPassiveSand(block)) { if (DensityShift.isPassiveSand(block)) {
DensityShift.revertSand(block); DensityShift.revertSand(block);
} }
if (Illumination.isIlluminationTorch(affectedblock) && TempBlock.isTempBlock(affectedblock)) { if (TempBlock.isTempBlock(affectedblock)) {
TempBlock.get(affectedblock).revertBlock(); TempBlock.get(affectedblock).revertBlock();
} }
if (LavaFlow.isLavaFlowBlock(block)) {
LavaFlow.removeBlock(block);
}
if (affectedblock == null) { if (affectedblock == null) {
return false; return false;
@ -182,9 +184,9 @@ public abstract class EarthAbility extends ElementalAbility {
} }
if (up) { if (up) {
final Block topblock = affectedblock.getRelative(BlockFace.UP); final Block topblock = affectedblock.getRelative(BlockFace.UP);
if (topblock.getType() != Material.AIR) { if (!isAir(topblock.getType())) {
GeneralMethods.breakBlock(affectedblock); GeneralMethods.breakBlock(affectedblock);
} else if (!affectedblock.isLiquid() && affectedblock.getType() != Material.AIR) { } else if (!affectedblock.isLiquid() && !isAir(affectedblock.getType())) {
moveEarthBlock(affectedblock, topblock); moveEarthBlock(affectedblock, topblock);
} }
} else { } else {
@ -198,7 +200,7 @@ public abstract class EarthAbility extends ElementalAbility {
affectedblock = location.clone().add(negnorm.getX() * i, negnorm.getY() * i, negnorm.getZ() * i).getBlock(); affectedblock = location.clone().add(negnorm.getX() * i, negnorm.getY() * i, negnorm.getZ() * i).getBlock();
if (!this.isEarthbendable(affectedblock)) { if (!this.isEarthbendable(affectedblock)) {
if (down) { if (down) {
if (this.isTransparent(affectedblock) && !affectedblock.isLiquid() && affectedblock.getType() != Material.AIR) { if (this.isTransparent(affectedblock) && !affectedblock.isLiquid() && !isAir(affectedblock.getType())) {
moveEarthBlock(affectedblock, block); moveEarthBlock(affectedblock, block);
} }
} }
@ -221,7 +223,7 @@ public abstract class EarthAbility extends ElementalAbility {
affectedblock = location.clone().add(negnorm.getX() * i, negnorm.getY() * i, negnorm.getZ() * i).getBlock(); affectedblock = location.clone().add(negnorm.getX() * i, negnorm.getY() * i, negnorm.getZ() * i).getBlock();
if (!this.isEarthbendable(affectedblock)) { if (!this.isEarthbendable(affectedblock)) {
if (down) { if (down) {
if (this.isTransparent(affectedblock) && !affectedblock.isLiquid()) { if (this.isTransparent(affectedblock) && !affectedblock.isLiquid() && !isAir(affectedblock.getType())) {
moveEarthBlock(affectedblock, block); moveEarthBlock(affectedblock, block);
} }
} }
@ -265,28 +267,22 @@ public abstract class EarthAbility extends ElementalAbility {
info.setBlock(block); info.setBlock(block);
info.setState(block.getState()); info.setState(block.getState());
info.setData(block.getData());
} }
block.setType(Material.AIR); block.setType(Material.AIR, false);
info.setTime(System.currentTimeMillis()); info.setTime(System.currentTimeMillis());
TEMP_AIR_LOCATIONS.put(info.getID(), info); TEMP_AIR_LOCATIONS.put(info.getID(), info);
} }
public static void displaySandParticle(final Location loc, final float xOffset, final float yOffset, final float zOffset, final float amount, final float speed, final boolean red) { public static void displaySandParticle(final Location loc, final int amount, final double xOffset, final double yOffset, final double zOffset, final double speed, final boolean red) {
if (amount <= 0) { if (amount <= 0) {
return; return;
} }
for (int x = 0; x < amount; x++) { final Material sand = red ? Material.RED_SAND : Material.SAND;
if (!red) { final Material stone = red ? Material.RED_SANDSTONE : Material.SANDSTONE;
ParticleEffect.ITEM_CRACK.display(new ParticleEffect.ItemData(Material.SAND, (byte) 0), new Vector(((Math.random() - 0.5) * xOffset), ((Math.random() - 0.5) * yOffset), ((Math.random() - 0.5) * zOffset)), speed, loc, 255.0);
ParticleEffect.ITEM_CRACK.display(new ParticleEffect.ItemData(Material.SANDSTONE, (byte) 0), new Vector(((Math.random() - 0.5) * xOffset), ((Math.random() - 0.5) * yOffset), ((Math.random() - 0.5) * zOffset)), speed, loc, 255.0);
} else if (red) {
ParticleEffect.ITEM_CRACK.display(new ParticleEffect.ItemData(Material.SAND, (byte) 1), new Vector(((Math.random() - 0.5) * xOffset), ((Math.random() - 0.5) * yOffset), ((Math.random() - 0.5) * zOffset)), speed, loc, 255.0);
ParticleEffect.ITEM_CRACK.display(new ParticleEffect.ItemData(Material.RED_SANDSTONE, (byte) 0), new Vector(((Math.random() - 0.5) * xOffset), ((Math.random() - 0.5) * yOffset), ((Math.random() - 0.5) * zOffset)), speed, loc, 255.0);
}
} ParticleEffect.BLOCK_CRACK.display(loc, amount, xOffset, yOffset, zOffset, speed, sand.createBlockData());
ParticleEffect.BLOCK_CRACK.display(loc, amount, xOffset, yOffset, zOffset, speed, stone.createBlockData());
} }
/** /**
@ -346,13 +342,6 @@ public abstract class EarthAbility extends ElementalAbility {
continue; continue;
} }
if (isLavabendable(player, block)) { if (isLavabendable(player, block)) {
if (TempBlock.isTempBlock(block)) {
final TempBlock tb = TempBlock.get(block);
final byte full = 0x0;
if (tb.getState().getRawData() != full && !isLava(tb.getState().getType())) {
continue;
}
}
return block; return block;
} }
} }
@ -436,14 +425,7 @@ public abstract class EarthAbility extends ElementalAbility {
} }
public static boolean isLavabendable(final Player player, final Block block) { public static boolean isLavabendable(final Player player, final Block block) {
final byte full = 0x0; if (isLava(block) && (block.getBlockData() instanceof Levelled && ((Levelled) block.getBlockData()).getLevel() == 0)) {
if (TempBlock.isTempBlock(block)) {
final TempBlock tblock = TempBlock.instances.get(block);
if (tblock == null || !LavaFlow.getTempLavaBlocks().values().contains(tblock)) {
return false;
}
}
if (isLava(block) && block.getData() == full) {
return true; return true;
} }
return false; return false;
@ -475,19 +457,18 @@ public abstract class EarthAbility extends ElementalAbility {
MOVED_EARTH.put(target, info); MOVED_EARTH.put(target, info);
if (info.getState().getType() == Material.SAND) { if (info.getState().getType() == Material.SAND) {
if (info.getState().getRawData() == (byte) 0x1) { target.setType(Material.SANDSTONE, false);
target.setType(Material.RED_SANDSTONE); } else if (info.getState().getType() == Material.RED_SAND) {
} else { target.setType(Material.RED_SANDSTONE, false);
target.setType(Material.SANDSTONE);
}
} else if (info.getState().getType() == Material.GRAVEL) { } else if (info.getState().getType() == Material.GRAVEL) {
target.setType(Material.STONE); target.setType(Material.STONE, false);
} else if (info.getState().getType().name().endsWith("CONCRETE_POWDER")) {
target.setType(Material.getMaterial(info.getState().getType().name().replace("_POWDER", "")), false);
} else { } else {
target.setType(info.getState().getType()); target.setBlockData(info.getState().getBlockData(), false);
target.setData(info.getState().getRawData());
} }
source.setType(Material.AIR); source.setType(Material.AIR, false);
} }
public static void playEarthbendingSound(final Location loc) { public static void playEarthbendingSound(final Location loc) {
@ -499,11 +480,9 @@ public abstract class EarthAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Earth.EarthSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Earth.EarthSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Earth.EarthSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Earth.EarthSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }
@ -514,15 +493,13 @@ public abstract class EarthAbility extends ElementalAbility {
final float volume = (float) getConfig().getDouble("Properties.Earth.MetalSound.Volume"); final float volume = (float) getConfig().getDouble("Properties.Earth.MetalSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Earth.MetalSound.Pitch"); final float pitch = (float) getConfig().getDouble("Properties.Earth.MetalSound.Pitch");
Sound sound = Sound.ENTITY_IRONGOLEM_HURT; Sound sound = Sound.ENTITY_IRON_GOLEM_HURT;
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Earth.MetalSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Earth.MetalSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Earth.MetalSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Earth.MetalSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }
@ -537,11 +514,9 @@ public abstract class EarthAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Earth.SandSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Earth.SandSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Earth.SandSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Earth.SandSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }
@ -556,11 +531,9 @@ public abstract class EarthAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Earth.LavaSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Earth.LavaSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Earth.LavaSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Earth.LavaSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }
@ -579,7 +552,7 @@ public abstract class EarthAbility extends ElementalAbility {
if (MOVED_EARTH.containsKey(block)) { if (MOVED_EARTH.containsKey(block)) {
final Information info = MOVED_EARTH.get(block); final Information info = MOVED_EARTH.get(block);
if (block.getType() == Material.SANDSTONE && info.getType() == Material.SAND) { if (block.getType() == Material.SANDSTONE && info.getType() == Material.SAND) {
block.setType(Material.SAND); block.setType(Material.SAND, false);
} }
if (RaiseEarth.blockInAllAffectedBlocks(block)) { if (RaiseEarth.blockInAllAffectedBlocks(block)) {
EarthAbility.revertBlock(block); EarthAbility.revertBlock(block);
@ -601,7 +574,7 @@ public abstract class EarthAbility extends ElementalAbility {
final Information info = TEMP_AIR_LOCATIONS.get(i); final Information info = TEMP_AIR_LOCATIONS.get(i);
final Block block = info.getState().getBlock(); final Block block = info.getState().getBlock();
if (block.getType() != Material.AIR && !block.isLiquid()) { if (!ElementalAbility.isAir(block.getType()) && !block.isLiquid()) {
if (force || !MOVED_EARTH.containsKey(block)) { if (force || !MOVED_EARTH.containsKey(block)) {
TEMP_AIR_LOCATIONS.remove(i); TEMP_AIR_LOCATIONS.remove(i);
} else { } else {
@ -609,13 +582,12 @@ public abstract class EarthAbility extends ElementalAbility {
} }
return; return;
} else { } else {
info.getState().update(true); info.getState().update(true, false);
TEMP_AIR_LOCATIONS.remove(i); TEMP_AIR_LOCATIONS.remove(i);
} }
} }
public static boolean revertBlock(final Block block) { public static boolean revertBlock(final Block block) {
final byte full = 0x0;
if (!isEarthRevertOn()) { if (!isEarthRevertOn()) {
MOVED_EARTH.remove(block); MOVED_EARTH.remove(block);
return false; return false;
@ -624,18 +596,18 @@ public abstract class EarthAbility extends ElementalAbility {
final Information info = MOVED_EARTH.get(block); final Information info = MOVED_EARTH.get(block);
final Block sourceblock = info.getState().getBlock(); final Block sourceblock = info.getState().getBlock();
if (info.getState().getType() == Material.AIR) { if (ElementalAbility.isAir(info.getState().getType())) {
MOVED_EARTH.remove(block); MOVED_EARTH.remove(block);
return true; return true;
} }
if (block.equals(sourceblock)) { if (block.equals(sourceblock)) {
info.getState().update(true); info.getState().update(true, false);
if (RaiseEarth.blockInAllAffectedBlocks(sourceblock)) { if (RaiseEarth.blockInAllAffectedBlocks(sourceblock)) {
EarthAbility.revertBlock(sourceblock); RaiseEarth.revertAffectedBlock(sourceblock);
} }
if (RaiseEarth.blockInAllAffectedBlocks(block)) { if (RaiseEarth.blockInAllAffectedBlocks(block)) {
EarthAbility.revertBlock(block); RaiseEarth.revertAffectedBlock(block);
} }
MOVED_EARTH.remove(block); MOVED_EARTH.remove(block);
return true; return true;
@ -647,24 +619,27 @@ public abstract class EarthAbility extends ElementalAbility {
return true; return true;
} }
if (sourceblock.getType() == Material.AIR || sourceblock.isLiquid()) { if (ElementalAbility.isAir(sourceblock.getType()) || sourceblock.isLiquid()) {
info.getState().update(true); info.getState().update(true, false);
} else { } else {
} }
if (GeneralMethods.isAdjacentToThreeOrMoreSources(block)) { if (GeneralMethods.isAdjacentToThreeOrMoreSources(block, false)) {
block.setType(Material.WATER); final BlockData data = Material.WATER.createBlockData();
block.setData(full); if (data instanceof Levelled) {
((Levelled) data).setLevel(7);
}
block.setBlockData(data, false);
} else { } else {
block.setType(Material.AIR); block.setType(Material.AIR, false);
} }
if (RaiseEarth.blockInAllAffectedBlocks(sourceblock)) { if (RaiseEarth.blockInAllAffectedBlocks(sourceblock)) {
EarthAbility.revertBlock(sourceblock); RaiseEarth.revertAffectedBlock(sourceblock);
} }
if (RaiseEarth.blockInAllAffectedBlocks(block)) { if (RaiseEarth.blockInAllAffectedBlocks(block)) {
EarthAbility.revertBlock(block); RaiseEarth.revertAffectedBlock(block);
} }
MOVED_EARTH.remove(block); MOVED_EARTH.remove(block);
} }

View file

@ -3,18 +3,18 @@ package com.projectkorra.projectkorra.ability;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.block.data.BlockData;
import org.bukkit.entity.EntityType; import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.rpg.event.EventManager;
/** /**
* ElementalAbility is used to hold methods that should be accessible by every * ElementalAbility is used to hold methods that should be accessible by every
@ -25,6 +25,16 @@ public abstract class ElementalAbility extends CoreAbility {
private static final PotionEffectType[] POSITIVE_EFFECTS = { PotionEffectType.ABSORPTION, PotionEffectType.DAMAGE_RESISTANCE, PotionEffectType.FAST_DIGGING, PotionEffectType.FIRE_RESISTANCE, PotionEffectType.HEAL, PotionEffectType.HEALTH_BOOST, PotionEffectType.INCREASE_DAMAGE, PotionEffectType.JUMP, PotionEffectType.NIGHT_VISION, PotionEffectType.REGENERATION, PotionEffectType.SATURATION, PotionEffectType.SPEED, PotionEffectType.WATER_BREATHING }; private static final PotionEffectType[] POSITIVE_EFFECTS = { PotionEffectType.ABSORPTION, PotionEffectType.DAMAGE_RESISTANCE, PotionEffectType.FAST_DIGGING, PotionEffectType.FIRE_RESISTANCE, PotionEffectType.HEAL, PotionEffectType.HEALTH_BOOST, PotionEffectType.INCREASE_DAMAGE, PotionEffectType.JUMP, PotionEffectType.NIGHT_VISION, PotionEffectType.REGENERATION, PotionEffectType.SATURATION, PotionEffectType.SPEED, PotionEffectType.WATER_BREATHING };
private static final PotionEffectType[] NEUTRAL_EFFECTS = { PotionEffectType.INVISIBILITY }; private static final PotionEffectType[] NEUTRAL_EFFECTS = { PotionEffectType.INVISIBILITY };
private static final PotionEffectType[] NEGATIVE_EFFECTS = { PotionEffectType.POISON, PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER }; private static final PotionEffectType[] NEGATIVE_EFFECTS = { PotionEffectType.POISON, PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER };
private static final Set<Material> TRANSPARENT = new HashSet<>();
static {
TRANSPARENT.clear();
for (final Material mat : Material.values()) {
if (GeneralMethods.isTransparent(mat)) {
TRANSPARENT.add(mat);
}
}
}
public ElementalAbility(final Player player) { public ElementalAbility(final Player player) {
super(player); super(player);
@ -39,16 +49,15 @@ public abstract class ElementalAbility extends CoreAbility {
} }
public static Material[] getTransparentMaterials() { public static Material[] getTransparentMaterials() {
return GeneralMethods.NON_OPAQUE; return TRANSPARENT.toArray(new Material[TRANSPARENT.size()]);
} }
public static HashSet<Material> getTransparentMaterialSet() { public static HashSet<Material> getTransparentMaterialSet() {
final HashSet<Material> set = new HashSet<Material>(); return new HashSet<>(TRANSPARENT);
for (final Material material : getTransparentMaterials()) { }
set.add(material);
}
return set; public static boolean isAir(final Material material) {
return material == Material.AIR || material == Material.CAVE_AIR || material == Material.VOID_AIR;
} }
public static boolean isDay(final World world) { public static boolean isDay(final World world) {
@ -73,19 +82,10 @@ public abstract class ElementalAbility extends CoreAbility {
} }
public static boolean isFullMoon(final World world) { public static boolean isFullMoon(final World world) {
if (GeneralMethods.hasRPG()) { final double days = Math.ceil(world.getFullTime() / 24000) + 1;
final String event = EventManager.marker.get(world); final double phase = days % 8;
return event != null && event.equalsIgnoreCase("FullMoon");
} else {
final long days = world.getFullTime() / 24000;
final long phase = days % 8;
if (phase == 0) { return phase == 0;
return true;
}
return false;
}
} }
public static boolean isIce(final Block block) { public static boolean isIce(final Block block) {
@ -101,7 +101,7 @@ public abstract class ElementalAbility extends CoreAbility {
} }
public static boolean isLava(final Material material) { public static boolean isLava(final Material material) {
return material == Material.LAVA || material == Material.STATIONARY_LAVA; return material == Material.LAVA;
} }
public static boolean isSnow(final Block block) { public static boolean isSnow(final Block block) {
@ -112,26 +112,8 @@ public abstract class ElementalAbility extends CoreAbility {
return getConfig().getStringList("Properties.Water.SnowBlocks").contains(material.toString()); return getConfig().getStringList("Properties.Water.SnowBlocks").contains(material.toString());
} }
public static boolean isLunarEclipse(final World world) {
if (world == null || !GeneralMethods.hasRPG()) {
return false;
}
final String event = EventManager.marker.get(world);
return event != null && event.equalsIgnoreCase("LunarEclipse");
}
public static boolean isSolarEclipse(final World world) {
if (world == null || !GeneralMethods.hasRPG() || !EventManager.marker.containsKey(world)) {
return false;
}
final String event = EventManager.marker.get(world);
return event != null && event.equalsIgnoreCase("SolarEclipse");
}
public static boolean isMeltable(final Block block) { public static boolean isMeltable(final Block block) {
if (block.getType() == Material.ICE || block.getType() == Material.SNOW) { if (isIce(block) || isSnow(block)) {
return true; return true;
} }
@ -147,7 +129,7 @@ public abstract class ElementalAbility extends CoreAbility {
} }
public static boolean isMetalBlock(final Block block) { public static boolean isMetalBlock(final Block block) {
if (block.getType() == Material.GOLD_BLOCK || block.getType() == Material.IRON_BLOCK || block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.QUARTZ_BLOCK || block.getType() == Material.QUARTZ_ORE) { if (block.getType() == Material.GOLD_BLOCK || block.getType() == Material.IRON_BLOCK || block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.QUARTZ_BLOCK || block.getType() == Material.NETHER_QUARTZ_ORE) {
return true; return true;
} }
@ -214,15 +196,6 @@ public abstract class ElementalAbility extends CoreAbility {
return getConfig().getStringList("Properties.Earth.SandBlocks").contains(material.toString()); return getConfig().getStringList("Properties.Earth.SandBlocks").contains(material.toString());
} }
public static boolean isSozinsComet(final World world) {
if (world == null || !GeneralMethods.hasRPG()) {
return false;
}
final String event = EventManager.marker.get(world);
return event != null && event.equalsIgnoreCase("SozinsComet");
}
public static boolean isTransparent(final Player player, final Block block) { public static boolean isTransparent(final Player player, final Block block) {
return isTransparent(player, null, block); return isTransparent(player, null, block);
} }
@ -231,22 +204,22 @@ public abstract class ElementalAbility extends CoreAbility {
return Arrays.asList(getTransparentMaterials()).contains(block.getType()) && !GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation()); return Arrays.asList(getTransparentMaterials()).contains(block.getType()) && !GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation());
} }
public static boolean isUndead(final Entity entity) { public static boolean isWater(final Block block) {
if (entity == null) { if (block == null) {
return false; return false;
} else if (entity.getType() == EntityType.ZOMBIE || entity.getType() == EntityType.BLAZE || entity.getType() == EntityType.GIANT || entity.getType() == EntityType.IRON_GOLEM || entity.getType() == EntityType.MAGMA_CUBE || entity.getType() == EntityType.PIG_ZOMBIE || entity.getType() == EntityType.SKELETON || entity.getType() == EntityType.SLIME || entity.getType() == EntityType.SNOWMAN || entity.getType() == EntityType.ZOMBIE) { } else if (isWater(block.getType())) {
return true; return true;
} else {
return isWater(block.getBlockData());
} }
return false;
} }
public static boolean isWater(final Block block) { public static boolean isWater(final BlockData data) {
return block != null ? isWater(block.getType()) : null; return (data instanceof Waterlogged) ? ((Waterlogged) data).isWaterlogged() : isWater(data.getMaterial());
} }
public static boolean isWater(final Material material) { public static boolean isWater(final Material material) {
return material == Material.WATER || material == Material.STATIONARY_WATER; return material == Material.WATER || material == Material.SEAGRASS || material == Material.TALL_SEAGRASS || material == Material.KELP_PLANT || material == Material.KELP || material == Material.BUBBLE_COLUMN;
} }
} }

View file

@ -1,7 +1,6 @@
package com.projectkorra.projectkorra.ability; package com.projectkorra.projectkorra.ability;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -25,13 +24,10 @@ import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.firebending.BlazeArc; import com.projectkorra.projectkorra.firebending.BlazeArc;
import com.projectkorra.projectkorra.util.Information; import com.projectkorra.projectkorra.util.Information;
import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
import com.projectkorra.rpg.RPGMethods;
public abstract class FireAbility extends ElementalAbility { public abstract class FireAbility extends ElementalAbility {
private static final Map<Location, Information> TEMP_FIRE = new ConcurrentHashMap<Location, Information>(); private static final Map<Location, Information> TEMP_FIRE = new ConcurrentHashMap<Location, Information>();
private static final Material[] IGNITABLE_MATERIALS = { Material.BEDROCK, Material.BOOKSHELF, Material.BRICK, Material.CLAY, Material.CLAY_BRICK, Material.COAL_ORE, Material.COBBLESTONE, Material.DIAMOND_ORE, Material.DIAMOND_BLOCK, Material.DIRT, Material.ENDER_STONE, Material.GLOWING_REDSTONE_ORE, Material.GOLD_BLOCK, Material.GRAVEL, Material.GRASS, Material.HUGE_MUSHROOM_1, Material.HUGE_MUSHROOM_2, Material.LAPIS_BLOCK, Material.LAPIS_ORE, Material.LOG, Material.MOSSY_COBBLESTONE, Material.MYCEL, Material.NETHER_BRICK, Material.NETHERRACK, Material.OBSIDIAN, Material.REDSTONE_ORE, Material.SAND, Material.SANDSTONE, Material.SMOOTH_BRICK, Material.STONE, Material.SOUL_SAND, Material.WOOD, Material.WOOL, Material.LEAVES, Material.LEAVES_2, Material.MELON_BLOCK, Material.PUMPKIN, Material.JACK_O_LANTERN, Material.NOTE_BLOCK, Material.GLOWSTONE, Material.IRON_BLOCK, Material.DISPENSER, Material.SPONGE, Material.IRON_ORE, Material.GOLD_ORE, Material.COAL_BLOCK, Material.WORKBENCH, Material.HAY_BLOCK, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.EMERALD_ORE, Material.EMERALD_BLOCK, Material.REDSTONE_BLOCK, Material.QUARTZ_BLOCK, Material.QUARTZ_ORE, Material.STAINED_CLAY, Material.HARD_CLAY };
public FireAbility(final Player player) { public FireAbility(final Player player) {
super(player); super(player);
@ -56,15 +52,10 @@ public abstract class FireAbility extends ElementalAbility {
public void handleCollision(final Collision collision) { public void handleCollision(final Collision collision) {
super.handleCollision(collision); super.handleCollision(collision);
if (collision.isRemovingFirst()) { if (collision.isRemovingFirst()) {
final ParticleData particleData = new ParticleEffect.BlockData(Material.FIRE, (byte) 0); ParticleEffect.BLOCK_CRACK.display(collision.getLocationFirst(), 10, 1, 1, 1, 0.1, Material.FIRE.createBlockData());
ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50);
} }
} }
public double getDayFactor(final double value) {
return this.player != null ? getDayFactor(value, this.player.getWorld()) : 1;
}
/** /**
* Returns if fire is allowed to completely replace blocks or if it should * Returns if fire is allowed to completely replace blocks or if it should
* place a temp fire block. * place a temp fire block.
@ -78,7 +69,7 @@ public abstract class FireAbility extends ElementalAbility {
* fire dissipates or is destroyed. * fire dissipates or is destroyed.
*/ */
public static void createTempFire(final Location loc) { public static void createTempFire(final Location loc) {
if (loc.getBlock().getType() == Material.AIR) { if (ElementalAbility.isAir(loc.getBlock().getType())) {
loc.getBlock().setType(Material.FIRE); loc.getBlock().setType(Material.FIRE);
return; return;
} }
@ -96,6 +87,10 @@ public abstract class FireAbility extends ElementalAbility {
TEMP_FIRE.put(loc, info); TEMP_FIRE.put(loc, info);
} }
public double getDayFactor(final double value) {
return this.player != null ? value * getDayFactor() : 1;
}
public static double getDayFactor() { public static double getDayFactor() {
return getConfig().getDouble("Properties.Fire.DayFactor"); return getConfig().getDouble("Properties.Fire.DayFactor");
} }
@ -113,17 +108,7 @@ public abstract class FireAbility extends ElementalAbility {
*/ */
public static double getDayFactor(final double value, final World world) { public static double getDayFactor(final double value, final World world) {
if (isDay(world)) { if (isDay(world)) {
if (GeneralMethods.hasRPG()) { return value * getDayFactor();
if (isSozinsComet(world)) {
return RPGMethods.getFactor("SozinsComet") * value;
} else if (isLunarEclipse(world)) {
return RPGMethods.getFactor("SolarEclipse") * value;
} else {
return value * getDayFactor();
}
} else {
return value * getDayFactor();
}
} }
return value; return value;
} }
@ -137,7 +122,7 @@ public abstract class FireAbility extends ElementalAbility {
} }
public static boolean isIgnitable(final Material material) { public static boolean isIgnitable(final Material material) {
return Arrays.asList(IGNITABLE_MATERIALS).contains(material); return material.isFlammable() || material.isBurnable();
} }
/** /**
@ -161,22 +146,20 @@ public abstract class FireAbility extends ElementalAbility {
final float volume = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Volume"); final float volume = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Pitch"); final float pitch = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Pitch");
Sound sound = Sound.ENTITY_FIREWORK_BLAST; Sound sound = Sound.ENTITY_FIREWORK_ROCKET_BLAST;
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Fire.CombustionSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Fire.CombustionSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Fire.CombustionSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Fire.CombustionSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }
} }
public static void playFirebendingParticles(final Location loc, final int amount, final float xOffset, final float yOffset, final float zOffset) { public static void playFirebendingParticles(final Location loc, final int amount, final double xOffset, final double yOffset, final double zOffset) {
ParticleEffect.FLAME.display(loc, xOffset, yOffset, zOffset, 0, amount); ParticleEffect.FLAME.display(loc, amount, xOffset, yOffset, zOffset);
} }
public static void playFirebendingSound(final Location loc) { public static void playFirebendingSound(final Location loc) {
@ -188,25 +171,20 @@ public abstract class FireAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Fire.FireSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Fire.FireSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Fire.FireSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Fire.FireSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }
} }
public static void playLightningbendingParticle(final Location loc) { public static void playLightningbendingParticle(final Location loc) {
playLightningbendingParticle(loc, (float) Math.random(), (float) Math.random(), (float) Math.random()); playLightningbendingParticle(loc, Math.random(), Math.random(), Math.random());
} }
public static void playLightningbendingParticle(final Location loc, final float xOffset, final float yOffset, final float zOffset) { public static void playLightningbendingParticle(final Location loc, final double xOffset, final double yOffset, final double zOffset) {
loc.setX(loc.getX() + Math.random() * (xOffset / 2 - -(xOffset / 2))); GeneralMethods.displayColoredParticle("#01E1FF", loc, 1, xOffset, yOffset, zOffset);
loc.setY(loc.getY() + Math.random() * (yOffset / 2 - -(yOffset / 2)));
loc.setZ(loc.getZ() + Math.random() * (zOffset / 2 - -(zOffset / 2)));
GeneralMethods.displayColoredParticle(loc, "#01E1FF");
} }
public static void playLightningbendingSound(final Location loc) { public static void playLightningbendingSound(final Location loc) {
@ -218,11 +196,9 @@ public abstract class FireAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Fire.LightningSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Fire.LightningSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Fire.LightningSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Fire.LightningSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }
@ -234,9 +210,9 @@ public abstract class FireAbility extends ElementalAbility {
while (it.hasNext()) { while (it.hasNext()) {
final Location loc = it.next(); final Location loc = it.next();
final Information info = TEMP_FIRE.get(loc); final Information info = TEMP_FIRE.get(loc);
if (info.getLocation().getBlock().getType() != Material.FIRE && info.getLocation().getBlock().getType() != Material.AIR) { if (info.getLocation().getBlock().getType() != Material.FIRE && !ElementalAbility.isAir(info.getLocation().getBlock().getType())) {
revertTempFire(loc); revertTempFire(loc);
} else if (info.getBlock().getType() == Material.AIR || System.currentTimeMillis() > info.getTime()) { } else if (ElementalAbility.isAir(info.getBlock().getType()) || System.currentTimeMillis() > info.getTime()) {
revertTempFire(loc); revertTempFire(loc);
} }
} }
@ -252,14 +228,14 @@ public abstract class FireAbility extends ElementalAbility {
return; return;
} }
final Information info = TEMP_FIRE.get(location); final Information info = TEMP_FIRE.get(location);
if (info.getLocation().getBlock().getType() != Material.FIRE && info.getLocation().getBlock().getType() != Material.AIR) { if (info.getLocation().getBlock().getType() != Material.FIRE && !ElementalAbility.isAir(info.getLocation().getBlock().getType())) {
if (info.getState().getType() == Material.RED_ROSE || info.getState().getType() == Material.YELLOW_FLOWER) { if (info.getState().getType().isBurnable() && !info.getState().getType().isOccluding()) {
final ItemStack itemStack = new ItemStack(info.getState().getData().getItemType(), 1, info.getState().getRawData()); final ItemStack itemStack = new ItemStack(info.getState().getType(), 1);
info.getState().getBlock().getWorld().dropItemNaturally(info.getLocation(), itemStack); info.getState().getBlock().getWorld().dropItemNaturally(info.getLocation(), itemStack);
} }
} else { } else {
info.getBlock().setType(info.getState().getType()); info.getBlock().setType(info.getState().getType());
info.getBlock().setData(info.getState().getRawData()); info.getBlock().setBlockData(info.getState().getBlockData());
} }
TEMP_FIRE.remove(location); TEMP_FIRE.remove(location);
} }

View file

@ -6,14 +6,14 @@ public interface PassiveAbility {
* This is a check to see if the passive requires some form of activation, * This is a check to see if the passive requires some form of activation,
* such as sneaking, clicking, etc. <br> * such as sneaking, clicking, etc. <br>
* <b>If false, the passive should not call start!</b> * <b>If false, the passive should not call start!</b>
* *
* @return false if this passive should always be on * @return false if this passive should always be on
*/ */
public boolean isInstantiable(); public boolean isInstantiable();
/** /**
* This is used if the passive should progress * This is used if the passive should progress
* *
* @return false if progress() shouldn't be called; * @return false if progress() shouldn't be called;
*/ */
public boolean isProgressable(); public boolean isProgressable();

View file

@ -1,12 +1,16 @@
package com.projectkorra.projectkorra.ability; package com.projectkorra.projectkorra.ability;
import org.bukkit.Effect; import java.util.HashSet;
import java.util.Set;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.Tag;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Levelled;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -18,14 +22,13 @@ import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.firebending.HeatControl; import com.projectkorra.projectkorra.firebending.HeatControl;
import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.waterbending.SurgeWall; import com.projectkorra.projectkorra.waterbending.SurgeWall;
import com.projectkorra.projectkorra.waterbending.SurgeWave; import com.projectkorra.projectkorra.waterbending.SurgeWave;
import com.projectkorra.projectkorra.waterbending.Torrent;
import com.projectkorra.projectkorra.waterbending.WaterSpout; import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.projectkorra.waterbending.ice.PhaseChange; import com.projectkorra.projectkorra.waterbending.ice.PhaseChange;
import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms;
import com.projectkorra.rpg.RPGMethods;
public abstract class WaterAbility extends ElementalAbility { public abstract class WaterAbility extends ElementalAbility {
@ -50,17 +53,6 @@ public abstract class WaterAbility extends ElementalAbility {
return getIceSourceBlock(this.player, range); return getIceSourceBlock(this.player, range);
} }
public double getNightFactor() {
if (this.getLocation() != null) {
return getNightFactor(this.getLocation().getWorld());
}
return this.player != null ? getNightFactor(this.player.getLocation().getWorld()) : 1;
}
public double getNightFactor(final double value) {
return this.player != null ? getNightFactor(value, this.player.getWorld()) : value;
}
public Block getPlantSourceBlock(final double range) { public Block getPlantSourceBlock(final double range) {
return this.getPlantSourceBlock(range, false); return this.getPlantSourceBlock(range, false);
} }
@ -83,17 +75,20 @@ public abstract class WaterAbility extends ElementalAbility {
public void handleCollision(final Collision collision) { public void handleCollision(final Collision collision) {
super.handleCollision(collision); super.handleCollision(collision);
if (collision.isRemovingFirst()) { if (collision.isRemovingFirst()) {
final ParticleData particleData = new ParticleEffect.BlockData(Material.WATER, (byte) 0); ParticleEffect.BLOCK_CRACK.display(collision.getLocationFirst(), 10, 1, 1, 1, 0.1, collision.getLocationFirst().getBlock().getBlockData());
ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50);
} }
} }
public double getNightFactor(final double value) {
return this.player != null ? value * getNightFactor() : 1;
}
public static boolean isBendableWaterTempBlock(final Block block) { // TODO: Will need to be done for earth as well. public static boolean isBendableWaterTempBlock(final Block block) { // TODO: Will need to be done for earth as well.
return isBendableWaterTempBlock(TempBlock.get(block)); return isBendableWaterTempBlock(TempBlock.get(block));
} }
public static boolean isBendableWaterTempBlock(final TempBlock tempBlock) { public static boolean isBendableWaterTempBlock(final TempBlock tempBlock) {
return PhaseChange.getFrozenBlocksAsTempBlock().contains(tempBlock) || HeatControl.getMeltedBlocks().contains(tempBlock) || SurgeWall.SOURCE_BLOCKS.contains(tempBlock); return PhaseChange.getFrozenBlocksMap().containsKey(tempBlock) || HeatControl.getMeltedBlocks().contains(tempBlock) || SurgeWall.SOURCE_BLOCKS.contains(tempBlock) || Torrent.getFrozenBlocks().containsKey(tempBlock);
} }
public boolean isIcebendable(final Block block) { public boolean isIcebendable(final Block block) {
@ -154,26 +149,16 @@ public abstract class WaterAbility extends ElementalAbility {
return null; return null;
} }
public static double getNightFactor() {
return getConfig().getDouble("Properties.Water.NightFactor");
}
public static double getNightFactor(final double value, final World world) { public static double getNightFactor(final double value, final World world) {
if (isNight(world)) { if (isNight(world)) {
if (GeneralMethods.hasRPG()) { return value * getNightFactor();
if (isLunarEclipse(world)) {
return RPGMethods.getFactor("LunarEclipse") * value;
} else if (isFullMoon(world)) {
return RPGMethods.getFactor("FullMoon") * value;
} else {
return getConfig().getDouble("Properties.Water.NightFactor") * value;
}
} else {
if (isFullMoon(world)) {
return getConfig().getDouble("Properties.Water.FullMoonFactor") * value;
} else {
return getConfig().getDouble("Properties.Water.NightFactor") * value;
}
}
} else {
return value;
} }
return value;
} }
public static double getNightFactor(final World world) { public static double getNightFactor(final World world) {
@ -214,7 +199,20 @@ public abstract class WaterAbility extends ElementalAbility {
final Vector vector = location.getDirection().clone().normalize(); final Vector vector = location.getDirection().clone().normalize();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
final Block testBlock = player.getTargetBlock(getTransparentMaterialSet(), range > 3 ? 3 : (int) range); final Set<Material> trans = getTransparentMaterialSet();
if (plantbending) {
final Set<Material> remove = new HashSet<>();
for (final Material m : trans) {
if (isPlant(m)) {
remove.add(m);
}
}
trans.removeAll(remove);
}
final Block testBlock = player.getTargetBlock(trans, range > 3 ? 3 : (int) range);
if (bPlayer == null) { if (bPlayer == null) {
return null; return null;
} else if (isWaterbendable(player, null, testBlock) && (!isPlant(testBlock) || plantbending)) { } else if (isWaterbendable(player, null, testBlock) && (!isPlant(testBlock) || plantbending)) {
@ -265,7 +263,7 @@ public abstract class WaterAbility extends ElementalAbility {
} }
public static boolean isLeaves(final Material material) { public static boolean isLeaves(final Material material) {
return material == Material.LEAVES || material == Material.LEAVES_2; return Tag.LEAVES.isTagged(material);
} }
public static boolean isSnow(final Block block) { public static boolean isSnow(final Block block) {
@ -277,14 +275,13 @@ public abstract class WaterAbility extends ElementalAbility {
} }
public static boolean isWaterbendable(final Player player, final String abilityName, final Block block) { public static boolean isWaterbendable(final Player player, final String abilityName, final Block block) {
final byte full = 0x0;
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null || !isWaterbendable(block.getType()) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) { if (bPlayer == null || !isWaterbendable(block.getType()) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) {
return false; return false;
} }
if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) { if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) {
return false; return false;
} else if (isWater(block) && block.getData() == full) { } else if (isWater(block) && block.getBlockData() instanceof Levelled && ((Levelled) block.getBlockData()).getLevel() == 0) {
return true; return true;
} else if (isIce(block) && !bPlayer.canIcebend()) { } else if (isIce(block) && !bPlayer.canIcebend()) {
return false; return false;
@ -295,7 +292,7 @@ public abstract class WaterAbility extends ElementalAbility {
} }
public static void playFocusWaterEffect(final Block block) { public static void playFocusWaterEffect(final Block block) {
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 4, 20); ParticleEffect.SMOKE_NORMAL.display(block.getLocation().add(0.5, 0.5, 0.5), 4);
} }
public static void playIcebendingSound(final Location loc) { public static void playIcebendingSound(final Location loc) {
@ -307,11 +304,9 @@ public abstract class WaterAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Water.IceSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Water.IceSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Water.IceSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Water.IceSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }
@ -326,11 +321,9 @@ public abstract class WaterAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Water.PlantSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Water.PlantSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Water.PlantSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Water.PlantSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }
@ -345,11 +338,9 @@ public abstract class WaterAbility extends ElementalAbility {
try { try {
sound = Sound.valueOf(getConfig().getString("Properties.Water.WaterSound.Sound")); sound = Sound.valueOf(getConfig().getString("Properties.Water.WaterSound.Sound"));
} } catch (final IllegalArgumentException exception) {
catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Water.WaterSound.Sound' is not valid."); ProjectKorra.log.warning("Your current value for 'Properties.Water.WaterSound.Sound' is not valid.");
} } finally {
finally {
loc.getWorld().playSound(loc, sound, volume, pitch); loc.getWorld().playSound(loc, sound, volume, pitch);
} }
} }

View file

@ -12,14 +12,14 @@ import java.util.List;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import sun.reflect.ReflectionFactory;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.event.AbilityLoadEvent; import com.projectkorra.projectkorra.event.AbilityLoadEvent;
import sun.reflect.ReflectionFactory;
public class AbilityLoader<T> { public class AbilityLoader<T> {
private final Plugin plugin; private final Plugin plugin;
@ -47,8 +47,7 @@ public class AbilityLoader<T> {
this.jar = new JarFile(new File(s)); this.jar = new JarFile(new File(s));
} } catch (final IOException e) {
catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -102,8 +101,7 @@ public class AbilityLoader<T> {
loadables.add(loadable); loadables.add(loadable);
final AbilityLoadEvent<T> event = new AbilityLoadEvent<T>(this.plugin, loadable, this.jar); final AbilityLoadEvent<T> event = new AbilityLoadEvent<T>(this.plugin, loadable, this.jar);
this.plugin.getServer().getPluginManager().callEvent(event); this.plugin.getServer().getPluginManager().callEvent(event);
} } catch (Exception | Error e) {
catch (Exception | Error e) {
continue; continue;
} }
} }

View file

@ -14,13 +14,13 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Level; import java.util.logging.Level;
import sun.reflect.ReflectionFactory;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import com.projectkorra.projectkorra.event.AbilityLoadEvent; import com.projectkorra.projectkorra.event.AbilityLoadEvent;
import com.projectkorra.projectkorra.util.FileExtensionFilter; import com.projectkorra.projectkorra.util.FileExtensionFilter;
import sun.reflect.ReflectionFactory;
public class AddonAbilityLoader<T> { public class AddonAbilityLoader<T> {
private final Plugin plugin; private final Plugin plugin;
@ -45,8 +45,7 @@ public class AddonAbilityLoader<T> {
for (final File file : this.files) { for (final File file : this.files) {
try { try {
urls.add(file.toURI().toURL()); urls.add(file.toURI().toURL());
} } catch (final MalformedURLException e) {
catch (final MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -79,8 +78,7 @@ public class AddonAbilityLoader<T> {
Class<?> clazz = null; Class<?> clazz = null;
try { try {
clazz = Class.forName(className, true, this.loader); clazz = Class.forName(className, true, this.loader);
} } catch (Exception | Error e) {
catch (Exception | Error e) {
continue; continue;
} }
@ -98,18 +96,15 @@ public class AddonAbilityLoader<T> {
this.plugin.getServer().getPluginManager().callEvent(event); this.plugin.getServer().getPluginManager().callEvent(event);
} }
} } catch (Exception | Error e) {
catch (Exception | Error e) {
e.printStackTrace(); e.printStackTrace();
this.plugin.getLogger().log(Level.WARNING, "Unknown cause"); this.plugin.getLogger().log(Level.WARNING, "Unknown cause");
this.plugin.getLogger().log(Level.WARNING, "The JAR file " + file.getName() + " failed to load"); this.plugin.getLogger().log(Level.WARNING, "The JAR file " + file.getName() + " failed to load");
} } finally {
finally {
if (jarFile != null) { if (jarFile != null) {
try { try {
jarFile.close(); jarFile.close();
} } catch (final IOException e) {
catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View file

@ -215,9 +215,14 @@ public class CollisionInitializer {
return; return;
} }
this.largeAbilities.add(largeAbility); this.largeAbilities.add(largeAbility);
for (final CoreAbility otherLargeAbility : this.largeAbilities) {
this.collisionManager.addCollision(new Collision(largeAbility, otherLargeAbility, true, true));
}
for (final CoreAbility smallAbility : this.smallAbilities) { for (final CoreAbility smallAbility : this.smallAbilities) {
this.collisionManager.addCollision(new Collision(largeAbility, smallAbility, false, true)); this.collisionManager.addCollision(new Collision(largeAbility, smallAbility, false, true));
} }
} }
/** /**
@ -252,11 +257,9 @@ public class CollisionInitializer {
} }
/** /**
* An ability that collides with other small abilities. (EarthBlast, * Cancel interaction between two abilities
* FireBlast). Two colliding small abilities will remove each other. A small
* ability is removed when it collides with a large ability.
* *
* @param smallAbility the small CoreAbility * @param ignoreAbility the small CoreAbility
*/ */
public void addIgnoreAbility(final CoreAbility ignoreAbility) { public void addIgnoreAbility(final CoreAbility ignoreAbility) {
if (ignoreAbility == null) { if (ignoreAbility == null) {

View file

@ -19,8 +19,6 @@ import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.combo.EarthDomeOthers; import com.projectkorra.projectkorra.earthbending.combo.EarthDomeOthers;
import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.ReflectionHandler; import com.projectkorra.projectkorra.util.ReflectionHandler;
import com.projectkorra.projectkorra.waterbending.combo.IceBullet.IceBulletLeftClick;
import com.projectkorra.projectkorra.waterbending.combo.IceBullet.IceBulletRightClick;
public class ComboManager { public class ComboManager {
private static final long CLEANUP_DELAY = 20 * 60; private static final long CLEANUP_DELAY = 20 * 60;
@ -35,15 +33,6 @@ public class ComboManager {
DESCRIPTIONS.clear(); DESCRIPTIONS.clear();
INSTRUCTIONS.clear(); INSTRUCTIONS.clear();
if (ConfigManager.defaultConfig.get().getBoolean("Abilities.Water.IceBullet.Enabled")) {
final ArrayList<AbilityInformation> iceBulletLeft = new ArrayList<>();
iceBulletLeft.add(new AbilityInformation("IceBlast", ClickType.LEFT_CLICK));
COMBO_ABILITIES.put("IceBulletLeftClick", new ComboAbilityInfo("IceBulletLeftClick", iceBulletLeft, IceBulletLeftClick.class));
final ArrayList<AbilityInformation> iceBulletRight = new ArrayList<>();
iceBulletRight.add(new AbilityInformation("IceBlast", ClickType.RIGHT_CLICK_BLOCK));
COMBO_ABILITIES.put("IceBulletRightClick", new ComboAbilityInfo("IceBulletRightClick", iceBulletRight, IceBulletRightClick.class));
}
if (ConfigManager.defaultConfig.get().getBoolean("Abilities.Earth.EarthDome.Enabled")) { if (ConfigManager.defaultConfig.get().getBoolean("Abilities.Earth.EarthDome.Enabled")) {
final ArrayList<AbilityInformation> earthDomeOthers = new ArrayList<>(); final ArrayList<AbilityInformation> earthDomeOthers = new ArrayList<>();
earthDomeOthers.add(new AbilityInformation("RaiseEarth", ClickType.RIGHT_CLICK_BLOCK)); earthDomeOthers.add(new AbilityInformation("RaiseEarth", ClickType.RIGHT_CLICK_BLOCK));
@ -82,8 +71,7 @@ public class ComboManager {
final Class<?> clazz = (Class<?>) comboAbil.getComboType(); final Class<?> clazz = (Class<?>) comboAbil.getComboType();
try { try {
ReflectionHandler.instantiateObject(clazz, player); ReflectionHandler.instantiateObject(clazz, player);
} } catch (final Exception e) {
catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {

View file

@ -15,7 +15,7 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.event.BindChangeEvent; import com.projectkorra.projectkorra.event.PlayerBindChangeEvent;
public class MultiAbilityManager { public class MultiAbilityManager {
@ -43,7 +43,7 @@ public class MultiAbilityManager {
* @param multiAbility MultiAbility being bound * @param multiAbility MultiAbility being bound
*/ */
public static void bindMultiAbility(final Player player, final String multiAbility) { public static void bindMultiAbility(final Player player, final String multiAbility) {
final BindChangeEvent event = new BindChangeEvent(player, multiAbility, true); final PlayerBindChangeEvent event = new PlayerBindChangeEvent(player, multiAbility, true);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

View file

@ -48,8 +48,7 @@ public class PassiveManager {
final Constructor<?> constructor = clazz.getConstructor(Player.class); final Constructor<?> constructor = clazz.getConstructor(Player.class);
final Object object = constructor.newInstance(player); final Object object = constructor.newInstance(player);
((CoreAbility) object).start(); ((CoreAbility) object).start();
} } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View file

@ -9,15 +9,16 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.data.Levelled;
import org.bukkit.block.data.type.Door;
import org.bukkit.block.data.type.Switch;
import org.bukkit.block.data.type.TrapDoor;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.material.Button;
import org.bukkit.material.Door;
import org.bukkit.material.Lever;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -37,6 +38,9 @@ public class AirBlast extends AirAbility {
private static final int MAX_TICKS = 10000; private static final int MAX_TICKS = 10000;
private static final Map<Player, Location> ORIGINS = new ConcurrentHashMap<>(); private static final Map<Player, Location> ORIGINS = new ConcurrentHashMap<>();
public static final Material[] DOORS = { Material.ACACIA_DOOR, Material.BIRCH_DOOR, Material.DARK_OAK_DOOR, Material.JUNGLE_DOOR, Material.OAK_DOOR, Material.SPRUCE_DOOR };
public static final Material[] TDOORS = { Material.ACACIA_TRAPDOOR, Material.BIRCH_TRAPDOOR, Material.DARK_OAK_TRAPDOOR, Material.JUNGLE_TRAPDOOR, Material.OAK_TRAPDOOR, Material.SPRUCE_TRAPDOOR };
public static final Material[] BUTTONS = { Material.ACACIA_BUTTON, Material.BIRCH_BUTTON, Material.DARK_OAK_BUTTON, Material.JUNGLE_BUTTON, Material.OAK_BUTTON, Material.SPRUCE_BUTTON, Material.STONE_BUTTON };
private boolean canFlickLevers; private boolean canFlickLevers;
private boolean canOpenDoors; private boolean canOpenDoors;
@ -51,9 +55,9 @@ public class AirBlast extends AirAbility {
private double speedFactor; private double speedFactor;
@Attribute(Attribute.RANGE) @Attribute(Attribute.RANGE)
private double range; private double range;
@Attribute(Attribute.POWER) @Attribute(Attribute.KNOCKBACK)
private double pushFactor; private double pushFactor;
@Attribute(Attribute.POWER) @Attribute(Attribute.KNOCKBACK + "Others")
private double pushFactorForOthers; private double pushFactorForOthers;
@Attribute(Attribute.DAMAGE) @Attribute(Attribute.DAMAGE)
private double damage; private double damage;
@ -137,8 +141,8 @@ public class AirBlast extends AirAbility {
this.speed = getConfig().getDouble("Abilities.Air.AirBlast.Speed"); this.speed = getConfig().getDouble("Abilities.Air.AirBlast.Speed");
this.range = getConfig().getDouble("Abilities.Air.AirBlast.Range"); this.range = getConfig().getDouble("Abilities.Air.AirBlast.Range");
this.radius = getConfig().getDouble("Abilities.Air.AirBlast.Radius"); this.radius = getConfig().getDouble("Abilities.Air.AirBlast.Radius");
this.pushFactor = getConfig().getDouble("Abilities.Air.AirBlast.Push.Entities"); this.pushFactor = getConfig().getDouble("Abilities.Air.AirBlast.Push.Self");
this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirBlast.Push.Self"); this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirBlast.Push.Entities");
this.canFlickLevers = getConfig().getBoolean("Abilities.Air.AirBlast.CanFlickLevers"); this.canFlickLevers = getConfig().getBoolean("Abilities.Air.AirBlast.CanFlickLevers");
this.canOpenDoors = getConfig().getBoolean("Abilities.Air.AirBlast.CanOpenDoors"); this.canOpenDoors = getConfig().getBoolean("Abilities.Air.AirBlast.CanOpenDoors");
this.canPressButtons = getConfig().getBoolean("Abilities.Air.AirBlast.CanPressButtons"); this.canPressButtons = getConfig().getBoolean("Abilities.Air.AirBlast.CanPressButtons");
@ -208,75 +212,72 @@ public class AirBlast extends AirAbility {
} }
private void affect(final Entity entity) { private void affect(final Entity entity) {
final boolean isUser = entity.getUniqueId() == this.player.getUniqueId(); if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) {
if (!isUser || this.isFromOtherOrigin) {
this.pushFactor = this.pushFactorForOthers;
final Vector velocity = entity.getVelocity();
final double max = this.speed / this.speedFactor;
double factor = this.pushFactor;
final Vector push = this.direction.clone();
if (Math.abs(push.getY()) > max && !isUser) {
if (push.getY() < 0) {
push.setY(-max);
} else {
push.setY(max);
}
}
if (this.location.getWorld().equals(this.origin.getWorld())) {
factor *= 1 - this.location.distance(this.origin) / (2 * this.range);
}
if (isUser && GeneralMethods.isSolid(this.player.getLocation().add(0, -.5, 0).getBlock())) {
factor *= .5;
}
final double comp = velocity.dot(push.clone().normalize());
if (comp > factor) {
velocity.multiply(.5);
velocity.add(push.clone().normalize().multiply(velocity.clone().dot(push.clone().normalize())));
} else if (comp + factor * .5 > factor) {
velocity.add(push.clone().multiply(factor - comp));
} else {
velocity.add(push.clone().multiply(factor * .5));
}
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) {
return;
}
}
if (Double.isNaN(velocity.length())) {
return; return;
} }
}
final boolean isUser = entity.getUniqueId() == this.player.getUniqueId();
double knockback = this.pushFactorForOthers;
GeneralMethods.setVelocity(entity, velocity); if (isUser) {
if (this.source != null) { if (isFromOtherOrigin) {
new HorizontalVelocityTracker(entity, this.player, 200l, this.source); knockback = this.pushFactor;
} else { } else {
new HorizontalVelocityTracker(entity, this.player, 200l, this); return;
}
if (!isUser && entity instanceof Player) {
ProjectKorra.flightHandler.createInstance((Player) entity, this.player, 1000L, this.getName());
}
if (entity.getFireTicks() > 0) {
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
}
entity.setFireTicks(0);
breakBreathbendingHold(entity);
if (this.source != null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player) && !this.affectedEntities.contains(entity))) {
DamageHandler.damageEntity(entity, this.damage, this.source);
this.affectedEntities.add(entity);
} else if (this.source == null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player) && !this.affectedEntities.contains(entity))) {
DamageHandler.damageEntity(entity, this.damage, this);
this.affectedEntities.add(entity);
} }
} }
final double max = this.speed / this.speedFactor;
final Vector push = this.direction.clone();
if (Math.abs(push.getY()) > max && !isUser) {
if (push.getY() < 0) {
push.setY(-max);
} else {
push.setY(max);
}
}
if (this.location.getWorld().equals(this.origin.getWorld())) {
knockback *= 1 - this.location.distance(this.origin) / (2 * this.range);
}
if (GeneralMethods.isSolid(entity.getLocation().add(0, -0.5, 0).getBlock()) && source == null) {
knockback *= 0.85;
}
push.normalize().multiply(knockback);
if (Math.abs(entity.getVelocity().dot(push)) > knockback && entity.getVelocity().angle(push) > Math.PI / 3) {
push.normalize().add(entity.getVelocity()).multiply(knockback);
}
GeneralMethods.setVelocity(entity, push);
if (this.source != null) {
new HorizontalVelocityTracker(entity, this.player, 200l, this.source);
} else {
new HorizontalVelocityTracker(entity, this.player, 200l, this);
}
if (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(this.player) && !this.affectedEntities.contains(entity)) {
if (this.source != null) {
DamageHandler.damageEntity(entity, this.damage, this.source);
} else {
DamageHandler.damageEntity(entity, this.damage, this);
}
this.affectedEntities.add(entity);
}
if (entity.getFireTicks() > 0) {
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
}
entity.setFireTicks(0);
breakBreathbendingHold(entity);
} }
@Override @Override
@ -297,119 +298,109 @@ public class AirBlast extends AirAbility {
return; return;
} }
Block block = this.location.getBlock(); final Block block = this.location.getBlock();
for (final Block testblock : GeneralMethods.getBlocksAroundPoint(this.location, this.radius)) { for (final Block testblock : GeneralMethods.getBlocksAroundPoint(this.location, this.radius)) {
if (testblock.getType() == Material.FIRE) { if (testblock.getType() == Material.FIRE) {
testblock.setType(Material.AIR); testblock.setType(Material.AIR);
testblock.getWorld().playEffect(testblock.getLocation(), Effect.EXTINGUISH, 0); testblock.getWorld().playEffect(testblock.getLocation(), Effect.EXTINGUISH, 0);
} continue;
if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { } else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
continue;
} else if (this.affectedLevers.contains(testblock)) {
continue; continue;
} }
final Material doorTypes[] = { Material.WOODEN_DOOR, Material.SPRUCE_DOOR, Material.BIRCH_DOOR, Material.JUNGLE_DOOR, Material.ACACIA_DOOR, Material.DARK_OAK_DOOR, Material.TRAP_DOOR }; if (Arrays.asList(DOORS).contains(testblock.getType())) {
if (Arrays.asList(doorTypes).contains(block.getType()) && !this.affectedLevers.contains(block) && this.canOpenDoors) { if (testblock.getBlockData() instanceof Door) {
if (block.getData() >= 8 && block.getType() != Material.TRAP_DOOR) { final Door door = (Door) testblock.getBlockData();
block = block.getRelative(BlockFace.DOWN); final BlockFace face = door.getFacing();
} final Vector toPlayer = GeneralMethods.getDirection(block.getLocation(), this.player.getLocation().getBlock().getLocation());
final double[] dims = { toPlayer.getX(), toPlayer.getY(), toPlayer.getZ() };
this.handleDoorMechanics(block); for (int i = 0; i < 3; i++) {
} if (i == 1) {
if ((block.getType() == Material.LEVER) && !this.affectedLevers.contains(block) && this.canFlickLevers) { continue;
final Lever lever = new Lever(Material.LEVER, block.getData()); }
lever.setPowered(!lever.isPowered());
block.setData(lever.getData());
final Block supportBlock = block.getRelative(lever.getAttachedFace()); final BlockFace bf = GeneralMethods.getBlockFaceFromValue(i, dims[i]);
if (supportBlock != null && supportBlock.getType() != Material.AIR) {
final BlockState initialSupportState = supportBlock.getState();
final BlockState supportState = supportBlock.getState();
supportState.setType(Material.AIR);
supportState.update(true, false);
initialSupportState.update(true);
}
this.affectedLevers.add(block);
} else if ((block.getType() == Material.STONE_BUTTON) && !this.affectedLevers.contains(block) && this.canPressButtons) {
final Button button = new Button(Material.STONE_BUTTON, block.getData());
if (!button.isPowered()) {
button.setPowered(!button.isPowered());
block.setData(button.getData());
final Block supportBlock = block.getRelative(button.getAttachedFace()); if (bf == face) {
if (supportBlock != null && supportBlock.getType() != Material.AIR) { if (!door.isOpen()) {
final BlockState initialSupportState = supportBlock.getState(); return;
final BlockState supportState = supportBlock.getState(); }
supportState.setType(Material.AIR); } else if (bf.getOppositeFace() == face) {
supportState.update(true, false); if (door.isOpen()) {
initialSupportState.update(true); return;
}
final Block btBlock = block;
new BukkitRunnable() {
@Override
public void run() {
button.setPowered(!button.isPowered());
btBlock.setData(button.getData());
final Block supportBlock = btBlock.getRelative(button.getAttachedFace());
if (supportBlock != null && supportBlock.getType() != Material.AIR) {
final BlockState initialSupportState = supportBlock.getState();
final BlockState supportState = supportBlock.getState();
supportState.setType(Material.AIR);
supportState.update(true, false);
initialSupportState.update(true);
} }
} }
}.runTaskLater(ProjectKorra.plugin, 10);
this.affectedLevers.add(block);
}
} else if ((block.getType() == Material.WOOD_BUTTON) && !this.affectedLevers.contains(block) && this.canPressButtons) {
final Button button = new Button(Material.WOOD_BUTTON, block.getData());
if (!button.isPowered()) {
button.setPowered(!button.isPowered());
block.setData(button.getData());
final Block supportBlock = block.getRelative(button.getAttachedFace());
if (supportBlock != null && supportBlock.getType() != Material.AIR) {
final BlockState initialSupportState = supportBlock.getState();
final BlockState supportState = supportBlock.getState();
supportState.setType(Material.AIR);
supportState.update(true, false);
initialSupportState.update(true);
} }
final Block btBlock = block; door.setOpen(!door.isOpen());
testblock.setBlockData(door);
testblock.getWorld().playSound(testblock.getLocation(), Sound.valueOf("BLOCK_WOODEN_DOOR_" + (door.isOpen() ? "OPEN" : "CLOSE")), 0.5f, 0);
this.affectedLevers.add(testblock);
}
} else if (Arrays.asList(TDOORS).contains(testblock.getType())) {
if (testblock.getBlockData() instanceof TrapDoor) {
final TrapDoor tDoor = (TrapDoor) testblock.getBlockData();
new BukkitRunnable() { if (this.origin.getY() < block.getY()) {
@Override if (!tDoor.isOpen()) {
public void run() { return;
button.setPowered(!button.isPowered());
btBlock.setData(button.getData());
final Block supportBlock = btBlock.getRelative(button.getAttachedFace());
if (supportBlock != null && supportBlock.getType() != Material.AIR) {
final BlockState initialSupportState = supportBlock.getState();
final BlockState supportState = supportBlock.getState();
supportState.setType(Material.AIR);
supportState.update(true, false);
initialSupportState.update(true);
}
} }
}.runTaskLater(ProjectKorra.plugin, 15); } else {
if (tDoor.isOpen()) {
return;
}
}
this.affectedLevers.add(block); tDoor.setOpen(!tDoor.isOpen());
testblock.setBlockData(tDoor);
testblock.getWorld().playSound(testblock.getLocation(), Sound.valueOf("BLOCK_WOODEN_TRAPDOOR_" + (tDoor.isOpen() ? "OPEN" : "CLOSE")), 0.5f, 0);
}
} else if (Arrays.asList(BUTTONS).contains(testblock.getType())) {
if (testblock.getBlockData() instanceof Switch) {
final Switch button = (Switch) testblock.getBlockData();
if (!button.isPowered()) {
button.setPowered(true);
testblock.setBlockData(button);
this.affectedLevers.add(testblock);
new BukkitRunnable() {
@Override
public void run() {
button.setPowered(false);
testblock.setBlockData(button);
AirBlast.this.affectedLevers.remove(testblock);
testblock.getWorld().playSound(testblock.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_OFF, 0.5f, 0);
}
}.runTaskLater(ProjectKorra.plugin, 15);
}
testblock.getWorld().playSound(testblock.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 0.5f, 0);
}
} else if (testblock.getType() == Material.LEVER) {
if (testblock.getBlockData() instanceof Switch) {
final Switch lever = (Switch) testblock.getBlockData();
lever.setPowered(!lever.isPowered());
testblock.setBlockData(lever);
this.affectedLevers.add(testblock);
testblock.getWorld().playSound(testblock.getLocation(), Sound.BLOCK_LEVER_CLICK, 0.5f, 0);
} }
} }
} }
if ((GeneralMethods.isSolid(block) || block.isLiquid()) && !this.affectedLevers.contains(block) && this.canCoolLava) { if ((GeneralMethods.isSolid(block) || block.isLiquid()) && !this.affectedLevers.contains(block) && this.canCoolLava) {
if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) { if (block.getType() == Material.LAVA) {
if (LavaFlow.isLavaFlowBlock(block)) { if (LavaFlow.isLavaFlowBlock(block)) {
LavaFlow.removeBlock(block); // TODO: Make more generic for future lava generating moves. LavaFlow.removeBlock(block); // TODO: Make more generic for future lava generating moves.
} else if (block.getData() == 0x0) { } else if (block.getBlockData() instanceof Levelled && ((Levelled) block.getBlockData()).getLevel() == 0) {
new TempBlock(block, Material.OBSIDIAN, (byte) 0); new TempBlock(block, Material.OBSIDIAN);
} else { } else {
new TempBlock(block, Material.COBBLESTONE, (byte) 0); new TempBlock(block, Material.COBBLESTONE);
} }
} }
this.remove(); this.remove();
@ -432,6 +423,9 @@ public class AirBlast extends AirAbility {
} }
for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, this.radius)) { for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, this.radius)) {
if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) {
continue;
}
this.affect(entity); this.affect(entity);
} }
@ -458,52 +452,6 @@ public class AirBlast extends AirAbility {
return removed; return removed;
} }
private void handleDoorMechanics(final Block block) {
boolean tDoor = false;
final boolean open = (block.getData() & 0x4) == 0x4;
if (block.getType() != Material.TRAP_DOOR) {
final Door door = (Door) block.getState().getData();
final BlockFace face = door.getFacing();
final Vector toPlayer = GeneralMethods.getDirection(block.getLocation(), this.player.getLocation().getBlock().getLocation());
final double[] dims = { toPlayer.getX(), toPlayer.getY(), toPlayer.getZ() };
for (int i = 0; i < 3; i++) {
if (i == 1) {
continue;
}
final BlockFace bf = GeneralMethods.getBlockFaceFromValue(i, dims[i]);
if (bf == face) {
if (open) {
return;
}
} else if (bf.getOppositeFace() == face) {
if (!open) {
return;
}
}
}
} else {
tDoor = true;
if (this.origin.getY() < block.getY()) {
if (!open) {
return;
}
} else {
if (open) {
return;
}
}
}
block.setData((byte) ((block.getData() & 0x4) == 0x4 ? (block.getData() & ~0x4) : (block.getData() | 0x4)));
final String sound = "BLOCK_WOODEN_" + (tDoor ? "TRAP" : "") + "DOOR_" + (!open ? "OPEN" : "CLOSE");
block.getWorld().playSound(block.getLocation(), sound, 0.5f, 0);
this.affectedLevers.add(block);
}
@Override @Override
public String getName() { public String getName() {
return "AirBlast"; return "AirBlast";

View file

@ -21,9 +21,10 @@ public class AirBurst extends AirAbility {
private float playerFallDistance; private float playerFallDistance;
@Attribute(Attribute.CHARGE_DURATION) @Attribute(Attribute.CHARGE_DURATION)
private long chargeTime; private long chargeTime;
@Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
private double fallThreshold; private double fallThreshold;
@Attribute(Attribute.POWER) @Attribute(Attribute.KNOCKBACK)
private double pushFactor; private double pushFactor;
@Attribute(Attribute.DAMAGE) @Attribute(Attribute.DAMAGE)
private double damage; private double damage;
@ -320,8 +321,4 @@ public class AirBurst extends AirAbility {
public ArrayList<AirBlast> getBlasts() { public ArrayList<AirBlast> getBlasts() {
return this.blasts; return this.blasts;
} }
public ArrayList<Entity> getAffectedEntities() {
return this.affectedEntities;
}
} }

View file

@ -3,15 +3,18 @@ package com.projectkorra.projectkorra.airbending;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import org.bukkit.Difficulty;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.attribute.Attribute;
@ -25,11 +28,15 @@ public class AirScooter extends AirAbility {
private double radius; private double radius;
@Attribute(Attribute.COOLDOWN) @Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@Attribute(Attribute.DURATION)
private long duration; private long duration;
@Attribute(Attribute.HEIGHT)
private double maxHeightFromGround; private double maxHeightFromGround;
private Block floorblock; private Block floorblock;
private Random random; private Random random;
private ArrayList<Double> angles; private ArrayList<Double> angles;
private Slime slime;
private Boolean useslime;
private double phi = 0; private double phi = 0;
@ -38,7 +45,7 @@ public class AirScooter extends AirAbility {
if (check(player)) { if (check(player)) {
return; return;
} else if (!player.isSprinting() || GeneralMethods.isSolid(player.getEyeLocation().getBlock()) || player.getEyeLocation().getBlock().isLiquid()) { } else if (!player.isSprinting() || GeneralMethods.isSolid(player.getEyeLocation().getBlock()) || ElementalAbility.isWater(player.getEyeLocation().getBlock())) {
return; return;
} else if (GeneralMethods.isSolid(player.getLocation().add(0, -.5, 0).getBlock())) { } else if (GeneralMethods.isSolid(player.getLocation().add(0, -.5, 0).getBlock())) {
return; return;
@ -52,10 +59,11 @@ public class AirScooter extends AirAbility {
this.cooldown = getConfig().getLong("Abilities.Air.AirScooter.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Air.AirScooter.Cooldown");
this.duration = getConfig().getLong("Abilities.Air.AirScooter.Duration"); this.duration = getConfig().getLong("Abilities.Air.AirScooter.Duration");
this.maxHeightFromGround = getConfig().getDouble("Abilities.Air.AirScooter.MaxHeightFromGround"); this.maxHeightFromGround = getConfig().getDouble("Abilities.Air.AirScooter.MaxHeightFromGround");
this.useslime = getConfig().getBoolean("Abilities.Air.AirScooter.ShowSitting");
this.random = new Random(); this.random = new Random();
this.angles = new ArrayList<>(); this.angles = new ArrayList<>();
ProjectKorra.flightHandler.createInstance(player, this.getName()); this.flightHandler.createInstance(player, this.getName());
player.setAllowFlight(true); player.setAllowFlight(true);
player.setFlying(true); player.setFlying(true);
@ -65,6 +73,21 @@ public class AirScooter extends AirAbility {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
this.angles.add((double) (60 * i)); this.angles.add((double) (60 * i));
} }
if (player.getWorld().getDifficulty() == Difficulty.PEACEFUL) {
this.useslime = false;
}
if (this.useslime) {
this.slime = (Slime) player.getWorld().spawnEntity(player.getLocation(), EntityType.SLIME);
if (this.slime != null) {
this.slime.setSize(1);
this.slime.setSilent(true);
this.slime.setInvulnerable(true);
this.slime.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, true, false));
this.slime.addPassenger(player);
} else {
this.useslime = false;
}
}
this.start(); this.start();
} }
@ -91,7 +114,7 @@ public class AirScooter extends AirAbility {
this.floorblock = null; this.floorblock = null;
for (int i = 0; i <= this.maxHeightFromGround; i++) { for (int i = 0; i <= this.maxHeightFromGround; i++) {
final Block block = this.player.getEyeLocation().getBlock().getRelative(BlockFace.DOWN, i); final Block block = this.player.getEyeLocation().getBlock().getRelative(BlockFace.DOWN, i);
if (GeneralMethods.isSolid(block) || block.isLiquid()) { if (GeneralMethods.isSolid(block) || ElementalAbility.isWater(block)) {
this.floorblock = block; this.floorblock = block;
return; return;
} }
@ -121,15 +144,28 @@ public class AirScooter extends AirAbility {
return; return;
} }
if (this.useslime && (this.slime == null || !this.slime.getPassengers().contains(this.player))) {
this.bPlayer.addCooldown(this);
this.remove();
return;
}
Vector velocity = this.player.getEyeLocation().getDirection().clone().normalize(); Vector velocity = this.player.getEyeLocation().getDirection().clone().normalize();
velocity = velocity.clone().normalize().multiply(this.speed); velocity = velocity.clone().normalize().multiply(this.speed);
/* /*
* checks the players speed and ends the move if they are going too slow * checks the players speed and ends the move if they are going too slow
*/ */
if (System.currentTimeMillis() > this.getStartTime() + this.interval) { if (System.currentTimeMillis() > this.getStartTime() + this.interval) {
if (this.player.getVelocity().length() < this.speed * 0.3) { if (this.useslime) {
this.remove(); if (this.slime.getVelocity().length() < this.speed * 0.3) {
return; this.remove();
return;
}
} else {
if (this.player.getVelocity().length() < this.speed * 0.3) {
this.remove();
return;
}
} }
this.spinScooter(); this.spinScooter();
} }
@ -138,21 +174,21 @@ public class AirScooter extends AirAbility {
* lowers the player based on their distance from the ground. * lowers the player based on their distance from the ground.
*/ */
final double distance = this.player.getLocation().getY() - this.floorblock.getY(); final double distance = this.player.getLocation().getY() - this.floorblock.getY();
final double dx = Math.abs(distance - 2.4); Math.abs(distance - 2.4);
if (distance > 2.75) { if (distance > 2.75) {
velocity.setY(-.25 * dx * dx); velocity.setY(-.25);
} else if (distance < 2) { } else if (distance < 2) {
velocity.setY(.25 * dx * dx); velocity.setY(.25);
} else { } else {
velocity.setY(0); velocity.setY(0);
} }
final Vector v = velocity.clone().setY(0); final Vector v = velocity.clone().setY(0);
final Block b = this.floorblock.getLocation().clone().add(v.multiply(1.2)).getBlock(); final Block b = this.floorblock.getLocation().clone().add(v.multiply(1.2)).getBlock();
if (!GeneralMethods.isSolid(b) && !b.isLiquid()) { if (!GeneralMethods.isSolid(b) && !ElementalAbility.isWater(b)) {
velocity.add(new Vector(0, -0.6, 0)); velocity.add(new Vector(0, -0.1, 0));
} else if (GeneralMethods.isSolid(b.getRelative(BlockFace.UP)) || b.getRelative(BlockFace.UP).isLiquid()) { } else if (GeneralMethods.isSolid(b.getRelative(BlockFace.UP)) || ElementalAbility.isWater(b.getRelative(BlockFace.UP))) {
velocity.add(new Vector(0, 1.0, 0)); velocity.add(new Vector(0, 0.7, 0));
} }
final Location loc = this.player.getLocation(); final Location loc = this.player.getLocation();
@ -164,7 +200,11 @@ public class AirScooter extends AirAbility {
this.player.setSprinting(false); this.player.setSprinting(false);
this.player.removePotionEffect(PotionEffectType.SPEED); this.player.removePotionEffect(PotionEffectType.SPEED);
this.player.setVelocity(velocity); if (this.useslime) {
this.slime.setVelocity(velocity);
} else {
this.player.setVelocity(velocity);
}
if (this.random.nextInt(4) == 0) { if (this.random.nextInt(4) == 0) {
playAirbendingSound(this.player.getLocation()); playAirbendingSound(this.player.getLocation());
@ -177,7 +217,10 @@ public class AirScooter extends AirAbility {
@Override @Override
public void remove() { public void remove() {
super.remove(); super.remove();
ProjectKorra.flightHandler.removeInstance(this.player, this.getName()); if (this.slime != null) {
this.slime.remove();
}
this.flightHandler.removeInstance(this.player, this.getName());
this.bPlayer.addCooldown(this); this.bPlayer.addCooldown(this);
} }

View file

@ -22,30 +22,39 @@ import com.projectkorra.projectkorra.command.Commands;
public class AirShield extends AirAbility { public class AirShield extends AirAbility {
private boolean isToggledByAvatarState; private boolean isToggledByAvatarState;
@Attribute(Attribute.RADIUS) @Attribute("Max" + Attribute.RADIUS)
private double maxRadius; private double maxRadius;
@Attribute(Attribute.RADIUS) @Attribute("Initial" + Attribute.RADIUS)
private double initialRadius;
private double radius; private double radius;
@Attribute(Attribute.SPEED) @Attribute(Attribute.SPEED)
private double speed; private double speed;
private int streams; private int streams;
private int particles; private int particles;
@Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@Attribute(Attribute.DURATION)
private long duration; private long duration;
private Random random; private Random random;
private HashMap<Integer, Integer> angles; private HashMap<Integer, Integer> angles;
private boolean dynamicCooldown;
public AirShield(final Player player) { public AirShield(final Player player) {
super(player); super(player);
this.maxRadius = getConfig().getDouble("Abilities.Air.AirShield.Radius"); this.maxRadius = getConfig().getDouble("Abilities.Air.AirShield.MaxRadius");
this.initialRadius = getConfig().getDouble("Abilities.Air.AirShield.InitialRadius");
this.isToggledByAvatarState = getConfig().getBoolean("Abilities.Avatar.AvatarState.Air.AirShield.IsAvatarStateToggle"); this.isToggledByAvatarState = getConfig().getBoolean("Abilities.Avatar.AvatarState.Air.AirShield.IsAvatarStateToggle");
this.radius = this.maxRadius; this.radius = this.initialRadius;
this.cooldown = getConfig().getLong("Abilities.Air.AirShield.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Air.AirShield.Cooldown");
this.duration = getConfig().getLong("Abilities.Air.AirShield.Duration"); this.duration = getConfig().getLong("Abilities.Air.AirShield.Duration");
this.speed = getConfig().getDouble("Abilities.Air.AirShield.Speed"); this.speed = getConfig().getDouble("Abilities.Air.AirShield.Speed");
this.streams = getConfig().getInt("Abilities.Air.AirShield.Streams"); this.streams = getConfig().getInt("Abilities.Air.AirShield.Streams");
this.particles = getConfig().getInt("Abilities.Air.AirShield.Particles"); this.particles = getConfig().getInt("Abilities.Air.AirShield.Particles");
this.dynamicCooldown = getConfig().getBoolean("Abilities.Air.AirShield.DynamicCooldown"); //any unused duration from shield is removed from the cooldown
if (this.duration == 0) {
this.dynamicCooldown = false;
}
this.random = new Random(); this.random = new Random();
this.angles = new HashMap<>(); this.angles = new HashMap<>();
@ -91,7 +100,15 @@ public class AirShield extends AirAbility {
return; return;
} else if (!this.bPlayer.isAvatarState() || !this.isToggledByAvatarState) { } else if (!this.bPlayer.isAvatarState() || !this.isToggledByAvatarState) {
if (!this.player.isSneaking() || !this.bPlayer.canBend(this)) { if (!this.player.isSneaking() || !this.bPlayer.canBend(this)) {
this.bPlayer.addCooldown(this); if (this.dynamicCooldown) {
Long reducedCooldown = this.cooldown - (this.duration - (System.currentTimeMillis() - this.getStartTime()));
if (reducedCooldown < 0L) {
reducedCooldown = 0L;
}
this.bPlayer.addCooldown(this, reducedCooldown);
} else {
this.bPlayer.addCooldown(this);
}
this.remove(); this.remove();
return; return;
} else if (this.duration != 0) { } else if (this.duration != 0) {
@ -128,7 +145,7 @@ public class AirShield extends AirAbility {
vx = (x * Math.cos(angle) - z * Math.sin(angle)) / mag; vx = (x * Math.cos(angle) - z * Math.sin(angle)) / mag;
vz = (x * Math.sin(angle) + z * Math.cos(angle)) / mag; vz = (x * Math.sin(angle) + z * Math.cos(angle)) / mag;
final Vector velocity = entity.getVelocity(); final Vector velocity = entity.getVelocity().clone();
if (this.bPlayer.isAvatarState()) { if (this.bPlayer.isAvatarState()) {
velocity.setX(AvatarState.getValue(vx)); velocity.setX(AvatarState.getValue(vx));
velocity.setZ(AvatarState.getValue(vz)); velocity.setZ(AvatarState.getValue(vz));

View file

@ -10,8 +10,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.attribute.Attribute;
@ -22,6 +22,7 @@ public class AirSpout extends AirAbility {
private int angle; private int angle;
private long animTime; private long animTime;
private long interval; private long interval;
@Attribute(Attribute.DURATION)
private long duration; private long duration;
@Attribute(Attribute.COOLDOWN) @Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@ -53,7 +54,7 @@ public class AirSpout extends AirAbility {
return; return;
} }
ProjectKorra.flightHandler.createInstance(player, this.getName()); this.flightHandler.createInstance(player, this.getName());
if (this.bPlayer.isAvatarState()) { if (this.bPlayer.isAvatarState()) {
this.height = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSpout.Height"); this.height = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSpout.Height");
@ -89,8 +90,21 @@ public class AirSpout extends AirAbility {
} }
private void allowFlight() { private void allowFlight() {
this.player.setAllowFlight(true); if (!this.player.getAllowFlight()) {
this.player.setFlying(true); this.player.setAllowFlight(true);
}
if (!this.player.isFlying()) {
this.player.setFlying(true);
}
}
private void removeFlight() {
if (this.player.isFlying()) {
this.player.setFlying(false);
}
if (this.player.getAllowFlight()) {
this.player.setAllowFlight(false);
}
} }
private boolean isWithinMaxSpoutHeight(final double threshold) { private boolean isWithinMaxSpoutHeight(final double threshold) {
@ -109,7 +123,7 @@ public class AirSpout extends AirAbility {
final Block standingblock = this.player.getLocation().getBlock(); final Block standingblock = this.player.getLocation().getBlock();
for (int i = 0; i <= this.height + 5; i++) { for (int i = 0; i <= this.height + 5; i++) {
final Block block = standingblock.getRelative(BlockFace.DOWN, i); final Block block = standingblock.getRelative(BlockFace.DOWN, i);
if (GeneralMethods.isSolid(block) || block.isLiquid()) { if (GeneralMethods.isSolid(block) || ElementalAbility.isWater(block)) {
return block; return block;
} }
} }
@ -135,7 +149,7 @@ public class AirSpout extends AirAbility {
} }
final Block eyeBlock = this.player.getEyeLocation().getBlock(); final Block eyeBlock = this.player.getEyeLocation().getBlock();
if (eyeBlock.isLiquid() || GeneralMethods.isSolid(eyeBlock)) { if (ElementalAbility.isWater(eyeBlock) || GeneralMethods.isSolid(eyeBlock)) {
this.remove(); this.remove();
return; return;
} }
@ -163,12 +177,7 @@ public class AirSpout extends AirAbility {
@Override @Override
public void remove() { public void remove() {
super.remove(); super.remove();
ProjectKorra.flightHandler.removeInstance(this.player, this.getName()); this.flightHandler.removeInstance(this.player, this.getName());
}
private void removeFlight() {
this.player.setAllowFlight(false);
this.player.setFlying(false);
} }
private void rotateAirColumn(final Block block) { private void rotateAirColumn(final Block block) {

View file

@ -3,24 +3,23 @@ package com.projectkorra.projectkorra.airbending;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Door;
import org.bukkit.block.data.type.TrapDoor;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.material.Door;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.command.Commands;
@ -29,13 +28,9 @@ import com.projectkorra.projectkorra.waterbending.WaterSpout;
public class AirSuction extends AirAbility { public class AirSuction extends AirAbility {
private static final int MAX_TICKS = 10000;
private static final Map<Player, Location> ORIGINS = new ConcurrentHashMap<>();
private static Material doorTypes[] = { Material.WOODEN_DOOR, Material.SPRUCE_DOOR, Material.BIRCH_DOOR, Material.JUNGLE_DOOR, Material.ACACIA_DOOR, Material.DARK_OAK_DOOR, Material.TRAP_DOOR };
private final List<Block> affectedDoors = new ArrayList<>(); private final List<Block> affectedDoors = new ArrayList<>();
private boolean hasOtherOrigin; private boolean progressing;
private int ticks;
private int particleCount; private int particleCount;
@Attribute(Attribute.COOLDOWN) @Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@ -45,12 +40,15 @@ public class AirSuction extends AirAbility {
private double range; private double range;
@Attribute(Attribute.RADIUS) @Attribute(Attribute.RADIUS)
private double radius; private double radius;
@Attribute(Attribute.POWER) @Attribute(Attribute.KNOCKBACK)
private double pushFactor; private double pushFactor;
@Attribute(Attribute.KNOCKBACK + "Others")
private double pushFactorForOthers;
private Random random; private Random random;
private Location location; private Location location;
private Location origin; private Location origin;
private Vector direction; private Vector direction;
private boolean canAffectSelf;
public AirSuction(final Player player) { public AirSuction(final Player player) {
super(player); super(player);
@ -63,88 +61,43 @@ public class AirSuction extends AirAbility {
return; return;
} }
this.hasOtherOrigin = false; if (hasAbility(player, AirSuction.class)) {
this.ticks = 0; final AirSuction suc = getAbility(player, AirSuction.class);
if (!suc.isProgressing()) {
final Location loc = this.getTargetLocation();
if (!GeneralMethods.isRegionProtectedFromBuild(player, this.getName(), loc)) {
suc.setOrigin(loc);
}
}
return;
}
this.progressing = false;
this.particleCount = getConfig().getInt("Abilities.Air.AirSuction.Particles"); this.particleCount = getConfig().getInt("Abilities.Air.AirSuction.Particles");
this.speed = getConfig().getDouble("Abilities.Air.AirSuction.Speed"); this.speed = getConfig().getDouble("Abilities.Air.AirSuction.Speed");
this.range = getConfig().getDouble("Abilities.Air.AirSuction.Range"); this.range = getConfig().getDouble("Abilities.Air.AirSuction.Range");
this.radius = getConfig().getDouble("Abilities.Air.AirSuction.Radius"); this.radius = getConfig().getDouble("Abilities.Air.AirSuction.Radius");
this.pushFactor = getConfig().getDouble("Abilities.Air.AirSuction.Push"); this.pushFactor = getConfig().getDouble("Abilities.Air.AirSuction.Push.Self");
this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirSuction.Push.Others");
this.cooldown = getConfig().getLong("Abilities.Air.AirSuction.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Air.AirSuction.Cooldown");
this.random = new Random(); this.random = new Random();
this.origin = this.getTargetLocation();
this.canAffectSelf = true;
if (ORIGINS.containsKey(player)) { if (GeneralMethods.isRegionProtectedFromBuild(player, this.getName(), this.origin)) {
this.origin = ORIGINS.get(player); return;
this.hasOtherOrigin = true;
ORIGINS.remove(player);
} else {
this.origin = player.getEyeLocation();
} }
this.location = GeneralMethods.getTargetedLocation(player, this.range, getTransparentMaterials()); this.location = null;
this.direction = GeneralMethods.getDirection(this.location, this.origin).normalize();
final Entity entity = GeneralMethods.getTargetedEntity(player, this.range);
if (entity != null) {
this.direction = GeneralMethods.getDirection(entity.getLocation(), this.origin).normalize();
this.location = this.getLocation(this.origin, this.direction.clone().multiply(-1));
}
this.bPlayer.addCooldown(this);
if (this.bPlayer.isAvatarState()) { if (this.bPlayer.isAvatarState()) {
this.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSuction.Push"); this.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSuction.Push");
} }
this.start(); this.start();
} }
private static void playOriginEffect(final Player player) {
if (!ORIGINS.containsKey(player)) {
return;
}
final Location origin = ORIGINS.get(player);
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null || player.isDead() || !player.isOnline()) {
return;
} else if (!origin.getWorld().equals(player.getWorld())) {
ORIGINS.remove(player);
return;
} else if (!bPlayer.canBendIgnoreCooldowns(getAbility("AirSuction"))) {
ORIGINS.remove(player);
return;
} else if (origin.distanceSquared(player.getEyeLocation()) > getSelectRange() * getSelectRange()) {
ORIGINS.remove(player);
return;
}
playAirbendingParticles(origin, getSelectParticles());
}
public static void progressOrigins() {
for (final Player player : ORIGINS.keySet()) {
playOriginEffect(player);
}
}
public static void setOrigin(final Player player) {
final Material[] ignore = new Material[getTransparentMaterials().length + doorTypes.length];
for (int i = 0; i < ignore.length; i++) {
if (i < getTransparentMaterials().length) {
ignore[i] = getTransparentMaterials()[i];
} else {
ignore[i] = doorTypes[i - getTransparentMaterials().length];
}
}
final Location location = GeneralMethods.getTargetedLocation(player, getSelectRange(), ignore);
if (location.getBlock().isLiquid() || GeneralMethods.isSolid(location.getBlock())) {
return;
} else if (GeneralMethods.isRegionProtectedFromBuild(player, "AirSuction", location)) {
return;
} else {
ORIGINS.put(player, location);
}
}
private void advanceLocation() { private void advanceLocation() {
playAirbendingParticles(this.location, this.particleCount, 0.275F, 0.275F, 0.275F); playAirbendingParticles(this.location, this.particleCount, 0.275F, 0.275F, 0.275F);
if (this.random.nextInt(4) == 0) { if (this.random.nextInt(4) == 0) {
@ -153,17 +106,17 @@ public class AirSuction extends AirAbility {
final double speedFactor = this.speed * (ProjectKorra.time_step / 1000.); final double speedFactor = this.speed * (ProjectKorra.time_step / 1000.);
this.location = this.location.add(this.direction.clone().multiply(speedFactor)); this.location = this.location.add(this.direction.clone().multiply(speedFactor));
if (Arrays.asList(doorTypes).contains(this.location.getBlock().getType()) && !this.affectedDoors.contains(this.location.getBlock())) { if ((Arrays.asList(AirBlast.DOORS).contains(this.location.getBlock().getType()) || Arrays.asList(AirBlast.TDOORS).contains(this.location.getBlock().getType())) && !this.affectedDoors.contains(this.location.getBlock())) {
this.handleDoorMechanics(this.location.getBlock()); this.handleDoorMechanics(this.location.getBlock());
} }
} }
private void handleDoorMechanics(final Block block) { private void handleDoorMechanics(final Block block) {
boolean tDoor = false; boolean tDoor = false;
final boolean open = (block.getData() & 0x4) == 0x4; boolean open = false;
if (block.getType() != Material.TRAP_DOOR) { if (Arrays.asList(AirBlast.DOORS).contains(block.getType())) {
final Door door = (Door) block.getState().getData(); final Door door = (Door) block.getBlockData();
final BlockFace face = door.getFacing(); final BlockFace face = door.getFacing();
final Vector toPlayer = GeneralMethods.getDirection(block.getLocation(), this.player.getLocation().getBlock().getLocation()); final Vector toPlayer = GeneralMethods.getDirection(block.getLocation(), this.player.getLocation().getBlock().getLocation());
final double[] dims = { toPlayer.getX(), toPlayer.getY(), toPlayer.getZ() }; final double[] dims = { toPlayer.getX(), toPlayer.getY(), toPlayer.getZ() };
@ -175,44 +128,57 @@ public class AirSuction extends AirAbility {
final BlockFace bf = GeneralMethods.getBlockFaceFromValue(i, dims[i]); final BlockFace bf = GeneralMethods.getBlockFaceFromValue(i, dims[i]);
if (bf == face) { if (bf == face) {
if (!open) { if (!door.isOpen()) {
return; return;
} }
} else if (bf.getOppositeFace() == face) { } else if (bf.getOppositeFace() == face) {
if (open) { if (door.isOpen()) {
return; return;
} }
} }
} }
door.setOpen(!door.isOpen());
block.setBlockData(door);
open = door.isOpen();
} else { } else {
tDoor = true; tDoor = true;
final TrapDoor trap = (TrapDoor) block.getBlockData();
if (this.origin.getY() < block.getY()) { if (this.origin.getY() < block.getY()) {
if (open) { if (trap.isOpen()) {
return; return;
} }
} else { } else {
if (!open) { if (!trap.isOpen()) {
return; return;
} }
} }
trap.setOpen(!trap.isOpen());
block.setBlockData(trap);
open = trap.isOpen();
} }
block.setData((byte) ((block.getData() & 0x4) == 0x4 ? (block.getData() & ~0x4) : (block.getData() | 0x4))); final String sound = "block_wooden_" + (tDoor ? "trap" : "") + "door_" + (!open ? "open" : "close");
final String sound = "BLOCK_WOODEN_" + (tDoor ? "TRAP" : "") + "DOOR_" + (!open ? "OPEN" : "CLOSE");
block.getWorld().playSound(block.getLocation(), sound, 0.5f, 0); block.getWorld().playSound(block.getLocation(), sound, 0.5f, 0);
this.affectedDoors.add(block); this.affectedDoors.add(block);
} }
private Location getLocation(final Location origin, final Vector direction) { private Location getTargetLocation() {
Location location = origin.clone(); final Material[] ignore = new Material[getTransparentMaterials().length + AirBlast.DOORS.length + AirBlast.TDOORS.length];
for (double i = 1; i <= this.range; i++) {
location = origin.clone().add(direction.clone().multiply(i)); for (int i = 0; i < ignore.length; i++) {
if ((!this.isTransparent(location.getBlock()) && !Arrays.asList(doorTypes).contains(location.getBlock().getType())) || GeneralMethods.isRegionProtectedFromBuild(this, location)) { if (i < getTransparentMaterials().length) {
return origin.clone().add(direction.clone().multiply(i - 1)); ignore[i] = getTransparentMaterials()[i];
} else if (i < getTransparentMaterials().length + AirBlast.DOORS.length) {
ignore[i] = AirBlast.DOORS[i - getTransparentMaterials().length];
} else {
ignore[i] = AirBlast.TDOORS[i - getTransparentMaterials().length - AirBlast.DOORS.length];
} }
} }
return location;
return GeneralMethods.getTargetedLocation(this.player, getSelectRange(), ignore);
} }
@Override @Override
@ -220,60 +186,55 @@ public class AirSuction extends AirAbility {
if (this.player.isDead() || !this.player.isOnline()) { if (this.player.isDead() || !this.player.isOnline()) {
this.remove(); this.remove();
return; return;
} else if (GeneralMethods.isRegionProtectedFromBuild(this.player, "AirSuction", this.location)) {
this.remove();
return;
} }
this.ticks++; if (this.progressing) {
if (this.ticks > MAX_TICKS) { if (GeneralMethods.isRegionProtectedFromBuild(this.player, "AirSuction", this.location)) {
this.remove(); this.remove();
return; return;
} else if ((this.location.distanceSquared(this.origin) > this.range * this.range) || (this.location.distanceSquared(this.origin) <= 1)) { } else if (!this.location.getWorld().equals(this.origin.getWorld()) || this.location.distanceSquared(this.origin) > this.range * this.range || this.location.distanceSquared(this.origin) <= 1) {
this.remove(); this.remove();
return; return;
} }
for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, this.radius)) { for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, this.radius)) {
if (entity.getEntityId() != this.player.getEntityId() || this.hasOtherOrigin) { if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) {
final Vector velocity = entity.getVelocity(); continue;
}
if ((entity.getEntityId() == this.player.getEntityId()) && !this.canAffectSelf) {
continue;
}
double knockback = this.pushFactor;
if (entity.getEntityId() != player.getEntityId()) {
knockback = this.pushFactorForOthers;
}
final double max = this.speed; final double max = this.speed;
double factor = this.pushFactor;
final Vector push = this.direction.clone(); final Vector push = this.direction.clone();
if (Math.abs(push.getY()) > max && entity.getEntityId() != this.player.getEntityId()) {
if (Math.abs(push.getY()) > max) {
if (push.getY() < 0) { if (push.getY() < 0) {
push.setY(-max); push.setY(-max);
} else { } else {
push.setY(max); push.setY(max);
} }
} }
if (this.location.getWorld().equals(this.origin.getWorld())) { if (this.location.getWorld().equals(this.origin.getWorld())) {
factor *= 1 - this.location.distance(this.origin) / (2 * this.range); knockback *= 1 - this.location.distance(this.origin) / (2 * this.range);
}
push.normalize().multiply(knockback);
if (Math.abs(entity.getVelocity().dot(push)) > knockback) {
push.normalize().add(entity.getVelocity()).multiply(knockback);
} }
final double comp = velocity.dot(push.clone().normalize()); GeneralMethods.setVelocity(entity, push.normalize().multiply(knockback));
if (comp > factor) {
velocity.multiply(.5);
velocity.add(push.clone().normalize().multiply(velocity.clone().dot(push.clone().normalize())));
} else if (comp + factor * .5 > factor) {
velocity.add(push.clone().multiply(factor - comp));
} else {
velocity.add(push.clone().multiply(factor * .5));
}
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) {
continue;
}
}
GeneralMethods.setVelocity(entity, velocity);
new HorizontalVelocityTracker(entity, this.player, 200l, this); new HorizontalVelocityTracker(entity, this.player, 200l, this);
entity.setFallDistance(0); entity.setFallDistance(0);
if (entity.getEntityId() != this.player.getEntityId() && entity instanceof Player) {
ProjectKorra.flightHandler.createInstance((Player) entity, this.player, 5000L, this.getName());
}
if (entity.getFireTicks() > 0) { if (entity.getFireTicks() > 0) {
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0); entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
@ -281,9 +242,46 @@ public class AirSuction extends AirAbility {
entity.setFireTicks(0); entity.setFireTicks(0);
breakBreathbendingHold(entity); breakBreathbendingHold(entity);
} }
this.advanceLocation();
} else {
playAirbendingParticles(this.origin, 5, 0.5, 0.5, 0.5);
}
}
public void shoot() {
Location target;
final Entity entity = GeneralMethods.getTargetedEntity(this.player, this.range);
if (entity != null) {
target = entity.getLocation();
} else {
target = this.getTargetLocation();
} }
this.advanceLocation(); this.location = target.clone();
this.direction = GeneralMethods.getDirection(this.location, this.origin).normalize();
this.progressing = true;
this.bPlayer.addCooldown(this);
}
public static void shoot(final Player player) {
AirSuction suc = null;
if (CoreAbility.hasAbility(player, AirSuction.class)) {
suc = CoreAbility.getAbility(player, AirSuction.class);
if (suc.isProgressing()) {
return;
}
} else {
suc = new AirSuction(player);
suc.setOrigin(player.getEyeLocation().clone());
suc.setCanEffectSelf(false);
}
if (suc.getOrigin() != null) {
suc.shoot();
}
} }
/** /**
@ -335,6 +333,10 @@ public class AirSuction extends AirAbility {
return this.getRadius(); return this.getRadius();
} }
public boolean isProgressing() {
return this.progressing;
}
public Location getOrigin() { public Location getOrigin() {
return this.origin; return this.origin;
} }
@ -351,22 +353,6 @@ public class AirSuction extends AirAbility {
this.direction = direction; this.direction = direction;
} }
public boolean isHasOtherOrigin() {
return this.hasOtherOrigin;
}
public void setHasOtherOrigin(final boolean hasOtherOrigin) {
this.hasOtherOrigin = hasOtherOrigin;
}
public int getTicks() {
return this.ticks;
}
public void setTicks(final int ticks) {
this.ticks = ticks;
}
public int getParticleCount() { public int getParticleCount() {
return this.particleCount; return this.particleCount;
} }
@ -415,8 +401,8 @@ public class AirSuction extends AirAbility {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
public static Map<Player, Location> getOrigins() { public void setCanEffectSelf(final boolean affect) {
return ORIGINS; this.canAffectSelf = affect;
} }
public static int getSelectParticles() { public static int getSelectParticles() {

View file

@ -9,6 +9,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.data.Levelled;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -33,16 +34,18 @@ public class AirSwipe extends AirAbility {
private static final int MAX_AFFECTABLE_ENTITIES = 10; private static final int MAX_AFFECTABLE_ENTITIES = 10;
private boolean charging; private boolean charging;
@Attribute("Arc")
private int arc; private int arc;
private int particles; private int particles;
private int stepSize; @Attribute("ArcIncrement")
private int arcIncrement;
@Attribute(Attribute.CHARGE_DURATION) @Attribute(Attribute.CHARGE_DURATION)
private long maxChargeTime; private long maxChargeTime;
@Attribute(Attribute.COOLDOWN) @Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@Attribute(Attribute.DAMAGE) @Attribute(Attribute.DAMAGE)
private double damage; private double damage;
@Attribute(Attribute.POWER) @Attribute(Attribute.KNOCKBACK)
private double pushFactor; private double pushFactor;
@Attribute(Attribute.SPEED) @Attribute(Attribute.SPEED)
private double speed; private double speed;
@ -74,10 +77,10 @@ public class AirSwipe extends AirAbility {
} }
this.charging = charging; this.charging = charging;
this.origin = player.getEyeLocation(); this.origin = GeneralMethods.getMainHandLocation(player);
this.particles = getConfig().getInt("Abilities.Air.AirSwipe.Particles"); this.particles = getConfig().getInt("Abilities.Air.AirSwipe.Particles");
this.arc = getConfig().getInt("Abilities.Air.AirSwipe.Arc"); this.arc = getConfig().getInt("Abilities.Air.AirSwipe.Arc");
this.stepSize = getConfig().getInt("Abilities.Air.AirSwipe.StepSize"); this.arcIncrement = getConfig().getInt("Abilities.Air.AirSwipe.StepSize");
this.maxChargeTime = getConfig().getLong("Abilities.Air.AirSwipe.MaxChargeTime"); this.maxChargeTime = getConfig().getLong("Abilities.Air.AirSwipe.MaxChargeTime");
this.cooldown = getConfig().getLong("Abilities.Air.AirSwipe.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Air.AirSwipe.Cooldown");
this.damage = getConfig().getDouble("Abilities.Air.AirSwipe.Damage"); this.damage = getConfig().getDouble("Abilities.Air.AirSwipe.Damage");
@ -159,19 +162,21 @@ public class AirSwipe extends AirAbility {
} }
} }
if (block.getType() != Material.AIR) { if (!isAir(block.getType())) {
if (block.getType().equals(Material.SNOW)) { if (block.getType().equals(Material.SNOW)) {
continue; continue;
} else if (isPlant(block.getType())) {
block.breakNaturally();
} else { } else {
this.elements.remove(direction); this.elements.remove(direction);
} }
if (isLava(block)) { if (isLava(block)) {
if (LavaFlow.isLavaFlowBlock(block)) { if (LavaFlow.isLavaFlowBlock(block)) {
LavaFlow.removeBlock(block); // TODO: Make more generic for future lava generating moves. LavaFlow.removeBlock(block); // TODO: Make more generic for future lava generating moves.
} else if (block.getData() == 0x0) { } else if (block.getBlockData() instanceof Levelled && ((Levelled) block.getBlockData()).getLevel() == 0) {
new TempBlock(block, Material.OBSIDIAN, (byte) 0); new TempBlock(block, Material.OBSIDIAN);
} else { } else {
new TempBlock(block, Material.COBBLESTONE, (byte) 0); new TempBlock(block, Material.COBBLESTONE);
} }
} }
} else { } else {
@ -191,7 +196,7 @@ public class AirSwipe extends AirAbility {
private void affectPeople(final Location location, final Vector direction) { private void affectPeople(final Location location, final Vector direction) {
final List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(location, this.radius); final List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(location, this.radius);
final Vector fDirection = direction; final Vector fDirection = direction.clone();
for (int i = 0; i < entities.size(); i++) { for (int i = 0; i < entities.size(); i++) {
final Entity entity = entities.get(i); final Entity entity = entities.get(i);
@ -213,19 +218,14 @@ public class AirSwipe extends AirAbility {
GeneralMethods.setVelocity(entity, fDirection.multiply(AirSwipe.this.pushFactor)); GeneralMethods.setVelocity(entity, fDirection.multiply(AirSwipe.this.pushFactor));
} }
if (entity instanceof LivingEntity && !AirSwipe.this.affectedEntities.contains(entity)) { if (!AirSwipe.this.affectedEntities.contains(entity)) {
if (AirSwipe.this.damage != 0) { if (AirSwipe.this.damage != 0) {
DamageHandler.damageEntity(entity, AirSwipe.this.damage, abil); DamageHandler.damageEntity(entity, AirSwipe.this.damage, abil);
} }
AirSwipe.this.affectedEntities.add(entity); AirSwipe.this.affectedEntities.add(entity);
} }
if (entity instanceof Player) {
ProjectKorra.flightHandler.createInstance((Player) entity, AirSwipe.this.player, 1000L, AirSwipe.this.getName());
}
breakBreathbendingHold(entity); breakBreathbendingHold(entity);
if (AirSwipe.this.elements.containsKey(fDirection)) { AirSwipe.this.elements.remove(direction);
AirSwipe.this.elements.remove(fDirection);
}
} else if (entity.getEntityId() != AirSwipe.this.player.getEntityId() && !(entity instanceof LivingEntity)) { } else if (entity.getEntityId() != AirSwipe.this.player.getEntityId() && !(entity instanceof LivingEntity)) {
GeneralMethods.setVelocity(entity, fDirection.multiply(AirSwipe.this.pushFactor)); GeneralMethods.setVelocity(entity, fDirection.multiply(AirSwipe.this.pushFactor));
@ -239,7 +239,7 @@ public class AirSwipe extends AirAbility {
private void launch() { private void launch() {
this.bPlayer.addCooldown("AirSwipe", this.cooldown); this.bPlayer.addCooldown("AirSwipe", this.cooldown);
this.origin = this.player.getEyeLocation(); this.origin = this.player.getEyeLocation();
for (double i = -this.arc; i <= this.arc; i += this.stepSize) { for (double i = -this.arc; i <= this.arc; i += this.arcIncrement) {
final double angle = Math.toRadians(i); final double angle = Math.toRadians(i);
final Vector direction = this.player.getEyeLocation().getDirection().clone(); final Vector direction = this.player.getEyeLocation().getDirection().clone();
@ -443,12 +443,12 @@ public class AirSwipe extends AirAbility {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
public int getStepSize() { public int getArcIncrement() {
return this.stepSize; return this.arcIncrement;
} }
public void setStepSize(final int stepSize) { public void setArcIncrement(final int arcIncrement) {
this.stepSize = stepSize; this.arcIncrement = arcIncrement;
} }
} }

View file

@ -97,7 +97,6 @@ public class Suffocate extends AirAbility {
this.chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Air.Suffocate.ChargeTime"); this.chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Air.Suffocate.ChargeTime");
this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Suffocate.Damage"); this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Suffocate.Damage");
this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Suffocate.Range"); this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Suffocate.Range");
} }
if (this.particleCount < 1) { if (this.particleCount < 1) {
@ -143,7 +142,6 @@ public class Suffocate extends AirAbility {
} }
} }
this.bPlayer.addCooldown(this);
this.start(); this.start();
} }
@ -172,7 +170,7 @@ public class Suffocate extends AirAbility {
if (this.player.getWorld().equals(this.targets.get(0).getWorld())) { if (this.player.getWorld().equals(this.targets.get(0).getWorld())) {
dist = this.player.getEyeLocation().distance(this.targets.get(0).getEyeLocation()); dist = this.player.getEyeLocation().distance(this.targets.get(0).getEyeLocation());
} }
final Location targetLoc = this.player.getEyeLocation().clone().add(this.player.getEyeLocation().getDirection().normalize().multiply(dist)); final Location targetLoc = GeneralMethods.getTargetedLocation(player, dist, false, getTransparentMaterials());
final List<Entity> ents = GeneralMethods.getEntitiesAroundPoint(targetLoc, this.constantAimRadius); final List<Entity> ents = GeneralMethods.getEntitiesAroundPoint(targetLoc, this.constantAimRadius);
for (int i = 0; i < this.targets.size(); i++) { for (int i = 0; i < this.targets.size(); i++) {
@ -337,6 +335,7 @@ public class Suffocate extends AirAbility {
@Override @Override
public void remove() { public void remove() {
super.remove(); super.remove();
this.bPlayer.addCooldown(this);
for (int i = 0; i < this.tasks.size(); i++) { for (int i = 0; i < this.tasks.size(); i++) {
this.tasks.get(i).cancel(); this.tasks.get(i).cancel();
this.tasks.remove(i); this.tasks.remove(i);

View file

@ -12,14 +12,16 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.command.Commands;
public class Tornado extends AirAbility { public class Tornado extends AirAbility {
@Attribute(Attribute.COOLDOWN)
private final long cooldown; private final long cooldown;
@Attribute(Attribute.DURATION)
private final long duration; private final long duration;
private int numberOfStreams; private int numberOfStreams;
private int particleCount; private int particleCount;
@ -27,7 +29,7 @@ public class Tornado extends AirAbility {
private double speed; private double speed;
@Attribute(Attribute.HEIGHT) @Attribute(Attribute.HEIGHT)
private double maxHeight; private double maxHeight;
@Attribute(Attribute.POWER) @Attribute(Attribute.KNOCKBACK)
private double playerPushFactor; private double playerPushFactor;
@Attribute(Attribute.RADIUS) @Attribute(Attribute.RADIUS)
private double radius; private double radius;
@ -68,7 +70,7 @@ public class Tornado extends AirAbility {
} }
} }
ProjectKorra.flightHandler.createInstance(player, this.getName()); this.flightHandler.createInstance(player, this.getName());
player.setAllowFlight(true); player.setAllowFlight(true);
this.start(); this.start();
} }
@ -95,7 +97,7 @@ public class Tornado extends AirAbility {
@Override @Override
public void remove() { public void remove() {
super.remove(); super.remove();
ProjectKorra.flightHandler.removeInstance(this.player, this.getName()); this.flightHandler.removeInstance(this.player, this.getName());
} }
private void rotateTornado() { private void rotateTornado() {
@ -103,7 +105,7 @@ public class Tornado extends AirAbility {
final double timefactor = this.currentHeight / this.maxHeight; final double timefactor = this.currentHeight / this.maxHeight;
this.currentRadius = timefactor * this.radius; this.currentRadius = timefactor * this.radius;
if (this.origin.getBlock().getType() != Material.AIR && this.origin.getBlock().getType() != Material.BARRIER) { if (!ElementalAbility.isAir(this.origin.getBlock().getType()) && this.origin.getBlock().getType() != Material.BARRIER) {
this.origin.setY(this.origin.getY() - 1. / 10. * this.currentHeight); this.origin.setY(this.origin.getY() - 1. / 10. * this.currentHeight);
for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.origin, this.currentHeight)) { for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.origin, this.currentHeight)) {
@ -126,8 +128,13 @@ public class Tornado extends AirAbility {
mag = Math.sqrt(x * x + z * z); mag = Math.sqrt(x * x + z * z);
vx = (x * Math.cos(angle) - z * Math.sin(angle)) / mag; if (mag == 0.0) {
vz = (x * Math.sin(angle) + z * Math.cos(angle)) / mag; vx = 0.0;
vz = 0.0;
} else {
vx = (x * Math.cos(angle) - z * Math.sin(angle)) / mag;
vz = (x * Math.sin(angle) + z * Math.cos(angle)) / mag;
}
if (entity instanceof Player) { if (entity instanceof Player) {
vy = 0.05 * this.playerPushFactor; vy = 0.05 * this.playerPushFactor;
@ -157,7 +164,7 @@ public class Tornado extends AirAbility {
} }
} }
final Vector velocity = entity.getVelocity(); final Vector velocity = entity.getVelocity().clone();
velocity.setX(vx); velocity.setX(vx);
velocity.setZ(vz); velocity.setZ(vz);
velocity.setY(vy); velocity.setY(vy);
@ -166,10 +173,6 @@ public class Tornado extends AirAbility {
entity.setFallDistance(0); entity.setFallDistance(0);
breakBreathbendingHold(entity); breakBreathbendingHold(entity);
if (entity instanceof Player) {
ProjectKorra.flightHandler.createInstance((Player) entity, 50L, this.getName());
}
} }
} }
} }

View file

@ -1,8 +1,6 @@
package com.projectkorra.projectkorra.airbending.combo; package com.projectkorra.projectkorra.airbending.combo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -20,13 +18,17 @@ import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.ClickType;
public class AirStream extends AirAbility implements ComboAbility { public class AirStream extends AirAbility implements ComboAbility {
@Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
private long time; private long time;
@Attribute(Attribute.SPEED) @Attribute(Attribute.SPEED)
private double speed; private double speed;
@Attribute(Attribute.RANGE) @Attribute(Attribute.RANGE)
private double range; private double range;
@Attribute("EntityCarry" + Attribute.HEIGHT)
private double airStreamMaxEntityHeight; private double airStreamMaxEntityHeight;
@Attribute("EntityCarry" + Attribute.DURATION)
private double airStreamEntityCarryDuration; private double airStreamEntityCarryDuration;
private Location origin; private Location origin;
private Location currentLoc; private Location currentLoc;
@ -34,14 +36,12 @@ public class AirStream extends AirAbility implements ComboAbility {
private Vector direction; private Vector direction;
private ArrayList<Entity> affectedEntities; private ArrayList<Entity> affectedEntities;
private ArrayList<BukkitRunnable> tasks; private ArrayList<BukkitRunnable> tasks;
private Set<Player> flights;
public AirStream(final Player player) { public AirStream(final Player player) {
super(player); super(player);
this.affectedEntities = new ArrayList<>(); this.affectedEntities = new ArrayList<>();
this.tasks = new ArrayList<>(); this.tasks = new ArrayList<>();
this.flights = new HashSet<>();
if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) { if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) {
return; return;
@ -54,14 +54,14 @@ public class AirStream extends AirAbility implements ComboAbility {
this.range = getConfig().getDouble("Abilities.Air.AirStream.Range"); this.range = getConfig().getDouble("Abilities.Air.AirStream.Range");
this.speed = getConfig().getDouble("Abilities.Air.AirStream.Speed"); this.speed = getConfig().getDouble("Abilities.Air.AirStream.Speed");
this.cooldown = getConfig().getLong("Abilities.Air.AirStream.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Air.AirStream.Cooldown");
this.airStreamMaxEntityHeight = getConfig().getDouble("Abilities.Air.AirStream.EntityHeight"); this.airStreamMaxEntityHeight = getConfig().getDouble("Abilities.Air.AirStream.EntityCarry.Height");
this.airStreamEntityCarryDuration = getConfig().getLong("Abilities.Air.AirStream.EntityDuration"); this.airStreamEntityCarryDuration = getConfig().getLong("Abilities.Air.AirStream.EntityCarry.Duration");
if (this.bPlayer.isAvatarState()) { if (this.bPlayer.isAvatarState()) {
this.cooldown = 0; this.cooldown = 0;
this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirStream.Range"); this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirStream.Range");
this.airStreamMaxEntityHeight = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirStream.EntityHeight"); this.airStreamMaxEntityHeight = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirStream.EntityCarry.Height");
this.airStreamEntityCarryDuration = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirStream.EntityDuration"); this.airStreamEntityCarryDuration = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirStream.EntityCarry.Duration");
} }
this.bPlayer.addCooldown(this); this.bPlayer.addCooldown(this);
@ -93,11 +93,6 @@ public class AirStream extends AirAbility implements ComboAbility {
this.currentLoc = this.origin.clone(); this.currentLoc = this.origin.clone();
} }
final Entity target = GeneralMethods.getTargetedEntity(this.player, this.range); final Entity target = GeneralMethods.getTargetedEntity(this.player, this.range);
if (target instanceof Player) {
if (Commands.invincible.contains(((Player) target).getName())) {
return;
}
}
if (target != null && target.getLocation().distanceSquared(this.currentLoc) > 49) { if (target != null && target.getLocation().distanceSquared(this.currentLoc) > 49) {
this.destination = target.getLocation(); this.destination = target.getLocation();
@ -105,6 +100,11 @@ public class AirStream extends AirAbility implements ComboAbility {
this.destination = GeneralMethods.getTargetedLocation(this.player, this.range, getTransparentMaterials()); this.destination = GeneralMethods.getTargetedLocation(this.player, this.range, getTransparentMaterials());
} }
if (GeneralMethods.locationEqualsIgnoreDirection(this.currentLoc, this.destination)) {
this.remove();
return;
}
this.direction = GeneralMethods.getDirection(this.currentLoc, this.destination).normalize(); this.direction = GeneralMethods.getDirection(this.currentLoc, this.destination).normalize();
this.currentLoc.add(this.direction.clone().multiply(this.speed)); this.currentLoc.add(this.direction.clone().multiply(this.speed));
@ -157,15 +157,13 @@ public class AirStream extends AirAbility implements ComboAbility {
} }
if (!entity.equals(this.player) && !this.affectedEntities.contains(entity)) { if (!entity.equals(this.player) && !this.affectedEntities.contains(entity)) {
this.affectedEntities.add(entity); this.affectedEntities.add(entity);
if (entity instanceof Player) {
final Player ep = (Player) entity;
ProjectKorra.flightHandler.createInstance(ep, this.player, this.getName());
this.flights.add(ep);
}
} }
} }
for (final Entity entity : this.affectedEntities) { for (final Entity entity : this.affectedEntities) {
if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) {
continue;
}
final Vector force = GeneralMethods.getDirection(entity.getLocation(), this.currentLoc); final Vector force = GeneralMethods.getDirection(entity.getLocation(), this.currentLoc);
entity.setVelocity(force.clone().normalize().multiply(this.speed)); entity.setVelocity(force.clone().normalize().multiply(this.speed));
entity.setFallDistance(0F); entity.setFallDistance(0F);
@ -178,10 +176,6 @@ public class AirStream extends AirAbility implements ComboAbility {
for (final BukkitRunnable task : this.tasks) { for (final BukkitRunnable task : this.tasks) {
task.cancel(); task.cancel();
} }
for (final Player flyer : this.flights) {
ProjectKorra.flightHandler.removeInstance(flyer, this.getName());
}
this.flights.clear();
} }
@Override @Override
@ -191,7 +185,7 @@ public class AirStream extends AirAbility implements ComboAbility {
@Override @Override
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return true; return false;
} }
@Override @Override
@ -302,16 +296,7 @@ public class AirStream extends AirAbility implements ComboAbility {
this.tasks = tasks; this.tasks = tasks;
} }
public Set<Player> getFlights() {
return this.flights;
}
public void setCooldown(final long cooldown) { public void setCooldown(final long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
@Override
public String getInstructions() {
return "AirShield (Hold Shift) > AirSuction (Left Click) > AirBlast (Left Click)";
}
} }

View file

@ -3,6 +3,7 @@ package com.projectkorra.projectkorra.airbending.combo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -17,6 +18,7 @@ import com.projectkorra.projectkorra.ability.ComboAbility;
import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation;
import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.firebending.combo.FireComboStream; import com.projectkorra.projectkorra.firebending.combo.FireComboStream;
import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.DamageHandler;
@ -24,6 +26,7 @@ import com.projectkorra.projectkorra.util.DamageHandler;
public class AirSweep extends AirAbility implements ComboAbility { public class AirSweep extends AirAbility implements ComboAbility {
private int progressCounter; private int progressCounter;
@Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@Attribute(Attribute.DAMAGE) @Attribute(Attribute.DAMAGE)
private double damage; private double damage;
@ -31,7 +34,7 @@ public class AirSweep extends AirAbility implements ComboAbility {
private double speed; private double speed;
@Attribute(Attribute.RANGE) @Attribute(Attribute.RANGE)
private double range; private double range;
@Attribute(Attribute.POWER) @Attribute(Attribute.KNOCKBACK)
private double knockback; private double knockback;
private Location origin; private Location origin;
private Location currentLoc; private Location currentLoc;
@ -129,18 +132,23 @@ public class AirSweep extends AirAbility implements ComboAbility {
if (this.origin == null) { if (this.origin == null) {
this.direction = this.player.getEyeLocation().getDirection().normalize(); this.direction = this.player.getEyeLocation().getDirection().normalize();
this.origin = this.player.getLocation().add(this.direction.clone().multiply(10)); this.origin = GeneralMethods.getMainHandLocation(player).add(this.direction.clone().multiply(10));
} }
if (this.progressCounter < 8) { if (this.progressCounter < 8) {
return; return;
} }
if (this.destination == null) { if (this.destination == null) {
this.destination = this.player.getLocation().add(this.player.getEyeLocation().getDirection().normalize().multiply(10)); this.destination = GeneralMethods.getMainHandLocation(player).add(GeneralMethods.getMainHandLocation(player).getDirection().normalize().multiply(10));
final Vector origToDest = GeneralMethods.getDirection(this.origin, this.destination); final Vector origToDest = GeneralMethods.getDirection(this.origin, this.destination);
final Location hand = GeneralMethods.getMainHandLocation(player);
for (double i = 0; i < 30; i++) { for (double i = 0; i < 30; i++) {
final Vector vec = GeneralMethods.getDirection(this.player.getLocation(), this.origin.clone().add(origToDest.clone().multiply(i / 30))); final Location endLoc = this.origin.clone().add(origToDest.clone().multiply(i / 30));
if (GeneralMethods.locationEqualsIgnoreDirection(hand, endLoc)) {
continue;
}
final Vector vec = GeneralMethods.getDirection(hand, endLoc);
final FireComboStream fs = new FireComboStream(this.player, this, vec, this.player.getLocation(), this.range, this.speed); final FireComboStream fs = new FireComboStream(this.player, this, vec, hand, this.range, this.speed);
fs.setDensity(1); fs.setDensity(1);
fs.setSpread(0F); fs.setSpread(0F);
fs.setUseNewParticles(true); fs.setUseNewParticles(true);
@ -185,17 +193,17 @@ public class AirSweep extends AirAbility implements ComboAbility {
this.remove(); this.remove();
return; return;
} }
if (!entity.equals(this.player) && !this.affectedEntities.contains(entity)) { if (!entity.equals(this.player) && !(entity instanceof Player && Commands.invincible.contains(((Player) entity).getName()))) {
this.affectedEntities.add(entity);
if (this.knockback != 0) { if (this.knockback != 0) {
final Vector force = fstream.getDirection(); final Vector force = fstream.getLocation().getDirection();
entity.setVelocity(force.multiply(this.knockback)); GeneralMethods.setVelocity(entity, force.clone().multiply(this.knockback));
new HorizontalVelocityTracker(entity, this.player, 200l, this);
entity.setFallDistance(0);
} }
if (this.damage != 0) { if(!this.affectedEntities.contains(entity)) {
if (entity instanceof LivingEntity) { this.affectedEntities.add(entity);
if (fstream.getAbility().getName().equalsIgnoreCase("AirSweep")) { if (this.damage != 0) {
DamageHandler.damageEntity(entity, this.damage, this); if (entity instanceof LivingEntity) {
} else {
DamageHandler.damageEntity(entity, this.damage, this); DamageHandler.damageEntity(entity, this.damage, this);
} }
} }
@ -332,9 +340,4 @@ public class AirSweep extends AirAbility implements ComboAbility {
public void setTasks(final ArrayList<BukkitRunnable> tasks) { public void setTasks(final ArrayList<BukkitRunnable> tasks) {
this.tasks = tasks; this.tasks = tasks;
} }
@Override
public String getInstructions() {
return "AirSwipe (Left Click) > AirSwipe (Left Click) > AirBurst (Hold Shift) > AirBurst (Left Click)";
}
} }

View file

@ -22,6 +22,7 @@ public class Twister extends AirAbility implements ComboAbility {
TWISTER_MOVING, TWISTER_STATIONARY TWISTER_MOVING, TWISTER_STATIONARY
} }
@Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
private long time; private long time;
@Attribute(Attribute.DAMAGE) @Attribute(Attribute.DAMAGE)
@ -141,12 +142,10 @@ public class Twister extends AirAbility implements ComboAbility {
} }
for (final Entity entity : this.affectedEntities) { for (final Entity entity : this.affectedEntities) {
final Vector forceDir = GeneralMethods.getDirection(entity.getLocation(), this.currentLoc.clone().add(0, height, 0)); if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) {
if (entity instanceof Player) { continue;
if (Commands.invincible.contains(((Player) entity).getName())) {
break;
}
} }
final Vector forceDir = GeneralMethods.getDirection(entity.getLocation(), this.currentLoc.clone().add(0, height, 0));
entity.setVelocity(forceDir.clone().normalize().multiply(0.3)); entity.setVelocity(forceDir.clone().normalize().multiply(0.3));
} }
} }
@ -193,9 +192,4 @@ public class Twister extends AirAbility implements ComboAbility {
twister.add(new AbilityInformation("AirBlast", ClickType.LEFT_CLICK)); twister.add(new AbilityInformation("AirBlast", ClickType.LEFT_CLICK));
return twister; return twister;
} }
@Override
public String getInstructions() {
return "AirShield (Tap Shift) > Tornado (Hold Shift) > AirBlast (Left Click)";
}
} }

View file

@ -26,6 +26,7 @@ import com.projectkorra.projectkorra.ability.util.MultiAbilityManager;
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager.MultiAbilityInfoSub; import com.projectkorra.projectkorra.ability.util.MultiAbilityManager.MultiAbilityInfoSub;
import com.projectkorra.projectkorra.airbending.AirScooter; import com.projectkorra.projectkorra.airbending.AirScooter;
import com.projectkorra.projectkorra.airbending.AirSpout; import com.projectkorra.projectkorra.airbending.AirSpout;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.firebending.FireJet; import com.projectkorra.projectkorra.firebending.FireJet;
import com.projectkorra.projectkorra.util.ActionBar; import com.projectkorra.projectkorra.util.ActionBar;
import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.DamageHandler;
@ -46,10 +47,18 @@ public class FlightMultiAbility extends FlightAbility implements MultiAbility {
SOAR, GLIDE, LEVITATE, ENDING; SOAR, GLIDE, LEVITATE, ENDING;
} }
public double speed = 1, baseSpeed, slowSpeed, fastSpeed, multiplier; private double speed;
public FlightMode mode = FlightMode.SOAR; private double slowSpeed;
public long prevCheck = 0, duration; private double fastSpeed;
public Vector prevDir; private double multiplier;
@Attribute(Attribute.SPEED)
private double baseSpeed;
private FlightMode mode = FlightMode.SOAR;
@Attribute(Attribute.DURATION)
private long duration;
@Attribute(Attribute.COOLDOWN)
private long cooldown;
private Vector prevDir;
public FlightMultiAbility(final Player player) { public FlightMultiAbility(final Player player) {
super(player); super(player);
@ -104,12 +113,15 @@ public class FlightMultiAbility extends FlightAbility implements MultiAbility {
} }
MultiAbilityManager.bindMultiAbility(player, "Flight"); MultiAbilityManager.bindMultiAbility(player, "Flight");
ProjectKorra.flightHandler.createInstance(player, ID); this.flightHandler.createInstance(player, ID);
this.hadGlide = player.isGliding(); this.hadGlide = player.isGliding();
flying.add(player.getUniqueId()); flying.add(player.getUniqueId());
this.prevDir = player.getEyeLocation().getDirection().clone(); this.prevDir = player.getEyeLocation().getDirection().clone();
this.duration = getConfig().getLong("Abilities.Air.Flight.Duration"); this.duration = getConfig().getLong("Abilities.Air.Flight.Duration");
this.cooldown = getConfig().getLong("Abilities.Air.Flight.Cooldown");
this.baseSpeed = getConfig().getDouble("Abilities.Air.Flight.BaseSpeed"); this.baseSpeed = getConfig().getDouble("Abilities.Air.Flight.BaseSpeed");
this.speed = 1;
this.slowSpeed = this.baseSpeed / 2; this.slowSpeed = this.baseSpeed / 2;
this.fastSpeed = this.baseSpeed * 2; this.fastSpeed = this.baseSpeed * 2;
this.multiplier = this.baseSpeed; this.multiplier = this.baseSpeed;
@ -118,7 +130,7 @@ public class FlightMultiAbility extends FlightAbility implements MultiAbility {
@Override @Override
public long getCooldown() { public long getCooldown() {
return getConfig().getLong("Abilities.Air.Flight.Cooldown"); return this.cooldown;
} }
@Override @Override
@ -209,11 +221,7 @@ public class FlightMultiAbility extends FlightAbility implements MultiAbility {
} }
this.prevDir = this.player.getEyeLocation().getDirection().clone(); this.prevDir = this.player.getEyeLocation().getDirection().clone();
}
this.particles();
if (this.speed > this.baseSpeed) {
for (final Entity e : GeneralMethods.getEntitiesAroundPoint(this.player.getLocation(), this.speed)) { for (final Entity e : GeneralMethods.getEntitiesAroundPoint(this.player.getLocation(), this.speed)) {
if (e instanceof LivingEntity && e.getEntityId() != this.player.getEntityId() && !this.player.getPassengers().contains(e)) { if (e instanceof LivingEntity && e.getEntityId() != this.player.getEntityId() && !this.player.getPassengers().contains(e)) {
if (!GeneralMethods.isRegionProtectedFromBuild(this.player, e.getLocation())) { if (!GeneralMethods.isRegionProtectedFromBuild(this.player, e.getLocation())) {
@ -225,6 +233,7 @@ public class FlightMultiAbility extends FlightAbility implements MultiAbility {
} }
} }
this.particles();
this.player.setVelocity(this.player.getEyeLocation().getDirection().clone().multiply(this.multiplier)); this.player.setVelocity(this.player.getEyeLocation().getDirection().clone().multiply(this.multiplier));
} else if (this.mode == FlightMode.GLIDE) { } else if (this.mode == FlightMode.GLIDE) {
this.player.setAllowFlight(false); this.player.setAllowFlight(false);
@ -252,8 +261,8 @@ public class FlightMultiAbility extends FlightAbility implements MultiAbility {
} }
private void particles() { private void particles() {
ParticleEffect.CLOUD.display(GeneralMethods.getRightSide(this.player.getLocation(), 0.55).add(this.player.getVelocity().clone()), 0f, 0f, 0f, 0f, 1); ParticleEffect.CLOUD.display(GeneralMethods.getRightSide(this.player.getLocation(), 0.55).add(this.player.getVelocity().clone()), 1, 0, 0, 0);
ParticleEffect.CLOUD.display(GeneralMethods.getLeftSide(this.player.getLocation(), 0.55).add(this.player.getVelocity().clone()), 0f, 0f, 0f, 0f, 1); ParticleEffect.CLOUD.display(GeneralMethods.getLeftSide(this.player.getLocation(), 0.55).add(this.player.getVelocity().clone()), 1, 0, 0, 0);
} }
private String speed() { private String speed() {
@ -311,7 +320,7 @@ public class FlightMultiAbility extends FlightAbility implements MultiAbility {
if (this.player.isOnline() && !this.player.isDead()) { if (this.player.isOnline() && !this.player.isDead()) {
this.player.eject(); this.player.eject();
} }
ProjectKorra.flightHandler.removeInstance(this.player, ID); this.flightHandler.removeInstance(this.player, ID);
this.player.setGliding(this.hadGlide); this.player.setGliding(this.hadGlide);
} }

View file

@ -6,30 +6,26 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility; import com.projectkorra.projectkorra.ability.PassiveAbility;
import com.projectkorra.projectkorra.chiblocking.passive.ChiAgility; import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
public class AirAgility extends AirAbility implements PassiveAbility { public class AirAgility extends AirAbility implements PassiveAbility {
// Configurable variables. // Configurable variables.
@Attribute("Jump")
private int jumpPower; private int jumpPower;
@Attribute(Attribute.SPEED)
private int speedPower; private int speedPower;
// Instance related variables.
private boolean jumpActivate;
private boolean speedActivate;
public AirAgility(final Player player) { public AirAgility(final Player player) {
super(player); super(player);
this.setFields(); this.setFields();
} }
public void setFields() { public void setFields() {
this.jumpPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.AirAgility.JumpPower"); this.jumpPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.AirAgility.JumpPower") - 1;
this.speedPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.AirAgility.SpeedPower"); this.speedPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.AirAgility.SpeedPower") - 1;
} }
@Override @Override
@ -38,42 +34,13 @@ public class AirAgility extends AirAbility implements PassiveAbility {
return; return;
} }
if (CoreAbility.hasAbility(this.player, ChiAgility.class) && this.bPlayer.canBendPassive(CoreAbility.getAbility(ChiAbility.class))) {
final ChiAgility chiAgility = CoreAbility.getAbility(this.player, ChiAgility.class);
if (chiAgility.getJumpPower() > this.jumpPower) {
this.jumpPower = chiAgility.getJumpPower();
}
if (chiAgility.getSpeedPower() > this.speedPower) {
this.speedPower = chiAgility.getSpeedPower();
}
}
// Jump Buff. // Jump Buff.
this.jumpActivate = true; if (!this.player.hasPotionEffect(PotionEffectType.JUMP) || this.player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() < this.jumpPower || (this.player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() == this.jumpPower && this.player.getPotionEffect(PotionEffectType.JUMP).getDuration() == 1)) {
if (this.player.hasPotionEffect(PotionEffectType.JUMP)) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 10, this.jumpPower, true, false), true);
final PotionEffect potion = this.player.getPotionEffect(PotionEffectType.JUMP);
if (potion.getAmplifier() > this.jumpPower - 1) {
this.jumpActivate = false;
} else {
this.player.removePotionEffect(PotionEffectType.JUMP);
}
} }
if (this.jumpActivate) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20, this.jumpPower - 1, true, false), false);
}
// Speed Buff. // Speed Buff.
this.speedActivate = true; if (!this.player.hasPotionEffect(PotionEffectType.SPEED) || this.player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() < this.speedPower || (this.player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() == this.speedPower && this.player.getPotionEffect(PotionEffectType.SPEED).getDuration() == 1)) {
if (this.player.hasPotionEffect(PotionEffectType.SPEED)) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 10, this.speedPower, true, false), true);
final PotionEffect potion = this.player.getPotionEffect(PotionEffectType.SPEED);
if (potion.getAmplifier() > this.speedPower - 1) {
this.speedActivate = false;
} else {
this.player.removePotionEffect(PotionEffectType.SPEED);
}
}
if (this.speedActivate) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20, this.speedPower - 1, true, false), false);
} }
} }

View file

@ -17,8 +17,7 @@ public class AirSaturation extends AirAbility implements PassiveAbility {
} }
@Override @Override
public void progress() { public void progress() {}
}
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {

View file

@ -2,7 +2,6 @@ package com.projectkorra.projectkorra.airbending.util;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.airbending.AirBlast; import com.projectkorra.projectkorra.airbending.AirBlast;
import com.projectkorra.projectkorra.airbending.AirSuction;
public class AirbendingManager implements Runnable { public class AirbendingManager implements Runnable {
@ -15,7 +14,6 @@ public class AirbendingManager implements Runnable {
@Override @Override
public void run() { public void run() {
AirBlast.progressOrigins(); AirBlast.progressOrigins();
AirSuction.progressOrigins();
} }
} }

View file

@ -6,22 +6,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(value = { ElementType.FIELD }) @Target(ElementType.FIELD)
public @interface Attribute { public @interface Attribute {
/** public String value();
* This is the attribute name that is added to the CoreAbility name. E.g.
* Returning "Damage" on a FireBlast ability would make the attribute
* "FireBlastDamage"
*/
String value() default "";
/**
* This is for overriding the attribute name if the name you want should not
* come from the CoreAbility name. E.g. Returning "FastSwimSpeed" would make
* the Attribute name "FastSwimSpeed", instead of ability + "FastSwimSpeed"
*/
String attribute() default "";
public static final String SPEED = "Speed"; public static final String SPEED = "Speed";
public static final String RANGE = "Range"; public static final String RANGE = "Range";
@ -31,7 +19,9 @@ public @interface Attribute {
public static final String DURATION = "Duration"; public static final String DURATION = "Duration";
public static final String RADIUS = "Radius"; public static final String RADIUS = "Radius";
public static final String CHARGE_DURATION = "ChargeTime"; public static final String CHARGE_DURATION = "ChargeTime";
public static final String POWER = "Power";
public static final String WIDTH = "Width"; public static final String WIDTH = "Width";
public static final String HEIGHT = "Height"; public static final String HEIGHT = "Height";
public static final String KNOCKBACK = "Knockback";
public static final String KNOCKUP = "Knockup";
public static final String FIRE_TICK = "FireTicks";
} }

View file

@ -1,64 +1,79 @@
package com.projectkorra.projectkorra.attribute; package com.projectkorra.projectkorra.attribute;
import org.bukkit.plugin.Plugin; public enum AttributeModifier {
import com.projectkorra.projectkorra.ProjectKorra; ADDITION((oldValue, modifier) -> {
import com.projectkorra.projectkorra.ability.CoreAbility; if (oldValue instanceof Double || modifier instanceof Double) {
import com.projectkorra.projectkorra.ability.FireAbility; return oldValue.doubleValue() + modifier.doubleValue();
import com.projectkorra.projectkorra.ability.WaterAbility; } else if (oldValue instanceof Float || modifier instanceof Float) {
return oldValue.floatValue() + modifier.floatValue();
} else if (oldValue instanceof Long || modifier instanceof Long) {
return oldValue.longValue() + modifier.longValue();
} else if (oldValue instanceof Integer || modifier instanceof Integer) {
return oldValue.intValue() + modifier.intValue();
}
return 0;
}), SUBTRACTION((oldValue, modifier) -> {
if (oldValue instanceof Double || modifier instanceof Double) {
return oldValue.doubleValue() - modifier.doubleValue();
} else if (oldValue instanceof Float || modifier instanceof Float) {
return oldValue.floatValue() - modifier.floatValue();
} else if (oldValue instanceof Long || modifier instanceof Long) {
return oldValue.longValue() - modifier.longValue();
} else if (oldValue instanceof Integer || modifier instanceof Integer) {
return oldValue.intValue() - modifier.intValue();
}
return 0;
}), MULTIPLICATION((oldValue, modifier) -> {
if (oldValue instanceof Double || modifier instanceof Double) {
return oldValue.doubleValue() * modifier.doubleValue();
} else if (oldValue instanceof Float || modifier instanceof Float) {
return oldValue.floatValue() * modifier.floatValue();
} else if (oldValue instanceof Long || modifier instanceof Long) {
return oldValue.longValue() * modifier.longValue();
} else if (oldValue instanceof Integer || modifier instanceof Integer) {
return oldValue.intValue() * modifier.intValue();
}
return 0;
}), DIVISION((oldValue, modifier) -> {
if (oldValue instanceof Double || modifier instanceof Double) {
return oldValue.doubleValue() / modifier.doubleValue();
} else if (oldValue instanceof Float || modifier instanceof Float) {
return oldValue.floatValue() / modifier.floatValue();
} else if (oldValue instanceof Long || modifier instanceof Long) {
return oldValue.longValue() / modifier.longValue();
} else if (oldValue instanceof Integer || modifier instanceof Integer) {
return oldValue.intValue() / modifier.intValue();
}
return 0;
});
public class AttributeModifier { private AttributeModifierMethod modifier;
private double modifier = 1.0D; private AttributeModifier(final AttributeModifierMethod modifier) {
private final AttributeModifierType type;
public enum AttributeModifierType {
MULTIPLY, ADDITION
};
public AttributeModifier(final String name, final double modifier, final AttributeModifierType type, final Plugin plugin) {
this.modifier = modifier; this.modifier = modifier;
this.type = type;
} }
public AttributeModifier(final String name, final AttributeModifierType type, final Plugin plugin) { public AttributeModifierMethod getModifier() {
this(name, 1.0D, type, plugin);
}
protected AttributeModifier(final String name, final AttributeModifierType type, final double modifier) {
this(name, modifier, type, ProjectKorra.plugin);
}
/**
* Should return the modifier that should be applied to the Attribute. Is
* called every time it is applied, so the value doesn't have to be final.
*
* @return The modifier
*/
public double getModifier(final CoreAbility ability) {
return this.modifier; return this.modifier;
} }
/** public Number performModification(final Number oldValue, final Number modifier) {
* Returns what type of math should be done with the modifier. if (this == DIVISION && modifier.doubleValue() == 0) {
* throw new IllegalArgumentException("Attribute modifier for DIVISION cannot be zero!");
* @return The modifier type }
*/ return this.modifier.performModification(oldValue, modifier);
public AttributeModifierType getType() {
return this.type;
} }
public static AttributeModifier WATERBENDING_NIGHT = new AttributeModifier("WaterbendingNightModifier", AttributeModifierType.MULTIPLY, 1.0) { /**
@Override * Functional interface for modifying fields with the {@link Attribute}
public double getModifier(final CoreAbility ability) { * annotation
return WaterAbility.getNightFactor(ability.getPlayer().getWorld()); */
} @FunctionalInterface
}; public interface AttributeModifierMethod {
public Number performModification(Number oldValue, Number modifier);
}
public static AttributeModifier FIREBENDING_DAY = new AttributeModifier("FirebendingDayModifier", AttributeModifierType.MULTIPLY, 1.0) {
@Override
public double getModifier(final CoreAbility ability) {
return FireAbility.getDayFactor(1.0, ability.getPlayer().getWorld());
}
};
} }

View file

@ -0,0 +1,7 @@
package com.projectkorra.projectkorra.attribute;
public enum AttributePriority {
LOW, MEDIUM, HIGH;
}

View file

@ -1,104 +0,0 @@
package com.projectkorra.projectkorra.attribute;
import java.lang.reflect.Field;
import org.bukkit.Bukkit;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.attribute.AttributeModifier.AttributeModifierType;
import com.projectkorra.projectkorra.event.AttributeModifyEvent;
public class Attributes {
/**
* Modifies all abilities of the provided element for the given attribute
* and modifier
*
* @param element The type of abilities being changed. Can be a subelement.
* @param attribute What attribute to modify
* @param modifier The modifier
*/
public static void modify(final Element element, final String attribute, final AttributeModifier modifier) {
for (final CoreAbility ability : CoreAbility.getAbilitiesByElement(element)) {
modify(ability, attribute, modifier);
}
};
/**
* Modifies all the attribute of the provided ability from the given
* attribute and modifier
*
* @param ability The ability to change
* @param attribute What attribute to modify
* @param modifier The modifier
*/
public static void modify(final CoreAbility ability, final String attribute, final AttributeModifier modifier) {
if (ability.getPlayer() == null) {
for (final CoreAbility ability2 : CoreAbility.getAbilities(ability.getClass())) {
modify(ability2, attribute, modifier);
}
return;
}
for (final Field field : ability.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(Attribute.class)) {
final Attribute annotation = field.getAnnotation(Attribute.class);
String attrToTest = ability.getName() + annotation.value();
if (!annotation.attribute().equals("")) {
attrToTest = annotation.attribute();
}
if (attrToTest.equalsIgnoreCase(attribute)) {
final boolean flag = field.isAccessible();
if (!flag) {
field.setAccessible(true);
}
try {
if (field.getDeclaringClass().equals(Double.TYPE.getClass())) {
final double oldValue = field.getDouble(ability);
double newValue = modifier.getType() == AttributeModifierType.MULTIPLY ? oldValue * modifier.getModifier(ability) : oldValue + modifier.getModifier(ability);
final AttributeModifyEvent event = new AttributeModifyEvent(ability, attribute, oldValue, newValue, modifier);
Bukkit.getPluginManager().callEvent(event);
newValue = event.getNewValue();
field.setDouble(ability, newValue);
} else if (field.getDeclaringClass().equals(Long.TYPE.getClass())) {
final long oldValue = field.getLong(ability);
long newValue = (long) (modifier.getType() == AttributeModifierType.MULTIPLY ? oldValue * modifier.getModifier(ability) : oldValue + modifier.getModifier(ability));
final AttributeModifyEvent event = new AttributeModifyEvent(ability, attribute, oldValue, newValue, modifier);
Bukkit.getPluginManager().callEvent(event);
newValue = (long) event.getNewValue();
field.setLong(ability, newValue);
} else if (field.getDeclaringClass().equals(Integer.TYPE.getClass())) {
final int oldValue = field.getInt(ability);
int newValue = (int) (modifier.getType() == AttributeModifierType.MULTIPLY ? oldValue * modifier.getModifier(ability) : oldValue + modifier.getModifier(ability));
final AttributeModifyEvent event = new AttributeModifyEvent(ability, attribute, oldValue, newValue, modifier);
Bukkit.getPluginManager().callEvent(event);
newValue = (int) event.getNewValue();
field.setInt(ability, newValue);
}
}
catch (final IllegalArgumentException e) {
e.printStackTrace();
}
catch (final IllegalAccessException e) {
e.printStackTrace();
}
if (!flag) {
field.setAccessible(false);
}
}
}
}
}
}

View file

@ -64,11 +64,6 @@ public class AvatarState extends AvatarAbility {
@Override @Override
public void progress() { public void progress() {
if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) { if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) {
if (this.player != null) {
if (this.bPlayer.isOnCooldown(this)) {
this.bPlayer.removeCooldown(this);
}
}
this.remove(); this.remove();
return; return;
} }
@ -85,18 +80,23 @@ public class AvatarState extends AvatarAbility {
} }
private void addPotionEffects() { private void addPotionEffects() {
final int duration = 70;
if (this.regenEnabled) { if (this.regenEnabled) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, duration, this.regenPower)); this.addProgressPotionEffect(PotionEffectType.REGENERATION, this.regenPower);
} }
if (this.speedEnabled) { if (this.speedEnabled) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, duration, this.speedPower)); this.addProgressPotionEffect(PotionEffectType.SPEED, this.speedPower);
} }
if (this.resistanceEnabled) { if (this.resistanceEnabled) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, duration, this.resistancePower)); this.addProgressPotionEffect(PotionEffectType.DAMAGE_RESISTANCE, this.resistancePower);
} }
if (this.fireResistanceEnabled) { if (this.fireResistanceEnabled) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, duration, this.fireResistancePower)); this.addProgressPotionEffect(PotionEffectType.FIRE_RESISTANCE, this.fireResistancePower);
}
}
private void addProgressPotionEffect(final PotionEffectType effect, final int power) {
if (!this.player.hasPotionEffect(effect) || this.player.getPotionEffect(effect).getAmplifier() < power || (this.player.getPotionEffect(effect).getAmplifier() == power && this.player.getPotionEffect(effect).getDuration() == 1)) {
this.player.addPotionEffect(new PotionEffect(effect, 10, power, true, false), true);
} }
} }

View file

@ -9,13 +9,21 @@ import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.attribute.Attribute;
public class AcrobatStance extends ChiAbility { public class AcrobatStance extends ChiAbility {
@Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@Attribute(Attribute.DURATION)
private long duration;
@Attribute(Attribute.SPEED)
private int speed; private int speed;
@Attribute("Jump")
private int jump; private int jump;
@Attribute("ChiBlockBoost")
private double chiBlockBoost; private double chiBlockBoost;
@Attribute("ParalyzeDodgeBoost")
private double paralyzeDodgeBoost; private double paralyzeDodgeBoost;
public AcrobatStance(final Player player) { public AcrobatStance(final Player player) {
@ -24,8 +32,9 @@ public class AcrobatStance extends ChiAbility {
return; return;
} }
this.cooldown = getConfig().getLong("Abilities.Chi.AcrobatStance.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Chi.AcrobatStance.Cooldown");
this.speed = getConfig().getInt("Abilities.Chi.AcrobatStance.Speed") + 1; this.duration = getConfig().getLong("Abilities.Chi.AcrobatStance.Duration");
this.jump = getConfig().getInt("Abilities.Chi.AcrobatStance.Jump") + 1; this.speed = getConfig().getInt("Abilities.Chi.AcrobatStance.Speed") - 1;
this.jump = getConfig().getInt("Abilities.Chi.AcrobatStance.Jump") - 1;
this.chiBlockBoost = getConfig().getDouble("Abilities.Chi.AcrobatStance.ChiBlockBoost"); this.chiBlockBoost = getConfig().getDouble("Abilities.Chi.AcrobatStance.ChiBlockBoost");
this.paralyzeDodgeBoost = getConfig().getDouble("Abilities.Chi.AcrobatStance.ParalyzeChanceDecrease"); this.paralyzeDodgeBoost = getConfig().getDouble("Abilities.Chi.AcrobatStance.ParalyzeChanceDecrease");
@ -40,7 +49,7 @@ public class AcrobatStance extends ChiAbility {
this.start(); this.start();
this.bPlayer.setStance(this); this.bPlayer.setStance(this);
GeneralMethods.displayMovePreview(player); GeneralMethods.displayMovePreview(player);
player.playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_HURT, 0.5F, 2F); player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_HURT, 0.5F, 2F);
} }
@Override @Override
@ -48,13 +57,16 @@ public class AcrobatStance extends ChiAbility {
if (!this.bPlayer.canBendIgnoreBinds(this) || !this.bPlayer.hasElement(Element.CHI)) { if (!this.bPlayer.canBendIgnoreBinds(this) || !this.bPlayer.hasElement(Element.CHI)) {
this.remove(); this.remove();
return; return;
} else if (this.duration != 0 && System.currentTimeMillis() > this.getStartTime() + this.duration) {
this.remove();
return;
} }
if (!this.player.hasPotionEffect(PotionEffectType.SPEED)) { if (!this.player.hasPotionEffect(PotionEffectType.SPEED) || this.player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() < this.speed || (this.player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() == this.speed && this.player.getPotionEffect(PotionEffectType.SPEED).getDuration() == 1)) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, this.speed, true)); this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 10, this.speed, true, false), true);
} }
if (!this.player.hasPotionEffect(PotionEffectType.JUMP)) { if (!this.player.hasPotionEffect(PotionEffectType.JUMP) || this.player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() < this.jump || (this.player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() == this.jump && this.player.getPotionEffect(PotionEffectType.JUMP).getDuration() == 1)) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, this.jump, true)); this.player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 10, this.jump, true, false), true);
} }
} }
@ -64,7 +76,7 @@ public class AcrobatStance extends ChiAbility {
this.bPlayer.addCooldown(this); this.bPlayer.addCooldown(this);
this.bPlayer.setStance(null); this.bPlayer.setStance(null);
GeneralMethods.displayMovePreview(this.player); GeneralMethods.displayMovePreview(this.player);
this.player.playSound(this.player.getLocation(), Sound.ENTITY_ENDERDRAGON_SHOOT, 0.5F, 2F); this.player.playSound(this.player.getLocation(), Sound.ENTITY_ENDER_DRAGON_SHOOT, 0.5F, 2F);
this.player.removePotionEffect(PotionEffectType.SPEED); this.player.removePotionEffect(PotionEffectType.SPEED);
this.player.removePotionEffect(PotionEffectType.JUMP); this.player.removePotionEffect(PotionEffectType.JUMP);
} }
@ -110,6 +122,14 @@ public class AcrobatStance extends ChiAbility {
this.jump = jump; this.jump = jump;
} }
public long getDuration() {
return this.duration;
}
public void setDuration(final long duration) {
this.duration = duration;
}
public double getChiBlockBoost() { public double getChiBlockBoost() {
return this.chiBlockBoost; return this.chiBlockBoost;
} }

View file

@ -19,6 +19,8 @@ public class Paralyze extends ChiAbility {
@Attribute(Attribute.COOLDOWN) @Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@Attribute(Attribute.DURATION)
private long duration;
private Entity target; private Entity target;
public Paralyze(final Player sourceplayer, final Entity targetentity) { public Paralyze(final Player sourceplayer, final Entity targetentity) {
@ -27,7 +29,11 @@ public class Paralyze extends ChiAbility {
return; return;
} }
this.target = targetentity; this.target = targetentity;
if (!(this.target instanceof LivingEntity)) {
return;
}
this.cooldown = getConfig().getLong("Abilities.Chi.Paralyze.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Chi.Paralyze.Cooldown");
this.duration = getConfig().getLong("Abilities.Chi.Paralyze.Duration");
this.start(); this.start();
} }
@ -40,13 +46,13 @@ public class Paralyze extends ChiAbility {
return; return;
} }
} }
paralyze(this.target); this.paralyze(this.target);
this.bPlayer.addCooldown(this); this.bPlayer.addCooldown(this);
} }
this.remove(); this.remove();
} }
private static void paralyze(final Entity entity) { private void paralyze(final Entity entity) {
if (entity instanceof Creature) { if (entity instanceof Creature) {
((Creature) entity).setTarget(null); ((Creature) entity).setTarget(null);
} }
@ -57,8 +63,8 @@ public class Paralyze extends ChiAbility {
} }
} }
final MovementHandler mh = new MovementHandler((LivingEntity) entity, CoreAbility.getAbility(Paralyze.class)); final MovementHandler mh = new MovementHandler((LivingEntity) entity, CoreAbility.getAbility(Paralyze.class));
mh.stopWithDuration(getDuration() / 1000 * 20, Element.CHI.getColor() + "* Paralyzed *"); mh.stopWithDuration(this.duration / 1000 * 20, Element.CHI.getColor() + "* Paralyzed *");
entity.getWorld().playSound(entity.getLocation(), Sound.ENTITY_ENDERDRAGON_HURT, 2, 0); entity.getWorld().playSound(entity.getLocation(), Sound.ENTITY_ENDER_DRAGON_HURT, 2, 0);
} }
@Override @Override
@ -86,10 +92,6 @@ public class Paralyze extends ChiAbility {
return false; return false;
} }
public static long getDuration() {
return getConfig().getLong("Abilities.Chi.Paralyze.Duration");
}
public Entity getTarget() { public Entity getTarget() {
return this.target; return this.target;
} }
@ -98,4 +100,7 @@ public class Paralyze extends ChiAbility {
this.target = target; this.target = target;
} }
public long getDuration() {
return this.duration;
}
} }

View file

@ -13,6 +13,7 @@ public class QuickStrike extends ChiAbility {
@Attribute(Attribute.DAMAGE) @Attribute(Attribute.DAMAGE)
private double damage; private double damage;
@Attribute("ChiBlockChance")
private int blockChance; private int blockChance;
private Entity target; private Entity target;
@Attribute(Attribute.COOLDOWN) @Attribute(Attribute.COOLDOWN)

View file

@ -3,7 +3,6 @@ package com.projectkorra.projectkorra.chiblocking;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -15,6 +14,7 @@ import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.util.ParticleEffect;
public class Smokescreen extends ChiAbility { public class Smokescreen extends ChiAbility {
@ -55,7 +55,7 @@ public class Smokescreen extends ChiAbility {
for (int i = 0; i < 125; i++) { for (int i = 0; i < 125; i++) {
final Location newLoc = new Location(loc.getWorld(), loc.getX() + x, loc.getY() + y, loc.getZ() + z); final Location newLoc = new Location(loc.getWorld(), loc.getX() + x, loc.getY() + y, loc.getZ() + z);
for (int direction = 0; direction < 8; direction++) { for (int direction = 0; direction < 8; direction++) {
loc.getWorld().playEffect(newLoc, Effect.SMOKE, direction); ParticleEffect.SMOKE_NORMAL.display(newLoc, 4, 0.5, 0.5, 0.5);
} }
if (z == 2) { if (z == 2) {
z = -2; z = -2;

View file

@ -1,11 +1,11 @@
package com.projectkorra.projectkorra.chiblocking; package com.projectkorra.projectkorra.chiblocking;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.chiblocking.passive.ChiPassive; import com.projectkorra.projectkorra.chiblocking.passive.ChiPassive;
import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.DamageHandler;
@ -14,6 +14,7 @@ public class SwiftKick extends ChiAbility {
@Attribute(Attribute.DAMAGE) @Attribute(Attribute.DAMAGE)
private double damage; private double damage;
@Attribute("ChiBlockChance")
private int blockChance; private int blockChance;
@Attribute(Attribute.COOLDOWN) @Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@ -37,7 +38,7 @@ public class SwiftKick extends ChiAbility {
this.remove(); this.remove();
return; return;
} }
if (this.player.getLocation().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR) { if (!ElementalAbility.isAir(this.player.getLocation().subtract(0, 0.5, 0).getBlock().getType())) {
this.remove(); this.remove();
return; return;
} }

View file

@ -9,11 +9,17 @@ import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.attribute.Attribute;
public class WarriorStance extends ChiAbility { public class WarriorStance extends ChiAbility {
@Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
@Attribute(Attribute.DURATION)
private long duration;
@Attribute("Strength")
private int strength; private int strength;
@Attribute("Resistance")
private int resistance; private int resistance;
public WarriorStance(final Player player) { public WarriorStance(final Player player) {
@ -22,8 +28,9 @@ public class WarriorStance extends ChiAbility {
return; return;
} }
this.cooldown = getConfig().getLong("Abilities.Chi.WarriorStance.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Chi.WarriorStance.Cooldown");
this.duration = getConfig().getLong("Abilities.Chi.WarriorStance.Duration");
this.strength = getConfig().getInt("Abilities.Chi.WarriorStance.Strength") - 1; this.strength = getConfig().getInt("Abilities.Chi.WarriorStance.Strength") - 1;
this.resistance = getConfig().getInt("Abilities.Chi.WarriorStance.Resistance"); this.resistance = getConfig().getInt("Abilities.Chi.WarriorStance.Resistance"); //intended to be negative
final ChiAbility stance = this.bPlayer.getStance(); final ChiAbility stance = this.bPlayer.getStance();
if (stance != null) { if (stance != null) {
@ -36,7 +43,7 @@ public class WarriorStance extends ChiAbility {
this.start(); this.start();
this.bPlayer.setStance(this); this.bPlayer.setStance(this);
GeneralMethods.displayMovePreview(player); GeneralMethods.displayMovePreview(player);
player.playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_HURT, 0.5F, 2F); player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_HURT, 0.5F, 2F);
} }
@Override @Override
@ -44,13 +51,16 @@ public class WarriorStance extends ChiAbility {
if (!this.bPlayer.canBendIgnoreBinds(this) || !this.bPlayer.hasElement(Element.CHI)) { if (!this.bPlayer.canBendIgnoreBinds(this) || !this.bPlayer.hasElement(Element.CHI)) {
this.remove(); this.remove();
return; return;
} else if (this.duration != 0 && System.currentTimeMillis() > this.getStartTime() + this.duration) {
this.remove();
return;
} }
if (!this.player.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) { if (!this.player.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE) || this.player.getPotionEffect(PotionEffectType.DAMAGE_RESISTANCE).getAmplifier() > this.resistance || (this.player.getPotionEffect(PotionEffectType.DAMAGE_RESISTANCE).getAmplifier() == this.resistance && this.player.getPotionEffect(PotionEffectType.DAMAGE_RESISTANCE).getDuration() == 1)) { //special case for negative resistance
this.player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 60, this.resistance, true)); this.player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 10, this.resistance, true, false), true);
} }
if (!this.player.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) { if (!this.player.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE) || this.player.getPotionEffect(PotionEffectType.INCREASE_DAMAGE).getAmplifier() < this.strength || (this.player.getPotionEffect(PotionEffectType.INCREASE_DAMAGE).getAmplifier() == this.strength && this.player.getPotionEffect(PotionEffectType.INCREASE_DAMAGE).getDuration() == 1)) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 60, this.strength, true)); this.player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 10, this.strength, true, false), true);
} }
} }
@ -61,7 +71,7 @@ public class WarriorStance extends ChiAbility {
this.bPlayer.setStance(null); this.bPlayer.setStance(null);
if (this.player != null) { if (this.player != null) {
GeneralMethods.displayMovePreview(this.player); GeneralMethods.displayMovePreview(this.player);
this.player.playSound(this.player.getLocation(), Sound.ENTITY_ENDERDRAGON_SHOOT, 0.5F, 2F); this.player.playSound(this.player.getLocation(), Sound.ENTITY_ENDER_DRAGON_SHOOT, 0.5F, 2F);
this.player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); this.player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
this.player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE); this.player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
} }
@ -108,4 +118,12 @@ public class WarriorStance extends ChiAbility {
this.resistance = resistance; this.resistance = resistance;
} }
public long getDuration() {
return this.duration;
}
public void setDuration(final long duration) {
this.duration = duration;
}
} }

View file

@ -13,12 +13,16 @@ import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.ComboAbility;
import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.MovementHandler; import com.projectkorra.projectkorra.util.MovementHandler;
public class Immobilize extends ChiAbility implements ComboAbility { public class Immobilize extends ChiAbility implements ComboAbility {
@Attribute(Attribute.DURATION)
private long duration; private long duration;
@Attribute(Attribute.COOLDOWN)
private long cooldown; private long cooldown;
private Entity target; private Entity target;
@ -35,6 +39,9 @@ public class Immobilize extends ChiAbility implements ComboAbility {
this.remove(); this.remove();
return; return;
} else { } else {
if (GeneralMethods.isRegionProtectedFromBuild(this, this.target.getLocation()) || ((this.target instanceof Player) && Commands.invincible.contains(((Player) this.target).getName()))) {
return;
}
paralyze(this.target, this.duration); paralyze(this.target, this.duration);
this.bPlayer.addCooldown(this); this.bPlayer.addCooldown(this);
} }
@ -58,8 +65,7 @@ public class Immobilize extends ChiAbility implements ComboAbility {
} }
@Override @Override
public void progress() { public void progress() {}
}
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
@ -115,9 +121,4 @@ public class Immobilize extends ChiAbility implements ComboAbility {
public void setCooldown(final long cooldown) { public void setCooldown(final long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
@Override
public String getInstructions() {
return "QuickStrike > SwiftKick > QuickStrike > QuickStrike";
}
} }

View file

@ -17,8 +17,7 @@ public class Acrobatics extends ChiAbility implements PassiveAbility {
} }
@Override @Override
public void progress() { public void progress() {}
}
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {

View file

@ -5,32 +5,27 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility; import com.projectkorra.projectkorra.ability.PassiveAbility;
import com.projectkorra.projectkorra.airbending.passive.AirAgility; import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.chiblocking.AcrobatStance;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
public class ChiAgility extends ChiAbility implements PassiveAbility { public class ChiAgility extends ChiAbility implements PassiveAbility {
// Configurable variables. // Configurable variables.
@Attribute("Jump")
private int jumpPower; private int jumpPower;
@Attribute(Attribute.SPEED)
private int speedPower; private int speedPower;
// Instance related variables.
private boolean jumpActivate;
private boolean speedActivate;
public ChiAgility(final Player player) { public ChiAgility(final Player player) {
super(player); super(player);
this.setFields(); this.setFields();
} }
public void setFields() { public void setFields() {
this.jumpPower = ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.JumpPower"); this.jumpPower = ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.JumpPower") - 1;
this.speedPower = ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.SpeedPower"); this.speedPower = ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.SpeedPower") - 1;
} }
@Override @Override
@ -39,47 +34,13 @@ public class ChiAgility extends ChiAbility implements PassiveAbility {
return; return;
} }
if (CoreAbility.hasAbility(this.player, AirAgility.class) && this.bPlayer.canBendPassive(CoreAbility.getAbility(AirAbility.class))) {
final AirAgility airAgility = CoreAbility.getAbility(this.player, AirAgility.class);
if (airAgility.getJumpPower() > this.jumpPower) {
this.jumpPower = airAgility.getJumpPower();
}
if (airAgility.getSpeedPower() > this.speedPower) {
this.speedPower = airAgility.getSpeedPower();
}
}
if (hasAbility(this.player, AcrobatStance.class)) {
final AcrobatStance stance = getAbility(this.player, AcrobatStance.class);
this.jumpPower = Math.max(this.jumpPower, stance.getJump());
this.speedPower = Math.max(this.speedPower, stance.getSpeed());
}
// Jump Buff. // Jump Buff.
this.jumpActivate = true; if (!this.player.hasPotionEffect(PotionEffectType.JUMP) || this.player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() < this.jumpPower || (this.player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() == this.jumpPower && this.player.getPotionEffect(PotionEffectType.JUMP).getDuration() == 1)) {
if (this.player.hasPotionEffect(PotionEffectType.JUMP)) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 10, this.jumpPower, true, false), true);
final PotionEffect potion = this.player.getPotionEffect(PotionEffectType.JUMP);
if (potion.getAmplifier() > this.jumpPower - 1) {
this.jumpActivate = false;
} else {
this.player.removePotionEffect(PotionEffectType.JUMP);
}
} }
if (this.jumpActivate) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20, this.jumpPower - 1, true, false), false);
}
// Speed Buff. // Speed Buff.
this.speedActivate = true; if (!this.player.hasPotionEffect(PotionEffectType.SPEED) || this.player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() < this.speedPower || (this.player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() == this.speedPower && this.player.getPotionEffect(PotionEffectType.SPEED).getDuration() == 1)) {
if (this.player.hasPotionEffect(PotionEffectType.SPEED)) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 10, this.speedPower, true, false), true);
final PotionEffect potion = this.player.getPotionEffect(PotionEffectType.SPEED);
if (potion.getAmplifier() > this.speedPower - 1) {
this.speedActivate = false;
} else {
this.player.removePotionEffect(PotionEffectType.SPEED);
}
}
if (this.speedActivate) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20, this.speedPower - 1, true, false), false);
} }
} }

View file

@ -58,7 +58,7 @@ public class ChiPassive {
} }
bPlayer.blockChi(); bPlayer.blockChi();
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_HURT, 2, 0); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_HURT, 2, 0);
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
new BukkitRunnable() { new BukkitRunnable() {

View file

@ -17,8 +17,7 @@ public class ChiSaturation extends ChiAbility implements PassiveAbility {
} }
@Override @Override
public void progress() { public void progress() {}
}
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {

View file

@ -69,8 +69,7 @@ public class BindCommand extends PKCommand {
if (args.size() == 2) { if (args.size() == 2) {
try { try {
this.bind(sender, args.get(0), Integer.parseInt(args.get(1))); this.bind(sender, args.get(0), Integer.parseInt(args.get(1)));
} } catch (final NumberFormatException ex) {
catch (final NumberFormatException ex) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.wrongNumber); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.wrongNumber);
} }
} }

View file

@ -67,8 +67,7 @@ public class ClearCommand extends PKCommand {
} else { } else {
GeneralMethods.sendBrandingMessage(sender, ChatColor.YELLOW + this.alreadyEmpty); GeneralMethods.sendBrandingMessage(sender, ChatColor.YELLOW + this.alreadyEmpty);
} }
} } catch (final NumberFormatException e) {
catch (final NumberFormatException e) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.wrongNumber); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.wrongNumber);
} }
} }

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