mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 03:30:10 +00:00
Illumination
This commit is contained in:
parent
ab9d048080
commit
d941a74564
5 changed files with 149 additions and 2 deletions
|
@ -28,6 +28,7 @@ import com.projectkorra.ProjectKorra.firebending.Cook;
|
|||
import com.projectkorra.ProjectKorra.firebending.FireJet;
|
||||
import com.projectkorra.ProjectKorra.firebending.FirePassive;
|
||||
import com.projectkorra.ProjectKorra.firebending.FireStream;
|
||||
import com.projectkorra.ProjectKorra.firebending.Illumination;
|
||||
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
|
||||
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
|
||||
import com.projectkorra.ProjectKorra.waterbending.OctopusForm;
|
||||
|
@ -83,6 +84,7 @@ public class BendingManager implements Runnable {
|
|||
FreezeMelt.handleFrozenBlocks();
|
||||
OctopusForm.progressAll();
|
||||
AirBubble.handleBubbles(Bukkit.getServer());
|
||||
Illumination.manage(Bukkit.getServer());
|
||||
for (int ID: Tornado.instances.keySet()) {
|
||||
Tornado.progress(ID);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Air.AirBubble.Enabled", true);
|
||||
config.addDefault("Abilities.Air.AirBubble.Description", "To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability.");
|
||||
config.addDefault("Abilities.Air.AirBubble.Radius", 7);
|
||||
|
||||
config.addDefault("Abilities.Air.AirBurst.Enabled", true);
|
||||
config.addDefault("Abilities.Air.AirBurst.Description", "AirBurst is one of the most powerful abilities in the airbender's arsenal. "
|
||||
+ "To use, press and hold sneak to charge your burst. "
|
||||
|
@ -135,7 +136,7 @@ public class ConfigManager {
|
|||
+ "While channeling, the water will form itself around you and has a chance to block incoming attacks. "
|
||||
+ "Additionally, you can click while channeling to attack things near you, dealing damage and knocking them back. "
|
||||
+ "Releasing shift at any time will dissipate the form.");
|
||||
|
||||
|
||||
config.addDefault("Abilities.Water.PhaseChange.Enabled", true);
|
||||
config.addDefault("Abilities.Water.PhaseChange.Description", "To use, simply left-click. "
|
||||
+ "Any water you are looking at within range will instantly freeze over into solid ice. "
|
||||
|
@ -154,7 +155,7 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Water.WaterBubble.Enabled", true);
|
||||
config.addDefault("Abilities.Water.WaterBubble.Description","To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability.");
|
||||
config.addDefault("Abilities.Water.WaterBubble.Radius", 7);
|
||||
|
||||
|
||||
config.addDefault("Abilities.Water.WaterSpout.Enabled", true);
|
||||
config.addDefault("Abilities.Water.WaterSpout.Description", "To use this ability, click while over or in water. "
|
||||
+ "You will spout water up from beneath you to experience controlled levitation. "
|
||||
|
@ -225,6 +226,14 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Fire.HeatControl.Melt.Range", 15);
|
||||
config.addDefault("Abilities.Fire.HeatControl.Melt.Radius", 5);
|
||||
|
||||
config.addDefault("Abilities.Fire.Illumination.Enabled", true);
|
||||
config.addDefault("Abilities.Fire.Illumination.Description", "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking "
|
||||
+ "will create a torch that follows you around. The torch will only appear on objects that are "
|
||||
+ "ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, "
|
||||
+ "it will disappear, but will reappear when you get on another ignitable block. Clicking again "
|
||||
+ "dismisses this torch.");
|
||||
config.addDefault("Abilities.Fire.Illumination.Range", 5);
|
||||
|
||||
plugin.getConfig().addDefault("Abilities.Chi.Passive.FallReductionFactor", 0.5);
|
||||
plugin.getConfig().addDefault("Abilities.Chi.Passive.Speed", 1);
|
||||
plugin.getConfig().addDefault("Abilities.Chi.Passive.Jump", 2);
|
||||
|
|
|
@ -62,6 +62,7 @@ import com.projectkorra.ProjectKorra.firebending.Enflamed;
|
|||
import com.projectkorra.ProjectKorra.firebending.Extinguish;
|
||||
import com.projectkorra.ProjectKorra.firebending.FireJet;
|
||||
import com.projectkorra.ProjectKorra.firebending.FireStream;
|
||||
import com.projectkorra.ProjectKorra.firebending.Illumination;
|
||||
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
|
||||
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
|
||||
import com.projectkorra.ProjectKorra.waterbending.Melt;
|
||||
|
@ -396,6 +397,9 @@ public class PKListener implements Listener {
|
|||
if (abil.equalsIgnoreCase("HeatControl")) {
|
||||
new Extinguish(player);
|
||||
}
|
||||
if (abil.equalsIgnoreCase("Illumination")) {
|
||||
new Illumination(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
128
src/com/projectkorra/ProjectKorra/firebending/Illumination.java
Normal file
128
src/com/projectkorra/ProjectKorra/firebending/Illumination.java
Normal file
|
@ -0,0 +1,128 @@
|
|||
package com.projectkorra.ProjectKorra.firebending;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
||||
public class Illumination {
|
||||
|
||||
public static ConcurrentHashMap<Player, Illumination> instances = new ConcurrentHashMap<Player, Illumination>();
|
||||
public static ConcurrentHashMap<Block, Player> blocks = new ConcurrentHashMap<Block, Player>();
|
||||
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
|
||||
|
||||
private static final int range = ProjectKorra.plugin.getConfig().getInt("Abilities.Fire.Illumination.Range");
|
||||
|
||||
private Player player;
|
||||
private Block block;
|
||||
private Material normaltype;
|
||||
private byte normaldata;
|
||||
|
||||
public Illumination(Player player) {
|
||||
if (cooldowns.containsKey(player.getName())) {
|
||||
if (cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
|
||||
return;
|
||||
} else {
|
||||
cooldowns.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (instances.containsKey(player)) {
|
||||
instances.get(player).revert();
|
||||
instances.remove(player);
|
||||
} else {
|
||||
this.player = player;
|
||||
set();
|
||||
instances.put(player, this);
|
||||
cooldowns.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
private void set() {
|
||||
Block standingblock = player.getLocation().getBlock();
|
||||
Block standblock = standingblock.getRelative(BlockFace.DOWN);
|
||||
if ((FireStream.isIgnitable(player, standingblock) && standblock
|
||||
.getType() != Material.LEAVES)
|
||||
&& block == null
|
||||
&& !blocks.containsKey(standblock)) {
|
||||
block = standingblock;
|
||||
normaltype = block.getType();
|
||||
normaldata = block.getData();
|
||||
block.setType(Material.TORCH);
|
||||
blocks.put(block, player);
|
||||
} else if ((FireStream.isIgnitable(player, standingblock) && standblock
|
||||
.getType() != Material.LEAVES)
|
||||
&& !block.equals(standblock)
|
||||
&& !blocks.containsKey(standblock) && Methods.isSolid(standblock)) {
|
||||
revert();
|
||||
block = standingblock;
|
||||
normaltype = block.getType();
|
||||
normaldata = block.getData();
|
||||
block.setType(Material.TORCH);
|
||||
blocks.put(block, player);
|
||||
} else if (block == null) {
|
||||
return;
|
||||
} else if (player.getWorld() != block.getWorld()) {
|
||||
revert();
|
||||
} else if (player.getLocation().distance(block.getLocation()) > Methods
|
||||
.firebendingDayAugment(range, player.getWorld())) {
|
||||
revert();
|
||||
}
|
||||
}
|
||||
|
||||
private void revert() {
|
||||
if (block != null) {
|
||||
blocks.remove(block);
|
||||
block.setType(normaltype);
|
||||
block.setData(normaldata);
|
||||
}
|
||||
}
|
||||
|
||||
public static void revert(Block block) {
|
||||
Player player = blocks.get(block);
|
||||
instances.get(player).revert();
|
||||
}
|
||||
|
||||
public static void manage(Server server) {
|
||||
for (Player player : server.getOnlinePlayers()) {
|
||||
if (instances.containsKey(player)) {
|
||||
if (!Methods.canBend(player.getName(), "Illumination")) {
|
||||
instances.get(player).revert();
|
||||
instances.remove(player);
|
||||
} else {
|
||||
instances.get(player).set();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Player player : instances.keySet()) {
|
||||
if (!player.isOnline() || player.isDead()) {
|
||||
instances.get(player).revert();
|
||||
instances.remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (Player player : instances.keySet()) {
|
||||
instances.get(player).revert();
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getDescription() {
|
||||
return "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking "
|
||||
+ "will create a torch that follows you around. The torch will only appear on objects that are "
|
||||
+ "ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, "
|
||||
+ "it will disappear, but will reappear when you get on another ignitable block. Clicking again "
|
||||
+ "dismisses this torch.";
|
||||
}
|
||||
|
||||
}
|
|
@ -147,6 +147,10 @@ Abilities:
|
|||
Melt:
|
||||
Range: 15
|
||||
Radius: 5
|
||||
Illumination:
|
||||
Enabled: true
|
||||
Description: "This ability gives firebenders a means of illuminating the area. It is a toggle - clicking will create a torch that follows you around. The torch will only appear on objects that are ignitable and can hold a torch (e.g. not leaves or ice). If you get too far away from the torch, it will disappear, but will reappear when you get on another ignitable block. Clicking again dismisses this torch."
|
||||
Range: 5
|
||||
Chi:
|
||||
Passive:
|
||||
FallReductionFactor: 0.5
|
||||
|
|
Loading…
Reference in a new issue