Fix Item giving
Dieser Commit ist enthalten in:
Ursprung
0b0b9323cc
Commit
cd6ad1a85d
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.PlayerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -27,6 +28,6 @@ class CommandDebugStick_15 {
|
||||
private CommandDebugStick_15(){}
|
||||
|
||||
static void giveStick(Player player){
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.DEBUG_STICK));
|
||||
PlayerUtils.giveItemToPlayer(player, new ItemStack(Material.DEBUG_STICK));
|
||||
}
|
||||
}
|
||||
|
36
BauSystem_API/src/de/steamwar/bausystem/PlayerUtils.java
Normale Datei
36
BauSystem_API/src/de/steamwar/bausystem/PlayerUtils.java
Normale Datei
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.bausystem;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PlayerUtils {
|
||||
|
||||
public static void giveItemToPlayer(Player player, ItemStack itemStack) {
|
||||
ItemStack current = player.getInventory().getItemInMainHand();
|
||||
player.getInventory().setItemInMainHand(itemStack);
|
||||
if (current.getType() != Material.AIR) {
|
||||
player.getInventory().addItem(current);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -21,6 +21,7 @@ package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.PlayerUtils;
|
||||
import de.steamwar.bausystem.world.Detonator;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import org.bukkit.command.Command;
|
||||
@ -62,7 +63,7 @@ public class CommandDetonator implements CommandExecutor {
|
||||
case "wand":
|
||||
case "detonator":
|
||||
case "item":
|
||||
player.getInventory().setItemInMainHand(Detonator.WAND);
|
||||
PlayerUtils.giveItemToPlayer(player, Detonator.WAND);
|
||||
player.updateInventory();
|
||||
Detonator.getDetonator(player);
|
||||
break;
|
||||
|
@ -2,6 +2,7 @@ package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.PlayerUtils;
|
||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
||||
import de.steamwar.bausystem.world.*;
|
||||
@ -574,13 +575,8 @@ public class CommandGUI implements CommandExecutor, Listener {
|
||||
if (strings.length == 0) {
|
||||
openBauGui(player);
|
||||
OPEN_INVS.add(player);
|
||||
} else {
|
||||
if ("item".equalsIgnoreCase(strings[0])) {
|
||||
if (player.getInventory().getItemInMainHand().getType() == Material.AIR)
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.NETHER_STAR));
|
||||
else
|
||||
player.getInventory().addItem(new ItemStack(Material.NETHER_STAR));
|
||||
}
|
||||
} else if ("item".equalsIgnoreCase(strings[0])) {
|
||||
PlayerUtils.giveItemToPlayer(player, new ItemStack(Material.NETHER_STAR));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.PlayerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -67,7 +68,7 @@ public class CommandScript implements CommandExecutor {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
((Player) sender).getInventory().setItemInMainHand(BOOK);
|
||||
PlayerUtils.giveItemToPlayer((Player) sender, BOOK);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.PlayerUtils;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -46,7 +47,7 @@ public class CommandSkull implements CommandExecutor {
|
||||
assert sm != null;
|
||||
sm.setDisplayName("§e" + args[0] + "§8s Kopf");
|
||||
is.setItemMeta(sm);
|
||||
p.getInventory().setItemInMainHand(is);
|
||||
PlayerUtils.giveItemToPlayer(p, is);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren