mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +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.FireJet;
|
||||||
import com.projectkorra.ProjectKorra.firebending.FirePassive;
|
import com.projectkorra.ProjectKorra.firebending.FirePassive;
|
||||||
import com.projectkorra.ProjectKorra.firebending.FireStream;
|
import com.projectkorra.ProjectKorra.firebending.FireStream;
|
||||||
|
import com.projectkorra.ProjectKorra.firebending.Illumination;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
|
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
|
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.OctopusForm;
|
import com.projectkorra.ProjectKorra.waterbending.OctopusForm;
|
||||||
|
@ -83,6 +84,7 @@ public class BendingManager implements Runnable {
|
||||||
FreezeMelt.handleFrozenBlocks();
|
FreezeMelt.handleFrozenBlocks();
|
||||||
OctopusForm.progressAll();
|
OctopusForm.progressAll();
|
||||||
AirBubble.handleBubbles(Bukkit.getServer());
|
AirBubble.handleBubbles(Bukkit.getServer());
|
||||||
|
Illumination.manage(Bukkit.getServer());
|
||||||
for (int ID: Tornado.instances.keySet()) {
|
for (int ID: Tornado.instances.keySet()) {
|
||||||
Tornado.progress(ID);
|
Tornado.progress(ID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ public class ConfigManager {
|
||||||
config.addDefault("Abilities.Air.AirBubble.Enabled", true);
|
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.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.AirBubble.Radius", 7);
|
||||||
|
|
||||||
config.addDefault("Abilities.Air.AirBurst.Enabled", true);
|
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. "
|
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. "
|
+ "To use, press and hold sneak to charge your burst. "
|
||||||
|
@ -225,6 +226,14 @@ public class ConfigManager {
|
||||||
config.addDefault("Abilities.Fire.HeatControl.Melt.Range", 15);
|
config.addDefault("Abilities.Fire.HeatControl.Melt.Range", 15);
|
||||||
config.addDefault("Abilities.Fire.HeatControl.Melt.Radius", 5);
|
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.FallReductionFactor", 0.5);
|
||||||
plugin.getConfig().addDefault("Abilities.Chi.Passive.Speed", 1);
|
plugin.getConfig().addDefault("Abilities.Chi.Passive.Speed", 1);
|
||||||
plugin.getConfig().addDefault("Abilities.Chi.Passive.Jump", 2);
|
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.Extinguish;
|
||||||
import com.projectkorra.ProjectKorra.firebending.FireJet;
|
import com.projectkorra.ProjectKorra.firebending.FireJet;
|
||||||
import com.projectkorra.ProjectKorra.firebending.FireStream;
|
import com.projectkorra.ProjectKorra.firebending.FireStream;
|
||||||
|
import com.projectkorra.ProjectKorra.firebending.Illumination;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
|
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
|
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.Melt;
|
import com.projectkorra.ProjectKorra.waterbending.Melt;
|
||||||
|
@ -396,6 +397,9 @@ public class PKListener implements Listener {
|
||||||
if (abil.equalsIgnoreCase("HeatControl")) {
|
if (abil.equalsIgnoreCase("HeatControl")) {
|
||||||
new Extinguish(player);
|
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:
|
Melt:
|
||||||
Range: 15
|
Range: 15
|
||||||
Radius: 5
|
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:
|
Chi:
|
||||||
Passive:
|
Passive:
|
||||||
FallReductionFactor: 0.5
|
FallReductionFactor: 0.5
|
||||||
|
|
Loading…
Reference in a new issue