mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-02-01 11:11:23 +01:00
Fixed key combos casting
This commit is contained in:
parent
5042f78fa3
commit
f1366a584d
@ -46,8 +46,8 @@ import net.Indyuce.mmocore.skill.binding.BoundSkillInfo;
|
||||
import net.Indyuce.mmocore.skill.binding.SkillSlot;
|
||||
import net.Indyuce.mmocore.skill.cast.SkillCastingInstance;
|
||||
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
|
||||
import net.Indyuce.mmocore.skilltree.SkillTreeStatus;
|
||||
import net.Indyuce.mmocore.skilltree.SkillTreeNode;
|
||||
import net.Indyuce.mmocore.skilltree.SkillTreeStatus;
|
||||
import net.Indyuce.mmocore.skilltree.tree.SkillTree;
|
||||
import net.Indyuce.mmocore.waypoint.Waypoint;
|
||||
import net.Indyuce.mmocore.waypoint.WaypointOption;
|
||||
@ -1004,29 +1004,32 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
||||
return skillCasting != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the PlayerEnterCastingModeEvent successfully put the player into casting mode, otherwise if the event is cancelled, returns false.
|
||||
* @apiNote Changed to a boolean to reflect the cancellation state of the event being fired
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean setSkillCasting(@NotNull SkillCastingInstance skillCasting) {
|
||||
Validate.isTrue(!isCasting(), "Player already in casting mode");
|
||||
PlayerEnterCastingModeEvent event = new PlayerEnterCastingModeEvent(getPlayer());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return false;
|
||||
|
||||
if (event.isCancelled()){
|
||||
skillCasting.close();
|
||||
return false;
|
||||
}
|
||||
this.skillCasting = skillCasting;
|
||||
skillCasting.close();
|
||||
setSkillCasting();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* API Method
|
||||
* @return true if the PlayerEnterCastingModeEvent successfully put the player into casting mode, otherwise if the event is cancelled, returns false.
|
||||
* @apiNote Changed to a boolean to reflect the cancellation state of the event being fired
|
||||
*/
|
||||
public void setSkillCasting() {
|
||||
public boolean setSkillCasting() {
|
||||
Validate.isTrue(!isCasting(), "Player already in casting mode");
|
||||
setSkillCasting(SkillCastingMode.getCurrent().newInstance(this));
|
||||
PlayerEnterCastingModeEvent event = new PlayerEnterCastingModeEvent(getPlayer());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return false;
|
||||
|
||||
Bukkit.broadcastMessage("Entering casting mode");
|
||||
|
||||
this.skillCasting = SkillCastingMode.getCurrent().newInstance(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@ -1036,27 +1039,27 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
||||
|
||||
/**
|
||||
* API Method to leave casting mode and fire the PlayerExitCastingModeEvent
|
||||
*
|
||||
* @return true if the skill casting mode was left, or false if the event was cancelled, keeping the player in casting mode.
|
||||
*/
|
||||
public boolean leaveSkillCasting(){
|
||||
return this.leaveSkillCasting(false);
|
||||
public boolean leaveSkillCasting() {
|
||||
return leaveSkillCasting(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param skipEvent Skip Firing the PlayerExitCastingModeEvent
|
||||
* @return true if the PlayerExitCastingModeEvent is not cancelled, or if the event is skipped.
|
||||
*
|
||||
*/
|
||||
public boolean leaveSkillCasting(boolean skipEvent) {
|
||||
Validate.isTrue(isCasting(), "Player not in casting mode");
|
||||
if (!skipEvent) {
|
||||
PlayerExitCastingModeEvent event = new PlayerExitCastingModeEvent(getPlayer());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
if (event.isCancelled()) return false;
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage("Leaving casting mode");
|
||||
|
||||
skillCasting.close();
|
||||
this.skillCasting = null;
|
||||
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE, 0); // Reset action bar
|
||||
|
@ -12,11 +12,11 @@ import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.skill.cast.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -82,7 +82,7 @@ public class KeyCombos implements SkillCastingListener {
|
||||
if (event.getPressed().shouldCancelEvent()) event.setCancelled(true);
|
||||
|
||||
// Start combo
|
||||
if (playerData.setSkillCasting(new CustomSkillCastingInstance(playerData)) && beginComboSound != null)
|
||||
if (playerData.setSkillCasting() && beginComboSound != null)
|
||||
beginComboSound.playTo(player);
|
||||
|
||||
}
|
||||
@ -97,10 +97,9 @@ public class KeyCombos implements SkillCastingListener {
|
||||
// Start combo when there is NO initializer key
|
||||
else {
|
||||
final @NotNull ComboMap comboMap = Objects.requireNonNullElse(playerData.getProfess().getComboMap(), this.comboMap);
|
||||
if (comboMap.isComboStart(event.getPressed())) {
|
||||
casting = new CustomSkillCastingInstance(playerData);
|
||||
if (playerData.setSkillCasting(new CustomSkillCastingInstance(playerData)) && beginComboSound != null)
|
||||
beginComboSound.playTo(player);
|
||||
if (comboMap.isComboStart(event.getPressed()) && playerData.setSkillCasting()) {
|
||||
casting = (CustomSkillCastingInstance) playerData.getSkillCasting();
|
||||
if (beginComboSound != null) beginComboSound.playTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,6 +173,7 @@ public class KeyCombos implements SkillCastingListener {
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
Bukkit.broadcastMessage("runnable combos");
|
||||
if (actionBarOptions != null) if (actionBarOptions.isSubtitle)
|
||||
getCaster().getPlayer().sendTitle(" ", actionBarOptions.format(this), 0, 20, 0);
|
||||
else getCaster().displayActionBar(actionBarOptions.format(this));
|
||||
|
@ -55,11 +55,9 @@ public class SkillBar implements SkillCastingListener {
|
||||
|
||||
// Enter spell casting
|
||||
final PlayerData playerData = event.getData();
|
||||
if (player.getGameMode() != GameMode.SPECTATOR && (MMOCore.plugin.configManager.canCreativeCast || player.getGameMode() != GameMode.CREATIVE) && !playerData.isCasting() && !playerData.getBoundSkills().isEmpty()) {
|
||||
if (playerData.setSkillCasting(new CustomSkillCastingInstance(playerData))) {
|
||||
if (player.getGameMode() != GameMode.SPECTATOR && (MMOCore.plugin.configManager.canCreativeCast || player.getGameMode() != GameMode.CREATIVE) && !playerData.isCasting() && !playerData.getBoundSkills().isEmpty())
|
||||
if (playerData.setSkillCasting())
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.SPELL_CAST_BEGIN).playTo(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomSkillCastingInstance extends SkillCastingInstance {
|
||||
|
@ -80,7 +80,7 @@ public class SkillScroller implements SkillCastingListener {
|
||||
if (event.getPressed().shouldCancelEvent()) event.setCancelled(true);
|
||||
|
||||
// Enter casting mode
|
||||
if (!playerData.setSkillCasting(new CustomSkillCastingInstance(playerData))) {
|
||||
if (!playerData.setSkillCasting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user