## Additions
* Adds a built-in bending board sidebar to visualize bound abilities and cooldowns.
  * The board respects worlds where bending is disabled.
  * Players can use the command `/pk board` to toggle the visibility of their board.
  * Includes an API that community developers can use in BendingBoardManager.
  * Adds the `"Properties.BendingBoard"` config option to enable or disable the board server.
  * Adds language file configuration options to control BendingBoard visuals.
    * `"Board.Title"`
      * Controls the title at the top of the board.
      * Supports the standard Minecraft color codes.
    * `"Board.SelectionPrefix"`
      * Controls the prefix shown corresponding to your current hot bar slot.
      * Supports the standard Minecraft color codes.
    * `"Board.EmptySlot"`
      * Controls what is shown for empty slots.
      * Supports the standard Minecraft color codes.
      * `{slot_number}` can be used as a placeholder for the slot number.
    * `"Board.MiscSeparator"`
      * Controls the separation between hot bar binds and temporary cooldowns such as Combos.
      * Supports the standard Minecraft color codes.
* Adds support for KingdomsX version 1.10.19.1
* Adds ability permission check to passive abilities. They should now respect their `bending.ability.<ability name>` permissions.
* Adds `AbilityVelocityAffectEntityEvent`
  * A cancellable event that will fire whenever an ability would alter the velocity of an entity.
* Adds the `Abilities.Earth.EarthSmash.Shoot.CollisionRadius` configuration option
  * Sets the collision radius of shot EarthSmash.

## Fixes
* Fixes FireBlast going through liquids.
* Fixes duplication involving waterlogged containers.
* Fixes being able to not enter the name of a Preset when using the `/pk preset create <name>` command.
* Fixes getDayFactor() not being applied correctly and occasionally producing the wrong value.
* Fixes a rounding issue with some Fire ability damage configuration options.
* Fixes an error when attempting to start EarthGrab.
* Fixes PhaseChange error when melting snow.
* Fixes a memory/process leak in how cooldowns were removed.
  * A player's cooldowns could only be removed when they were online. If a player's cooldown expired while they weren't online, their cooldown would attempt to revert every tick until the player rejoined. This has been resolved so cooldowns can revert while a player is offline.
  * A side effect of this fix is that it is now possible for `PlayerCooldownChangeEvents` to fire while their corresponding Player is offline.
* Fixes an issue with `MultiAbilityManager#hasMultiAbilityBound` where it would return true if any MultiAbility is bound, not if the specified MultiAbility was bound.

## Misc Changes
* Updates Towny version to 0.96.2.0
* DensityShift sand blocks can now be used as a bendable source.
* Changes AvatarState so that its cooldown is applied when the ability ends instead of when it starts.
* Changes togglable abilities such as AvatarState, Illumination, and TremorSense to visually show when they are enabled in the BendingBoard and on BendingPreview in the same way as the ChiBlocking Stances.
* Updated the text of some ability descriptions and instructions.
* Adds new cache to PhaseChange to greatly improve the performance of water/ice updates.
This commit is contained in:
Christopher Martin 2021-06-07 16:58:29 -07:00 committed by GitHub
parent 0b35fb9fda
commit 787b303c9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 710 additions and 217 deletions

View File

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

View File

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

34
pom.xml
View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.projectkorra</groupId>
<artifactId>projectkorra</artifactId>
<version>1.9.0</version>
<version>1.9.1</version>
<name>ProjectKorra</name>
<repositories>
<!-- local jar files, add more using: mvn install:install-file -Dfile=aaa.jar -DgroupId=aaa -DartifactId=aaa -Dversion=aaa -Dpackaging=jar -DlocalRepositoryPath=path/to/ProjectKorra/localrepo/ -->
@ -17,7 +17,7 @@
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
<!-- GriefPrevention Repo -->
<!-- GriefPrevention and Towny Repo -->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
@ -80,8 +80,8 @@
<artifactId>factionsframework</artifactId>
<version>1.2.0</version>
<scope>provided</scope>
</dependency>
<!-- GriefPrevention -->
</dependency>
<!-- GriefPrevention -->
<dependency>
<groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId>
@ -121,9 +121,9 @@
</dependency>
<!-- Towny -->
<dependency>
<groupId>com.palmergames</groupId>
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>Towny</artifactId>
<version>0.93.0.0</version>
<version>0.96.2.0</version>
<scope>provided</scope>
</dependency>
<!-- WorldEdit / WorldGuard -->
@ -160,10 +160,16 @@
</dependency>
<!-- Kingdoms -->
<dependency>
<groupId>com.songoda</groupId>
<groupId>com.github.cryptomorin</groupId>
<artifactId>kingdoms</artifactId>
<version>1.2.3</version>
<scope>provided</scope>
<version>1.10.19.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- PlaceholderAPI -->
<dependency>
@ -208,9 +214,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.4</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<filters>
<filter>
<artifact>com.github.cryptomorin:kingdoms</artifact>
<includes>
<include>org/kingdoms/constants/player/KingdomPermission.class</include>
</includes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>co.aikar.timings.lib</pattern>

View File

