mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 17:43:44 +01:00 
			
		
		
		
	Pass the PlotArea into the PlotManager
This commit is contained in:
		 Alexander Krivács Schrøder
					Alexander Krivács Schrøder
				
			
				
					committed by
					
						 Matt
						Matt
					
				
			
			
				
	
			
			
			 Matt
						Matt
					
				
			
						parent
						
							908a5784a1
						
					
				
				
					commit
					6b3960fc3f
				
			| @@ -30,8 +30,8 @@ import java.util.Random; | |||||||
|     @Override public void initialize(PlotArea area) { |     @Override public void initialize(PlotArea area) { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override public PlotManager getNewPlotManager() { |     @Override public PlotManager getNewPlotManager(PlotArea plotArea) { | ||||||
|         return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotManager(); |         return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotManager(plotArea); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override public String getName() { |     @Override public String getName() { | ||||||
|   | |||||||
| @@ -1086,7 +1086,7 @@ import java.util.zip.ZipInputStream; | |||||||
|             } |             } | ||||||
|             // Conventional plot generator |             // Conventional plot generator | ||||||
|             PlotArea plotArea = plotGenerator.getNewPlotArea(world, null, null, null); |             PlotArea plotArea = plotGenerator.getNewPlotArea(world, null, null, null); | ||||||
|             PlotManager plotManager = plotGenerator.getNewPlotManager(); |             PlotManager plotManager = plotGenerator.getNewPlotManager(plotArea); | ||||||
|             PlotSquared.log(Captions.PREFIX + "&aDetected world load for '" + world + "'"); |             PlotSquared.log(Captions.PREFIX + "&aDetected world load for '" + world + "'"); | ||||||
|             PlotSquared |             PlotSquared | ||||||
|                 .log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + plotGenerator); |                 .log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + plotGenerator); | ||||||
|   | |||||||
| @@ -13,6 +13,17 @@ import java.util.List; | |||||||
|  */ |  */ | ||||||
| public class ClassicPlotManager extends SquarePlotManager { | public class ClassicPlotManager extends SquarePlotManager { | ||||||
|  |  | ||||||
|  |     private final ClassicPlotWorld classicPlotWorld; | ||||||
|  |  | ||||||
|  |     public ClassicPlotManager(PlotArea plotArea) { | ||||||
|  |         super(plotArea); | ||||||
|  |         if (plotArea instanceof ClassicPlotWorld){ | ||||||
|  |             classicPlotWorld = (ClassicPlotWorld)plotArea; | ||||||
|  |         } else { | ||||||
|  |             throw new RuntimeException("ClassicPlotManager requires plotArea to be an instance of ClassicPlotWorld"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @Override public boolean setComponent(PlotArea plotArea, PlotId plotId, String component, |     @Override public boolean setComponent(PlotArea plotArea, PlotId plotId, String component, | ||||||
|                                           BlockBucket blocks) { |                                           BlockBucket blocks) { | ||||||
|         switch (component) { |         switch (component) { | ||||||
|   | |||||||
| @@ -1,10 +1,13 @@ | |||||||
| package com.github.intellectualsites.plotsquared.plot.generator; | package com.github.intellectualsites.plotsquared.plot.generator; | ||||||
|  |  | ||||||
|  | import com.github.intellectualsites.plotsquared.plot.object.PlotArea; | ||||||
| import com.github.intellectualsites.plotsquared.plot.object.PlotManager; | import com.github.intellectualsites.plotsquared.plot.object.PlotManager; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * A plot manager where plots tessellate in a grid formation symmetrical about x=z. |  * A plot manager where plots tessellate in a grid formation symmetrical about x=z. | ||||||
|  */ |  */ | ||||||
| public abstract class GridPlotManager extends PlotManager { | public abstract class GridPlotManager extends PlotManager { | ||||||
|  |     public GridPlotManager(PlotArea plotArea) { | ||||||
|  |         super(plotArea); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -253,8 +253,8 @@ public class HybridGen extends IndependentPlotGenerator { | |||||||
|         return new HybridPlotWorld(world, id, this, min, max); |         return new HybridPlotWorld(world, id, this, min, max); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override public PlotManager getNewPlotManager() { |     @Override public PlotManager getNewPlotManager(PlotArea plotArea) { | ||||||
|         return new HybridPlotManager(); |         return new HybridPlotManager(plotArea); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override public void initialize(PlotArea area) { |     @Override public void initialize(PlotArea area) { | ||||||
|   | |||||||
| @@ -21,6 +21,17 @@ public class HybridPlotManager extends ClassicPlotManager { | |||||||
|  |  | ||||||
|     public static boolean REGENERATIVE_CLEAR = true; |     public static boolean REGENERATIVE_CLEAR = true; | ||||||
|  |  | ||||||
|  |     private final HybridPlotWorld hybridPlotWorld; | ||||||
|  |  | ||||||
|  |     public HybridPlotManager(PlotArea plotArea) { | ||||||
|  |         super(plotArea); | ||||||
|  |         if (plotArea instanceof HybridPlotWorld){ | ||||||
|  |             hybridPlotWorld = (HybridPlotWorld)plotArea; | ||||||
|  |         } else { | ||||||
|  |             throw new RuntimeException("HybridPlotManager requires plotArea to be an instance of HybridPlotWorld"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @Override public void exportTemplate(PlotArea plotArea) throws IOException { |     @Override public void exportTemplate(PlotArea plotArea) throws IOException { | ||||||
|         HashSet<FileBytes> files = Sets.newHashSet( |         HashSet<FileBytes> files = Sets.newHashSet( | ||||||
|             new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea))); |             new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea))); | ||||||
|   | |||||||
| @@ -53,8 +53,9 @@ public abstract class IndependentPlotGenerator { | |||||||
|      * Return a new PlotManager object. |      * Return a new PlotManager object. | ||||||
|      * |      * | ||||||
|      * @return |      * @return | ||||||
|  |      * @param plotArea | ||||||
|      */ |      */ | ||||||
|     public abstract PlotManager getNewPlotManager(); |     public abstract PlotManager getNewPlotManager(PlotArea plotArea); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * If any additional setup options need to be changed before world creation. |      * If any additional setup options need to be changed before world creation. | ||||||
|   | |||||||
| @@ -14,6 +14,17 @@ import java.util.Iterator; | |||||||
|  */ |  */ | ||||||
| public abstract class SquarePlotManager extends GridPlotManager { | public abstract class SquarePlotManager extends GridPlotManager { | ||||||
|  |  | ||||||
|  |     private final SquarePlotWorld squarePlotWorld; | ||||||
|  |  | ||||||
|  |     public SquarePlotManager(PlotArea plotArea) { | ||||||
|  |         super(plotArea); | ||||||
|  |         if (plotArea instanceof SquarePlotWorld){ | ||||||
|  |             squarePlotWorld = (SquarePlotWorld)plotArea; | ||||||
|  |         } else { | ||||||
|  |             throw new RuntimeException("SquarePlotManager requires plotArea to be an instance of SquarePlotWorld"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean clearPlot(PlotArea plotArea, final Plot plot, final Runnable whenDone) { |     public boolean clearPlot(PlotArea plotArea, final Plot plot, final Runnable whenDone) { | ||||||
|         final HashSet<RegionWrapper> regions = plot.getRegions(); |         final HashSet<RegionWrapper> regions = plot.getRegions(); | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ public abstract class PlotArea { | |||||||
|         @Nullable final PlotId max) { |         @Nullable final PlotId max) { | ||||||
|         this.worldname = worldName; |         this.worldname = worldName; | ||||||
|         this.id = id; |         this.id = id; | ||||||
|         this.manager = generator.getNewPlotManager(); |         this.manager = generator.getNewPlotManager(this); | ||||||
|         this.generator = generator; |         this.generator = generator; | ||||||
|         if (min == null || max == null) { |         if (min == null || max == null) { | ||||||
|             if (min != max) { |             if (min != max) { | ||||||
|   | |||||||
| @@ -10,6 +10,13 @@ import java.util.List; | |||||||
|  |  | ||||||
| public abstract class PlotManager { | public abstract class PlotManager { | ||||||
|  |  | ||||||
|  |     private final PlotArea plotArea; | ||||||
|  |  | ||||||
|  |     public PlotManager(PlotArea plotArea) { | ||||||
|  |  | ||||||
|  |         this.plotArea = plotArea; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /* |     /* | ||||||
|      * Plot locations (methods with Abs in them will not need to consider mega |      * Plot locations (methods with Abs in them will not need to consider mega | ||||||
|      * plots). |      * plots). | ||||||
|   | |||||||
| @@ -10,6 +10,10 @@ import java.io.File; | |||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class SinglePlotManager extends PlotManager { | public class SinglePlotManager extends PlotManager { | ||||||
|  |     public SinglePlotManager(PlotArea plotArea) { | ||||||
|  |         super(plotArea); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @Override public PlotId getPlotIdAbs(PlotArea plotArea, int x, int y, int z) { |     @Override public PlotId getPlotIdAbs(PlotArea plotArea, int x, int y, int z) { | ||||||
|         return new PlotId(0, 0); |         return new PlotId(0, 0); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -81,8 +81,8 @@ public class SingleWorldGenerator extends IndependentPlotGenerator { | |||||||
|         return ((SinglePlotAreaManager) PlotSquared.get().getPlotAreaManager()).getArea(); |         return ((SinglePlotAreaManager) PlotSquared.get().getPlotAreaManager()).getArea(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override public PlotManager getNewPlotManager() { |     @Override public PlotManager getNewPlotManager(PlotArea plotArea) { | ||||||
|         return new SinglePlotManager(); |         return new SinglePlotManager(plotArea); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override public void initialize(PlotArea area) { |     @Override public void initialize(PlotArea area) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user