This commit is contained in:
MattBDev 2016-11-20 22:24:27 -05:00
parent e0208aa369
commit 77281017d4
10 changed files with 165 additions and 81 deletions

View File

@ -2,12 +2,15 @@ repositories {
maven {url "https://hub.spigotmc.org/nexus/content/groups/public/"}
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/"}
maven {url "http://nexus.hc.to/content/repositories/pub_releases"}
mavenLocal()
}
dependencies {
compile project(':Core')
compile 'org.spigotmc:spigot-api:1.10.2-R0.1-SNAPSHOT'
compile 'net.milkbowl.vault:VaultAPI:1.6'
compile 'org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT'
compile("net.milkbowl.vault:VaultAPI:1.6") {
exclude module: 'bukkit'
}
}
sourceCompatibility = 1.7

View File

@ -72,15 +72,6 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.sk89q.worldedit.WorldEdit;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -97,54 +88,63 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
private static ConcurrentHashMap<String, Plugin> pluginMap;
static {
{ // Disable AWE as otherwise both fail to load
PluginManager manager = Bukkit.getPluginManager();
try {
Settings.load(new File("plugins/PlotSquared/config/settings.yml"));
if (Settings.Enabled_Components.PLOTME_CONVERTER) { // Only disable PlotMe if conversion is enabled
Field pluginsField = manager.getClass().getDeclaredField("plugins");
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
pluginsField.setAccessible(true);
lookupNamesField.setAccessible(true);
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
Iterator<Plugin> iter = plugins.iterator();
while (iter.hasNext()) {
if (iter.next().getName().startsWith("PlotMe")) {
iter.remove();
}
// Disable AWE as otherwise both fail to load
PluginManager manager = Bukkit.getPluginManager();
try {
Settings.load(new File("plugins/PlotSquared/config/settings.yml"));
if (Settings.Enabled_Components.PLOTME_CONVERTER) { // Only disable PlotMe if conversion is enabled
Field pluginsField = manager.getClass().getDeclaredField("plugins");
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
pluginsField.setAccessible(true);
lookupNamesField.setAccessible(true);
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
Iterator<Plugin> iter = plugins.iterator();
while (iter.hasNext()) {
if (iter.next().getName().startsWith("PlotMe")) {
iter.remove();
}
Map<String, Plugin> lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
lookupNames.remove("PlotMe");
lookupNames.remove("PlotMe-DefaultGenerator");
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
@Override
public boolean add(Plugin plugin) {
if (plugin.getName().startsWith("PlotMe")) {
System.out.print("Disabling `" + plugin.getName() + "` for PlotMe conversion (configure in PlotSquared settings.yml)");
} else {
return super.add(plugin);
}
return false;
}
});
pluginMap = new ConcurrentHashMap<String, Plugin>(lookupNames) {
@Override
public Plugin put(String key, Plugin plugin) {
if (!plugin.getName().startsWith("PlotMe")) {
return super.put(key, plugin);
}
return null;
}
};
lookupNamesField.set(manager, pluginMap);
}
} catch (Throwable ignore) {}
}
Map<String, Plugin> lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
lookupNames.remove("PlotMe");
lookupNames.remove("PlotMe-DefaultGenerator");
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
@Override
public boolean add(Plugin plugin) {
if (plugin.getName().startsWith("PlotMe")) {
System.out.print("Disabling `" + plugin.getName() + "` for PlotMe conversion (configure in PlotSquared settings.yml)");
} else {
return super.add(plugin);
}
return false;
}
});
pluginMap = new ConcurrentHashMap<String, Plugin>(lookupNames) {
@Override
public Plugin put(String key, Plugin plugin) {
if (!plugin.getName().startsWith("PlotMe")) {
return super.put(key, plugin);
}
return null;
}
};
lookupNamesField.set(manager, pluginMap);
}
} catch (Throwable ignore) {}
}
public static WorldEdit worldEdit;
@ -299,6 +299,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
case TIPPED_ARROW:
case ENDER_PEARL:
case ARROW:
case LLAMA_SPIT:
// managed elsewhere | projectile
continue;
case ITEM_FRAME:
@ -315,7 +316,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
case MINECART_MOB_SPAWNER:
case ENDER_CRYSTAL:
case MINECART_TNT:
case BOAT: {
case BOAT:
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation());
Plot plot = location.getPlot();
@ -339,7 +340,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} else {
continue;
}
}
case SMALL_FIREBALL:
case FIREBALL:
case DRAGON_FIREBALL:
@ -350,6 +350,20 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
case FALLING_BLOCK:
// managed elsewhere
continue;
case LLAMA:
case DONKEY:
case MULE:
case ZOMBIE_HORSE:
case SKELETON_HORSE:
case HUSK:
case ELDER_GUARDIAN:
case WITHER_SKELETON:
case STRAY:
case ZOMBIE_VILLAGER:
case EVOKER:
case EVOKER_FANGS:
case VEX:
case VINDICATOR:
case POLAR_BEAR:
case BAT:
case BLAZE:
@ -530,8 +544,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
public boolean initPlotMeConverter() {
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) {
return true;
}
else if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
} else if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
return true;
}
return false;

