forked from SteamWar/SteamWar
Fix WetRegion -> WetRegionData
Fix DynamicRegionSystem.get Add Fallback.schem for PathArea
This commit is contained in:
+28
-4
@@ -21,13 +21,17 @@ 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.DynamicRegionRepository;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
@AbstractSWCommand.PartOf(RegionCommand.class)
|
||||
@@ -38,16 +42,17 @@ public class DynamicRegionCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register({"dynamic", "place"})
|
||||
public void placeRegion(Player player) {
|
||||
public void placeRegion(Player player, @Mapper("regionType") String regionType) {
|
||||
Region region = DynamicRegionSystem.INSTANCE.get(player.getLocation());
|
||||
if (!region.getType().isGlobal()) return;
|
||||
Tile tile = Tile.fromLocation(player.getLocation()).orElse(null);
|
||||
if (tile == null) return;
|
||||
|
||||
// TODO: Replace!
|
||||
PathRegion dynamicRegion = new PathRegion(UUID.randomUUID(), tile.getMinX(), tile.getMinZ());
|
||||
Class<? extends DynamicRegion> regionClass = DynamicRegionSystem.identifierDataMap.get(regionType);
|
||||
DynamicRegion dynamicRegion = DynamicRegionRepository.constructRegion(regionClass, UUID.randomUUID(), tile.getMinX(), tile.getMinZ());
|
||||
|
||||
dynamicRegion.getArea().reset(new PasteBuilder(new PasteBuilder.FileProvider(dynamicRegion.getArea().getResetFile())), false);
|
||||
// TODO: This here still has some kind of error!aww
|
||||
DynamicRegionSystem.INSTANCE.getNeighbours(dynamicRegion).forEach(r -> r.update(dynamicRegion));
|
||||
}
|
||||
|
||||
@@ -57,4 +62,23 @@ public class DynamicRegionCommand extends SWCommand {
|
||||
if (!region.getType().isDeletable()) return;
|
||||
((DynamicRegion) region).delete();
|
||||
}
|
||||
|
||||
@Mapper("regionType")
|
||||
private TypeMapper<String> regionType() {
|
||||
return new TypeMapper<>() {
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
if (DynamicRegionSystem.identifierDataMap.containsKey(s)) {
|
||||
return s;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
return DynamicRegionSystem.identifierDataMap.keySet();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user