diff --git a/.travis.yml b/.travis.yml
index 6d6441d9..9bddb57f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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:
diff --git a/lib/PlotSquared-Bukkit-4.18.12.31-38a382f-2131.jar b/lib/PlotSquared-Bukkit-4.18.12.31-38a382f-2131.jar
deleted file mode 100644
index fea23b84..00000000
Binary files a/lib/PlotSquared-Bukkit-4.18.12.31-38a382f-2131.jar and /dev/null differ
diff --git a/lib/PreciousStones 10.6.1.jar b/lib/PreciousStones 10.6.1.jar
deleted file mode 100644
index cb267131..00000000
Binary files a/lib/PreciousStones 10.6.1.jar and /dev/null differ
diff --git a/lib/RedProtect-7.5.5-b129-Universal.jar b/localrepo/br/net/fabiozumbi12/RedProtect/7.5.5/RedProtect-7.5.5.jar
similarity index 100%
rename from lib/RedProtect-7.5.5-b129-Universal.jar
rename to localrepo/br/net/fabiozumbi12/RedProtect/7.5.5/RedProtect-7.5.5.jar
diff --git a/localrepo/br/net/fabiozumbi12/RedProtect/7.5.5/RedProtect-7.5.5.pom b/localrepo/br/net/fabiozumbi12/RedProtect/7.5.5/RedProtect-7.5.5.pom
new file mode 100644
index 00000000..faf74fcb
--- /dev/null
+++ b/localrepo/br/net/fabiozumbi12/RedProtect/7.5.5/RedProtect-7.5.5.pom
@@ -0,0 +1,9 @@
+
+
+ 4.0.0
+ br.net.fabiozumbi12
+ RedProtect
+ 7.5.5
+ POM was created from install:install-file
+
diff --git a/localrepo/br/net/fabiozumbi12/RedProtect/maven-metadata-local.xml b/localrepo/br/net/fabiozumbi12/RedProtect/maven-metadata-local.xml
new file mode 100644
index 00000000..e7077f45
--- /dev/null
+++ b/localrepo/br/net/fabiozumbi12/RedProtect/maven-metadata-local.xml
@@ -0,0 +1,12 @@
+
+
+ br.net.fabiozumbi12
+ RedProtect
+
+ 7.5.5
+
+ 7.5.5
+
+ 20190223101710
+
+
diff --git a/lib/Residence4.8.3.1.jar b/localrepo/com/bekvon/bukkit/residence/4.8.3.1/residence-4.8.3.1.jar
similarity index 100%
rename from lib/Residence4.8.3.1.jar
rename to localrepo/com/bekvon/bukkit/residence/4.8.3.1/residence-4.8.3.1.jar
diff --git a/localrepo/com/bekvon/bukkit/residence/4.8.3.1/residence-4.8.3.1.pom b/localrepo/com/bekvon/bukkit/residence/4.8.3.1/residence-4.8.3.1.pom
new file mode 100644
index 00000000..f8c03974
--- /dev/null
+++ b/localrepo/com/bekvon/bukkit/residence/4.8.3.1/residence-4.8.3.1.pom
@@ -0,0 +1,9 @@
+
+
+ 4.0.0
+ com.bekvon.bukkit
+ residence
+ 4.8.3.1
+ POM was created from install:install-file
+
diff --git a/localrepo/com/bekvon/bukkit/residence/maven-metadata-local.xml b/localrepo/com/bekvon/bukkit/residence/maven-metadata-local.xml
new file mode 100644
index 00000000..be2a1416
--- /dev/null
+++ b/localrepo/com/bekvon/bukkit/residence/maven-metadata-local.xml
@@ -0,0 +1,12 @@
+
+
+ com.bekvon.bukkit
+ residence
+
+ 4.8.3.1
+
+ 4.8.3.1
+
+ 20190223101425
+
+
diff --git a/lib/Modern-LWC-2.1.2.jar b/localrepo/com/griefcraft/lwc/2.1.2/lwc-2.1.2.jar
similarity index 100%
rename from lib/Modern-LWC-2.1.2.jar
rename to localrepo/com/griefcraft/lwc/2.1.2/lwc-2.1.2.jar
diff --git a/localrepo/com/griefcraft/lwc/2.1.2/lwc-2.1.2.pom b/localrepo/com/griefcraft/lwc/2.1.2/lwc-2.1.2.pom
new file mode 100644
index 00000000..95e6db14
--- /dev/null
+++ b/localrepo/com/griefcraft/lwc/2.1.2/lwc-2.1.2.pom
@@ -0,0 +1,9 @@
+
+
+ 4.0.0
+ com.griefcraft
+ lwc
+ 2.1.2
+ POM was created from install:install-file
+
diff --git a/localrepo/com/griefcraft/lwc/maven-metadata-local.xml b/localrepo/com/griefcraft/lwc/maven-metadata-local.xml
new file mode 100644
index 00000000..cc7b3485
--- /dev/null
+++ b/localrepo/com/griefcraft/lwc/maven-metadata-local.xml
@@ -0,0 +1,12 @@
+
+
+ com.griefcraft
+ lwc
+
+ 2.1.2
+
+ 2.1.2
+
+ 20190223101300
+
+
diff --git a/lib/Towny.jar b/localrepo/com/palmergames/Towny/0.93.0.0/Towny-0.93.0.0.jar
similarity index 100%
rename from lib/Towny.jar
rename to localrepo/com/palmergames/Towny/0.93.0.0/Towny-0.93.0.0.jar
diff --git a/localrepo/com/palmergames/Towny/0.93.0.0/Towny-0.93.0.0.pom b/localrepo/com/palmergames/Towny/0.93.0.0/Towny-0.93.0.0.pom
new file mode 100644
index 00000000..837a877a
--- /dev/null
+++ b/localrepo/com/palmergames/Towny/0.93.0.0/Towny-0.93.0.0.pom
@@ -0,0 +1,9 @@
+
+
+ 4.0.0
+ com.palmergames
+ Towny
+ 0.93.0.0
+ POM was created from install:install-file
+
diff --git a/localrepo/com/palmergames/Towny/maven-metadata-local.xml b/localrepo/com/palmergames/Towny/maven-metadata-local.xml
new file mode 100644
index 00000000..692b1aff
--- /dev/null
+++ b/localrepo/com/palmergames/Towny/maven-metadata-local.xml
@@ -0,0 +1,12 @@
+
+
+ com.palmergames
+ Towny
+
+ 0.93.0.0
+
+ 0.93.0.0
+
+ 20190223101606
+
+
diff --git a/lib/FabledKingdoms-1.2.3.jar b/localrepo/com/songoda/kingdoms/1.2.3/kingdoms-1.2.3.jar
similarity index 100%
rename from lib/FabledKingdoms-1.2.3.jar
rename to localrepo/com/songoda/kingdoms/1.2.3/kingdoms-1.2.3.jar
diff --git a/localrepo/com/songoda/kingdoms/1.2.3/kingdoms-1.2.3.pom b/localrepo/com/songoda/kingdoms/1.2.3/kingdoms-1.2.3.pom
new file mode 100644
index 00000000..a0dac4bc
--- /dev/null
+++ b/localrepo/com/songoda/kingdoms/1.2.3/kingdoms-1.2.3.pom
@@ -0,0 +1,9 @@
+
+
+ 4.0.0
+ com.songoda
+ kingdoms
+ 1.2.3
+ POM was created from install:install-file
+
diff --git a/localrepo/com/songoda/kingdoms/maven-metadata-local.xml b/localrepo/com/songoda/kingdoms/maven-metadata-local.xml
new file mode 100644
index 00000000..31130761
--- /dev/null
+++ b/localrepo/com/songoda/kingdoms/maven-metadata-local.xml
@@ -0,0 +1,12 @@
+
+
+ com.songoda
+ kingdoms
+
+ 1.2.3
+
+ 1.2.3
+
+ 20190223101813
+
+
diff --git a/lib/FactionsFramework1.2.0.jar b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.jar
similarity index 100%
rename from lib/FactionsFramework1.2.0.jar
rename to localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.jar
diff --git a/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.jar.md5 b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.jar.md5
new file mode 100644
index 00000000..6239148a
--- /dev/null
+++ b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.jar.md5
@@ -0,0 +1 @@
+333673ff2f0740caad4889dcaa4840d4
\ No newline at end of file
diff --git a/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.jar.sha1 b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.jar.sha1
new file mode 100644
index 00000000..1814d8a4
--- /dev/null
+++ b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.jar.sha1
@@ -0,0 +1 @@
+3869ec4128db113162c54a11d0010a002ed3b5ee
\ No newline at end of file
diff --git a/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.pom b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.pom
new file mode 100644
index 00000000..c474924b
--- /dev/null
+++ b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.pom
@@ -0,0 +1,8 @@
+
+
+ 4.0.0
+ me.markeh
+ factionsframework
+ 1.2.0
+
diff --git a/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.pom.md5 b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.pom.md5
new file mode 100644
index 00000000..0b82b721
--- /dev/null
+++ b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.pom.md5
@@ -0,0 +1 @@
+1fe23316d4e93edea247dd0e49a73cee
\ No newline at end of file
diff --git a/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.pom.sha1 b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.pom.sha1
new file mode 100644
index 00000000..3fd23435
--- /dev/null
+++ b/localrepo/me/markeh/factionsframework/1.2.0/factionsframework-1.2.0.pom.sha1
@@ -0,0 +1 @@
+fa0e391fae40a538a5b3223ad3b3b01990c0afe6
\ No newline at end of file
diff --git a/localrepo/me/markeh/factionsframework/maven-metadata.xml b/localrepo/me/markeh/factionsframework/maven-metadata.xml
new file mode 100644
index 00000000..ed669a9e
--- /dev/null
+++ b/localrepo/me/markeh/factionsframework/maven-metadata.xml
@@ -0,0 +1,12 @@
+
+
+ me.markeh
+ factionsframework
+
+ 1.2.0
+
+ 1.2.0
+
+ 20190223095944
+
+
diff --git a/localrepo/me/markeh/factionsframework/maven-metadata.xml.md5 b/localrepo/me/markeh/factionsframework/maven-metadata.xml.md5
new file mode 100644
index 00000000..8df5ad74
--- /dev/null
+++ b/localrepo/me/markeh/factionsframework/maven-metadata.xml.md5
@@ -0,0 +1 @@
+f381f9c9b67641659a289a4e6ed63a25
\ No newline at end of file
diff --git a/localrepo/me/markeh/factionsframework/maven-metadata.xml.sha1 b/localrepo/me/markeh/factionsframework/maven-metadata.xml.sha1
new file mode 100644
index 00000000..8a3a5e01
--- /dev/null
+++ b/localrepo/me/markeh/factionsframework/maven-metadata.xml.sha1
@@ -0,0 +1 @@
+8ced509852cc7dd171ce85c9eb439969b9af1ce1
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5ef2b46e..eace9821 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,9 +3,15 @@
4.0.0
com.projectkorra
projectkorra
- 1.8.7
+ 1.8.8
ProjectKorra
+
+
+ project.local
+ project
+ file://${project.basedir}/localrepo/
+
sk89q-repo
@@ -26,8 +32,35 @@
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ aikar
+ http://repo.aikar.co/nexus/content/groups/aikar/
+
+
+
+ papermc
+ https://papermc.io/repo/repository/maven-public/
+
+
+
+ placeholderapi
+ http://repo.extendedclip.com/content/repositories/placeholderapi/
+
+
+
+ io.papermc
+ paperlib
+ 1.0.1
+
+
+
+ co.aikar
+ minecraft-timings
+ 1.0.4
+
org.spigotmc
@@ -46,10 +79,9 @@
me.markeh
factionsframework
1.2.0
- system
- ${project.basedir}/lib/FactionsFramework1.2.0.jar
-
-
+ provided
+
+
com.github.TechFortress
GriefPrevention
@@ -60,9 +92,8 @@
com.griefcraft
lwc
- LATEST
- system
- ${project.basedir}/lib/Modern-LWC-2.1.2.jar
+ 2.1.2
+ provided
@@ -85,17 +116,15 @@
com.bekvon.bukkit
residence
- LATEST
- system
- ${project.basedir}/lib/Residence4.8.3.1.jar
+ 4.8.3.1
+ provided
com.palmergames
Towny
0.93.0.0
- system
- ${project.basedir}/lib/Towny.jar
+ provided
@@ -126,25 +155,22 @@
br.net.fabiozumbi12
RedProtect
- LATEST
- system
- ${project.basedir}/lib/RedProtect-7.5.5-b129-Universal.jar
-
-
-
- com.github.intelletualsites
- plotsquared
- LATEST
- system
- ${project.basedir}/lib/PlotSquared-Bukkit-4.18.12.31-38a382f-2131.jar
+ 7.5.5
+ provided
com.songoda
kingdoms
- LATEST
- system
- ${project.basedir}/lib/FabledKingdoms-1.2.3.jar
+ 1.2.3
+ provided
+
+
+
+ me.clip
+ placeholderapi
+ 2.9.2
+ provided
@@ -179,6 +205,39 @@
${dir}
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.1
+
+ ${project.build.directory}/dependency-reduced-pom.xml
+
+
+ co.aikar.timings.lib
+ timingslib.projectkorra
+
+
+ io.papermc.lib
+ paperlib.projectkorra
+
+
+ org.apache.commons
+ commonslang3.projectkorra
+
+
+
+
+
+ package
+
+ shade
+
+
+ true
+
+
+
+
diff --git a/src/com/projectkorra/projectkorra/BendingManager.java b/src/com/projectkorra/projectkorra/BendingManager.java
index 129d8ed6..f601b97d 100644
--- a/src/com/projectkorra/projectkorra/BendingManager.java
+++ b/src/com/projectkorra/projectkorra/BendingManager.java
@@ -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 times = new HashMap(); // 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() {
diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java
index f55507cb..77c4561c 100644
--- a/src/com/projectkorra/projectkorra/GeneralMethods.java
+++ b/src/com/projectkorra/projectkorra/GeneralMethods.java
@@ -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(), new ArrayList(), new HashMap(), false);
- ProjectKorra.log.info("Created new BendingPlayer for " + player);
+ new BukkitRunnable() {
+ @Override
+ public void run() {
+ new BendingPlayer(uuid, player, new ArrayList(), new ArrayList(), new HashMap(), 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 getEntitiesAroundPoint(final Location location, final double radius) {
- final List entities = new ArrayList();
- 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 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;
+ }
}
\ No newline at end of file
diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java
index 50379fab..1e1ba6de 100644
--- a/src/com/projectkorra/projectkorra/PKListener.java
+++ b/src/com/projectkorra/projectkorra/PKListener.java
@@ -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 TOGGLED_OUT = new ArrayList<>(); // Stands for toggled = false while logging out.
private static final Map 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 newDrops = armor.filterArmor(event.getDrops());
+ if (armor != null) {
+ final List 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)) {
diff --git a/src/com/projectkorra/projectkorra/ProjectKorra.java b/src/com/projectkorra/projectkorra/ProjectKorra.java
index b8df86d0..102ec070 100644
--- a/src/com/projectkorra/projectkorra/ProjectKorra.java
+++ b/src/com/projectkorra/projectkorra/ProjectKorra.java
@@ -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);
+ }
}
diff --git a/src/com/projectkorra/projectkorra/ability/CoreAbility.java b/src/com/projectkorra/projectkorra/ability/CoreAbility.java
index 75de53d5..8cca8718 100644
--- a/src/com/projectkorra/projectkorra/ability/CoreAbility.java
+++ b/src/com/projectkorra/projectkorra/ability/CoreAbility.java
@@ -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) {
diff --git a/src/com/projectkorra/projectkorra/ability/EarthAbility.java b/src/com/projectkorra/projectkorra/ability/EarthAbility.java
index d58e238b..ccf4d66b 100644
--- a/src/com/projectkorra/projectkorra/ability/EarthAbility.java
+++ b/src/com/projectkorra/projectkorra/ability/EarthAbility.java
@@ -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)) {
diff --git a/src/com/projectkorra/projectkorra/ability/ElementalAbility.java b/src/com/projectkorra/projectkorra/ability/ElementalAbility.java
index 841347fb..500fcdd2 100644
--- a/src/com/projectkorra/projectkorra/ability/ElementalAbility.java
+++ b/src/com/projectkorra/projectkorra/ability/ElementalAbility.java
@@ -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());
}
diff --git a/src/com/projectkorra/projectkorra/ability/WaterAbility.java b/src/com/projectkorra/projectkorra/ability/WaterAbility.java
index fb7a5399..b2fb938f 100644
--- a/src/com/projectkorra/projectkorra/ability/WaterAbility.java
+++ b/src/com/projectkorra/projectkorra/ability/WaterAbility.java
@@ -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) {
diff --git a/src/com/projectkorra/projectkorra/ability/util/CollisionInitializer.java b/src/com/projectkorra/projectkorra/ability/util/CollisionInitializer.java
index 0b6fb69b..b11ff4cc 100644
--- a/src/com/projectkorra/projectkorra/ability/util/CollisionInitializer.java
+++ b/src/com/projectkorra/projectkorra/ability/util/CollisionInitializer.java
@@ -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) {
diff --git a/src/com/projectkorra/projectkorra/ability/util/ComboManager.java b/src/com/projectkorra/projectkorra/ability/util/ComboManager.java
index 5221078c..cbf3a49c 100644
--- a/src/com/projectkorra/projectkorra/ability/util/ComboManager.java
+++ b/src/com/projectkorra/projectkorra/ability/util/ComboManager.java
@@ -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 iceBulletLeft = new ArrayList<>();
- iceBulletLeft.add(new AbilityInformation("IceBlast", ClickType.LEFT_CLICK));
- COMBO_ABILITIES.put("IceBulletLeftClick", new ComboAbilityInfo("IceBulletLeftClick", iceBulletLeft, IceBulletLeftClick.class));
- final ArrayList 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 earthDomeOthers = new ArrayList<>();
earthDomeOthers.add(new AbilityInformation("RaiseEarth", ClickType.RIGHT_CLICK_BLOCK));
diff --git a/src/com/projectkorra/projectkorra/airbending/AirBlast.java b/src/com/projectkorra/projectkorra/airbending/AirBlast.java
index 7a75c6b4..4b7829c1 100644
--- a/src/com/projectkorra/projectkorra/airbending/AirBlast.java
+++ b/src/com/projectkorra/projectkorra/airbending/AirBlast.java
@@ -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);
}
diff --git a/src/com/projectkorra/projectkorra/airbending/AirShield.java b/src/com/projectkorra/projectkorra/airbending/AirShield.java
index 8fdba841..d0791638 100644
--- a/src/com/projectkorra/projectkorra/airbending/AirShield.java
+++ b/src/com/projectkorra/projectkorra/airbending/AirShield.java
@@ -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));
diff --git a/src/com/projectkorra/projectkorra/airbending/AirSpout.java b/src/com/projectkorra/projectkorra/airbending/AirSpout.java
index b5d42b3a..f86175a4 100644
--- a/src/com/projectkorra/projectkorra/airbending/AirSpout.java
+++ b/src/com/projectkorra/projectkorra/airbending/AirSpout.java
@@ -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;
diff --git a/src/com/projectkorra/projectkorra/airbending/AirSuction.java b/src/com/projectkorra/projectkorra/airbending/AirSuction.java
index f1c9565c..c04a3905 100644
--- a/src/com/projectkorra/projectkorra/airbending/AirSuction.java
+++ b/src/com/projectkorra/projectkorra/airbending/AirSuction.java
@@ -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);
diff --git a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java
index f6e6cbf7..bc10f48a 100644
--- a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java
+++ b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java
@@ -196,7 +196,7 @@ public class AirSwipe extends AirAbility {
private void affectPeople(final Location location, final Vector direction) {
final List 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));
diff --git a/src/com/projectkorra/projectkorra/airbending/Tornado.java b/src/com/projectkorra/projectkorra/airbending/Tornado.java
index 969598fe..bff866ed 100644
--- a/src/com/projectkorra/projectkorra/airbending/Tornado.java
+++ b/src/com/projectkorra/projectkorra/airbending/Tornado.java
@@ -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());
- }
}
}
}
diff --git a/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java b/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java
index 95544e88..a8b8d4a1 100644
--- a/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java
+++ b/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java
@@ -37,14 +37,12 @@ public class AirStream extends AirAbility implements ComboAbility {
private Vector direction;
private ArrayList affectedEntities;
private ArrayList tasks;
- private Set 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 getFlights() {
- return this.flights;
- }
-
public void setCooldown(final long cooldown) {
this.cooldown = cooldown;
}
diff --git a/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java b/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java
index cf9f9390..21d2c376 100644
--- a/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java
+++ b/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java
@@ -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();
diff --git a/src/com/projectkorra/projectkorra/avatar/AvatarState.java b/src/com/projectkorra/projectkorra/avatar/AvatarState.java
index 8057805d..10ecca71 100644
--- a/src/com/projectkorra/projectkorra/avatar/AvatarState.java
+++ b/src/com/projectkorra/projectkorra/avatar/AvatarState.java
@@ -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;
}
diff --git a/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java b/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java
index 493f01a3..58f299bd 100644
--- a/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java
+++ b/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java
@@ -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();
diff --git a/src/com/projectkorra/projectkorra/command/WhoCommand.java b/src/com/projectkorra/projectkorra/command/WhoCommand.java
index ad3f7ede..f6ab6810 100644
--- a/src/com/projectkorra/projectkorra/command/WhoCommand.java
+++ b/src/com/projectkorra/projectkorra/command/WhoCommand.java
@@ -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");
}
}
diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java
index 25278eb7..c2c46ba5 100644
--- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java
+++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java
@@ -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);
diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java b/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java
index 7cce24da..1b13f1c2 100644
--- a/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java
+++ b/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java
@@ -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)) {
diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java b/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java
index 07af951c..c769c3ce 100644
--- a/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java
+++ b/src/com/projectkorra/projectkorra/earthbending/EarthTunnel.java
@@ -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";
diff --git a/src/com/projectkorra/projectkorra/firebending/FireManipulation.java b/src/com/projectkorra/projectkorra/firebending/FireManipulation.java
index aa061e33..0ccc2abf 100644
--- a/src/com/projectkorra/projectkorra/firebending/FireManipulation.java
+++ b/src/com/projectkorra/projectkorra/firebending/FireManipulation.java
@@ -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 getLocations() {
final List locations = new ArrayList<>();
- locations.addAll(this.points.keySet());
+ if (points != null) {
+ locations.addAll(this.points.keySet());
+ }
return locations;
}
diff --git a/src/com/projectkorra/projectkorra/firebending/HeatControl.java b/src/com/projectkorra/projectkorra/firebending/HeatControl.java
index eff789da..180ef20d 100644
--- a/src/com/projectkorra/projectkorra/firebending/HeatControl.java
+++ b/src/com/projectkorra/projectkorra/firebending/HeatControl.java
@@ -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);
diff --git a/src/com/projectkorra/projectkorra/firebending/Illumination.java b/src/com/projectkorra/projectkorra/firebending/Illumination.java
index 71448902..c7314a81 100644
--- a/src/com/projectkorra/projectkorra/firebending/Illumination.java
+++ b/src/com/projectkorra/projectkorra/firebending/Illumination.java
@@ -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;
}
diff --git a/src/com/projectkorra/projectkorra/firebending/combo/FireComboStream.java b/src/com/projectkorra/projectkorra/firebending/combo/FireComboStream.java
index 77c73087..d1eb4d51 100644
--- a/src/com/projectkorra/projectkorra/firebending/combo/FireComboStream.java
+++ b/src/com/projectkorra/projectkorra/firebending/combo/FireComboStream.java
@@ -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);
+ }
}
diff --git a/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java b/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java
index 52d6fb75..2264d9d0 100644
--- a/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java
+++ b/src/com/projectkorra/projectkorra/firebending/combo/JetBlast.java
@@ -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;
diff --git a/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java b/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java
index 316fd3fa..1e0cb163 100644
--- a/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java
+++ b/src/com/projectkorra/projectkorra/firebending/combo/JetBlaze.java
@@ -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;
diff --git a/src/com/projectkorra/projectkorra/hooks/PlaceholderAPIHook.java b/src/com/projectkorra/projectkorra/hooks/PlaceholderAPIHook.java
new file mode 100644
index 00000000..470a8cb5
--- /dev/null
+++ b/src/com/projectkorra/projectkorra/hooks/PlaceholderAPIHook.java
@@ -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();
+ }
+}
diff --git a/src/com/projectkorra/projectkorra/hooks/WorldGuardFlag.java b/src/com/projectkorra/projectkorra/hooks/WorldGuardFlag.java
new file mode 100644
index 00000000..e91584d5
--- /dev/null
+++ b/src/com/projectkorra/projectkorra/hooks/WorldGuardFlag.java
@@ -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");
+ }
+ }
+}
diff --git a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java
index 48d7ef8f..81a88de9 100644
--- a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java
+++ b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java
@@ -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);
+ }
}
diff --git a/src/com/projectkorra/projectkorra/util/DamageHandler.java b/src/com/projectkorra/projectkorra/util/DamageHandler.java
index 575c5698..7aa90c39 100644
--- a/src/com/projectkorra/projectkorra/util/DamageHandler.java
+++ b/src/com/projectkorra/projectkorra/util/DamageHandler.java
@@ -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) {
diff --git a/src/com/projectkorra/projectkorra/util/RevertChecker.java b/src/com/projectkorra/projectkorra/util/RevertChecker.java
index d238272d..4d5502da 100644
--- a/src/com/projectkorra/projectkorra/util/RevertChecker.java
+++ b/src/com/projectkorra/projectkorra/util/RevertChecker.java
@@ -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> returnFuture;
+ private Future>> 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 chunks = this.returnFuture.get();
+ final Set