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.events; 020 021import com.plotsquared.core.command.Claim; 022import com.plotsquared.core.player.PlotPlayer; 023import com.plotsquared.core.plot.Plot; 024import com.plotsquared.core.plot.PlotArea; 025import org.checkerframework.checker.nullness.qual.Nullable; 026 027/** 028 * PlayerAutoPlotEvent returns null for {@link PlotEvent#getPlot()} as the event is fired before the plot is chosen. 029 */ 030public class PlayerAutoPlotEvent extends PlotEvent implements CancellablePlotEvent { 031 032 private final PlotPlayer<?> player; 033 private final PlotArea plotArea; 034 private Result eventResult; 035 private String schematic; 036 private int sizeX; 037 private int sizeZ; 038 039 /** 040 * PlayerAutoPlotEvent: called when a player attempts to auto claim a plot. 041 * 042 * @param player The player attempting to auto claim 043 * @param plotArea The applicable plot area 044 * @param schematic The schematic defined or null 045 * @param sizeX The size of the auto area 046 * @param sizeZ The size of the auto area 047 */ 048 public PlayerAutoPlotEvent( 049 PlotPlayer<?> player, PlotArea plotArea, @Nullable String schematic, 050 int sizeX, int sizeZ 051 ) { 052 super(null); 053 this.player = player; 054 this.plotArea = plotArea; 055 this.schematic = schematic; 056 this.sizeX = sizeX; 057 this.sizeZ = sizeZ; 058 } 059 060 /** 061 * Returns null as the plots to be claimed haven't been chosen yet. This will depend on the size of the auto 062 * ({@link PlayerAutoPlotEvent#setSizeX(int)} and {@link PlayerAutoPlotEvent#setSizeZ(int)}). To see which plots have been 063 * chosen, see {@link PlayerAutoPlotsChosenEvent}. 064 * 065 * @return null 066 */ 067 @Override 068 public @Nullable Plot getPlot() { 069 return null; 070 } 071 072 /** 073 * Obtain the schematic string as used by the {@link Claim} command or null. 074 * 075 * @return schematic string 076 */ 077 public @Nullable String getSchematic() { 078 return this.schematic; 079 } 080 081 /** 082 * Set the schematic string used in the claim. 083 * 084 * @param schematic the schematic name 085 */ 086 public void setSchematic(String schematic) { 087 this.schematic = schematic; 088 } 089 090 @Override 091 public Result getEventResult() { 092 return eventResult; 093 } 094 095 @Override 096 public void setEventResult(Result e) { 097 this.eventResult = e; 098 } 099 100 public PlotPlayer<?> getPlayer() { 101 return this.player; 102 } 103 104 public PlotArea getPlotArea() { 105 return this.plotArea; 106 } 107 108 /** 109 * @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeX()} 110 */ 111 @Deprecated(forRemoval = true, since = "6.1.0") 112 public int getSize_x() { 113 return getSizeX(); 114 } 115 116 /** 117 * @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeX(int)} 118 */ 119 @Deprecated(forRemoval = true, since = "6.1.0") 120 public void setSize_x(int sizeX) { 121 setSizeX(sizeX); 122 } 123 124 /** 125 * @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeZ()} 126 */ 127 @Deprecated(forRemoval = true, since = "6.1.0") 128 public int getSize_z() { 129 return getSizeZ(); 130 } 131 132 /** 133 * @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeZ(int)} 134 */ 135 @Deprecated(forRemoval = true, since = "6.1.0") 136 public void setSize_z(int sizeZ) { 137 setSizeZ(sizeZ); 138 } 139 140 /** 141 * Get the x size of the auto-area 142 * 143 * @return x size 144 * @since 6.1.0 145 */ 146 public int getSizeX() { 147 return this.sizeX; 148 } 149 150 /** 151 * Set the x size of the auto-area 152 * 153 * @param sizeX x size 154 * @since 6.1.0 155 */ 156 public void setSizeX(int sizeX) { 157 this.sizeX = sizeX; 158 } 159 160 /** 161 * Get the z size of the auto-area 162 * 163 * @return z size 164 * @since 6.1.0 165 */ 166 public int getSizeZ() { 167 return this.sizeZ; 168 } 169 170 /** 171 * Set the z size of the auto-area 172 * 173 * @param sizeZ z size 174 * @since 6.1.0 175 */ 176 public void setSizeZ(int sizeZ) { 177 this.sizeZ = sizeZ; 178 } 179 180}