001/* 002 * PlotSquared, a land and world management plugin for Minecraft. 003 * Copyright (C) IntellectualSites <https://intellectualsites.com> 004 * Copyright (C) IntellectualSites team and contributors 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 018 */ 019package com.plotsquared.core.command; 020 021import com.google.inject.Inject; 022import com.plotsquared.core.configuration.caption.TranslatableCaption; 023import com.plotsquared.core.generator.HybridPlotWorld; 024import com.plotsquared.core.generator.HybridUtils; 025import com.plotsquared.core.location.Location; 026import com.plotsquared.core.player.PlotPlayer; 027import com.plotsquared.core.plot.Plot; 028import net.kyori.adventure.text.minimessage.Template; 029import org.checkerframework.checker.nullness.qual.NonNull; 030 031@CommandDeclaration(command = "createroadschematic", 032 aliases = {"crs"}, 033 category = CommandCategory.ADMINISTRATION, 034 requiredType = RequiredType.PLAYER, 035 permission = "plots.createroadschematic", 036 usage = "/plot createroadschematic") 037public class CreateRoadSchematic extends SubCommand { 038 039 private final HybridUtils hybridUtils; 040 041 @Inject 042 public CreateRoadSchematic(final @NonNull HybridUtils hybridUtils) { 043 this.hybridUtils = hybridUtils; 044 } 045 046 @Override 047 public boolean onCommand(PlotPlayer<?> player, String[] args) { 048 Location location = player.getLocation(); 049 Plot plot = location.getPlotAbs(); 050 if (plot == null) { 051 player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); 052 return false; 053 } 054 if (plot.getVolume() > Integer.MAX_VALUE) { 055 player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); 056 return false; 057 } 058 if (!(location.getPlotArea() instanceof HybridPlotWorld)) { 059 player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); 060 } 061 this.hybridUtils.setupRoadSchematic(plot); 062 player.sendMessage( 063 TranslatableCaption.of("schematics.schematic_road_created"), 064 Template.of("command", "/plot debugroadregen") 065 ); 066 return true; 067 } 068 069}