mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Start implementing new Flag system.
This commit is contained in:
@ -385,18 +385,6 @@ public class PlotAPI {
|
||||
FlagManager.addFlag(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* get all the currently registered flags.
|
||||
*
|
||||
* @return array of Flag[]
|
||||
*
|
||||
* @see FlagManager#getFlags()
|
||||
* @see AbstractFlag
|
||||
*/
|
||||
public AbstractFlag[] getFlags() {
|
||||
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the ID.
|
||||
*
|
||||
@ -663,7 +651,7 @@ public class PlotAPI {
|
||||
if (world == null) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
return BukkitUtil.getPlayer(player).getPlots(world.getName());
|
||||
return PlotPlayer.wrap(player).getPlots(world.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -675,7 +663,7 @@ public class PlotAPI {
|
||||
*
|
||||
*/
|
||||
public int getAllowedPlots(Player player) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
PlotPlayer pp = PlotPlayer.wrap(player);
|
||||
return pp.getAllowedPlots();
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
@ -95,7 +94,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
public static WorldEditPlugin worldEdit;
|
||||
|
||||
@ -195,14 +194,18 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
public void run() {
|
||||
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||
@Override
|
||||
public void run(PlotArea pw) {
|
||||
World world = Bukkit.getWorld(pw.worldname);
|
||||
public void run(PlotArea plotArea) {
|
||||
World world = Bukkit.getWorld(plotArea.worldname);
|
||||
try {
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
List<Entity> entities = world.getEntities();
|
||||
Iterator<Entity> iterator = entities.iterator();
|
||||
for (Entity entity : entities) {
|
||||
|
||||
}
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = iterator.next();
|
||||
switch (entity.getType()) {
|
||||
@ -211,6 +214,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
case COMPLEX_PART:
|
||||
case FISHING_HOOK:
|
||||
case ENDER_SIGNAL:
|
||||
case LINGERING_POTION:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case EXPERIENCE_ORB:
|
||||
case LEASH_HITCH:
|
||||
@ -507,7 +511,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
if (!checkVersion) {
|
||||
log(C.PREFIX + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
||||
Settings.TITLES = false;
|
||||
FlagManager.removeFlag(FlagManager.getFlag("titles"));
|
||||
} else {
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_19();
|
||||
if (wrapper instanceof DefaultUUIDWrapper || wrapper.getClass() == OfflineUUIDWrapper.class && !Bukkit.getOnlineMode()) {
|
||||
|
@ -5,8 +5,6 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
@ -21,15 +19,6 @@ abstract class APlotMeConnector {
|
||||
|
||||
public abstract boolean accepts(String version);
|
||||
|
||||
public String getWorld(String world) {
|
||||
for (World newWorld : Bukkit.getWorlds()) {
|
||||
if (newWorld.getName().equalsIgnoreCase(world)) {
|
||||
return newWorld.getName();
|
||||
}
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
public boolean isValidConnection(Connection connection) {
|
||||
return connection != null;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -36,7 +37,13 @@ public class ForceFieldListener implements Listener {
|
||||
private PlotPlayer hasNearbyPermitted(Player player, Plot plot) {
|
||||
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
|
||||
PlotPlayer pp;
|
||||
if (!(entity instanceof Player) || ((pp = BukkitUtil.getPlayer((Player) entity)) == null) || !plot.equals(pp.getCurrentPlot())) {
|
||||
if (!(entity instanceof Player)) {
|
||||
continue;
|
||||
}
|
||||
if ((pp = BukkitUtil.getPlayer((Player) entity)) == null) {
|
||||
continue;
|
||||
}
|
||||
if (!plot.equals(pp.getCurrentPlot())) {
|
||||
continue;
|
||||
}
|
||||
if (plot.isAdded(pp.getUUID())) {
|
||||
@ -84,8 +91,9 @@ public class ForceFieldListener implements Listener {
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if ((FlagManager.getPlotFlagRaw(plot, "forcefield") != null) && FlagManager.getPlotFlagRaw(plot, "forcefield").getValue().equals("true")) {
|
||||
if (!FlagManager.isBooleanFlag(plot, "forcefield", false)) {
|
||||
Optional<Boolean> forcefield = plot.getFlag(Flags.FORCEFIELD);
|
||||
if (forcefield.isPresent() && forcefield.get()) {
|
||||
if (!plot.getFlag(Flags.FORCEFIELD).or(false)) {
|
||||
UUID uuid = pp.getUUID();
|
||||
if (plot.isAdded(uuid)) {
|
||||
Set<PlotPlayer> players = getNearbyPlayers(player, plot);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
@ -35,7 +35,7 @@ public class PlayerEvents183 implements Listener {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(loc);
|
||||
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
if (plot == null || !plot.getFlag(Flags.EXPLOSION).or(false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||
@ -88,7 +88,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (FlagManager.isBooleanFlag(plot, "instabreak", false)) {
|
||||
if (plot.getFlag(Flags.INSTABREAK).or(false)) {
|
||||
event.getBlock().breakNaturally();
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (FlagManager.isBooleanFlag(plot, "invincible", false)) {
|
||||
if (plot.getFlag(Flags.INVINCIBLE).or(false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
UUID uuid = pp.getUUID();
|
||||
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "drop-protection", false)) {
|
||||
if (plot.isAdded(uuid) && plot.getFlag(Flags.DROP_PROTECTION).or(false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
UUID uuid = pp.getUUID();
|
||||
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "item-drop", false)) {
|
||||
if (plot.isAdded(uuid) && plot.getFlag(Flags.ITEM_DROP).or(false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -140,14 +140,14 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
public void onPlotEnter(PlayerEnterPlotEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Plot plot = event.getPlot();
|
||||
Flag feed = FlagManager.getPlotFlagRaw(plot, "feed");
|
||||
if (feed != null) {
|
||||
Integer[] value = (Integer[]) feed.getValue();
|
||||
Optional<Integer[]> feed = plot.getFlag(Flags.FEED);
|
||||
if (feed.isPresent()) {
|
||||
Integer[] value = feed.get();
|
||||
feedRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||
}
|
||||
Flag heal = FlagManager.getPlotFlagRaw(plot, "heal");
|
||||
if (heal != null) {
|
||||
Integer[] value = (Integer[]) heal.getValue();
|
||||
Optional<Integer[]> heal = plot.getFlag(Flags.HEAL);
|
||||
if (heal.isPresent()) {
|
||||
Integer[] value = heal.get();
|
||||
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class DefaultTitleManager extends TitleManager {
|
||||
@ -23,18 +22,6 @@ public class DefaultTitleManager extends TitleManager {
|
||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||
}
|
||||
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load spigot and NMS classes.
|
||||
*/
|
||||
@ -90,7 +77,8 @@ public class DefaultTitleManager extends TitleManager {
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override public void clearTitle(Player player) throws Exception {
|
||||
@Override
|
||||
public void clearTitle(Player player) throws Exception {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
@ -106,7 +94,8 @@ public class DefaultTitleManager extends TitleManager {
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override public void resetTitle(Player player) throws Exception {
|
||||
@Override
|
||||
public void resetTitle(Player player) throws Exception {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
@ -116,27 +105,7 @@ public class DefaultTitleManager extends TitleManager {
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
|
||||
private Object getHandle(Object obj) {
|
||||
try {
|
||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Method m : clazz.getMethods()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
|
||||
if (m.getName().equals(name) && equalsTypeArray(types, t)) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Field getField(Class<?> clazz, String name) {
|
||||
Field getField(Class<?> clazz, String name) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
@ -157,7 +126,7 @@ public class DefaultTitleManager extends TitleManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
|
||||
boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
|
||||
if (l1.length != l2.length) {
|
||||
return false;
|
||||
}
|
||||
|
@ -4,10 +4,9 @@ import com.plotsquared.bukkit.chat.Reflection;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class DefaultTitleManager_183 extends TitleManager {
|
||||
public class DefaultTitleManager_183 extends DefaultTitleManager {
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
@ -22,18 +21,6 @@ public class DefaultTitleManager_183 extends TitleManager {
|
||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||
}
|
||||
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load spigot and NMS classes.
|
||||
*/
|
||||
@ -82,71 +69,6 @@ public class DefaultTitleManager_183 extends TitleManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the title.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void clearTitle(Player player) throws Exception {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
Object[] actions = this.packetActions.getEnumConstants();
|
||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[3], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the title settings.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void resetTitle(Player player) throws Exception {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
Object[] actions = this.packetActions.getEnumConstants();
|
||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||
Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
|
||||
private Object getHandle(Object obj) {
|
||||
try {
|
||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Method m : clazz.getMethods()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
|
||||
if (m.getName().equals(name) && equalsTypeArray(types, t)) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Field getField(Class<?> clazz, String name) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
for (Method m : clazz.getMethods()) {
|
||||
if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) {
|
||||
@ -157,17 +79,4 @@ public class DefaultTitleManager_183 extends TitleManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
|
||||
if (l1.length != l2.length) {
|
||||
return false;
|
||||
}
|
||||
boolean equal = true;
|
||||
for (int i = 0; i < l1.length; i++) {
|
||||
if (l1[i] != l2[i]) {
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class HackTitleManager extends TitleManager {
|
||||
@ -24,18 +23,6 @@ public class HackTitleManager extends TitleManager {
|
||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||
}
|
||||
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load spigot and NMS classes.
|
||||
*/
|
||||
@ -171,26 +158,6 @@ public class HackTitleManager extends TitleManager {
|
||||
return f.get(obj);
|
||||
}
|
||||
|
||||
private Object getHandle(Object obj) {
|
||||
try {
|
||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Method m : clazz.getMethods()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
|
||||
if (m.getName().equals(name) && equalsTypeArray(types, t)) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Field getField(Class<?> clazz, String name) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
@ -225,4 +192,5 @@ public class HackTitleManager extends TitleManager {
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -201,4 +203,36 @@ public abstract class TitleManager {
|
||||
return types;
|
||||
}
|
||||
|
||||
final Object getHandle(Object obj) {
|
||||
try {
|
||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Method m : clazz.getMethods()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
|
||||
if (m.getName().equals(name) && equalsTypeArray(types, t)) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
final boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,41 +20,41 @@ public class BukkitChatManager extends ChatManager<FancyMessage> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void color(PlotMessage m, String color) {
|
||||
m.$(this).color(ChatColor.getByChar(C.color(color).substring(1)));
|
||||
public void color(PlotMessage message, String color) {
|
||||
message.$(this).color(ChatColor.getByChar(C.color(color).substring(1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tooltip(PlotMessage m, PlotMessage... tooltips) {
|
||||
public void tooltip(PlotMessage message, PlotMessage... tooltips) {
|
||||
List<FancyMessage> lines = new ArrayList<>();
|
||||
for (PlotMessage tooltip : tooltips) {
|
||||
lines.add(tooltip.$(this));
|
||||
}
|
||||
m.$(this).formattedTooltip(lines);
|
||||
message.$(this).formattedTooltip(lines);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void command(PlotMessage m, String command) {
|
||||
m.$(this).command(command);
|
||||
public void command(PlotMessage message, String command) {
|
||||
message.$(this).command(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void text(PlotMessage m, String text) {
|
||||
m.$(this).then(ChatColor.stripColor(text));
|
||||
public void text(PlotMessage message, String text) {
|
||||
message.$(this).then(ChatColor.stripColor(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(PlotMessage m, PlotPlayer player) {
|
||||
public void send(PlotMessage plotMessage, PlotPlayer player) {
|
||||
if (player instanceof ConsolePlayer) {
|
||||
player.sendMessage(m.$(this).toOldMessageFormat());
|
||||
player.sendMessage(plotMessage.$(this).toOldMessageFormat());
|
||||
} else {
|
||||
m.$(this).send(((BukkitPlayer) player).player);
|
||||
plotMessage.$(this).send(((BukkitPlayer) player).player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suggest(PlotMessage m, String command) {
|
||||
m.$(this).suggest(command);
|
||||
public void suggest(PlotMessage plotMessage, String command) {
|
||||
plotMessage.$(this).suggest(command);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class BukkitEventUtil extends EventUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callFlagRemove(Flag flag, Plot plot) {
|
||||
public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) {
|
||||
return callEvent(new PlotFlagRemoveEvent(flag, plot));
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public class BukkitEventUtil extends EventUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callFlagRemove(Flag flag, PlotCluster cluster) {
|
||||
public boolean callFlagRemove(Flag flag, Object object, PlotCluster cluster) {
|
||||
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
|
||||
}
|
||||
|
||||
|
@ -16,35 +16,35 @@ public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void color(PlotMessage m, String color) {
|
||||
List<StringBuilder> parts = m.$(this);
|
||||
public void color(PlotMessage message, String color) {
|
||||
List<StringBuilder> parts = message.$(this);
|
||||
parts.get(parts.size() - 1).insert(0, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tooltip(PlotMessage m, PlotMessage... tooltips) {
|
||||
public void tooltip(PlotMessage message, PlotMessage... tooltips) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void command(PlotMessage m, String command) {
|
||||
public void command(PlotMessage message, String command) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void text(PlotMessage m, String text) {
|
||||
m.$(this).add(new StringBuilder(ChatColor.stripColor(text)));
|
||||
public void text(PlotMessage message, String text) {
|
||||
message.$(this).add(new StringBuilder(ChatColor.stripColor(text)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(PlotMessage m, PlotPlayer player) {
|
||||
public void send(PlotMessage plotMessage, PlotPlayer player) {
|
||||
StringBuilder built = new StringBuilder();
|
||||
for (StringBuilder sb : m.$(this)) {
|
||||
for (StringBuilder sb : plotMessage.$(this)) {
|
||||
built.append(sb);
|
||||
}
|
||||
player.sendMessage(built.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suggest(PlotMessage m, String command) {
|
||||
public void suggest(PlotMessage plotMessage, String command) {
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user