This commit is contained in:
Jesse Boyd 2017-08-10 16:46:51 +10:00
parent c36ef1d237
commit c3759f8963
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
6 changed files with 68 additions and 16 deletions

View File

@ -7,7 +7,7 @@ repositories {
dependencies {
compile project(':Core')
compile 'org.spigotmc:spigot-api:1.11.2-R0.1-SNAPSHOT'
compile 'org.spigotmc:spigot-api:1.12.1-R0.1-SNAPSHOT'
compile("net.milkbowl.vault:VaultAPI:1.6") {
exclude module: 'bukkit'
}

View File

@ -49,6 +49,8 @@ import com.plotsquared.bukkit.listeners.PlayerEvents183;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_9;
import com.plotsquared.bukkit.listeners.PlotPlusListener;
import com.plotsquared.bukkit.listeners.PlotPlusListener_1_12;
import com.plotsquared.bukkit.listeners.PlotPlusListener_Legacy;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.titles.DefaultTitle_111;
import com.plotsquared.bukkit.util.BukkitChatManager;
@ -532,6 +534,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
public void registerPlotPlusEvents() {
PlotPlusListener.startRunnable(this);
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_12_0)) {
getServer().getPluginManager().registerEvents(new PlotPlusListener_1_12(), this);
} else {
getServer().getPluginManager().registerEvents(new PlotPlusListener_Legacy(), this);
}
}
@Override

View File

@ -24,7 +24,6 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -114,20 +113,6 @@ public class PlotPlusListener extends PlotListener implements Listener {
}
}
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
if (plot == null) {
return;
}
UUID uuid = pp.getUUID();
if (plot.isAdded(uuid) && Flags.DROP_PROTECTION.isTrue(plot)) {
event.setCancelled(true);
}
}
@EventHandler
public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();

View File

@ -0,0 +1,31 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import java.util.UUID;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent;
public class PlotPlusListener_1_12 implements Listener {
@EventHandler
public void onItemPickup(EntityPickupItemEvent event) {
LivingEntity ent = event.getEntity();
if (ent instanceof Player) {
Player player = (Player) ent;
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
if (plot == null) {
return;
}
UUID uuid = pp.getUUID();
if (plot.isAdded(uuid) && Flags.DROP_PROTECTION.isTrue(plot)) {
event.setCancelled(true);
}
}
}
}

View File

@ -0,0 +1,27 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupItemEvent;
public class PlotPlusListener_Legacy implements Listener {
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
if (plot == null) {
return;
}
UUID uuid = pp.getUUID();
if (plot.isAdded(uuid) && Flags.DROP_PROTECTION.isTrue(plot)) {
event.setCancelled(true);
}
}
}

View File

@ -1,6 +1,8 @@
package com.plotsquared.bukkit.util;
public class BukkitVersion {
public static int[] v1_12_1 = {1, 12, 1};
public static int[] v1_12_0 = {1, 12, 0};
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};