mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 09:33:43 +01:00 
			
		
		
		
	Allow specifying Y value for default plot home
This commit is contained in:
		| @@ -1248,8 +1248,9 @@ public class Plot { | |||||||
|                 x = bot.getX() + loc.x; |                 x = bot.getX() + loc.x; | ||||||
|                 z = bot.getZ() + loc.z; |                 z = bot.getZ() + loc.z; | ||||||
|             } |             } | ||||||
|             int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z) : 62; |             int y = loc.y < 1 ? (isLoaded() ? WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z) + 1 : 63) : loc.y; | ||||||
|             return new Location(plot.getWorldName(), x, y + 1, z); |             PlotSquared.log("Getting home with Y " + y); | ||||||
|  |             return new Location(plot.getWorldName(), x, y, z); | ||||||
|         } |         } | ||||||
|         // Side |         // Side | ||||||
|         return plot.getSide(); |         return plot.getSide(); | ||||||
|   | |||||||
| @@ -272,16 +272,16 @@ public abstract class PlotArea { | |||||||
|             this.NONMEMBER_HOME = PlotLoc.fromString(homeNonMembers); |             this.NONMEMBER_HOME = PlotLoc.fromString(homeNonMembers); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         if ("side".equalsIgnoreCase(homeDefault)) { |         if ("side".equalsIgnoreCase(homeDefault)) { | ||||||
|             this.DEFAULT_HOME = null; |             this.DEFAULT_HOME = null; | ||||||
|         } else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle")) { |         } else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle")) { | ||||||
|             this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE); |             this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE); | ||||||
|         } else { |         } else { | ||||||
|             try { |             try { | ||||||
|                 String[] split = homeDefault.split(","); |                 /*String[] split = homeDefault.split(","); | ||||||
|                 this.DEFAULT_HOME = |                 this.DEFAULT_HOME = | ||||||
|                     new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1])); |                     new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));*/ | ||||||
|  |                 this.DEFAULT_HOME = PlotLoc.fromString(homeDefault); | ||||||
|             } catch (NumberFormatException ignored) { |             } catch (NumberFormatException ignored) { | ||||||
|                 this.DEFAULT_HOME = null; |                 this.DEFAULT_HOME = null; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -3,11 +3,20 @@ package com.github.intellectualsites.plotsquared.plot.object; | |||||||
| import com.github.intellectualsites.plotsquared.plot.util.StringMan; | import com.github.intellectualsites.plotsquared.plot.util.StringMan; | ||||||
|  |  | ||||||
| public class PlotLoc { | public class PlotLoc { | ||||||
|  |  | ||||||
|     public int x; |     public int x; | ||||||
|  |     public int y; | ||||||
|     public int z; |     public int z; | ||||||
|  |  | ||||||
|     public PlotLoc(int x, int z) { |     public PlotLoc(int x, int z) { | ||||||
|         this.x = x; |         this.x = x; | ||||||
|  |         this.y = -1; | ||||||
|  |         this.z = z; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public PlotLoc(int x, int y, int z) { | ||||||
|  |         this.x = x; | ||||||
|  |         this.y = y; | ||||||
|         this.z = z; |         this.z = z; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -19,7 +28,13 @@ public class PlotLoc { | |||||||
|         } else { |         } else { | ||||||
|             try { |             try { | ||||||
|                 String[] split = input.split(","); |                 String[] split = input.split(","); | ||||||
|  |                 if (split.length == 2) { | ||||||
|                     return new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1])); |                     return new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1])); | ||||||
|  |                 } else if (split.length == 3) { | ||||||
|  |                     return new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])); | ||||||
|  |                 } else { | ||||||
|  |                     throw new  IllegalArgumentException(String.format("Unable to deserialize: %s", input)); | ||||||
|  |                 } | ||||||
|             } catch (NumberFormatException ignored) { |             } catch (NumberFormatException ignored) { | ||||||
|                 return null; |                 return null; | ||||||
|             } |             } | ||||||
| @@ -30,12 +45,16 @@ public class PlotLoc { | |||||||
|         int prime = 31; |         int prime = 31; | ||||||
|         int result = 1; |         int result = 1; | ||||||
|         result = (prime * result) + this.x; |         result = (prime * result) + this.x; | ||||||
|  |         result = (prime * result) + this.y; | ||||||
|         result = (prime * result) + this.z; |         result = (prime * result) + this.z; | ||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override public String toString() { |     @Override public String toString() { | ||||||
|         return this.x + "," + this.z; |         if (this.y == -1) { | ||||||
|  |             return String.format("%d,%d", x, z); | ||||||
|  |         } | ||||||
|  |         return String.format("%d,%d,%d", x, y, z); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override public boolean equals(Object obj) { |     @Override public boolean equals(Object obj) { | ||||||
| @@ -49,6 +68,6 @@ public class PlotLoc { | |||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         PlotLoc other = (PlotLoc) obj; |         PlotLoc other = (PlotLoc) obj; | ||||||
|         return (this.x == other.x) && (this.z == other.z); |         return (this.x == other.x) && (this.y == other.y) && (this.z == other.z); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sauilitired
					Sauilitired