forked from SteamWar/SteamWar
Add PathRegion
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.region;
|
||||
|
||||
import de.steamwar.bausystem.features.region.RegionCommand;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.TileUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@AbstractSWCommand.PartOf(RegionCommand.class)
|
||||
public class DynamicRegionCommand extends SWCommand {
|
||||
|
||||
public DynamicRegionCommand() {
|
||||
super("");
|
||||
}
|
||||
|
||||
@Register({"dynamic", "place"})
|
||||
public void placeRegion(Player player) {
|
||||
Region region = DynamicRegionSystem.INSTANCE.get(player.getLocation());
|
||||
if (!region.getType().isGlobal()) return;
|
||||
Pair<Integer, Integer> tile = TileUtils.fromLocation(player.getLocation());
|
||||
Pair<Integer, Integer> min = TileUtils.toMinLocation(tile);
|
||||
PathRegion pathRegion = new PathRegion(min.getKey(), min.getValue());
|
||||
pathRegion.getArea().reset(null, false);
|
||||
DynamicRegionSystem.INSTANCE.getNeighbours(pathRegion).collect(Collectors.toList())
|
||||
.forEach(r -> r.update(pathRegion));
|
||||
}
|
||||
|
||||
@Register({"dynamic", "delete"})
|
||||
public void deleteRegion(Player player) {
|
||||
Region region = DynamicRegionSystem.INSTANCE.get(player.getLocation());
|
||||
if (region.getType().isCannotDelete()) return;
|
||||
((DynamicRegion) region).delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user