Merge pull request #265 from jacklin213/master

Util package cleanup/performance improvments
This commit is contained in:
OmniCypher 2015-10-02 23:56:58 -07:00
commit 981fe250e3
13 changed files with 234 additions and 231 deletions

View file

@ -1,8 +1,95 @@
package com.projectkorra.projectkorra;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.projectkorra.projectkorra.ability.AvatarState;
import com.projectkorra.projectkorra.ability.api.CoreAbility;
import com.projectkorra.projectkorra.ability.combo.ComboManager;
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
import com.projectkorra.projectkorra.airbending.AirBlast;
import com.projectkorra.projectkorra.airbending.AirBubble;
import com.projectkorra.projectkorra.airbending.AirBurst;
import com.projectkorra.projectkorra.airbending.AirMethods;
import com.projectkorra.projectkorra.airbending.AirScooter;
import com.projectkorra.projectkorra.airbending.AirShield;
import com.projectkorra.projectkorra.airbending.AirSpout;
import com.projectkorra.projectkorra.airbending.AirSuction;
import com.projectkorra.projectkorra.airbending.AirSwipe;
import com.projectkorra.projectkorra.airbending.FlightAbility;
import com.projectkorra.projectkorra.airbending.Suffocate;
import com.projectkorra.projectkorra.airbending.Tornado;
import com.projectkorra.projectkorra.chiblocking.AcrobatStance;
import com.projectkorra.projectkorra.chiblocking.ChiCombo;
import com.projectkorra.projectkorra.chiblocking.ChiMethods;
import com.projectkorra.projectkorra.chiblocking.ChiPassive;
import com.projectkorra.projectkorra.chiblocking.HighJump;
import com.projectkorra.projectkorra.chiblocking.Paralyze;
import com.projectkorra.projectkorra.chiblocking.QuickStrike;
import com.projectkorra.projectkorra.chiblocking.RapidPunch;
import com.projectkorra.projectkorra.chiblocking.Smokescreen;
import com.projectkorra.projectkorra.chiblocking.SwiftKick;
import com.projectkorra.projectkorra.chiblocking.WarriorStance;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.Catapult;
import com.projectkorra.projectkorra.earthbending.Collapse;
import com.projectkorra.projectkorra.earthbending.CompactColumn;
import com.projectkorra.projectkorra.earthbending.EarthArmor;
import com.projectkorra.projectkorra.earthbending.EarthBlast;
import com.projectkorra.projectkorra.earthbending.EarthColumn;
import com.projectkorra.projectkorra.earthbending.EarthGrab;
import com.projectkorra.projectkorra.earthbending.EarthMethods;
import com.projectkorra.projectkorra.earthbending.EarthPassive;
import com.projectkorra.projectkorra.earthbending.EarthSmash;
import com.projectkorra.projectkorra.earthbending.EarthTunnel;
import com.projectkorra.projectkorra.earthbending.EarthWall;
import com.projectkorra.projectkorra.earthbending.Extraction;
import com.projectkorra.projectkorra.earthbending.LavaFlow;
import com.projectkorra.projectkorra.earthbending.LavaFlow.AbilityType;
import com.projectkorra.projectkorra.earthbending.LavaSurge;
import com.projectkorra.projectkorra.earthbending.LavaWave;
import com.projectkorra.projectkorra.earthbending.MetalClips;
import com.projectkorra.projectkorra.earthbending.SandSpout;
import com.projectkorra.projectkorra.earthbending.Shockwave;
import com.projectkorra.projectkorra.earthbending.Tremorsense;
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
import com.projectkorra.projectkorra.event.PlayerBendingDeathEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
import com.projectkorra.projectkorra.firebending.ArcOfFire;
import com.projectkorra.projectkorra.firebending.Combustion;
import com.projectkorra.projectkorra.firebending.Enflamed;
import com.projectkorra.projectkorra.firebending.Extinguish;
import com.projectkorra.projectkorra.firebending.FireBlast;
import com.projectkorra.projectkorra.firebending.FireBurst;
import com.projectkorra.projectkorra.firebending.FireJet;
import com.projectkorra.projectkorra.firebending.FireMethods;
import com.projectkorra.projectkorra.firebending.FireShield;
import com.projectkorra.projectkorra.firebending.FireStream;
import com.projectkorra.projectkorra.firebending.Fireball;
import com.projectkorra.projectkorra.firebending.HeatControl;
import com.projectkorra.projectkorra.firebending.Illumination;
import com.projectkorra.projectkorra.firebending.Lightning;
import com.projectkorra.projectkorra.firebending.RingOfFire;
import com.projectkorra.projectkorra.firebending.WallOfFire;
import com.projectkorra.projectkorra.object.Preset;
import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.Flight;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.waterbending.Bloodbending;
import com.projectkorra.projectkorra.waterbending.FreezeMelt;
import com.projectkorra.projectkorra.waterbending.IceBlast;
import com.projectkorra.projectkorra.waterbending.IceSpike2;
import com.projectkorra.projectkorra.waterbending.Melt;
import com.projectkorra.projectkorra.waterbending.OctopusForm;
import com.projectkorra.projectkorra.waterbending.PlantArmor;
import com.projectkorra.projectkorra.waterbending.Torrent;
import com.projectkorra.projectkorra.waterbending.WaterArms;
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
import com.projectkorra.projectkorra.waterbending.WaterMethods;
import com.projectkorra.projectkorra.waterbending.WaterPassive;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.projectkorra.waterbending.WaterWall;
import com.projectkorra.projectkorra.waterbending.WaterWave;
import com.projectkorra.projectkorra.waterbending.Wave;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -59,96 +146,9 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.ability.AvatarState;
import com.projectkorra.projectkorra.ability.api.CoreAbility;
import com.projectkorra.projectkorra.ability.combo.ComboManager;
import com.projectkorra.projectkorra.ability.multiability.MultiAbilityManager;
import com.projectkorra.projectkorra.airbending.AirBlast;
import com.projectkorra.projectkorra.airbending.AirBubble;
import com.projectkorra.projectkorra.airbending.AirBurst;
import com.projectkorra.projectkorra.airbending.AirMethods;
import com.projectkorra.projectkorra.airbending.AirScooter;
import com.projectkorra.projectkorra.airbending.AirShield;
import com.projectkorra.projectkorra.airbending.AirSpout;
import com.projectkorra.projectkorra.airbending.AirSuction;
import com.projectkorra.projectkorra.airbending.AirSwipe;
import com.projectkorra.projectkorra.airbending.FlightAbility;
import com.projectkorra.projectkorra.airbending.Suffocate;
import com.projectkorra.projectkorra.airbending.Tornado;
import com.projectkorra.projectkorra.chiblocking.AcrobatStance;
import com.projectkorra.projectkorra.chiblocking.ChiCombo;
import com.projectkorra.projectkorra.chiblocking.ChiMethods;
import com.projectkorra.projectkorra.chiblocking.ChiPassive;
import com.projectkorra.projectkorra.chiblocking.HighJump;
import com.projectkorra.projectkorra.chiblocking.Paralyze;
import com.projectkorra.projectkorra.chiblocking.QuickStrike;
import com.projectkorra.projectkorra.chiblocking.RapidPunch;
import com.projectkorra.projectkorra.chiblocking.Smokescreen;
import com.projectkorra.projectkorra.chiblocking.SwiftKick;
import com.projectkorra.projectkorra.chiblocking.WarriorStance;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.Catapult;
import com.projectkorra.projectkorra.earthbending.Collapse;
import com.projectkorra.projectkorra.earthbending.CompactColumn;
import com.projectkorra.projectkorra.earthbending.EarthArmor;
import com.projectkorra.projectkorra.earthbending.EarthBlast;
import com.projectkorra.projectkorra.earthbending.EarthColumn;
import com.projectkorra.projectkorra.earthbending.EarthGrab;
import com.projectkorra.projectkorra.earthbending.EarthMethods;
import com.projectkorra.projectkorra.earthbending.EarthPassive;
import com.projectkorra.projectkorra.earthbending.EarthSmash;
import com.projectkorra.projectkorra.earthbending.EarthTunnel;
import com.projectkorra.projectkorra.earthbending.EarthWall;
import com.projectkorra.projectkorra.earthbending.Extraction;
import com.projectkorra.projectkorra.earthbending.LavaFlow;
import com.projectkorra.projectkorra.earthbending.LavaFlow.AbilityType;
import com.projectkorra.projectkorra.earthbending.LavaSurge;
import com.projectkorra.projectkorra.earthbending.LavaWave;
import com.projectkorra.projectkorra.earthbending.MetalClips;
import com.projectkorra.projectkorra.earthbending.SandSpout;
import com.projectkorra.projectkorra.earthbending.Shockwave;
import com.projectkorra.projectkorra.earthbending.Tremorsense;
import com.projectkorra.projectkorra.event.PlayerBendingDeathEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
import com.projectkorra.projectkorra.firebending.ArcOfFire;
import com.projectkorra.projectkorra.firebending.Combustion;
import com.projectkorra.projectkorra.firebending.Enflamed;
import com.projectkorra.projectkorra.firebending.Extinguish;
import com.projectkorra.projectkorra.firebending.FireBlast;
import com.projectkorra.projectkorra.firebending.FireBurst;
import com.projectkorra.projectkorra.firebending.FireJet;
import com.projectkorra.projectkorra.firebending.FireMethods;
import com.projectkorra.projectkorra.firebending.FireShield;
import com.projectkorra.projectkorra.firebending.FireStream;
import com.projectkorra.projectkorra.firebending.Fireball;
import com.projectkorra.projectkorra.firebending.HeatControl;
import com.projectkorra.projectkorra.firebending.Illumination;
import com.projectkorra.projectkorra.firebending.Lightning;
import com.projectkorra.projectkorra.firebending.RingOfFire;
import com.projectkorra.projectkorra.firebending.WallOfFire;
import com.projectkorra.projectkorra.object.Preset;
import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.Flight;
import com.projectkorra.projectkorra.util.HorizontalVelocityChangeEvent;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.waterbending.Bloodbending;
import com.projectkorra.projectkorra.waterbending.FreezeMelt;
import com.projectkorra.projectkorra.waterbending.IceBlast;
import com.projectkorra.projectkorra.waterbending.IceSpike2;
import com.projectkorra.projectkorra.waterbending.Melt;
import com.projectkorra.projectkorra.waterbending.OctopusForm;
import com.projectkorra.projectkorra.waterbending.PlantArmor;
import com.projectkorra.projectkorra.waterbending.Torrent;
import com.projectkorra.projectkorra.waterbending.WaterArms;
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
import com.projectkorra.projectkorra.waterbending.WaterMethods;
import com.projectkorra.projectkorra.waterbending.WaterPassive;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.projectkorra.waterbending.WaterWall;
import com.projectkorra.projectkorra.waterbending.WaterWave;
import com.projectkorra.projectkorra.waterbending.Wave;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class PKListener implements Listener {

View file

@ -1,66 +1,70 @@
package com.projectkorra.projectkorra.util;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import java.util.jar.JarFile;
/**
* Called when an ability is successfully loaded.
*
* @author kingbirdy
*/
public class AbilityLoadEvent<T> extends Event {
private static final HandlerList handlers = new HandlerList();
private final Plugin plugin;
private final T loadable;
private final JarFile jarFile;
/**
* Creates a new AbilityLoadEvent.
* @param plugin The instance of ProjectKorra
* @param loadable The class that was loaded
* @param jarFile The JarFile the class was loaded from
*/
public AbilityLoadEvent(Plugin plugin, T loadable, JarFile jarFile) {
this.plugin = plugin;
this.loadable = loadable;
this.jarFile = jarFile;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Gets the JarFile the ability was loaded from.
* @return The JarFile from the event
*/
public JarFile getJarFile() {
return jarFile;
}
/**
* Gets the ability's class that was loaded
* @return The loaded class
*/
public T getLoadable() {
return loadable;
}
/**
* Gets the ProjectKorra instance the ability was loaded into.
* @return The ProjectKorra instance
*/
public Plugin getPlugin() {
return plugin;
}
}
package com.projectkorra.projectkorra.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import java.util.jar.JarFile;
/**
* Called when an ability is successfully loaded.
*
* @author kingbirdy
*/
public class AbilityLoadEvent<T> extends Event {
private static final HandlerList handlers = new HandlerList();
private final Plugin plugin;
private final T loadable;
private final JarFile jarFile;
/**
* Creates a new AbilityLoadEvent.
*
* @param plugin The instance of ProjectKorra
* @param loadable The class that was loaded
* @param jarFile The JarFile the class was loaded from
*/
public AbilityLoadEvent(Plugin plugin, T loadable, JarFile jarFile) {
this.plugin = plugin;
this.loadable = loadable;
this.jarFile = jarFile;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Gets the JarFile the ability was loaded from.
*
* @return The JarFile from the event
*/
public JarFile getJarFile() {
return jarFile;
}
/**
* Gets the ability's class that was loaded.
*
* @return The loaded class
*/
public T getLoadable() {
return loadable;
}
/**
* Gets the ProjectKorra instance the ability was loaded into.
*
* @return The ProjectKorra instance
*/
public Plugin getPlugin() {
return plugin;
}
}

View file

@ -1,4 +1,4 @@
package com.projectkorra.projectkorra.util;
package com.projectkorra.projectkorra.event;
import org.bukkit.Location;
import org.bukkit.entity.Entity;

View file

@ -3,7 +3,7 @@ package com.projectkorra.projectkorra.object;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.earthbending.EarthMethods;
import com.projectkorra.projectkorra.util.HorizontalVelocityChangeEvent;
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
import com.projectkorra.projectkorra.waterbending.WaterMethods;
import org.bukkit.Location;

View file

@ -1,5 +1,6 @@
package com.projectkorra.projectkorra.util;
import com.projectkorra.projectkorra.event.AbilityLoadEvent;
import com.projectkorra.projectkorra.util.AbilityLoadable.LoadResult;
import com.projectkorra.projectkorra.util.AbilityLoadable.LoadResult.Result;

View file

@ -1,7 +1,7 @@
package com.projectkorra.projectkorra.util;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.EarthMethods;
import com.projectkorra.projectkorra.waterbending.WaterMethods;
@ -24,15 +24,15 @@ import java.util.HashMap;
public class BlockSource {
/**
* An enum representation of the source types available for bending abilities.
*
* @author kingbirdy
*
*/
public static enum BlockSourceType {
WATER, ICE, PLANT, EARTH, METAL, LAVA
}
private static HashMap<Player, HashMap<BlockSourceType, HashMap<ClickType, BlockSourceInformation>>> playerSources = new HashMap<Player, HashMap<BlockSourceType, HashMap<ClickType, BlockSourceInformation>>>();
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
private static FileConfiguration config = ConfigManager.defaultConfig.get();
// The player should never need to grab source blocks from farther than this.
private static double MAX_RANGE = config.getDouble("Abilities.Water.WaterManipulation.Range");
@ -80,7 +80,7 @@ public class BlockSource {
}
/**
* Helper method to create and update a specific source
* Helper method to create and update a specific source.
*
* @param player a player.
* @param block the block that is considered a source.

View file

@ -7,8 +7,8 @@ import org.bukkit.entity.Player;
/**
* The information for a bending source block.
*
* @author kingbirdy
*
*/
public class BlockSourceInformation {
private Player player;
@ -19,6 +19,7 @@ public class BlockSourceInformation {
/**
* Creates a new BlockSourceInformation.
*
* @param player The player the source belongs to
* @param block The source block
* @param sourceType What {@link BlockSourceType source type} the block is
@ -34,6 +35,7 @@ public class BlockSourceInformation {
/**
* Gets the source block.
*
* @return The source block
*/
public Block getBlock() {
@ -42,6 +44,7 @@ public class BlockSourceInformation {
/**
* Sets a new source block.
*
* @param block The new source block.
*/
public void setBlock(Block block) {
@ -50,6 +53,7 @@ public class BlockSourceInformation {
/**
* Get what {@link BlockSourceType source type} the source is.
*
* @return The block's source type
*/
public BlockSourceType getSourceType() {
@ -58,6 +62,7 @@ public class BlockSourceInformation {
/**
* Sets the source type.
*
* @param sourceType The new source type.
*/
public void setSourceType(BlockSourceType sourceType) {
@ -66,6 +71,7 @@ public class BlockSourceInformation {
/**
* Gets when the source was created.
*
* @return The source's creation time
*/
public long getCreationTime() {
@ -74,6 +80,7 @@ public class BlockSourceInformation {
/**
* Sets the source's creation time.
*
* @param creationTime The new creation time
*/
public void setCreationTime(long creationTime) {
@ -82,6 +89,7 @@ public class BlockSourceInformation {
/**
* Get the player the source belongs to.
*
* @return The player the source belongs to
*/
public Player getPlayer() {
@ -90,6 +98,7 @@ public class BlockSourceInformation {
/**
* Sets the player the source belongs to.
*
* @param player The player the source will belong to
*/
public void setPlayer(Player player) {
@ -98,6 +107,7 @@ public class BlockSourceInformation {
/**
* Gets the {@link ClickType} used to select the source.
*
* @return The ClickType used to select the source
*/
public ClickType getClickType() {
@ -106,6 +116,7 @@ public class BlockSourceInformation {
/**
* Sets the source's {@link ClickType}.
*
* @param clickType The ClickType to set
*/
public void setClickType(ClickType clickType) {

View file

@ -2,8 +2,8 @@ package com.projectkorra.projectkorra.util;
/**
* An enum representation of the ways in which an ability can be activated.
*
* @author kingbirdy
*
*/
public enum ClickType {
SHIFT,

View file

@ -15,6 +15,7 @@ public final class FileExtensionFilter implements FileFilter {
/**
* Creates a new FileExtensionFilter.
*
* @param extension the extension to filter for
*/
public FileExtensionFilter(String extension) {

View file

@ -1,6 +1,5 @@
package com.projectkorra.projectkorra.util;
import com.projectkorra.projectkorra.ability.AvatarState;
import com.projectkorra.projectkorra.airbending.AirScooter;
import com.projectkorra.projectkorra.airbending.AirSpout;
import com.projectkorra.projectkorra.airbending.Tornado;
@ -21,10 +20,10 @@ public class Flight {
private static ConcurrentHashMap<Player, Flight> instances = new ConcurrentHashMap<Player, Flight>();
private static long duration = 5000;
private Player player = null, source = null;
private boolean couldFly = false, wasFlying = false;
private Player player;
private Player source;
private boolean couldFly = false;
private boolean wasFlying = false;
private long time;
public Flight(Player player) {
@ -38,11 +37,11 @@ public class Flight {
instances.replace(player, flight);
return;
}
couldFly = player.getAllowFlight();
wasFlying = player.isFlying();
this.couldFly = player.getAllowFlight();
this.wasFlying = player.isFlying();
this.player = player;
this.source = source;
time = System.currentTimeMillis();
this.time = System.currentTimeMillis();
instances.put(player, this);
}
@ -59,14 +58,13 @@ public class Flight {
if (instances.containsKey(player)) {
return instances.get(player).source;
}
return null;
}
public static void handle() {
ArrayList<Player> players = new ArrayList<Player>();
ArrayList<Player> newflyingplayers = new ArrayList<Player>();
ArrayList<Player> avatarstateplayers = new ArrayList<Player>();
//ArrayList<Player> avatarstateplayers = new ArrayList<Player>();
ArrayList<Player> airscooterplayers = new ArrayList<Player>();
ArrayList<Player> waterspoutplayers = new ArrayList<Player>();
ArrayList<Player> airspoutplayers = new ArrayList<Player>();
@ -76,7 +74,7 @@ public class Flight {
// players.addAll(Speed.getPlayers());
players.addAll(FireJet.getPlayers());
players.addAll(Catapult.getPlayers());
avatarstateplayers = AvatarState.getPlayers();
//avatarstateplayers = AvatarState.getPlayers();
airscooterplayers = AirScooter.getPlayers();
waterspoutplayers = WaterSpout.getPlayers();
airspoutplayers = AirSpout.getPlayers();
@ -112,15 +110,8 @@ public class Flight {
}
}
} else {
if (flight.source == null) {
flight.revert();
flight.remove();
continue;
}
if (System.currentTimeMillis() > flight.time + duration) {
flight.revert();
flight.remove();
}
flight.revert();
flight.remove();
}
}
}
@ -128,11 +119,10 @@ public class Flight {
public static void removeAll() {
for (Player player : instances.keySet()) {
Flight flight = instances.get(player);
if (player == null || flight == null) {
if (flight == null) {
instances.remove(player);
continue;
}
//if (flight.source != null)
flight.revert();
flight.remove();
}
@ -145,21 +135,21 @@ public class Flight {
}
public void remove() {
if (player == null) {
for (Player player : instances.keySet()) {
if (instances.get(player).equals(this)) {
instances.remove(player);
}
}
return;
}
// if (player == null) {
// for (Player player : instances.keySet()) {
// if (instances.get(player).equals(this)) {
// instances.remove(player);
// }
// }
// return;
// }
instances.remove(player);
}
public void revert() {
if (player == null) {
return;
}
// if (player == null) {
// return;
// }
player.setAllowFlight(couldFly);
player.setFlying(wasFlying);
}

View file

@ -1,30 +1,33 @@
package com.projectkorra.projectkorra.util;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.EarthMethods;
import org.bukkit.Chunk;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
public class RevertChecker implements Runnable {
private ProjectKorra plugin;
private static final boolean safeRevert = ProjectKorra.plugin.getConfig().getBoolean("Properties.Earth.SafeRevert");
public static ConcurrentHashMap<Block, Block> earthRevertQueue = new ConcurrentHashMap<Block, Block>();
static ConcurrentHashMap<Integer, Integer> airRevertQueue = new ConcurrentHashMap<Integer, Integer>();
static ConcurrentHashMap<Chunk, Chunk> chunks = new ConcurrentHashMap<Chunk, Chunk>();
// static ConcurrentHashMap<Block, Material> movedEarthQueue = new
// ConcurrentHashMap<Block, Material>();
private static final FileConfiguration config = ConfigManager.defaultConfig.get();
private static final boolean safeRevert = config.getBoolean("Properties.Earth.SafeRevert");
public static Set<Block> earthRevertQueue = new HashSet<>();
static Set<Integer> airRevertQueue = new HashSet<>();
//static ConcurrentHashMap<Chunk, Chunk> chunks = new ConcurrentHashMap<Chunk, Chunk>();
// static ConcurrentHashMap<Block, Material> movedEarthQueue = new ConcurrentHashMap<Block, Material>();
private long time;
@ -33,14 +36,14 @@ public class RevertChecker implements Runnable {
}
public static void revertAirBlocks() {
for (int ID : airRevertQueue.keySet()) {
for (int ID : airRevertQueue) {
EarthMethods.revertAirBlock(ID);
RevertChecker.airRevertQueue.remove(ID);
}
}
public static void revertEarthBlocks() {
for (Block block : earthRevertQueue.keySet()) {
for (Block block : earthRevertQueue) {
EarthMethods.revertBlock(block);
earthRevertQueue.remove(block);
}
@ -55,20 +58,20 @@ public class RevertChecker implements Runnable {
// }
private void addToAirRevertQueue(int i) {
if (!airRevertQueue.containsKey(i))
airRevertQueue.put(i, i);
if (!airRevertQueue.contains(i))
airRevertQueue.add(i);
}
private void addToRevertQueue(Block block) {
if (!earthRevertQueue.containsKey(block))
earthRevertQueue.put(block, block);
if (!earthRevertQueue.contains(block))
earthRevertQueue.add(block);
}
public void run() {
time = System.currentTimeMillis();
if (plugin.getConfig().getBoolean("Properties.Earth.RevertEarthbending")) {
if (config.getBoolean("Properties.Earth.RevertEarthbending")) {
try {
returnFuture = plugin.getServer().getScheduler().callSyncMethod(plugin, new getOccupiedChunks(plugin.getServer()));
@ -78,11 +81,11 @@ public class RevertChecker implements Runnable {
earth.putAll(EarthMethods.movedearth);
for (Block block : earth.keySet()) {
if (earthRevertQueue.containsKey(block))
if (earthRevertQueue.contains(block))
continue;
boolean remove = true;
Information info = earth.get(block);
if (time < info.getTime() + ProjectKorra.plugin.getConfig().getLong("Properties.Earth.RevertCheckTime") || (chunks.contains(block.getChunk()) && safeRevert)) {
if (time < info.getTime() + config.getLong("Properties.Earth.RevertCheckTime") || (chunks.contains(block.getChunk()) && safeRevert)) {
remove = false;
}
if (remove) {
@ -94,12 +97,12 @@ public class RevertChecker implements Runnable {
air.putAll(EarthMethods.tempair);
for (Integer i : air.keySet()) {
if (airRevertQueue.containsKey(i))
if (airRevertQueue.contains(i))
continue;
boolean remove = true;
Information info = air.get(i);
Block block = info.getBlock();
if (time < info.getTime() + ProjectKorra.plugin.getConfig().getLong("Properties.Earth.RevertCheckTime") || (chunks.contains(block.getChunk()) && safeRevert)) {
if (time < info.getTime() + config.getLong("Properties.Earth.RevertCheckTime") || (chunks.contains(block.getChunk()) && safeRevert)) {
remove = false;
}
if (remove) {

View file

@ -14,10 +14,10 @@ public class TempBlock {
public static ConcurrentHashMap<Block, TempBlock> instances = new ConcurrentHashMap<Block, TempBlock>();
Block block;
Material newtype;
byte newdata;
BlockState state;
private Block block;
private Material newtype;
private byte newdata;
private BlockState state;
@SuppressWarnings("deprecation")
public TempBlock(Block block, Material newtype, byte newdata) {
@ -53,9 +53,7 @@ public class TempBlock {
}
public static boolean isTempBlock(Block block) {
if (instances.containsKey(block))
return true;
return false;
return instances.containsKey(block);
}
public static boolean isTouchingTempBlock(Block block) {
@ -71,13 +69,10 @@ public class TempBlock {
for (Block block : instances.keySet()) {
revertBlock(block, Material.AIR);
}
}
public static void removeBlock(Block block) {
if (instances.containsKey(block)) {
instances.remove(block);
}
instances.remove(block);
}
@SuppressWarnings("deprecation")

View file

@ -34,8 +34,6 @@ public class TempPotionEffect {
public static void progressAll() {
for (LivingEntity entity : instances.keySet()) {
if (instances.get(entity) == null)
continue;
instances.get(entity).progress();
}
}