View File

@ -67,7 +67,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
return null;
}
boolean checkUUID = DBFunc.hasColumn(resultSet, "ownerID");
boolean merge = !this.plugin.equals("plotme") && Settings.Enabled_Components.PLOTME_CONVERTER;
boolean merge = !"plotme".equals(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER;
while (resultSet.next()) {
int key = resultSet.getInt("plot_id");
PlotId id = new PlotId(resultSet.getInt("plotX"), resultSet.getInt("plotZ"));

View File

@ -2,7 +2,6 @@ package com.plotsquared.bukkit.generator;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.ChunkWrapper;
@ -245,8 +244,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
ArrayList<BlockPopulator> toAdd = new ArrayList<>();
List<BlockPopulator> existing = world.getPopulators();
if (populators == null && platformGenerator != null) {
populators = new ArrayList<>();
this.populators.addAll(platformGenerator.getDefaultPopulators(world));
populators = new ArrayList<>(platformGenerator.getDefaultPopulators(world));
}
for (BlockPopulator populator : this.populators) {
if (!existing.contains(populator)) {

View File

@ -25,17 +25,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.BukkitVersion;
import com.plotsquared.listener.PlayerBlockEventType;
import com.plotsquared.listener.PlotListener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -123,6 +115,18 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
/**
* Player Events involving plots.
*
@ -160,6 +164,7 @@ public class PlayerEvents extends PlotListener implements Listener {
public void onRedstoneEvent(BlockRedstoneEvent event) {
Block block = event.getBlock();
switch (block.getType()) {
case OBSERVER:
case REDSTONE_LAMP_OFF:
case REDSTONE_WIRE:
case REDSTONE_LAMP_ON:
@ -604,7 +609,7 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea();
if (area == null || (!area.PLOT_CHAT != plotPlayer.getAttribute("chat"))) {
if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) {
return;
}
Plot plot = area.getPlot(location);
@ -1223,6 +1228,25 @@ public class PlayerEvents extends PlotListener implements Listener {
case NOTE_BLOCK:
case JUKEBOX:
case WORKBENCH:
case SILVER_SHULKER_BOX:
case BLACK_SHULKER_BOX:
case BLUE_SHULKER_BOX:
case RED_SHULKER_BOX:
case PINK_SHULKER_BOX:
case ORANGE_SHULKER_BOX:
case WHITE_SHULKER_BOX:
case YELLOW_SHULKER_BOX:
case BROWN_SHULKER_BOX:
case CYAN_SHULKER_BOX:
case GREEN_SHULKER_BOX:
case PURPLE_SHULKER_BOX:
case GRAY_SHULKER_BOX:
case LIME_SHULKER_BOX:
case LIGHT_BLUE_SHULKER_BOX:
case MAGENTA_SHULKER_BOX:
case COMMAND_REPEATING:
case COMMAND_CHAIN:
eventType = PlayerBlockEventType.INTERACT_BLOCK;
break;
case DRAGON_EGG:
@ -1241,7 +1265,7 @@ public class PlayerEvents extends PlotListener implements Listener {
}
Material type = (hand == null) ? null : hand.getType();
int id = (type == null) ? 0 : type.getId();
if (id == 0) {
if (type == Material.AIR) {
eventType = PlayerBlockEventType.INTERACT_BLOCK;
break;
}
@ -1258,18 +1282,15 @@ public class PlayerEvents extends PlotListener implements Listener {
case MONSTER_EGGS:
eventType = PlayerBlockEventType.SPAWN_MOB;
break;
case ARMOR_STAND:
location = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_MISC;
break;
case WRITTEN_BOOK:
case BOOK_AND_QUILL:
case BOOK:
eventType = PlayerBlockEventType.READ;
break;
case APPLE:
case BAKED_POTATO:
case MUSHROOM_SOUP:
@ -1510,6 +1531,7 @@ public class PlayerEvents extends PlotListener implements Listener {
switch (entity.getType()) {
case PLAYER:
return false;
case LLAMA_SPIT:
case SMALL_FIREBALL:
case FIREBALL:
case DROPPED_ITEM:
@ -1539,6 +1561,7 @@ public class PlayerEvents extends PlotListener implements Listener {
case AREA_EFFECT_CLOUD:
case LIGHTNING:
case WITHER_SKULL:
case EVOKER_FANGS:
case UNKNOWN:
// non moving / unmovable
return checkEntity(plot, Flags.ENTITY_CAP);
@ -1571,6 +1594,11 @@ public class PlayerEvents extends PlotListener implements Listener {
case SNOWMAN:
case BAT:
case HORSE:
case DONKEY:
case LLAMA:
case MULE:
case ZOMBIE_HORSE:
case SKELETON_HORSE:
// animal
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
case BLAZE:
@ -1592,6 +1620,14 @@ public class PlayerEvents extends PlotListener implements Listener {
case WITHER:
case ZOMBIE:
case SHULKER:
case HUSK:
case STRAY:
case ELDER_GUARDIAN:
case WITHER_SKELETON:
case VINDICATOR:
case EVOKER:
case VEX:
case ZOMBIE_VILLAGER:
// monster
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
default:
@ -2055,7 +2091,23 @@ public class PlayerEvents extends PlotListener implements Listener {
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
EntityDamageByEntityEvent eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
EntityDamageByEntityEvent eventChange = null;
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_11_0)) {
eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(),
EntityDamageEvent.DamageCause.FIRE_TICK, (double)event.getDuration());
} else {
try {
Constructor<EntityDamageByEntityEvent> constructor = EntityDamageByEntityEvent.class.getConstructor(Entity.class,
Entity.class, EntityDamageEvent.DamageCause.class, Integer.TYPE);
eventChange = constructor.newInstance(event.getCombuster(), event.getEntity(),
EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
e.printStackTrace();
}
}
if (eventChange == null) {
return;
}
onEntityDamageByEntityEvent(eventChange);
}

View File

@ -11,9 +11,6 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlotListener;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.ArmorStand;
@ -30,6 +27,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
public class PlayerEvents_1_8 extends PlotListener implements Listener {
@SuppressWarnings("deprecation")
@ -66,7 +67,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
oldLore = lore.toString();
}
}
if (!newLore.equals("[(+NBT)]") || (current.equals(newItem) && newLore.equals(oldLore))) {
if (!"[(+NBT)]".equals(newLore) || (current.equals(newItem) && newLore.equals(oldLore))) {
return;
}
HashSet<Byte> blocks = null;

View File

@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.entity.Player;
@SuppressWarnings("deprecation")
public class DefaultTitle_19 extends AbstractTitle {
@Override

View File

@ -516,6 +516,7 @@ public class BukkitChunkManager extends ChunkManager {
case SHULKER_BULLET:
case SPECTRAL_ARROW:
case DRAGON_FIREBALL:
case LLAMA_SPIT:
// projectile
case PRIMED_TNT:
case FALLING_BLOCK:
@ -533,6 +534,7 @@ public class BukkitChunkManager extends ChunkManager {
case UNKNOWN:
case AREA_EFFECT_CLOUD:
case LINGERING_POTION:
case EVOKER_FANGS:
// non moving / unremovable
break;
case ITEM_FRAME:
@ -566,6 +568,11 @@ public class BukkitChunkManager extends ChunkManager {
case COW:
case SNOWMAN:
case BAT:
case DONKEY:
case LLAMA:
case SKELETON_HORSE:
case ZOMBIE_HORSE:
case MULE:
// animal
count[3]++;
count[1]++;
@ -589,6 +596,14 @@ public class BukkitChunkManager extends ChunkManager {
case WITHER:
case ZOMBIE:
case SHULKER:
case ELDER_GUARDIAN:
case STRAY:
case HUSK:
case EVOKER:
case VEX:
case WITHER_SKELETON:
case ZOMBIE_VILLAGER:
case VINDICATOR:
// monster
count[3]++;
count[2]++;

View File

@ -1,6 +1,7 @@
package com.plotsquared.bukkit.util;
public class BukkitVersion {
public static int[] v1_11_0 = {1, 11, 0};
public static int[] v1_10_2 = {1, 10, 2};
public static int[] v1_10_0 = {1, 10, 0};
public static int[] v1_9_4 = {1, 9, 4};

View File

@ -1,6 +1,6 @@
#Wed Oct 26 22:42:12 EDT 2016
#Thu Nov 17 22:56:15 EST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-all.zip