mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
hotbar swap
This commit is contained in:
parent
52183f81f6
commit
952df8f8b9
@ -9,7 +9,6 @@ import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import net.Indyuce.mmocore.api.PlayerActionBar;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
import net.Indyuce.mmocore.api.util.debug.DebugMode;
|
||||
import net.Indyuce.mmocore.command.*;
|
||||
@ -27,6 +26,7 @@ import net.Indyuce.mmocore.comp.region.WorldGuardMMOLoader;
|
||||
import net.Indyuce.mmocore.comp.region.WorldGuardRegionHandler;
|
||||
import net.Indyuce.mmocore.comp.vault.VaultEconomy;
|
||||
import net.Indyuce.mmocore.comp.vault.VaultMMOLoader;
|
||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||
import net.Indyuce.mmocore.listener.*;
|
||||
import net.Indyuce.mmocore.listener.event.PlayerPressKeyListener;
|
||||
import net.Indyuce.mmocore.listener.option.*;
|
||||
@ -251,6 +251,13 @@ public class MMOCore extends LuminePlugin {
|
||||
if (configManager.overrideVanillaExp = getConfig().getBoolean("override-vanilla-exp"))
|
||||
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), this);
|
||||
|
||||
if (getConfig().getBoolean("hotbar-swapping.enabled"))
|
||||
try {
|
||||
Bukkit.getPluginManager().registerEvents(new HotbarSwap(getConfig().getConfigurationSection("hotbar-swapping")), this);
|
||||
} catch (RuntimeException exception) {
|
||||
getLogger().log(Level.WARNING, "Could not load hotbar swapping: " + exception.getMessage());
|
||||
}
|
||||
|
||||
if (getConfig().getBoolean("prevent-spawner-xp"))
|
||||
Bukkit.getPluginManager().registerEvents(new NoSpawnerEXP(), this);
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
package net.Indyuce.mmocore.api.util.math.format;
|
||||
|
||||
public class RomanFormat {
|
||||
|
||||
public RomanFormat() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
@ -32,10 +32,6 @@ public class GoldPouch extends PluginInventory {
|
||||
return inv;
|
||||
}
|
||||
|
||||
/*
|
||||
* if the player has opened a backpack, he cannot click a backpack. bug fix
|
||||
* - the player can move the backpack and lose the inventory he had opened
|
||||
*/
|
||||
@Override
|
||||
public void whenClicked(InventoryClickEvent event) {
|
||||
|
||||
@ -63,6 +59,12 @@ public class GoldPouch extends PluginInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Player cannot interact with a backpack item while
|
||||
* interacting with a backpack inventory. This fixes a
|
||||
* huge glitch where the player would lose the backpack
|
||||
* contents
|
||||
*/
|
||||
if (nbt.hasTag("RpgPouchInventory"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.guild.AbstractGuild;
|
||||
import net.Indyuce.mmocore.guild.GuildModule;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class UltimateClansGuildModule implements GuildModule {
|
||||
private static final UClans API = (UClans) Bukkit.getPluginManager().getPlugin("UltimateCLans");
|
||||
@ -17,8 +16,6 @@ public class UltimateClansGuildModule implements GuildModule {
|
||||
}
|
||||
|
||||
class CustomGuild implements AbstractGuild {
|
||||
|
||||
@Nullable
|
||||
private final ClanData clan;
|
||||
|
||||
CustomGuild(ClanData clan) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.Indyuce.mmocore.listener;
|
||||
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.gui.eco.GoldPouch;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -8,9 +10,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmocore.gui.eco.GoldPouch;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
|
||||
public class GoldPouchesListener implements Listener {
|
||||
@EventHandler
|
||||
public void a(PlayerInteractEvent event) {
|
||||
@ -21,11 +20,13 @@ public class GoldPouchesListener implements Listener {
|
||||
if (!nbt.hasTag("RpgPouchInventory"))
|
||||
return;
|
||||
|
||||
// that way ppl can't open a chest when right clicking a backpack
|
||||
// when they wanted to open the backpack
|
||||
/*
|
||||
* That way players cannot open a chest when right clicking
|
||||
* a backpack when they wanted to open the backpack
|
||||
*/
|
||||
event.setCancelled(true);
|
||||
|
||||
// dupe bug : open 2 stacked backpacks and split them to dupe.
|
||||
// Dupe bug: open 2 stacked backpacks and split them to dupe.
|
||||
if (event.getItem().getAmount() > 1)
|
||||
return;
|
||||
|
||||
@ -33,9 +34,9 @@ public class GoldPouchesListener implements Listener {
|
||||
}
|
||||
|
||||
/*
|
||||
* if a player has a backpack open, he cannot pick up a backpack. bug fix -
|
||||
* If a player has a backpack open, he cannot pick up a backpack. bug fix -
|
||||
* he can pick up a backpack, and dupe items when the items are saved in a
|
||||
* amount=2 backpack itemstack TODO register and unregister listener.
|
||||
* amount=2 backpack itemstack
|
||||
*/
|
||||
@EventHandler
|
||||
public void b(EntityPickupItemEvent event) {
|
||||
|
@ -0,0 +1,41 @@
|
||||
package net.Indyuce.mmocore.listener.option;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
|
||||
import net.Indyuce.mmocore.skill.cast.PlayerKey;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class HotbarSwap implements Listener {
|
||||
private final PlayerKey keybind;
|
||||
private final boolean crouching;
|
||||
|
||||
public HotbarSwap(ConfigurationSection config) {
|
||||
this.keybind = PlayerKey.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("keybind"), "Could not find keybind")));
|
||||
this.crouching = config.getBoolean("crouching");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void keyPress(PlayerKeyPressEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getPressed() == keybind && event.getPlayer().isSneaking() == crouching) {
|
||||
|
||||
if (event.getPressed().shouldCancelEvent())
|
||||
event.setCancelled(true);
|
||||
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.HOTBAR_SWAP).playTo(player);
|
||||
for (int j = 0; j < 9; j++) {
|
||||
ItemStack replaced = player.getInventory().getItem(j + 9 * 3);
|
||||
player.getInventory().setItem(j + 9 * 3, player.getInventory().getItem(j));
|
||||
player.getInventory().setItem(j, replaced);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +1,35 @@
|
||||
package net.Indyuce.mmocore.listener.option;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
public class VanillaExperienceOverride implements Listener {
|
||||
|
||||
/*
|
||||
* when picking up exp orbs or any action like that
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void a(PlayerExpChangeEvent event) {
|
||||
event.setAmount(0);
|
||||
}
|
||||
/**
|
||||
* When picking up exp orbs or any action like that
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void a(PlayerExpChangeEvent event) {
|
||||
event.setAmount(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* this event is not supported by the expChangeEvent. since the event is
|
||||
* actually called before applying the enchant and consuming levels, we must
|
||||
* update the player level using a delayed task. setExpLevelCost(level) DOES
|
||||
* NOT WORK
|
||||
*/
|
||||
@EventHandler
|
||||
public void b(EnchantItemEvent event) {
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> event.getEnchanter().setLevel(PlayerData.get(event.getEnchanter()).getLevel()));
|
||||
}
|
||||
/**
|
||||
* This event is not supported by the expChangeEvent. Since the event is
|
||||
* actually called before applying the enchant and consuming levels, we must
|
||||
* update the player level using a delayed task.
|
||||
* <p>
|
||||
* {@link EnchantItemEvent#setExpLevelCost(int)} does NOT work
|
||||
*/
|
||||
@EventHandler
|
||||
public void b(EnchantItemEvent event) {
|
||||
Player player = event.getEnchanter();
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> player.setLevel(PlayerData.get(player).getLevel()));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.Indyuce.mmocore.manager;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.util.EnumUtils;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
@ -28,7 +27,6 @@ public class ConfigManager {
|
||||
public String partyChatPrefix, noSkillBoundPlaceholder;
|
||||
public ChatColor staminaFull, staminaHalf, staminaEmpty;
|
||||
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
|
||||
public SwapAction normalSwapAction, sneakingSwapAction;
|
||||
|
||||
private final FileConfiguration messages;
|
||||
private final boolean chatInput;
|
||||
@ -104,8 +102,6 @@ public class ConfigManager {
|
||||
staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GREEN);
|
||||
staminaEmpty = getColorOrDefault("stamina-empty", ChatColor.WHITE);
|
||||
|
||||
normalSwapAction = EnumUtils.getIfPresent(SwapAction.class, MMOCore.plugin.getConfig().getString("swap-keybind.normal").toUpperCase()).orElse(SwapAction.VANILLA);
|
||||
sneakingSwapAction = EnumUtils.getIfPresent(SwapAction.class, MMOCore.plugin.getConfig().getString("swap-keybind.sneaking").toUpperCase()).orElse(SwapAction.VANILLA);
|
||||
canCreativeCast = MMOCore.plugin.getConfig().getBoolean("can-creative-cast");
|
||||
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
|
||||
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");
|
||||
@ -177,10 +173,4 @@ public class ConfigManager {
|
||||
return !msg.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public enum SwapAction {
|
||||
VANILLA,
|
||||
SPELL_CAST,
|
||||
HOTBAR_SWAP
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public enum SkillCastingMode {
|
||||
SKILL_BAR(config -> new SkillBar(config)),
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
*/
|
||||
SKILL_SCROLL(config -> new SkillScroller(config)),
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmocore.skill.cast.listener;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.player.PlayerMetadata;
|
||||
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
||||
@ -7,7 +8,6 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.ConfigManager;
|
||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||
import net.Indyuce.mmocore.skill.cast.PlayerKey;
|
||||
import net.Indyuce.mmocore.skill.cast.SkillCastingHandler;
|
||||
@ -17,7 +17,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -25,7 +24,7 @@ public class SkillBar implements Listener {
|
||||
private final PlayerKey mainKey;
|
||||
|
||||
public SkillBar(ConfigurationSection config) {
|
||||
mainKey = PlayerKey.valueOf(Objects.requireNonNull(config.getString("open"), "Could not find open key"));
|
||||
mainKey = PlayerKey.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("open"), "Could not find open key")));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -61,7 +60,7 @@ public class SkillBar implements Listener {
|
||||
super(playerData, 1);
|
||||
}
|
||||
|
||||
@EventHandler()
|
||||
@EventHandler
|
||||
public void onSkillCast(PlayerItemHeldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!getCaster().isOnline()) return;
|
||||
@ -91,13 +90,9 @@ public class SkillBar implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopCasting(PlayerSwapHandItemsEvent event) {
|
||||
public void stopCasting(PlayerKeyPressEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ConfigManager.SwapAction action = player.isSneaking()
|
||||
? MMOCore.plugin.configManager.sneakingSwapAction
|
||||
: MMOCore.plugin.configManager.normalSwapAction;
|
||||
if (action != ConfigManager.SwapAction.SPELL_CAST || !getCaster().isOnline()) return;
|
||||
if (event.getPlayer().equals(getCaster().getPlayer())) {
|
||||
if (event.getPressed() == mainKey && event.getPlayer().equals(getCaster().getPlayer())) {
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.SPELL_CAST_END).playTo(player);
|
||||
MMOCore.plugin.configManager.getSimpleMessage("casting.no-longer").send(getCaster().getPlayer());
|
||||
PlayerData.get(player).leaveCastingMode();
|
||||
|
@ -1,14 +1,6 @@
|
||||
#
|
||||
# ███ ███ ███ ███ ██████ ██████ ██████ ██████ ███████
|
||||
# ████ ████ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
# ██ ████ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██████ █████
|
||||
# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
# ██ ██ ██ ██ ██████ ██████ ██████ ██ ██ ███████
|
||||
#
|
||||
# a Spigot Plugin by Team Requiem
|
||||
|
||||
# DO NOT TOUCH
|
||||
config-version: 8
|
||||
config-version: 9
|
||||
|
||||
# Auto-Save feature automatically saves playerdata
|
||||
# (class, level, etc.) and guild data
|
||||
@ -157,7 +149,7 @@ death-exp-loss:
|
||||
# Fun extra RPG feature that switches the player's hotbar with
|
||||
# the 9 lower row items of his inventory. This allows the player
|
||||
# to have two different item sets or quickly have access to pots
|
||||
# TODO
|
||||
# Requires a SERVER reload when changed.
|
||||
hotbar-swapping:
|
||||
enabled: true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user