mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
Updated PK
This commit is contained in:
commit
e39f260bd8
13 changed files with 142 additions and 303 deletions
26
.classpath
26
.classpath
|
@ -1,19 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/LocalServer/BukkitForPlugins1.8.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Desktop/Korra/bukkit-1.8-R0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/Factions.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/GriefPrevention.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/LWC.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/MassiveCore.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/NoCheatPlus.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/PreciousStones.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/TagAPI.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/Towny.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Desktop/Amestria/plugins/WorldEdit.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/WorldGuard.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Downloads/KorraRPG.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Brendan/Desktop/Korra/craftbukkit-180.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/Factions.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/GriefPrevention.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/LWC.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/MassiveCore.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/NoCheatPlus.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/PreciousStones.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/TagAPI.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/Towny.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/WorldEdit.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/WorldGuard.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/LocalServer/plugins/KorraRPG.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/LocalServer/Spigot.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
Binary file not shown.
|
@ -118,7 +118,7 @@ public class AbilityModuleManager {
|
|||
if (a == StockAbilities.MetalClips) earthsubabilities.add(a.name());
|
||||
if (a == StockAbilities.Extraction) earthsubabilities.add(a.name());
|
||||
if (a == StockAbilities.LavaFlow) earthsubabilities.add(a.name());
|
||||
if (a == StockAbilities.LavaSurge) earthsubabilities.add(a.name());
|
||||
// if (a == StockAbilities.LavaSurge) earthsubabilities.add(a.name());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public enum StockAbilities {
|
|||
AvatarState,
|
||||
|
||||
// Project Korra
|
||||
Extraction, MetalClips, Smokescreen, Combustion, LavaSurge, LavaFlow, Suffocate, IceBlast, WarriorStance, AcrobatStance;
|
||||
Extraction, MetalClips, Smokescreen, Combustion, LavaFlow, Suffocate, IceBlast, WarriorStance, AcrobatStance;
|
||||
|
||||
private enum AirbendingAbilities {
|
||||
AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, Suffocate;
|
||||
|
@ -30,7 +30,7 @@ public enum StockAbilities {
|
|||
}
|
||||
|
||||
private enum EarthbendingAbilities {
|
||||
Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, Extraction, MetalClips, LavaSurge, LavaFlow;
|
||||
Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, Extraction, MetalClips, LavaFlow;
|
||||
}
|
||||
|
||||
private enum FirebendingAbilities {
|
||||
|
|
|
@ -463,15 +463,15 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Earth.LavaFlow.AllowNaturalFlow", false);
|
||||
config.addDefault("Abilities.Earth.LavaFlow.ParticleDensity", 0.33);
|
||||
|
||||
config.addDefault("Abilities.Earth.LavaSurge.Enabled", true);
|
||||
config.addDefault("Abilities.Earth.LavaSurge.Description", "LavaSurge is a fundamental move for any Lavabender out there. To use, simply sneak (Default: Shift) while looking at a source of Earth or Lava, then click in a direction. A surge of lava will swiftly travel towards the target you were pointing at, dealing moderate damage, a large knockback, and setting them on fire.");
|
||||
config.addDefault("Abilities.Earth.LavaSurge.Damage", 4);
|
||||
config.addDefault("Abilities.Earth.LavaSurge.Cooldown", 1000);
|
||||
config.addDefault("Abilities.Earth.LavaSurge.FractureRadius", 1);
|
||||
config.addDefault("Abilities.Earth.LavaSurge.PrepareRange", 7);
|
||||
config.addDefault("Abilities.Earth.LavaSurge.TravelRange", 15);
|
||||
config.addDefault("Abilities.Earth.LavaSurge.MaxLavaWaves", 10);
|
||||
config.addDefault("Abilities.Earth.LavaSurge.SourceCanBeEarth", true);
|
||||
// config.addDefault("Abilities.Earth.LavaSurge.Enabled", true);
|
||||
// config.addDefault("Abilities.Earth.LavaSurge.Description", "LavaSurge is a fundamental move for any Lavabender out there. To use, simply sneak (Default: Shift) while looking at a source of Earth or Lava, then click in a direction. A surge of lava will swiftly travel towards the target you were pointing at, dealing moderate damage, a large knockback, and setting them on fire.");
|
||||
// config.addDefault("Abilities.Earth.LavaSurge.Damage", 4);
|
||||
// config.addDefault("Abilities.Earth.LavaSurge.Cooldown", 1000);
|
||||
// config.addDefault("Abilities.Earth.LavaSurge.FractureRadius", 1);
|
||||
// config.addDefault("Abilities.Earth.LavaSurge.PrepareRange", 7);
|
||||
// config.addDefault("Abilities.Earth.LavaSurge.TravelRange", 15);
|
||||
// config.addDefault("Abilities.Earth.LavaSurge.MaxLavaWaves", 10);
|
||||
// config.addDefault("Abilities.Earth.LavaSurge.SourceCanBeEarth", true);
|
||||
|
||||
config.addDefault("Abilities.Earth.MetalClips.Enabled", true);
|
||||
config.addDefault("Abilities.Earth.MetalClips.Description", "MetalClips has the potential to be both an offensive and a utility ability. To start, you must carry smelted Iron Ingots in your inventory. To apply the clips onto an entity, simply click at them. If the entity is a Zombie, a Skeleton, or a Player, the clips will form armor around the entity, giving you some control over them. Each additional clip will give you more control. If you have permission to do so, you may crush the entity against a wall with a 4th clip, hurting them. Without explicit permissions, you will only be able to strap three clips on your target. If the entity is not one of the above, the clip will simply do damage and fall to the ground, to be collected.");
|
||||
|
|
|
@ -75,6 +75,9 @@ import com.palmergames.bukkit.towny.object.WorldCoord;
|
|||
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
|
||||
import com.palmergames.bukkit.towny.war.flagwar.TownyWar;
|
||||
import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig;
|
||||
import com.projectkorra.ProjectKorra.Element;
|
||||
import com.projectkorra.ProjectKorra.Information;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.Ability.AbilityModule;
|
||||
import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager;
|
||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||
|
@ -1445,7 +1448,7 @@ public class Methods {
|
|||
if (gpp != null && respectGriefPrevention) {
|
||||
Material type = player.getWorld().getBlockAt(location).getType();
|
||||
if (type == null) type = Material.AIR;
|
||||
String reason = GriefPrevention.instance.allowBuild(player, location);
|
||||
String reason = GriefPrevention.instance.allowBuild(player, location, type);
|
||||
|
||||
if (ignite.contains(ability)) {
|
||||
|
||||
|
@ -1734,6 +1737,16 @@ public class Methods {
|
|||
else
|
||||
return ParticleEffect.CLOUD;
|
||||
}
|
||||
|
||||
public static Collection<Player> getPlayersAroundPoint(Location location, double distance) {
|
||||
Collection<Player> players = new HashSet<Player>();
|
||||
for (Player player: Bukkit.getOnlinePlayers()) {
|
||||
if (player.getLocation().distance(location) <= distance) {
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
public static void playAirbendingParticles(Location loc, int amount) {
|
||||
playAirbendingParticles(loc, amount, (float) Math.random(), (float) Math.random(), (float) Math.random());
|
||||
|
|
|
@ -498,9 +498,9 @@ public class PKListener implements Listener {
|
|||
new MetalClips(player, 1);
|
||||
}
|
||||
|
||||
if (abil.equalsIgnoreCase("LavaSurge")) {
|
||||
new LavaSurge(player);
|
||||
}
|
||||
// if (abil.equalsIgnoreCase("LavaSurge")) {
|
||||
// new LavaSurge(player);
|
||||
// }
|
||||
|
||||
if (abil.equalsIgnoreCase("LavaFlow")) {
|
||||
new LavaFlow(player,LavaFlow.AbilityType.SHIFT);
|
||||
|
|
|
@ -43,45 +43,33 @@ public class RevertChecker implements Runnable {
|
|||
|
||||
@Override
|
||||
public ArrayList<Chunk> call() throws Exception {
|
||||
ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||
Collection<? extends Player> players = server.getOnlinePlayers();
|
||||
|
||||
for (Player player : players) {
|
||||
ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||
|
||||
for (Player player : server.getOnlinePlayers()) {
|
||||
Chunk chunk = player.getLocation().getChunk();
|
||||
if (!chunks.contains(chunk))
|
||||
chunks.add(chunk);
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void run() {
|
||||
time = System.currentTimeMillis();
|
||||
|
||||
if (plugin.getConfig().getBoolean("Properties.Earth.RevertEarthbending")) {
|
||||
|
||||
// ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||
// Player[] players = plugin.getServer().getOnlinePlayers();
|
||||
//
|
||||
// for (Player player : players) {
|
||||
// Chunk chunk = player.getLocation().getChunk();
|
||||
// if (!chunks.contains(chunk))
|
||||
// chunks.add(chunk);
|
||||
// }
|
||||
|
||||
try {
|
||||
// Tools.verbose("Calling future at t="
|
||||
// + System.currentTimeMillis());
|
||||
returnFuture = plugin
|
||||
.getServer()
|
||||
.getScheduler()
|
||||
.callSyncMethod(plugin,
|
||||
new getOccupiedChunks(plugin.getServer()));
|
||||
ArrayList<Chunk> chunks = returnFuture.get();
|
||||
// Tools.verbose("Future called, t=" +
|
||||
// System.currentTimeMillis());
|
||||
|
||||
Map<Block, Information> earth = new HashMap<Block, Information>();
|
||||
earth.putAll(Methods.movedearth);
|
||||
|
@ -120,41 +108,6 @@ public class RevertChecker implements Runnable {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// for (Block block : Tools.tempearthblocks.keySet()) {
|
||||
// if (revertQueue.containsKey(block))
|
||||
// continue;
|
||||
// boolean remove = true;
|
||||
//
|
||||
// Block index = Tools.tempearthblocks.get(block);
|
||||
// if (Tools.movedearth.containsKey(index)) {
|
||||
// Information info = Tools.movedearth.get(index);
|
||||
// if (time < info.getTime() + ConfigManager.revertchecktime
|
||||
// || (chunks.contains(index.getChunk()) && safeRevert)) {
|
||||
// remove = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (remove)
|
||||
// addToRevertQueue(block);
|
||||
//
|
||||
// }
|
||||
|
||||
// for (Block block : Tools.movedearth.keySet()) {
|
||||
// if (movedEarthQueue.containsKey(block))
|
||||
// continue;
|
||||
// Information info = Tools.movedearth.get(block);
|
||||
// if (time >= info.getTime() + ConfigManager.revertchecktime) {
|
||||
// // if (Tools.tempearthblocks.containsKey(info.getBlock()))
|
||||
// // Tools.verbose("PROBLEM!");
|
||||
// // block.setType(info.getType());
|
||||
// // Tools.movedearth.remove(block);
|
||||
// addToMovedEarthQueue(block, info.getType());
|
||||
// }
|
||||
// }
|
||||
|
||||
// Tools.writeToLog("Still " + Tools.tempearthblocks.size()
|
||||
// + " remaining.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,14 +127,14 @@ public class RevertChecker implements Runnable {
|
|||
if (!earthRevertQueue.containsKey(block))
|
||||
earthRevertQueue.put(block, block);
|
||||
}
|
||||
|
||||
|
||||
public static void revertEarthBlocks() {
|
||||
for (Block block : earthRevertQueue.keySet()) {
|
||||
Methods.revertBlock(block);
|
||||
earthRevertQueue.remove(block);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void revertAirBlocks() {
|
||||
for (int ID : airRevertQueue.keySet()) {
|
||||
Methods.revertAirBlock(ID);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package com.projectkorra.ProjectKorra.Utilities;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -10,17 +9,13 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.server.v1_8_R1.EnumParticle;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Utilities.ReflectionHandler.PackageType;
|
||||
import com.projectkorra.ProjectKorra.Utilities.ReflectionHandler.PacketType;
|
||||
import com.projectkorra.ProjectKorra.Utilities.ReflectionHandler.SubPackageType;
|
||||
|
||||
/**
|
||||
* ParticleEffect Library v1.4
|
||||
*
|
||||
|
@ -206,7 +201,6 @@ public enum ParticleEffect {
|
|||
* @displayed by bone meal and when trading with a villager
|
||||
*/
|
||||
HAPPY_VILLAGER("happyVillager");
|
||||
|
||||
private static final Map<String, ParticleEffect> NAME_MAP = new HashMap<String, ParticleEffect>();
|
||||
private static final double MAX_RANGE = 16;
|
||||
private static Constructor<?> packetPlayOutWorldParticles;
|
||||
|
@ -214,7 +208,6 @@ public enum ParticleEffect {
|
|||
private static Field playerConnection;
|
||||
private static Method sendPacket;
|
||||
private final String name;
|
||||
|
||||
static {
|
||||
for (ParticleEffect p : values())
|
||||
NAME_MAP.put(p.name, p);
|
||||
|
@ -228,21 +221,18 @@ public enum ParticleEffect {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of this particle effect
|
||||
*/
|
||||
private ParticleEffect(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name of this particle effect
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a particle effect from name
|
||||
*
|
||||
|
@ -256,7 +246,6 @@ public enum ParticleEffect {
|
|||
return e.getValue();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of players in a certain range
|
||||
*
|
||||
|
@ -273,7 +262,6 @@ public enum ParticleEffect {
|
|||
players.add(p);
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new @PacketPlayOutWorldParticles object through reflection
|
||||
*
|
||||
|
@ -295,65 +283,62 @@ public enum ParticleEffect {
|
|||
throw new PacketInstantiationException("Packet instantiation failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static EnumParticle getEnumParticle(String name)
|
||||
{
|
||||
switch(name.toUpperCase())
|
||||
{
|
||||
case "HUGEEXPLOSION":
|
||||
return EnumParticle.EXPLOSION_HUGE;
|
||||
case "BUBBLE":
|
||||
return EnumParticle.WATER_BUBBLE;
|
||||
case "SUSPEND":
|
||||
return EnumParticle.SUSPENDED;
|
||||
case "DEPTHSUSPEND":
|
||||
return EnumParticle.SUSPENDED_DEPTH;
|
||||
case "MAGICCRIT":
|
||||
return EnumParticle.CRIT_MAGIC;
|
||||
case "SMOKE":
|
||||
return EnumParticle.SMOKE_NORMAL;
|
||||
case "MOBSPELL":
|
||||
return EnumParticle.SPELL_MOB;
|
||||
case "MOBSPELLAMBIENT":
|
||||
return EnumParticle.SPELL_MOB_AMBIENT;
|
||||
case "INSTANTSPELL":
|
||||
return EnumParticle.SPELL_INSTANT;
|
||||
case "WITCHMAGIC":
|
||||
return EnumParticle.SPELL_WITCH;
|
||||
case "EXPLODE":
|
||||
return EnumParticle.EXPLOSION_NORMAL;
|
||||
case "SPLASH":
|
||||
return EnumParticle.WATER_SPLASH;
|
||||
case "WAKE":
|
||||
return EnumParticle.WATER_WAKE;
|
||||
case "LARGESMOKE":
|
||||
return EnumParticle.SMOKE_LARGE;
|
||||
case "REDDUST":
|
||||
return EnumParticle.REDSTONE;
|
||||
case "SNOWBALLPOOF":
|
||||
return EnumParticle.SNOWBALL;
|
||||
case "ANGRYVILLAGER":
|
||||
return EnumParticle.VILLAGER_ANGRY;
|
||||
case "HAPPYVILLAGER":
|
||||
return EnumParticle.VILLAGER_HAPPY;
|
||||
case "DRIPWATER":
|
||||
return EnumParticle.DRIP_WATER;
|
||||
case "DRIPLAVA":
|
||||
return EnumParticle.DRIP_LAVA;
|
||||
case "SNOWSHOVEL":
|
||||
return EnumParticle.SNOW_SHOVEL;
|
||||
case "ENCHANTMENTTABLE":
|
||||
return EnumParticle.ENCHANTMENT_TABLE;
|
||||
case "TOWNAURA":
|
||||
return EnumParticle.TOWN_AURA;
|
||||
case "FIREWORKSSPARK":
|
||||
return EnumParticle.FIREWORKS_SPARK;
|
||||
default:
|
||||
return EnumParticle.valueOf(name.toUpperCase());
|
||||
case "HUGEEXPLOSION":
|
||||
return EnumParticle.EXPLOSION_HUGE;
|
||||
case "BUBBLE":
|
||||
return EnumParticle.WATER_BUBBLE;
|
||||
case "SUSPEND":
|
||||
return EnumParticle.SUSPENDED;
|
||||
case "DEPTHSUSPEND":
|
||||
return EnumParticle.SUSPENDED_DEPTH;
|
||||
case "MAGICCRIT":
|
||||
return EnumParticle.CRIT_MAGIC;
|
||||
case "SMOKE":
|
||||
return EnumParticle.SMOKE_NORMAL;
|
||||
case "MOBSPELL":
|
||||
return EnumParticle.SPELL_MOB;
|
||||
case "MOBSPELLAMBIENT":
|
||||
return EnumParticle.SPELL_MOB_AMBIENT;
|
||||
case "INSTANTSPELL":
|
||||
return EnumParticle.SPELL_INSTANT;
|
||||
case "WITCHMAGIC":
|
||||
return EnumParticle.SPELL_WITCH;
|
||||
case "EXPLODE":
|
||||
return EnumParticle.EXPLOSION_NORMAL;
|
||||
case "SPLASH":
|
||||
return EnumParticle.WATER_SPLASH;
|
||||
case "WAKE":
|
||||
return EnumParticle.WATER_WAKE;
|
||||
case "LARGESMOKE":
|
||||
return EnumParticle.SMOKE_LARGE;
|
||||
case "REDDUST":
|
||||
return EnumParticle.REDSTONE;
|
||||
case "SNOWBALLPOOF":
|
||||
return EnumParticle.SNOWBALL;
|
||||
case "ANGRYVILLAGER":
|
||||
return EnumParticle.VILLAGER_ANGRY;
|
||||
case "HAPPYVILLAGER":
|
||||
return EnumParticle.VILLAGER_HAPPY;
|
||||
case "DRIPWATER":
|
||||
return EnumParticle.DRIP_WATER;
|
||||
case "DRIPLAVA":
|
||||
return EnumParticle.DRIP_LAVA;
|
||||
case "SNOWSHOVEL":
|
||||
return EnumParticle.SNOW_SHOVEL;
|
||||
case "ENCHANTMENTTABLE":
|
||||
return EnumParticle.ENCHANTMENT_TABLE;
|
||||
case "TOWNAURA":
|
||||
return EnumParticle.TOWN_AURA;
|
||||
case "FIREWORKSSPARK":
|
||||
return EnumParticle.FIREWORKS_SPARK;
|
||||
default:
|
||||
return EnumParticle.valueOf(name.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new @PacketPlayOutWorldParticles object through reflection especially for the "iconcrack" effect
|
||||
*
|
||||
|
@ -370,7 +355,6 @@ public enum ParticleEffect {
|
|||
private static Object instantiateIconCrackPacket(int id, Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
return instantiatePacket("iconcrack_" + id, center, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new @PacketPlayOutWorldParticles object through reflection especially for the "blockcrack" effect
|
||||
*
|
||||
|
@ -387,7 +371,6 @@ public enum ParticleEffect {
|
|||
private static Object instantiateBlockCrackPacket(int id, byte data, Location center, float offsetX, float offsetY, float offsetZ, int amount) {
|
||||
return instantiatePacket("blockcrack_" + id + "_" + data, center, offsetX, offsetY, offsetZ, 0, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new @PacketPlayOutWorldParticles object through reflection especially for the "blockdust" effect
|
||||
*
|
||||
|
@ -405,7 +388,6 @@ public enum ParticleEffect {
|
|||
private static Object instantiateBlockDustPacket(int id, byte data, Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
return instantiatePacket("blockdust_" + id + "_" + data, center, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet through reflection to a player
|
||||
*
|
||||
|
@ -420,7 +402,6 @@ public enum ParticleEffect {
|
|||
throw new PacketSendingException("Failed to send a packet to player '" + p.getName() + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet through reflection to a collection of players
|
||||
*
|
||||
|
@ -433,7 +414,6 @@ public enum ParticleEffect {
|
|||
for (Player p : players)
|
||||
sendPacket(p, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particle effect which is only visible for the specified players
|
||||
*
|
||||
|
@ -450,7 +430,6 @@ public enum ParticleEffect {
|
|||
public void display(Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), instantiatePacket(name, center, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particle effect which is only visible for all players within a certain range in the world of @param center
|
||||
*
|
||||
|
@ -471,7 +450,6 @@ public enum ParticleEffect {
|
|||
throw new IllegalArgumentException("Range cannot exceed the maximum value of 16");
|
||||
sendPacket(getPlayers(center, range), instantiatePacket(name, center, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particle effect which is only visible for all players within a range of 20 in the world of @param center
|
||||
*
|
||||
|
@ -487,7 +465,6 @@ public enum ParticleEffect {
|
|||
public void display(Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
display(center, MAX_RANGE, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an icon crack (item break) particle effect which is only visible for the specified players
|
||||
*
|
||||
|
@ -505,7 +482,6 @@ public enum ParticleEffect {
|
|||
public static void displayIconCrack(Location center, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), instantiateIconCrackPacket(id, center, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an icon crack (item break) particle effect which is only visible for all players within a certain range in the world of @param center
|
||||
*
|
||||
|
@ -526,7 +502,6 @@ public enum ParticleEffect {
|
|||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 16");
|
||||
sendPacket(getPlayers(center, range), instantiateIconCrackPacket(id, center, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an icon crack (item break) effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param center
|
||||
*
|
||||
|
@ -542,7 +517,6 @@ public enum ParticleEffect {
|
|||
public static void displayIconCrack(Location center, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
displayIconCrack(center, MAX_RANGE, id, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block crack (block break) particle effect which is only visible for the specified players
|
||||
*
|
||||
|
@ -560,7 +534,6 @@ public enum ParticleEffect {
|
|||
public static void displayBlockCrack(Location center, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), instantiateBlockCrackPacket(id, data, center, offsetX, offsetY, offsetZ, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block crack (block break) particle effect which is only visible for all players within a certain range in the world of @param center
|
||||
*
|
||||
|
@ -581,7 +554,6 @@ public enum ParticleEffect {
|
|||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 16");
|
||||
sendPacket(getPlayers(center, range), instantiateBlockCrackPacket(id, data, center, offsetX, offsetY, offsetZ, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block crack (block break) effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param center
|
||||
*
|
||||
|
@ -597,7 +569,6 @@ public enum ParticleEffect {
|
|||
public static void displayBlockCrack(Location center, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount) {
|
||||
displayBlockCrack(center, MAX_RANGE, id, data, offsetX, offsetY, offsetZ, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block dust particle effect which is only visible for the specified players
|
||||
*
|
||||
|
@ -616,7 +587,6 @@ public enum ParticleEffect {
|
|||
public static void displayBlockDust(Location center, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), instantiateBlockDustPacket(id, data, center, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block dust particle effect which is only visible for all players within a certain range in the world of @param center
|
||||
*
|
||||
|
@ -638,7 +608,6 @@ public enum ParticleEffect {
|
|||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 16");
|
||||
sendPacket(getPlayers(center, range), instantiateBlockDustPacket(id, data, center, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block dust effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param center
|
||||
*
|
||||
|
@ -655,20 +624,17 @@ public enum ParticleEffect {
|
|||
public static void displayBlockDust(Location center, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
displayBlockDust(center, MAX_RANGE, id, data, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a runtime exception that can be thrown upon packet instantiation
|
||||
*/
|
||||
private static final class PacketInstantiationException extends RuntimeException {
|
||||
private static final long serialVersionUID = 3203085387160737484L;
|
||||
|
||||
/**
|
||||
* @param message Message that will be logged
|
||||
*/
|
||||
public PacketInstantiationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message Message that will be logged
|
||||
* @param cause Cause of the exception
|
||||
|
@ -677,13 +643,11 @@ public enum ParticleEffect {
|
|||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a runtime exception that can be thrown upon packet sending
|
||||
*/
|
||||
private static final class PacketSendingException extends RuntimeException {
|
||||
private static final long serialVersionUID = 3203085387160737484L;
|
||||
|
||||
/**
|
||||
* @param message Message that will be logged
|
||||
* @param cause Cause of the exception
|
||||
|
|
|
@ -5,9 +5,7 @@ import java.lang.reflect.Field;
|
|||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* ReflectionHandler v1.0
|
||||
*
|
||||
|
@ -23,15 +21,12 @@ import org.bukkit.Bukkit;
|
|||
*/
|
||||
public final class ReflectionHandler {
|
||||
private ReflectionHandler() {}
|
||||
|
||||
public static Class<?> getClass(String name, PackageType type) throws Exception {
|
||||
return Class.forName(type + "." + name);
|
||||
}
|
||||
|
||||
public static Class<?> getClass(String name, SubPackageType type) throws Exception {
|
||||
return Class.forName(type + "." + name);
|
||||
}
|
||||
|
||||
public static Constructor<?> getConstructor(Class<?> clazz, Class<?>... parameterTypes) {
|
||||
Class<?>[] p = DataType.convertToPrimitive(parameterTypes);
|
||||
for (Constructor<?> c : clazz.getConstructors())
|
||||
|
@ -39,27 +34,21 @@ public final class ReflectionHandler {
|
|||
return c;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Constructor<?> getConstructor(String className, PackageType type, Class<?>... parameterTypes) throws Exception {
|
||||
return getConstructor(getClass(className, type), parameterTypes);
|
||||
}
|
||||
|
||||
public static Constructor<?> getConstructor(String className, SubPackageType type, Class<?>... parameterTypes) throws Exception {
|
||||
return getConstructor(getClass(className, type), parameterTypes);
|
||||
}
|
||||
|
||||
public static Object newInstance(Class<?> clazz, Object... args) throws Exception {
|
||||
return getConstructor(clazz, DataType.convertToPrimitive(args)).newInstance(args);
|
||||
}
|
||||
|
||||
public static Object newInstance(String className, PackageType type, Object... args) throws Exception {
|
||||
return newInstance(getClass(className, type), args);
|
||||
}
|
||||
|
||||
public static Object newInstance(String className, SubPackageType type, Object... args) throws Exception {
|
||||
return newInstance(getClass(className, type), args);
|
||||
}
|
||||
|
||||
public static Method getMethod(Class<?> clazz, String name, Class<?>... parameterTypes) {
|
||||
Class<?>[] p = DataType.convertToPrimitive(parameterTypes);
|
||||
for (Method m : clazz.getMethods())
|
||||
|
@ -67,195 +56,150 @@ public final class ReflectionHandler {
|
|||
return m;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Method getMethod(String className, PackageType type, String name, Class<?>... parameterTypes) throws Exception {
|
||||
return getMethod(getClass(className, type), name, parameterTypes);
|
||||
}
|
||||
|
||||
public static Method getMethod(String className, SubPackageType type, String name, Class<?>... parameterTypes) throws Exception {
|
||||
return getMethod(getClass(className, type), name, parameterTypes);
|
||||
}
|
||||
|
||||
public static Object invokeMethod(String name, Object instance, Object... args) throws Exception {
|
||||
return getMethod(instance.getClass(), name, DataType.convertToPrimitive(args)).invoke(instance, args);
|
||||
}
|
||||
|
||||
public static Object invokeMethod(Class<?> clazz, String name, Object instance, Object... args) throws Exception {
|
||||
return getMethod(clazz, name, DataType.convertToPrimitive(args)).invoke(instance, args);
|
||||
}
|
||||
|
||||
public static Object invokeMethod(String className, PackageType type, String name, Object instance, Object... args) throws Exception {
|
||||
return invokeMethod(getClass(className, type), name, instance, args);
|
||||
}
|
||||
|
||||
public static Object invokeMethod(String className, SubPackageType type, String name, Object instance, Object... args) throws Exception {
|
||||
return invokeMethod(getClass(className, type), name, instance, args);
|
||||
}
|
||||
|
||||
public static Field getField(Class<?> clazz, String name) throws Exception {
|
||||
Field f = clazz.getField(name);
|
||||
f.setAccessible(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
public static Field getField(String className, PackageType type, String name) throws Exception {
|
||||
return getField(getClass(className, type), name);
|
||||
}
|
||||
|
||||
public static Field getField(String className, SubPackageType type, String name) throws Exception {
|
||||
return getField(getClass(className, type), name);
|
||||
}
|
||||
|
||||
public static Field getDeclaredField(Class<?> clazz, String name) throws Exception {
|
||||
Field f = clazz.getDeclaredField(name);
|
||||
f.setAccessible(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
public static Field getDeclaredField(String className, PackageType type, String name) throws Exception {
|
||||
return getDeclaredField(getClass(className, type), name);
|
||||
}
|
||||
|
||||
public static Field getDeclaredField(String className, SubPackageType type, String name) throws Exception {
|
||||
return getDeclaredField(getClass(className, type), name);
|
||||
}
|
||||
|
||||
public static Object getValue(Object instance, String fieldName) throws Exception {
|
||||
return getField(instance.getClass(), fieldName).get(instance);
|
||||
}
|
||||
|
||||
public static Object getValue(Class<?> clazz, Object instance, String fieldName) throws Exception {
|
||||
return getField(clazz, fieldName).get(instance);
|
||||
}
|
||||
|
||||
public static Object getValue(String className, PackageType type, Object instance, String fieldName) throws Exception {
|
||||
return getValue(getClass(className, type), instance, fieldName);
|
||||
}
|
||||
|
||||
public static Object getValue(String className, SubPackageType type, Object instance, String fieldName) throws Exception {
|
||||
return getValue(getClass(className, type), instance, fieldName);
|
||||
}
|
||||
|
||||
public static Object getDeclaredValue(Object instance, String fieldName) throws Exception {
|
||||
return getDeclaredField(instance.getClass(), fieldName).get(instance);
|
||||
}
|
||||
|
||||
public static Object getDeclaredValue(Class<?> clazz, Object instance, String fieldName) throws Exception {
|
||||
return getDeclaredField(clazz, fieldName).get(instance);
|
||||
}
|
||||
|
||||
public static Object getDeclaredValue(String className, PackageType type, Object instance, String fieldName) throws Exception {
|
||||
return getDeclaredValue(getClass(className, type), instance, fieldName);
|
||||
}
|
||||
|
||||
public static Object getDeclaredValue(String className, SubPackageType type, Object instance, String fieldName) throws Exception {
|
||||
return getDeclaredValue(getClass(className, type), instance, fieldName);
|
||||
}
|
||||
|
||||
public static void setValue(Object instance, String fieldName, Object fieldValue) throws Exception {
|
||||
Field f = getField(instance.getClass(), fieldName);
|
||||
f.set(instance, fieldValue);
|
||||
}
|
||||
|
||||
public static void setValue(Object instance, FieldPair pair) throws Exception {
|
||||
setValue(instance, pair.getName(), pair.getValue());
|
||||
}
|
||||
|
||||
public static void setValue(Class<?> clazz, Object instance, String fieldName, Object fieldValue) throws Exception {
|
||||
Field f = getField(clazz, fieldName);
|
||||
f.set(instance, fieldValue);
|
||||
}
|
||||
|
||||
public static void setValue(Class<?> clazz, Object instance, FieldPair pair) throws Exception {
|
||||
setValue(clazz, instance, pair.getName(), pair.getValue());
|
||||
}
|
||||
|
||||
public static void setValue(String className, PackageType type, Object instance, String fieldName, Object fieldValue) throws Exception {
|
||||
setValue(getClass(className, type), instance, fieldName, fieldValue);
|
||||
}
|
||||
|
||||
public static void setValue(String className, PackageType type, Object instance, FieldPair pair) throws Exception {
|
||||
setValue(className, type, instance, pair.getName(), pair.getValue());
|
||||
}
|
||||
|
||||
public static void setValue(String className, SubPackageType type, Object instance, String fieldName, Object fieldValue) throws Exception {
|
||||
setValue(getClass(className, type), instance, fieldName, fieldValue);
|
||||
}
|
||||
|
||||
public static void setValue(String className, SubPackageType type, Object instance, FieldPair pair) throws Exception {
|
||||
setValue(className, type, instance, pair.getName(), pair.getValue());
|
||||
}
|
||||
|
||||
public static void setValues(Object instance, FieldPair... pairs) throws Exception {
|
||||
for (FieldPair pair : pairs)
|
||||
setValue(instance, pair);
|
||||
}
|
||||
|
||||
public static void setValues(Class<?> clazz, Object instance, FieldPair... pairs) throws Exception {
|
||||
for (FieldPair pair : pairs)
|
||||
setValue(clazz, instance, pair);
|
||||
}
|
||||
|
||||
public static void setValues(String className, PackageType type, Object instance, FieldPair... pairs) throws Exception {
|
||||
setValues(getClass(className, type), instance, pairs);
|
||||
}
|
||||
|
||||
public static void setValues(String className, SubPackageType type, Object instance, FieldPair... pairs) throws Exception {
|
||||
setValues(getClass(className, type), instance, pairs);
|
||||
}
|
||||
|
||||
public static void setDeclaredValue(Object instance, String fieldName, Object fieldValue) throws Exception {
|
||||
Field f = getDeclaredField(instance.getClass(), fieldName);
|
||||
f.set(instance, fieldValue);
|
||||
}
|
||||
|
||||
public static void setDeclaredValue(Object instance, FieldPair pair) throws Exception {
|
||||
setDeclaredValue(instance, pair.getName(), pair.getValue());
|
||||
}
|
||||
|
||||
public static void setDeclaredValue(Class<?> clazz, Object instance, String fieldName, Object fieldValue) throws Exception {
|
||||
Field f = getDeclaredField(clazz, fieldName);
|
||||
f.set(instance, fieldValue);
|
||||
}
|
||||
|
||||
public static void setDeclaredValue(Class<?> clazz, Object instance, FieldPair pair) throws Exception {
|
||||
setDeclaredValue(clazz, instance, pair.getName(), pair.getValue());
|
||||
}
|
||||
|
||||
public static void setDeclaredValue(String className, PackageType type, Object instance, String fieldName, Object fieldValue) throws Exception {
|
||||
setDeclaredValue(getClass(className, type), instance, fieldName, fieldValue);
|
||||
}
|
||||
|
||||
public static void setDeclaredValue(String className, PackageType type, Object instance, FieldPair pair) throws Exception {
|
||||
setDeclaredValue(className, type, instance, pair.getName(), pair.getValue());
|
||||
}
|
||||
|
||||
public static void setDeclaredValue(String className, SubPackageType type, Object instance, String fieldName, Object fieldValue) throws Exception {
|
||||
setDeclaredValue(getClass(className, type), instance, fieldName, fieldValue);
|
||||
}
|
||||
|
||||
public static void setDeclaredValue(String className, SubPackageType type, Object instance, FieldPair pair) throws Exception {
|
||||
setDeclaredValue(className, type, instance, pair.getName(), pair.getValue());
|
||||
}
|
||||
|
||||
public static void setDeclaredValues(Object instance, FieldPair... pairs) throws Exception {
|
||||
for (FieldPair pair : pairs)
|
||||
setDeclaredValue(instance, pair);
|
||||
}
|
||||
|
||||
public static void setDeclaredValues(Class<?> clazz, Object instance, FieldPair... pairs) throws Exception {
|
||||
for (FieldPair pair : pairs)
|
||||
setDeclaredValue(clazz, instance, pair);
|
||||
}
|
||||
|
||||
public static void setDeclaredValues(String className, PackageType type, Object instance, FieldPair... pairs) throws Exception {
|
||||
setDeclaredValues(getClass(className, type), instance, pairs);
|
||||
}
|
||||
|
||||
public static void setDeclaredValues(String className, SubPackageType type, Object instance, FieldPair... pairs) throws Exception {
|
||||
setDeclaredValues(getClass(className, type), instance, pairs);
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is part of the ReflectionHandler and follows the same usage conditions
|
||||
*
|
||||
|
@ -270,45 +214,36 @@ public final class ReflectionHandler {
|
|||
FLOAT(float.class, Float.class),
|
||||
DOUBLE(double.class, Double.class),
|
||||
BOOLEAN(boolean.class, Boolean.class);
|
||||
|
||||
private static final Map<Class<?>, DataType> CLASS_MAP = new HashMap<Class<?>, DataType>();
|
||||
private final Class<?> primitive;
|
||||
private final Class<?> reference;
|
||||
|
||||
static {
|
||||
for (DataType t : values()) {
|
||||
CLASS_MAP.put(t.primitive, t);
|
||||
CLASS_MAP.put(t.reference, t);
|
||||
}
|
||||
}
|
||||
|
||||
private DataType(Class<?> primitive, Class<?> reference) {
|
||||
this.primitive = primitive;
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public Class<?> getPrimitive() {
|
||||
return this.primitive;
|
||||
}
|
||||
|
||||
public Class<?> getReference() {
|
||||
return this.reference;
|
||||
}
|
||||
|
||||
public static DataType fromClass(Class<?> c) {
|
||||
return CLASS_MAP.get(c);
|
||||
}
|
||||
|
||||
public static Class<?> getPrimitive(Class<?> c) {
|
||||
DataType t = fromClass(c);
|
||||
return t == null ? c : t.getPrimitive();
|
||||
}
|
||||
|
||||
public static Class<?> getReference(Class<?> c) {
|
||||
DataType t = fromClass(c);
|
||||
return t == null ? c : t.getReference();
|
||||
}
|
||||
|
||||
public static Class<?>[] convertToPrimitive(Class<?>[] classes) {
|
||||
int length = classes == null ? 0 : classes.length;
|
||||
Class<?>[] types = new Class<?>[length];
|
||||
|
@ -316,7 +251,6 @@ public final class ReflectionHandler {
|
|||
types[i] = getPrimitive(classes[i]);
|
||||
return types;
|
||||
}
|
||||
|
||||
public static Class<?>[] convertToPrimitive(Object[] objects) {
|
||||
int length = objects == null ? 0 : objects.length;
|
||||
Class<?>[] types = new Class<?>[length];
|
||||
|
@ -324,7 +258,6 @@ public final class ReflectionHandler {
|
|||
types[i] = getPrimitive(objects[i].getClass());
|
||||
return types;
|
||||
}
|
||||
|
||||
public static boolean equalsArray(Class<?>[] a1, Class<?>[] a2) {
|
||||
if (a1 == null || a2 == null || a1.length != a2.length)
|
||||
return false;
|
||||
|
@ -334,7 +267,6 @@ public final class ReflectionHandler {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is part of the ReflectionHandler and follows the same usage conditions
|
||||
*
|
||||
|
@ -343,21 +275,17 @@ public final class ReflectionHandler {
|
|||
public final class FieldPair {
|
||||
private final String name;
|
||||
private final Object value;
|
||||
|
||||
public FieldPair(String name, Object value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is part of the ReflectionHandler and follows the same usage conditions
|
||||
*
|
||||
|
@ -366,23 +294,18 @@ public final class ReflectionHandler {
|
|||
public enum PackageType {
|
||||
MINECRAFT_SERVER("net.minecraft.server." + Bukkit.getServer().getClass().getPackage().getName().substring(23)),
|
||||
CRAFTBUKKIT(Bukkit.getServer().getClass().getPackage().getName());
|
||||
|
||||
private final String name;
|
||||
|
||||
private PackageType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is part of the ReflectionHandler and follows the same usage conditions
|
||||
*
|
||||
|
@ -407,23 +330,18 @@ public final class ReflectionHandler {
|
|||
SCOREBOARD,
|
||||
UPDATER,
|
||||
UTIL;
|
||||
|
||||
private final String name;
|
||||
|
||||
private SubPackageType() {
|
||||
name = PackageType.CRAFTBUKKIT + "." + name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is part of the ReflectionHandler and follows the same usage conditions
|
||||
*
|
||||
|
@ -529,18 +447,14 @@ public final class ReflectionHandler {
|
|||
STATUS_IN_START("PacketStatusInStart"),
|
||||
STATUS_OUT_PONG("PacketStatusOutPong"),
|
||||
STATUS_OUT_SERVER_INFO("PacketStatusOutServerInfo");
|
||||
|
||||
private final String name;
|
||||
private Class<?> packet;
|
||||
|
||||
private PacketType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
public Class<?> getPacket() throws Exception {
|
||||
return packet == null ? packet = ReflectionHandler.getClass(name, PackageType.MINECRAFT_SERVER) : packet;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class LavaFlow
|
|||
public static double SHIFT_REMOVE_SPEED = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.LavaFlow.ShiftRemoveSpeed");
|
||||
public static long SHIFT_REMOVE_DELAY = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.LavaFlow.ShiftCleanupDelay");
|
||||
public static double PARTICLE_DENSITY = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.LavaFlow.ParticleDensity");
|
||||
|
||||
|
||||
public static double CLICK_RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.LavaFlow.ClickRange");
|
||||
public static double CLICK_LAVA_RADIUS = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.LavaFlow.ClickRadius");
|
||||
public static double CLICK_LAND_RADIUS = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.LavaFlow.ClickRadius");
|
||||
|
@ -43,7 +43,7 @@ public class LavaFlow
|
|||
public static long CLICK_LAND_CLEANUP_DELAY = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.LavaFlow.ClickLandCleanupDelay");
|
||||
public static double LAVA_CREATE_SPEED = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.LavaFlow.ClickLavaCreateSpeed");
|
||||
public static double LAND_CREATE_SPEED = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.LavaFlow.ClickLandCreateSpeed");
|
||||
|
||||
|
||||
public static long AS_SHIFT_COOLDOWN = 0;
|
||||
public static double AS_SHIFT_PLATFORM_RADIUS = 3;
|
||||
public static double AS_SHIFT_MAX_RADIUS = 16;
|
||||
|
@ -55,16 +55,16 @@ public class LavaFlow
|
|||
public static long AS_CLICK_LAVA_DELAY = 2000;
|
||||
public static long AS_CLICK_LAND_DELAY = 0;
|
||||
public static long AS_CLICK_COOLDOWN = 0;
|
||||
|
||||
|
||||
public static int UPWARD_FLOW = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.LavaFlow.UpwardFlow");
|
||||
public static int DOWNWARD_FLOW = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.LavaFlow.DownwardFlow");
|
||||
public static boolean ALLOW_NATURAL_FLOW = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth.LavaFlow.AllowNaturalFlow");
|
||||
|
||||
|
||||
private static final double PARTICLE_OFFSET = 3;
|
||||
|
||||
public static ArrayList<LavaFlow> instances = new ArrayList<LavaFlow>();
|
||||
public static ArrayList<TempBlock> totalBlocks = new ArrayList<TempBlock>();
|
||||
|
||||
|
||||
private Player player;
|
||||
private BendingPlayer bplayer;
|
||||
private long time;
|
||||
|
@ -77,7 +77,7 @@ public class LavaFlow
|
|||
private double currentRadius = 0;
|
||||
private ArrayList<TempBlock> affectedBlocks = new ArrayList<TempBlock>();
|
||||
private ArrayList<BukkitRunnable> tasks = new ArrayList<BukkitRunnable>();
|
||||
|
||||
|
||||
public LavaFlow(Player player, AbilityType type)
|
||||
{
|
||||
time = System.currentTimeMillis();
|
||||
|
@ -92,7 +92,7 @@ public class LavaFlow
|
|||
if(shiftFlows.size() > 0 && !player.isSneaking())
|
||||
for(LavaFlow lf : shiftFlows)
|
||||
lf.shiftCounter++;
|
||||
|
||||
|
||||
if(bplayer.isOnCooldown("lavaflowcooldownshift")){
|
||||
remove();
|
||||
return;
|
||||
|
@ -111,7 +111,7 @@ public class LavaFlow
|
|||
makeLava = !isLava(sourceBlock);
|
||||
long cooldown = makeLava ? CLICK_LAVA_COOLDOWN : CLICK_LAND_COOLDOWN;
|
||||
cooldown = AvatarState.isAvatarState(player) ? AS_CLICK_COOLDOWN : cooldown;
|
||||
|
||||
|
||||
if(makeLava){
|
||||
if(bplayer.isOnCooldown("lavaflowmakelava")){
|
||||
remove();
|
||||
|
@ -120,7 +120,7 @@ public class LavaFlow
|
|||
else
|
||||
bplayer.addCooldown("lavaflowmakelava", cooldown);
|
||||
}
|
||||
|
||||
|
||||
if(!makeLava){
|
||||
if(bplayer.isOnCooldown("lavaflowmakeland")){
|
||||
remove();
|
||||
|
@ -132,7 +132,7 @@ public class LavaFlow
|
|||
instances.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void progress()
|
||||
{
|
||||
if(shiftCounter > 0 && type == AbilityType.SHIFT){
|
||||
|
@ -145,7 +145,7 @@ public class LavaFlow
|
|||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(type == AbilityType.SHIFT)
|
||||
{
|
||||
double removeDelay = AvatarState.isAvatarState(player) ? AS_SHIFT_REMOVE_DELAY : SHIFT_REMOVE_DELAY;
|
||||
|
@ -164,7 +164,7 @@ public class LavaFlow
|
|||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String ability = Methods.getBoundAbility(player);
|
||||
if(ability == null){
|
||||
remove();
|
||||
|
@ -181,7 +181,7 @@ public class LavaFlow
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double platformRadius = AvatarState.isAvatarState(player) ? AS_SHIFT_PLATFORM_RADIUS : SHIFT_PLATFORM_RADIUS;
|
||||
double maxRadius = AvatarState.isAvatarState(player) ? AS_SHIFT_MAX_RADIUS : SHIFT_MAX_RADIUS;
|
||||
double flowSpeed = AvatarState.isAvatarState(player) ? AS_SHIFT_FLOW_SPEED : SHIFT_FLOW_SPEED;
|
||||
|
@ -204,15 +204,16 @@ public class LavaFlow
|
|||
}
|
||||
else if(Math.random() < PARTICLE_DENSITY
|
||||
&& dSquared < Math.pow(currentRadius + PARTICLE_OFFSET, 2)
|
||||
&& currentRadius + PARTICLE_OFFSET < maxRadius)
|
||||
ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 1);
|
||||
&& currentRadius + PARTICLE_OFFSET < maxRadius) {
|
||||
ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
currentRadius += flowSpeed;
|
||||
if(currentRadius > maxRadius) currentRadius = maxRadius;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The variable makeLava refers to whether or not the ability is trying to
|
||||
* remove land in place of lava or if makeLava = false then lava is being replaced
|
||||
|
@ -245,17 +246,17 @@ public class LavaFlow
|
|||
{
|
||||
double radius = AvatarState.isAvatarState(player) ? AS_CLICK_RADIUS : CLICK_LAVA_RADIUS;
|
||||
for(double x = -radius; x <= radius; x++)
|
||||
for(double z = -radius; z <= radius; z++)
|
||||
{
|
||||
Location loc = origin.clone().add(x,0,z);
|
||||
Block tempBlock = getTopBlock(loc,UPWARD_FLOW,DOWNWARD_FLOW);
|
||||
if(tempBlock != null
|
||||
&& !isLava(tempBlock)
|
||||
&& Math.random() < PARTICLE_DENSITY
|
||||
&& tempBlock.getLocation().distanceSquared(origin) <= Math.pow(radius,2))
|
||||
ParticleEffect.LAVA.display(loc, 0, 0, 0, 0, 1);
|
||||
|
||||
}
|
||||
for(double z = -radius; z <= radius; z++)
|
||||
{
|
||||
Location loc = origin.clone().add(x,0,z);
|
||||
Block tempBlock = getTopBlock(loc,UPWARD_FLOW,DOWNWARD_FLOW);
|
||||
if(tempBlock != null
|
||||
&& !isLava(tempBlock)
|
||||
&& Math.random() < PARTICLE_DENSITY
|
||||
&& tempBlock.getLocation().distanceSquared(origin) <= Math.pow(radius,2))
|
||||
ParticleEffect.LAVA.display(loc, 0, 0, 0, 0, 1);
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,7 +276,7 @@ public class LavaFlow
|
|||
Block tempBlock = getTopBlock(loc,UPWARD_FLOW,DOWNWARD_FLOW);
|
||||
if(tempBlock == null)
|
||||
continue;
|
||||
|
||||
|
||||
double dSquared = distanceSquaredXZ(tempBlock.getLocation(),origin);
|
||||
if(dSquared < Math.pow(radius,2) && !Methods.isRegionProtectedFromBuild(player, "LavaFlow", loc))
|
||||
{
|
||||
|
@ -319,8 +320,8 @@ public class LavaFlow
|
|||
}
|
||||
else if(isEarthbendableMaterial(block.getType(), player))
|
||||
valid = true;
|
||||
|
||||
|
||||
|
||||
|
||||
if(valid){
|
||||
TempBlock tblock = new TempBlock(block,Material.STATIONARY_LAVA,(byte) 0);
|
||||
totalBlocks.add(tblock);
|
||||
|
@ -347,9 +348,9 @@ public class LavaFlow
|
|||
}
|
||||
}
|
||||
testBlock.setType(REVERT_MATERIAL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void removeOnDelay()
|
||||
{
|
||||
/**
|
||||
|
@ -366,7 +367,7 @@ public class LavaFlow
|
|||
br.runTaskLater(ProjectKorra.plugin, (long) (delay / 1000.0 * 20.0));
|
||||
tasks.add(br);
|
||||
}
|
||||
|
||||
|
||||
public void remove()
|
||||
{
|
||||
/**
|
||||
|
@ -393,13 +394,13 @@ public class LavaFlow
|
|||
for(BukkitRunnable task : tasks)
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
|
||||
public static void progressAll()
|
||||
{
|
||||
for(int i = instances.size() - 1; i >= 0; i--)
|
||||
instances.get(i).progress();
|
||||
}
|
||||
|
||||
|
||||
public static void removeAll()
|
||||
{
|
||||
for(int i = instances.size() - 1; i >= 0; i--)
|
||||
|
@ -407,7 +408,7 @@ public class LavaFlow
|
|||
instances.get(i).remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<Block> getAdjacentBlocks(Location loc)
|
||||
{
|
||||
/**
|
||||
|
@ -478,14 +479,14 @@ public class LavaFlow
|
|||
return blockHolder;
|
||||
blockHolder = tempBlock;
|
||||
}
|
||||
|
||||
|
||||
while(blockHolder.getType() == Material.AIR && Math.abs(y) < Math.abs(negativeY))
|
||||
{
|
||||
y--;
|
||||
blockHolder = loc.clone().add(0,y,0).getBlock();
|
||||
if(blockHolder.getType() != Material.AIR)
|
||||
return blockHolder;
|
||||
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -506,7 +507,7 @@ public class LavaFlow
|
|||
if ((!Methods.isRegionProtectedFromBuild(player, "LavaFlow", testblock.getLocation()))
|
||||
&& (isEarthbendableMaterial(testblock.getType(), player) || isLava(testblock)))
|
||||
return testblock;
|
||||
|
||||
|
||||
Location location = player.getEyeLocation();
|
||||
Vector vector = location.getDirection().clone().normalize();
|
||||
for (double i = 0; i <= range; i++) {
|
||||
|
|
|
@ -348,12 +348,6 @@ Abilities:
|
|||
DoubleLootChance: 40
|
||||
MetalClips:
|
||||
Enabled: true
|
||||
LavaSurge:
|
||||
Enabled: true
|
||||
Description: "This ability allows an Earthbender to bend an existing Lava Source to create a large wave that deals damage and knocks back anything in its path. To use, simply tap sneak (Default: Shift) while targeting an earthbendable block. Once a source has been selected, left click to launch the wave off into the direction you are looking. This ability has a small knockback and does a fair amount of damage."
|
||||
Radius: 3
|
||||
HorizontalPush: 0.5
|
||||
VerticalPush: 0.1
|
||||
LavaFlow:
|
||||
Enabled: true
|
||||
Description: 'This ability allows an Earthbender to create lava using the Earth
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: ProjectKorra
|
||||
author: ProjectKorra
|
||||
version: 1.5.0
|
||||
version: 1.5.1
|
||||
main: com.projectkorra.ProjectKorra.ProjectKorra
|
||||
softdepend: [PreciousStones, WorldGuard, WorldEdit, Factions, MassiveCore, GriefPrevention, Towny, TagAPI, NoCheatPlus, LWC]
|
||||
commands:
|
||||
|
|
Loading…
Reference in a new issue