mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 20:56:45 +01:00
Add PS.get().isPlotWorld() and MainUtil.getPlotID( Location );
@_Cory_
This commit is contained in:
parent
f996b1d95d
commit
7b15d50674
@ -1,5 +1,38 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.MemorySection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
@ -55,39 +88,6 @@ import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.plotsquared.listener.WESubscriber;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* An implementation of the core,
|
||||
* with a static getter for easy access
|
||||
@ -1260,6 +1260,18 @@ public class PS {
|
||||
return new HashSet<>(myplots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link #hasPlotArea(String)}<br>
|
||||
* Note: Worlds may have more than one plot area
|
||||
* @deprecated
|
||||
* @param world
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isPlotWorld(String world) {
|
||||
return plotareamap.containsKey(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a plot world
|
||||
* @param world
|
||||
|
@ -20,6 +20,16 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -38,21 +48,24 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
*
|
||||
*/
|
||||
public class MainUtil {
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated
|
||||
* @param loc
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static PlotId getPlotId(Location loc) {
|
||||
PlotArea area = loc.getPlotArea();
|
||||
return area == null ? null : area.getPlotManager().getPlotId(area, loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* If the NMS code for sending chunk updates is functional<br>
|
||||
* - E.g. If using an older version of Bukkit, or before the plugin is updated to 1.5<br>
|
||||
|
@ -24,6 +24,7 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -51,6 +52,36 @@ public class ReflectionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Method findMethod(Class<?> clazz, boolean isStatic, Class<?> returnType, Class... types) {
|
||||
System.out.println("CLASS: " + clazz + " | " + isStatic + " | " + returnType + " | " + types.length);
|
||||
loop: for (Method method : clazz.getMethods()) {
|
||||
Class<?> result = method.getReturnType();
|
||||
Class<?>[] param = method.getParameterTypes();
|
||||
int paramCount = param.length;
|
||||
boolean stc = Modifier.isStatic(method.getModifiers());
|
||||
if (stc == isStatic && result == returnType && types.length == paramCount) {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (types[i] != param[i]) {
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
method.setAccessible(true);
|
||||
return method;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("no such method");
|
||||
}
|
||||
|
||||
public static Field findField(Class<?> clazz, Class<?> fieldClass) {
|
||||
for (Field field : clazz.getFields()) {
|
||||
if (field.getClass() == fieldClass) {
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> List<T> getStaticFields(Class clazz) {
|
||||
ArrayList<T> list = new ArrayList<T>();
|
||||
try {
|
||||
|
@ -716,7 +716,7 @@ public class MainListener {
|
||||
if (plotworld == null) {
|
||||
return;
|
||||
}
|
||||
final PlotManager plotManager = PS.get().getPlotManager(PS.get().getPlot(plotworld, plotworld.getMin()));
|
||||
final PlotManager plotManager = plotworld.getPlotManager();
|
||||
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, MathMan.roundInt(to.getZ()));
|
||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if (id == null) {
|
||||
@ -772,7 +772,7 @@ public class MainListener {
|
||||
if (plotworld == null) {
|
||||
return;
|
||||
}
|
||||
final PlotManager plotManager = PS.get().getPlot(plotworld, plotworld.getMin()).getManager();
|
||||
final PlotManager plotManager = plotworld.getPlotManager();
|
||||
final PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
|
||||
final Plot lastPlot = pp.getMeta("lastplot");
|
||||
if (id == null) {
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.plotsquared.sponge.util.block;
|
||||
|
||||
public class FastChunk {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user