mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-04 05:25:28 +02:00
Chimaera wing code is a little bit less disgusting now Fixes #5049
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.runnables.items;
|
||||
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -7,16 +8,24 @@ import com.gmail.nossr50.util.CancellableRunnable;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ChimaeraWingWarmup extends CancellableRunnable {
|
||||
private final McMMOPlayer mcMMOPlayer;
|
||||
import static com.gmail.nossr50.util.ChimaeraWing.expendChimaeraWing;
|
||||
|
||||
public ChimaeraWingWarmup(McMMOPlayer mcMMOPlayer) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
public class ChimaeraWingWarmup extends CancellableRunnable {
|
||||
private final McMMOPlayer mmoPlayer;
|
||||
private final Location location;
|
||||
|
||||
public ChimaeraWingWarmup(McMMOPlayer mmoPlayer, Location location) {
|
||||
this.mmoPlayer = mmoPlayer;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,23 +34,24 @@ public class ChimaeraWingWarmup extends CancellableRunnable {
|
||||
}
|
||||
|
||||
private void checkChimaeraWingTeleport() {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation();
|
||||
final Player player = mmoPlayer.getPlayer();
|
||||
final Location previousLocation = mmoPlayer.getTeleportCommenceLocation();
|
||||
|
||||
if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
|
||||
if (player.getLocation().distanceSquared(previousLocation) > 1.0
|
||||
|| !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(1), 1)) {
|
||||
player.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
|
||||
mcMMOPlayer.setTeleportCommenceLocation(null);
|
||||
mmoPlayer.setTeleportCommenceLocation(null);
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack inHand = player.getInventory().getItemInMainHand();
|
||||
final ItemStack inHand = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < mcMMO.p.getGeneralConfig().getChimaeraUseCost()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
|
||||
return;
|
||||
}
|
||||
|
||||
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
||||
long recentlyHurt = mmoPlayer.getRecentlyHurt();
|
||||
int hurtCooldown = mcMMO.p.getGeneralConfig().getChimaeraRecentlyHurtCooldown();
|
||||
|
||||
if (hurtCooldown > 0) {
|
||||
@@ -53,6 +63,32 @@ public class ChimaeraWingWarmup extends CancellableRunnable {
|
||||
}
|
||||
}
|
||||
|
||||
ChimaeraWing.chimaeraExecuteTeleport();
|
||||
chimaeraExecuteTeleport();
|
||||
}
|
||||
|
||||
private void chimaeraExecuteTeleport() {
|
||||
final Player player = mmoPlayer.getPlayer();
|
||||
|
||||
if (mcMMO.p.getGeneralConfig().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
|
||||
mcMMO.p.getFoliaLib().getScheduler().teleportAsync(player, player.getBedSpawnLocation());
|
||||
} else {
|
||||
final Location spawnLocation = player.getWorld().getSpawnLocation();
|
||||
if (spawnLocation.getBlock().getType() == Material.AIR) {
|
||||
mcMMO.p.getFoliaLib().getScheduler().teleportAsync(player, spawnLocation);
|
||||
} else {
|
||||
mcMMO.p.getFoliaLib().getScheduler().teleportAsync(
|
||||
player, player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
expendChimaeraWing(player, mcMMO.p.getGeneralConfig().getChimaeraUseCost(), player.getInventory().getItemInMainHand());
|
||||
mmoPlayer.actualizeChimeraWingLastUse();
|
||||
mmoPlayer.setTeleportCommenceLocation(null);
|
||||
|
||||
if (mcMMO.p.getGeneralConfig().getChimaeraSoundEnabled()) {
|
||||
SoundManager.sendSound(player, location, SoundType.CHIMAERA_WING);
|
||||
}
|
||||
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.ChimaeraWing.Pass");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user