Commits vergleichen
8 Commits
Autor | SHA1 | Datum | |
---|---|---|---|
|
f94ed415a4 | ||
|
bbe7edc55a | ||
|
5555da69aa | ||
|
fa9f5792ea | ||
|
9faa238f7d | ||
|
d9f0ca901d | ||
|
701667ab29 | ||
|
6d09635a38 |
|
@ -741,6 +741,9 @@ NIGHT_VISION_OFF=§eNightvision deactivated
|
|||
NIGHT_VISION_ON=§eNightvision activated
|
||||
NIGHT_VISION_ITEM_ON = §7Nightvision: §eActivated
|
||||
NIGHT_VISION_ITEM_OFF = §7Nightvision: §eDeactivated
|
||||
#Autodust
|
||||
AUTODUST_ENABLE=§eAutodust was enabled.
|
||||
AUTODUST_DISABLE=§eAutodust was disabled.
|
||||
|
||||
#Navigation Wand
|
||||
NAVIGATION_WAND=§eNavigation Wand
|
||||
|
|
|
@ -706,6 +706,9 @@ NIGHT_VISION_OFF=§eNightvision deaktiviert
|
|||
NIGHT_VISION_ON=§eNightvision aktiviert
|
||||
NIGHT_VISION_ITEM_ON = §7Nightvision: §eAktiviert
|
||||
NIGHT_VISION_ITEM_OFF = §7Nightvision: §eDeaktiviert
|
||||
#Autodust
|
||||
AUTODUST_ENABLE=§eAutodust wurde aktiviert.
|
||||
AUTODUST_DISABLE=§eAutodust wurde deaktiviert.
|
||||
|
||||
#Navigation Wand
|
||||
NAVIGATION_WAND=§eNavigation Wand
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 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.autodust;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.region.Color;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Linked
|
||||
public class AutoDustCommand extends SWCommand implements Listener {
|
||||
|
||||
private static final Pattern COLORED_BLOCK_REGEX = Pattern.compile(
|
||||
"^(\\w+?)_(wool|stained_glass|concrete_powder|concrete|glazed_terracotta|terracotta)$"
|
||||
);
|
||||
|
||||
|
||||
public AutoDustCommand() {
|
||||
super("autodust", "dust");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
boolean autoDust = Config.getInstance().get(p).getPlainValueOrDefault("autodust", false);
|
||||
Config.getInstance().get(p).put("autodust", !autoDust);
|
||||
|
||||
if(!autoDust) {
|
||||
BauSystem.MESSAGE.send("AUTODUST_ENABLE",p);
|
||||
SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("AUTODUST_ENABLE", p));
|
||||
}else {
|
||||
BauSystem.MESSAGE.send("AUTODUST_DISABLE",p);
|
||||
SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("AUTODUST_DISABLE", p));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(BlockPlaceEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
|
||||
if(!Config.getInstance().get(p).getPlainValueOrDefault("autodust", false)) return;
|
||||
|
||||
Block placed = event.getBlockPlaced();
|
||||
if (!placed.getType().isBlock() || !placed.getType().isSolid()) {
|
||||
return;
|
||||
}
|
||||
String type = placed.getType().name();
|
||||
boolean isColored = false;
|
||||
for (Color color : Color.values()) {
|
||||
if (type.startsWith(color.name() + "_")) {
|
||||
isColored = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isColored) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block above = placed.getRelative(BlockFace.UP);
|
||||
if (!above.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
above.setType(Material.REDSTONE_WIRE);
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren