mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-24 04:57:36 +01:00
Fixed 'disable-sneak'
This commit is contained in:
parent
1a987535ee
commit
7f6ba0f272
@ -31,15 +31,18 @@ public class SkillBar implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void a(PlayerKeyPressEvent event) {
|
public void enterSkillCasting(PlayerKeyPressEvent event) {
|
||||||
if (event.getPressed() != mainKey) return;
|
if (event.getPressed() != mainKey) return;
|
||||||
|
|
||||||
|
// Extra option to improve support with other plugins
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (disableSneak && player.isSneaking()) return;
|
||||||
|
|
||||||
// Always cancel event
|
// Always cancel event
|
||||||
if (event.getPressed().shouldCancelEvent()) event.setCancelled(true);
|
if (event.getPressed().shouldCancelEvent()) event.setCancelled(true);
|
||||||
|
|
||||||
// Enter spell casting
|
// Enter spell casting
|
||||||
Player player = event.getData().getPlayer();
|
final PlayerData playerData = event.getData();
|
||||||
PlayerData playerData = event.getData();
|
|
||||||
if (player.getGameMode() != GameMode.SPECTATOR && (MMOCore.plugin.configManager.canCreativeCast || player.getGameMode() != GameMode.CREATIVE) && !playerData.isCasting() && !playerData.getBoundSkills()
|
if (player.getGameMode() != GameMode.SPECTATOR && (MMOCore.plugin.configManager.canCreativeCast || player.getGameMode() != GameMode.CREATIVE) && !playerData.isCasting() && !playerData.getBoundSkills()
|
||||||
.isEmpty()) {
|
.isEmpty()) {
|
||||||
playerData.setSkillCasting(new CustomSkillCastingHandler(playerData));
|
playerData.setSkillCasting(new CustomSkillCastingHandler(playerData));
|
||||||
@ -64,10 +67,9 @@ public class SkillBar implements Listener {
|
|||||||
public void onSkillCast(PlayerItemHeldEvent event) {
|
public void onSkillCast(PlayerItemHeldEvent event) {
|
||||||
if (!event.getPlayer().equals(getCaster().getPlayer())) return;
|
if (!event.getPlayer().equals(getCaster().getPlayer())) return;
|
||||||
|
|
||||||
if (!getCaster().isOnline()) {
|
// Extra option to improve support with other plugins
|
||||||
getCaster().leaveSkillCasting();
|
final Player player = event.getPlayer();
|
||||||
return;
|
if (disableSneak && player.isSneaking()) return;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When the event is cancelled, another playerItemHeldEvent is
|
* When the event is cancelled, another playerItemHeldEvent is
|
||||||
@ -76,10 +78,6 @@ public class SkillBar implements Listener {
|
|||||||
*/
|
*/
|
||||||
if (event.getPreviousSlot() == event.getNewSlot()) return;
|
if (event.getPreviousSlot() == event.getNewSlot()) return;
|
||||||
|
|
||||||
// Extra option to improve support with other plugins
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (disableSneak && player.isSneaking()) return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
int slot = event.getNewSlot() + (event.getNewSlot() >= player.getInventory().getHeldItemSlot() ? -1 : 0);
|
int slot = event.getNewSlot() + (event.getNewSlot() >= player.getInventory().getHeldItemSlot() ? -1 : 0);
|
||||||
|
|
||||||
@ -97,8 +95,14 @@ public class SkillBar implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void stopCasting(PlayerKeyPressEvent event) {
|
public void stopCasting(PlayerKeyPressEvent event) {
|
||||||
Player player = event.getPlayer();
|
if (!event.getPlayer().equals(getCaster().getPlayer())) return;
|
||||||
if (event.getPressed() == mainKey && event.getPlayer().equals(getCaster().getPlayer())) {
|
|
||||||
|
if (event.getPressed() != mainKey) return;
|
||||||
|
|
||||||
|
// Extra option to improve support with other plugins
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (disableSneak && player.isSneaking()) return;
|
||||||
|
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.SPELL_CAST_END).playTo(player);
|
MMOCore.plugin.soundManager.getSound(SoundEvent.SPELL_CAST_END).playTo(player);
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@ -109,7 +113,6 @@ public class SkillBar implements Listener {
|
|||||||
}.runTask(MMOCore.plugin);
|
}.runTask(MMOCore.plugin);
|
||||||
getCaster().leaveSkillCasting();
|
getCaster().leaveSkillCasting();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private String getFormat(PlayerData data) {
|
private String getFormat(PlayerData data) {
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
|
Loading…
Reference in New Issue
Block a user