Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
65cf7ffe77
Commit
a317891685
@ -701,26 +701,16 @@ KILLCHECKER_BOSSBAR = §e§l{0} §7(§e{1}%§7) §e§l{2}§7 cannons
|
|||||||
BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Toggle on/off
|
BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Toggle on/off
|
||||||
BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Toggles BlockCounter on
|
BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Toggles BlockCounter on
|
||||||
BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Toggles BlockCounter off
|
BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Toggles BlockCounter off
|
||||||
BLOCK_COUNTER_MESSAGE = §7Counter §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/tick
|
BLOCK_COUNTER_MESSAGE = §7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/tick
|
||||||
BLOCK_COUNTER_MESSAGE_SECOND = §7Counter §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/s
|
BLOCK_COUNTER_MESSAGE_SECOND = §7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/s
|
||||||
BLOCK_COUNTER_ENABLE = §7BlockCounter activated
|
BLOCK_COUNTER_ENABLE = §7BlockCounter activated
|
||||||
BLOCK_COUNTER_DISABLE = §7BlockCounter deactivated
|
BLOCK_COUNTER_DISABLE = §7BlockCounter deactivated
|
||||||
|
|
||||||
# DepthCounter
|
# DepthCounter
|
||||||
DEPTH_COUNTER_COMMAND_ENABLE_HELP = §8/§edepthcounter enable §8- §7Activate the depth-counter
|
DEPTH_COUNTER_MESSAGE = §7Depth §8> §7
|
||||||
DEPTH_COUNTER_COMMAND_DISABLE_HELP = §8/§edepthcounter disable §8- §7Deactivate the depth-counter
|
DEPTH_COUNTER_COUNT = {0}{1}§8×{2}{3}§8×{4}{5}
|
||||||
DEPTH_COUNTER_COMMAND_INFO_HELP = §8/§edepthcounter info §8- §7Lists active counting modes
|
DEPTH_COUNTER_HOVER = §7X§8ק7Y§8ק7Z
|
||||||
DEPTH_COUNTER_COMMAND_TOGGLE_HELP = §8/§edepthcounter toggle §8<§7CountMode§8> §8- §7Toggle counting modes
|
DEPTH_COUNTER_TNT = §7 TNT§8: §e{0}
|
||||||
DEPTH_COUNTER_ENABLE_MESSAGE = §7You activated the depth-counter
|
|
||||||
DEPTH_COUNTER_DISABLE_MESSAGE = §7You deactivated the depth-counter
|
|
||||||
DEPTH_COUNTER_ACTIVE_MESSAGE = §7Active couting modes: §e{0}§8.
|
|
||||||
DEPTH_COUNTER_MESSAGE = §7Damage §8> §7{0}
|
|
||||||
DEPTH_COUNTER_HIGHLIGHT = §e
|
|
||||||
DEPTH_COUNTER_SEPARATOR = §7 §7
|
|
||||||
DEPTH_COUNTER_X = X: {0}
|
|
||||||
DEPTH_COUNTER_Y = Y: {0}
|
|
||||||
DEPTH_COUNTER_Z = Z: {0}
|
|
||||||
DEPTH_COUNTER_TNT = §7TNT§8: §e{0}
|
|
||||||
|
|
||||||
# TPSLimit
|
# TPSLimit
|
||||||
TICK_STEP_HELP = §8/§etick step §8<§7Ticks§8> §8- §7Step n ticks
|
TICK_STEP_HELP = §8/§etick step §8<§7Ticks§8> §8- §7Step n ticks
|
||||||
|
@ -673,26 +673,13 @@ KILLCHECKER_BOSSBAR = §e§l{0} §7(§e{1}%§7) §e§l{2}§7 Kanonnen
|
|||||||
BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus
|
BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus
|
||||||
BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an
|
BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an
|
||||||
BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus
|
BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus
|
||||||
BLOCK_COUNTER_MESSAGE = §7Counter §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick
|
BLOCK_COUNTER_MESSAGE = §7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick
|
||||||
BLOCK_COUNTER_MESSAGE_SECOND = §7Counter §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s
|
BLOCK_COUNTER_MESSAGE_SECOND = §7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s
|
||||||
BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht
|
BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht
|
||||||
BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht
|
BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht
|
||||||
|
|
||||||
# DepthCounter
|
# DepthCounter
|
||||||
DEPTH_COUNTER_COMMAND_ENABLE_HELP = §8/§edepthcounter enable §8- §7Aktiviere den Tiefenzähler
|
DEPTH_COUNTER_MESSAGE = §7Tiefe §8> §7
|
||||||
DEPTH_COUNTER_COMMAND_DISABLE_HELP = §8/§edepthcounter disable §8- §7Deaktiviere den Tiefenzähler
|
|
||||||
DEPTH_COUNTER_COMMAND_INFO_HELP = §8/§edepthcounter info §8- §7Zähle aktive Zählmodi auf
|
|
||||||
DEPTH_COUNTER_COMMAND_TOGGLE_HELP = §8/§edepthcounter toggle §8<§7CountMode§8> §8- §7Stelle einzelne Zählmodi ein
|
|
||||||
DEPTH_COUNTER_ENABLE_MESSAGE = §7Du hast den Tiefenzähler aktiviert.
|
|
||||||
DEPTH_COUNTER_DISABLE_MESSAGE = §7Du hast den Tiefenzähler deaktiviert.
|
|
||||||
DEPTH_COUNTER_ACTIVE_MESSAGE = §7Aktive Zählmodi: §e{0}§8.
|
|
||||||
DEPTH_COUNTER_MESSAGE = §7Schaden §8> §7{0}
|
|
||||||
DEPTH_COUNTER_HIGHLIGHT = §e
|
|
||||||
DEPTH_COUNTER_SEPARATOR = §7 §7
|
|
||||||
DEPTH_COUNTER_X = X: {0}
|
|
||||||
DEPTH_COUNTER_Y = Y: {0}
|
|
||||||
DEPTH_COUNTER_Z = Z: {0}
|
|
||||||
DEPTH_COUNTER_TNT = §7TNT§8: §e{0}
|
|
||||||
|
|
||||||
# TPSLimit
|
# TPSLimit
|
||||||
TICK_STEP_HELP = §8/§etick step §8<§7Ticks§8> §8- §7Spule n Ticks vor
|
TICK_STEP_HELP = §8/§etick step §8<§7Ticks§8> §8- §7Spule n Ticks vor
|
||||||
|
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* 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.cannon;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.cannon.depth.Depth;
|
||||||
|
import de.steamwar.bausystem.features.cannon.depth.DepthManager;
|
||||||
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class CannonDetector implements Listener {
|
||||||
|
|
||||||
|
private Map<TNTPrimed, Vector> velocities = new HashMap<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof TNTPrimed)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TNTPrimed tnt = (TNTPrimed) event.getEntity();
|
||||||
|
DepthManager.update(tnt, event.blockList());
|
||||||
|
|
||||||
|
List<TNTPrimed> tnts = Bukkit.getWorlds().get(0).getEntitiesByClass(TNTPrimed.class)
|
||||||
|
.stream()
|
||||||
|
.filter(entity -> entity != tnt)
|
||||||
|
.filter(entity -> entity.getFuseTicks() > 1)
|
||||||
|
.filter(entity -> entity.getLocation().distance(event.getLocation()) <= 8)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (tnts.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isEmpty = velocities.isEmpty();
|
||||||
|
tnts.forEach(tntPrimed -> {
|
||||||
|
velocities.put(tntPrimed, tntPrimed.getVelocity().clone());
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
Map<CannonKey, List<TNTPrimed>> grouped = new HashMap<>();
|
||||||
|
velocities.forEach((tntPrimed, vector) -> {
|
||||||
|
grouped.computeIfAbsent(new CannonKey(round(tntPrimed.getLocation().toVector()), round(vector)), ignored -> new ArrayList<>()).add(tntPrimed);
|
||||||
|
});
|
||||||
|
grouped.forEach((cannonKey, tntPrimeds) -> {
|
||||||
|
if (tntPrimeds.size() <= 5) return;
|
||||||
|
Region region = Region.getRegion(tntPrimeds.get(0).getLocation());
|
||||||
|
if (region.isGlobal()) return;
|
||||||
|
if (!region.hasType(RegionType.TESTBLOCK)) return;
|
||||||
|
Depth depth = new Depth(region);
|
||||||
|
DepthManager.init(tntPrimeds, depth);
|
||||||
|
});
|
||||||
|
velocities.clear();
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector round(Vector vector) {
|
||||||
|
vector.multiply(10000);
|
||||||
|
vector.setX(Math.round(vector.getX()));
|
||||||
|
vector.setY(Math.round(vector.getY()));
|
||||||
|
vector.setZ(Math.round(vector.getZ()));
|
||||||
|
return vector;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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.cannon;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@Getter
|
||||||
|
public final class CannonKey {
|
||||||
|
private Vector locationVector;
|
||||||
|
private Vector velocityVector;
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* 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.cannon.depth;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
|
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||||
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class Depth {
|
||||||
|
|
||||||
|
private Region region;
|
||||||
|
private Vector minVector = null;
|
||||||
|
private Vector maxVector = null;
|
||||||
|
private int tntCount = 0;
|
||||||
|
|
||||||
|
public Depth(Region region) {
|
||||||
|
this.region = region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(List<Block> blocks) {
|
||||||
|
List<Block> blocksList = blocks.stream()
|
||||||
|
.filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (blocksList.isEmpty()) return;
|
||||||
|
tntCount++;
|
||||||
|
for (Block block : blocksList) {
|
||||||
|
internalUpdate(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finish() {
|
||||||
|
if (maxVector == null || minVector == null) return;
|
||||||
|
Vector dimensions = maxVector.subtract(minVector);
|
||||||
|
dimensions.setX(Math.abs(dimensions.getX()));
|
||||||
|
dimensions.setY(Math.abs(dimensions.getY()));
|
||||||
|
dimensions.setZ(Math.abs(dimensions.getZ()));
|
||||||
|
|
||||||
|
RegionUtils.message(region, player -> {
|
||||||
|
player.spigot().sendMessage(getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalUpdate(Block block) {
|
||||||
|
if (minVector == null) {
|
||||||
|
minVector = block.getLocation().toVector();
|
||||||
|
}
|
||||||
|
minVector.setX(Math.min(minVector.getX(), block.getX()));
|
||||||
|
minVector.setY(Math.min(minVector.getY(), block.getY()));
|
||||||
|
minVector.setZ(Math.min(minVector.getZ(), block.getZ()));
|
||||||
|
|
||||||
|
if (maxVector == null) {
|
||||||
|
maxVector = block.getLocation().toVector();
|
||||||
|
}
|
||||||
|
maxVector.setX(Math.max(maxVector.getX(), block.getX()));
|
||||||
|
maxVector.setY(Math.max(maxVector.getY(), block.getY()));
|
||||||
|
maxVector.setZ(Math.max(maxVector.getZ(), block.getZ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BaseComponent[] getMessage(Player player, int x, int y, int z, int tntCount) {
|
||||||
|
final Set<Integer> dimensions = new HashSet<>();
|
||||||
|
dimensions.add(x);
|
||||||
|
dimensions.add(y);
|
||||||
|
dimensions.add(z);
|
||||||
|
|
||||||
|
int max = getMax(dimensions);
|
||||||
|
|
||||||
|
TextComponent headerComponent = new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_MESSAGE", player));
|
||||||
|
|
||||||
|
TextComponent depthComponent = new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_COUNT", player, x == max ? "§e" : "§7", x, y == max ? "§e" : "§7", y, z == max ? "§e" : "§7", z));
|
||||||
|
depthComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_HOVER", player))}));
|
||||||
|
|
||||||
|
TextComponent tntComponent = new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_TNT", player, tntCount));
|
||||||
|
|
||||||
|
return new BaseComponent[]{headerComponent, depthComponent, tntComponent};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getMax(Set<Integer> values) {
|
||||||
|
return values.stream().max(Integer::compare).orElse(0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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.cannon.depth;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class DepthManager {
|
||||||
|
|
||||||
|
private Map<TNTPrimed, Depth> depths = new HashMap<>();
|
||||||
|
|
||||||
|
public void init(List<TNTPrimed> list, Depth depth) {
|
||||||
|
for (TNTPrimed tnt : list) {
|
||||||
|
depths.putIfAbsent(tnt, depth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(TNTPrimed tnt, List<Block> blocks) {
|
||||||
|
Depth depth = depths.remove(tnt);
|
||||||
|
if (depth == null) return;
|
||||||
|
depth.update(blocks);
|
||||||
|
if (depths.containsValue(depth)) return;
|
||||||
|
depth.finish();
|
||||||
|
}
|
||||||
|
}
|
@ -57,7 +57,9 @@ public class BlockCount {
|
|||||||
toRemove.add(blockCount.region);
|
toRemove.add(blockCount.region);
|
||||||
|
|
||||||
if (count > 10) {
|
if (count > 10) {
|
||||||
RegionUtils.message(blockCount.region, player -> BlockCounter.getMessage(player, blockCount.count, blockCount.tntCount, blockCount.tick, blockCount.lastUpdate));
|
RegionUtils.message(blockCount.region, player -> {
|
||||||
|
return BlockCounter.getMessage(player, blockCount.count, blockCount.tntCount, blockCount.tick, blockCount.lastUpdate);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toRemove.forEach(BlockCounter.blockCountMap::remove);
|
toRemove.forEach(BlockCounter.blockCountMap::remove);
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.features.testblock.depthcounter;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
public enum CountMode {
|
|
||||||
|
|
||||||
X,
|
|
||||||
Y,
|
|
||||||
Z;
|
|
||||||
|
|
||||||
public static Set<CountMode> ALL() {
|
|
||||||
return new HashSet<>(Arrays.asList(values()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,131 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.features.testblock.depthcounter;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class Depth {
|
|
||||||
|
|
||||||
private static BukkitTask bukkitTask = null;
|
|
||||||
|
|
||||||
private Region region;
|
|
||||||
private int tntCount = 1;
|
|
||||||
private Vector minVector = null;
|
|
||||||
private Vector maxVector = null;
|
|
||||||
|
|
||||||
private long lastUpdate = TPSUtils.currentTick.get();
|
|
||||||
|
|
||||||
public Depth(Region region, List<Block> blocks) {
|
|
||||||
if (blocks.isEmpty()) {
|
|
||||||
throw new SecurityException();
|
|
||||||
}
|
|
||||||
this.region = region;
|
|
||||||
blocks.forEach(block -> {
|
|
||||||
if (minVector == null) {
|
|
||||||
minVector = DepthCounter.blockVector(block.getLocation().toVector());
|
|
||||||
maxVector = DepthCounter.blockVector(block.getLocation().toVector());
|
|
||||||
} else {
|
|
||||||
internalUpdate(block);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (bukkitTask == null) {
|
|
||||||
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
|
||||||
Set<Depth> toRemove = new HashSet<>();
|
|
||||||
for (Set<Depth> value : DepthCounter.depthMap.values()) {
|
|
||||||
value.forEach(depth -> {
|
|
||||||
if (TPSUtils.currentTick.get() - depth.lastUpdate < 10) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector dimensions = depth.maxVector.subtract(depth.minVector);
|
|
||||||
dimensions.setX(Math.abs(dimensions.getX()));
|
|
||||||
dimensions.setY(Math.abs(dimensions.getY()));
|
|
||||||
dimensions.setZ(Math.abs(dimensions.getZ()));
|
|
||||||
|
|
||||||
if (depth.tntCount > 4 && dimensions.getX() != 0 && dimensions.getY() != 0 && dimensions.getZ() != 0) {
|
|
||||||
RegionUtils.message(depth.region, player -> DepthCounter.getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, depth.tntCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<Depth> depthSet = DepthCounter.depthMap.get(depth.region);
|
|
||||||
if (depthSet == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
toRemove.add(depth);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
toRemove.forEach(depth -> {
|
|
||||||
Set<Depth> depthSet = DepthCounter.depthMap.get(depth.region);
|
|
||||||
depthSet.remove(depth);
|
|
||||||
if (depthSet.isEmpty()) {
|
|
||||||
DepthCounter.depthMap.remove(depth.region);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (DepthCounter.depthMap.isEmpty()) {
|
|
||||||
bukkitTask.cancel();
|
|
||||||
bukkitTask = null;
|
|
||||||
}
|
|
||||||
}, 2, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean update(List<Block> blocks) {
|
|
||||||
double totalBlastResistanceBroken = blocks.stream().filter(block -> {
|
|
||||||
Vector vector = DepthCounter.blockVector(block.getLocation().toVector());
|
|
||||||
return vector.getX() >= minVector.getX()
|
|
||||||
&& vector.getY() >= minVector.getY()
|
|
||||||
&& vector.getZ() >= minVector.getZ()
|
|
||||||
&& vector.getX() <= maxVector.getX()
|
|
||||||
&& vector.getY() <= maxVector.getY()
|
|
||||||
&& vector.getZ() <= maxVector.getZ();
|
|
||||||
}).filter(block -> block.getType().isBlock())
|
|
||||||
.mapToDouble(block -> block.getType().getBlastResistance())
|
|
||||||
.sum();
|
|
||||||
if (totalBlastResistanceBroken < 18) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
lastUpdate = TPSUtils.currentTick.get();
|
|
||||||
blocks.forEach(this::internalUpdate);
|
|
||||||
tntCount++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void internalUpdate(Block block) {
|
|
||||||
minVector.setX(Math.min(minVector.getX(), block.getX()));
|
|
||||||
minVector.setY(Math.min(minVector.getY(), block.getY()));
|
|
||||||
minVector.setZ(Math.min(minVector.getZ(), block.getZ()));
|
|
||||||
|
|
||||||
maxVector.setX(Math.max(maxVector.getX(), block.getX()));
|
|
||||||
maxVector.setY(Math.max(maxVector.getY(), block.getY()));
|
|
||||||
maxVector.setZ(Math.max(maxVector.getZ(), block.getZ()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.features.testblock.depthcounter;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class DepthCounter {
|
|
||||||
|
|
||||||
public final Map<Region, Set<Depth>> depthMap = new HashMap<>();
|
|
||||||
|
|
||||||
private static final YAPIONObject DEFAULT = new YAPIONObject().add("X", "").add("Y", "").add("Z", "");
|
|
||||||
|
|
||||||
public void toggleMode(final Player p, final CountMode countMode) {
|
|
||||||
if (isActive(p, countMode)) {
|
|
||||||
removeMode(p, countMode);
|
|
||||||
} else {
|
|
||||||
addMode(p, countMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive(final Player p, final CountMode countMode) {
|
|
||||||
return Config.getInstance().get(p).getYAPIONObjectOrSetDefault("depth-counter", (YAPIONObject) DEFAULT.copy()).containsKey(countMode.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMode(final Player p, final CountMode countMode) {
|
|
||||||
if (!isActive(p, countMode)) {
|
|
||||||
Config.getInstance().get(p).getObject("depth-counter").add(countMode.name(), "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeMode(final Player p, final CountMode countMode) {
|
|
||||||
if (isActive(p, countMode)) {
|
|
||||||
Config.getInstance().get(p).getObject("depth-counter").remove(countMode.name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModes(final Player p, final Set<CountMode> countModes) {
|
|
||||||
YAPIONObject yapionObject = new YAPIONObject();
|
|
||||||
countModes.forEach(countMode -> yapionObject.put(countMode.name(), ""));
|
|
||||||
Config.getInstance().get(p).put("depth-counter", yapionObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removePlayer(final Player p) {
|
|
||||||
Config.getInstance().get(p).put("depth-counter", new YAPIONObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector blockVector(Vector vector) {
|
|
||||||
return new Vector(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<CountMode> getModes(Player p) {
|
|
||||||
Set<CountMode> countModes = new HashSet<>();
|
|
||||||
Config.getInstance().get(p).getYAPIONObjectOrSetDefault("depth-counter", (YAPIONObject) DEFAULT.copy()).forEach((s, yapionAnyType) -> {
|
|
||||||
countModes.add(CountMode.valueOf(s));
|
|
||||||
});
|
|
||||||
return countModes.stream().sorted().collect(Collectors.toCollection(LinkedHashSet::new));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasModes(Player p) {
|
|
||||||
return !getModes(p).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMax(int... values) {
|
|
||||||
return Arrays.stream(values).max().orElse(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMax(Set<Integer> values) {
|
|
||||||
return values.stream().max(Integer::compare).orElse(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage(Player player, int x, int y, int z, int tntCount) {
|
|
||||||
final boolean xActive = DepthCounter.isActive(player, CountMode.X);
|
|
||||||
final boolean yActive = DepthCounter.isActive(player, CountMode.Y);
|
|
||||||
final boolean zActive = DepthCounter.isActive(player, CountMode.Z);
|
|
||||||
|
|
||||||
if (!xActive && !yActive && !zActive) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Set<Integer> dimensions = new HashSet<>();
|
|
||||||
if (xActive) {
|
|
||||||
dimensions.add(x);
|
|
||||||
}
|
|
||||||
if (yActive) {
|
|
||||||
dimensions.add(y);
|
|
||||||
}
|
|
||||||
if (zActive) {
|
|
||||||
dimensions.add(z);
|
|
||||||
}
|
|
||||||
|
|
||||||
int max = getMax(dimensions);
|
|
||||||
|
|
||||||
StringBuilder st = new StringBuilder();
|
|
||||||
if (xActive) {
|
|
||||||
st.append(x == max ? BauSystem.MESSAGE.parse("DEPTH_COUNTER_HIGHLIGHT", player) : "")
|
|
||||||
.append(BauSystem.MESSAGE.parse("DEPTH_COUNTER_X", player, x))
|
|
||||||
.append(BauSystem.MESSAGE.parse("DEPTH_COUNTER_SEPARATOR", player));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (yActive) {
|
|
||||||
st.append(y == max ? BauSystem.MESSAGE.parse("DEPTH_COUNTER_HIGHLIGHT", player) : "")
|
|
||||||
.append(BauSystem.MESSAGE.parse("DEPTH_COUNTER_Y", player, y))
|
|
||||||
.append(BauSystem.MESSAGE.parse("DEPTH_COUNTER_SEPARATOR", player));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zActive) {
|
|
||||||
st.append(z == max ? BauSystem.MESSAGE.parse("DEPTH_COUNTER_HIGHLIGHT", player) : "")
|
|
||||||
.append(BauSystem.MESSAGE.parse("DEPTH_COUNTER_Z", player, z))
|
|
||||||
.append(BauSystem.MESSAGE.parse("DEPTH_COUNTER_SEPARATOR", player));
|
|
||||||
}
|
|
||||||
|
|
||||||
st.append(BauSystem.MESSAGE.parse("DEPTH_COUNTER_TNT", player, tntCount));
|
|
||||||
return BauSystem.MESSAGE.parse("DEPTH_COUNTER_MESSAGE", player, st.toString());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.features.testblock.depthcounter;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class DepthCounterCommand extends SWCommand {
|
|
||||||
|
|
||||||
public DepthCounterCommand() {
|
|
||||||
super("depthcounter", "depthcount", "dcounter", "dcount");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "toggle", description = "DEPTH_COUNTER_COMMAND_TOGGLE_HELP")
|
|
||||||
public void toggleCommand(Player p, CountMode countMode) {
|
|
||||||
DepthCounter.toggleMode(p, countMode);
|
|
||||||
BauSystem.MESSAGE.send("DEPTH_COUNTER_ACTIVE_MESSAGE", p, DepthCounter.getModes(p).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "enable", description = "DEPTH_COUNTER_COMMAND_ENABLE_HELP")
|
|
||||||
public void enableCommand(Player p) {
|
|
||||||
DepthCounter.setModes(p, CountMode.ALL());
|
|
||||||
BauSystem.MESSAGE.send("DEPTH_COUNTER_ENABLE_MESSAGE", p);
|
|
||||||
BauSystem.MESSAGE.send("DEPTH_COUNTER_ACTIVE_MESSAGE", p, DepthCounter.getModes(p).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "disable", description = "DEPTH_COUNTER_COMMAND_DISABLE_HELP")
|
|
||||||
public void disableCommand(Player p) {
|
|
||||||
DepthCounter.removePlayer(p);
|
|
||||||
BauSystem.MESSAGE.send("DEPTH_COUNTER_DISABLE_MESSAGE", p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "info", description = "DEPTH_COUNTER_COMMAND_INFO_HELP")
|
|
||||||
public void infoCommand(Player p) {
|
|
||||||
BauSystem.MESSAGE.send("DEPTH_COUNTER_ACTIVE_MESSAGE", p, DepthCounter.getModes(p).toString());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.features.testblock.depthcounter;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class DepthCounterListener implements Listener {
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
|
||||||
Region region = Region.getRegion(event.getLocation());
|
|
||||||
List<Block> blockList = event.blockList();
|
|
||||||
blockList = blockList.stream().filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)).collect(Collectors.toList());
|
|
||||||
if (blockList.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DepthCounter.depthMap.putIfAbsent(region, new HashSet<>());
|
|
||||||
Set<Depth> depthSet = DepthCounter.depthMap.get(region);
|
|
||||||
for (Depth depth : depthSet) {
|
|
||||||
if (depth.update(blockList)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
depthSet.add(new Depth(region, blockList));
|
|
||||||
}
|
|
||||||
}
|
|
@ -33,6 +33,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
|
||||||
@ -70,6 +71,16 @@ public class RegionUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void message(Region region, Consumer<Player> function) {
|
||||||
|
Bukkit.getOnlinePlayers()
|
||||||
|
.stream()
|
||||||
|
.filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
|
||||||
|
.filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal())
|
||||||
|
.forEach(player -> {
|
||||||
|
function.accept(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
|
static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
|
||||||
return FlatteningWrapper.impl.paste(file, pastePoint, pasteOptions);
|
return FlatteningWrapper.impl.paste(file, pastePoint, pasteOptions);
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren