mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 03:30:10 +00:00
New Metalbending Passive
Metalbenders can tap sneak to open / close iron doors. (Assuming they can bend there)
This commit is contained in:
parent
4f8cc009e5
commit
653aeb8718
2 changed files with 39 additions and 0 deletions
|
@ -94,6 +94,7 @@ public class BendingManager implements Runnable {
|
|||
WaterPassive.handlePassive();
|
||||
FirePassive.handlePassive();
|
||||
EarthPassive.revertSands();
|
||||
EarthPassive.handleMetalPassives();
|
||||
TempPotionEffect.progressAll();
|
||||
Plantbending.regrow();
|
||||
AirBurst.progressAll();
|
||||
|
|
|
@ -2,11 +2,16 @@ package com.projectkorra.ProjectKorra.earthbending;
|
|||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.material.Door;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Element;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
||||
|
@ -67,6 +72,39 @@ public class EarthPassive {
|
|||
}
|
||||
}
|
||||
|
||||
public static void handleMetalPassives() {
|
||||
for (Player player: Bukkit.getOnlinePlayers()) {
|
||||
if (Methods.canBendPassive(player.getName(), Element.Earth) && Methods.canMetalbend(player)) {
|
||||
if (player.isSneaking()) {
|
||||
Block block = player.getTargetBlock(null, 5);
|
||||
if (block == null) continue;
|
||||
if (block.getType() == Material.IRON_DOOR_BLOCK && !Methods.isRegionProtectedFromBuild(player, null, block.getLocation())) {
|
||||
if (block.getData() >= 8) {
|
||||
block = block.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
|
||||
if (block.getData() < 4) {
|
||||
block.setData((byte) (block.getData() + 4));
|
||||
block.getWorld().playSound(block.getLocation(), Sound.DOOR_CLOSE, 10, 1);
|
||||
} else {
|
||||
block.setData((byte) (block.getData() - 4));
|
||||
block.getWorld().playSound(block.getLocation(), Sound.DOOR_OPEN, 10, 1);
|
||||
}
|
||||
// Door door = (Door) block.getState().getData();
|
||||
// if (door.isTopHalf()) {
|
||||
// block = block.getRelative(BlockFace.DOWN);
|
||||
// if (door.isOpen()) {
|
||||
// door.setOpen(false);
|
||||
// } else {
|
||||
// door.setOpen(true);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void revertSands() {
|
||||
for (Block block: sandblocks.keySet()) {
|
||||
if (System.currentTimeMillis() >= sandblocks.get(block) + duration) {
|
||||
|
|
Loading…
Reference in a new issue