Merge remote-tracking branch 'origin/master'

This commit is contained in:
MattBDev 2016-06-27 10:10:55 -04:00
commit a579df00db
14 changed files with 97 additions and 95 deletions

View File

@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.object.chat.PlainChatManager;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.ChatManager;
import com.intellectualcrafters.plot.util.ChunkManager;
@ -52,7 +53,6 @@ import com.plotsquared.bukkit.util.BukkitEconHandler;
import com.plotsquared.bukkit.util.BukkitEventUtil;
import com.plotsquared.bukkit.util.BukkitHybridUtils;
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
import com.plotsquared.bukkit.util.BukkitPlainChatManager;
import com.plotsquared.bukkit.util.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.BukkitTaskManager;
@ -428,7 +428,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
new SendChunk();
MainUtil.canSendChunk = true;
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
e.printStackTrace();
PS.debug(SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
MainUtil.canSendChunk = false;
}
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
@ -653,7 +653,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
if (Settings.Chat.INTERACTIVE) {
return new BukkitChatManager();
} else {
return new BukkitPlainChatManager();
return new PlainChatManager();
}
}

View File

@ -14,6 +14,20 @@ import java.util.Map;
*/
public final class Reflection {
/**
* Stores loaded classes from the {@code net.minecraft.server} package.
*/
private static final Map<String, Class<?>> _loadedNMSClasses = new HashMap<String, Class<?>>();
/**
* Stores loaded classes from the {@code org.bukkit.craftbukkit} package (and subpackages).
*/
private static final Map<String, Class<?>> _loadedOBCClasses = new HashMap<String, Class<?>>();
private static final Map<Class<?>, Map<String, Field>> _loadedFields = new HashMap<Class<?>, Map<String, Field>>();
/**
* Contains loaded methods in a cache.
* The map maps [types to maps of [method names to maps of [parameter types to method instances]]].
*/
private static final Map<Class<?>, Map<String, Map<ArrayWrapper<Class<?>>, Method>>> _loadedMethods = new HashMap<Class<?>, Map<String, Map<ArrayWrapper<Class<?>>, Method>>>();
private static String _versionString;
private Reflection() { }
@ -37,16 +51,6 @@ public final class Reflection {
return _versionString;
}
/**
* Stores loaded classes from the {@code net.minecraft.server} package.
*/
private static final Map<String, Class<?>> _loadedNMSClasses = new HashMap<String, Class<?>>();
/**
* Stores loaded classes from the {@code org.bukkit.craftbukkit} package (and subpackages).
*/
private static final Map<String, Class<?>> _loadedOBCClasses = new HashMap<String, Class<?>>();
/**
* Gets a {@link Class} object representing a type contained within the {@code net.minecraft.server} versioned package.
* The class instances returned by this method are cached, such that no lookup will be done twice (unless multiple threads are accessing this method simultaneously).
@ -64,9 +68,8 @@ public final class Reflection {
try {
clazz = Class.forName(fullName);
} catch (Exception e) {
e.printStackTrace();
_loadedNMSClasses.put(className, null);
return null;
throw new RuntimeException(e);
}
_loadedNMSClasses.put(className, clazz);
return clazz;
@ -89,9 +92,8 @@ public final class Reflection {
try {
clazz = Class.forName(fullName);
} catch (Exception e) {
e.printStackTrace();
_loadedOBCClasses.put(className, null);
return null;
throw new RuntimeException(e);
}
_loadedOBCClasses.put(className, clazz);
return clazz;
@ -110,13 +112,10 @@ public final class Reflection {
try {
return getMethod(obj.getClass(), "getHandle").invoke(obj);
} catch (Exception e) {
e.printStackTrace();
return null;
throw new RuntimeException(e);
}
}
private static final Map<Class<?>, Map<String, Field>> _loadedFields = new HashMap<Class<?>, Map<String, Field>>();
/**
* Retrieves a {@link Field} instance declared by the specified class with the specified name.
* Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field
@ -161,12 +160,6 @@ public final class Reflection {
}
}
/**
* Contains loaded methods in a cache.
* The map maps [types to maps of [method names to maps of [parameter types to method instances]]].
*/
private static final Map<Class<?>, Map<String, Map<ArrayWrapper<Class<?>>, Method>>> _loadedMethods = new HashMap<Class<?>, Map<String, Map<ArrayWrapper<Class<?>>, Method>>>();
/**
* Retrieves a {@link Method} instance declared by the specified class with the specified name and argument types.
* Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field

View File

@ -30,7 +30,6 @@ public class DefaultTitleManager_183 extends DefaultTitleManager {
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
this.nmsChatSerializer = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
}
@Override

View File

@ -26,9 +26,8 @@ import java.util.HashSet;
import java.util.Map.Entry;
/**
* An utility that can be used to send chunks, rather than using bukkit code to do so (uses heavy NMS)
*
* An utility that can be used to send chunks, rather than using bukkit code
* to do so (uses heavy NMS).
*/
public class SendChunk {
@ -40,7 +39,7 @@ public class SendChunk {
private final RefMethod methodInitLighting;
/**
* Constructor
* Constructor.
*/
public SendChunk() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException {
RefConstructor tempMapChunk;

View File

@ -85,7 +85,7 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
if (block != null) {
int x = MainUtil.x_loc[layer][j];
int y = MainUtil.y_loc[layer][j];
int z = MainUtil.y_loc[layer][j];
int z = MainUtil.z_loc[layer][j];
Block existing = chunk.getBlock(x, y, z);
int existingId = existing.getTypeId();
if (existingId == block.id) {

View File

@ -54,7 +54,7 @@ public class Kick extends SubCommand {
}
players.add(pp);
}
break;
continue;
}
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
if (pp != null) {
@ -67,8 +67,7 @@ public class Kick extends SubCommand {
return false;
}
for (PlotPlayer player2 : players) {
Location location2 = player2.getLocation();
if (!player2.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
if (!plot.equals(player2.getCurrentPlot())) {
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
return false;
}

View File

@ -454,6 +454,7 @@ public enum C {
* Info
*/
NONE("None", "Info"),
NOW("Now", "Info"),
NEVER("Never", "Info"),
UNKNOWN("Unknown", "Info"),
EVERYONE("Everyone", "Info"),

View File

@ -65,7 +65,7 @@ public class Settings extends Config {
Enabled_Components.KILL_ROAD_VEHICLES = config.getBoolean("kill_road_vehicles", Enabled_Components.KILL_ROAD_VEHICLES);
// Clearing + Expiry
// FAST_CLEAR = config.getBoolean("clear.fastmode");
//FAST_CLEAR = config.getBoolean("clear.fastmode");
Enabled_Components.PLOT_EXPIRY = config.getBoolean("clear.auto.enabled", Enabled_Components.PLOT_EXPIRY);
if (Enabled_Components.PLOT_EXPIRY) {
Enabled_Components.BAN_DELETER = config.getBoolean("clear.on.ban");
@ -119,7 +119,7 @@ public class Settings extends Config {
Teleport.ON_DEATH = config.getBoolean("teleport.on_death", Teleport.ON_DEATH);
// WorldEdit
// WE_ALLOW_HELPER = config.getBoolean("worldedit.enable-for-helpers");
//WE_ALLOW_HELPER = config.getBoolean("worldedit.enable-for-helpers");
// Chunk processor
Enabled_Components.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled", Enabled_Components.CHUNK_PROCESSOR);

View File

@ -1650,7 +1650,7 @@ public class Plot {
if (uuid == DBFunc.everyone) {
boolean result = false;
for (UUID other : new HashSet<>(getDenied())) {
result = result || rmvDenied(other);
result = rmvDenied(other) || result;
}
return result;
}
@ -1677,7 +1677,7 @@ public class Plot {
if (uuid == DBFunc.everyone) {
boolean result = false;
for (UUID other : new HashSet<>(getTrusted())) {
result = result || rmvTrusted(other);
result = rmvTrusted(other) || result;
}
return result;
}
@ -1707,7 +1707,7 @@ public class Plot {
if (uuid == DBFunc.everyone) {
boolean result = false;
for (UUID other : new HashSet<>(this.members)) {
result = result || rmvMember(other);
result = rmvMember(other) || result;
}
return result;
}
@ -2681,7 +2681,7 @@ public class Plot {
greaterPlot.setMerged(3, true);
lesserPlot.mergeData(greaterPlot);
if (removeRoads) {
Plot diagonal = greaterPlot.getRelative(1);
Plot diagonal = greaterPlot.getRelative(2);
if (diagonal.getMerged(7)) {
lesserPlot.removeRoadSouthEast();
}

View File

@ -1,6 +1,8 @@
package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.chat.PlainChatManager;
import com.intellectualcrafters.plot.util.ChatManager;
public class PlotMessage {
@ -8,8 +10,14 @@ public class PlotMessage {
private Object builder;
public PlotMessage() {
try {
reset(ChatManager.manager);
} catch (Throwable e) {
PS.debug("PlotSquared doesn't support fancy chat for " + PS.get().IMP.getServerVersion());
ChatManager.manager = new PlainChatManager();
reset(ChatManager.manager);
}
}
public PlotMessage(String text) {
this();

View File

@ -55,7 +55,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Set some session only metadata for the player.
* Set some session only metadata for this player.
* @param key
* @param value
*/
@ -102,7 +102,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* The player's name.
* This player's name.
*
* @return the name of the player
*/
@ -112,7 +112,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Get the player's current plot.
* Get this player's current plot.
* @return the plot the player is standing on or null if standing on a road or not in a {@link PlotArea}
*/
public Plot getCurrentPlot() {
@ -133,7 +133,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Get the number of plots the player owns.
* Get the number of plots this player owns.
*
* @see #getPlotCount(String);
* @see #getPlots()
@ -164,7 +164,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Get the number of plots the player owns in the world.
* Get the number of plots this player owns in the world.
* @param world the name of the plotworld to check.
* @return
*/
@ -196,7 +196,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Return the PlotArea the player is currently in, or null.
* Return the PlotArea this player is currently in, or null.
* @return
*/
public PlotArea getPlotAreaAbs() {
@ -216,7 +216,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
////////////// PARTIALLY IMPLEMENTED ///////////
/**
* Get the player's last recorded location or null if they don't any plot relevant location.
* Get this player's last recorded location or null if they don't any plot relevant location.
* @return The location
*/
public Location getLocation() {
@ -235,13 +235,13 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Get the player's full location (including yaw/pitch)
* Get this player's full location (including yaw/pitch)
* @return
*/
public abstract Location getLocationFull();
/**
* Get the player's UUID.
* Get this player's UUID.
* === !IMPORTANT ===<br>
* The UUID is dependent on the mode chosen in the settings.yml and may not be the same as Bukkit has
* (especially if using an old version of Bukkit that does not support UUIDs)
@ -262,13 +262,13 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Teleport the player to a location.
* Teleport this player to a location.
* @param location the target location
*/
public abstract void teleport(Location location);
/**
* Set the compass target.
* Set this compass target.
* @param location the target location
*/
public abstract void setCompassTarget(Location location);
@ -285,7 +285,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
/**
* Retrieves t player attribute.
* Retrieves the attribute of this player.
*
* @param key
* @return the attribute will be either true or false
@ -312,19 +312,19 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
public abstract void setWeather(PlotWeather weather);
/**
* Get the player's gamemode.
* Get this player's gamemode.
* @return the gamemode of the player.
*/
public abstract PlotGameMode getGameMode();
/**
* Set the player's gameMode.
* Set this player's gameMode.
* @param gameMode the gamemode to set
*/
public abstract void setGameMode(PlotGameMode gameMode);
/**
* Set the player's local time (ticks).
* Set this player's local time (ticks).
* @param time the time visible to the player
*/
public abstract void setTime(long time);
@ -332,32 +332,32 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
public abstract boolean getFlight();
/**
* Set the player's fly mode.
* Set this player's fly mode.
* @param fly if the player can fly
*/
public abstract void setFlight(boolean fly);
/**
* Play music at a location for the player.
* Play music at a location for this player.
* @param location where to play the music
* @param id the numerical record item id
*/
public abstract void playMusic(Location location, int id);
/**
* Check if the player is banned.
* Check if this player is banned.
* @return true if the player is banned, false otherwise.
*/
public abstract boolean isBanned();
/**
* Kick the player from the game.
* Kick this player from the game.
* @param message the reason for the kick
*/
public abstract void kick(String message);
/**
* Called when the player quits.
* Called when this player quits.
*/
public void unregister() {
Plot plot = getCurrentPlot();
@ -379,7 +379,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Get the amount of clusters a player owns in the specific world.
* Get the amount of clusters this player owns in the specific world.
* @param world
* @return
*/
@ -395,7 +395,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Get the amount of clusters a player owns.
* Get the amount of clusters this player owns.
* @return the number of clusters this player owns
*/
public int getPlayerClusterCount() {
@ -410,9 +410,9 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Return a {@code Set} of all plots a player owns in a certain world.
* Return a {@code Set} of all plots this player owns in a certain world.
* @param world the world to retrieve plots from
* @return a {@code Set} of plots the player owns in the provided world
* @return a {@code Set} of plots this player owns in the provided world
*/
public Set<Plot> getPlots(String world) {
UUID uuid = getUUID();

View File

@ -1,14 +1,14 @@
package com.plotsquared.bukkit.util;
package com.intellectualcrafters.plot.object.chat;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotMessage;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.ChatManager;
import org.bukkit.ChatColor;
import java.util.ArrayList;
import java.util.List;
public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
public class PlainChatManager extends ChatManager<List<StringBuilder>> {
@Override
public List<StringBuilder> builder() {
@ -29,7 +29,7 @@ public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
@Override
public void text(PlotMessage message, String text) {
message.$(this).add(new StringBuilder(ChatColor.stripColor(text)));
message.$(this).add(new StringBuilder(C.color(text)));
}
@Override
@ -44,4 +44,4 @@ public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
@Override
public void suggest(PlotMessage plotMessage, String command) {}
}
}

View File

@ -17,6 +17,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@ -208,29 +209,29 @@ public class MainUtil {
public static String secToTime(long time) {
StringBuilder toreturn = new StringBuilder();
if (time>=33868800) {
int years = (int) (time/33868800);
time-=years*33868800;
if (time >= 33868800) {
int years = (int) (time / 33868800);
time -= years * 33868800;
toreturn.append(years+"y ");
}
if (time>=604800) {
int weeks = (int) (time/604800);
time-=weeks*604800;
if (time >= 604800) {
int weeks = (int) (time / 604800);
time -= weeks * 604800;
toreturn.append(weeks+"w ");
}
if (time>=86400) {
int days = (int) (time/86400);
time-=days*86400;
if (time >= 86400) {
int days = (int) (time / 86400);
time -= days * 86400;
toreturn.append(days+"d ");
}
if (time>=3600) {
int hours = (int) (time/3600);
time-=hours*3600;
if (time >= 3600) {
int hours = (int) (time / 3600);
time -= hours * 3600;
toreturn.append(hours+"h ");
}
if (time>=60) {
int minutes = (int) (time/60);
time-=minutes*60;
int minutes = (int) (time / 60);
time -= minutes * 60;
toreturn.append(minutes+"m ");
}
if (toreturn.equals("")||time>0){
@ -719,10 +720,18 @@ public class MainUtil {
String trusted = getPlayerList(plot.getTrusted());
String members = getPlayerList(plot.getMembers());
String denied = getPlayerList(plot.getDenied());
String seen = C.UNKNOWN.s();
String seen;
if (Settings.Enabled_Components.PLOT_EXPIRY) {
int time = (int) (ExpireManager.IMP.getAge(plot) / 1000);
seen = MainUtil.secToTime(time);
if (plot.isOnline()) {
seen = C.NOW.s();
} else {
int time = (int) (ExpireManager.IMP.getAge(plot) / 1000);
if (time != 0) {
seen = MainUtil.secToTime(time);
} else {
seen = C.UNKNOWN.s();
}
}
} else {
seen = C.NEVER.s();
}
@ -741,9 +750,7 @@ public class MainUtil {
}
}
boolean build = plot.isAdded(player.getUUID());
String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners());
info = info.replace("%id%", plot.getId().toString());
info = info.replace("%alias%", alias);
info = info.replace("%num%", String.valueOf(num));
@ -771,10 +778,6 @@ public class MainUtil {
String info;
if (full && Settings.Ratings.CATEGORIES != null && Settings.Ratings.CATEGORIES.size() > 1) {
double[] ratings = MainUtil.getAverageRatings(plot);
for (double v : ratings) {
}
String rating = "";
String prefix = "";
for (int i = 0; i < ratings.length; i++) {

View File

@ -300,7 +300,7 @@ public class ExpireManager {
}
}, 86400000);
} else {
TaskManager.runTaskLaterAsync(this, 20);
TaskManager.runTaskLaterAsync(this, 20 * 10);
}
}
});