SteamWar/FightSystem
Archiviert
13
1

Make it harder to accidentialy move/equip items in the HotbarGUI

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-05-24 09:31:58 +02:00
Ursprung 14986aedd8
Commit e408aac608
4 geänderte Dateien mit 44 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentListener;
@ -39,6 +40,11 @@ public class DenyWorldInteraction implements Listener {
public DenyWorldInteraction() { public DenyWorldInteraction() {
new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this); new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this);
new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, 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 @EventHandler
@ -68,13 +74,13 @@ public class DenyWorldInteraction implements Listener {
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked())) if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void onInventoryDrag(InventoryDragEvent event) { public void onInventoryDrag(InventoryDragEvent event) {
if(PersonalKitCreator.notInKitCreator(event.getWhoClicked())) if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
event.setCancelled(true); event.setCancelled(true);
} }

Datei anzeigen

@ -42,9 +42,10 @@ public class HotbarGUI implements Listener {
public void handlePlayerInteract(PlayerInteractEvent event) { public void handlePlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if(!PersonalKitCreator.notInKitCreator(player)) if(PersonalKitCreator.inKitCreator(player))
return; return;
event.setCancelled(true);
if(event.getItem() == null) if(event.getItem() == null)
return; return;
@ -52,7 +53,6 @@ public class HotbarGUI implements Listener {
if(fightTeam == null) if(fightTeam == null)
return; return;
event.setCancelled(true);
ItemMeta itemMeta = event.getItem().getItemMeta(); ItemMeta itemMeta = event.getItem().getItemMeta();
String displayName = itemMeta.getDisplayName(); String displayName = itemMeta.getDisplayName();

Datei anzeigen

@ -61,8 +61,8 @@ public class PersonalKitCreator implements Listener {
BasicListener.toActionbar(player, TextComponent.fromLegacyText("§eInventar zum Anpassen des Kits öffnen§8!")); BasicListener.toActionbar(player, TextComponent.fromLegacyText("§eInventar zum Anpassen des Kits öffnen§8!"));
} }
public static boolean notInKitCreator(HumanEntity player){ public static boolean inKitCreator(HumanEntity player){
return !openKitCreators.containsKey(player); return openKitCreators.containsKey(player);
} }
public static void closeIfInKitCreator(HumanEntity player){ public static void closeIfInKitCreator(HumanEntity player){