mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-22 16:05:01 +00:00
improvements/updates/fixes (#987)
## Additions * use spigot method for entities around point, should be more optimized * optimizations to water and air spout to not continually set flying * optimization 1 for revertchecker: do not use block.getChunk as this will load the chunk on the server and instead use hashmap of coords * optimization 2 for revertcheck: use paperlib to allow servers running paper to load the chunk for a revert block async * optimize tempblock revert to load chunk async before updating state * create local folder repo and update pom for local jar files, this is necessary to use the maven shade plugin. Put a comment in the pom for how to add new dependencies * add specific timings for hot spots in the code: player move event, physics event, and bending manager. Should help server owners diagnose lag from PK * optimize move event to ignore head movements without directional movement * optimize physics event to check for air prior to checking for tempblocks * optimize tempblock set/revert to not apply physics for blocks that dont emit light * check for concrete powder in move earth * optimize isWater to hit actual water blocks first * optimize PhaseChange list check, hot spot due to being called in physics event * add "large" abilities collision with each other * remove HorizontalVelocityTracker that has lasted over 30 seconds, also don't create a tracker for non-living entities * add config to ignore ores completely for EarthTunnel (good for mining) * add config option for multiple blocks to be changed per earthtunnel run, allowing for much faster earth tunnels * add config option to allow snow to be used for ice blast * add config options for avatar state cooldowns for IceBlast and IceBullet * add config option for ice trap type moves to not place blocks in players head or feet * add PlaceholderAPI support for %projectkorra_slot<1-9>% %projectkorra_element% %projectkorra_elementcolor% %projectkorra_elements% * add "bending" WorldGuard flag. Used for allowing or denying bending in worldguard regions. Will fallback to the old method of the build flag if the custom flag fails to register or isn't set ## Fixes * wrong plugin version * remove unnecessary code from avatar state causing cooldown removal * fix error in EarthGrab remove * fix error with TempArmor remove if some armor was null * fix NPE and CME in WaterArms * fix sound error in AirSuction * fix NPE in player chat * fix error when damaging item frame * fix NPE in FireManipulation getting locations * fix NPE in WaterSpout getting locations * fix NPE in HeatControl * prevent placing blocks in earth tunnel air, and fix error with placing blocks in tempblocks * fix AirSweep affecting toggled invincible * fix illumination torch replacing fences allowing players to pass through them * fix AirShield vector * fix AirSwipe not being removed * fix AirSuction not checking worlds * remove firestream tasks on JetBlast/JetBlaze removal * division by 0 fix for tornado (entity location and origin location being equal) * NaN vector fix for airstream (location and destination being equal) * use actual list of undead for isUndead from the wiki * fix BloodBending affecting armor stands * fix AirSweep vector * fix IceBullet combo to function better * fix isMeltable to use ElementalAbility functions * fix Paralyze trying to paralyze non-living entities ## Removals * remove plotsquared support, and bentobox leftovers * remove unnecessary flight handlers
This commit is contained in:
parent
ea73c04788
commit
e757cea57a
77 changed files with 1054 additions and 546 deletions
|
@ -2,7 +2,7 @@ language: java
|
|||
script: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
||||
sudo: false
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
- openjdk8
|
||||
notifications:
|
||||
slack:
|
||||
rooms:
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
9
localrepo/com/griefcraft/lwc/2.1.2/lwc-2.1.2.pom
Normal file
9
localrepo/com/griefcraft/lwc/2.1.2/lwc-2.1.2.pom
Normal 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>
|
12
localrepo/com/griefcraft/lwc/maven-metadata-local.xml
Normal file
12
localrepo/com/griefcraft/lwc/maven-metadata-local.xml
Normal 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>
|
|
@ -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>
|
12
localrepo/com/palmergames/Towny/maven-metadata-local.xml
Normal file
12
localrepo/com/palmergames/Towny/maven-metadata-local.xml
Normal 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>
|
9
localrepo/com/songoda/kingdoms/1.2.3/kingdoms-1.2.3.pom
Normal file
9
localrepo/com/songoda/kingdoms/1.2.3/kingdoms-1.2.3.pom
Normal 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>
|
12
localrepo/com/songoda/kingdoms/maven-metadata-local.xml
Normal file
12
localrepo/com/songoda/kingdoms/maven-metadata-local.xml
Normal 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>
|
|
@ -0,0 +1 @@
|
|||
333673ff2f0740caad4889dcaa4840d4
|
|
@ -0,0 +1 @@
|
|||
3869ec4128db113162c54a11d0010a002ed3b5ee
|
|
@ -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>
|
|
@ -0,0 +1 @@
|
|||
1fe23316d4e93edea247dd0e49a73cee
|
|
@ -0,0 +1 @@
|
|||
fa0e391fae40a538a5b3223ad3b3b01990c0afe6
|
12
localrepo/me/markeh/factionsframework/maven-metadata.xml
Normal file
12
localrepo/me/markeh/factionsframework/maven-metadata.xml
Normal 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>
|
|
@ -0,0 +1 @@
|
|||
f381f9c9b67641659a289a4e6ed63a25
|
|
@ -0,0 +1 @@
|
|||
8ced509852cc7dd171ce85c9eb439969b9af1ce1
|
113
pom.xml
113
pom.xml
|
@ -3,9 +3,15 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.projectkorra</groupId>
|
||||
<artifactId>projectkorra</artifactId>
|
||||
<version>1.8.7</version>
|
||||
<version>1.8.8</version>
|
||||
<name>ProjectKorra</name>
|
||||
<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>
|
||||
|
@ -26,8 +32,35 @@
|
|||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</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>
|
||||
<dependencies>
|
||||
<!-- PaperLib -->
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<!-- Minecraft Timings -->
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>minecraft-timings</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
<!-- Spigot API -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
|
@ -46,10 +79,9 @@
|
|||
<groupId>me.markeh</groupId>
|
||||
<artifactId>factionsframework</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/FactionsFramework1.2.0.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- GriefPrevention -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- GriefPrevention -->
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
|
@ -60,9 +92,8 @@
|
|||
<dependency>
|
||||
<groupId>com.griefcraft</groupId>
|
||||
<artifactId>lwc</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Modern-LWC-2.1.2.jar</systemPath>
|
||||
<version>2.1.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- NoCheatPlus -->
|
||||
<dependency>
|
||||
|
@ -85,17 +116,15 @@
|
|||
<dependency>
|
||||
<groupId>com.bekvon.bukkit</groupId>
|
||||
<artifactId>residence</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Residence4.8.3.1.jar</systemPath>
|
||||
<version>4.8.3.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Towny -->
|
||||
<dependency>
|
||||
<groupId>com.palmergames</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
<version>0.93.0.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Towny.jar</systemPath>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- WorldEdit / WorldGuard -->
|
||||
<dependency>
|
||||
|
@ -126,25 +155,22 @@
|
|||
<dependency>
|
||||
<groupId>br.net.fabiozumbi12</groupId>
|
||||
<artifactId>RedProtect</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/RedProtect-7.5.5-b129-Universal.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- PlotSquared -->
|
||||
<dependency>
|
||||
<groupId>com.github.intelletualsites</groupId>
|
||||
<artifactId>plotsquared</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/PlotSquared-Bukkit-4.18.12.31-38a382f-2131.jar</systemPath>
|
||||
<version>7.5.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Kingdoms -->
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>kingdoms</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/FabledKingdoms-1.2.3.jar</systemPath>
|
||||
<version>1.2.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- PlaceholderAPI -->
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
@ -179,6 +205,39 @@
|
|||
<outputDirectory>${dir}</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<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>
|
||||
</build>
|
||||
<properties>
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.projectkorra.projectkorra;
|
|||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import co.aikar.timings.lib.MCTiming;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
|
@ -28,9 +29,19 @@ public class BendingManager implements Runnable {
|
|||
long interval;
|
||||
private final HashMap<World, Boolean> times = new HashMap<World, Boolean>(); // true if day time
|
||||
|
||||
private MCTiming TimingCoreAbilityProgressAll, TimingTempPotionProgressAll, TimingHandleDayNight, TimingHorizontalVelocityTrackerUpdateAll, TimingHandleCoolDowns, TimingTempArmorCleanup, TimingActionBarCheck;
|
||||
|
||||
public BendingManager() {
|
||||
instance = this;
|
||||
this.time = System.currentTimeMillis();
|
||||
|
||||
TimingCoreAbilityProgressAll = ProjectKorra.timing("CoreAbilityProgressAll");
|
||||
TimingTempPotionProgressAll = ProjectKorra.timing("TempPotionProgressAll");
|
||||
TimingHandleDayNight = ProjectKorra.timing("HandleDayNight");
|
||||
TimingHorizontalVelocityTrackerUpdateAll = ProjectKorra.timing("HorizontalVelocityTrackerUpdateAll");
|
||||
TimingHandleCoolDowns = ProjectKorra.timing("HandleCoolDowns");
|
||||
TimingTempArmorCleanup = ProjectKorra.timing("TempArmorCleanup");
|
||||
TimingActionBarCheck = ProjectKorra.timing("ActionBarCheck");
|
||||
}
|
||||
|
||||
public static BendingManager getInstance() {
|
||||
|
@ -97,19 +108,37 @@ public class BendingManager implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
this.interval = System.currentTimeMillis() - this.time;
|
||||
this.time = System.currentTimeMillis();
|
||||
ProjectKorra.time_step = this.interval;
|
||||
this.interval = System.currentTimeMillis() - this.time;
|
||||
this.time = System.currentTimeMillis();
|
||||
ProjectKorra.time_step = this.interval;
|
||||
|
||||
try(MCTiming timing = TimingCoreAbilityProgressAll.startTiming()) {
|
||||
CoreAbility.progressAll();
|
||||
TempPotionEffect.progressAll();
|
||||
this.handleDayNight();
|
||||
RevertChecker.revertAirBlocks();
|
||||
HorizontalVelocityTracker.updateAll();
|
||||
this.handleCooldowns();
|
||||
TempArmor.cleanup();
|
||||
}
|
||||
|
||||
try(MCTiming timing = TimingTempPotionProgressAll.startTiming()) {
|
||||
TempPotionEffect.progressAll();
|
||||
}
|
||||
|
||||
try(MCTiming timing = TimingHandleDayNight.startTiming()) {
|
||||
this.handleDayNight();
|
||||
}
|
||||
|
||||
RevertChecker.revertAirBlocks();
|
||||
|
||||
try(MCTiming timing = TimingHorizontalVelocityTrackerUpdateAll.startTiming()) {
|
||||
HorizontalVelocityTracker.updateAll();
|
||||
}
|
||||
|
||||
try(MCTiming timing = TimingHandleCoolDowns.startTiming()) {
|
||||
this.handleCooldowns();
|
||||
}
|
||||
|
||||
try(MCTiming timing = TimingTempArmorCleanup.startTiming()) {
|
||||
TempArmor.cleanup();
|
||||
}
|
||||
|
||||
try(MCTiming timing = TimingActionBarCheck.startTiming()) {
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (Bloodbending.isBloodbent(player)) {
|
||||
ActionBar.sendActionBar(Element.BLOOD.getColor() + "* Bloodbent *", player);
|
||||
|
@ -118,9 +147,6 @@ public class BendingManager implements Runnable {
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSunriseMessage() {
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
@ -62,13 +61,6 @@ import com.bekvon.bukkit.residence.Residence;
|
|||
import com.bekvon.bukkit.residence.api.ResidenceInterface;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
|
||||
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import com.griefcraft.lwc.LWC;
|
||||
import com.griefcraft.lwc.LWCPlugin;
|
||||
|
@ -348,8 +340,13 @@ public class GeneralMethods {
|
|||
try {
|
||||
if (!rs2.next()) { // Data doesn't exist, we want a completely new player.
|
||||
DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9) VALUES ('" + uuid.toString() + "', '" + player + "', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null', 'null')");
|
||||
new BendingPlayer(uuid, player, new ArrayList<Element>(), new ArrayList<SubElement>(), new HashMap<Integer, String>(), false);
|
||||
ProjectKorra.log.info("Created new BendingPlayer for " + player);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new BendingPlayer(uuid, player, new ArrayList<Element>(), new ArrayList<SubElement>(), new HashMap<Integer, String>(), false);
|
||||
ProjectKorra.log.info("Created new BendingPlayer for " + player);
|
||||
}
|
||||
}.runTask(ProjectKorra.plugin);
|
||||
} else {
|
||||
// The player has at least played before.
|
||||
final String player2 = rs2.getString("player");
|
||||
|
@ -938,34 +935,7 @@ public class GeneralMethods {
|
|||
* @return A list of entities around a point
|
||||
*/
|
||||
public static List<Entity> getEntitiesAroundPoint(final Location location, final double radius) {
|
||||
final List<Entity> entities = new ArrayList<Entity>();
|
||||
final World world = location.getWorld();
|
||||
|
||||
// To find chunks we use chunk coordinates (not block coordinates!)
|
||||
final int smallX = (int) (location.getX() - radius) >> 4;
|
||||
final int bigX = (int) (location.getX() + radius) >> 4;
|
||||
final int smallZ = (int) (location.getZ() - radius) >> 4;
|
||||
final int bigZ = (int) (location.getZ() + radius) >> 4;
|
||||
|
||||
for (int x = smallX; x <= bigX; x++) {
|
||||
for (int z = smallZ; z <= bigZ; z++) {
|
||||
if (world.isChunkLoaded(x, z)) {
|
||||
entities.addAll(Arrays.asList(world.getChunkAt(x, z).getEntities()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<Entity> entityIterator = entities.iterator();
|
||||
while (entityIterator.hasNext()) {
|
||||
final Entity e = entityIterator.next();
|
||||
if (e.getWorld().equals(location.getWorld()) && e.getLocation().distanceSquared(location) > radius * radius) {
|
||||
entityIterator.remove();
|
||||
} else if (e instanceof Player && (((Player) e).isDead() || ((Player) e).getGameMode().equals(GameMode.SPECTATOR))) {
|
||||
entityIterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
return entities;
|
||||
return new ArrayList<>(location.getWorld().getNearbyEntities(location, radius, radius, radius, entity -> !(entity.isDead() || (entity instanceof Player && ((Player) entity).getGameMode().equals(GameMode.SPECTATOR)))));
|
||||
}
|
||||
|
||||
public static long getGlobalCooldown() {
|
||||
|
@ -1049,16 +1019,16 @@ public class GeneralMethods {
|
|||
}
|
||||
|
||||
public static int getMaxPresets(final Player player) {
|
||||
int max = ConfigManager.getConfig().getInt("Properties.MaxPresets");
|
||||
if (player.isOp()) {
|
||||
return 100;
|
||||
return max;
|
||||
}
|
||||
int cap = 0;
|
||||
for (int i = 0; i <= 10; i++) {
|
||||
for (int i = max; i > 0; i--) {
|
||||
if (player.hasPermission("bending.command.preset.create." + i)) {
|
||||
cap = i;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return cap;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static Vector getOrthogonalVector(final Vector axis, final double degrees, final double length) {
|
||||
|
@ -1424,7 +1394,6 @@ public class GeneralMethods {
|
|||
final boolean respectLWC = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectLWC");
|
||||
final boolean respectResidence = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.Residence.Respect");
|
||||
final boolean respectKingdoms = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectKingdoms");
|
||||
final boolean respectPlotSquared = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectPlotSquared");
|
||||
final boolean respectRedProtect = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectRedProtect");
|
||||
|
||||
boolean isIgnite = false;
|
||||
|
@ -1454,7 +1423,6 @@ public class GeneralMethods {
|
|||
final Plugin lwc = pm.getPlugin("LWC");
|
||||
final Plugin residence = pm.getPlugin("Residence");
|
||||
final Plugin kingdoms = pm.getPlugin("Kingdoms");
|
||||
final Plugin plotsquared = pm.getPlugin("PlotSquared");
|
||||
final Plugin redprotect = pm.getPlugin("RedProtect");
|
||||
|
||||
for (final Location location : new Location[] { loc, player.getLocation() }) {
|
||||
|
@ -1492,9 +1460,19 @@ public class GeneralMethods {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wg.getPlatform().getRegionContainer().createQuery().testState(BukkitAdapter.adapt(location), WorldGuardPlugin.inst().wrapPlayer(player), Flags.BUILD)) {
|
||||
return true;
|
||||
StateFlag bendingflag = (StateFlag)WorldGuard.getInstance().getFlagRegistry().get("bending");
|
||||
if (bendingflag != null) {
|
||||
StateFlag.State bendingflagstate = wg.getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(location), WorldGuardPlugin.inst().wrapPlayer(player), bendingflag);
|
||||
if(bendingflagstate == null && !wg.getPlatform().getRegionContainer().createQuery().testState(BukkitAdapter.adapt(location), WorldGuardPlugin.inst().wrapPlayer(player), Flags.BUILD)){
|
||||
return true;
|
||||
}
|
||||
if (bendingflagstate != null && bendingflagstate.equals(StateFlag.State.DENY)){
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if(!wg.getPlatform().getRegionContainer().createQuery().testState(BukkitAdapter.adapt(location), WorldGuardPlugin.inst().wrapPlayer(player), Flags.BUILD)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1607,42 +1585,6 @@ public class GeneralMethods {
|
|||
|
||||
}
|
||||
|
||||
if (plotsquared != null && respectPlotSquared) {
|
||||
com.github.intellectualsites.plotsquared.plot.object.Location plotLocation = BukkitUtil.getLocation(location);
|
||||
PlotArea plotArea = plotLocation.getPlotArea();
|
||||
if (plotArea != null) {
|
||||
Plot plot = plotArea.getPlot(plotLocation);
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (plot != null) {
|
||||
if (location.getBlock().getY() == 0) {
|
||||
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
|
||||
return true;
|
||||
}
|
||||
} else if ((location.getY() > plotArea.MAX_BUILD_HEIGHT || location.getY() < plotArea.MIN_BUILD_HEIGHT) && !Permissions
|
||||
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
|
||||
return true;
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
return true;
|
||||
}
|
||||
} else if (Settings.Done.RESTRICT_BUILDING && plot.getFlags().containsKey(com.github.intellectualsites.plotsquared.plot.flag.Flags.DONE)) {
|
||||
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (redprotect != null && respectRedProtect) {
|
||||
RedProtectAPI api = RedProtect.get().getAPI();
|
||||
Region region = api.getRegion(location);
|
||||
|
@ -1672,7 +1614,25 @@ public class GeneralMethods {
|
|||
|
||||
/** Checks if an entity is Undead **/
|
||||
public static boolean isUndead(final Entity entity) {
|
||||
return entity != null && (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);
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
switch(entity.getType()){
|
||||
case SKELETON:
|
||||
case STRAY:
|
||||
case WITHER_SKELETON:
|
||||
case WITHER:
|
||||
case ZOMBIE:
|
||||
case HUSK:
|
||||
case ZOMBIE_VILLAGER:
|
||||
case PIG_ZOMBIE:
|
||||
case DROWNED:
|
||||
case ZOMBIE_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
case PHANTOM:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isWeapon(final Material mat) {
|
||||
|
@ -1906,9 +1866,7 @@ public class GeneralMethods {
|
|||
final boolean respectLWC = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectLWC");
|
||||
final boolean respectResidence = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.Residence.Respect");
|
||||
final boolean respectKingdoms = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.Kingdoms");
|
||||
final boolean respectPlotSquared = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.PlotSquared");
|
||||
final boolean respectRedProtect = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RedProtect");
|
||||
final boolean respectBentoBox = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.BentoBox");
|
||||
final PluginManager pm = Bukkit.getPluginManager();
|
||||
|
||||
final Plugin wgp = pm.getPlugin("WorldGuard");
|
||||
|
@ -1919,9 +1877,7 @@ public class GeneralMethods {
|
|||
final Plugin lwc = pm.getPlugin("LWC");
|
||||
final Plugin residence = pm.getPlugin("Residence");
|
||||
final Plugin kingdoms = pm.getPlugin("Kingdoms");
|
||||
final Plugin plotsquared = pm.getPlugin("PlotSquared");
|
||||
final Plugin redprotect = pm.getPlugin("RedProtect");
|
||||
final Plugin bentobox = pm.getPlugin("BentoBox");
|
||||
|
||||
if (wgp != null && respectWorldGuard) {
|
||||
writeToDebug("WorldGuard v" + wgp.getDescription().getVersion());
|
||||
|
@ -1947,15 +1903,9 @@ public class GeneralMethods {
|
|||
if (kingdoms != null && respectKingdoms) {
|
||||
writeToDebug("Kingdoms v" + kingdoms.getDescription().getVersion());
|
||||
}
|
||||
if (plotsquared != null && respectPlotSquared) {
|
||||
writeToDebug("PlotSquared v" + plotsquared.getDescription().getVersion());
|
||||
}
|
||||
if (redprotect != null && respectRedProtect) {
|
||||
writeToDebug("RedProtect v" + redprotect.getDescription().getVersion());
|
||||
}
|
||||
if (bentobox != null && respectBentoBox) {
|
||||
writeToDebug("BentoBox v" + bentobox.getDescription().getVersion());
|
||||
}
|
||||
|
||||
writeToDebug("");
|
||||
writeToDebug("Plugins Hooking Into ProjectKorra (Core)");
|
||||
|
@ -2203,6 +2153,34 @@ public class GeneralMethods {
|
|||
return loc.getWorld().spawnFallingBlock(loc, data);
|
||||
}
|
||||
|
||||
public static boolean playerHeadIsInBlock(Player player, Block block) {
|
||||
return playerHeadIsInBlock(player, block, false);
|
||||
}
|
||||
|
||||
public static boolean playerHeadIsInBlock(Player player, Block block, boolean exact) {
|
||||
double checkDistance;
|
||||
if (exact){
|
||||
checkDistance = 0.5;
|
||||
} else {
|
||||
checkDistance = 0.75;
|
||||
}
|
||||
return (player.getEyeLocation().getBlockY() == block.getLocation().getBlockY() && (Math.abs(player.getEyeLocation().getX() - block.getLocation().add(0.5,0.0, 0.5).getX()) < checkDistance) && (Math.abs(player.getEyeLocation().getZ() - block.getLocation().add(0.5,0.0, 0.5).getZ()) < checkDistance));
|
||||
}
|
||||
|
||||
public static boolean playerFeetIsInBlock(Player player, Block block) {
|
||||
return playerFeetIsInBlock(player, block, false);
|
||||
}
|
||||
|
||||
public static boolean playerFeetIsInBlock(Player player, Block block, boolean exact) {
|
||||
double checkDistance;
|
||||
if (exact){
|
||||
checkDistance = 0.5;
|
||||
} else {
|
||||
checkDistance = 0.75;
|
||||
}
|
||||
return (player.getLocation().getBlockY() == block.getLocation().getBlockY() && (Math.abs(player.getLocation().getX() - block.getLocation().add(0.5,0.0, 0.5).getX()) < checkDistance) && (Math.abs(player.getLocation().getZ() - block.getLocation().add(0.5,0.0, 0.5).getZ()) < checkDistance));
|
||||
}
|
||||
|
||||
public static void sendBrandingMessage(final CommandSender sender, final String message) {
|
||||
ChatColor color;
|
||||
try {
|
||||
|
@ -2319,4 +2297,25 @@ public class GeneralMethods {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean locationEqualsIgnoreDirection(Location loc1, Location loc2) {
|
||||
return loc1.getWorld().equals(loc2.getWorld()) && loc1.getX() == loc2.getX() && loc1.getY() == loc2.getY() && loc1.getZ() == loc2.getZ();
|
||||
}
|
||||
|
||||
public static boolean isLightEmitting(Material material) {
|
||||
switch (material) {
|
||||
case GLOWSTONE:
|
||||
case TORCH:
|
||||
case SEA_LANTERN:
|
||||
case BEACON:
|
||||
case REDSTONE_LAMP:
|
||||
case REDSTONE_TORCH:
|
||||
case MAGMA_BLOCK:
|
||||
case LAVA:
|
||||
case JACK_O_LANTERN:
|
||||
case END_ROD:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.projectkorra.projectkorra;
|
||||
|
||||
import co.aikar.timings.lib.MCTiming;
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
import com.projectkorra.projectkorra.ability.*;
|
||||
import com.projectkorra.projectkorra.ability.util.ComboManager;
|
||||
|
@ -42,6 +43,7 @@ import com.projectkorra.projectkorra.util.*;
|
|||
import com.projectkorra.projectkorra.util.FlightHandler.Flight;
|
||||
import com.projectkorra.projectkorra.waterbending.*;
|
||||
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.ice.IceBlast;
|
||||
import com.projectkorra.projectkorra.waterbending.ice.IceSpikeBlast;
|
||||
|
@ -66,6 +68,7 @@ import org.bukkit.event.entity.*;
|
|||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -83,8 +86,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 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) {
|
||||
|
||||
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)
|
||||
|
@ -249,13 +269,42 @@ public class PKListener implements Listener {
|
|||
public void onBlockPhysics(final BlockPhysicsEvent event) {
|
||||
final Block block = event.getBlock();
|
||||
|
||||
if (!WaterManipulation.canPhysicsChange(block) || !EarthPassive.canPhysicsChange(block) || Illumination.isIlluminationTorch(block) || EarthAbility.getPreventPhysicsBlocks().contains(block)) {
|
||||
event.setCancelled(true);
|
||||
try(MCTiming timing = TimingPhysicsWaterManipulationCheck.startTiming()) {
|
||||
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 (!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)) && ElementalAbility.isAir(block.getRelative(BlockFace.DOWN).getType())) {
|
||||
event.setCancelled(true);
|
||||
try(MCTiming timing = TimingPhysicsAirTempBlockBelowFallingBlockCheck.startTiming()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,19 +316,13 @@ public class PKListener implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
if (TempBlock.isTempBlock(event.getBlock())) {
|
||||
final TempBlock tb = TempBlock.get(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);
|
||||
}
|
||||
if (TempBlock.isTempBlock(event.getBlockPlaced()) && event.getItemInHand().getType() != Material.FLINT_AND_STEEL) {
|
||||
// EarthTunnel has its own list of airBlocks TempBlocks, so we need to either not allow placing in Earth Tunnels, or remove the tempblock from Earth Tunnels airBlocks list so it doesn't revert. Here we just don't allow placing
|
||||
if (EarthTunnel.airBlocks.containsKey(TempBlock.get(event.getBlockPlaced()))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
TempBlock.removeBlock(event.getBlockPlaced());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,7 +410,9 @@ public class PKListener implements Listener {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -404,10 +449,12 @@ public class PKListener implements Listener {
|
|||
if (TempArmor.hasTempArmor(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())) {
|
||||
event.getDrops().add(new ItemStack(Material.IRON_INGOT, MetalClips.getTargetToAbility().get(event.getEntity()).getMetalClipsCount()));
|
||||
}
|
||||
|
@ -661,12 +708,14 @@ public class PKListener implements Listener {
|
|||
|
||||
String e = "Nonbender";
|
||||
ChatColor c = ChatColor.WHITE;
|
||||
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();
|
||||
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);
|
||||
event.setFormat(event.getFormat().replace("{element}", c + element + ChatColor.RESET).replace("{ELEMENT}", c + element + ChatColor.RESET).replace("{elementcolor}", c + "").replace("{ELEMENTCOLOR}", c + ""));
|
||||
|
@ -805,7 +854,7 @@ public class PKListener implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
final String boundAbil = sourceBPlayer.getBoundAbilityName();
|
||||
final Ability boundAbil = sourceBPlayer.getBoundAbility();
|
||||
|
||||
if (sourceBPlayer.getBoundAbility() != null) {
|
||||
if (!sourceBPlayer.isOnCooldown(boundAbil)) {
|
||||
|
@ -814,15 +863,15 @@ public class PKListener implements Listener {
|
|||
if (sourceBPlayer.getBoundAbility() instanceof ChiAbility) {
|
||||
if (sourceBPlayer.canCurrentlyBendWithWeapons()) {
|
||||
if (sourceBPlayer.isElementToggled(Element.CHI)) {
|
||||
if (boundAbil.equalsIgnoreCase("Paralyze")) {
|
||||
if (boundAbil.equals(CoreAbility.getAbility(Paralyze.class))) {
|
||||
new Paralyze(sourcePlayer, entity);
|
||||
} else if (boundAbil.equalsIgnoreCase("QuickStrike")) {
|
||||
} else if (boundAbil.equals(CoreAbility.getAbility(QuickStrike.class))) {
|
||||
new QuickStrike(sourcePlayer, entity);
|
||||
e.setCancelled(true);
|
||||
} else if (boundAbil.equalsIgnoreCase("SwiftKick")) {
|
||||
} else if (boundAbil.equals(CoreAbility.getAbility(SwiftKick.class))) {
|
||||
new SwiftKick(sourcePlayer, entity);
|
||||
e.setCancelled(true);
|
||||
} else if (boundAbil.equalsIgnoreCase("RapidPunch")) {
|
||||
} else if (boundAbil.equals(CoreAbility.getAbility(RapidPunch.class))) {
|
||||
new RapidPunch(sourcePlayer, entity);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
@ -940,6 +989,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)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -979,6 +1036,7 @@ public class PKListener implements Listener {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!RIGHT_CLICK_INTERACT.contains(player.getUniqueId())) {
|
||||
if (event.getRightClicked() instanceof Player) {
|
||||
final Player target = (Player) event.getRightClicked();
|
||||
|
@ -1064,75 +1122,86 @@ public class PKListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
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 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()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
try(MCTiming timing = TimingPlayerMoveMovementHandlerCheck.startTiming()) {
|
||||
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;
|
||||
}
|
||||
} 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();
|
||||
final double maxspeed = .2;
|
||||
if (currspeed > maxspeed) {
|
||||
// apply only if moving set a factor
|
||||
vel = vel.normalize().multiply(maxspeed);
|
||||
// apply the new velocity
|
||||
event.getPlayer().setVelocity(vel);
|
||||
}
|
||||
} else if (Bloodbending.isBloodbent(player)) {
|
||||
final BendingPlayer bender = Bloodbending.getBloodbender(player);
|
||||
if (bender.isAvatarState()) {
|
||||
event.setCancelled(true);
|
||||
try(MCTiming timing = TimingPlayerMoveSpoutCheck.startTiming()) {
|
||||
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();
|
||||
final double maxspeed = .2;
|
||||
if (currspeed > maxspeed) {
|
||||
// apply only if moving set a factor
|
||||
vel = vel.normalize().multiply(maxspeed);
|
||||
// apply the new velocity
|
||||
event.getPlayer().setVelocity(vel);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
double distance1 = 0;
|
||||
double distance2 = 0;
|
||||
final Location loc = Bloodbending.getBloodbendingLocation(player);
|
||||
if (player.getWorld().equals(loc.getWorld())) {
|
||||
distance1 = event.getFrom().distanceSquared(loc);
|
||||
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));
|
||||
try(MCTiming timing = TimingPlayerMoveBloodbentCheck.startTiming()) {
|
||||
if (Bloodbending.isBloodbent(player)) {
|
||||
final BendingPlayer bender = Bloodbending.getBloodbender(player);
|
||||
if (bender.isAvatarState()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (bPlayer != null) {
|
||||
if (event.getTo().getX() != event.getFrom().getX() || event.getTo().getY() != event.getFrom().getY() || event.getTo().getZ() != event.getFrom().getZ()) {
|
||||
if (bPlayer.hasElement(Element.AIR) || bPlayer.hasElement(Element.CHI)) {
|
||||
PassiveHandler.checkExhaustionPassives(player);
|
||||
|
||||
final Location loc = Bloodbending.getBloodbendingLocation(player);
|
||||
if (player.getWorld().equals(loc.getWorld())) {
|
||||
if (!player.getVelocity().equals(Bloodbending.getBloodbendingVector(player))) {
|
||||
player.setVelocity(Bloodbending.getBloodbendingVector(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()) {
|
||||
FirePassive.handle(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getTo().getY() > event.getFrom().getY()) {
|
||||
if (!(player.getLocation().getBlock().getType() == Material.VINE) && !(player.getLocation().getBlock().getType() == Material.LADDER)) {
|
||||
final int current = player.getStatistic(Statistic.JUMP);
|
||||
final int last = JUMPS.get(player);
|
||||
try(MCTiming timing = TimingPlayerMoveJumpCheck.startTiming()) {
|
||||
if (event.getTo().getY() > event.getFrom().getY()) {
|
||||
if (!(player.getLocation().getBlock().getType() == Material.VINE) && !(player.getLocation().getBlock().getType() == Material.LADDER)) {
|
||||
final int current = player.getStatistic(Statistic.JUMP);
|
||||
final int last = JUMPS.get(player);
|
||||
|
||||
if (last != current) {
|
||||
JUMPS.put(player, current);
|
||||
if (last != 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)) {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerJumpEvent(player, yDif));
|
||||
if ((yDif < 0.035 || yDif > 0.037) && (yDif < 0.116 || yDif > 0.118)) {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerJumpEvent(player, yDif));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1504,7 +1573,11 @@ public class PKListener implements Listener {
|
|||
if (abil.equalsIgnoreCase("Bloodbending")) {
|
||||
Bloodbending.launch(player);
|
||||
} 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")) {
|
||||
IceSpikeBlast.activate(player);
|
||||
} else if (abil.equalsIgnoreCase("OctopusForm")) {
|
||||
|
@ -1700,6 +1773,15 @@ public class PKListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryPickupItem(final InventoryPickupItemEvent event) {
|
||||
for (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 (MetalClips metalClips : CoreAbility.getAbilities(MetalClips.class)) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.projectkorra.projectkorra;
|
||||
|
||||
import co.aikar.timings.lib.MCTiming;
|
||||
import co.aikar.timings.lib.TimingManager;
|
||||
import com.bekvon.bukkit.residence.protection.FlagPermissions;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.*;
|
||||
|
@ -9,6 +11,8 @@ import com.projectkorra.projectkorra.command.Commands;
|
|||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.earthbending.util.EarthbendingManager;
|
||||
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.storage.DBConnection;
|
||||
import com.projectkorra.projectkorra.util.*;
|
||||
|
@ -32,12 +36,15 @@ public class ProjectKorra extends JavaPlugin {
|
|||
public static long time_step = 1;
|
||||
public Updater updater;
|
||||
private BukkitTask revertChecker;
|
||||
private static TimingManager timingManager;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
ProjectKorra.log = this.getLogger();
|
||||
|
||||
timingManager = TimingManager.of(this);
|
||||
|
||||
new ConfigManager();
|
||||
new GeneralMethods(this);
|
||||
final boolean checkUpdateOnStartup = ConfigManager.getConfig().getBoolean("Properties.UpdateChecker");
|
||||
|
@ -135,6 +142,10 @@ public class ProjectKorra extends JavaPlugin {
|
|||
|
||||
GeneralMethods.deserializeFile();
|
||||
GeneralMethods.startCacheCleaner(cacheTime);
|
||||
|
||||
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new PlaceholderAPIHook(this).register();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,6 +167,13 @@ public class ProjectKorra extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
if(Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
WorldGuardFlag.registerBendingWorldGuardFlag();
|
||||
}
|
||||
}
|
||||
|
||||
public static CollisionManager getCollisionManager() {
|
||||
return collisionManager;
|
||||
}
|
||||
|
@ -179,4 +197,7 @@ public class ProjectKorra extends JavaPlugin {
|
|||
return ConfigManager.getConfig().getBoolean("Properties.DatabaseCooldowns");
|
||||
}
|
||||
|
||||
public static MCTiming timing(String name) {
|
||||
return timingManager.of(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.projectkorra.projectkorra.ability;
|
||||
|
||||
import co.aikar.timings.lib.MCTiming;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import com.google.common.reflect.ClassPath.ClassInfo;
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
|
@ -248,7 +249,11 @@ public abstract class CoreAbility implements Ability {
|
|||
abil.modifyAttributes();
|
||||
abil.attributesModified = true;
|
||||
}
|
||||
abil.progress();
|
||||
|
||||
try(MCTiming timing = ProjectKorra.timing(abil.getName()).startTiming()) {
|
||||
abil.progress();
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new AbilityProgressEvent(abil));
|
||||
}
|
||||
catch (final Exception e) {
|
||||
|
|
|
@ -128,7 +128,7 @@ public abstract class EarthAbility extends ElementalAbility {
|
|||
}
|
||||
|
||||
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 down = false;
|
||||
final Vector norm = direction.clone().normalize();
|
||||
|
@ -154,7 +154,7 @@ public abstract class EarthAbility extends ElementalAbility {
|
|||
if (DensityShift.isPassiveSand(block)) {
|
||||
DensityShift.revertSand(block);
|
||||
}
|
||||
if (Illumination.isIlluminationTorch(affectedblock) && TempBlock.isTempBlock(affectedblock)) {
|
||||
if (TempBlock.isTempBlock(affectedblock)) {
|
||||
TempBlock.get(affectedblock).revertBlock();
|
||||
}
|
||||
if (LavaFlow.isLavaFlowBlock(block)){
|
||||
|
@ -268,7 +268,7 @@ public abstract class EarthAbility extends ElementalAbility {
|
|||
info.setBlock(block);
|
||||
info.setState(block.getState());
|
||||
}
|
||||
block.setType(Material.AIR);
|
||||
block.setType(Material.AIR, false);
|
||||
info.setTime(System.currentTimeMillis());
|
||||
TEMP_AIR_LOCATIONS.put(info.getID(), info);
|
||||
}
|
||||
|
@ -457,17 +457,18 @@ public abstract class EarthAbility extends ElementalAbility {
|
|||
MOVED_EARTH.put(target, info);
|
||||
|
||||
if (info.getState().getType() == Material.SAND) {
|
||||
target.setType(Material.SANDSTONE);
|
||||
target.setType(Material.SANDSTONE, false);
|
||||
} else if (info.getState().getType() == Material.RED_SAND) {
|
||||
target.setType(Material.RED_SANDSTONE);
|
||||
target.setType(Material.RED_SANDSTONE, false);
|
||||
} 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 {
|
||||
target.setType(info.getState().getType());
|
||||
target.setBlockData(info.getState().getBlockData());
|
||||
target.setBlockData(info.getState().getBlockData(), false);
|
||||
}
|
||||
|
||||
source.setType(Material.AIR);
|
||||
source.setType(Material.AIR, false);
|
||||
}
|
||||
|
||||
public static void playEarthbendingSound(final Location loc) {
|
||||
|
@ -559,7 +560,7 @@ public abstract class EarthAbility extends ElementalAbility {
|
|||
if (MOVED_EARTH.containsKey(block)) {
|
||||
final Information info = MOVED_EARTH.get(block);
|
||||
if (block.getType() == Material.SANDSTONE && info.getType() == Material.SAND) {
|
||||
block.setType(Material.SAND);
|
||||
block.setType(Material.SAND, false);
|
||||
}
|
||||
if (RaiseEarth.blockInAllAffectedBlocks(block)) {
|
||||
EarthAbility.revertBlock(block);
|
||||
|
@ -589,7 +590,7 @@ public abstract class EarthAbility extends ElementalAbility {
|
|||
}
|
||||
return;
|
||||
} else {
|
||||
info.getState().update(true);
|
||||
info.getState().update(true, false);
|
||||
TEMP_AIR_LOCATIONS.remove(i);
|
||||
}
|
||||
}
|
||||
|
@ -609,7 +610,7 @@ public abstract class EarthAbility extends ElementalAbility {
|
|||
}
|
||||
|
||||
if (block.equals(sourceblock)) {
|
||||
info.getState().update(true);
|
||||
info.getState().update(true, false);
|
||||
if (RaiseEarth.blockInAllAffectedBlocks(sourceblock)) {
|
||||
EarthAbility.revertBlock(sourceblock);
|
||||
}
|
||||
|
@ -627,20 +628,19 @@ public abstract class EarthAbility extends ElementalAbility {
|
|||
}
|
||||
|
||||
if (ElementalAbility.isAir(sourceblock.getType()) || sourceblock.isLiquid()) {
|
||||
info.getState().update(true);
|
||||
info.getState().update(true, false);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
if (GeneralMethods.isAdjacentToThreeOrMoreSources(block, false)) {
|
||||
block.setType(Material.WATER);
|
||||
BlockData data = Material.WATER.createBlockData();
|
||||
if (data instanceof Levelled) {
|
||||
((Levelled) data).setLevel(7);
|
||||
}
|
||||
block.setBlockData(data);
|
||||
block.setBlockData(data, false);
|
||||
} else {
|
||||
block.setType(Material.AIR);
|
||||
block.setType(Material.AIR, false);
|
||||
}
|
||||
|
||||
if (RaiseEarth.blockInAllAffectedBlocks(sourceblock)) {
|
||||
|
|
|
@ -115,7 +115,7 @@ public abstract class ElementalAbility extends CoreAbility {
|
|||
}
|
||||
|
||||
public static boolean isMeltable(final Block block) {
|
||||
if (block.getType() == Material.ICE || block.getType() == Material.SNOW) {
|
||||
if (isIce(block) || isSnow(block)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -206,19 +206,11 @@ public abstract class ElementalAbility extends CoreAbility {
|
|||
return Arrays.asList(getTransparentMaterials()).contains(block.getType()) && !GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation());
|
||||
}
|
||||
|
||||
public static boolean isUndead(final Entity entity) {
|
||||
if (entity == null) {
|
||||
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) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isWater(final Block block) {
|
||||
if (block == null) {
|
||||
return false;
|
||||
} else if(isWater(block.getType())) {
|
||||
return true;
|
||||
} else {
|
||||
return isWater(block.getBlockData());
|
||||
}
|
||||
|
|
|
@ -15,10 +15,7 @@ import com.projectkorra.projectkorra.waterbending.Torrent;
|
|||
import com.projectkorra.projectkorra.waterbending.WaterSpout;
|
||||
import com.projectkorra.projectkorra.waterbending.ice.PhaseChange;
|
||||
import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Levelled;
|
||||
|
@ -86,7 +83,7 @@ public abstract class WaterAbility extends ElementalAbility {
|
|||
}
|
||||
|
||||
public static boolean isBendableWaterTempBlock(final TempBlock tempBlock) {
|
||||
return PhaseChange.getFrozenBlocksAsTempBlock().contains(tempBlock) || HeatControl.getMeltedBlocks().contains(tempBlock) || SurgeWall.SOURCE_BLOCKS.contains(tempBlock) || Torrent.getFrozenBlocks().containsKey(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) {
|
||||
|
@ -261,7 +258,7 @@ public abstract class WaterAbility extends ElementalAbility {
|
|||
}
|
||||
|
||||
public static boolean isLeaves(final Material material) {
|
||||
return material == Material.ACACIA_LEAVES || material == Material.BIRCH_LEAVES || material == Material.DARK_OAK_LEAVES || material == Material.JUNGLE_LEAVES || material == Material.OAK_LEAVES || material == Material.SPRUCE_LEAVES;
|
||||
return Tag.LEAVES.isTagged(material);
|
||||
}
|
||||
|
||||
public static boolean isSnow(final Block block) {
|
||||
|
|
|
@ -215,9 +215,14 @@ public class CollisionInitializer {
|
|||
return;
|
||||
}
|
||||
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) {
|
||||
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,
|
||||
* FireBlast). Two colliding small abilities will remove each other. A small
|
||||
* ability is removed when it collides with a large ability.
|
||||
* Cancel interaction between two abilities
|
||||
*
|
||||
* @param smallAbility the small CoreAbility
|
||||
* @param ignoreAbility the small CoreAbility
|
||||
*/
|
||||
public void addIgnoreAbility(final CoreAbility ignoreAbility) {
|
||||
if (ignoreAbility == null) {
|
||||
|
|
|
@ -19,8 +19,6 @@ import com.projectkorra.projectkorra.configuration.ConfigManager;
|
|||
import com.projectkorra.projectkorra.earthbending.combo.EarthDomeOthers;
|
||||
import com.projectkorra.projectkorra.util.ClickType;
|
||||
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 {
|
||||
private static final long CLEANUP_DELAY = 20 * 60;
|
||||
|
@ -35,15 +33,6 @@ public class ComboManager {
|
|||
DESCRIPTIONS.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")) {
|
||||
final ArrayList<AbilityInformation> earthDomeOthers = new ArrayList<>();
|
||||
earthDomeOthers.add(new AbilityInformation("RaiseEarth", ClickType.RIGHT_CLICK_BLOCK));
|
||||
|
|
|
@ -262,9 +262,6 @@ public class AirBlast extends AirAbility {
|
|||
new HorizontalVelocityTracker(entity, this.player, 200l, this);
|
||||
}
|
||||
|
||||
if (!isUser && entity instanceof Player) {
|
||||
flightHandler.createInstance((Player) entity, this.player, 1000L, this.getName());
|
||||
}
|
||||
if (entity.getFireTicks() > 0) {
|
||||
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public class AirShield extends AirAbility {
|
|||
vx = (x * Math.cos(angle) - z * Math.sin(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()) {
|
||||
velocity.setX(AvatarState.getValue(vx));
|
||||
velocity.setZ(AvatarState.getValue(vz));
|
||||
|
|
|
@ -89,8 +89,21 @@ public class AirSpout extends AirAbility {
|
|||
}
|
||||
|
||||
private void allowFlight() {
|
||||
this.player.setAllowFlight(true);
|
||||
this.player.setFlying(true);
|
||||
if (!this.player.getAllowFlight()) {
|
||||
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) {
|
||||
|
@ -166,11 +179,6 @@ public class AirSpout extends AirAbility {
|
|||
flightHandler.removeInstance(this.player, this.getName());
|
||||
}
|
||||
|
||||
private void removeFlight() {
|
||||
this.player.setAllowFlight(false);
|
||||
this.player.setFlying(false);
|
||||
}
|
||||
|
||||
private void rotateAirColumn(final Block block) {
|
||||
if (!this.player.getWorld().equals(block.getWorld())) {
|
||||
return;
|
||||
|
|
|
@ -156,7 +156,7 @@ public class AirSuction extends AirAbility {
|
|||
open = trap.isOpen();
|
||||
}
|
||||
|
||||
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);
|
||||
this.affectedDoors.add(block);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public class AirSuction extends AirAbility {
|
|||
if (GeneralMethods.isRegionProtectedFromBuild(this.player, "AirSuction", this.location)) {
|
||||
this.remove();
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
@ -230,9 +230,6 @@ public class AirSuction extends AirAbility {
|
|||
GeneralMethods.setVelocity(entity, velocity);
|
||||
new HorizontalVelocityTracker(entity, this.player, 200l, this);
|
||||
entity.setFallDistance(0);
|
||||
if (entity instanceof Player) {
|
||||
flightHandler.createInstance((Player) entity, this.player, 5000L, this.getName());
|
||||
}
|
||||
|
||||
if (entity.getFireTicks() > 0) {
|
||||
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
|
||||
|
|
|
@ -196,7 +196,7 @@ public class AirSwipe extends AirAbility {
|
|||
|
||||
private void affectPeople(final Location location, final Vector direction) {
|
||||
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++) {
|
||||
final Entity entity = entities.get(i);
|
||||
|
@ -218,19 +218,14 @@ public class AirSwipe extends AirAbility {
|
|||
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) {
|
||||
DamageHandler.damageEntity(entity, AirSwipe.this.damage, abil);
|
||||
}
|
||||
AirSwipe.this.affectedEntities.add(entity);
|
||||
}
|
||||
if (entity instanceof Player) {
|
||||
flightHandler.createInstance((Player) entity, AirSwipe.this.player, 1000L, AirSwipe.this.getName());
|
||||
}
|
||||
breakBreathbendingHold(entity);
|
||||
if (AirSwipe.this.elements.containsKey(fDirection)) {
|
||||
AirSwipe.this.elements.remove(fDirection);
|
||||
}
|
||||
AirSwipe.this.elements.remove(direction);
|
||||
} else if (entity.getEntityId() != AirSwipe.this.player.getEntityId() && !(entity instanceof LivingEntity)) {
|
||||
|
||||
GeneralMethods.setVelocity(entity, fDirection.multiply(AirSwipe.this.pushFactor));
|
||||
|
|
|
@ -127,8 +127,13 @@ public class Tornado extends AirAbility {
|
|||
|
||||
mag = Math.sqrt(x * x + z * z);
|
||||
|
||||
vx = (x * Math.cos(angle) - z * Math.sin(angle)) / mag;
|
||||
vz = (x * Math.sin(angle) + z * Math.cos(angle)) / mag;
|
||||
if (mag == 0.0) {
|
||||
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) {
|
||||
vy = 0.05 * this.playerPushFactor;
|
||||
|
@ -158,7 +163,7 @@ public class Tornado extends AirAbility {
|
|||
}
|
||||
}
|
||||
|
||||
final Vector velocity = entity.getVelocity();
|
||||
final Vector velocity = entity.getVelocity().clone();
|
||||
velocity.setX(vx);
|
||||
velocity.setZ(vz);
|
||||
velocity.setY(vy);
|
||||
|
@ -167,10 +172,6 @@ public class Tornado extends AirAbility {
|
|||
entity.setFallDistance(0);
|
||||
|
||||
breakBreathbendingHold(entity);
|
||||
|
||||
if (entity instanceof Player) {
|
||||
flightHandler.createInstance((Player) entity, 50L, this.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,14 +37,12 @@ public class AirStream extends AirAbility implements ComboAbility {
|
|||
private Vector direction;
|
||||
private ArrayList<Entity> affectedEntities;
|
||||
private ArrayList<BukkitRunnable> tasks;
|
||||
private Set<Player> flights;
|
||||
|
||||
public AirStream(final Player player) {
|
||||
super(player);
|
||||
|
||||
this.affectedEntities = new ArrayList<>();
|
||||
this.tasks = new ArrayList<>();
|
||||
this.flights = new HashSet<>();
|
||||
|
||||
if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) {
|
||||
return;
|
||||
|
@ -103,6 +101,11 @@ public class AirStream extends AirAbility implements ComboAbility {
|
|||
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.currentLoc.add(this.direction.clone().multiply(this.speed));
|
||||
|
||||
|
@ -155,11 +158,6 @@ public class AirStream extends AirAbility implements ComboAbility {
|
|||
}
|
||||
if (!entity.equals(this.player) && !this.affectedEntities.contains(entity)) {
|
||||
this.affectedEntities.add(entity);
|
||||
if (entity instanceof Player) {
|
||||
final Player ep = (Player) entity;
|
||||
flightHandler.createInstance(ep, this.player, this.getName());
|
||||
this.flights.add(ep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,10 +177,6 @@ public class AirStream extends AirAbility implements ComboAbility {
|
|||
for (final BukkitRunnable task : this.tasks) {
|
||||
task.cancel();
|
||||
}
|
||||
for (final Player flyer : this.flights) {
|
||||
flightHandler.removeInstance(flyer, this.getName());
|
||||
}
|
||||
this.flights.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -303,10 +297,6 @@ public class AirStream extends AirAbility implements ComboAbility {
|
|||
this.tasks = tasks;
|
||||
}
|
||||
|
||||
public Set<Player> getFlights() {
|
||||
return this.flights;
|
||||
}
|
||||
|
||||
public void setCooldown(final long cooldown) {
|
||||
this.cooldown = cooldown;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.projectkorra.projectkorra.airbending.combo;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -139,7 +140,11 @@ public class AirSweep extends AirAbility implements ComboAbility {
|
|||
this.destination = this.player.getLocation().add(this.player.getEyeLocation().getDirection().normalize().multiply(10));
|
||||
final Vector origToDest = GeneralMethods.getDirection(this.origin, this.destination);
|
||||
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(this.player.getLocation(), endLoc)) {
|
||||
continue;
|
||||
}
|
||||
final Vector vec = GeneralMethods.getDirection(this.player.getLocation(), endLoc);
|
||||
|
||||
final FireComboStream fs = new FireComboStream(this.player, this, vec, this.player.getLocation(), this.range, this.speed);
|
||||
fs.setDensity(1);
|
||||
|
@ -186,7 +191,7 @@ public class AirSweep extends AirAbility implements ComboAbility {
|
|||
this.remove();
|
||||
return;
|
||||
}
|
||||
if (!entity.equals(this.player) && !this.affectedEntities.contains(entity)) {
|
||||
if (!entity.equals(this.player) && !this.affectedEntities.contains(entity) && !(entity instanceof Player && Commands.invincible.contains(((Player) entity).getName()))) {
|
||||
this.affectedEntities.add(entity);
|
||||
if (this.knockback != 0) {
|
||||
final Vector force = fstream.getDirection();
|
||||
|
|
|
@ -63,11 +63,6 @@ public class AvatarState extends AvatarAbility {
|
|||
@Override
|
||||
public void progress() {
|
||||
if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) {
|
||||
if (this.player != null) {
|
||||
if (this.bPlayer.isOnCooldown(this)) {
|
||||
this.bPlayer.removeCooldown(this);
|
||||
}
|
||||
}
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ public class Paralyze extends ChiAbility {
|
|||
return;
|
||||
}
|
||||
this.target = targetentity;
|
||||
if (!(this.target instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
this.cooldown = getConfig().getLong("Abilities.Chi.Paralyze.Cooldown");
|
||||
this.duration = getConfig().getLong("Abilities.Chi.Paralyze.Duration");
|
||||
this.start();
|
||||
|
|
|
@ -333,8 +333,7 @@ public class WhoCommand extends PKCommand {
|
|||
}
|
||||
|
||||
if (player.getPlayer() != null && player.getPlayer().hasPermission("bending.donor")) {
|
||||
// Requires Servers to define `server-name` in their server.properties file. Example: server-name=My Server.
|
||||
sender.sendMessage(Element.AVATAR.getColor() + ProjectKorra.plugin.getServer().getServerName() + " Donor");
|
||||
sender.sendMessage(Element.AVATAR.getColor() + "Server Donor");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -551,6 +551,7 @@ public class ConfigManager {
|
|||
config.addDefault("Properties.TogglePassivesWithAllBending", true);
|
||||
config.addDefault("Properties.SeaLevel", 62);
|
||||
config.addDefault("Properties.ChooseCooldown", 0L);
|
||||
config.addDefault("Properties.MaxPresets", 10);
|
||||
|
||||
config.addDefault("Properties.HorizontalCollisionPhysics.Enabled", true);
|
||||
config.addDefault("Properties.HorizontalCollisionPhysics.DamageOnBarrierBlock", false);
|
||||
|
@ -579,6 +580,8 @@ public class ConfigManager {
|
|||
config.addDefault("Properties.Air.Sound.Pitch", 2);
|
||||
|
||||
config.addDefault("Properties.Water.DynamicSourcing", true);
|
||||
config.addDefault("Properties.Water.FreezePlayerHead", true);
|
||||
config.addDefault("Properties.Water.FreezePlayerFeet", true);
|
||||
config.addDefault("Properties.Water.CanBendWithWeapons", true);
|
||||
config.addDefault("Properties.Water.IceBlocks", iceBlocks);
|
||||
config.addDefault("Properties.Water.PlantBlocks", plantBlocks);
|
||||
|
@ -761,6 +764,8 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Avatar.AvatarState.Water.WaterManipulation.Damage", 5);
|
||||
config.addDefault("Abilities.Avatar.AvatarState.Water.IceBlast.Damage", 4);
|
||||
config.addDefault("Abilities.Avatar.AvatarState.Water.IceBlast.Range", 30);
|
||||
config.addDefault("Abilities.Avatar.AvatarState.Water.IceBlast.Cooldown", 0);
|
||||
config.addDefault("Abilities.Avatar.AvatarState.Water.IceBullet.Cooldown", 0);
|
||||
config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Damage", 4);
|
||||
config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Range", 30);
|
||||
config.addDefault("Abilities.Avatar.AvatarState.Water.IceSpike.Push", 0.9);
|
||||
|
@ -954,6 +959,7 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Water.IceBlast.CollisionRadius", 1.5);
|
||||
config.addDefault("Abilities.Water.IceBlast.Interval", 20);
|
||||
config.addDefault("Abilities.Water.IceBlast.Cooldown", 1500);
|
||||
config.addDefault("Abilities.Water.IceBlast.AllowSnow", false);
|
||||
|
||||
config.addDefault("Abilities.Water.IceSpike.Enabled", true);
|
||||
config.addDefault("Abilities.Water.IceSpike.Cooldown", 2000);
|
||||
|
@ -1151,6 +1157,7 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Water.IceBullet.AnimationSpeed", 1);
|
||||
config.addDefault("Abilities.Water.IceBullet.ShootTime", 10000);
|
||||
config.addDefault("Abilities.Water.IceBullet.Cooldown", 10000);
|
||||
config.addDefault("Abilities.Water.IceBullet.ShotCooldown", 500);
|
||||
|
||||
config.addDefault("Abilities.Earth.Passive.Duration", 2500);
|
||||
config.addDefault("Abilities.Earth.Passive.DensityShift.Enabled", true);
|
||||
|
@ -1211,7 +1218,9 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Earth.EarthTunnel.Radius", 0.25);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.Revert", true);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.DropLootIfNotRevert", false);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.IgnoreOres", false);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.Interval", 30);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.BlocksPerInterval", 1);
|
||||
|
||||
config.addDefault("Abilities.Earth.Extraction.Enabled", true);
|
||||
config.addDefault("Abilities.Earth.Extraction.SelectRange", 5);
|
||||
|
|
|
@ -323,8 +323,7 @@ public class EarthGrab extends EarthAbility {
|
|||
@Override
|
||||
public void remove() {
|
||||
super.remove();
|
||||
if (this.mode == GrabMode.TRAP) {
|
||||
this.bPlayer.addCooldown(this);
|
||||
if (this.mode == GrabMode.TRAP && this.initiated) {
|
||||
this.mHandler.reset();
|
||||
this.trap.remove();
|
||||
if (TempArmor.getTempArmorList(this.target).contains(this.armor)) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.projectkorra.projectkorra.util.TempBlock;
|
|||
public class EarthTunnel extends EarthAbility {
|
||||
|
||||
private long interval;
|
||||
private int blocksPerInterval;
|
||||
private long time;
|
||||
@Attribute("Depth")
|
||||
private double depth;
|
||||
|
@ -37,6 +38,7 @@ public class EarthTunnel extends EarthAbility {
|
|||
private double radiusIncrement;
|
||||
private boolean revert;
|
||||
private boolean dropLootIfNotRevert;
|
||||
private boolean ignoreOres;
|
||||
private Block block;
|
||||
private Location origin;
|
||||
private Location location;
|
||||
|
@ -52,8 +54,10 @@ public class EarthTunnel extends EarthAbility {
|
|||
this.range = getConfig().getDouble("Abilities.Earth.EarthTunnel.Range");
|
||||
this.radius = getConfig().getDouble("Abilities.Earth.EarthTunnel.Radius");
|
||||
this.interval = getConfig().getLong("Abilities.Earth.EarthTunnel.Interval");
|
||||
this.blocksPerInterval = getConfig().getInt("Abilities.Earth.EarthTunnel.BlocksPerInterval");
|
||||
this.revert = getConfig().getBoolean("Abilities.Earth.EarthTunnel.Revert");
|
||||
this.dropLootIfNotRevert = getConfig().getBoolean("Abilities.Earth.EarthTunnel.DropLootIfNotRevert");
|
||||
this.ignoreOres = getConfig().getBoolean("Abilities.Earth.EarthTunnel.IgnoreOres");
|
||||
|
||||
this.time = System.currentTimeMillis();
|
||||
|
||||
|
@ -92,72 +96,89 @@ public class EarthTunnel extends EarthAbility {
|
|||
|
||||
if (System.currentTimeMillis() - this.time >= this.interval) {
|
||||
this.time = System.currentTimeMillis();
|
||||
if (Math.abs(Math.toDegrees(this.player.getEyeLocation().getDirection().angle(this.direction))) > 20 || !this.player.isSneaking()) {
|
||||
this.bPlayer.addCooldown(this);
|
||||
this.remove();
|
||||
return;
|
||||
} else {
|
||||
while ((!isEarth(this.block) && !isSand(this.block))) {
|
||||
if (!this.isTransparent(this.block)) {
|
||||
for (int i = 1; i <= blocksPerInterval; i++) {
|
||||
if (Math.abs(Math.toDegrees(this.player.getEyeLocation().getDirection().angle(this.direction))) > 20 || !this.player.isSneaking()) {
|
||||
this.bPlayer.addCooldown(this);
|
||||
this.remove();
|
||||
return;
|
||||
} else {
|
||||
while ((!isEarth(this.block) && !isSand(this.block)) || (ignoreOres && this.isOre(this.block))) {
|
||||
if (!this.isTransparent(this.block) && (ignoreOres && !this.isOre(this.block))) {
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.angle >= 360) {
|
||||
this.angle = 0;
|
||||
if (this.radius >= this.maxRadius) {
|
||||
this.radius = this.radiusIncrement;
|
||||
if (this.depth >= this.range) {
|
||||
this.bPlayer.addCooldown(this);
|
||||
this.remove();
|
||||
return;
|
||||
} else {
|
||||
this.depth += 0.5;
|
||||
}
|
||||
} else {
|
||||
this.radius += this.radiusIncrement;
|
||||
}
|
||||
} else {
|
||||
this.angle += 20;
|
||||
}
|
||||
|
||||
final Vector vec = GeneralMethods.getOrthogonalVector(this.direction, this.angle, this.radius);
|
||||
this.block = this.location.clone().add(this.direction.clone().normalize().multiply(this.depth)).add(vec).getBlock();
|
||||
}
|
||||
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(this, this.block.getLocation())) {
|
||||
this.bPlayer.addCooldown(this);
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.angle >= 360) {
|
||||
this.angle = 0;
|
||||
if (this.radius >= this.maxRadius) {
|
||||
this.radius = this.radiusIncrement;
|
||||
if (this.depth >= this.range) {
|
||||
this.bPlayer.addCooldown(this);
|
||||
this.remove();
|
||||
return;
|
||||
} else {
|
||||
this.depth += 0.5;
|
||||
}
|
||||
if (this.revert) {
|
||||
if (getMovedEarth().containsKey(this.block)) {
|
||||
this.block.setType(Material.AIR);
|
||||
} else {
|
||||
this.radius += this.radiusIncrement;
|
||||
}
|
||||
} else {
|
||||
this.angle += 20;
|
||||
}
|
||||
|
||||
final Vector vec = GeneralMethods.getOrthogonalVector(this.direction, this.angle, this.radius);
|
||||
this.block = this.location.clone().add(this.direction.clone().normalize().multiply(this.depth)).add(vec).getBlock();
|
||||
}
|
||||
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(this, this.block.getLocation())) {
|
||||
this.bPlayer.addCooldown(this);
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.revert) {
|
||||
if (getMovedEarth().containsKey(this.block)) {
|
||||
this.block.setType(Material.AIR);
|
||||
} else {
|
||||
airBlocks.put(new TempBlock(this.block, Material.AIR), System.currentTimeMillis());
|
||||
if (isPlant(this.block.getRelative(BlockFace.UP)) || isSnow(this.block.getRelative(BlockFace.UP))) {
|
||||
final Block above = this.block.getRelative(BlockFace.UP);
|
||||
final Block above2 = above.getRelative(BlockFace.UP);
|
||||
if (isPlant(above) || isSnow(above)) {
|
||||
airBlocks.put(new TempBlock(above, Material.AIR), System.currentTimeMillis());
|
||||
if (isPlant(above2) && above2.getType().equals(Material.TALL_GRASS)) {
|
||||
airBlocks.put(new TempBlock(above2, Material.AIR), System.currentTimeMillis());
|
||||
airBlocks.put(new TempBlock(this.block, Material.AIR), System.currentTimeMillis());
|
||||
if (isPlant(this.block.getRelative(BlockFace.UP)) || isSnow(this.block.getRelative(BlockFace.UP))) {
|
||||
final Block above = this.block.getRelative(BlockFace.UP);
|
||||
final Block above2 = above.getRelative(BlockFace.UP);
|
||||
if (isPlant(above) || isSnow(above)) {
|
||||
airBlocks.put(new TempBlock(above, Material.AIR), System.currentTimeMillis());
|
||||
if (isPlant(above2) && above2.getType().equals(Material.TALL_GRASS)) {
|
||||
airBlocks.put(new TempBlock(above2, Material.AIR), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.dropLootIfNotRevert) {
|
||||
this.block.breakNaturally();
|
||||
} else {
|
||||
this.block.setType(Material.AIR);
|
||||
if (this.dropLootIfNotRevert) {
|
||||
this.block.breakNaturally();
|
||||
} else {
|
||||
this.block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOre(Block block) {
|
||||
switch (block.getType()) {
|
||||
case IRON_ORE:
|
||||
case GOLD_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case REDSTONE_ORE:
|
||||
case COAL_ORE:
|
||||
case EMERALD_ORE:
|
||||
case LAPIS_ORE:
|
||||
case NETHER_QUARTZ_ORE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "EarthTunnel";
|
||||
|
|
|
@ -114,7 +114,7 @@ public class FireManipulation extends FireAbility {
|
|||
return;
|
||||
}
|
||||
ParticleEffect.FLAME.display(point, 12, 0.25, 0.25, 0.25);
|
||||
ParticleEffect.SMOKE.display(point, 6, 0.25, 0.25, 0.25);
|
||||
ParticleEffect.SMOKE_NORMAL.display(point, 6, 0.25, 0.25, 0.25);
|
||||
for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(point, 1.2D)) {
|
||||
if (entity instanceof LivingEntity && entity.getUniqueId() != this.player.getUniqueId()) {
|
||||
DamageHandler.damageEntity(entity, this.shieldDamage, this);
|
||||
|
@ -144,7 +144,7 @@ public class FireManipulation extends FireAbility {
|
|||
final Vector direction = this.focalPoint.toVector().subtract(point.toVector());
|
||||
point.add(direction.clone().multiply(this.streamSpeed / 5));
|
||||
ParticleEffect.FLAME.display(point, this.shieldParticles, 0.25, 0.25, 0.25);
|
||||
ParticleEffect.SMOKE.display(point, this.shieldParticles/2, 0.25, 0.25, 0.25);
|
||||
ParticleEffect.SMOKE_NORMAL.display(point, this.shieldParticles/2, 0.25, 0.25, 0.25);
|
||||
}
|
||||
} else {
|
||||
Vector direction = this.player.getLocation().getDirection().clone();
|
||||
|
@ -174,7 +174,7 @@ public class FireManipulation extends FireAbility {
|
|||
}
|
||||
|
||||
ParticleEffect.FLAME.display(this.shotPoint, this.streamParticles, 0.5, 0.5, 0.5, 0.01);
|
||||
ParticleEffect.SMOKE.display(this.shotPoint, this.streamParticles/2, 0.5, 0.5, 0.5, 0.01);
|
||||
ParticleEffect.SMOKE_NORMAL.display(this.shotPoint, this.streamParticles/2, 0.5, 0.5, 0.5, 0.01);
|
||||
for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.shotPoint, 2)) {
|
||||
if (entity instanceof LivingEntity && entity.getUniqueId() != this.player.getUniqueId()) {
|
||||
DamageHandler.damageEntity(entity, this.streamDamage, this);
|
||||
|
@ -214,7 +214,9 @@ public class FireManipulation extends FireAbility {
|
|||
@Override
|
||||
public List<Location> getLocations() {
|
||||
final List<Location> locations = new ArrayList<>();
|
||||
locations.addAll(this.points.keySet());
|
||||
if (points != null) {
|
||||
locations.addAll(this.points.keySet());
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
|
|
|
@ -309,8 +309,8 @@ public class HeatControl extends FireAbility {
|
|||
|
||||
if (TempBlock.isTempBlock(block)) {
|
||||
final TempBlock tb = TempBlock.get(block);
|
||||
if (PhaseChange.getFrozenBlocksAsTempBlock().contains(tb)) {
|
||||
PhaseChange.thaw(tb);
|
||||
if (PhaseChange.getFrozenBlocksMap().containsKey(tb)) {
|
||||
new PhaseChange(player, PhaseChange.PhaseChangeType.MELT).melt(tb.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,10 @@ public class HeatControl extends FireAbility {
|
|||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MELTED_BLOCKS.get(block).revertBlock();
|
||||
TempBlock melted = MELTED_BLOCKS.get(block);
|
||||
if (melted != null) {
|
||||
melted.revertBlock();
|
||||
}
|
||||
MELTED_BLOCKS.remove(block);
|
||||
}
|
||||
}.runTaskLater(ProjectKorra.plugin, 5 * 20 * 60);
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -117,7 +118,9 @@ public class Illumination extends FireAbility {
|
|||
return;
|
||||
} else if (this.block != null && standingBlock.equals(this.block.getBlock())) {
|
||||
return;
|
||||
} else if (standBlock.getType() == Material.ACACIA_LEAVES || standBlock.getType() == Material.BIRCH_LEAVES || standBlock.getType() == Material.DARK_OAK_LEAVES || standBlock.getType() == Material.JUNGLE_LEAVES || standBlock.getType() == Material.OAK_LEAVES || standBlock.getType() == Material.SPRUCE_LEAVES) {
|
||||
} else if (Tag.LEAVES.isTagged(standBlock.getType())) {
|
||||
return;
|
||||
} else if (standingBlock.getType().name().endsWith("_FENCE") || standingBlock.getType().name().endsWith("_FENCE_GATE") || standingBlock.getType().name().endsWith("_WALL") || standingBlock.getType() == Material.IRON_BARS || standingBlock.getType().name().endsWith("_PANE")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ import com.projectkorra.projectkorra.command.Commands;
|
|||
import com.projectkorra.projectkorra.firebending.util.FireDamageTimer;
|
||||
import com.projectkorra.projectkorra.util.DamageHandler;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
|
@ -224,4 +226,10 @@ public class FireComboStream extends BukkitRunnable {
|
|||
public void setUseNewParticles(final boolean b) {
|
||||
this.useNewParticles = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,6 +100,14 @@ public class JetBlast extends FireAbility implements ComboAbility {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
for(FireComboStream task : tasks) {
|
||||
task.remove();
|
||||
}
|
||||
super.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneakAbility() {
|
||||
return false;
|
||||
|
|
|
@ -115,6 +115,14 @@ public class JetBlaze extends FireAbility implements ComboAbility {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
for(FireComboStream task : tasks) {
|
||||
task.remove();
|
||||
}
|
||||
super.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneakAbility() {
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package com.projectkorra.projectkorra.hooks;
|
||||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
public class PlaceholderAPIHook extends PlaceholderExpansion {
|
||||
|
||||
private ProjectKorra plugin;
|
||||
|
||||
public PlaceholderAPIHook(ProjectKorra plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, String params) {
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
if (bPlayer == null) { return ""; }
|
||||
|
||||
if (params.startsWith("slot")) {
|
||||
final String ability = bPlayer.getAbilities().get(Integer.parseInt(params.substring(params.length() - 1)));
|
||||
final CoreAbility coreAbil = CoreAbility.getAbility(ability);
|
||||
if (coreAbil == null) {
|
||||
return "";
|
||||
}
|
||||
return coreAbil.getElement().getColor() + coreAbil.getName();
|
||||
} else if (params.equals("element") || params.equals("elementcolor")) {
|
||||
String e = "Nonbender";
|
||||
ChatColor c = ChatColor.WHITE;
|
||||
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);
|
||||
if (params.equals("element")) {
|
||||
return c + element + ChatColor.RESET;
|
||||
} else if(params.equals("elementcolor")) {
|
||||
return c + "";
|
||||
}
|
||||
} else if (params.equals("elements")) {
|
||||
return bPlayer.getElements().stream().map(item -> item.getColor() + item.getName()).collect(joining(" "));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRegister(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor(){
|
||||
return plugin.getDescription().getAuthors().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier(){
|
||||
return "ProjectKorra";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion(){
|
||||
return plugin.getDescription().getVersion();
|
||||
}
|
||||
}
|
18
src/com/projectkorra/projectkorra/hooks/WorldGuardFlag.java
Normal file
18
src/com/projectkorra/projectkorra/hooks/WorldGuardFlag.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package com.projectkorra.projectkorra.hooks;
|
||||
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
|
||||
public class WorldGuardFlag {
|
||||
public static void registerBendingWorldGuardFlag() {
|
||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||
try {
|
||||
registry.register(new StateFlag("bending", false));
|
||||
} catch (FlagConflictException e) {
|
||||
ProjectKorra.log.severe("unable to register bending WorldGuard Flag");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,11 +4,14 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
@ -44,6 +47,10 @@ public class HorizontalVelocityTracker {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(e instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
remove(e);
|
||||
this.entity = e;
|
||||
this.instigator = instigator;
|
||||
|
@ -52,7 +59,6 @@ public class HorizontalVelocityTracker {
|
|||
this.thisVelocity = e.getVelocity().clone();
|
||||
this.launchLocation = e.getLocation().clone();
|
||||
this.impactLocation = this.launchLocation.clone();
|
||||
this.delay = delay;
|
||||
this.abil = ability;
|
||||
this.update();
|
||||
instances.put(this.entity, this);
|
||||
|
@ -68,6 +74,12 @@ public class HorizontalVelocityTracker {
|
|||
return;
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > (this.fireTime + 30000)) {
|
||||
ProjectKorra.log.info("removed HorizontalVelocityTracker lasting over 30 seconds: " + this.instigator.getName() + " using " + this.abil.getName() + " on " + this.entity);
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
this.lastVelocity = this.thisVelocity.clone();
|
||||
this.thisVelocity = this.entity.getVelocity().clone();
|
||||
|
||||
|
@ -86,7 +98,7 @@ public class HorizontalVelocityTracker {
|
|||
if ((diff.getX() > 1 || diff.getX() < -1) || (diff.getZ() > 1 || diff.getZ() < -1)) {
|
||||
this.impactLocation = this.entity.getLocation();
|
||||
for (final Block b : blocks) {
|
||||
if (b.getType() == Material.BARRIER && this.barrier == false) {
|
||||
if (b.getType() == Material.BARRIER && !this.barrier) {
|
||||
return;
|
||||
}
|
||||
if (GeneralMethods.isSolid(b) && (this.entity.getLocation().getBlock().getRelative(BlockFace.EAST, 1).equals(b) || this.entity.getLocation().getBlock().getRelative(BlockFace.NORTH, 1).equals(b) || this.entity.getLocation().getBlock().getRelative(BlockFace.WEST, 1).equals(b) || this.entity.getLocation().getBlock().getRelative(BlockFace.SOUTH, 1).equals(b))) {
|
||||
|
@ -117,9 +129,7 @@ public class HorizontalVelocityTracker {
|
|||
}
|
||||
|
||||
public static void remove(final Entity e) {
|
||||
if (instances.containsKey(e)) {
|
||||
instances.remove(e);
|
||||
}
|
||||
instances.remove(e);
|
||||
}
|
||||
|
||||
public static boolean hasBeenDamagedByHorizontalVelocity(final Entity e) {
|
||||
|
@ -128,4 +138,10 @@ public class HorizontalVelocityTracker {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class DamageHandler {
|
|||
* @param damage The amount of damage to deal
|
||||
*/
|
||||
public static void damageEntity(final Entity entity, Player source, double damage, final Ability ability, boolean ignoreArmor) {
|
||||
if (TempArmor.hasTempArmor((LivingEntity) entity)) {
|
||||
if (entity instanceof LivingEntity && TempArmor.hasTempArmor((LivingEntity) entity)) {
|
||||
ignoreArmor = true;
|
||||
}
|
||||
if (ability == null) {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package com.projectkorra.projectkorra.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
@ -34,19 +35,23 @@ public class RevertChecker implements Runnable {
|
|||
|
||||
public static void revertAirBlocks() {
|
||||
for (final int ID : airRevertQueue.keySet()) {
|
||||
EarthAbility.revertAirBlock(ID);
|
||||
PaperLib.getChunkAtAsync(EarthAbility.getTempAirLocations().get(ID).getState().getBlock().getLocation()).thenAccept(result ->
|
||||
EarthAbility.revertAirBlock(ID)
|
||||
);
|
||||
RevertChecker.airRevertQueue.remove(ID);
|
||||
}
|
||||
}
|
||||
|
||||
public static void revertEarthBlocks() {
|
||||
for (final Block block : earthRevertQueue.keySet()) {
|
||||
EarthAbility.revertBlock(block);
|
||||
PaperLib.getChunkAtAsync(block.getLocation()).thenAccept(result ->
|
||||
EarthAbility.revertBlock(block)
|
||||
);
|
||||
earthRevertQueue.remove(block);
|
||||
}
|
||||
}
|
||||
|
||||
private Future<ArrayList<Chunk>> returnFuture;
|
||||
private Future<Set<Map<String,Integer>>> returnFuture;
|
||||
|
||||
private void addToAirRevertQueue(final int i) {
|
||||
if (!airRevertQueue.containsKey(i)) {
|
||||
|
@ -72,39 +77,41 @@ public class RevertChecker implements Runnable {
|
|||
|
||||
try {
|
||||
this.returnFuture = this.plugin.getServer().getScheduler().callSyncMethod(this.plugin, new getOccupiedChunks(this.plugin.getServer()));
|
||||
final ArrayList<Chunk> chunks = this.returnFuture.get();
|
||||
final Set<Map<String,Integer>> chunks = this.returnFuture.get();
|
||||
|
||||
final Map<Block, Information> earth = new HashMap<Block, Information>();
|
||||
earth.putAll(EarthAbility.getMovedEarth());
|
||||
final Map<Block, Information> earth = new HashMap<>(EarthAbility.getMovedEarth());
|
||||
|
||||
for (final Block block : earth.keySet()) {
|
||||
if (earthRevertQueue.containsKey(block)) {
|
||||
continue;
|
||||
}
|
||||
boolean remove = true;
|
||||
|
||||
final Information info = earth.get(block);
|
||||
if (this.time < info.getTime() + config.getLong("Properties.Earth.RevertCheckTime") || (chunks.contains(block.getChunk()) && safeRevert)) {
|
||||
remove = false;
|
||||
}
|
||||
if (remove) {
|
||||
|
||||
Map<String, Integer> chunkcoord = new HashMap<>();
|
||||
chunkcoord.put("x", block.getX() >> 4);
|
||||
chunkcoord.put("z", block.getZ() >> 4);
|
||||
|
||||
if (this.time > (info.getTime() + config.getLong("Properties.Earth.RevertCheckTime")) && !(chunks.contains(chunkcoord) && safeRevert)) {
|
||||
this.addToRevertQueue(block);
|
||||
}
|
||||
}
|
||||
|
||||
final Map<Integer, Information> air = new HashMap<Integer, Information>();
|
||||
air.putAll(EarthAbility.getTempAirLocations());
|
||||
final Map<Integer, Information> air = new HashMap<>(EarthAbility.getTempAirLocations());
|
||||
|
||||
for (final Integer i : air.keySet()) {
|
||||
if (airRevertQueue.containsKey(i)) {
|
||||
continue;
|
||||
}
|
||||
boolean remove = true;
|
||||
|
||||
final Information info = air.get(i);
|
||||
final Block block = info.getBlock();
|
||||
if (this.time < info.getTime() + config.getLong("Properties.Earth.RevertCheckTime") || (chunks.contains(block.getChunk()) && safeRevert)) {
|
||||
remove = false;
|
||||
}
|
||||
if (remove) {
|
||||
|
||||
Map<String, Integer> chunkcoord = new HashMap<>();
|
||||
chunkcoord.put("x", block.getX() >> 4);
|
||||
chunkcoord.put("z", block.getZ() >> 4);
|
||||
|
||||
if (this.time > (info.getTime() + config.getLong("Properties.Earth.RevertCheckTime")) && !(chunks.contains(chunkcoord) && safeRevert)) {
|
||||
this.addToAirRevertQueue(i);
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +122,7 @@ public class RevertChecker implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
private class getOccupiedChunks implements Callable<ArrayList<Chunk>> {
|
||||
private class getOccupiedChunks implements Callable<Set<Map<String,Integer>>> {
|
||||
private final Server server;
|
||||
|
||||
public getOccupiedChunks(final Server server) {
|
||||
|
@ -123,16 +130,17 @@ public class RevertChecker implements Runnable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Chunk> call() throws Exception {
|
||||
|
||||
final ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||
public Set<Map<String,Integer>> call() {
|
||||
final Set<Map<String,Integer>> chunks = new HashSet<>();
|
||||
|
||||
for (final Player player : this.server.getOnlinePlayers()) {
|
||||
final Chunk chunk = player.getLocation().getChunk();
|
||||
if (!chunks.contains(chunk)) {
|
||||
chunks.add(chunk);
|
||||
}
|
||||
Map<String, Integer> chunkcoord = new HashMap<>();
|
||||
chunkcoord.put("x", player.getLocation().getBlockX() >> 4);
|
||||
chunkcoord.put("z", player.getLocation().getBlockZ() >> 4);
|
||||
|
||||
chunks.add(chunkcoord);
|
||||
}
|
||||
|
||||
return chunks;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.projectkorra.projectkorra.util;
|
||||
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -111,7 +113,7 @@ public class TempArmor {
|
|||
for (final ItemStack drop : drops) {
|
||||
boolean match = false;
|
||||
for (final ItemStack armorPiece : this.newArmor) {
|
||||
if (armorPiece.isSimilar(drop)) {
|
||||
if (armorPiece != null && armorPiece.isSimilar(drop)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
|
@ -283,4 +285,10 @@ public class TempArmor {
|
|||
}
|
||||
return new ArrayList<>(INSTANCES.get(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,18 +2,18 @@ package com.projectkorra.projectkorra.util;
|
|||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Levelled;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class TempBlock {
|
||||
|
@ -34,28 +34,32 @@ public class TempBlock {
|
|||
private RevertTask revertTask = null;
|
||||
|
||||
public TempBlock(final Block block, final Material newtype) {
|
||||
this(block, newtype, newtype.createBlockData());
|
||||
this(block, newtype.createBlockData());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public TempBlock(final Block block, final Material newtype, final BlockData newdata) {
|
||||
this(block, newdata);
|
||||
}
|
||||
|
||||
public TempBlock(final Block block, final BlockData newdata) {
|
||||
this.block = block;
|
||||
this.newdata = newdata;
|
||||
if (instances.containsKey(block)) {
|
||||
final TempBlock temp = instances.get(block);
|
||||
if (newtype != temp.block.getType()) {
|
||||
temp.block.setType(newtype);
|
||||
}
|
||||
if (newdata != temp.block.getBlockData()) {
|
||||
temp.block.setBlockData(newdata);
|
||||
if (!newdata.equals(temp.block.getBlockData())) {
|
||||
temp.block.setBlockData(newdata, GeneralMethods.isLightEmitting(newdata.getMaterial()));
|
||||
temp.newdata = newdata;
|
||||
}
|
||||
this.state = temp.state;
|
||||
instances.put(block, temp);
|
||||
} else {
|
||||
this.state = block.getState();
|
||||
if(this.state instanceof Container) {
|
||||
return;
|
||||
}
|
||||
instances.put(block, this);
|
||||
block.setType(newtype);
|
||||
block.setBlockData(newdata);
|
||||
block.setBlockData(newdata, GeneralMethods.isLightEmitting(newdata.getMaterial()));
|
||||
}
|
||||
if (this.state.getType() == Material.FIRE) {
|
||||
this.state.setType(Material.AIR);
|
||||
|
@ -70,7 +74,7 @@ public class TempBlock {
|
|||
}
|
||||
|
||||
public static boolean isTempBlock(final Block block) {
|
||||
return block != null ? instances.containsKey(block) : false;
|
||||
return block != null && instances.containsKey(block);
|
||||
}
|
||||
|
||||
public static boolean isTouchingTempBlock(final Block block) {
|
||||
|
@ -87,18 +91,17 @@ public class TempBlock {
|
|||
for (final Block block : instances.keySet()) {
|
||||
revertBlock(block, Material.AIR);
|
||||
}
|
||||
if (REVERT_QUEUE != null) {
|
||||
for (final TempBlock tempblock : REVERT_QUEUE) {
|
||||
tempblock.state.update(true);
|
||||
if (tempblock.revertTask != null) {
|
||||
tempblock.revertTask.run();
|
||||
}
|
||||
for (final TempBlock tempblock : REVERT_QUEUE) {
|
||||
tempblock.state.update(true, GeneralMethods.isLightEmitting(tempblock.state.getType()));
|
||||
if (tempblock.revertTask != null) {
|
||||
tempblock.revertTask.run();
|
||||
}
|
||||
REVERT_QUEUE.clear();
|
||||
}
|
||||
REVERT_QUEUE.clear();
|
||||
}
|
||||
|
||||
public static void removeBlock(final Block block) {
|
||||
REVERT_QUEUE.remove(instances.get(block));
|
||||
instances.remove(block);
|
||||
}
|
||||
|
||||
|
@ -107,27 +110,23 @@ public class TempBlock {
|
|||
instances.get(block).revertBlock();
|
||||
} else {
|
||||
if ((defaulttype == Material.LAVA) && GeneralMethods.isAdjacentToThreeOrMoreSources(block, true)) {
|
||||
block.setType(Material.LAVA);
|
||||
|
||||
BlockData data = Material.LAVA.createBlockData();
|
||||
|
||||
if (data instanceof Levelled) {
|
||||
((Levelled) data).setLevel(0);
|
||||
}
|
||||
|
||||
block.setBlockData(data);
|
||||
block.setBlockData(data, GeneralMethods.isLightEmitting(data.getMaterial()));
|
||||
} else if ((defaulttype == Material.WATER) && GeneralMethods.isAdjacentToThreeOrMoreSources(block)) {
|
||||
block.setType(Material.WATER);
|
||||
|
||||
BlockData data = Material.WATER.createBlockData();
|
||||
|
||||
if (data instanceof Levelled) {
|
||||
((Levelled) data).setLevel(0);
|
||||
}
|
||||
|
||||
block.setBlockData(data);
|
||||
block.setBlockData(data, GeneralMethods.isLightEmitting(data.getMaterial()));
|
||||
} else {
|
||||
block.setType(defaulttype);
|
||||
block.setType(defaulttype, GeneralMethods.isLightEmitting(defaulttype));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,11 +169,11 @@ public class TempBlock {
|
|||
}
|
||||
|
||||
public void revertBlock() {
|
||||
this.state.update(true);
|
||||
PaperLib.getChunkAtAsync(block.getLocation()).thenAccept(result ->
|
||||
this.state.update(true, GeneralMethods.isLightEmitting(this.state.getType()))
|
||||
);
|
||||
instances.remove(this.block);
|
||||
if (REVERT_QUEUE.contains(this)) {
|
||||
REVERT_QUEUE.remove(this);
|
||||
}
|
||||
REVERT_QUEUE.remove(this);
|
||||
if (this.revertTask != null) {
|
||||
this.revertTask.run();
|
||||
}
|
||||
|
@ -185,13 +184,17 @@ public class TempBlock {
|
|||
}
|
||||
|
||||
public void setType(final Material material) {
|
||||
this.setType(material, material.createBlockData());
|
||||
this.setType(material.createBlockData());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setType(final Material material, final BlockData data) {
|
||||
this.setType(data);
|
||||
}
|
||||
|
||||
public void setType(final BlockData data) {
|
||||
this.newdata = data;
|
||||
this.block.setType(material);
|
||||
this.block.setBlockData(data);
|
||||
this.block.setBlockData(data, GeneralMethods.isLightEmitting(data.getMaterial()));
|
||||
}
|
||||
|
||||
public static void startReversion() {
|
||||
|
|
|
@ -187,7 +187,7 @@ public class SurgeWall extends WaterAbility {
|
|||
|
||||
if (isPlant(this.sourceBlock) || isSnow(this.sourceBlock)) {
|
||||
new PlantRegrowth(this.player, this.sourceBlock);
|
||||
this.sourceBlock.setType(Material.AIR);
|
||||
this.sourceBlock.setType(Material.AIR, false);
|
||||
}
|
||||
this.addWater(this.sourceBlock);
|
||||
}
|
||||
|
|
|
@ -147,14 +147,28 @@ public class SurgeWave extends WaterAbility {
|
|||
if (freezeradius > this.maxFreezeRadius) {
|
||||
freezeradius = this.maxFreezeRadius;
|
||||
}
|
||||
|
||||
for (final Block block : GeneralMethods.getBlocksAroundPoint(this.frozenLocation, freezeradius)) {
|
||||
final List<Entity> trapped = GeneralMethods.getEntitiesAroundPoint(this.frozenLocation, freezeradius);
|
||||
ICE_SETTING: for (final Block block : GeneralMethods.getBlocksAroundPoint(this.frozenLocation, freezeradius)) {
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
|
||||
continue;
|
||||
} else if (TempBlock.isTempBlock(block)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Entity entity : trapped) {
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) {
|
||||
return;
|
||||
}
|
||||
if (!getConfig().getBoolean("Properties.Water.FreezePlayerHead") && GeneralMethods.playerHeadIsInBlock((Player) entity, block)) {
|
||||
continue ICE_SETTING;
|
||||
}
|
||||
if (!getConfig().getBoolean("Properties.Water.FreezePlayerFeet") && GeneralMethods.playerFeetIsInBlock((Player) entity, block)) {
|
||||
continue ICE_SETTING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Block oldBlock = block;
|
||||
if (!ElementalAbility.isAir(block.getType()) && block.getType() != Material.SNOW && !isWater(block) && !isPlant(block)) {
|
||||
continue;
|
||||
|
@ -232,7 +246,7 @@ public class SurgeWave extends WaterAbility {
|
|||
|
||||
if (isPlant(this.sourceBlock) || isSnow(this.sourceBlock)) {
|
||||
new PlantRegrowth(this.player, this.sourceBlock);
|
||||
this.sourceBlock.setType(Material.AIR);
|
||||
this.sourceBlock.setType(Material.AIR, false);
|
||||
}
|
||||
|
||||
if (TempBlock.isTempBlock(this.sourceBlock)) {
|
||||
|
@ -412,7 +426,7 @@ public class SurgeWave extends WaterAbility {
|
|||
public static void removeAllCleanup() {
|
||||
for (final SurgeWave surgeWave : getAbilities(SurgeWave.class)) {
|
||||
for (final Block block : surgeWave.waveBlocks.keySet()) {
|
||||
block.setType(Material.AIR);
|
||||
block.setType(Material.AIR, false);
|
||||
surgeWave.waveBlocks.remove(block);
|
||||
}
|
||||
for (final Block block : surgeWave.frozenBlocks.keySet()) {
|
||||
|
|
|
@ -130,8 +130,22 @@ public class Torrent extends WaterAbility {
|
|||
return;
|
||||
}
|
||||
final List<Block> ice = GeneralMethods.getBlocksAroundPoint(this.location, this.layer);
|
||||
for (final Block block : ice) {
|
||||
final List<Entity> trapped = GeneralMethods.getEntitiesAroundPoint(this.location, this.layer);
|
||||
ICE_SETTING: for (final Block block : ice) {
|
||||
if (isTransparent(this.player, block) && block.getType() != Material.ICE) {
|
||||
for (Entity entity : trapped) {
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) {
|
||||
return;
|
||||
}
|
||||
if (!getConfig().getBoolean("Properties.Water.FreezePlayerHead") && GeneralMethods.playerHeadIsInBlock((Player) entity, block)) {
|
||||
continue ICE_SETTING;
|
||||
}
|
||||
if (!getConfig().getBoolean("Properties.Water.FreezePlayerFeet") && GeneralMethods.playerFeetIsInBlock((Player) entity, block)) {
|
||||
continue ICE_SETTING;
|
||||
}
|
||||
}
|
||||
}
|
||||
final TempBlock tblock = new TempBlock(block, Material.ICE);
|
||||
FROZEN_BLOCKS.put(tblock, Pair.of(this.player, this.getId()));
|
||||
if (this.revert) {
|
||||
|
|
|
@ -164,10 +164,14 @@ public class WaterSpout extends WaterAbility {
|
|||
|
||||
this.displayWaterSpiral(location.clone().add(.5, 0, .5));
|
||||
if (this.player.getLocation().getBlockY() > block.getY()) {
|
||||
this.player.setFlying(false);
|
||||
if (this.player.isFlying()) {
|
||||
this.player.setFlying(false);
|
||||
}
|
||||
} else {
|
||||
this.player.setAllowFlight(true);
|
||||
this.player.setFlying(true);
|
||||
if (!this.player.isFlying()) {
|
||||
this.player.setAllowFlight(true);
|
||||
this.player.setFlying(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.bPlayer.addCooldown(this);
|
||||
|
@ -356,6 +360,9 @@ public class WaterSpout extends WaterAbility {
|
|||
|
||||
@Override
|
||||
public List<Location> getLocations() {
|
||||
if (this.getBase() == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
final ArrayList<Location> locations = new ArrayList<>();
|
||||
final Location top = this.getLocation();
|
||||
final Location iterLoc = this.getBase().getLocation();
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.projectkorra.projectkorra.ability.CoreAbility;
|
|||
import com.projectkorra.projectkorra.ability.ElementalAbility;
|
||||
import com.projectkorra.projectkorra.ability.WaterAbility;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import com.projectkorra.projectkorra.util.DamageHandler;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
import com.projectkorra.projectkorra.waterbending.combo.IceWave;
|
||||
|
@ -419,7 +420,17 @@ public class WaterSpoutWave extends WaterAbility {
|
|||
if(GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entity instanceof Player){
|
||||
if(Commands.invincible.contains(((Player) entity).getName())) {
|
||||
return;
|
||||
}
|
||||
if(!getConfig().getBoolean("Properties.Water.FreezePlayerHead") && GeneralMethods.playerHeadIsInBlock((Player) entity, block)){
|
||||
continue;
|
||||
}
|
||||
if(!getConfig().getBoolean("Properties.Water.FreezePlayerFeet") && GeneralMethods.playerFeetIsInBlock((Player) entity, block)){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ElementalAbility.isAir(block.getType()) || block.getType() == Material.ICE || this.isWaterbendable(block)) {
|
||||
if (!FROZEN_BLOCKS.containsKey(block)) {
|
||||
final TempBlock tblock = new TempBlock(block, Material.ICE);
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
package com.projectkorra.projectkorra.waterbending.blood;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
@ -97,19 +93,15 @@ public class Bloodbending extends BloodAbility {
|
|||
for (int i = 0; i < this.range; i++) {
|
||||
final Location location = GeneralMethods.getTargetedLocation(player, i, getTransparentMaterials());
|
||||
entities = GeneralMethods.getEntitiesAroundPoint(location, 1.7);
|
||||
if (entities.contains(player)) {
|
||||
entities.remove(player);
|
||||
}
|
||||
for (final Iterator<Entity> iterator = entities.iterator(); iterator.hasNext();) {
|
||||
if (!(iterator.next() instanceof LivingEntity)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
if (entities != null && !entities.isEmpty() && !entities.contains(player)) {
|
||||
|
||||
entities.remove(player);
|
||||
entities.removeIf(e -> !(e instanceof LivingEntity) || e instanceof ArmorStand);
|
||||
|
||||
if (!entities.isEmpty() && !entities.contains(player)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (entities == null || entities.isEmpty()) {
|
||||
if (entities.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
this.target = entities.get(0);
|
||||
|
@ -127,7 +119,7 @@ public class Bloodbending extends BloodAbility {
|
|||
return;
|
||||
}
|
||||
}
|
||||
} else if (!this.canBeUsedOnUndeadMobs && isUndead(this.target)) {
|
||||
} else if (!this.canBeUsedOnUndeadMobs && GeneralMethods.isUndead(this.target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -179,7 +171,7 @@ public class Bloodbending extends BloodAbility {
|
|||
|
||||
if (!this.canBeUsedOnUndeadMobs) {
|
||||
for (final Entity entity : TARGETED_ENTITIES.keySet()) {
|
||||
if (isUndead(entity)) {
|
||||
if (GeneralMethods.isUndead(entity)) {
|
||||
TARGETED_ENTITIES.remove(entity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public class IceBullet extends IceAbility implements ComboAbility {
|
|||
private double animationSpeed;
|
||||
@Attribute(Attribute.COOLDOWN)
|
||||
private long cooldown;
|
||||
private long shotcooldown;
|
||||
private long time;
|
||||
private String name;
|
||||
private AbilityState state;
|
||||
|
@ -74,6 +75,7 @@ public class IceBullet extends IceAbility implements ComboAbility {
|
|||
this.range = getConfig().getDouble("Abilities.Water.IceBullet.Range");
|
||||
this.radius = getConfig().getDouble("Abilities.Water.IceBullet.Radius");
|
||||
this.cooldown = getConfig().getLong("Abilities.Water.IceBullet.Cooldown");
|
||||
this.shotcooldown = getConfig().getLong("Abilities.Water.IceBullet.ShotCooldown");
|
||||
this.shootTime = getConfig().getLong("Abilities.Water.IceBullet.ShootTime");
|
||||
this.maxShots = getConfig().getInt("Abilities.Water.IceBullet.MaxShots");
|
||||
this.animationSpeed = getConfig().getDouble("Abilities.Water.IceBullet.AnimationSpeed");
|
||||
|
@ -92,7 +94,7 @@ public class IceBullet extends IceAbility implements ComboAbility {
|
|||
this.radius *= aug;
|
||||
|
||||
if (this.bPlayer.isAvatarState()) {
|
||||
this.cooldown = 0;
|
||||
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Water.IceBullet.Cooldown");
|
||||
this.damage = AvatarState.getValue(this.damage);
|
||||
this.range = AvatarState.getValue(this.range);
|
||||
this.shootTime = AvatarState.getValue(this.shootTime);
|
||||
|
@ -147,34 +149,6 @@ public class IceBullet extends IceAbility implements ComboAbility {
|
|||
return locations;
|
||||
}
|
||||
|
||||
public static class IceBulletLeftClick extends IceBullet {
|
||||
|
||||
public IceBulletLeftClick(final Player player) {
|
||||
super(player);
|
||||
this.setName("IceBulletLeftClick");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "IceBullet";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class IceBulletRightClick extends IceBullet {
|
||||
|
||||
public IceBulletRightClick(final Player player) {
|
||||
super(player);
|
||||
this.setName("IceBulletRightClick");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "IceBullet";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void manageShots() {
|
||||
for (int i = 0; i < this.tasks.size(); i++) {
|
||||
if (((FireComboStream) this.tasks.get(i)).isCancelled()) {
|
||||
|
@ -250,30 +224,13 @@ public class IceBullet extends IceAbility implements ComboAbility {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.name.equalsIgnoreCase("IceBulletLeftClick") || this.name.equalsIgnoreCase("IceBulletRightClick")) {
|
||||
final Collection<IceBullet> bullets = CoreAbility.getAbilities(this.player, IceBullet.class);
|
||||
if (bullets.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (final IceBullet bullet : bullets) {
|
||||
if (this.name.equalsIgnoreCase("IceBulletLeftClick")) {
|
||||
if (bullet.leftClicks <= bullet.rightClicks) {
|
||||
bullet.leftClicks += 1;
|
||||
}
|
||||
} else if (bullet.leftClicks >= bullet.rightClicks) {
|
||||
bullet.rightClicks += 1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.origin == null) {
|
||||
if (this.bPlayer.isOnCooldown("IceBullet") && !this.bPlayer.isAvatarState()) {
|
||||
if (this.bPlayer.isOnCooldown("IceBullet")) {
|
||||
this.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
final Block waterBlock = BlockSource.getWaterSourceBlock(this.player, this.range, ClickType.LEFT_CLICK, true, true, this.bPlayer.canPlantbend());
|
||||
final Block waterBlock = BlockSource.getWaterSourceBlock(this.player, this.range, ClickType.SHIFT_DOWN, true, true, this.bPlayer.canPlantbend());
|
||||
if (waterBlock == null) {
|
||||
this.remove();
|
||||
return;
|
||||
|
@ -283,7 +240,6 @@ public class IceBullet extends IceAbility implements ComboAbility {
|
|||
this.origin = waterBlock.getLocation();
|
||||
this.location = this.origin.clone();
|
||||
this.state = AbilityState.ICE_BULLET_FORMING;
|
||||
this.bPlayer.addCooldown("IceBullet", this.cooldown);
|
||||
this.direction = new Vector(1, 0, 1);
|
||||
this.waterGrabber = new WaterSourceGrabber(this.player, this.origin.clone());
|
||||
} else if (this.waterGrabber.getState() == WaterSourceGrabber.AnimationState.FAILED) {
|
||||
|
@ -312,7 +268,15 @@ public class IceBullet extends IceAbility implements ComboAbility {
|
|||
}
|
||||
|
||||
if (timeDiff < this.shootTime) {
|
||||
if (this.shots < this.rightClicks + this.leftClicks) {
|
||||
if (this.rightClicks > 0 || this.leftClicks > 0) {
|
||||
if (this.leftClicks > 0) {
|
||||
this.leftClicks = 0;
|
||||
this.bPlayer.addCooldown("IceBullet Left", this.shotcooldown);
|
||||
} else if (this.rightClicks > 0){
|
||||
this.rightClicks = 0;
|
||||
this.bPlayer.addCooldown("IceBullet Right", this.shotcooldown);
|
||||
}
|
||||
|
||||
this.shots++;
|
||||
final Vector vec = this.player.getEyeLocation().getDirection().normalize();
|
||||
final Location loc = this.player.getEyeLocation().add(vec.clone().multiply(this.radius + 1.3));
|
||||
|
@ -337,6 +301,19 @@ public class IceBullet extends IceAbility implements ComboAbility {
|
|||
}
|
||||
}
|
||||
|
||||
public void doLeftClick() {
|
||||
if (this.bPlayer.isOnCooldown("IceBullet Left")) {
|
||||
return;
|
||||
}
|
||||
this.leftClicks++;
|
||||
}
|
||||
public void doRightClick() {
|
||||
if (this.bPlayer.isOnCooldown("IceBullet Right")) {
|
||||
return;
|
||||
}
|
||||
this.rightClicks++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneakAbility() {
|
||||
return true;
|
||||
|
|
|
@ -49,6 +49,7 @@ public class IceBlast extends IceAbility {
|
|||
private Location location;
|
||||
private Location firstDestination;
|
||||
private Location destination;
|
||||
private boolean allowSnow;
|
||||
public TempBlock source;
|
||||
|
||||
public IceBlast(final Player player) {
|
||||
|
@ -61,6 +62,7 @@ public class IceBlast extends IceAbility {
|
|||
this.range = getConfig().getDouble("Abilities.Water.IceBlast.Range");
|
||||
this.damage = getConfig().getInt("Abilities.Water.IceBlast.Damage");
|
||||
this.cooldown = getConfig().getInt("Abilities.Water.IceBlast.Cooldown");
|
||||
this.allowSnow = getConfig().getBoolean("Abilities.Water.IceBlast.AllowSnow");
|
||||
|
||||
this.damage = getNightFactor(this.damage, player.getWorld());
|
||||
|
||||
|
@ -69,14 +71,14 @@ public class IceBlast extends IceAbility {
|
|||
}
|
||||
|
||||
if (this.bPlayer.isAvatarState()) {
|
||||
this.cooldown = 0;
|
||||
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Water.IceBlast.Cooldown");
|
||||
this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceBlast.Range");
|
||||
this.damage = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceBlast.Damage");
|
||||
}
|
||||
|
||||
block(player);
|
||||
this.range = getNightFactor(this.range, player.getWorld());
|
||||
final Block sourceBlock = BlockSource.getWaterSourceBlock(player, this.range, ClickType.SHIFT_DOWN, false, true, false, false, false);
|
||||
final Block sourceBlock = BlockSource.getWaterSourceBlock(player, this.range, ClickType.SHIFT_DOWN, false, true, false, this.allowSnow, false);
|
||||
final IceBlast oldAbil = getAbility(player, IceBlast.class);
|
||||
if (oldAbil != null) {
|
||||
oldAbil.setSourceBlock(sourceBlock == null ? oldAbil.getSourceBlock() : sourceBlock);
|
||||
|
|
|
@ -455,12 +455,6 @@ public class PhaseChange extends IceAbility {
|
|||
return PLAYER_BY_BLOCK;
|
||||
}
|
||||
|
||||
public static List<TempBlock> getFrozenBlocksAsTempBlock() {
|
||||
final List<TempBlock> list = new ArrayList<>();
|
||||
list.addAll(PLAYER_BY_BLOCK.keySet());
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<Block> getFrozenBlocksAsBlock() {
|
||||
final List<Block> list = new ArrayList<>();
|
||||
for (final TempBlock tb : PLAYER_BY_BLOCK.keySet()) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
@ -229,8 +230,22 @@ public class WaterArmsSpear extends WaterAbility {
|
|||
}
|
||||
return;
|
||||
}
|
||||
for (final Block block : GeneralMethods.getBlocksAroundPoint(this.location, this.spearSphereRadius)) {
|
||||
final List<Entity> trapped = GeneralMethods.getEntitiesAroundPoint(this.location, this.spearSphereRadius);
|
||||
ICE_SETTING: for (final Block block : GeneralMethods.getBlocksAroundPoint(this.location, this.spearSphereRadius)) {
|
||||
if (isTransparent(this.player, block) && block.getType() != Material.ICE && !WaterArms.isUnbreakable(block)) {
|
||||
for (Entity entity : trapped) {
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) {
|
||||
return;
|
||||
}
|
||||
if (!getConfig().getBoolean("Properties.Water.FreezePlayerHead") && GeneralMethods.playerHeadIsInBlock((Player) entity, block, true)) {
|
||||
continue ICE_SETTING;
|
||||
}
|
||||
if (!getConfig().getBoolean("Properties.Water.FreezePlayerFeet") && GeneralMethods.playerFeetIsInBlock((Player) entity, block, true)) {
|
||||
continue ICE_SETTING;
|
||||
}
|
||||
}
|
||||
}
|
||||
playIcebendingSound(block.getLocation());
|
||||
new TempBlock(block, Material.ICE);
|
||||
getIceBlocks().put(block, System.currentTimeMillis() + this.spearDuration + (long) (Math.random() * 500));
|
||||
|
|
|
@ -222,7 +222,9 @@ public class WaterArmsWhip extends WaterAbility {
|
|||
}
|
||||
|
||||
this.useArm();
|
||||
this.dragEntity(this.end);
|
||||
if (this.end != null) { //not 100% sure if this null check is a root cause fix or not
|
||||
this.dragEntity(this.end);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canPlaceBlock(final Block block) {
|
||||
|
@ -395,16 +397,7 @@ public class WaterArmsWhip extends WaterAbility {
|
|||
}
|
||||
|
||||
public static void checkValidEntities() {
|
||||
for (final LivingEntity livingEnt : GRABBED_ENTITIES.keySet()) {
|
||||
final WaterArmsWhip whip = GRABBED_ENTITIES.get(livingEnt);
|
||||
if (!whip.isRemoved()) {
|
||||
if (whip.grabbedEntity == null) {
|
||||
GRABBED_ENTITIES.remove(livingEnt);
|
||||
}
|
||||
} else {
|
||||
GRABBED_ENTITIES.remove(livingEnt);
|
||||
}
|
||||
}
|
||||
GRABBED_ENTITIES.entrySet().removeIf(entry -> entry.getValue().isRemoved() || entry.getValue().grabbedEntity == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,7 @@ author: ProjectKorra
|
|||
api-version: 1.13
|
||||
version: ${project.version}
|
||||
main: com.projectkorra.projectkorra.ProjectKorra
|
||||
softdepend: [PreciousStones, WorldGuard, WorldEdit, FactionsFramework, GriefPrevention, Towny, NoCheatPlus, LWC, Residence, Kingdoms, PlotSquared, RedProtect]
|
||||
softdepend: [PreciousStones, WorldGuard, WorldEdit, FactionsFramework, GriefPrevention, Towny, NoCheatPlus, LWC, Residence, Kingdoms, RedProtect, PlaceholderAPI]
|
||||
commands:
|
||||
projectkorra:
|
||||
aliases: [b,bending,mtla,tla,korra,pk,bend]
|
||||
|
|
Loading…
Reference in a new issue