This commit is contained in:
boy0001 2015-02-08 14:49:00 +11:00
parent bf49ff20d0
commit 239fcc9b2d
5 changed files with 66 additions and 19 deletions

View File

@ -45,6 +45,10 @@
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>confuser-repo</id>
<url>http://ci.frostcast.net/plugin/repository/everything</url>
@ -67,8 +71,8 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.7.9-R0.2</version>
</dependency>
<version>1.8-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>

View File

@ -88,6 +88,7 @@ import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
import com.intellectualcrafters.plot.listeners.InventoryListener;
import com.intellectualcrafters.plot.listeners.PlayerEvents;
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
import com.intellectualcrafters.plot.listeners.PlotListener;
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
import com.intellectualcrafters.plot.listeners.WorldEditListener;
@ -1480,9 +1481,12 @@ public class PlotMain extends JavaPlugin implements Listener {
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
plotCommand.setTabCompleter(command);
}
// Main event handler
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
if (checkVersion(1, 8, 0)) {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
}
// World load events
getServer().getPluginManager().registerEvents(this, this);
// Info Inventory
@ -1558,7 +1562,7 @@ public class PlotMain extends JavaPlugin implements Listener {
}
// Handle UUIDS
{
boolean checkVersion = checkVersion();
boolean checkVersion = checkVersion(1, 7, 5);
if (!checkVersion) {
sendConsoleSenderMessage(C.PREFIX.s()+" &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
Settings.TITLES = false;
@ -1592,7 +1596,7 @@ public class PlotMain extends JavaPlugin implements Listener {
}
}
public static boolean checkVersion() {
public static boolean checkVersion(int major, int minor, int minor2) {
try {
String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
int a = Integer.parseInt(version[0]);
@ -1601,18 +1605,10 @@ public class PlotMain extends JavaPlugin implements Listener {
if (version.length == 3) {
c = Integer.parseInt(version[2]);
}
if (a < 2) {
if (a < 1) {
return false;
}
if (b < 7) {
return false;
}
if (b == 7 && c < 5) {
return false;
}
if (a > major || (a == major && b > minor) || (a == major && b == minor && c >= minor2)) {
return true;
}
return true;
return false;
}
catch (Exception e) {
return false;

View File

@ -470,6 +470,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onInteract(final PlayerInteractEvent event) {
@ -536,7 +537,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
event.setCancelled(true);
} else if (!(reason == CreatureSpawnEvent.SpawnReason.BREEDING) && pW.SPAWN_BREEDING) {
event.setCancelled(true);
} else if (!(reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && pW.SPAWN_CUSTOM) {
} else if (!(reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && pW.SPAWN_CUSTOM && !(event.getEntityType().getTypeId() == 30)) {
event.setCancelled(true);
}
}
@ -884,7 +885,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
final Player p = (Player) d;
final boolean aPlr = a instanceof Player;
final PlotWorld pW = getPlotWorld(l.getWorld());
if (!aPlr && pW.PVE && (!(a instanceof ItemFrame) && !(a.getEntityId() == 416) ) ) {
if (!aPlr && pW.PVE && (!(a instanceof ItemFrame) && !(a.getType().getTypeId() == 30) ) ) {
return;
} else if (aPlr && pW.PVP) {
return;

View File

@ -0,0 +1,46 @@
package com.intellectualcrafters.plot.listeners;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
public class PlayerEvents_1_8 extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onInteract(final PlayerInteractAtEntityEvent e) {
final Location l = e.getRightClicked().getLocation();
if (isPlotWorld(l)) {
final Player p = e.getPlayer();
if (!isInPlot(l)) {
if (!PlotMain.hasPermission(p, "plots.admin.interact.road")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.road");
e.setCancelled(true);
}
} else {
final Plot plot = getCurrentPlot(l);
if (plot == null || !plot.hasOwner()) {
if (!PlotMain.hasPermission(p, "plots.admin.interact.unowned")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned");
e.setCancelled(true);
}
} else if (!plot.hasRights(p)) {
if (!PlotMain.hasPermission(p, "plots.admin.interact.other")) {
if (isPlotArea(l)) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.other");
e.setCancelled(true);
}
}
}
}
}
}
}

View File

@ -179,7 +179,7 @@ public class ExpireManager {
String worldname = Bukkit.getWorlds().get(0).getName();
String foldername;
String filename = null;
if (PlotMain.checkVersion()) {
if (PlotMain.checkVersion(1, 7, 5)) {
foldername = "playerdata";
try {
filename = op.getUniqueId() +".dat";