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