SteamWar/BauSystem2.0
Archiviert
12
0

Add ChestFiller
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-08-27 22:50:42 +02:00
Ursprung cc9bd07743
Commit 777f3cd506
3 geänderte Dateien mit 57 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -1241,6 +1241,8 @@ SELECT_ITEM_BAURAHMEN=§eBuild area
SELECT_ITEM_BAUPLATTFORM=§eBuild platform
SELECT_ITEM_TESTBLOCK=§eDummy
CHESTFILLER_FILLED = §eChest filled
# Warp
WARP_DISALLOWED = §cYou are not allowed to use the warp here
WARP_LOC_X = §7X§8: §e{0}

Datei anzeigen

@ -1221,6 +1221,8 @@ SELECT_ITEM_BAURAHMEN=§eBaurahmen
SELECT_ITEM_BAUPLATTFORM=§eBauplattform
SELECT_ITEM_TESTBLOCK=§eTestblock
CHESTFILLER_FILLED = §eKiste gefüllt
# Warp
WARP_DISALLOWED = §cDu darfst hier nicht das Warp System nutzen
WARP_LOC_X = §7X§8: §e{0}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.features.util;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.block.Block;
import org.bukkit.block.Container;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@Linked(LinkageType.LISTENER)
public class ChestFiller implements Listener {
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
if (!event.getPlayer().isSneaking()) return;
Block block = event.getPlayer().getTargetBlockExact(5);
if (block == null) return;
if (!(block.getState() instanceof Container)) return;
Container container = (Container) block.getState();
Inventory inventory = container.getInventory();
ItemStack itemStack = event.getItemDrop().getItemStack().clone();
itemStack.setAmount(itemStack.getType().getMaxStackSize());
event.setCancelled(true);
for (int i = 0; i < inventory.getSize(); i++) {
inventory.setItem(i, itemStack);
}
BauSystem.MESSAGE.sendPrefixless("CHESTFILLER_FILLED", event.getPlayer(), ChatMessageType.ACTION_BAR);
}
}