mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bb43365538
@ -9,7 +9,9 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -17,6 +19,7 @@ import org.bukkit.block.BlockState;
|
|||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -202,17 +205,18 @@ public class PlotHelper {
|
|||||||
long r = ((nextLong() >>> 32) * n) >> 32;
|
long r = ((nextLong() >>> 32) * n) >> 32;
|
||||||
return (int) r;
|
return (int) r;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* End of random number gen section
|
||||||
|
*/
|
||||||
|
|
||||||
public static void removeSign(Player plr, Plot p) {
|
public static void removeSign(Player plr, Plot p) {
|
||||||
World world = plr.getWorld();
|
World world = plr.getWorld();
|
||||||
PlotManager manager = PlotMain.getPlotManager(world);
|
PlotManager manager = PlotMain.getPlotManager(world);
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
Location loc = manager.getSignLoc(plr, plotworld, p);
|
Location loc = manager.getSignLoc(plr, plotworld, p);
|
||||||
loc.getBlock().setType(Material.AIR);
|
Block bs = loc.getBlock();
|
||||||
|
bs.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* End of random number gen section
|
|
||||||
*/
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void setSign(Player plr, Plot p) {
|
public static void setSign(Player plr, Plot p) {
|
||||||
@ -673,7 +677,6 @@ public class PlotHelper {
|
|||||||
manager.clearPlot(requester, plot);
|
manager.clearPlot(requester, plot);
|
||||||
|
|
||||||
removeSign(requester, plot);
|
removeSign(requester, plot);
|
||||||
setSign(requester, plot);
|
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""
|
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""
|
||||||
+ ((System.nanoTime() - start) / 1000000.0)));
|
+ ((System.nanoTime() - start) / 1000000.0)));
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
import ca.mera.CameraAPI;
|
import ca.mera.CameraAPI;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.Logger.LogLevel;
|
import com.intellectualcrafters.plot.Logger.LogLevel;
|
||||||
import com.intellectualcrafters.plot.Settings.Web;
|
import com.intellectualcrafters.plot.Settings.Web;
|
||||||
import com.intellectualcrafters.plot.commands.Camera;
|
import com.intellectualcrafters.plot.commands.Camera;
|
||||||
@ -29,8 +30,10 @@ import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
|||||||
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
import me.confuser.barapi.BarAPI;
|
import me.confuser.barapi.BarAPI;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -426,6 +429,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
public void run() {
|
public void run() {
|
||||||
for (String world : getPlotWorldsString()) {
|
for (String world : getPlotWorldsString()) {
|
||||||
if (plots.containsKey(world)) {
|
if (plots.containsKey(world)) {
|
||||||
|
|
||||||
|
ArrayList<Plot> toDeletePlot = new ArrayList<Plot>();
|
||||||
|
|
||||||
for (Plot plot : plots.get(world).values()) {
|
for (Plot plot : plots.get(world).values()) {
|
||||||
if (plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -442,10 +448,13 @@ public class PlotMain extends JavaPlugin {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBFunc.delete(world, plot);
|
toDeletePlot.add(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (Plot plot: toDeletePlot) {
|
||||||
|
DBFunc.delete(world, plot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,11 +112,11 @@ public abstract class PlotWorld {
|
|||||||
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
||||||
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
||||||
this.DEFAULT_FLAGS = config.getStringList("flags.default");
|
this.DEFAULT_FLAGS = config.getStringList("flags.default");
|
||||||
this.PVP = config.getBoolean("events.pvp");
|
this.PVP = config.getBoolean("event.pvp");
|
||||||
this.PVE = config.getBoolean("events.pve");
|
this.PVE = config.getBoolean("event.pve");
|
||||||
this.SPAWN_EGGS = config.getBoolean("events.spawn.egg");
|
this.SPAWN_EGGS = config.getBoolean("event.spawn.egg");
|
||||||
this.SPAWN_CUSTOM = config.getBoolean("events.spawn.custom");
|
this.SPAWN_CUSTOM = config.getBoolean("event.spawn.custom");
|
||||||
this.SPAWN_BREEDING = config.getBoolean("events.spawn.breeding");
|
this.SPAWN_BREEDING = config.getBoolean("event.spawn.breeding");
|
||||||
loadConfiguration(config);
|
loadConfiguration(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,11 +143,11 @@ public abstract class PlotWorld {
|
|||||||
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
|
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
|
||||||
options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT);
|
options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT);
|
||||||
options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT);
|
options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT);
|
||||||
options.put("events.pvp", PlotWorld.PVP_DEFAULT);
|
options.put("event.pvp", PlotWorld.PVP_DEFAULT);
|
||||||
options.put("events.pve", PlotWorld.PVE_DEFAULT);
|
options.put("event.pve", PlotWorld.PVE_DEFAULT);
|
||||||
options.put("events.spawn.egg", PlotWorld.SPAWN_EGGS_DEFAULT);
|
options.put("event.spawn.egg", PlotWorld.SPAWN_EGGS_DEFAULT);
|
||||||
options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT);
|
options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT);
|
||||||
options.put("events.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT);
|
options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT);
|
||||||
ConfigurationNode[] settings = getSettingNodes();
|
ConfigurationNode[] settings = getSettingNodes();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -18,7 +18,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class Copy extends SubCommand {
|
public class Copy extends SubCommand {
|
||||||
|
|
||||||
public Copy() {
|
public Copy() {
|
||||||
super(Command.COPY, "Copy a plot", "clear", CommandCategory.ACTIONS, true);
|
super(Command.COPY, "Copy a plot", "copy", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +56,6 @@ public class Delete extends SubCommand {
|
|||||||
}
|
}
|
||||||
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
|
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
|
||||||
if (result) {
|
if (result) {
|
||||||
PlotHelper.removeSign(plr, plot);
|
|
||||||
plot.clear(plr);
|
plot.clear(plr);
|
||||||
DBFunc.delete(plr.getWorld().getName(), plot);
|
DBFunc.delete(plr.getWorld().getName(), plot);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class Kick extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, "&c/plot kick <player>");
|
PlayerFunctions.sendMessage(plr, "&c/plot kick <player>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Bukkit.getPlayer(args[0]) != null) {
|
if (Bukkit.getPlayer(args[0]) == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
|||||||
public class Purge extends SubCommand {
|
public class Purge extends SubCommand {
|
||||||
|
|
||||||
public Purge() {
|
public Purge() {
|
||||||
super("purge", "plots.admin", "Purge all plots for a world", "", "purge", CommandCategory.ACTIONS, false);
|
super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.ACTIONS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,7 +99,7 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!plr.hasPermission("plots.set.flag" + args[1].toLowerCase())) {
|
if (!plr.hasPermission("plots.set.flag." + args[1].toLowerCase())) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Setup() {
|
public Setup() {
|
||||||
super("setup", "plots.admin", "Setup a PlotWorld", "setup {world}", "setup", CommandCategory.ACTIONS, false);
|
super("setup", "plots.admin", "Setup a PlotWorld", "setup {world} {generator}", "setup", CommandCategory.ACTIONS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -252,23 +252,23 @@ public class DefaultPlotManager extends PlotManager {
|
|||||||
for (int i = startX; i < chunkX; i += 16) {
|
for (int i = startX; i < chunkX; i += 16) {
|
||||||
for (int j = startZ; j < chunkZ; j += 16) {
|
for (int j = startZ; j < chunkZ; j += 16) {
|
||||||
Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j));
|
Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j));
|
||||||
if ((plot1 != null) && (plot1.getId() != plot.getId()) && plot1.hasOwner()) {
|
if ((plot1 != null) && (plot1.getId() != plot.getId())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j));
|
Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j));
|
||||||
if ((plot2 != null) && (plot2.getId() != plot.getId()) && plot2.hasOwner()) {
|
if ((plot2 != null) && (plot2.getId() != plot.getId())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
||||||
if ((plot3 != null) && (plot3.getId() != plot.getId()) && plot3.hasOwner()) {
|
if ((plot3 != null) && (plot3.getId() != plot.getId())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15));
|
Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15));
|
||||||
if ((plot4 != null) && (plot4.getId() != plot.getId()) && plot4.hasOwner()) {
|
if ((plot4 != null) && (plot4.getId() != plot.getId())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
||||||
if ((plot5 != null) && (plot5.getId() != plot.getId()) && plot5.hasOwner()) {
|
if ((plot5 != null) && (plot5.getId() != plot.getId())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (min == null) {
|
if (min == null) {
|
||||||
|
@ -119,66 +119,81 @@ public class WorldGuardListener implements Listener {
|
|||||||
@EventHandler(
|
@EventHandler(
|
||||||
priority = EventPriority.MONITOR, ignoreCancelled = true)
|
priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onUnlink(PlotUnlinkEvent event) {
|
public void onUnlink(PlotUnlinkEvent event) {
|
||||||
World w = event.getWorld();
|
try {
|
||||||
ArrayList<PlotId> plots = event.getPlots();
|
World w = event.getWorld();
|
||||||
Plot main = PlotMain.getPlots(w).get(plots.get(0));
|
ArrayList<PlotId> plots = event.getPlots();
|
||||||
|
Plot main = PlotMain.getPlots(w).get(plots.get(0));
|
||||||
|
|
||||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(w);
|
RegionManager manager = PlotMain.worldGuard.getRegionManager(w);
|
||||||
ProtectedRegion region = manager.getRegion(main.id.x + "-" + main.id.y);
|
ProtectedRegion region = manager.getRegion(main.id.x + "-" + main.id.y);
|
||||||
|
|
||||||
DefaultDomain owner = region.getOwners();
|
DefaultDomain owner = region.getOwners();
|
||||||
Map<Flag<?>, Object> flags = region.getFlags();
|
Map<Flag<?>, Object> flags = region.getFlags();
|
||||||
DefaultDomain members = region.getMembers();
|
DefaultDomain members = region.getMembers();
|
||||||
|
|
||||||
manager.removeRegion(main.id.x + "-" + main.id.y);
|
manager.removeRegion(main.id.x + "-" + main.id.y);
|
||||||
for (int i = 1; i < plots.size(); i++) {
|
for (int i = 1; i < plots.size(); i++) {
|
||||||
PlotId id = plots.get(i);
|
PlotId id = plots.get(i);
|
||||||
Location location1 = PlotHelper.getPlotBottomLocAbs(w, id);
|
Location location1 = PlotHelper.getPlotBottomLocAbs(w, id);
|
||||||
Location location2 = PlotHelper.getPlotTopLocAbs(w, id);
|
Location location2 = PlotHelper.getPlotTopLocAbs(w, id);
|
||||||
|
|
||||||
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
||||||
BlockVector vector2 = new BlockVector(location2.getBlockX(), w.getMaxHeight(), location2.getBlockZ());
|
BlockVector vector2 = new BlockVector(location2.getBlockX(), w.getMaxHeight(), location2.getBlockZ());
|
||||||
ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, vector1, vector2);
|
ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, vector1, vector2);
|
||||||
|
|
||||||
rg.setFlags(flags);
|
rg.setFlags(flags);
|
||||||
|
|
||||||
rg.setOwners(owner);
|
rg.setOwners(owner);
|
||||||
|
|
||||||
rg.setMembers(members);
|
rg.setMembers(members);
|
||||||
|
|
||||||
manager.addRegion(rg);
|
manager.addRegion(rg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlotClaim(PlayerClaimPlotEvent event) {
|
public void onPlotClaim(PlayerClaimPlotEvent event) {
|
||||||
Player player = event.getPlayer();
|
try {
|
||||||
Plot plot = event.getPlot();
|
Player player = event.getPlayer();
|
||||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(plot.getWorld());
|
Plot plot = event.getPlot();
|
||||||
|
RegionManager manager = PlotMain.worldGuard.getRegionManager(plot.getWorld());
|
||||||
|
|
||||||
Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId());
|
Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId());
|
||||||
Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId());
|
Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId());
|
||||||
|
|
||||||
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
||||||
BlockVector vector2 =
|
BlockVector vector2 =
|
||||||
new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ());
|
new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ());
|
||||||
|
|
||||||
ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2);
|
ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2);
|
||||||
|
|
||||||
DefaultDomain owner = new DefaultDomain();
|
DefaultDomain owner = new DefaultDomain();
|
||||||
owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player));
|
owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player));
|
||||||
|
|
||||||
region.setOwners(owner);
|
region.setOwners(owner);
|
||||||
|
|
||||||
manager.addRegion(region);
|
manager.addRegion(region);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlotDelete(PlotDeleteEvent event) {
|
public void onPlotDelete(PlotDeleteEvent event) {
|
||||||
PlotId plot = event.getPlotId();
|
try {
|
||||||
World world = Bukkit.getWorld(event.getWorld());
|
PlotId plot = event.getPlotId();
|
||||||
|
World world = Bukkit.getWorld(event.getWorld());
|
||||||
|
|
||||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||||
manager.removeRegion(plot.x + "-" + plot.y);
|
manager.removeRegion(plot.x + "-" + plot.y);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: PlotSquared
|
name: PlotSquared
|
||||||
main: com.intellectualcrafters.plot.PlotMain
|
main: com.intellectualcrafters.plot.PlotMain
|
||||||
version: 2.0.5
|
version: 2.1
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
description: >
|
description: >
|
||||||
Easy, yet powerful Plot World generation and management.
|
Easy, yet powerful Plot World generation and management.
|
||||||
|
Loading…
Reference in New Issue
Block a user