forked from Upstream/mmocore
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.binding.SkillSlot;
|
||||||
import net.Indyuce.mmocore.skill.cast.SkillCastingInstance;
|
import net.Indyuce.mmocore.skill.cast.SkillCastingInstance;
|
||||||
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
|
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
|
||||||
import net.Indyuce.mmocore.skilltree.SkillTreeStatus;
|
|
||||||
import net.Indyuce.mmocore.skilltree.SkillTreeNode;
|
import net.Indyuce.mmocore.skilltree.SkillTreeNode;
|
||||||
|
import net.Indyuce.mmocore.skilltree.SkillTreeStatus;
|
||||||
import net.Indyuce.mmocore.skilltree.tree.SkillTree;
|
import net.Indyuce.mmocore.skilltree.tree.SkillTree;
|
||||||
import net.Indyuce.mmocore.waypoint.Waypoint;
|
import net.Indyuce.mmocore.waypoint.Waypoint;
|
||||||
import net.Indyuce.mmocore.waypoint.WaypointOption;
|
import net.Indyuce.mmocore.waypoint.WaypointOption;
|
||||||
@ -1004,29 +1004,32 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
|||||||
return skillCasting != null;
|
return skillCasting != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Deprecated
|
||||||
* @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 boolean setSkillCasting(@NotNull SkillCastingInstance skillCasting) {
|
public boolean setSkillCasting(@NotNull SkillCastingInstance skillCasting) {
|
||||||
Validate.isTrue(!isCasting(), "Player already in casting mode");
|
Validate.isTrue(!isCasting(), "Player already in casting mode");
|
||||||
PlayerEnterCastingModeEvent event = new PlayerEnterCastingModeEvent(getPlayer());
|
PlayerEnterCastingModeEvent event = new PlayerEnterCastingModeEvent(getPlayer());
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) return false;
|
||||||
|
|
||||||
if (event.isCancelled()){
|
|
||||||
skillCasting.close();
|
skillCasting.close();
|
||||||
return false;
|
setSkillCasting();
|
||||||
}
|
|
||||||
this.skillCasting = skillCasting;
|
|
||||||
return true;
|
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");
|
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
|
@NotNull
|
||||||
@ -1036,27 +1039,27 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* API Method to leave casting mode and fire the PlayerExitCastingModeEvent
|
* 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.
|
* @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(){
|
public boolean leaveSkillCasting() {
|
||||||
return this.leaveSkillCasting(false);
|
return leaveSkillCasting(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param skipEvent Skip Firing the PlayerExitCastingModeEvent
|
* @param skipEvent Skip Firing the PlayerExitCastingModeEvent
|
||||||
* @return true if the PlayerExitCastingModeEvent is not cancelled, or if the event is skipped.
|
* @return true if the PlayerExitCastingModeEvent is not cancelled, or if the event is skipped.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public boolean leaveSkillCasting(boolean skipEvent) {
|
public boolean leaveSkillCasting(boolean skipEvent) {
|
||||||
Validate.isTrue(isCasting(), "Player not in casting mode");
|
Validate.isTrue(isCasting(), "Player not in casting mode");
|
||||||
if (!skipEvent) {
|
if (!skipEvent) {
|
||||||
PlayerExitCastingModeEvent event = new PlayerExitCastingModeEvent(getPlayer());
|
PlayerExitCastingModeEvent event = new PlayerExitCastingModeEvent(getPlayer());
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.broadcastMessage("Leaving casting mode");
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
skillCasting.close();
|
skillCasting.close();
|
||||||
this.skillCasting = null;
|
this.skillCasting = null;
|
||||||
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE, 0); // Reset action bar
|
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.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||||
import net.Indyuce.mmocore.skill.cast.*;
|
import net.Indyuce.mmocore.skill.cast.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -82,7 +82,7 @@ public class KeyCombos implements SkillCastingListener {
|
|||||||
if (event.getPressed().shouldCancelEvent()) event.setCancelled(true);
|
if (event.getPressed().shouldCancelEvent()) event.setCancelled(true);
|
||||||
|
|
||||||
// Start combo
|
// Start combo
|
||||||
if (playerData.setSkillCasting(new CustomSkillCastingInstance(playerData)) && beginComboSound != null)
|
if (playerData.setSkillCasting() && beginComboSound != null)
|
||||||
beginComboSound.playTo(player);
|
beginComboSound.playTo(player);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -97,10 +97,9 @@ public class KeyCombos implements SkillCastingListener {
|
|||||||
// Start combo when there is NO initializer key
|
// Start combo when there is NO initializer key
|
||||||
else {
|
else {
|
||||||
final @NotNull ComboMap comboMap = Objects.requireNonNullElse(playerData.getProfess().getComboMap(), this.comboMap);
|
final @NotNull ComboMap comboMap = Objects.requireNonNullElse(playerData.getProfess().getComboMap(), this.comboMap);
|
||||||
if (comboMap.isComboStart(event.getPressed())) {
|
if (comboMap.isComboStart(event.getPressed()) && playerData.setSkillCasting()) {
|
||||||
casting = new CustomSkillCastingInstance(playerData);
|
casting = (CustomSkillCastingInstance) playerData.getSkillCasting();
|
||||||
if (playerData.setSkillCasting(new CustomSkillCastingInstance(playerData)) && beginComboSound != null)
|
if (beginComboSound != null) beginComboSound.playTo(player);
|
||||||
beginComboSound.playTo(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,6 +173,7 @@ public class KeyCombos implements SkillCastingListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick() {
|
public void onTick() {
|
||||||
|
Bukkit.broadcastMessage("runnable combos");
|
||||||
if (actionBarOptions != null) if (actionBarOptions.isSubtitle)
|
if (actionBarOptions != null) if (actionBarOptions.isSubtitle)
|
||||||
getCaster().getPlayer().sendTitle(" ", actionBarOptions.format(this), 0, 20, 0);
|
getCaster().getPlayer().sendTitle(" ", actionBarOptions.format(this), 0, 20, 0);
|
||||||
else getCaster().displayActionBar(actionBarOptions.format(this));
|
else getCaster().displayActionBar(actionBarOptions.format(this));
|
||||||
|
@ -55,12 +55,10 @@ public class SkillBar implements SkillCastingListener {
|
|||||||
|
|
||||||
// Enter spell casting
|
// Enter spell casting
|
||||||
final PlayerData playerData = event.getData();
|
final PlayerData playerData = event.getData();
|
||||||
if (player.getGameMode() != GameMode.SPECTATOR && (MMOCore.plugin.configManager.canCreativeCast || player.getGameMode() != GameMode.CREATIVE) && !playerData.isCasting() && !playerData.getBoundSkills().isEmpty()) {
|
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 (playerData.setSkillCasting())
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.SPELL_CAST_BEGIN).playTo(player);
|
MMOCore.plugin.soundManager.getSound(SoundEvent.SPELL_CAST_BEGIN).playTo(player);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CustomSkillCastingInstance extends SkillCastingInstance {
|
public class CustomSkillCastingInstance extends SkillCastingInstance {
|
||||||
private final String ready = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.ready").message();
|
private final String ready = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.ready").message();
|
||||||
|
@ -80,7 +80,7 @@ public class SkillScroller implements SkillCastingListener {
|
|||||||
if (event.getPressed().shouldCancelEvent()) event.setCancelled(true);
|
if (event.getPressed().shouldCancelEvent()) event.setCancelled(true);
|
||||||
|
|
||||||
// Enter casting mode
|
// Enter casting mode
|
||||||
if (!playerData.setSkillCasting(new CustomSkillCastingInstance(playerData))) {
|
if (!playerData.setSkillCasting()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user