@ -10,6 +10,7 @@ import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import com.projectkorra.projectkorra.event.PlayerStanceChangeEvent;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -27,6 +28,7 @@ import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.board.BendingBoardManager;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.metal.MetalClips;
@ -132,7 +134,7 @@ public class BendingPlayer {
if (cooldown <= 0) {
return;
}
final PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(this.uuid), ability, cooldown, Result.ADDED);
final PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(player, ability, cooldown, Result.ADDED);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
@ -147,9 +149,11 @@ public class BendingPlayer {
final String abilityName = event.getAbility();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer.getBoundAbility() != null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) {
if (bPlayer != null && bPlayer.getBoundAbility() != null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) {
GeneralMethods.displayMovePreview(player);
}
BendingBoardManager.updateBoard(player, event.getAbility(), true, 0);
}
}
@ -310,6 +314,8 @@ public class BendingPlayer {
return false;
} else if (!this.player.hasPermission("bending." + element.getName() + ".passive")) {
return false;
} else if (!this.player.hasPermission("bending.ability." + ability.getName())) {
return false;
} else if (!this.hasElement(element)) {
return false;
} else if (disabledWorlds != null && disabledWorlds.contains(this.player.getWorld().getName())) {
@ -803,22 +809,25 @@ public class BendingPlayer {
* @param ability The ability's cooldown to remove
*/
public void removeCooldown(final String ability) {
if (Bukkit.getPlayer(this.uuid) == null) {
return;
}
final PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(this.uuid), ability, 0, Result.REMOVED);
final PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(player, ability, 0, Result.REMOVED);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.cooldowns.remove(ability);
final Player player = event.getPlayer();
if (player == null) {
return;
}
final String abilityName = event.getAbility();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer.getBoundAbility() != null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) {
if (bPlayer != null && bPlayer.getBoundAbility() != null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) {
GeneralMethods.displayMovePreview(player);
}
BendingBoardManager.updateBoard(player, event.getAbility(), false, 0);
}
}
@ -858,11 +867,17 @@ public class BendingPlayer {
/**
* Sets the player's {@link ChiAbility Chi stance}
* Also update any previews
*
* @param stance The player's new stance object
*/
public void setStance(final ChiAbility stance) {
final String oldStance = (this.stance == null) ? "" : this.stance.getName();
final String newStance = (stance == null) ? "" : stance.getName();
this.stance = stance;
GeneralMethods.displayMovePreview(player);
final PlayerStanceChangeEvent event = new PlayerStanceChangeEvent(Bukkit.getPlayer(this.uuid), oldStance, newStance);
Bukkit.getServer().getPluginManager().callEvent(event);
}
/**

View File

@ -39,28 +39,13 @@ import com.google.common.reflect.ClassPath;
import com.griefcraft.lwc.LWC;
import com.griefcraft.lwc.LWCPlugin;
import com.griefcraft.model.Protection;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyMessaging;
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.object.Coord;
import com.palmergames.bukkit.towny.object.PlayerCache;
import com.palmergames.bukkit.towny.object.PlayerCache.TownBlockStatus;
import com.palmergames.bukkit.towny.object.TownyPermission;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import com.palmergames.bukkit.towny.object.TownyWorld;
import com.palmergames.bukkit.towny.object.WorldCoord;
import com.palmergames.bukkit.towny.object.TownyPermission.ActionType;
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
import com.palmergames.bukkit.towny.war.flagwar.TownyWar;
import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.songoda.kingdoms.constants.land.Land;
import com.songoda.kingdoms.constants.land.SimpleChunkLocation;
import com.songoda.kingdoms.constants.player.KingdomPlayer;
import com.songoda.kingdoms.manager.game.GameManagement;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -87,6 +72,13 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.kingdoms.constants.kingdom.Kingdom;
import org.kingdoms.constants.kingdom.model.KingdomRelation;
import org.kingdoms.constants.land.Land;
import org.kingdoms.constants.land.structures.managers.Regulator;
import org.kingdoms.constants.land.structures.managers.Regulator.Attribute;
import org.kingdoms.constants.player.DefaultKingdomPermission;
import org.kingdoms.constants.player.KingdomPlayer;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.ability.Ability;
@ -109,6 +101,7 @@ import com.projectkorra.projectkorra.airbending.AirShield;
import com.projectkorra.projectkorra.airbending.AirSpout;
import com.projectkorra.projectkorra.airbending.AirSuction;
import com.projectkorra.projectkorra.airbending.AirSwipe;
import com.projectkorra.projectkorra.board.BendingBoardManager;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.EarthBlast;
import com.projectkorra.projectkorra.earthbending.passive.EarthPassive;
@ -174,7 +167,7 @@ public class GeneralMethods {
/**
* Checks to see if an AbilityExists. Uses method
* {@link #getAbility(String)} to check if it exists.
* {@link CoreAbility#getAbility(String)} to check if it exists.
*
* @param string Ability Name
* @return true if ability exists
@ -1042,7 +1035,6 @@ public class GeneralMethods {
* @param block The single block
* @param type The Material type to change the block into
* @param data The block data to change the block into
* @param breakitem Unused
* @return The item drops fromt the specified block
*/
public static Collection<ItemStack> getDrops(final Block block, final Material type, final BlockData data) {
@ -1298,7 +1290,7 @@ public class GeneralMethods {
if (trans.contains(block.getType())) {
continue;
} else if (ignoreTempBlocks && (TempBlock.isTempBlock(block) && !WaterAbility.isBendableWaterTempBlock(block))) {
} else if (ignoreTempBlocks && (TempBlock.isTempBlock(block) && !WaterAbility.isBendableWaterTempBlock(block) && !EarthAbility.isBendableEarthTempBlock(block))) {
continue;
} else {
location.subtract(vec);
@ -1565,7 +1557,7 @@ public class GeneralMethods {
final boolean respectGriefPrevention = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectGriefPrevention");
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 respectKingdoms = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.Kingdoms.Respect");
final boolean respectRedProtect = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectRedProtect");
boolean isIgnite = false;
@ -1659,38 +1651,8 @@ public class GeneralMethods {
}
if (twnp != null && respectTowny) {
final Towny twn = (Towny) twnp;
WorldCoord worldCoord;
try {
final TownyWorld tWorld = TownyUniverse.getDataSource().getWorld(world.getName());
worldCoord = new WorldCoord(tWorld.getName(), Coord.parseCoord(location));
final boolean bBuild = PlayerCacheUtil.getCachePermission(player, location, Material.DIRT, TownyPermission.ActionType.BUILD);
if (!bBuild) {
final PlayerCache cache = twn.getCache(player);
final TownBlockStatus status = cache.getStatus();
if (((status == TownBlockStatus.ENEMY) && TownyWarConfig.isAllowingAttacks())) {
try {
TownyWar.callAttackCellEvent(twn, player, location.getBlock(), worldCoord);
} catch (final Exception e) {
TownyMessaging.sendErrorMsg(player, e.getMessage());
}
return true;
} else if (status == TownBlockStatus.WARZONE) {
} else {
return true;
}
if ((cache.hasBlockErrMsg())) {
TownyMessaging.sendErrorMsg(player, cache.getBlockErrMsg());
}
}
} catch (final Exception e1) {
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_not_configured"));
if (!PlayerCacheUtil.getCachePermission(player, location, Material.DIRT, ActionType.BUILD)) {
return true;
}
}
@ -1720,18 +1682,22 @@ public class GeneralMethods {
}
if (kingdoms != null && respectKingdoms) {
final KingdomPlayer kPlayer = GameManagement.getPlayerManager().getOfflineKingdomPlayer(player).getKingdomPlayer();
if (kPlayer.getKingdom() != null) {
final SimpleChunkLocation chunkLocation = new SimpleChunkLocation(location.getChunk());
final Land land = GameManagement.getLandManager().getOrLoadLand(chunkLocation);
final UUID owner = land.getOwnerUUID();
if (owner != null) {
if (!kPlayer.getKingdom().getKing().equals(owner)) {
return true;
}
final KingdomPlayer kPlayer = KingdomPlayer.getKingdomPlayer(player);
final Land land = Land.getLand(location);
final boolean protectDuringInvasions = ConfigManager.getConfig().getBoolean("Properties.RegionProtection.Kingdoms.ProtectDuringInvasions");
if (land != null) {
final Kingdom kingdom = land.getKingdom();
if (kPlayer.isAdmin()
|| (!protectDuringInvasions && !land.getInvasions().isEmpty() && land.getInvasions().values().stream().anyMatch(i -> i.getInvader().equals(kPlayer))) // Protection during invasions is off, and player is currently invading; allow
|| (land.getStructure() != null && land.getStructure() instanceof Regulator && ((Regulator) land.getStructure()).hasAttribute(player, Attribute.BUILD))) { // There is a regulator on site which allows the player to build; allow
return false;
}
if (!kPlayer.hasKingdom() // Player has no kingdom; deny
|| (kPlayer.getKingdom().equals(kingdom) && !kPlayer.hasPermission(DefaultKingdomPermission.BUILD)) // Player is a member of this kingdom but cannot build here; deny
|| (!kPlayer.getKingdom().equals(kingdom) && !kPlayer.getKingdom().hasAttribute(kingdom, KingdomRelation.Attribute.BUILD))) { // Player is not a member of this kingdom and cannot build here; deny
return true;
}
}
}
if (redprotect != null && respectRedProtect) {
@ -1929,6 +1895,7 @@ public class GeneralMethods {
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
PassiveManager.registerPassives(player);
}
BendingBoardManager.reload();
plugin.updater.checkUpdate();
ProjectKorra.log.info("Reload complete");
}
@ -2065,7 +2032,7 @@ public class GeneralMethods {
final boolean respectGriefPrevention = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectGriefPrevention");
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 respectKingdoms = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.Kingdoms.Respect");
final boolean respectRedProtect = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RedProtect");
final PluginManager pm = Bukkit.getPluginManager();
@ -2451,9 +2418,10 @@ public class GeneralMethods {
}
final File saveTo = new File(plugin.getDataFolder(), "debug.txt");
if (!saveTo.exists()) {
saveTo.createNewFile();
if (saveTo.exists()) {
saveTo.delete();
}
saveTo.createNewFile();
final FileWriter fw = new FileWriter(saveTo, true);
final PrintWriter pw = new PrintWriter(fw);

View File

@ -103,6 +103,7 @@ import com.projectkorra.projectkorra.airbending.Tornado;
import com.projectkorra.projectkorra.airbending.flight.FlightMultiAbility;
import com.projectkorra.projectkorra.airbending.passive.GracefulDescent;
import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.board.BendingBoardManager;
import com.projectkorra.projectkorra.chiblocking.AcrobatStance;
import com.projectkorra.projectkorra.chiblocking.HighJump;
import com.projectkorra.projectkorra.chiblocking.Paralyze;
@ -137,10 +138,15 @@ import com.projectkorra.projectkorra.earthbending.metal.MetalClips;
import com.projectkorra.projectkorra.earthbending.passive.DensityShift;
import com.projectkorra.projectkorra.earthbending.passive.EarthPassive;
import com.projectkorra.projectkorra.earthbending.passive.FerroControl;
import com.projectkorra.projectkorra.event.BendingPlayerCreationEvent;
import com.projectkorra.projectkorra.event.EntityBendingDeathEvent;
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
import com.projectkorra.projectkorra.event.PlayerBindChangeEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent;
import com.projectkorra.projectkorra.event.PlayerJumpEvent;
import com.projectkorra.projectkorra.event.PlayerStanceChangeEvent;
import com.projectkorra.projectkorra.firebending.Blaze;
import com.projectkorra.projectkorra.firebending.BlazeRing;
import com.projectkorra.projectkorra.firebending.FireBlast;
@ -877,7 +883,7 @@ public class PKListener implements Listener {
new AirBurst(player, true);
}
}
CoreAbility gd = CoreAbility.getAbility(GracefulDescent.class);
CoreAbility ds = CoreAbility.getAbility(DensityShift.class);
CoreAbility hs = CoreAbility.getAbility(HydroSink.class);
@ -918,7 +924,7 @@ public class PKListener implements Listener {
}
CoreAbility hc = CoreAbility.getAbility(HeatControl.class);
if (hc != null && bPlayer.hasElement(Element.FIRE) && bPlayer.canBendPassive(hc) && bPlayer.canUsePassive(hc) && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) {
event.setCancelled(!HeatControl.canBurn(player));
}
@ -1236,6 +1242,7 @@ public class PKListener implements Listener {
@EventHandler
public void onPlayerChangeWorld(final PlayerChangedWorldEvent event) {
PassiveManager.registerPassives(event.getPlayer());
BendingBoardManager.forceToggleScoreboard(event.getPlayer());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -1349,6 +1356,8 @@ public class PKListener implements Listener {
final Player player = event.getPlayer();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
BendingBoardManager.clean(player);
if (ProjectKorra.isStatisticsEnabled()) {
Manager.getManager(StatisticsManager.class).store(player.getUniqueId());
}
@ -1531,6 +1540,8 @@ public class PKListener implements Listener {
new EarthTunnel(player);
} else if (abil.equalsIgnoreCase("Tremorsense")) {
bPlayer.toggleTremorSense();
GeneralMethods.displayMovePreview(player);
BendingBoardManager.updateAllSlots(player);
} else if (abil.equalsIgnoreCase("Extraction")) {
new Extraction(player);
} else if (abil.equalsIgnoreCase("LavaFlow")) {
@ -1579,15 +1590,18 @@ public class PKListener implements Listener {
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerSlotChange(final PlayerItemHeldEvent event) {
final Player player = event.getPlayer();
final int slot = event.getNewSlot() + 1;
if (ConfigManager.defaultConfig.get().getBoolean("Properties.BendingPreview")) {
GeneralMethods.displayMovePreview(player, slot);
if (!MultiAbilityManager.canChangeSlot(player, event.getNewSlot())) {
event.setCancelled(true);
return;
}
final int slot = event.getNewSlot() + 1;
GeneralMethods.displayMovePreview(player, slot);
BendingBoardManager.changeActiveSlot(player, event.getPreviousSlot(), event.getNewSlot());
if (ConfigManager.defaultConfig.get().getBoolean("Abilities.Water.WaterArms.DisplayBoundMsg")) {
final WaterArms waterArms = CoreAbility.getAbility(player, WaterArms.class);
if (waterArms != null) {
@ -1790,6 +1804,8 @@ public class PKListener implements Listener {
} else if (abil.equalsIgnoreCase("Illumination")) {
if (ConfigManager.defaultConfig.get().getBoolean("Abilities.Fire.Illumination.Passive")) {
bPlayer.toggleIllumination();
GeneralMethods.displayMovePreview(player);
BendingBoardManager.updateAllSlots(player);
} else {
new Illumination(player);
}
@ -1831,6 +1847,8 @@ public class PKListener implements Listener {
if (coreAbil instanceof AvatarAbility) {
if (abil.equalsIgnoreCase("AvatarState")) {
new AvatarState(player);
GeneralMethods.displayMovePreview(player);
BendingBoardManager.updateAllSlots(player);
}
}
}
@ -1902,26 +1920,26 @@ public class PKListener implements Listener {
event.setCancelled(true);
}
}
if (event.isCancelled()) {
return;
}
if (event.getEntity() instanceof LivingEntity) {
LivingEntity lent = (LivingEntity) event.getEntity();
if (TempArmor.hasTempArmor(lent)) {
TempArmor armor = TempArmor.getVisibleTempArmor(lent);
ItemStack is = event.getItem().getItemStack();
int index = GeneralMethods.getArmorIndex(is.getType());
if (index == -1) {
return;
}
event.setCancelled(true);
ItemStack prev = armor.getOldArmor()[index];
if (GeneralMethods.compareArmor(is.getType(), prev.getType()) > 0) {
event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), prev);
armor.getOldArmor()[index] = is;
@ -1969,6 +1987,53 @@ public class PKListener implements Listener {
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBendingElementChange(final PlayerChangeElementEvent event) {
final Player player = event.getTarget();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) return;
if (event.getResult() == PlayerChangeElementEvent.Result.CHOOSE || event.getResult() == PlayerChangeElementEvent.Result.REMOVE || event.getResult() == PlayerChangeElementEvent.Result.PERMAREMOVE) {
BendingBoardManager.updateAllSlots(player);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBendingSubElementChange(final PlayerChangeSubElementEvent event) {
final Player player = event.getTarget();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) return;
if (event.getResult() == PlayerChangeSubElementEvent.Result.CHOOSE || event.getResult() == PlayerChangeSubElementEvent.Result.REMOVE || event.getResult() == PlayerChangeSubElementEvent.Result.PERMAREMOVE) {
BendingBoardManager.updateAllSlots(player);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBindChange(final PlayerBindChangeEvent event) {
final Player player = event.getPlayer();
if (player == null) return;
BendingBoardManager.updateBoard(player, event.getAbility(), false, event.getSlot());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerStanceChange(final PlayerStanceChangeEvent event) {
final Player player = event.getPlayer();
if (player == null) return;
if (!event.getOldStance().isEmpty()) {
BendingBoardManager.updateBoard(player, event.getOldStance(), false, 0);
}
if (!event.getNewStance().isEmpty()) {
BendingBoardManager.updateBoard(player, event.getNewStance(), false, 0);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBendingPlayerCreation(final BendingPlayerCreationEvent event) {
final Player player = event.getBendingPlayer().getPlayer();
BendingBoardManager.canUseScoreboard(player);
}
public static HashMap<Player, String> getBendingPlayerDeath() {
return BENDING_PLAYER_DEATH;
}

View File

@ -22,6 +22,7 @@ import com.projectkorra.projectkorra.ability.util.ComboManager;
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager;
import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.airbending.util.AirbendingManager;
import com.projectkorra.projectkorra.board.BendingBoardManager;
import com.projectkorra.projectkorra.chiblocking.util.ChiblockingManager;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager;
@ -77,6 +78,7 @@ public class ProjectKorra extends JavaPlugin {
}
Manager.startup();
BendingBoardManager.setup();
this.getServer().getPluginManager().registerEvents(new PKListener(this), this);
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new BendingManager(), 0, 1);

View File

@ -90,6 +90,7 @@ public abstract class CoreAbility implements Ability {
private static final Map<Class<? extends CoreAbility>, Map<String, Field>> ATTRIBUTE_FIELDS = new HashMap<>();
private static int idCounter;
private static long currentTick;
protected Player player;
protected BendingPlayer bPlayer;
@ -149,7 +150,6 @@ public abstract class CoreAbility implements Ability {
this.startTime = System.currentTimeMillis();
this.started = false;
this.id = CoreAbility.idCounter;
this.startTick = this.getCurrentTick();
if (idCounter == Integer.MAX_VALUE) {
idCounter = Integer.MIN_VALUE;
@ -181,6 +181,7 @@ public abstract class CoreAbility implements Ability {
this.started = true;
this.startTime = System.currentTimeMillis();
this.startTick = getCurrentTick();
final Class<? extends CoreAbility> clazz = this.getClass();
final UUID uuid = this.player.getUniqueId();
@ -291,6 +292,7 @@ public abstract class CoreAbility implements Ability {
}
}
}
currentTick++;
}
/**
@ -745,8 +747,12 @@ public abstract class CoreAbility implements Ability {
return this.startTick;
}
public long getCurrentTick() {
return this.player.getWorld().getFullTime();
public static long getCurrentTick() {
return currentTick;
}
public long getRunningTicks() {
return currentTick - this.startTick;
}
public boolean isStarted() {
@ -828,7 +834,7 @@ public abstract class CoreAbility implements Ability {
public String getMovePreview(final Player player) {
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
String displayedMessage = getMovePreviewWithoutCooldownTimer(player);
String displayedMessage = getMovePreviewWithoutCooldownTimer(player, false);
if (bPlayer.isOnCooldown(this)) {
final long cooldown = bPlayer.getCooldown(this.getName()) - System.currentTimeMillis();
displayedMessage += this.getElement().getColor() + " - " + TimeUtil.formatTime(cooldown);
@ -837,18 +843,24 @@ public abstract class CoreAbility implements Ability {
return displayedMessage;
}
public String getMovePreviewWithoutCooldownTimer(final Player player) {
public String getMovePreviewWithoutCooldownTimer(final Player player, boolean forceCooldown) {
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
String displayedMessage = "";
if (bPlayer.isOnCooldown(this)) {
if (forceCooldown || bPlayer.isOnCooldown(this)) {
displayedMessage = this.getElement().getColor() + "" + ChatColor.STRIKETHROUGH + this.getName();
} else {
if (bPlayer.getStance() != null && bPlayer.getStance().getName().equals(this.getName())) {
boolean isActiveStance = bPlayer.getStance() != null && bPlayer.getStance().getName().equals(this.getName());
boolean isActiveAvatarState = bPlayer.isAvatarState() && this.getName().equals("AvatarState");
boolean isActiveIllumination = bPlayer.isIlluminating() && this.getName().equals("Illumination");
boolean isActiveTremorSense = bPlayer.isTremorSensing() && this.getName().equals("Tremorsense");
if (isActiveStance || isActiveAvatarState || isActiveIllumination || isActiveTremorSense) {
displayedMessage = this.getElement().getColor() + "" + ChatColor.UNDERLINE + this.getName();
} else {
displayedMessage = this.getElement().getColor() + this.getName();
}
}
return displayedMessage;
}

View File

@ -90,6 +90,14 @@ public abstract class EarthAbility extends ElementalAbility {
ParticleEffect.BLOCK_CRACK.display(collision.getLocationFirst(), 10, 1, 1, 1, 0.1, Material.DIRT.createBlockData());
}
}
public static boolean isBendableEarthTempBlock(final Block block) {
return isBendableEarthTempBlock(TempBlock.get(block));
}
public static boolean isBendableEarthTempBlock(final TempBlock tempBlock) {
return DensityShift.getSandBlocks().contains(tempBlock);
}
public static boolean isEarthbendable(final Material material, final boolean metal, final boolean sand, final boolean lava) {
return isEarth(material) || (metal && isMetal(material)) || (sand && isSand(material)) || (lava && isLava(material));
@ -128,7 +136,7 @@ public abstract class EarthAbility extends ElementalAbility {
}
public boolean moveEarth(Block block, final Vector direction, final int chainlength, final boolean throwplayer) {
if (!TempBlock.isTempBlock(block) && this.isEarthbendable(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
if ((!TempBlock.isTempBlock(block) || isBendableEarthTempBlock(block)) && this.isEarthbendable(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
boolean up = false;
boolean down = false;
final Vector norm = direction.clone().normalize();

View File

@ -87,7 +87,7 @@ public abstract class FireAbility extends ElementalAbility {
}
public double getDayFactor(final double value) {
return this.player != null ? value * getDayFactor() : 1;
return (this.player != null && isDay(player.getWorld())) ? value * getDayFactor() : value;
}
public static double getDayFactor() {

View File

@ -33,7 +33,6 @@ public class MultiAbilityManager {
waterArms.add(new MultiAbilityInfoSub("Freeze", Element.ICE));
waterArms.add(new MultiAbilityInfoSub("Spear", Element.ICE));
multiAbilityList.add(new MultiAbilityInfo("WaterArms", waterArms));
manage();
}
/**
@ -135,22 +134,7 @@ public class MultiAbilityManager {
return false;
}
if (playerAbilities.containsKey(player)) {
if (!playerBoundAbility.get(player).equals(multiAbility) && bPlayer.getBoundAbility() != null) {
return false;
}
return true;
}
return false;
}
public static void manage() {
new BukkitRunnable() {
@Override
public void run() {
scrollHotBarSlots();
}
}.runTaskTimer(ProjectKorra.plugin, 0, 1);
return playerAbilities.containsKey(player) && playerBoundAbility.get(player).equals(multiAbility);
}
/**
@ -176,24 +160,17 @@ public class MultiAbilityManager {
/**
* Keeps track of the player's selected slot while a MultiAbility is active.
*/
public static void scrollHotBarSlots() {
if (!playerAbilities.isEmpty()) {
for (final Player player : playerAbilities.keySet()) {
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) {
continue;
}
if (playerBoundAbility.containsKey(player)) {
if (bPlayer.getBoundAbility() == null) {
if (multiAbilityList.contains(getMultiAbility(playerBoundAbility.get(player)))) {
if (player.getInventory().getHeldItemSlot() >= getMultiAbility(playerBoundAbility.get(player)).getAbilities().size()) {
player.getInventory().setHeldItemSlot(getMultiAbility(playerBoundAbility.get(player)).getAbilities().size() - 1);
}
}
}
}
public static boolean canChangeSlot(final Player player, int slot) {
if (playerAbilities.isEmpty()) {
return true;
}
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer != null) {
if (bPlayer.getBoundAbility() == null && multiAbilityList.contains(getMultiAbility(playerBoundAbility.getOrDefault(player, "")))) {
return slot < getMultiAbility(playerBoundAbility.get(player)).getAbilities().size();
}
}
return true;
}
/**

View File

@ -54,7 +54,6 @@ public class AvatarState extends AvatarAbility {
playAvatarSound(player.getLocation());
this.start();
this.bPlayer.addCooldown(this, true);
if (this.duration != 0) {
START_TIMES.put(player.getName(), System.currentTimeMillis());
player.getUniqueId();
@ -79,6 +78,12 @@ public class AvatarState extends AvatarAbility {
this.addPotionEffects();
}
@Override
public void remove() {
this.bPlayer.addCooldown(this, true);
super.remove();
}
private void addPotionEffects() {
if (this.regenEnabled) {
this.addProgressPotionEffect(PotionEffectType.REGENERATION, this.regenPower);

View File

@ -0,0 +1,130 @@
package com.projectkorra.projectkorra.board;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Represents a player's scoreboard for bending purposes
*/
public class BendingBoardInstance {
private final String[] cachedSlots = new String[10];
private final Set<String> misc = new HashSet<>(); // Stores scoreboard scores for combos and misc abilities
private final Player player;
private final BendingPlayer bendingPlayer;
private final Scoreboard bendingBoard;
private final Objective bendingSlots;
private int selectedSlot;
public BendingBoardInstance(final BendingPlayer bPlayer) {
bendingPlayer = bPlayer;
player = bPlayer.getPlayer();
selectedSlot = player.getInventory().getHeldItemSlot() + 1;
bendingBoard = Bukkit.getScoreboardManager().getNewScoreboard();
String title = ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Board.Title"));
bendingSlots = bendingBoard.registerNewObjective("Board Slots", "dummy", title);
bendingSlots.setDisplaySlot(DisplaySlot.SIDEBAR);
player.setScoreboard(bendingBoard);
Arrays.fill(cachedSlots, "");
updateAll();
}
public void disableScoreboard() {
bendingBoard.clearSlot(DisplaySlot.SIDEBAR);
bendingSlots.unregister();
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
}
private void setSlot(int slot, String name, boolean cooldown) {
if (slot < 1 || slot > 9 || !player.getScoreboard().equals(bendingBoard)) return;
String prefix = ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Board.SelectionPrefix"));
StringBuilder sb = new StringBuilder(slot == selectedSlot ? prefix : String.join("", Collections.nCopies(ChatColor.stripColor(prefix).length(), " ")));
if (name == null || name.isEmpty()) {
String emptySlot = ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Board.EmptySlot").replaceAll("\\{slot_number\\}", "" + slot));
sb.append(emptySlot);
} else {
CoreAbility coreAbility = CoreAbility.getAbility(ChatColor.stripColor(name));
if (coreAbility == null) { // MultiAbility
if (cooldown || bendingPlayer.isOnCooldown(name)) sb.append(ChatColor.STRIKETHROUGH);
sb.append(name);
} else {
sb.append(coreAbility.getMovePreviewWithoutCooldownTimer(player, cooldown));
}
}
sb.append(ChatColor.values()[slot].toString()); // Unique suffix
if (!cachedSlots[slot].equals(sb.toString())) {
bendingBoard.resetScores(cachedSlots[slot]);
}
cachedSlots[slot] = sb.toString();
bendingSlots.getScore(sb.toString()).setScore(-slot);
}
public void updateAll() {
final Map<Integer, String> boundAbilities = new HashMap<>(bendingPlayer.getAbilities());
for (int i = 1; i <= 9; i++) {
setSlot(i, boundAbilities.getOrDefault(i, ""), false);
}
}
public void clearSlot(int slot) {
setSlot(slot, null, false);
}
public void setActiveSlot(int oldSlot, int newSlot) {
if (selectedSlot != oldSlot) {
oldSlot = selectedSlot; // Fixes bug when slot is set using setHeldItemSlot
}
selectedSlot = newSlot;
setSlot(oldSlot, bendingPlayer.getAbilities().getOrDefault(oldSlot, ""), false);
setSlot(newSlot, bendingPlayer.getAbilities().getOrDefault(newSlot, ""), false);
}
public void setAbility(String name, boolean cooldown) {
final Map<Integer, String> boundAbilities = bendingPlayer.getAbilities();
boundAbilities.keySet().stream().filter(key -> name.equals(boundAbilities.get(key))).forEach(slot -> setSlot(slot, name, cooldown));
}
public void updateMisc(String text, boolean show, boolean isCombo) {
String selection = ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Board.SelectionPrefix"));
String prefix = String.join("", Collections.nCopies(ChatColor.stripColor(selection).length(), " "));
String miscSeparator = ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Board.MiscSeparator"));
String alignedText = prefix + text;
if (show) {
if (misc.isEmpty()) {
bendingSlots.getScore(miscSeparator).setScore(-10);
}
misc.add(alignedText);
bendingSlots.getScore(alignedText).setScore(isCombo ? -11 : -12);
} else {
misc.remove(alignedText);
bendingBoard.resetScores(alignedText);
if (misc.isEmpty()) {
bendingBoard.resetScores(miscSeparator);
}
}
}
}

View File

@ -0,0 +1,200 @@
package com.projectkorra.projectkorra.board;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.ComboManager;
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.storage.DBConnection;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
* Manages every individual {@link BendingBoardInstance}
*/
public class BendingBoardManager {
private static final Set<String> disabledWorlds = new HashSet<>();
private static final Map<String, ChatColor> trackedCooldowns = new ConcurrentHashMap<>();
private static final Set<UUID> disabledPlayers = Collections.synchronizedSet(new HashSet<>());
private static final Map<Player, BendingBoardInstance> scoreboardPlayers = new ConcurrentHashMap<>();
private static boolean enabled;
public static void setup() {
initialize(true);
Bukkit.getOnlinePlayers().forEach(BendingBoardManager::canUseScoreboard);
}
public static void reload() {
scoreboardPlayers.values().forEach(BendingBoardInstance::disableScoreboard);
scoreboardPlayers.clear();
initialize(false);
}
private static void initialize(boolean initial) {
if (initial) loadDisabledPlayers();
enabled = ConfigManager.getConfig().getBoolean("Properties.BendingBoard");
disabledWorlds.clear();
disabledWorlds.addAll(ConfigManager.getConfig().getStringList("Properties.DisabledWorlds"));
}
/**
* Force toggle the scoreboard for when a player changes worlds (for example when teleporting to a world where bending is disabled)
* @param player
*/
public static void forceToggleScoreboard(Player player) {
if (disabledWorlds.contains(player.getWorld().getName())) {
if (scoreboardPlayers.containsKey(player)) {
scoreboardPlayers.get(player).disableScoreboard();
scoreboardPlayers.remove(player);
}
} else {
canUseScoreboard(player);
}
}
public static void toggleScoreboard(Player player) {
if (!enabled || disabledWorlds.contains(player.getWorld().getName())) {
GeneralMethods.sendBrandingMessage(player, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Board.Disabled"));
return;
}
if (scoreboardPlayers.containsKey(player)) {
scoreboardPlayers.get(player).disableScoreboard();
disabledPlayers.add(player.getUniqueId());
scoreboardPlayers.remove(player);
GeneralMethods.sendBrandingMessage(player, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Board.ToggledOff"));
} else {
disabledPlayers.remove(player.getUniqueId());
canUseScoreboard(player);
GeneralMethods.sendBrandingMessage(player, ChatColor.GREEN + ConfigManager.languageConfig.get().getString("Commands.Board.ToggledOn"));
}
}
/**
* Checks if a player can use the bending board and creates a BendingBoardInstance if possible.
* @param player the player to check
* @return true if player can use the bending board, false otherwise
*/
public static boolean canUseScoreboard(Player player) {
if (!enabled || disabledPlayers.contains(player.getUniqueId()) || disabledWorlds.contains(player.getWorld().getName())) {
return false;
}
if (!player.isOnline()) {
return false;
}
if (!scoreboardPlayers.containsKey(player)) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) {
return false;
}
scoreboardPlayers.put(player, new BendingBoardInstance(bPlayer));
}
return true;
}
public static void updateAllSlots(Player player) {
if (canUseScoreboard(player)) {
scoreboardPlayers.get(player).updateAll();
}
}
public static void updateBoard(Player player, String abilityName, boolean cooldown, int slot) {
if (canUseScoreboard(player)) {
if (abilityName == null || abilityName.isEmpty()) {
scoreboardPlayers.get(player).clearSlot(slot);
return;
}
if (MultiAbilityManager.hasMultiAbilityBound(player)) {
scoreboardPlayers.get(player).updateAll();
return;
}
CoreAbility coreAbility = CoreAbility.getAbility(abilityName);
if (coreAbility != null && ComboManager.getComboAbilities().containsKey(abilityName)) {
scoreboardPlayers.get(player).updateMisc("" + coreAbility.getElement().getColor() + ChatColor.STRIKETHROUGH + abilityName, cooldown, true);
return;
} else if (coreAbility == null && trackedCooldowns.containsKey(abilityName)) {
scoreboardPlayers.get(player).updateMisc("" + trackedCooldowns.get(abilityName) + ChatColor.STRIKETHROUGH + abilityName, cooldown, false);
return;
}
scoreboardPlayers.get(player).setAbility(abilityName, cooldown);
}
}
public static void changeActiveSlot(Player player, int oldSlot, int newSlot) {
if (canUseScoreboard(player)) {
scoreboardPlayers.get(player).setActiveSlot(++oldSlot, ++newSlot);
}
}
/**
* Some abilities use internal cooldowns with custom names that don't correspond to bound abilities' names.
* Adds the internal cooldown name and color to the map of tracked abilities so as they can appear on the bending board.
* @param cooldownName the internal cooldown name
* @param color the color to use when rendering the board entry
*/
public static void addCooldownToTrack(String cooldownName, ChatColor color) {
trackedCooldowns.put(cooldownName, color);
}
/**
* Load into memory the list of players who have toggled the bending board off.
*/
public static void loadDisabledPlayers() {
Bukkit.getScheduler().runTaskAsynchronously(ProjectKorra.plugin, () -> {
Set<UUID> disabled = new HashSet<>();
try {
final ResultSet rs = DBConnection.sql.readQuery("SELECT uuid FROM pk_board where enabled = 0");
while (rs.next()) disabled.add(UUID.fromString(rs.getString("uuid")));
} catch (SQLException e) {
e.printStackTrace();
}
disabledPlayers.clear();
disabledPlayers.addAll(disabled);
});
}
/**
* Called on player logout
* Removes the board instance and stores the player's toggle preference for the bending board in the database
* @param player
*/
public static void clean(final Player player) {
scoreboardPlayers.remove(player);
final UUID uuid = player.getUniqueId();
final String updateQuery = "UPDATE pk_board SET enabled = " + (disabledPlayers.contains(uuid) ? 0 : 1) + " WHERE uuid = ?";
Bukkit.getScheduler().runTaskAsynchronously(ProjectKorra.plugin, () -> {
try {
PreparedStatement ps = DBConnection.sql.getConnection().prepareStatement("SELECT enabled FROM pk_board where uuid = ? LIMIT 1");
ps.setString(1, uuid.toString());
PreparedStatement ps2;
if (!ps.executeQuery().next()) { // if the entry doesn't exist in the DB, create it.
ps2 = DBConnection.sql.getConnection().prepareStatement("INSERT INTO pk_board (uuid, enabled) VALUES (?, 1)");
} else { // if the entry exists in the DB, update it
ps2 = DBConnection.sql.getConnection().prepareStatement(updateQuery);
}
ps2.setString(1, uuid.toString());
ps2.execute();
} catch (SQLException e) {
e.printStackTrace();
}
});
}
}

View File

@ -7,7 +7,6 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.attribute.Attribute;
@ -48,7 +47,6 @@ public class AcrobatStance extends ChiAbility {
}
this.start();
this.bPlayer.setStance(this);
GeneralMethods.displayMovePreview(player);
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_HURT, 0.5F, 2F);
}
@ -75,7 +73,6 @@ public class AcrobatStance extends ChiAbility {
super.remove();
this.bPlayer.addCooldown(this);
this.bPlayer.setStance(null);
GeneralMethods.displayMovePreview(this.player);
this.player.playSound(this.player.getLocation(), Sound.ENTITY_ENDER_DRAGON_SHOOT, 0.5F, 2F);
this.player.removePotionEffect(PotionEffectType.SPEED);
this.player.removePotionEffect(PotionEffectType.JUMP);

View File

@ -7,7 +7,6 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.attribute.Attribute;
@ -42,7 +41,6 @@ public class WarriorStance extends ChiAbility {
}
this.start();
this.bPlayer.setStance(this);
GeneralMethods.displayMovePreview(player);
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_HURT, 0.5F, 2F);
}
@ -70,7 +68,6 @@ public class WarriorStance extends ChiAbility {
this.bPlayer.addCooldown(this);
this.bPlayer.setStance(null);
if (this.player != null) {
GeneralMethods.displayMovePreview(this.player);
this.player.playSound(this.player.getLocation(), Sound.ENTITY_ENDER_DRAGON_SHOOT, 0.5F, 2F);
this.player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
this.player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);

View File

@ -0,0 +1,27 @@
package com.projectkorra.projectkorra.command;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.board.BendingBoardManager;
import com.projectkorra.projectkorra.configuration.ConfigManager;
/**
* Executor for /bending board. Extends {@link PKCommand}.
*/
public class BoardCommand extends PKCommand {
public BoardCommand() {
super("board", "/bending board", ConfigManager.languageConfig.get().getString("Commands.Board.Description"), new String[]{ "bendingboard", "board", "bb" });
}
@Override
public void execute(final CommandSender sender, final List<String> args) {
if (!this.hasPermission(sender) || !this.isPlayer(sender) || !this.correctLength(sender, args.size(), 0, 0)) {
return;
}
BendingBoardManager.toggleScoreboard((Player) sender);
}
}

View File

@ -170,7 +170,8 @@ public class ChooseCommand extends PKCommand {
GeneralMethods.sendBrandingMessage(target, color + this.chosenCFW.replace("{element}", sub.getName() + sub.getType().getBender()));
}
GeneralMethods.saveSubElements(bPlayer);
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, target, sub, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.CHOOSE));
GeneralMethods.removeUnusableAbilities(target.getName());
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, target, sub, PlayerChangeSubElementEvent.Result.CHOOSE));
} else {
bPlayer.setElement(element);
bPlayer.getSubElements().clear();
@ -196,11 +197,9 @@ public class ChooseCommand extends PKCommand {
}
GeneralMethods.saveElements(bPlayer);
GeneralMethods.saveSubElements(bPlayer);
GeneralMethods.removeUnusableAbilities(target.getName());
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE));
}
GeneralMethods.removeUnusableAbilities(target.getName());
}
public static boolean isVowel(final char c) {

View File

@ -80,6 +80,7 @@ public class Commands {
new AddCommand();
new BindCommand();
new CheckCommand();
new BoardCommand();
new ChooseCommand();
new ClearCommand();
new CopyCommand();

View File

@ -13,6 +13,7 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.board.BendingBoardManager;
import com.projectkorra.projectkorra.configuration.ConfigManager;
public class CopyCommand extends PKCommand {
@ -107,6 +108,7 @@ public class CopyCommand extends PKCommand {
}
}
target.setAbilities(abilities);
BendingBoardManager.updateAllSlots(player2);
return boundAll;
}

View File

@ -132,7 +132,11 @@ public class PresetCommand extends PKCommand {
} else if (Arrays.asList(bindaliases).contains(args.get(0)) && this.hasPermission(sender, "bind")) { // bending preset bind name.
if (args.size() < 3) {
boolean boundAll = false;
if (Preset.presetExists(player, name)) {
if (name == null) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.invalidName);
return;
} else if (Preset.presetExists(player, name)) {
final Preset preset = Preset.getPreset(player, name);
GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + this.bound.replace("{name}", ChatColor.YELLOW + preset.getName() + ChatColor.GREEN));

View File

@ -43,11 +43,6 @@ public class ConfigManager {
} else if (type == ConfigType.LANGUAGE) {
config = languageConfig.get();
final ArrayList<String> helpLines = new ArrayList<String>();
helpLines.add("&c/bending help [Ability/Command] &eDisplay help.");
helpLines.add("&c/bending choose [Element] &eChoose an element.");
helpLines.add("&c/bending bind [Ability] # &eBind an ability.");
config.addDefault("Chat.Enable", true);
config.addDefault("Chat.Format", "<name>: <message>");
config.addDefault("Chat.Colors.Avatar", "DARK_PURPLE");
@ -77,6 +72,11 @@ public class ConfigManager {
config.addDefault("Chat.Prefixes.Avatar", "[Avatar]");
config.addDefault("Chat.Prefixes.Nonbender", "[Nonbender]");
config.addDefault("Board.Title", "&lAbilities");
config.addDefault("Board.SelectionPrefix", "> &r");
config.addDefault("Board.EmptySlot", "&8-- Slot {slot_number} --");
config.addDefault("Board.MiscSeparator", " ------------");
config.addDefault("Extras.Water.NightMessage", "Your waterbending has become empowered due to the moon rising.");
config.addDefault("Extras.Water.DayMessage", "You feel the empowering of your waterbending subside as the moon sets.");
config.addDefault("Extras.Fire.NightMessage", "You feel the empowering of your firebending subside as the sun sets.");
@ -180,6 +180,11 @@ public class ConfigManager {
config.addDefault("Commands.Debug.Description", "Outputs information on the current ProjectKorra installation to /plugins/ProjectKorra/debug.txt");
config.addDefault("Commands.Debug.SuccessfullyExported", "Debug File Created as debug.txt in the ProjectKorra plugin folder.\nPut contents on pastie.org and create a bug report on the ProjectKorra forum if you need to.");
config.addDefault("Commands.Board.Description", "Toggle bending board visibility.");
config.addDefault("Commands.Board.Disabled", "Bending board is disabled.");
config.addDefault("Commands.Board.ToggledOn", "You have made your bending board visible again.");
config.addDefault("Commands.Board.ToggledOff", "You have hidden your bending board.");
config.addDefault("Commands.Copy.Description", "This command will allow the user to copy the binds of another player either for himself or assign them to <Player> if specified.");
config.addDefault("Commands.Copy.PlayerNotFound", "Couldn't find player.");
config.addDefault("Commands.Copy.SuccessfullyCopied", "Your binds have been set to match {target}'s!");
@ -252,7 +257,7 @@ public class ConfigManager {
config.addDefault("Abilities.Air.AirScooter.Instructions", "Sprint, jump, and left click while in the air to activate air scooter. You will then move forward in the direction you're looking.");
config.addDefault("Abilities.Air.Tornado.Description", "Tornado is one of the most powerful and advanced abilities that an Airbender knows. If the tornado meets a player or mob, it will push them around. Tornado can also be used to push back projectiles and used for mobility. Use a tornado directly under you to propel yourself upwards.");
config.addDefault("Abilities.Air.Tornado.Instructions", "Hold sneak and a tornado will form gradually wherever you look.");
config.addDefault("Abilities.Air.AirShield.Description", "Air Shield is one of the most powerful defensive techniques in existence. This ability is mainly used when you are low health and need protection. It's also useful when you're surrounded by mobs.");
config.addDefault("Abilities.Air.AirShield.Description", "AirShield is one of the most powerful defensive techniques in existence. This ability is mainly used when you are low health and need protection. It's also useful when you're surrounded by mobs.");
config.addDefault("Abilities.Air.AirShield.Instructions", "Hold sneak and a shield of air will form around you, blocking projectiles and pushing entities back.");
config.addDefault("Abilities.Air.AirSpout.Description", "This ability gives the airbender limited sustained levitation. It allows an airbender to gain a height advantage to escape from mobs, players or just to dodge from attacks. This ability is also useful for building as it allows you to reach great heights.");
config.addDefault("Abilities.Air.AirSpout.Instructions", "Left click to activate a spout beneath you and hold spacebar to go higher. If you wish to go lower, simply hold sneak. To disable this ability, left click once again.");
@ -357,7 +362,7 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.Tremorsense.Description", "This is a pure utility ability for earthbenders. If you are in an area of low-light and are standing on top of an earthbendable block, this ability will automatically turn that block into glowstone, visible *only by you*. If you lose contact with a bendable block, the light will go out as you have lost contact with the earth and cannot 'see' until you can touch earth again. Additionally, if you click with this ability selected, smoke will appear above nearby earth with pockets of air beneath them.");
config.addDefault("Abilities.Earth.Tremorsense.Instructions", "Simply left click while on an earthbendable block.");
config.addDefault("Abilities.Earth.Combo.EarthDome.Description", "EarthDome allows earthbenders to surround themselves or another entity in earth, temporarily preventing anything from entering or escaping the dome.");
config.addDefault("Abilities.Earth.Combo.EarthDome.Instructions", "(Self) RaiseEarth (Right click) > Shockwave (Right click)\\n(Projection) RaiseEarth(Right click) > Shockwave (Left click)");
config.addDefault("Abilities.Earth.Combo.EarthDome.Instructions", "(Self) RaiseEarth (Right click) > Shockwave (Right click)" + "\n" + "(Projection) RaiseEarth (Right click) > Shockwave (Left click)");
config.addDefault("Abilities.Earth.Combo.EarthPillars.Description", "Send players and entities flying into the air and possibly stunning them by raising pillars of earth under their feet, dealing damage initally as well. This combo can also be used by falling from high off the ground and landing while on the Catapult ability");
config.addDefault("Abilities.Earth.Combo.EarthPillars.Instructions", "Shockwave (Tap sneak) > Shockwave (Hold sneak) > Catapult (Release sneak)");
config.addDefault("Abilities.Earth.Passive.DensityShift.Description", "DensityShift is a passive ability which allows earthbenders to make a firm landing negating all fall damage on any earthbendable surface.");
@ -555,6 +560,7 @@ public class ConfigManager {
config.addDefault("Properties.UpdateChecker", true);
config.addDefault("Properties.Statistics", true);
config.addDefault("Properties.DatabaseCooldowns", true);
config.addDefault("Properties.BendingBoard", true);
config.addDefault("Properties.BendingPreview", true);
config.addDefault("Properties.BendingAffectFallingSand.Normal", true);
config.addDefault("Properties.BendingAffectFallingSand.NormalStrengthMultiplier", 1.0);
@ -580,7 +586,8 @@ public class ConfigManager {
config.addDefault("Properties.RegionProtection.RespectLWC", true);
config.addDefault("Properties.RegionProtection.Residence.Flag", "bending");
config.addDefault("Properties.RegionProtection.Residence.Respect", true);
config.addDefault("Properties.RegionProtection.RespectKingdoms", true);
config.addDefault("Properties.RegionProtection.Kingdoms.Respect", true);
config.addDefault("Properties.RegionProtection.Kingdoms.ProtectDuringInvasions", false);
config.addDefault("Properties.RegionProtection.RespectPlotSquared", true);
config.addDefault("Properties.RegionProtection.RespectRedProtect", true);
config.addDefault("Properties.RegionProtection.CacheBlockTime", 5000);
@ -652,7 +659,7 @@ public class ConfigManager {
config.addDefault("Properties.Fire.BlueFire.DamageFactor", 1.1);
config.addDefault("Properties.Fire.BlueFire.CooldownFactor", .9);
config.addDefault("Properties.Fire.BlueFire.RangeFactor", 1.2);
config.addDefault("Properties.Chi.CanBendWithWeapons", true);
final ArrayList<String> disabledWorlds = new ArrayList<String>();
@ -1293,6 +1300,7 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.EarthSmash.Grab.DetectionRadius", 2.5);
config.addDefault("Abilities.Earth.EarthSmash.Shoot.Range", 25);
config.addDefault("Abilities.Earth.EarthSmash.Shoot.AnimationInterval", 25);
config.addDefault("Abilities.Earth.EarthSmash.Shoot.CollisionRadius", 2.5);
config.addDefault("Abilities.Earth.EarthSmash.RequiredBendableBlocks", 11);
config.addDefault("Abilities.Earth.EarthSmash.MaxBlocksToPassThrough", 3);
config.addDefault("Abilities.Earth.EarthSmash.LiftAnimationInterval", 30);

View File

@ -84,6 +84,10 @@ public class EarthArmor extends EarthAbility {
if (!this.moveBlocks()) {
return;
}
if ((TempBlock.isTempBlock(oldHeadBlock) && !isBendableEarthTempBlock(oldHeadBlock))
|| (TempBlock.isTempBlock(oldLegsBlock) && !isBendableEarthTempBlock(oldLegsBlock))) {
return;
}
if (isEarthRevertOn()) {
addTempAirBlock(oldHeadBlock);
addTempAirBlock(oldLegsBlock);

View File

@ -156,7 +156,7 @@ public class EarthBlast extends EarthAbility {
final Block block = BlockSource.getEarthSourceBlock(this.player, this.range, ClickType.SHIFT_DOWN);
if (block == null || !this.isEarthbendable(block)) {
return false;
} else if (TempBlock.isTempBlock(block)) {
} else if (TempBlock.isTempBlock(block) && !EarthAbility.isBendableEarthTempBlock(block)) {
return false;
}

View File

@ -74,7 +74,7 @@ public class EarthGrab extends EarthAbility {
return;
}
if (this.bPlayer.isOnCooldown(this)) {
if (bPlayer != null && this.bPlayer.isOnCooldown(this)) { //bPlayer can be null if the ability is disabled. If it is, it just won't start()
return;
}

View File

@ -68,6 +68,7 @@ public class EarthSmash extends EarthAbility {
private double flightSpeed;
private double grabbedDistance;
private double grabDetectionRadius;
private double hitRadius;
private double flightDetectionRadius;
private State state;
private Block origin;
@ -147,6 +148,7 @@ public class EarthSmash extends EarthAbility {
this.liftAnimationInterval = getConfig().getLong("Abilities.Earth.EarthSmash.LiftAnimationInterval");
this.grabDetectionRadius = getConfig().getDouble("Abilities.Earth.EarthSmash.Grab.DetectionRadius");
this.flightDetectionRadius = getConfig().getDouble("Abilities.Earth.EarthSmash.Flight.DetectionRadius");
this.hitRadius = getConfig().getDouble("Abilities.Earth.EarthSmash.Shoot.CollisionRadius");
this.allowGrab = getConfig().getBoolean("Abilities.Earth.EarthSmash.Grab.Enabled");
this.allowFlight = getConfig().getBoolean("Abilities.Earth.EarthSmash.Flight.Enabled");
this.selectRange = getConfig().getDouble("Abilities.Earth.EarthSmash.SelectRange");
@ -201,6 +203,9 @@ public class EarthSmash extends EarthAbility {
if (this.origin == null) {
this.remove();
return;
} else if (TempBlock.isTempBlock(this.origin) && !isBendableEarthTempBlock(this.origin)) {
this.remove();
return;
}
this.bPlayer.addCooldown(this);
this.location = this.origin.getLocation();
@ -563,7 +568,7 @@ public class EarthSmash extends EarthAbility {
* already been shot.
*/
public void shootingCollisionDetection() {
final List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(this.location, this.flightDetectionRadius);
final List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(this.location, this.hitRadius);
for (final Entity entity : entities) {
if (entity instanceof LivingEntity && entity != this.player && !this.affectedEntities.contains(entity)) {
if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) {

View File

@ -102,7 +102,7 @@ public class RaiseEarth extends EarthAbility {
private boolean canInstantiate() {
for (final Block block : this.affectedBlocks.keySet()) {
if (!this.isEarthbendable(block) || TempBlock.isTempBlock(block)) {
if (!this.isEarthbendable(block) || (TempBlock.isTempBlock(block) && !EarthAbility.isBendableEarthTempBlock(block))) {
return false;
}
}

View File

@ -0,0 +1,41 @@
package com.projectkorra.projectkorra.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerStanceChangeEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final Player player;
private final String oldStance;
private final String newStance;
public PlayerStanceChangeEvent(final Player player, final String oldStance, final String newStance) {
this.player = player;
this.oldStance = oldStance;
this.newStance = newStance;
}
public Player getPlayer() {
return this.player;
}
public String getOldStance() {
return this.oldStance;
}
public String getNewStance() {
return this.newStance;
}
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -110,14 +110,14 @@ public class FireBlast extends FireAbility {
}
private void applyModifiers(double damage, double range) {
int damageMod = 0;
int rangeMod = 0;
double damageMod = 0;
double rangeMod = 0;
damageMod = (int) (this.getDayFactor(damage) - damage);
rangeMod = (int) (this.getDayFactor(range) - range);
damageMod = this.getDayFactor(damage) - damage;
rangeMod = this.getDayFactor(range) - range;
damageMod = (int) (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getDamageFactor() * damage - damage) + damageMod : damageMod);
rangeMod = (int) (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getRangeFactor() * range - range) + rangeMod : rangeMod);
damageMod = bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getDamageFactor() * damage - damage) + damageMod : damageMod;
rangeMod = bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getRangeFactor() * range - range) + rangeMod : rangeMod;
this.range += rangeMod;
this.damage += damageMod;
@ -166,6 +166,10 @@ public class FireBlast extends FireAbility {
}
public boolean checkLocation(Block block) {
if (block.isLiquid()) {
this.remove();
return false;
}
if (!block.isPassable()) {
if (block.getType() == Material.FURNACE && this.powerFurnace) {
final Furnace furnace = (Furnace) block.getState();

View File

@ -89,18 +89,18 @@ public class FireBlastCharged extends FireAbility {
private void applyModifiers() {
long chargeTimeMod = 0;
int damageMod = 0;
int rangeMod = 0;
double damageMod = 0;
double rangeMod = 0;
if (isDay(player.getWorld())) {
chargeTimeMod = (long) (this.chargeTime / getDayFactor()) - this.chargeTime;
damageMod = (int) (this.getDayFactor(this.maxDamage) - this.maxDamage);
rangeMod = (int) (this.getDayFactor(this.range) - this.range);
chargeTimeMod = (long) (this.chargeTime / getDayFactor() - this.chargeTime);
damageMod = this.getDayFactor(this.maxDamage) - this.maxDamage;
rangeMod = this.getDayFactor(this.range) - this.range;
}
chargeTimeMod = (long) (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (chargeTime / BlueFireAbility.getCooldownFactor() - chargeTime) + chargeTimeMod : chargeTimeMod);
damageMod = (int) (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getDamageFactor() * maxDamage - maxDamage) + damageMod : damageMod);
rangeMod = (int) (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getRangeFactor() * range - range) + rangeMod : rangeMod);
damageMod = (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getDamageFactor() * maxDamage - maxDamage) + damageMod : damageMod);
rangeMod = (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getRangeFactor() * range - range) + rangeMod : rangeMod);
if (this.bPlayer.isAvatarState()) {
this.chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Fire.FireBlast.Charged.ChargeTime");

View File

@ -73,16 +73,16 @@ public class WallOfFire extends FireAbility {
this.origin = GeneralMethods.getTargetedLocation(player, this.range);
int widthMod = 0;
int heightMod = 0;
double widthMod = 0;
double heightMod = 0;
long durationMod = 0;
int damageMod = 0;
double damageMod = 0;
if (isDay(player.getWorld())) {
widthMod = (int) this.getDayFactor(this.width) - this.width;
heightMod = (int) this.getDayFactor(this.height) - this.height;
widthMod = this.getDayFactor(this.width) - this.width;
heightMod = this.getDayFactor(this.height) - this.height;
durationMod = ((long) this.getDayFactor(this.duration) - this.duration);
damageMod = (int) (this.getDayFactor(this.damage) - this.damage);
damageMod = this.getDayFactor(this.damage) - this.damage;
}
widthMod = (int) (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getRangeFactor() * width - width) + widthMod : widthMod);

View File

@ -94,7 +94,15 @@ public class FireComboStream extends BukkitRunnable {
}
this.location.add(this.direction.normalize().multiply(this.speed));
if (this.initialLocation.distanceSquared(this.location) > this.distance * this.distance) {
try {
this.location.checkFinite();
} catch (IllegalArgumentException e) {
this.remove();
return;
}
if (this.initialLocation.distanceSquared(this.location) > this.distance * this.distance || !Double.isFinite(this.collisionRadius)) {
this.remove();
return;
} else if (this.collides && this.checkCollisionCounter % this.checkCollisionDelay == 0) {

View File

@ -17,6 +17,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.board.BendingBoardManager;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.storage.DBConnection;
@ -146,6 +147,7 @@ public class Preset {
}
}
bPlayer.setAbilities(abilities);
BendingBoardManager.updateAllSlots(player);
return boundAll;
}
@ -256,6 +258,7 @@ public class Preset {
}
}
bPlayer.setAbilities(abilities);
BendingBoardManager.updateAllSlots(player);
return boundAll;
}
return false;

View File

@ -68,6 +68,11 @@ public class DBConnection {
final String query = "CREATE TABLE `pk_cooldowns` (uuid VARCHAR(36) NOT NULL, cooldown_id INTEGER NOT NULL, value BIGINT, PRIMARY KEY (uuid, cooldown_id));";
sql.modifyQuery(query, false);
}
if (!sql.tableExists("pk_board")) {
ProjectKorra.log.info("Creating pk_board table");
final String query = "CREATE TABLE `pk_board` (uuid VARCHAR(36) NOT NULL, enabled BOOLEAN NOT NULL, PRIMARY KEY (uuid));";
sql.modifyQuery(query, false);
}
} else {
sql = new SQLite(ProjectKorra.log, "Establishing SQLite Connection.", "projectkorra.db", ProjectKorra.plugin.getDataFolder().getAbsolutePath());
if (((SQLite) sql).open() == null) {
@ -112,6 +117,11 @@ public class DBConnection {
final String query = "CREATE TABLE `pk_cooldowns` (uuid TEXT(36) NOT NULL, cooldown_id INTEGER NOT NULL, value BIGINT, PRIMARY KEY (uuid, cooldown_id));";
sql.modifyQuery(query, false);
}
if (!sql.tableExists("pk_board")) {
ProjectKorra.log.info("Creating pk_board table");
final String query = "CREATE TABLE `pk_board` (uuid TEXT(36) NOT NULL, enabled INTEGER NOT NULL, PRIMARY KEY (uuid));";
sql.modifyQuery(query, false);
}
}
}

View File

@ -161,7 +161,7 @@ public class BlockSource {
public static Block getSourceBlock(final Player player, final double range, final BlockSourceType sourceType, final ClickType clickType) {
final BlockSourceInformation info = getValidBlockSourceInformation(player, range, sourceType, clickType);
if (info != null) {
if (TempBlock.isTempBlock(info.getBlock()) && !WaterAbility.isBendableWaterTempBlock(info.getBlock())) {
if (TempBlock.isTempBlock(info.getBlock()) && !WaterAbility.isBendableWaterTempBlock(info.getBlock()) && !EarthAbility.isBendableEarthTempBlock(info.getBlock())) {
return null;
}
return info.getBlock();

View File

@ -53,7 +53,7 @@ public class TempBlock {
public TempBlock(final Block block, final BlockData newData, final long revertTime) {
this.block = block;
this.newData = newData;
this.setRevertTime(revertTime);
if (instances.containsKey(block)) {
final TempBlock temp = instances.get(block);
if (!newData.equals(temp.block.getBlockData())) {
@ -64,12 +64,15 @@ public class TempBlock {
instances.put(block, temp);
} else {
this.state = block.getState();
if (this.state instanceof Container || this.state.getType() == Material.JUKEBOX) {
return;
}
instances.put(block, this);
block.setBlockData(newData, GeneralMethods.isLightEmitting(newData.getMaterial()));
}
this.setRevertTime(revertTime);
}
public static TempBlock get(final Block block) {
@ -166,7 +169,7 @@ public class TempBlock {
}
public void setRevertTime(final long revertTime) {
if(revertTime <= 0) {
if(revertTime <= 0 || state instanceof Container) {
return;
}

View File

@ -364,7 +364,7 @@ public class WaterManipulation extends WaterAbility {
AFFECTED_BLOCKS.put(block, block);
}
if (PhaseChange.getFrozenBlocksAsBlock().contains(block)) {
PhaseChange.getFrozenBlocksAsBlock().remove(block);
PhaseChange.thaw(block);
}
new TempBlock(block, Material.WATER);
} else {

View File

@ -46,6 +46,7 @@ public class PhaseChange extends IceAbility {
private final List<PhaseChangeType> active_types = new ArrayList<>();
private static Map<TempBlock, Player> PLAYER_BY_BLOCK = new HashMap<>();
private static List<Block> BLOCKS = new ArrayList<>();
private final CopyOnWriteArrayList<TempBlock> blocks = new CopyOnWriteArrayList<>();
private final Random r = new Random();
@ -99,10 +100,12 @@ public class PhaseChange extends IceAbility {
tb.revertBlock();
this.blocks.remove(tb);
PLAYER_BY_BLOCK.remove(tb);
BLOCKS.remove(tb.getBlock());
} else if (tb.getLocation().distanceSquared(this.player.getLocation()) > (this.controlRadius * this.controlRadius)) {
tb.revertBlock();
this.blocks.remove(tb);
PLAYER_BY_BLOCK.remove(tb);
BLOCKS.remove(tb.getBlock());
}
}
}
@ -129,10 +132,12 @@ public class PhaseChange extends IceAbility {
tb.revertBlock();
this.blocks.remove(tb);
PLAYER_BY_BLOCK.remove(tb);
BLOCKS.remove(tb.getBlock());
} else if (tb.getLocation().distanceSquared(this.player.getLocation()) > (this.controlRadius * this.controlRadius)) {
tb.revertBlock();
this.blocks.remove(tb);
PLAYER_BY_BLOCK.remove(tb);
BLOCKS.remove(tb.getBlock());
}
}
}
@ -301,6 +306,7 @@ public class PhaseChange extends IceAbility {
}
this.blocks.add(tb);
PLAYER_BY_BLOCK.put(tb, this.player);
BLOCKS.add(tb.getBlock());
playIcebendingSound(b.getLocation());
}
@ -382,7 +388,8 @@ public class PhaseChange extends IceAbility {
new TempBlock(b, Material.AIR.createBlockData(), 120 * 1000L);
} else {
tb.revertBlock();
new TempBlock(b, Material.SNOW.createBlockData(d -> ((Snow) d).setLayers(snow.getLayers() - 1)), 120 * 1000L);
snow.setLayers(snow.getLayers() - 1);
new TempBlock(b, snow, 120 * 1000L);
}
}
}
@ -407,7 +414,7 @@ public class PhaseChange extends IceAbility {
new TempBlock(b, Material.AIR.createBlockData(), 120 * 1000L);
} else {
snow.setLayers(snow.getLayers() - 1);
new TempBlock(b, Material.SNOW.createBlockData(d -> ((Snow) d).setLayers(snow.getLayers() - 1)), 120 * 1000L);
new TempBlock(b, snow, 120 * 1000L);
}
}
@ -432,6 +439,7 @@ public class PhaseChange extends IceAbility {
return false;
}
PLAYER_BY_BLOCK.remove(tb);
BLOCKS.remove(tb.getBlock());
if (pc.getFrozenBlocks() != null) {
pc.getFrozenBlocks().remove(tb);
tb.revertBlock();
@ -460,18 +468,14 @@ public class PhaseChange extends IceAbility {
}
public static List<Block> getFrozenBlocksAsBlock() {
final List<Block> list = new ArrayList<>();
for (final TempBlock tb : PLAYER_BY_BLOCK.keySet()) {
final Block b = tb.getBlock();
list.add(b);
}
return list;
return BLOCKS;
}
public void revertFrozenBlocks() {
if (this.active_types.contains(PhaseChangeType.FREEZE)) {
for (final TempBlock tb : this.blocks) {
PLAYER_BY_BLOCK.remove(tb);
BLOCKS.remove(tb.getBlock());
tb.revertBlock();
}
this.blocks.clear();

View File

@ -43,6 +43,7 @@ permissions:
default: true
description: Grants access to most abilities and basic commands.
children:
bending.command.board: true
bending.command.bind: true
bending.command.display: true
bending.command.toggle: true