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.plot.world; 020 021import com.plotsquared.core.PlotSquared; 022import com.plotsquared.core.location.Location; 023import com.plotsquared.core.player.PlotPlayer; 024import com.plotsquared.core.plot.Plot; 025import com.plotsquared.core.plot.PlotArea; 026import com.plotsquared.core.plot.PlotId; 027import com.plotsquared.core.plot.PlotManager; 028import com.plotsquared.core.queue.QueueCoordinator; 029import com.plotsquared.core.util.RecursiveDirectoryRemovalWalker; 030import com.plotsquared.core.util.task.TaskManager; 031import com.sk89q.worldedit.function.pattern.Pattern; 032import org.apache.logging.log4j.LogManager; 033import org.apache.logging.log4j.Logger; 034import org.checkerframework.checker.nullness.qual.NonNull; 035import org.checkerframework.checker.nullness.qual.Nullable; 036 037import java.io.IOException; 038import java.nio.file.Files; 039import java.nio.file.Path; 040import java.util.List; 041 042public class SinglePlotManager extends PlotManager { 043 044 private static final int MAX_COORDINATE = 20000000; 045 private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + SinglePlotManager.class.getSimpleName()); 046 047 public SinglePlotManager(final @NonNull PlotArea plotArea) { 048 super(plotArea); 049 } 050 051 @Override 052 public PlotId getPlotIdAbs(int x, int y, int z) { 053 return PlotId.of(0, 0); 054 } 055 056 @Override 057 public PlotId getPlotId(int x, int y, int z) { 058 return PlotId.of(0, 0); 059 } 060 061 @Override 062 public Location getPlotBottomLocAbs(final @NonNull PlotId plotId) { 063 return Location.at(plotId.toUnderscoreSeparatedString(), -MAX_COORDINATE, 0, -MAX_COORDINATE); 064 } 065 066 @Override 067 public Location getPlotTopLocAbs(final @NonNull PlotId plotId) { 068 return Location.at(plotId.toUnderscoreSeparatedString(), MAX_COORDINATE, 0, MAX_COORDINATE); 069 } 070 071 @Override 072 public boolean clearPlot( 073 @NonNull Plot plot, 074 final Runnable whenDone, 075 @Nullable PlotPlayer<?> actor, 076 @Nullable QueueCoordinator queue 077 ) { 078 Path path = PlotSquared.platform().getPlatformWorld(plot.getWorldName()).getWorldFolder(); 079 PlotSquared.platform().setupUtils().unload(plot.getWorldName(), false); 080 TaskManager.getPlatformImplementation().taskAsync(() -> { 081 try { 082 Files.walkFileTree(path, RecursiveDirectoryRemovalWalker.INSTANCE); 083 } catch (IOException e) { 084 LOGGER.error("Failed to delete plot world for single plot area", e); 085 } 086 if (whenDone != null) { 087 whenDone.run(); 088 } 089 }); 090 return true; 091 } 092 093 @Override 094 public boolean claimPlot(@NonNull Plot plot, @Nullable QueueCoordinator queue) { 095 // TODO 096 return true; 097 } 098 099 @Override 100 public boolean unClaimPlot(@NonNull Plot plot, Runnable whenDone, @Nullable QueueCoordinator queue) { 101 if (whenDone != null) { 102 whenDone.run(); 103 } 104 return true; 105 } 106 107 @Override 108 public Location getSignLoc(@NonNull Plot plot) { 109 return null; 110 } 111 112 @Override 113 public String[] getPlotComponents(@NonNull PlotId plotId) { 114 return new String[0]; 115 } 116 117 @Override 118 public boolean setComponent( 119 @NonNull PlotId plotId, 120 @NonNull String component, 121 @NonNull Pattern blocks, 122 @Nullable PlotPlayer<?> actor, 123 @Nullable QueueCoordinator queue 124 ) { 125 return false; 126 } 127 128 @Override 129 public boolean createRoadEast(@NonNull Plot plot, @Nullable QueueCoordinator queue) { 130 return false; 131 } 132 133 @Override 134 public boolean createRoadSouth(@NonNull Plot plot, @Nullable QueueCoordinator queue) { 135 return false; 136 } 137 138 @Override 139 public boolean createRoadSouthEast(@NonNull Plot plot, @Nullable QueueCoordinator queue) { 140 return false; 141 } 142 143 @Override 144 public boolean removeRoadEast(@NonNull Plot plot, @Nullable QueueCoordinator queue) { 145 return false; 146 } 147 148 @Override 149 public boolean removeRoadSouth(@NonNull Plot plot, @Nullable QueueCoordinator queue) { 150 return false; 151 } 152 153 @Override 154 public boolean removeRoadSouthEast(@NonNull Plot plot, @Nullable QueueCoordinator queue) { 155 return false; 156 } 157 158 @Override 159 public boolean startPlotMerge(@NonNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) { 160 return false; 161 } 162 163 @Override 164 public boolean startPlotUnlink(@NonNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) { 165 return false; 166 } 167 168 @Override 169 public boolean finishPlotMerge(@NonNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) { 170 return false; 171 } 172 173 @Override 174 public boolean finishPlotUnlink(@NonNull List<PlotId> plotIds, @Nullable QueueCoordinator queue) { 175 return false; 176 } 177 178 @Override 179 public boolean regenerateAllPlotWalls(@Nullable QueueCoordinator queue) { 180 return false; 181 } 182 183}