forked from Upstream/mmocore
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,18 +95,23 @@ 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())) {
|
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.SPELL_CAST_END).playTo(player);
|
|
||||||
|
|
||||||
new BukkitRunnable() {
|
if (event.getPressed() != mainKey) return;
|
||||||
@Override
|
|
||||||
public void run() {
|
// Extra option to improve support with other plugins
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("casting.no-longer").send(getCaster().getPlayer());
|
final Player player = event.getPlayer();
|
||||||
}
|
if (disableSneak && player.isSneaking()) return;
|
||||||
}.runTask(MMOCore.plugin);
|
|
||||||
getCaster().leaveSkillCasting();
|
MMOCore.plugin.soundManager.getSound(SoundEvent.SPELL_CAST_END).playTo(player);
|
||||||
}
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MMOCore.plugin.configManager.getSimpleMessage("casting.no-longer").send(getCaster().getPlayer());
|
||||||
|
}
|
||||||
|
}.runTask(MMOCore.plugin);
|
||||||
|
getCaster().leaveSkillCasting();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFormat(PlayerData data) {
|
private String getFormat(PlayerData data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user