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