forked from Upstream/mmocore
more cleanup
This commit is contained in:
parent
3cf8886349
commit
591e92c46c
@ -1,5 +1,10 @@
|
||||
package net.Indyuce.mmocore.listener;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.ConfigManager;
|
||||
import net.Indyuce.mmocore.manager.SoundManager;
|
||||
import net.Indyuce.mmocore.skill.Skill.SkillInfo;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,27 +16,23 @@ import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.skill.Skill.SkillInfo;
|
||||
import net.Indyuce.mmocore.manager.ConfigManager;
|
||||
import net.Indyuce.mmocore.manager.SoundManager;
|
||||
|
||||
public class SpellCast implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerSwapHandItemsEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ConfigManager.SwapAction action = player.isSneaking()
|
||||
? MMOCore.plugin.configManager.sneakingSwapAction
|
||||
: MMOCore.plugin.configManager.normalSwapAction;
|
||||
ConfigManager.SwapAction action = player.isSneaking() ? MMOCore.plugin.configManager.sneakingSwapAction : MMOCore.plugin.configManager.normalSwapAction;
|
||||
|
||||
if(action == ConfigManager.SwapAction.VANILLA) return;
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
// Vanilla action does nothing
|
||||
if (action == ConfigManager.SwapAction.VANILLA)
|
||||
return;
|
||||
|
||||
// Always cancel event if it's not the vanilla action
|
||||
event.setCancelled(true);
|
||||
|
||||
/*
|
||||
* hotbar swap feature only if the player is sneaking while entering
|
||||
* skill casting mode
|
||||
* Hotbar swap feature, this entirely switches the
|
||||
* player's hotbar with their 9 lowest inventory slots
|
||||
*/
|
||||
if (action == ConfigManager.SwapAction.HOTBAR_SWAP) {
|
||||
MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.HOTBAR_SWAP);
|
||||
@ -43,8 +44,12 @@ public class SpellCast implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!((!MMOCore.plugin.configManager.canCreativeCast && player.getGameMode() == GameMode.CREATIVE) || player.getGameMode() == GameMode.SPECTATOR)
|
||||
&& !playerData.isCasting() && playerData.getBoundSkills().size() > 0) {
|
||||
// Enter spell casting
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
if (player.getGameMode() != GameMode.SPECTATOR
|
||||
&& (MMOCore.plugin.configManager.canCreativeCast || player.getGameMode() != GameMode.CREATIVE)
|
||||
&& !playerData.isCasting()
|
||||
&& playerData.getBoundSkills().size() > 0) {
|
||||
playerData.skillCasting = new SkillCasting(playerData);
|
||||
MMOCore.plugin.soundManager.play(player, SoundManager.SoundEvent.SPELL_CAST_BEGIN);
|
||||
}
|
||||
@ -144,7 +149,8 @@ public class SpellCast implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!playerData.isOnline() || playerData.getPlayer().isDead()) {
|
||||
close(); return;
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (j % 20 == 0)
|
||||
|
@ -135,17 +135,14 @@ death-exp-loss:
|
||||
# Percentage of current EXP you lose when dying.
|
||||
percent: 30
|
||||
|
||||
# Put the "value" of the action you want.
|
||||
# If the value is invalid or empty it will
|
||||
# default to the vanilla minecraft action.
|
||||
# spell_cast
|
||||
# Enters the default spell casting mode
|
||||
# hotbar_swap
|
||||
# Players can swap their hotbar with the 9 inventory slots
|
||||
# right above it by pressing [swap items] while crouching.
|
||||
# THis allows players to have two combat item sets.
|
||||
# - vanilla
|
||||
# The default F action, swapping main hand and offhand.
|
||||
# Modify the keybinds for the 'swap hand items' key (F by default)
|
||||
#
|
||||
# Available actions:
|
||||
# - spell_cast (enters the default spell casting mode)
|
||||
# - vanilla (swaps hand items)
|
||||
# - hotbar_swap (swap the player's horbat with the 9 lowest inventory slots)
|
||||
#
|
||||
# If the action is invalid, it will use 'vanilla' by default
|
||||
swap-keybind:
|
||||
normal: spell_cast
|
||||
sneaking: hotbar_swap
|
||||
|
Loading…
Reference in New Issue
Block a user