Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
a573836bd6
Commit
76631908f0
@ -46,6 +46,7 @@ FLAG_TNT = TNT
|
||||
FLAG_FIRE = Fire
|
||||
FLAG_FREEZE = Freeze
|
||||
FLAG_PROTECT = Protect
|
||||
FLAG_ITEMS = Items
|
||||
|
||||
FLAG_FIRE_ALLOW = §con
|
||||
FLAG_FIRE_DENY = §aoff
|
||||
@ -60,6 +61,9 @@ FLAG_TNT_ALLOW = §aon
|
||||
FLAG_TNT_DENY = §coff
|
||||
FLAG_TNT_ONLY_TB = §7no §ebuild area
|
||||
|
||||
FLAG_ITEMS_ACTIVE = §aon
|
||||
FLAG_ITEMS_INACTIVE = §coff
|
||||
|
||||
FLAG_COLOR_WHITE = §fWhite
|
||||
FLAG_COLOR_ORANGE = §6Orange
|
||||
FLAG_COLOR_MAGENTA = §dMagenta
|
||||
@ -1052,6 +1056,11 @@ REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
|
||||
REGION_FREEZE_NO_PERMS=§cYou are not allowed to freeze this world
|
||||
REGION_FREEZE_ENABLED=§cRegion frozen
|
||||
REGION_FREEZE_DISABLED=§aRegion thawed
|
||||
REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items
|
||||
REGION_ITEMS_NO_PERMS=§cYou are not allowed to toggle items in this world
|
||||
REGION_ITEMS_ENABLED=§cItems disabled in this region
|
||||
REGION_ITEMS_ENABLED_GLOBAL=§cItems disabled in this world
|
||||
REGION_ITEMS_DISABLED=§aItems enabled in this region
|
||||
REGION_PROTECT_HELP=§8/§eprotect §8- §7Protect the region
|
||||
REGION_PROTECT_DISABLE=§cProtection disabled
|
||||
REGION_PROTECT_ENABLE=§aProtection enabled
|
||||
|
@ -46,6 +46,7 @@ FLAG_TNT = TNT
|
||||
FLAG_FIRE = Fire
|
||||
FLAG_FREEZE = Freeze
|
||||
FLAG_PROTECT = Protect
|
||||
FLAG_ITEMS = Items
|
||||
|
||||
FLAG_FIRE_ALLOW = §can
|
||||
FLAG_FIRE_DENY = §aaus
|
||||
@ -60,6 +61,9 @@ FLAG_TNT_ALLOW = §aan
|
||||
FLAG_TNT_DENY = §caus
|
||||
FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen
|
||||
|
||||
FLAG_ITEMS_ACTIVE = §aan
|
||||
FLAG_ITEMS_INACTIVE = §caus
|
||||
|
||||
FLAG_COLOR_WHITE = §fWeiß
|
||||
FLAG_COLOR_ORANGE = §6Orange
|
||||
FLAG_COLOR_MAGENTA = §dMagenta
|
||||
@ -1021,6 +1025,11 @@ REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
|
||||
REGION_FREEZE_NO_PERMS=§cDu darfst diese Welt nicht einfrieren
|
||||
REGION_FREEZE_ENABLED=§cRegion eingefroren
|
||||
REGION_FREEZE_DISABLED=§aRegion aufgetaut
|
||||
REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items
|
||||
REGION_ITEMS_NO_PERMS=§cDu darfst hier nicht Items (de-)aktivieren
|
||||
REGION_ITEMS_ENABLED=§cItems deaktiviert in dieser Region
|
||||
REGION_ITEMS_ENABLED_GLOBAL=§cItems sind auf dem Server deaktiviert.
|
||||
REGION_ITEMS_DISABLED=§aItems aktiviert in dieser Region
|
||||
REGION_PROTECT_HELP=§8/§eprotect §8- §7Schütze die Region
|
||||
REGION_PROTECT_DISABLE=§cBoden Schutz aufgehoben
|
||||
REGION_PROTECT_ENABLE=§aBoden geschützt
|
||||
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.region;
|
||||
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
@MinVersion(19)
|
||||
public class ItemsCommand extends SWCommand {
|
||||
|
||||
public ItemsCommand() {
|
||||
super("items");
|
||||
}
|
||||
|
||||
@Register(description = "REGION_ITEMS_HELP")
|
||||
public void toggleCommand(@Validator Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (region != GlobalRegion.getInstance() && GlobalRegion.getInstance().getPlain(Flag.ITEMS, ItemMode.class) == ItemMode.INACTIVE) {
|
||||
RegionUtils.actionBar(region, "REGION_ITEMS_ENABLED_GLOBAL");
|
||||
return;
|
||||
}
|
||||
|
||||
if (toggle(region)) {
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
} else {
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String getNoPermMessage() {
|
||||
return "REGION_ITEMS_NO_PERMS";
|
||||
}
|
||||
|
||||
private String getEnableMessage(){
|
||||
return "REGION_ITEMS_ENABLED";
|
||||
}
|
||||
|
||||
private String getDisableMessage(){
|
||||
return "REGION_ITEMS_DISABLED";
|
||||
}
|
||||
|
||||
private boolean toggle(Region region) {
|
||||
switch (region.getPlain(Flag.ITEMS, ItemMode.class)) {
|
||||
case ACTIVE:
|
||||
region.set(Flag.ITEMS, ItemMode.INACTIVE);
|
||||
return false;
|
||||
default:
|
||||
case INACTIVE:
|
||||
region.set(Flag.ITEMS, ItemMode.ACTIVE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ClassValidator(value = Player.class, local = true)
|
||||
public TypeValidator<Player> validator() {
|
||||
return (commandSender, player, messageSender) -> {
|
||||
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage());
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
|
||||
@Linked
|
||||
@MinVersion(19)
|
||||
public class ItemsListener implements Listener, ScoreboardElement {
|
||||
|
||||
private static ItemMode getMode(Region region) {
|
||||
ItemMode itemMode = GlobalRegion.getInstance().getPlain(Flag.ITEMS, ItemMode.class);
|
||||
if (itemMode == ItemMode.INACTIVE) return ItemMode.INACTIVE;
|
||||
return region.getPlain(Flag.ITEMS, ItemMode.class);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemSpawn(ItemSpawnEvent event) {
|
||||
if (getMode(Region.getRegion(event.getLocation())) == ItemMode.INACTIVE) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreboardGroup getGroup() {
|
||||
return ScoreboardGroup.REGION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
ItemMode itemMode = getMode(region);
|
||||
if (itemMode == ItemMode.ACTIVE) return null;
|
||||
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(itemMode.getChatValue(), p);
|
||||
}
|
||||
}
|
@ -84,7 +84,7 @@ public class FlagStorage {
|
||||
}
|
||||
|
||||
public Flag.Value<?> get(final Flag flagType) {
|
||||
return flags.get(flagType);
|
||||
return flags.getOrDefault(flagType, flagType.getDefaultValue());
|
||||
}
|
||||
|
||||
public boolean set(final Tag tag) {
|
||||
|
@ -33,7 +33,9 @@ public enum Flag implements EnumDisplay {
|
||||
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB),
|
||||
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW),
|
||||
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE),
|
||||
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE);
|
||||
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE),
|
||||
ITEMS("FLAG_ITEMS", ItemMode.class, ItemMode.ACTIVE),
|
||||
;
|
||||
|
||||
@Getter
|
||||
private static final Set<Flag> flags;
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 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.region.flags.flagvalues;
|
||||
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ItemMode implements Flag.Value<ItemMode> {
|
||||
|
||||
ACTIVE("FLAG_ITEMS_ACTIVE"),
|
||||
INACTIVE("FLAG_ITEMS_INACTIVE");
|
||||
|
||||
private static ItemMode[] values;
|
||||
private final String chatValue;
|
||||
|
||||
@Override
|
||||
public ItemMode[] getValues() {
|
||||
if (ItemMode.values == null) {
|
||||
ItemMode.values = ItemMode.values(); //NOSONAR
|
||||
}
|
||||
return ItemMode.values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemMode getValue() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemMode getValueOf(final String name) {
|
||||
try {
|
||||
return ItemMode.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (name.equalsIgnoreCase("false")) {
|
||||
return ItemMode.INACTIVE;
|
||||
}
|
||||
return ItemMode.ACTIVE;
|
||||
}
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren