mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-22 16:05:01 +00:00
Final Fixes :D (#530)
• Added new message for failing to bind abilities when the user doesn't have the required subelements • Fixed PhaseChange not reverting melted ice • Fixed LavaFlow not creating lava under double plants • Fixed double plants dropping items when used as water sources
This commit is contained in:
parent
49216a3da3
commit
7124bf7ded
7 changed files with 62 additions and 16 deletions
|
@ -1024,7 +1024,7 @@ public class GeneralMethods {
|
|||
return blockHolder;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return blockHolder;
|
||||
}
|
||||
|
||||
public static boolean hasItems() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.projectkorra.projectkorra.GeneralMethods;
|
|||
import com.projectkorra.projectkorra.util.BlockSource;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
import com.projectkorra.projectkorra.waterbending.PhaseChangeFreeze;
|
||||
import com.projectkorra.projectkorra.waterbending.PhaseChangeMelt;
|
||||
import com.projectkorra.projectkorra.waterbending.SurgeWall;
|
||||
import com.projectkorra.projectkorra.waterbending.SurgeWave;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterArms;
|
||||
|
@ -322,6 +323,7 @@ public abstract class WaterAbility extends ElementalAbility {
|
|||
|
||||
public static void stopBending() {
|
||||
PhaseChangeFreeze.removeAllCleanup();
|
||||
PhaseChangeMelt.removeAllCleanup();
|
||||
SurgeWall.removeAllCleanup();
|
||||
SurgeWave.removeAllCleanup();
|
||||
WaterArms.removeAllCleanup();
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.command;
|
|||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
|
@ -25,6 +26,7 @@ public class BindCommand extends PKCommand {
|
|||
private String loadingInfo;
|
||||
private String toggledElementOff;
|
||||
private String noElement;
|
||||
private String noSubElement;
|
||||
|
||||
public BindCommand() {
|
||||
super("bind", "/bending bind <Ability> [Slot]", ConfigManager.languageConfig.get().getString("Commands.Bind.Description"), new String[]{ "bind", "b" });
|
||||
|
@ -34,6 +36,7 @@ public class BindCommand extends PKCommand {
|
|||
this.loadingInfo = ConfigManager.languageConfig.get().getString("Commands.Bind.LoadingInfo");
|
||||
this.toggledElementOff = ConfigManager.languageConfig.get().getString("Commands.Bind.ToggledElementOff");
|
||||
this.noElement = ConfigManager.languageConfig.get().getString("Commands.Bind.NoElement");
|
||||
this.noSubElement = ConfigManager.languageConfig.get().getString("Commands.Bind.NoSubElement");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,7 +77,11 @@ public class BindCommand extends PKCommand {
|
|||
return;
|
||||
} else if (coreAbil == null || !bPlayer.canBind(coreAbil)) {
|
||||
if (coreAbil != null && coreAbil.getElement() != Element.AVATAR && !bPlayer.hasElement(coreAbil.getElement())) {
|
||||
sender.sendMessage(ChatColor.RED + this.noElement.replace("{element}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBender()));
|
||||
if (coreAbil.getElement() instanceof SubElement) {
|
||||
sender.sendMessage(ChatColor.RED + this.noSubElement.replace("{subelement}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBending()));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + this.noElement.replace("{element}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBender()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + super.noPermissionMessage);
|
||||
}
|
||||
|
|
|
@ -199,6 +199,7 @@ public class ConfigManager {
|
|||
config.addDefault("Commands.Bind.ElementToggledOff", "You have that ability's element toggled off currently.");
|
||||
config.addDefault("Commands.Bind.SuccessfullyBound", "Succesfully bound {ability} to slot {slot}.");
|
||||
config.addDefault("Commands.Bind.NoElement", "You are not a {element}!");
|
||||
config.addDefault("Commands.Bind.NoSubElement", "You don't have access to {subelement}!");
|
||||
|
||||
config.addDefault("Commands.Add.Description", "This command will allow the user to add an element to the targeted <Player>, or themselves if the target is not specified. This command is typically reserved for server administrators.");
|
||||
config.addDefault("Commands.Add.SuccessfullyAddedCFW", "You are now also a {element}.");
|
||||
|
|
|
@ -232,12 +232,12 @@ public class LavaFlow extends LavaAbility {
|
|||
Block lower = block.getRelative(BlockFace.DOWN);
|
||||
if (isPlant(lower)) {
|
||||
Block lower2 = lower.getRelative(BlockFace.DOWN);
|
||||
if (!(isEarth(lower2) || isSand(lower2) || isMetal(lower2))) {
|
||||
if (!isEarth(lower2) && !isSand(lower2) && !isMetal(lower2)) {
|
||||
continue;
|
||||
}
|
||||
createLava(lower2);
|
||||
} else {
|
||||
if (!(isEarth(lower) || isSand(lower) || isMetal(lower))) {
|
||||
if (!isEarth(lower) && !isSand(lower) && !isMetal(lower)) {
|
||||
continue;
|
||||
}
|
||||
createLava(lower);
|
||||
|
@ -339,7 +339,6 @@ public class LavaFlow extends LavaAbility {
|
|||
if (!isEarth(lower2) && !isSand(lower2) && !isMetal(lower2)) {
|
||||
continue;
|
||||
}
|
||||
tempBlock.breakNaturally();
|
||||
createLava(lower2);
|
||||
} else {
|
||||
if (!isEarth(lower) && !isSand(lower) && !isMetal(lower)) {
|
||||
|
@ -387,19 +386,16 @@ public class LavaFlow extends LavaAbility {
|
|||
if (isPlant(block.getRelative(BlockFace.UP))) {
|
||||
Block above = block.getRelative(BlockFace.UP);
|
||||
Block above2 = above.getRelative(BlockFace.UP);
|
||||
if (isPlant(above2) && above2.getType() == Material.DOUBLE_PLANT) {
|
||||
if (isPlant(above) && above.getType() == Material.DOUBLE_PLANT) {
|
||||
TempBlock tb = new TempBlock(above, Material.AIR, (byte) 0);
|
||||
TEMP_AIR_BLOCKS.put(above, tb);
|
||||
affectedBlocks.add(tb);
|
||||
TempBlock tb2 = new TempBlock(above2, Material.AIR, (byte) 0);
|
||||
TEMP_AIR_BLOCKS.put(above2, tb2);
|
||||
affectedBlocks.add(tb2);
|
||||
} else if (!isPlant(above2)) {
|
||||
TempBlock tb = new TempBlock(above, Material.AIR, (byte) 0);
|
||||
TEMP_AIR_BLOCKS.put(above, tb);
|
||||
affectedBlocks.add(tb);
|
||||
} else return;
|
||||
}
|
||||
}
|
||||
TempBlock tblock = new TempBlock(block, Material.STATIONARY_LAVA, (byte) 0);
|
||||
TEMP_LAVA_BLOCKS.put(block, tblock);
|
||||
affectedBlocks.add(tblock);
|
||||
|
@ -458,10 +454,17 @@ public class LavaFlow extends LavaAbility {
|
|||
super.remove();
|
||||
for (int i = affectedBlocks.size() - 1; i > -1; i--) {
|
||||
final TempBlock tblock = affectedBlocks.get(i);
|
||||
final boolean isTempAir = TEMP_AIR_BLOCKS.values().contains(tblock);
|
||||
new BukkitRunnable() {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
tblock.revertBlock();
|
||||
if (isTempAir && tblock.getState().getType() == Material.DOUBLE_PLANT) {
|
||||
tblock.getBlock().getRelative(BlockFace.UP).setType(Material.DOUBLE_PLANT);
|
||||
tblock.getBlock().getRelative(BlockFace.UP).setData((byte) (tblock.getState().getRawData() + 8));
|
||||
}
|
||||
|
||||
}
|
||||
}.runTaskLater(ProjectKorra.plugin, (long) (i / shiftRemoveSpeed));
|
||||
|
||||
|
@ -540,7 +543,7 @@ public class LavaFlow extends LavaAbility {
|
|||
Block block = loc.getBlock();
|
||||
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int y = -2; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
if (!(x == 0 && y == 0 && z == 0)) {
|
||||
list.add(block.getLocation().add(x, y, z).getBlock());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.projectkorra.projectkorra.waterbending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.IceAbility;
|
||||
import com.projectkorra.projectkorra.avatar.AvatarState;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
|
@ -10,11 +11,15 @@ import org.bukkit.Location;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class PhaseChangeMelt extends IceAbility {
|
||||
|
||||
private static final List<Block> MELTED_BLOCKS = new CopyOnWriteArrayList<Block>();
|
||||
private static final byte FULL = 0x0;
|
||||
|
||||
private int seaLevel;
|
||||
|
@ -72,7 +77,7 @@ public class PhaseChangeMelt extends IceAbility {
|
|||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void melt(Player player, Block block) {
|
||||
public static void melt(Player player, final Block block) {
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) {
|
||||
return;
|
||||
} else if (!SurgeWave.canThaw(block)) {
|
||||
|
@ -96,8 +101,17 @@ public class PhaseChangeMelt extends IceAbility {
|
|||
} else if (PhaseChangeFreeze.getFrozenBlocks().containsKey(block)) {
|
||||
PhaseChangeFreeze.thaw(block);
|
||||
} else {
|
||||
MELTED_BLOCKS.add(block);
|
||||
block.setType(Material.WATER);
|
||||
block.setData(FULL);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MELTED_BLOCKS.remove(block);
|
||||
block.setType(Material.ICE);
|
||||
}
|
||||
}.runTaskLater(ProjectKorra.plugin, 5 * 20 * 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +124,13 @@ public class PhaseChangeMelt extends IceAbility {
|
|||
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAllCleanup() {
|
||||
for (Block b : MELTED_BLOCKS) {
|
||||
b.setType(Material.ICE);
|
||||
MELTED_BLOCKS.remove(b);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -176,4 +197,8 @@ public class PhaseChangeMelt extends IceAbility {
|
|||
this.location = location;
|
||||
}
|
||||
|
||||
public static List<Block> getMeltedBlocks() {
|
||||
return MELTED_BLOCKS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,9 +27,17 @@ public class PlantRegrowth extends PlantAbility {
|
|||
this.type = block.getType();
|
||||
this.data = block.getData();
|
||||
|
||||
if (block.getType() == Material.DOUBLE_PLANT && block.getRelative(BlockFace.DOWN).getType() == Material.DOUBLE_PLANT) {
|
||||
this.block = block.getRelative(BlockFace.DOWN);
|
||||
this.data = (byte) (block.getData() - 8);
|
||||
if (block.getType() == Material.DOUBLE_PLANT) {
|
||||
if (block.getRelative(BlockFace.DOWN).getType() == Material.DOUBLE_PLANT) {
|
||||
this.block = block.getRelative(BlockFace.DOWN);
|
||||
this.data = block.getRelative(BlockFace.DOWN).getData();
|
||||
|
||||
block.getRelative(BlockFace.DOWN).setType(Material.AIR);
|
||||
block.setType(Material.AIR);
|
||||
} else {
|
||||
block.setType(Material.AIR);
|
||||
block.getRelative(BlockFace.UP).setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
time = System.currentTimeMillis() + regrowTime / 2 + (long) (Math.random() * (double) regrowTime) / 2;
|
||||
|
@ -46,7 +54,7 @@ public class PlantRegrowth extends PlantAbility {
|
|||
block.setData(data);
|
||||
if (type == Material.DOUBLE_PLANT) {
|
||||
block.getRelative(BlockFace.UP).setType(Material.DOUBLE_PLANT);
|
||||
block.getRelative(BlockFace.UP).setData((byte) (data + 8));
|
||||
block.getRelative(BlockFace.UP).setData((byte) 10);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue