Release Bug Fixes/Patches (#1064)

## Fixes
* Patches AirBlast same origin & destination erroring.
* Patches PhaseChange duplication glitch
* Patches EarthGrab duplication glitch
* Fixes invalid preset name throwing NPE
* Fixes ChatPrefix not correctly displaying Avatar for those w/ multiple elements.
This commit is contained in:
Vahagn Tovmasian 2020-07-16 16:17:57 -07:00 committed by GitHub
parent 3c1d6b7b85
commit ca2bb791ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 22 deletions

View file

@ -808,7 +808,7 @@ public class PKListener implements Listener {
String e = "Nonbender"; String e = "Nonbender";
ChatColor c = ChatColor.WHITE; ChatColor c = ChatColor.WHITE;
if (bPlayer != null) { if (bPlayer != null) {
if (player.hasPermission("bending.avatar") || (bPlayer.hasElement(Element.AIR) && bPlayer.hasElement(Element.EARTH) && bPlayer.hasElement(Element.FIRE) && bPlayer.hasElement(Element.WATER))) { if (player.hasPermission("bending.avatar") || bPlayer.getElements().size() > 1) {
c = Element.AVATAR.getColor(); c = Element.AVATAR.getColor();
e = Element.AVATAR.getName(); e = Element.AVATAR.getName();
} else if (bPlayer.getElements().size() > 0) { } else if (bPlayer.getElements().size() > 0) {

View file

@ -9,6 +9,7 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Container;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -215,8 +216,8 @@ public abstract class ElementalAbility extends CoreAbility {
public static boolean isWater(final Block block) { public static boolean isWater(final Block block) {
if (block == null) { if (block == null) {
return false; return false;
} else if (isWater(block.getType())) { } else if (block.getState() instanceof Container) {
return true; return false;
} else { } else {
return isWater(block.getBlockData()); return isWater(block.getBlockData());
} }

View file

@ -91,7 +91,7 @@ public class AirBlast extends AirAbility {
ORIGINS.remove(player); ORIGINS.remove(player);
if (entity != null) { if (entity != null) {
this.direction = GeneralMethods.getDirection(this.origin, entity.getLocation()).normalize(); this.direction = GeneralMethods.getDirection(this.origin, GeneralMethods.getTargetedLocation(player, this.range, false, false)).normalize();
} else { } else {
this.direction = GeneralMethods.getDirection(this.origin, GeneralMethods.getTargetedLocation(player, this.range)).normalize(); this.direction = GeneralMethods.getDirection(this.origin, GeneralMethods.getTargetedLocation(player, this.range)).normalize();
} }
@ -99,7 +99,9 @@ public class AirBlast extends AirAbility {
this.origin = player.getEyeLocation(); this.origin = player.getEyeLocation();
this.direction = player.getEyeLocation().getDirection().normalize(); this.direction = player.getEyeLocation().getDirection().normalize();
} }
if(!Double.isFinite(this.direction.getX()) || !Double.isFinite(this.direction.getY()) || !Double.isFinite(this.direction.getZ())) {
return;
}
this.location = this.origin.clone(); this.location = this.origin.clone();
this.bPlayer.addCooldown(this); this.bPlayer.addCooldown(this);
this.start(); this.start();

View file

@ -40,6 +40,8 @@ public class PresetCommand extends PKCommand {
private final String alreadyExists; private final String alreadyExists;
private final String createdNewPreset; private final String createdNewPreset;
private final String cantEditBinds; private final String cantEditBinds;
private final String playerNotFound;
private final String invalidName;
public PresetCommand() { public PresetCommand() {
super("preset", "/bending preset <Bind/Create/Delete/List> [Preset]", ConfigManager.languageConfig.get().getString("Commands.Preset.Description"), new String[] { "preset", "presets", "pre", "set", "p" }); super("preset", "/bending preset <Bind/Create/Delete/List> [Preset]", ConfigManager.languageConfig.get().getString("Commands.Preset.Description"), new String[] { "preset", "presets", "pre", "set", "p" });
@ -58,6 +60,8 @@ public class PresetCommand extends PKCommand {
this.alreadyExists = ConfigManager.languageConfig.get().getString("Commands.Preset.AlreadyExists"); this.alreadyExists = ConfigManager.languageConfig.get().getString("Commands.Preset.AlreadyExists");
this.createdNewPreset = ConfigManager.languageConfig.get().getString("Commands.Preset.Created"); this.createdNewPreset = ConfigManager.languageConfig.get().getString("Commands.Preset.Created");
this.cantEditBinds = ConfigManager.languageConfig.get().getString("Commands.Preset.CantEditBinds"); this.cantEditBinds = ConfigManager.languageConfig.get().getString("Commands.Preset.CantEditBinds");
this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Preset.PlayerNotFound");
this.invalidName = ConfigManager.languageConfig.get().getString("Commands.Preset.InvalidName");
} }
@Override @Override
@ -177,7 +181,7 @@ public class PresetCommand extends PKCommand {
} }
return; return;
} else { } else {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.PlayerNotFound")); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.playerNotFound);
} }
} else if (this.hasPermission(sender, "bind.assign") && Preset.presetExists(player, name)) { } else if (this.hasPermission(sender, "bind.assign") && Preset.presetExists(player, name)) {
if (!Preset.presetExists(player, name)) { if (!Preset.presetExists(player, name)) {
@ -207,12 +211,15 @@ public class PresetCommand extends PKCommand {
} }
return; return;
} else { } else {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.PlayerNotFound")); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.playerNotFound);
} }
} }
} else if (Arrays.asList(createaliases).contains(args.get(0)) && this.hasPermission(sender, "create")) { // bending preset create name. } else if (Arrays.asList(createaliases).contains(args.get(0)) && this.hasPermission(sender, "create")) { // bending preset create name.
final int limit = GeneralMethods.getMaxPresets(player); final int limit = GeneralMethods.getMaxPresets(player);
if (name == null) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.invalidName);
return;
}
if (Preset.presets.get(player.getUniqueId()) != null && Preset.presets.get(player.getUniqueId()).size() >= limit) { if (Preset.presets.get(player.getUniqueId()) != null && Preset.presets.get(player.getUniqueId()).size() >= limit) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.reachedMax); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.reachedMax);
return; return;

View file

@ -135,6 +135,7 @@ public class ConfigManager {
config.addDefault("Commands.Preset.AlreadyExists", "A preset with that name already exists."); config.addDefault("Commands.Preset.AlreadyExists", "A preset with that name already exists.");
config.addDefault("Commands.Preset.BendingPermanentlyRemoved", "Your bending was permanently removed."); config.addDefault("Commands.Preset.BendingPermanentlyRemoved", "Your bending was permanently removed.");
config.addDefault("Commands.Preset.PlayerNotFound", "Player not found."); config.addDefault("Commands.Preset.PlayerNotFound", "Player not found.");
config.addDefault("Commands.Preset.InvalidName", "You must enter a valid name for your preset.");
config.addDefault("Commands.Preset.MaxPresets", "You've reached your maximum number of presets."); config.addDefault("Commands.Preset.MaxPresets", "You've reached your maximum number of presets.");
config.addDefault("Commands.Preset.CantEditBinds", "You can't edit your binds right now!"); config.addDefault("Commands.Preset.CantEditBinds", "You can't edit your binds right now!");
config.addDefault("Commands.Preset.Other.BendingPermanentlyRemoved", "That player's bending was permanently removed."); config.addDefault("Commands.Preset.Other.BendingPermanentlyRemoved", "That player's bending was permanently removed.");

View file

@ -203,20 +203,20 @@ public class EarthGrab extends EarthAbility {
this.mHandler = new MovementHandler(this.target, this); this.mHandler = new MovementHandler(this.target, this);
this.mHandler.stop(Element.EARTH.getColor() + "* Trapped *"); this.mHandler.stop(Element.EARTH.getColor() + "* Trapped *");
if (this.target instanceof Player || this.target instanceof Zombie || this.target instanceof Skeleton) { // if (this.target instanceof Player || this.target instanceof Zombie || this.target instanceof Skeleton) {
final ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); // final ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS);
final LeatherArmorMeta legmeta = (LeatherArmorMeta) legs.getItemMeta(); // final LeatherArmorMeta legmeta = (LeatherArmorMeta) legs.getItemMeta();
legmeta.setColor(Color.fromRGB(EarthArmor.getColor(m))); // legmeta.setColor(Color.fromRGB(EarthArmor.getColor(m)));
legs.setItemMeta(legmeta); // legs.setItemMeta(legmeta);
//
final ItemStack feet = new ItemStack(Material.LEATHER_BOOTS); // final ItemStack feet = new ItemStack(Material.LEATHER_BOOTS);
final LeatherArmorMeta footmeta = (LeatherArmorMeta) feet.getItemMeta(); // final LeatherArmorMeta footmeta = (LeatherArmorMeta) feet.getItemMeta();
footmeta.setColor(Color.fromRGB(EarthArmor.getColor(m))); // footmeta.setColor(Color.fromRGB(EarthArmor.getColor(m)));
feet.setItemMeta(footmeta); // feet.setItemMeta(footmeta);
//
final ItemStack[] pieces = { (this.target.getEquipment().getArmorContents()[0] == null || this.target.getEquipment().getArmorContents()[0].getType() == Material.AIR) ? feet : null, (this.target.getEquipment().getArmorContents()[1] == null || this.target.getEquipment().getArmorContents()[1].getType() == Material.AIR) ? legs : null, null, null }; // final ItemStack[] pieces = { (this.target.getEquipment().getArmorContents()[0] == null || this.target.getEquipment().getArmorContents()[0].getType() == Material.AIR) ? feet : null, (this.target.getEquipment().getArmorContents()[1] == null || this.target.getEquipment().getArmorContents()[1].getType() == Material.AIR) ? legs : null, null, null };
this.armor = new TempArmor(this.target, 36000000L, this, pieces); // this.armor = new TempArmor(this.target, 36000000L, this, pieces);
} // }
playEarthbendingSound(this.target.getLocation()); playEarthbendingSound(this.target.getLocation());
this.initiated = true; this.initiated = true;