mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-05-16 01:41:22 +00:00
c12e0daebb
For Spigot 1.14.4+ ## General Gameplay ### Additions - Added default Suffocate cooldown: 6.5 seconds - Added kinetic damage tracker to AirSweep - Added self and others push strength options for AirSuction - Added config option for multiple blocks to be changed per EarthTunnel run, allowing for much faster earth tunnels - Added config to ignore ores completely for EarthTunnel (good for mining) - Added AllowSnow config option for IceBlast - Added AvatarStateCooldown config options for IceBlast and IceBullet - Added config option for ice trapping abilities to not place blocks in players head or feet ### Fixes - Fixed preset command not allowing page numbers higher than 1 - Fixed Catapult and MetalClips not respecting /b invincible - Fixed Charged FireBlast radius and cooldown - Fixed Suffocate being usable through walls - Fixed FireBlast ignoring particle radius options - Fixed FireBurst fragmenting (not looking like a single burst) - Fixed AirSweep knockback to be more consistent (lessened friction) - Fixed AirBlast knockback using wrong push options - Fixed EarthSmash using nonexistent AvatarState options - Fixed error when switching worlds with PhaseChange active - Fixed server crash when hitting falling blocks with high-velocity abilities - Fixed server crash when using EarthGrab over the void - Fixed EarthTunnel not using configurable revert time - Fixed EarthPillars persisting when no entities were around ### Changes - Improved pathing for EarthBlast; works more consistently and can be used from ceilings - Improved aiming for EarthBlast and IceBlast - Changed AirSwipe and AirSweep to originate from the player’s main hand - Changed AirBlast knockback calculations; made the push options affect knockback more directly - Changed EarthTunnel to use tempblocks properly - Moved core combo instructions to config ### Removals - Removed being able to use Lightning while using FireJet - Removed jukeboxes being tempblocks - Removed bending.command.import permission from plugin.yml ## API ### Additions - Added GeneralMethods#getMainHandLocation(Player) - Added GeneralMethods#getClosestEntity(Location, double) - Added GeneralMethods#getClosestLivingEntity(Location, double) - Added "large" abilities collision with each other - Added specific timings for hot spots in the code that should help server owners diagnose lag from PK + player move event + physics event + bending manager - Created local folder repo and update pom for local jar files, this is necessary to use the maven shade plugin. - Added check for concrete powder in move earth - Added PlaceholderAPI support (hopefully more to come) + %projectkorra_slot<1-9>% ability on slot <1-9> + %projectkorra_element% element of the player + %projectkorra_elementcolor% color of the player’s element + %projectkorra_elements% elements the player has - Added "bending" WorldGuard flag. + Used for allowing or denying bending in worldguard regions. Will fall back to the old method of the build flag if the custom flag fails to register or isn't set ### Fixes - Fixed calls to CoreAbility#isEnabled() causing NullPointerExceptions when a CoreAbility is not enabled ### Changes - Changed CoreAbility#getAbility(..) Javadocs to state when it returns null - Formatted codebase - Changed GeneralMethods#getEntitiesAroundPoint() use spigot method for entities around point, should be more optimized - Optimizations to water and air spout to not continually set flying - Optimized revertchecker to not use block.getChunk; this will load the chunk on the server and instead use hashmap of coords - Optimized revertchecker to use paperlib to allow servers running paperspigot to load the chunk for a revert block async - Optimized tempblock revert to load chunk async before updating stateOptimize move event to ignore head movements without directional movement - Optimized physics event to check for air prior to checking for tempblocks - Optimized tempblock set/revert to not apply physics for blocks that don't emit light - Optimize isWater to check for actual water blocks first - Optimize PhaseChange list check, hot spot due to being called in physics event ### Removals - Removed BindChangeEvent; never called or used - Removed HorizontalVelocityTracker that has lasted over 30 seconds, also don't create a tracker for non-living entities
170 lines
6.1 KiB
Java
170 lines
6.1 KiB
Java
package com.projectkorra.projectkorra;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.UUID;
|
|
|
|
import co.aikar.timings.lib.MCTiming;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.World;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import com.projectkorra.projectkorra.ability.CoreAbility;
|
|
import com.projectkorra.projectkorra.ability.ElementalAbility;
|
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
|
import com.projectkorra.projectkorra.earthbending.metal.MetalClips;
|
|
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
|
|
import com.projectkorra.projectkorra.util.ActionBar;
|
|
import com.projectkorra.projectkorra.util.RevertChecker;
|
|
import com.projectkorra.projectkorra.util.TempArmor;
|
|
import com.projectkorra.projectkorra.util.TempPotionEffect;
|
|
import com.projectkorra.projectkorra.waterbending.blood.Bloodbending;
|
|
|
|
public class BendingManager implements Runnable {
|
|
|
|
private static BendingManager instance;
|
|
public static HashMap<World, String> events = new HashMap<World, String>(); // holds any current event.
|
|
|
|
long time;
|
|
long interval;
|
|
private final HashMap<World, Boolean> times = new HashMap<World, Boolean>(); // true if day time
|
|
|
|
private final MCTiming CORE_ABILITY_TIMING, TEMP_POTION_TIMING, DAY_NIGHT_TIMING, HORIZONTAL_VELOCITY_TRACKER_TIMING, COOLDOWN_TIMING, TEMP_ARMOR_TIMING, ACTIONBAR_STATUS_TIMING;
|
|
|
|
public BendingManager() {
|
|
instance = this;
|
|
this.time = System.currentTimeMillis();
|
|
|
|
this.CORE_ABILITY_TIMING = ProjectKorra.timing("CoreAbility#ProgressAll");
|
|
this.TEMP_POTION_TIMING = ProjectKorra.timing("TempPotion#ProgressAll");
|
|
this.DAY_NIGHT_TIMING = ProjectKorra.timing("HandleDayNight");
|
|
this.HORIZONTAL_VELOCITY_TRACKER_TIMING = ProjectKorra.timing("HorizontalVelocityTracker#UpdateAll");
|
|
this.COOLDOWN_TIMING = ProjectKorra.timing("HandleCooldowns");
|
|
this.TEMP_ARMOR_TIMING = ProjectKorra.timing("TempArmor#Cleanup");
|
|
this.ACTIONBAR_STATUS_TIMING = ProjectKorra.timing("ActionBarCheck");
|
|
}
|
|
|
|
public static BendingManager getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
public void handleCooldowns() {
|
|
for (final UUID uuid : BendingPlayer.getPlayers().keySet()) {
|
|
final BendingPlayer bPlayer = BendingPlayer.getPlayers().get(uuid);
|
|
for (final String abil : bPlayer.getCooldowns().keySet()) {
|
|
if (System.currentTimeMillis() >= bPlayer.getCooldown(abil)) {
|
|
bPlayer.removeCooldown(abil);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void handleDayNight() {
|
|
for (final World world : Bukkit.getServer().getWorlds()) {
|
|
if (!this.times.containsKey(world)) {
|
|
if (ElementalAbility.isDay(world)) {
|
|
this.times.put(world, true);
|
|
} else {
|
|
this.times.put(world, false);
|
|
}
|
|
} else {
|
|
if (this.times.get(world) && !ElementalAbility.isDay(world)) {
|
|
// The hashmap says it is day, but it is not.
|
|
this.times.put(world, false); // Sets time to night.
|
|
for (final Player player : world.getPlayers()) {
|
|
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
|
if (bPlayer == null) {
|
|
continue;
|
|
}
|
|
if (bPlayer.hasElement(Element.WATER) && player.hasPermission("bending.message.daymessage")) {
|
|
player.sendMessage(Element.WATER.getColor() + getMoonriseMessage());
|
|
}
|
|
if (bPlayer.hasElement(Element.FIRE) && player.hasPermission("bending.message.nightmessage")) {
|
|
player.sendMessage(Element.FIRE.getColor() + getSunsetMessage());
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!this.times.get(world) && ElementalAbility.isDay(world)) {
|
|
// The hashmap says it is night, but it is day.
|
|
this.times.put(world, true);
|
|
for (final Player player : world.getPlayers()) {
|
|
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
|
if (bPlayer == null) {
|
|
continue;
|
|
}
|
|
|
|
if (bPlayer.hasElement(Element.WATER) && player.hasPermission("bending.message.nightmessage")) {
|
|
player.sendMessage(Element.WATER.getColor() + getMoonsetMessage());
|
|
}
|
|
if (bPlayer.hasElement(Element.FIRE) && player.hasPermission("bending.message.daymessage")) {
|
|
player.sendMessage(Element.FIRE.getColor() + getSunriseMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
this.interval = System.currentTimeMillis() - this.time;
|
|
this.time = System.currentTimeMillis();
|
|
ProjectKorra.time_step = this.interval;
|
|
|
|
try (MCTiming timing = this.CORE_ABILITY_TIMING.startTiming()) {
|
|
CoreAbility.progressAll();
|
|
}
|
|
|
|
try (MCTiming timing = this.TEMP_POTION_TIMING.startTiming()) {
|
|
TempPotionEffect.progressAll();
|
|
}
|
|
|
|
try (MCTiming timing = this.DAY_NIGHT_TIMING.startTiming()) {
|
|
this.handleDayNight();
|
|
}
|
|
|
|
RevertChecker.revertAirBlocks();
|
|
|
|
try (MCTiming timing = this.HORIZONTAL_VELOCITY_TRACKER_TIMING.startTiming()) {
|
|
HorizontalVelocityTracker.updateAll();
|
|
}
|
|
|
|
try (MCTiming timing = this.COOLDOWN_TIMING.startTiming()) {
|
|
this.handleCooldowns();
|
|
}
|
|
|
|
try (MCTiming timing = this.TEMP_ARMOR_TIMING.startTiming()) {
|
|
TempArmor.cleanup();
|
|
}
|
|
|
|
try (MCTiming timing = this.ACTIONBAR_STATUS_TIMING.startTiming()) {
|
|
for (final Player player : Bukkit.getOnlinePlayers()) {
|
|
if (Bloodbending.isBloodbent(player)) {
|
|
ActionBar.sendActionBar(Element.BLOOD.getColor() + "* Bloodbent *", player);
|
|
} else if (MetalClips.isControlled(player)) {
|
|
ActionBar.sendActionBar(Element.METAL.getColor() + "* MetalClipped *", player);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static String getSunriseMessage() {
|
|
return ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Extras.Fire.DayMessage"));
|
|
}
|
|
|
|
public static String getSunsetMessage() {
|
|
return ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Extras.Fire.NightMessage"));
|
|
}
|
|
|
|
public static String getMoonriseMessage() {
|
|
return ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Extras.Water.NightMessage"));
|
|
}
|
|
|
|
public static String getMoonsetMessage() {
|
|
return ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Extras.Water.DayMessage"));
|
|
}
|
|
|
|
}
|