Make it harder to accidentialy move/equip items in the HotbarGUI
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
14986aedd8
Commit
e408aac608
@ -0,0 +1,32 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
|
||||
public class DenyWorldInteraction_10 implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onSwapItems(PlayerSwapHandItemsEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
@ -39,6 +40,11 @@ public class DenyWorldInteraction implements Listener {
|
||||
public DenyWorldInteraction() {
|
||||
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
|
||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this);
|
||||
if(Core.getVersion() > 9){
|
||||
Listener listener = new DenyWorldInteraction_10();
|
||||
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener);
|
||||
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -68,13 +74,13 @@ public class DenyWorldInteraction implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
||||
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent event) {
|
||||
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked()))
|
||||
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,10 @@ public class HotbarGUI implements Listener {
|
||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(!PersonalKitCreator.notInKitCreator(player))
|
||||
if(PersonalKitCreator.inKitCreator(player))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if(event.getItem() == null)
|
||||
return;
|
||||
|
||||
@ -52,7 +53,6 @@ public class HotbarGUI implements Listener {
|
||||
if(fightTeam == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
ItemMeta itemMeta = event.getItem().getItemMeta();
|
||||
String displayName = itemMeta.getDisplayName();
|
||||
|
||||
|
@ -61,8 +61,8 @@ public class PersonalKitCreator implements Listener {
|
||||
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§eInventar zum Anpassen des Kits öffnen§8!"));
|
||||
}
|
||||
|
||||
public static boolean notInKitCreator(HumanEntity player){
|
||||
return !openKitCreators.containsKey(player);
|
||||
public static boolean inKitCreator(HumanEntity player){
|
||||
return openKitCreators.containsKey(player);
|
||||
}
|
||||
|
||||
public static void closeIfInKitCreator(HumanEntity player){
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren