mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Trying to reduce reliance on Bukkit
This commit is contained in:
parent
2b229f49d1
commit
904b75a7cd
5
pom.xml
5
pom.xml
@ -49,7 +49,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<finalName>PlotSquared-Bukkit</finalName>
|
<finalName>PlotSquared-Bukkit</finalName>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/com/plotsquared/sponge/*</exclude>
|
<exclude>**/com/plotsquared/sponge/**</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
@ -62,7 +62,8 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<finalName>PlotSquared-Sponge</finalName>
|
<finalName>PlotSquared-Sponge</finalName>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/com/plotsquared/bukkit/*</exclude>
|
<exclude>**/com/plotsquared/bukkit/**</exclude>
|
||||||
|
<exclude>**/com/intellectualcrafters/plot/api/*</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -12,65 +12,189 @@ import java.io.File;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface IPlotMain {
|
public interface IPlotMain {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message to console
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
void log(String message);
|
void log(String message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the `PlotSquared` directory (e.g. /plugins/PlotSquared or /mods/PlotSquared)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
File getDirectory();
|
File getDirectory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable the implementation
|
||||||
|
* - If a full disable isn't feasibly, just disable what it can
|
||||||
|
*/
|
||||||
void disable();
|
void disable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of the PlotSquared being used
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
int[] getPluginVersion();
|
int[] getPluginVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of Minecraft that is running
|
||||||
|
* (used to check what protocols and such are supported)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
int[] getServerVersion();
|
int[] getServerVersion();
|
||||||
|
|
||||||
void handleKick(UUID uuid, C c);
|
/**
|
||||||
|
* The task manager will run and manage minecraft tasks
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
TaskManager getTaskManager();
|
TaskManager getTaskManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the task that will kill road mobs
|
||||||
|
*/
|
||||||
void runEntityTask();
|
void runEntityTask();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the implementation specific commands
|
||||||
|
*/
|
||||||
void registerCommands();
|
void registerCommands();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the protection system (used to protect blocks and such)
|
||||||
|
*/
|
||||||
void registerPlayerEvents();
|
void registerPlayerEvents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register inventory related events (used for inventory guis)
|
||||||
|
*/
|
||||||
void registerInventoryEvents();
|
void registerInventoryEvents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register plot plus related events (whatever these are?)
|
||||||
|
*/
|
||||||
void registerPlotPlusEvents();
|
void registerPlotPlusEvents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register force field events (why is this a thing?)
|
||||||
|
*/
|
||||||
void registerForceFieldEvents();
|
void registerForceFieldEvents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the WorldEdit hook
|
||||||
|
*/
|
||||||
void registerWorldEditEvents();
|
void registerWorldEditEvents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register TNT related events (if TNT protection is enabled)
|
||||||
|
*/
|
||||||
void registerTNTListener();
|
void registerTNTListener();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the economy provider
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
EconHandler getEconomyHandler();
|
EconHandler getEconomyHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block manager
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
BlockManager initBlockManager();
|
BlockManager initBlockManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the EventUtil class
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
EventUtil initEventUtil();
|
EventUtil initEventUtil();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the chunk manager
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
ChunkManager initChunkManager();
|
ChunkManager initChunkManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the setuputils class (used for world creation)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
SetupUtils initSetupUtils();
|
SetupUtils initSetupUtils();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get HybridUtils class (common functions useful for hybrid world generation)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
HybridUtils initHybridUtils();
|
HybridUtils initHybridUtils();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the metrics task
|
||||||
|
*/
|
||||||
|
void startMetrics();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a world is already loaded, set the generator (use NMS if required)
|
||||||
|
* @param world
|
||||||
|
*/
|
||||||
|
void setGenerator(String world);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the UUIDHandlerImplementation which will cache and provide UUIDs
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
UUIDHandlerImplementation initUUIDHandler();
|
UUIDHandlerImplementation initUUIDHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the InventoryUtil class (used for implementation specific inventory guis)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
InventoryUtil initInventoryUtil();
|
InventoryUtil initInventoryUtil();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the converter for the implementation (not necessarily PlotMe, just any plugin that we can convert from)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
boolean initPlotMeConverter();
|
boolean initPlotMeConverter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister a PlotPlayer from cache e.g. if they have logged off
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
void unregister(PlotPlayer player);
|
void unregister(PlotPlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the generator wrapper for a world (world) and generator (name)
|
||||||
|
* @param world
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
PlotGenerator<?> getGenerator(String world, String name);
|
PlotGenerator<?> getGenerator(String world, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PlotListener class for this implementation
|
||||||
|
* (We should try to make this generic so we don't need this)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
APlotListener initPlotListener();
|
APlotListener initPlotListener();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the chunk processor which will clean out chunks that have too many blockstates or entities
|
||||||
|
*/
|
||||||
void registerChunkProcessor();
|
void registerChunkProcessor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the world initialization events (used to keep track of worlds being generated)
|
||||||
|
*/
|
||||||
void registerWorldEvents();
|
void registerWorldEvents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is currently really empty, but player related stuff can go in here
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
PlayerManager initPlayerManager();
|
PlayerManager initPlayerManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the server
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
String getServerName();
|
String getServerName();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Configuration;
|
import com.intellectualcrafters.plot.config.Configuration;
|
||||||
@ -114,6 +115,12 @@ public class PS {
|
|||||||
IMP.registerForceFieldEvents();
|
IMP.registerForceFieldEvents();
|
||||||
IMP.registerWorldEditEvents();
|
IMP.registerWorldEditEvents();
|
||||||
IMP.registerWorldEvents();
|
IMP.registerWorldEvents();
|
||||||
|
if (Settings.METRICS) {
|
||||||
|
IMP.startMetrics();
|
||||||
|
} else {
|
||||||
|
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
||||||
|
}
|
||||||
|
IMP.startMetrics();
|
||||||
if (Settings.TNT_LISTENER) {
|
if (Settings.TNT_LISTENER) {
|
||||||
IMP.registerTNTListener();
|
IMP.registerTNTListener();
|
||||||
}
|
}
|
||||||
@ -122,6 +129,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
// create UUIDWrapper
|
// create UUIDWrapper
|
||||||
UUIDHandler.implementation = IMP.initUUIDHandler();
|
UUIDHandler.implementation = IMP.initUUIDHandler();
|
||||||
|
UUIDHandler.implementation.startCaching(null); // TODO maybe a notification when this is done?
|
||||||
// create event util class
|
// create event util class
|
||||||
EventUtil.manager = IMP.initEventUtil();
|
EventUtil.manager = IMP.initEventUtil();
|
||||||
// create Hybrid utility class
|
// create Hybrid utility class
|
||||||
@ -171,9 +179,21 @@ public class PS {
|
|||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto clearing
|
||||||
if (Settings.AUTO_CLEAR) {
|
if (Settings.AUTO_CLEAR) {
|
||||||
ExpireManager.runTask();
|
ExpireManager.runTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// World generators:
|
||||||
|
ConfigurationSection section = config.getConfigurationSection("worlds");
|
||||||
|
if (section != null) {
|
||||||
|
for (String world : section.getKeys(false)) {
|
||||||
|
if (BlockManager.manager.isWorld(world)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Copy files
|
// Copy files
|
||||||
copyFile("town.template", "templates");
|
copyFile("town.template", "templates");
|
||||||
|
@ -89,7 +89,7 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
}
|
}
|
||||||
final Location loc = manager.getSignLoc(plotworld, plot);
|
final Location loc = manager.getSignLoc(plotworld, plot);
|
||||||
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||||
final boolean result = ChunkManager.manager.loadChunk(world, chunk);
|
final boolean result = ChunkManager.manager.loadChunk(world, chunk, false);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,12 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
@ -153,7 +154,7 @@ public class DebugExec extends SubCommand {
|
|||||||
ChunkLoc chunk = BukkitHybridUtils.chunks.get(0);
|
ChunkLoc chunk = BukkitHybridUtils.chunks.get(0);
|
||||||
BukkitHybridUtils.chunks.remove(0);
|
BukkitHybridUtils.chunks.remove(0);
|
||||||
HybridUtils.manager.regenerateRoad(BukkitHybridUtils.world, chunk, 0);
|
HybridUtils.manager.regenerateRoad(BukkitHybridUtils.world, chunk, 0);
|
||||||
ChunkManager.manager.unloadChunk(BukkitHybridUtils.world, chunk);
|
ChunkManager.manager.unloadChunk(BukkitHybridUtils.world, chunk, true, true);
|
||||||
}
|
}
|
||||||
PS.log("&cCancelled!");
|
PS.log("&cCancelled!");
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,11 +28,15 @@ import com.intellectualcrafters.plot.flag.FlagManager;
|
|||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotItemStack;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.plotsquared.bukkit.object.InfoInventory;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -129,7 +133,22 @@ public class Info extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) {
|
if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) {
|
||||||
new InfoInventory(plot, player).build().display();
|
PlotInventory inv = new PlotInventory(player) {
|
||||||
|
@Override
|
||||||
|
public boolean onClick(int index) {
|
||||||
|
// TODO InfoInventory not implemented yet!!!!!!!!
|
||||||
|
// See plot rating or musicsubcommand on examples
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
UUID uuid = player.getUUID();
|
||||||
|
String name = MainUtil.getName(plot.owner);
|
||||||
|
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] { "&cID: &6" + plot.getId().toString(), "&cOwner: &6" + name, "&cAlias: &6" + plot.getSettings().getAlias(), "&cBiome: &6" + plot.getSettings().getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + plot.isAdded(uuid), "&cIs Denied: &6" + plot.isDenied(uuid)}));
|
||||||
|
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", new String[] {"&cAmount: &6" + plot.getTrusted().size(), "&8Click to view a list of the trusted users"}));
|
||||||
|
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers", new String[] {"&cAmount: &6" + plot.getMembers().size(), "&8Click to view a list of plot members"}));
|
||||||
|
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", new String[] {"&cDenied", "&cAmount: &6" + plot.getDenied().size(), "&8Click to view a list of denied players"}));
|
||||||
|
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", new String[] {"&cFlags", "&cAmount: &6" + plot.getSettings().flags.size(), "&8Click to view a list of plot flags"}));
|
||||||
|
inv.openInventory();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final boolean hasOwner = plot.hasOwner();
|
final boolean hasOwner = plot.hasOwner();
|
||||||
@ -194,7 +213,7 @@ public class Info extends SubCommand {
|
|||||||
final String alias = plot.getSettings().getAlias().length() > 0 ? plot.getSettings().getAlias() : C.NONE.s();
|
final String alias = plot.getSettings().getAlias().length() > 0 ? plot.getSettings().getAlias() : C.NONE.s();
|
||||||
Location top = MainUtil.getPlotTopLoc(world, plot.id);
|
Location top = MainUtil.getPlotTopLoc(world, plot.id);
|
||||||
Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||||
final String biome = BlockManager.manager.getBiome(bot.add((top.getX() - bot.getX()) / 2, 0, (top.getX() - bot.getX()) / 2));
|
final String biome = BlockManager.manager.getBiome(plot.world, bot.getX() + ((top.getX() - bot.getX()) / 2), bot.getZ() + ((top.getZ() - bot.getZ()) / 2));
|
||||||
final String trusted = getPlayerList(plot.getTrusted());
|
final String trusted = getPlayerList(plot.getTrusted());
|
||||||
final String members = getPlayerList(plot.getMembers());
|
final String members = getPlayerList(plot.getMembers());
|
||||||
final String denied = getPlayerList(plot.getDenied());
|
final String denied = getPlayerList(plot.getDenied());
|
||||||
|
@ -23,10 +23,10 @@ package com.intellectualcrafters.plot.generator;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.commands.Template;
|
import com.intellectualcrafters.plot.commands.Template;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -181,14 +181,14 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
public void run() {
|
public void run() {
|
||||||
// If the chunk isn't near the edge and it isn't an augmented world we can just regen the whole chunk
|
// If the chunk isn't near the edge and it isn't an augmented world we can just regen the whole chunk
|
||||||
if (canRegen && value[6] == 0) {
|
if (canRegen && value[6] == 0) {
|
||||||
BukkitUtil.regenerateChunk(world, value[0], value[1]);
|
ChunkManager.manager.regenerateChunk(world, new ChunkLoc(value[0], value[1]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Otherwise we need to set each component, as we don't want to regenerate the road or other plots that share the same chunk //
|
// Otherwise we need to set each component, as we don't want to regenerate the road or other plots that share the same chunk //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set the biome
|
// Set the biome
|
||||||
BukkitUtil.setBiome(plot.world, value[2], value[3], value[4], value[5], dpw.PLOT_BIOME);
|
MainUtil.setBiome(world, value[2], value[3], value[4], value[5], dpw.PLOT_BIOME);
|
||||||
// These two locations are for each component (e.g. bedrock, main block, floor, air)
|
// These two locations are for each component (e.g. bedrock, main block, floor, air)
|
||||||
Location bot = new Location(world, value[2], 0, value[3]);
|
Location bot = new Location(world, value[2], 0, value[3]);
|
||||||
Location top = new Location(world, value[4] + 1, 1, value[5] + 1);
|
Location top = new Location(world, value[4] + 1, 1, value[5] + 1);
|
||||||
|
@ -7,7 +7,7 @@ import com.intellectualcrafters.plot.object.PseudoRandom;
|
|||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.plotsquared.bukkit.object.PlotPopulator;
|
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ import java.util.HashSet;
|
|||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class HybridPop extends PlotPopulator {
|
public class HybridPop extends BukkitPlotPopulator {
|
||||||
/*
|
/*
|
||||||
* Sorry, this isn't well documented at the moment.
|
* Sorry, this isn't well documented at the moment.
|
||||||
* We advise you to take a look at a world generation tutorial for
|
* We advise you to take a look at a world generation tutorial for
|
||||||
|
@ -89,7 +89,7 @@ public abstract class HybridUtils {
|
|||||||
final PlotId id1 = manager.getPlotId(plotworld, x, 0, z);
|
final PlotId id1 = manager.getPlotId(plotworld, x, 0, z);
|
||||||
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
||||||
if ((id1 == null) || (id2 == null) || (id1 != id2)) {
|
if ((id1 == null) || (id2 == null) || (id1 != id2)) {
|
||||||
final boolean result = ChunkManager.manager.loadChunk(world, chunk);
|
final boolean result = ChunkManager.manager.loadChunk(world, chunk, false);
|
||||||
if (result) {
|
if (result) {
|
||||||
if (id1 != null) {
|
if (id1 != null) {
|
||||||
final Plot p1 = MainUtil.getPlot(world, id1);
|
final Plot p1 = MainUtil.getPlot(world, id1);
|
||||||
|
@ -186,25 +186,12 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
* Set a plot biome
|
* Set a plot biome
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final Plot plot, final int biome) {
|
public boolean setBiome(final Plot plot, final String biome) {
|
||||||
final int bottomX = MainUtil.getPlotBottomLoc(plot.world, plot.id).getX() - 1;
|
final int bottomX = MainUtil.getPlotBottomLoc(plot.world, plot.id).getX() - 1;
|
||||||
final int topX = MainUtil.getPlotTopLoc(plot.world, plot.id).getX() + 1;
|
final int topX = MainUtil.getPlotTopLoc(plot.world, plot.id).getX();
|
||||||
final int bottomZ = MainUtil.getPlotBottomLoc(plot.world, plot.id).getZ() - 1;
|
final int bottomZ = MainUtil.getPlotBottomLoc(plot.world, plot.id).getZ() - 1;
|
||||||
final int topZ = MainUtil.getPlotTopLoc(plot.world, plot.id).getZ() + 1;
|
final int topZ = MainUtil.getPlotTopLoc(plot.world, plot.id).getZ();
|
||||||
final int size = ((topX - bottomX) + 1) * ((topZ - bottomZ) + 1);
|
MainUtil.setBiome(plot.world, bottomX, bottomZ, topX, topZ, biome);
|
||||||
final int[] xb = new int[size];
|
|
||||||
final int[] zb = new int[size];
|
|
||||||
final int[] biomes = new int[size];
|
|
||||||
int index = 0;
|
|
||||||
for (int x = bottomX; x <= topX; x++) {
|
|
||||||
for (int z = bottomZ; z <= topZ; z++) {
|
|
||||||
xb[index] = x;
|
|
||||||
zb[index] = z;
|
|
||||||
biomes[index] = biome;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BlockManager.setBiomes(plot.world, xb, zb, biomes);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.plotsquared.bukkit.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -69,32 +69,4 @@ public class BlockWrapper {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Alternative Constructor Uses block data, rather than typed data
|
|
||||||
*
|
|
||||||
* @param block Block from which we get the data
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "deprecation", "unused" })
|
|
||||||
public BlockWrapper(final Block block) {
|
|
||||||
this.x = block.getX();
|
|
||||||
this.y = block.getY();
|
|
||||||
this.z = block.getZ();
|
|
||||||
this.id = block.getTypeId();
|
|
||||||
this.data = block.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a block based on the block wrapper
|
|
||||||
*
|
|
||||||
* @param world World in which the block is/will be, located
|
|
||||||
*
|
|
||||||
* @return block created/fetched from settings
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "unused", "deprecation" })
|
|
||||||
public Block toBlock(final World world) {
|
|
||||||
final Block block = world.getBlockAt(this.x, this.y, this.z);
|
|
||||||
block.setTypeIdAndData(this.id, this.data, true);
|
|
||||||
return block;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,10 +4,10 @@ import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.MathMan;
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
@ -7,7 +7,7 @@ public class PlotItemStack {
|
|||||||
public final String name;
|
public final String name;
|
||||||
public final String[] lore;
|
public final String[] lore;
|
||||||
|
|
||||||
public PlotItemStack(int id, short data, int amount, String name, String[] lore) {
|
public PlotItemStack(int id, short data, int amount, String name, String... lore) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
|
@ -61,7 +61,7 @@ public abstract class PlotManager {
|
|||||||
|
|
||||||
public abstract boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks);
|
public abstract boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks);
|
||||||
|
|
||||||
public abstract boolean setBiome(final Plot plot, final int biome);
|
public abstract boolean setBiome(final Plot plot, final String biome);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PLOT MERGING (return false if your generator does not support plot
|
* PLOT MERGING (return false if your generator does not support plot
|
||||||
|
@ -116,7 +116,7 @@ public class PlotSettings {
|
|||||||
*/
|
*/
|
||||||
public String getBiome() {
|
public String getBiome() {
|
||||||
final Location loc = MainUtil.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1);
|
final Location loc = MainUtil.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1);
|
||||||
return BlockManager.manager.getBiome(loc);
|
return BlockManager.manager.getBiome(loc.getWorld(), loc.getX(), loc.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockLoc getPosition() {
|
public BlockLoc getPosition() {
|
||||||
|
@ -21,9 +21,11 @@ public abstract class BlockManager {
|
|||||||
|
|
||||||
public abstract int getBlockIdFromString(String block);
|
public abstract int getBlockIdFromString(String block);
|
||||||
|
|
||||||
public abstract int getHeighestBlock(Location loc);
|
public abstract int getHeighestBlock(String world, int x, int z);
|
||||||
|
|
||||||
public abstract String getBiome(Location loc);
|
public abstract String getBiome(String world, int x, int z);
|
||||||
|
|
||||||
|
public abstract PlotBlock getBlock(Location loc);
|
||||||
|
|
||||||
public abstract Location getSpawn(String world);
|
public abstract Location getSpawn(String world);
|
||||||
|
|
||||||
@ -37,9 +39,9 @@ public abstract class BlockManager {
|
|||||||
|
|
||||||
public abstract void functionSetBlock(String worldname, int x, int y, int z, int id, byte data);
|
public abstract void functionSetBlock(String worldname, int x, int y, int z, int id, byte data);
|
||||||
|
|
||||||
public abstract void functionSetBiomes(final String worldname, final int[] x, final int z[], final int[] biome);
|
public abstract void functionSetBiomes(final String worldname, final int[] x, final int z[], final String biome);
|
||||||
|
|
||||||
public static void setBiomes(final String worldname, final int[] x, final int z[], final int[] biome) {
|
public static void setBiomes(final String worldname, final int[] x, final int z[], final String biome) {
|
||||||
manager.functionSetBiomes(worldname, x, z, biome);
|
manager.functionSetBiomes(worldname, x, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,9 +92,9 @@ public abstract class ChunkManager {
|
|||||||
|
|
||||||
public abstract int[] countEntities(Plot plot);
|
public abstract int[] countEntities(Plot plot);
|
||||||
|
|
||||||
public abstract boolean loadChunk(String world, ChunkLoc loc);
|
public abstract boolean loadChunk(String world, ChunkLoc loc, boolean force);
|
||||||
|
|
||||||
public abstract boolean unloadChunk(String world, ChunkLoc loc);
|
public abstract boolean unloadChunk(String world, ChunkLoc loc, boolean save, boolean safe);
|
||||||
|
|
||||||
public abstract List<ChunkLoc> getChunkChunks(String world);
|
public abstract List<ChunkLoc> getChunkChunks(String world);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class ClusterManager {
|
|||||||
} else {
|
} else {
|
||||||
toReturn = getClusterBottom(cluster).add(home.x, home.y, home.z);
|
toReturn = getClusterBottom(cluster).add(home.x, home.y, home.z);
|
||||||
}
|
}
|
||||||
final int max = BukkitUtil.getHeighestBlock(cluster.world, toReturn.getX(), toReturn.getZ());
|
final int max = MainUtil.getHeighestBlock(cluster.world, toReturn.getX(), toReturn.getZ());
|
||||||
if (max > toReturn.getY()) {
|
if (max > toReturn.getY()) {
|
||||||
toReturn.setY(max);
|
toReturn.setY(max);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,17 @@ public class MainUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getName(UUID owner) {
|
||||||
|
if (owner == null) {
|
||||||
|
return "unowned";
|
||||||
|
}
|
||||||
|
String name = UUIDHandler.getName(owner);
|
||||||
|
if (name == null) {
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<PlotPlayer> getPlayersInPlot(Plot plot) {
|
public static List<PlotPlayer> getPlayersInPlot(Plot plot) {
|
||||||
ArrayList<PlotPlayer> players = new ArrayList<>();
|
ArrayList<PlotPlayer> players = new ArrayList<>();
|
||||||
for (PlotPlayer pp : UUIDHandler.getPlayers().values()) {
|
for (PlotPlayer pp : UUIDHandler.getPlayers().values()) {
|
||||||
@ -1032,9 +1043,10 @@ public class MainUtil {
|
|||||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
BukkitUtil.loadChunkAt(plot.world, value[0], value[1], false);
|
ChunkLoc loc = new ChunkLoc(value[0], value[1]);
|
||||||
BukkitUtil.setBiome(plot.world, value[2], value[3], value[4], value[4], biome);
|
ChunkManager.manager.loadChunk(plot.world, loc, false);
|
||||||
BukkitUtil.unloadChunkAt(plot.world, value[0], value[1], true, true);
|
setBiome(plot.world, value[2], value[3], value[4], value[4], biome);
|
||||||
|
ChunkManager.manager.unloadChunk(plot.world, loc, true, true);
|
||||||
}
|
}
|
||||||
}, new Runnable() {
|
}, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -1045,8 +1057,23 @@ public class MainUtil {
|
|||||||
}, 5);
|
}, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setBiome(final String world, int p1x, int p1z, int p2x, int p2z, final String biome) {
|
||||||
|
final int length = (p2x - p1x + 1) * (p2z - p1z + 1);
|
||||||
|
final int[] xl = new int[length];
|
||||||
|
final int[] zl = new int[length];
|
||||||
|
int index = 0;
|
||||||
|
for (int x = p1x; x <= p2x; x++) {
|
||||||
|
for (int z = p1z; z <= p2z; z++) {
|
||||||
|
xl[index] = x;
|
||||||
|
zl[index] = z;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BlockManager.setBiomes(world, xl, zl, biome);
|
||||||
|
}
|
||||||
|
|
||||||
public static int getHeighestBlock(final String world, final int x, final int z) {
|
public static int getHeighestBlock(final String world, final int x, final int z) {
|
||||||
final int result = BukkitUtil.getHeighestBlock(world, x, z);
|
final int result = BlockManager.manager.getHeighestBlock(world, x, z);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
@ -1070,7 +1097,7 @@ public class MainUtil {
|
|||||||
return getDefaultHome(plot);
|
return getDefaultHome(plot);
|
||||||
} else {
|
} else {
|
||||||
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z);
|
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z);
|
||||||
if (BukkitUtil.getBlock(loc).id != 0) {
|
if (BlockManager.manager.getBlock(loc).id != 0) {
|
||||||
// sendConsoleMessage("ID was " + BukkitUtil.getBlock(loc).id);
|
// sendConsoleMessage("ID was " + BukkitUtil.getBlock(loc).id);
|
||||||
loc.setY(Math.max(getHeighestBlock(w, bot.getX(), bot.getZ()), bot.getY()));
|
loc.setY(Math.max(getHeighestBlock(w, bot.getX(), bot.getZ()), bot.getY()));
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public abstract class SchematicHandler {
|
|||||||
y_offset = 0;
|
y_offset = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
y_offset = BukkitUtil.getHeighestBlock(plot.world, bottom.getX() + 1, bottom.getZ() + 1);
|
y_offset = MainUtil.getHeighestBlock(plot.world, bottom.getX() + 1, bottom.getZ() + 1);
|
||||||
}
|
}
|
||||||
Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1 + x_offset, y_offset - 1, 1 + z_offset);
|
Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1 + x_offset, y_offset - 1, 1 + z_offset);
|
||||||
Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
||||||
@ -346,10 +346,10 @@ public abstract class SchematicHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId());
|
Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId());
|
||||||
final int sy = BukkitUtil.getHeighestBlock(plot.world, l1.getX() + 1, l1.getZ() + 1);
|
final int sy = MainUtil.getHeighestBlock(plot.world, l1.getX() + 1, l1.getZ() + 1);
|
||||||
final Dimension demensions = schematic.getSchematicDimension();
|
final Dimension demensions = schematic.getSchematicDimension();
|
||||||
final int HEIGHT = demensions.getY();
|
final int HEIGHT = demensions.getY();
|
||||||
if (!(HEIGHT == BukkitUtil.getMaxHeight(plot.world))) {
|
if ((HEIGHT < 255)) {
|
||||||
l1 = l1.add(1, sy - 1, 1);
|
l1 = l1.add(1, sy - 1, 1);
|
||||||
} else {
|
} else {
|
||||||
l1 = l1.add(1, 0, 1);
|
l1 = l1.add(1, 0, 1);
|
||||||
|
@ -1,5 +1,19 @@
|
|||||||
package com.plotsquared.bukkit;
|
package com.plotsquared.bukkit;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.IPlotMain;
|
import com.intellectualcrafters.plot.IPlotMain;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
@ -7,14 +21,20 @@ import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
|
||||||
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
import com.intellectualcrafters.plot.util.ConsoleColors;
|
||||||
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.InventoryUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.PlayerManager;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
import com.plotsquared.bukkit.commands.BukkitCommand;
|
import com.plotsquared.bukkit.commands.BukkitCommand;
|
||||||
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
|
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
|
||||||
@ -22,33 +42,44 @@ import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
|||||||
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
||||||
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
import com.plotsquared.bukkit.generator.HybridGen;
|
||||||
import com.plotsquared.bukkit.listeners.*;
|
import com.plotsquared.bukkit.listeners.APlotListener;
|
||||||
|
import com.plotsquared.bukkit.listeners.ChunkListener;
|
||||||
|
import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
||||||
|
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
||||||
|
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
||||||
|
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
|
||||||
|
import com.plotsquared.bukkit.listeners.PlotListener;
|
||||||
|
import com.plotsquared.bukkit.listeners.PlotPlusListener;
|
||||||
|
import com.plotsquared.bukkit.listeners.TNTListener;
|
||||||
|
import com.plotsquared.bukkit.listeners.WorldEvents;
|
||||||
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
|
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
|
||||||
import com.plotsquared.bukkit.listeners.worldedit.WESubscriber;
|
import com.plotsquared.bukkit.listeners.worldedit.WESubscriber;
|
||||||
import com.plotsquared.bukkit.titles.AbstractTitle;
|
import com.plotsquared.bukkit.titles.AbstractTitle;
|
||||||
import com.plotsquared.bukkit.titles.DefaultTitle;
|
import com.plotsquared.bukkit.titles.DefaultTitle;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
import com.plotsquared.bukkit.util.SetupUtils;
|
||||||
import com.plotsquared.bukkit.util.bukkit.*;
|
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.BukkitEconHandler;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.BukkitEventUtil;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.BukkitInventoryUtil;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.BukkitPlayerManager;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.BukkitSetupUtils;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.BukkitTaskManager;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.Metrics;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.SendChunk;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.SetBlockFast;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.SetBlockFast_1_8;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.SetBlockSlow;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.SetGenCB;
|
||||||
import com.plotsquared.bukkit.util.bukkit.uuid.FileUUIDHandler;
|
import com.plotsquared.bukkit.util.bukkit.uuid.FileUUIDHandler;
|
||||||
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||||
|
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
||||||
|
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
||||||
|
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||||
|
|
||||||
@ -79,29 +110,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
THIS = this;
|
THIS = this;
|
||||||
PS.instance = new PS(this);
|
PS.instance = new PS(this);
|
||||||
if (Settings.METRICS) {
|
|
||||||
try {
|
|
||||||
final Metrics metrics = new Metrics(this);
|
|
||||||
metrics.start();
|
|
||||||
log(C.PREFIX.s() + "&6Metrics enabled.");
|
|
||||||
} catch (final Exception e) {
|
|
||||||
log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
|
||||||
}
|
|
||||||
List<World> worlds = Bukkit.getWorlds();
|
|
||||||
if (worlds.size() > 0) {
|
|
||||||
UUIDHandler.startCaching(null);
|
|
||||||
for (World world : worlds) {
|
|
||||||
try {
|
|
||||||
SetGenCB.setGenerator(world);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log("Failed to reload world: " + world.getName());
|
|
||||||
Bukkit.getServer().unloadWorld(world, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,15 +150,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]) };
|
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]) };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleKick(UUID uuid, C c) {
|
|
||||||
Player player = Bukkit.getPlayer(uuid);
|
|
||||||
if (player != null && player.isOnline()) {
|
|
||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), c);
|
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
final BukkitCommand bcmd = new BukkitCommand();
|
final BukkitCommand bcmd = new BukkitCommand();
|
||||||
@ -323,7 +322,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerInventoryEvents() {
|
public void registerInventoryEvents() {
|
||||||
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
|
|
||||||
|
// Part of PlayerEvents - can be moved if necessary
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -522,4 +523,25 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
public String getServerName() {
|
public String getServerName() {
|
||||||
return Bukkit.getServerName();
|
return Bukkit.getServerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startMetrics() {
|
||||||
|
try {
|
||||||
|
final Metrics metrics = new Metrics(this);
|
||||||
|
metrics.start();
|
||||||
|
log(C.PREFIX.s() + "&6Metrics enabled.");
|
||||||
|
} catch (final Exception e) {
|
||||||
|
log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGenerator(String world) {
|
||||||
|
try {
|
||||||
|
SetGenCB.setGenerator(BukkitUtil.getWorld(world));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log("Failed to reload world: " + world);
|
||||||
|
Bukkit.getServer().unloadWorld(world, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.bukkit.object.BlockWrapper;
|
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager;
|
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager;
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager;
|
import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
@ -24,7 +24,7 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.plotsquared.bukkit.listeners.WorldEvents;
|
import com.plotsquared.bukkit.listeners.WorldEvents;
|
||||||
import com.plotsquared.bukkit.object.PlotPopulator;
|
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
@ -226,7 +226,7 @@ public abstract class BukkitPlotGenerator extends ChunkGenerator {
|
|||||||
*/
|
*/
|
||||||
public abstract void generateChunk(final World world, RegionWrapper requiredRegion, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes);
|
public abstract void generateChunk(final World world, RegionWrapper requiredRegion, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes);
|
||||||
|
|
||||||
public abstract List<PlotPopulator> getPopulators(String world);
|
public abstract List<BukkitPlotPopulator> getPopulators(String world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called when the generator is initialized.
|
* This is called when the generator is initialized.
|
||||||
|
@ -24,7 +24,7 @@ import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
|||||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.generator.HybridPop;
|
import com.intellectualcrafters.plot.generator.HybridPop;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.plotsquared.bukkit.object.PlotPopulator;
|
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -169,10 +169,10 @@ public class HybridGen extends BukkitPlotGenerator {
|
|||||||
/**
|
/**
|
||||||
* Return the block populator
|
* Return the block populator
|
||||||
*/
|
*/
|
||||||
public List<PlotPopulator> getPopulators(final String world) {
|
public List<BukkitPlotPopulator> getPopulators(final String world) {
|
||||||
// You can have as many populators as you would like, e.g. tree
|
// You can have as many populators as you would like, e.g. tree
|
||||||
// populator, ore populator
|
// populator, ore populator
|
||||||
return Arrays.asList((PlotPopulator) new HybridPop(this.plotworld));
|
return Arrays.asList((BukkitPlotPopulator) new HybridPop(this.plotworld));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
package com.plotsquared.bukkit.listeners;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
import com.plotsquared.bukkit.object.InfoInventory;
|
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryInteractEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created 2014-11-18 for PlotSquared
|
|
||||||
* @author Citymonstret
|
|
||||||
*/
|
|
||||||
public class InventoryListener implements Listener {
|
|
||||||
@EventHandler
|
|
||||||
public void onInventoryAction(final InventoryInteractEvent event) {
|
|
||||||
if (event.getInventory().getHolder() instanceof InfoInventory) {
|
|
||||||
event.setResult(Event.Result.DENY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onInventoryClick(final InventoryClickEvent event) {
|
|
||||||
final Inventory inventory = event.getInventory();
|
|
||||||
final Player player = (Player) event.getWhoClicked();
|
|
||||||
if (inventory.getHolder() instanceof InfoInventory) {
|
|
||||||
switch (event.getSlot()) {
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), "This is not implemented yet");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -242,7 +242,7 @@ public class PlayerEvents extends com.plotsquared.bukkit.listeners.PlotListener
|
|||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
|
Location loc = pp.getLocation();
|
||||||
if (!PS.get().isPlotWorld(BukkitUtil.getWorld(player))) {
|
if (!PS.get().isPlotWorld(BukkitUtil.getWorld(player))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,10 @@ import java.util.UUID;
|
|||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class PlotListener extends APlotListener {
|
public class PlotListener extends APlotListener {
|
||||||
|
|
||||||
|
// FIXME if we add a few more functions to PlotPlayer, we could make this generic and not implementation specific
|
||||||
|
// TODO Alternatively we could move functions into BukkitPlayerManager which seems to be heavily lacking
|
||||||
|
|
||||||
public void textures(final Player p) {
|
public void textures(final Player p) {
|
||||||
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && PS.get().isPlotWorld(p.getWorld().getName())) {
|
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && PS.get().isPlotWorld(p.getWorld().getName())) {
|
||||||
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
||||||
|
@ -92,7 +92,7 @@ public class TNTListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Location landing = loc.add(shortest.getBlockX() + 1, 0, shortest.getBlockZ() + 1);
|
Location landing = loc.add(shortest.getBlockX() + 1, 0, shortest.getBlockZ() + 1);
|
||||||
int ty = BukkitUtil.getHeighestBlock(worldname, landing.getX(), landing.getZ());
|
int ty = MainUtil.getHeighestBlock(worldname, landing.getX(), landing.getZ());
|
||||||
int diff = ty - loc.getY();
|
int diff = ty - loc.getY();
|
||||||
double calcDiff = getY(velocity, Math.sqrt(shortest.getBlockX() * shortest.getBlockX() + shortest.getBlockZ() * shortest.getBlockZ()));
|
double calcDiff = getY(velocity, Math.sqrt(shortest.getBlockX() * shortest.getBlockX() + shortest.getBlockZ() * shortest.getBlockZ()));
|
||||||
if (calcDiff > diff) {
|
if (calcDiff > diff) {
|
||||||
|
@ -40,9 +40,4 @@ public class WorldEvents implements Listener {
|
|||||||
}
|
}
|
||||||
lastWorld = null;
|
lastWorld = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void worldLoad(final WorldLoadEvent event) {
|
|
||||||
UUIDHandler.startCaching(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
package com.plotsquared.bukkit.object;
|
package com.plotsquared.bukkit.object;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
||||||
|
import com.plotsquared.bukkit.util.bukkit.SetBlockFast;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
@ -13,17 +19,20 @@ import java.util.HashMap;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public abstract class PlotPopulator extends BlockPopulator {
|
public abstract class BukkitPlotPopulator extends BlockPopulator {
|
||||||
|
|
||||||
private PseudoRandom random = new PseudoRandom();
|
private PseudoRandom random = new PseudoRandom();
|
||||||
|
|
||||||
public int X;
|
public int X;
|
||||||
public int Z;
|
public int Z;
|
||||||
|
public String worldname;
|
||||||
private World world;
|
private World world;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(World world, Random rand, Chunk chunk) {
|
public void populate(World world, Random rand, Chunk chunk) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
this.worldname = world.getName();
|
||||||
this.X = chunk.getX() << 4;
|
this.X = chunk.getX() << 4;
|
||||||
this.Z = chunk.getZ() << 4;
|
this.Z = chunk.getZ() << 4;
|
||||||
if (ChunkManager.FORCE_PASTE) {
|
if (ChunkManager.FORCE_PASTE) {
|
||||||
@ -67,7 +76,12 @@ public abstract class PlotPopulator extends BlockPopulator {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
public void setBlock(int x, int y, int z, short id, byte data) {
|
public void setBlock(int x, int y, int z, short id, byte data) {
|
||||||
BukkitUtil.setBlock(world, X + x, y, Z + z, id, data);
|
if (data == 0) {
|
||||||
|
SetBlockQueue.setBlock(worldname, x, y, z, id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SetBlockQueue.setBlock(worldname, x, y, z, new PlotBlock(id, data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,87 +0,0 @@
|
|||||||
package com.plotsquared.bukkit.object;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created 2014-11-18 for PlotSquared
|
|
||||||
*
|
|
||||||
* @author Citymonstret
|
|
||||||
*/
|
|
||||||
public class InfoInventory implements InventoryHolder {
|
|
||||||
private final Plot plot;
|
|
||||||
private final Inventory inventory;
|
|
||||||
private final Player player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param plot from which we take information
|
|
||||||
*/
|
|
||||||
public InfoInventory(final Plot plot, final PlotPlayer plr) {
|
|
||||||
this.plot = plot;
|
|
||||||
this.player = ((BukkitPlayer) plr).player;
|
|
||||||
this.inventory = Bukkit.createInventory(this, 9, "Plot: " + plot.id.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Inventory getInventory() {
|
|
||||||
return this.inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName(final UUID uuid) {
|
|
||||||
final String name = UUIDHandler.getName(this.plot.owner);
|
|
||||||
if (name == null) {
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InfoInventory build() {
|
|
||||||
final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(this.player));
|
|
||||||
final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.owner), "&cAlias: &6" + this.plot.getSettings().getAlias(), "&cBiome: &6" + this.plot.getSettings().getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid));
|
|
||||||
final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.getTrusted().size(), "&8Click to view a list of the trusted users");
|
|
||||||
final ItemStack members = getItem(Material.EMERALD, "&cMembers", "&cAmount: &6" + this.plot.getMembers().size(), "&8Click to view a list of plot members");
|
|
||||||
final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.getDenied().size(), "&8Click to view a list of denied players");
|
|
||||||
final ItemStack flags = getItem(Material.EMERALD, "&cFlags", "&cAmount: &6" + this.plot.getSettings().flags.size(), "&8Click to view a list of plot flags");
|
|
||||||
this.inventory.setItem(2, generalInfo);
|
|
||||||
this.inventory.setItem(3, trusted);
|
|
||||||
this.inventory.setItem(4, members);
|
|
||||||
this.inventory.setItem(5, denied);
|
|
||||||
this.inventory.setItem(6, flags);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InfoInventory display() {
|
|
||||||
this.player.closeInventory();
|
|
||||||
this.player.openInventory(this.inventory);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemStack getItem(final Material material, final String name, final String... lore) {
|
|
||||||
final ItemStack stack = new ItemStack(material);
|
|
||||||
final ItemMeta meta = stack.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
|
||||||
final List<String> lList = new ArrayList<>();
|
|
||||||
for (final String l : lore) {
|
|
||||||
lList.add(ChatColor.translateAlternateColorCodes('&', l));
|
|
||||||
}
|
|
||||||
meta.setLore(lList);
|
|
||||||
stack.setItemMeta(meta);
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,11 @@
|
|||||||
package com.intellectualcrafters.plot.generator;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
|
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
@ -12,6 +14,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||||||
import com.plotsquared.bukkit.BukkitMain;
|
import com.plotsquared.bukkit.BukkitMain;
|
||||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -437,7 +440,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
ChunkLoc chunk = chunks.get(0);
|
ChunkLoc chunk = chunks.get(0);
|
||||||
chunks.remove(0);
|
chunks.remove(0);
|
||||||
regenerateRoad(world, chunk, extend);
|
regenerateRoad(world, chunk, extend);
|
||||||
ChunkManager.manager.unloadChunk(world, chunk);
|
ChunkManager.manager.unloadChunk(world, chunk, true, true);
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
|
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
@ -453,7 +456,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
ChunkLoc chunk = chunks.get(0);
|
ChunkLoc chunk = chunks.get(0);
|
||||||
chunks.remove(0);
|
chunks.remove(0);
|
||||||
regenerateRoad(world, chunk, extend);
|
regenerateRoad(world, chunk, extend);
|
||||||
ChunkManager.manager.unloadChunk(world, chunk);
|
ChunkManager.manager.unloadChunk(world, chunk, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last = System.currentTimeMillis();
|
last = System.currentTimeMillis();
|
||||||
@ -466,7 +469,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
final int sz = loc.z << 5;
|
final int sz = loc.z << 5;
|
||||||
for (int x = sx; x < (sx + 32); x++) {
|
for (int x = sx; x < (sx + 32); x++) {
|
||||||
for (int z = sz; z < (sz + 32); z++) {
|
for (int z = sz; z < (sz + 32); z++) {
|
||||||
ChunkManager.manager.unloadChunk(world, new ChunkLoc(x, z));
|
ChunkManager.manager.unloadChunk(world, new ChunkLoc(x, z), true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PS.log("&d - Potentially skipping 1024 chunks");
|
PS.log("&d - Potentially skipping 1024 chunks");
|
@ -929,13 +929,13 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadChunk(final String world, final ChunkLoc loc) {
|
public boolean loadChunk(final String world, final ChunkLoc loc, boolean force) {
|
||||||
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(false);
|
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean unloadChunk(final String world, final ChunkLoc loc) {
|
public boolean unloadChunk(final String world, final ChunkLoc loc, boolean save, boolean safe) {
|
||||||
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).unload(true, true);
|
return BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void swapChunk(final World world, final Chunk pos1, final Chunk pos2, final RegionWrapper r1, final RegionWrapper r2) {
|
public static void swapChunk(final World world, final Chunk pos1, final Chunk pos2, final RegionWrapper r1, final RegionWrapper r2) {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package com.plotsquared.bukkit.util.bukkit;
|
package com.plotsquared.bukkit.util.bukkit;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import java.util.Arrays;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import java.util.HashMap;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import java.util.List;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
import org.bukkit.Bukkit;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import org.bukkit.Material;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.*;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@ -17,11 +17,22 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.*;
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.material.Sandstone;
|
||||||
|
import org.bukkit.material.Step;
|
||||||
|
import org.bukkit.material.Tree;
|
||||||
|
import org.bukkit.material.WoodenStep;
|
||||||
|
import org.bukkit.material.Wool;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import java.util.HashMap;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import java.util.List;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||||
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
|
|
||||||
public class BukkitUtil extends BlockManager {
|
public class BukkitUtil extends BlockManager {
|
||||||
private static HashMap<String, World> worlds = new HashMap<>();
|
private static HashMap<String, World> worlds = new HashMap<>();
|
||||||
@ -36,12 +47,71 @@ public class BukkitUtil extends BlockManager {
|
|||||||
lastPlotPlayer = null;
|
lastPlotPlayer = null;
|
||||||
UUIDHandler.getPlayers().remove(plr);
|
UUIDHandler.getPlayers().remove(plr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These weren't being used, but they might be useful later, so I'm just commenting them out
|
||||||
|
// private static int getMaxHeight(final String world) {
|
||||||
|
// return getWorld(world).getMaxHeight();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static void unloadChunkAt(String worldname, int X, int Z, boolean save, boolean safe) {
|
||||||
|
// final World world = getWorld(worldname);
|
||||||
|
// world.unloadChunk(X, Z, save, safe);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static void loadChunkAt(final String worldname, int X, int Z, boolean force) {
|
||||||
|
// final World world = getWorld(worldname);
|
||||||
|
// world.loadChunk(X, Z, force);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static Chunk getChunkAt(final String worldname, final int x, final int z) {
|
||||||
|
// final World world = getWorld(worldname);
|
||||||
|
// return world.getChunkAt(x, z);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static void teleportPlayer(final Player player, final Location loc) {
|
||||||
|
// final org.bukkit.Location bukkitLoc = new org.bukkit.Location(getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
// player.teleport(bukkitLoc);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static void setBiome(final String worldname, final int pos1_x, final int pos1_z, final int pos2_x, final int pos2_z, final String biome) {
|
||||||
|
// final Biome b = Biome.valueOf(biome.toUpperCase());
|
||||||
|
// final World world = getWorld(worldname);
|
||||||
|
// for (int x = pos1_x; x <= pos2_x; x++) {
|
||||||
|
// for (int z = pos1_z; z <= pos2_z; z++) {
|
||||||
|
// if (world.getBiome(x, z) == b) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// world.setBiome(x, z, b);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static void refreshChunk(final String name, final int x, final int z) {
|
||||||
|
// World world = getWorld(name);
|
||||||
|
// world.refreshChunk(x, z);
|
||||||
|
// world.loadChunk(x, z);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static void regenerateChunk(final String world, final int x, final int z) {
|
||||||
|
// World worldObj = getWorld(world);
|
||||||
|
// Chunk chunk = worldObj.getChunkAt(x, z);
|
||||||
|
// if (chunk.isLoaded() || chunk.load(false)) {
|
||||||
|
// ChunkManager.manager.regenerateChunk(world, new ChunkLoc(x, z));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static Location getLocationFull(final org.bukkit.Location loc) {
|
||||||
|
// final String world = loc.getWorld().getName();
|
||||||
|
// return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getYaw(), loc.getPitch());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static int getViewDistance() {
|
||||||
|
// return Bukkit.getViewDistance();
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
////////////////////////////////////////////////////////////////////////
|
||||||
public boolean isWorld(final String world) {
|
/////////////////// USED BY EVENT SYSTEM AND SUCH //////////////////////
|
||||||
return getWorld(world) != null;
|
////////////////////////////////////////////////////////////////////////
|
||||||
}
|
|
||||||
|
|
||||||
public static PlotPlayer getPlayer(final OfflinePlayer op) {
|
public static PlotPlayer getPlayer(final OfflinePlayer op) {
|
||||||
if (op.isOnline()) {
|
if (op.isOnline()) {
|
||||||
return getPlayer(op.getPlayer());
|
return getPlayer(op.getPlayer());
|
||||||
@ -66,11 +136,6 @@ public class BukkitUtil extends BlockManager {
|
|||||||
return lastPlotPlayer;
|
return lastPlotPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBiome(final Location loc) {
|
|
||||||
return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()).name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Location getLocation(final org.bukkit.Location loc) {
|
public static Location getLocation(final org.bukkit.Location loc) {
|
||||||
return new Location(loc.getWorld().getName(), (int) loc.getX(), (int) loc.getY(), (int) loc.getZ());
|
return new Location(loc.getWorld().getName(), (int) loc.getX(), (int) loc.getY(), (int) loc.getZ());
|
||||||
}
|
}
|
||||||
@ -91,99 +156,14 @@ public class BukkitUtil extends BlockManager {
|
|||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMaxHeight(final String world) {
|
|
||||||
return getWorld(world).getMaxHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getHeighestBlock(final String world, final int x, final int z) {
|
|
||||||
return getWorld(world).getHighestBlockYAt(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unloadChunkAt(String worldname, int X, int Z, boolean save, boolean safe) {
|
|
||||||
final World world = getWorld(worldname);
|
|
||||||
world.unloadChunk(X, Z, save, safe);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadChunkAt(final String worldname, int X, int Z, boolean force) {
|
|
||||||
final World world = getWorld(worldname);
|
|
||||||
world.loadChunk(X, Z, force);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Chunk getChunkAt(final String worldname, final int x, final int z) {
|
|
||||||
final World world = getWorld(worldname);
|
|
||||||
return world.getChunkAt(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static void update(final String world, final int x, final int z) {
|
|
||||||
// final ArrayList<Chunk> chunks = new ArrayList<>();
|
|
||||||
// final int distance = Bukkit.getViewDistance();
|
|
||||||
// for (int cx = -distance; cx < distance; cx++) {
|
|
||||||
// for (int cz = -distance; cz < distance; cz++) {
|
|
||||||
// final Chunk chunk = getChunkAt(world, (x >> 4) + cx, (z >> 4) + cz);
|
|
||||||
// chunks.add(chunk);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// BukkitSetBlockManager.setBlockManager.update(chunks);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static String getWorld(final Entity entity) {
|
public static String getWorld(final Entity entity) {
|
||||||
return entity.getWorld().getName();
|
return entity.getWorld().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void teleportPlayer(final Player player, final Location loc) {
|
|
||||||
final org.bukkit.Location bukkitLoc = new org.bukkit.Location(getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
player.teleport(bukkitLoc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Entity> getEntities(final String worldname) {
|
public static List<Entity> getEntities(final String worldname) {
|
||||||
return getWorld(worldname).getEntities();
|
return getWorld(worldname).getEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBlock(final World world, final int x, final int y, final int z, final int id, final byte data) {
|
|
||||||
try {
|
|
||||||
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, id, data);
|
|
||||||
} catch (final Throwable e) {
|
|
||||||
BukkitSetBlockManager.setBlockManager = new SetBlockSlow();
|
|
||||||
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, id, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setBiome(final String worldname, final int pos1_x, final int pos1_z, final int pos2_x, final int pos2_z, final String biome) {
|
|
||||||
final Biome b = Biome.valueOf(biome.toUpperCase());
|
|
||||||
final World world = getWorld(worldname);
|
|
||||||
for (int x = pos1_x; x <= pos2_x; x++) {
|
|
||||||
for (int z = pos1_z; z <= pos2_z; z++) {
|
|
||||||
if (world.getBiome(x, z) == b) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
world.setBiome(x, z, b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void refreshChunk(final String name, final int x, final int z) {
|
|
||||||
World world = getWorld(name);
|
|
||||||
world.refreshChunk(x, z);
|
|
||||||
world.loadChunk(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void regenerateChunk(final String world, final int x, final int z) {
|
|
||||||
World worldObj = getWorld(world);
|
|
||||||
Chunk chunk = worldObj.getChunkAt(x, z);
|
|
||||||
if (chunk.isLoaded() || chunk.load(false)) {
|
|
||||||
ChunkManager.manager.regenerateChunk(world, new ChunkLoc(x, z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlotBlock getBlock(final Location loc) {
|
|
||||||
final World world = getWorld(loc.getWorld());
|
|
||||||
final Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
if (block == null) {
|
|
||||||
return new PlotBlock((short) 0, (byte) 0);
|
|
||||||
}
|
|
||||||
return new PlotBlock((short) block.getTypeId(), block.getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Location getLocation(final Entity entity) {
|
public static Location getLocation(final Entity entity) {
|
||||||
final org.bukkit.Location loc = entity.getLocation();
|
final org.bukkit.Location loc = entity.getLocation();
|
||||||
final String world = loc.getWorld().getName();
|
final String world = loc.getWorld().getName();
|
||||||
@ -193,10 +173,31 @@ public class BukkitUtil extends BlockManager {
|
|||||||
public static Location getLocationFull(final Entity entity) {
|
public static Location getLocationFull(final Entity entity) {
|
||||||
return getLocation(entity.getLocation());
|
return getLocation(entity.getLocation());
|
||||||
}
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
public static Location getLocationFull(final org.bukkit.Location loc) {
|
////////////////////////////////////////////////////////////////////////
|
||||||
final String world = loc.getWorld().getName();
|
////////////////////// CLASS ONLY METHODS //////////////////////////////
|
||||||
return new Location(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getYaw(), loc.getPitch());
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
private static void setBlock(final World world, final int x, final int y, final int z, final int id, final byte data) {
|
||||||
|
try {
|
||||||
|
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, id, data);
|
||||||
|
} catch (final Throwable e) {
|
||||||
|
BukkitSetBlockManager.setBlockManager = new SetBlockSlow();
|
||||||
|
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, id, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWorld(final String world) {
|
||||||
|
return getWorld(world) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBiome(String world, int x, int z) {
|
||||||
|
return getWorld(world).getBiome(x, z).name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -222,16 +223,12 @@ public class BukkitUtil extends BlockManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getViewDistance() {
|
|
||||||
return Bukkit.getViewDistance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void functionSetBiomes(final String worldname, final int[] x, final int[] z, final int[] biome) {
|
public void functionSetBiomes(final String worldname, final int[] x, final int[] z, final String biomeStr) {
|
||||||
final World world = getWorld(worldname);
|
final World world = getWorld(worldname);
|
||||||
final Biome[] biomes = Biome.values();
|
final Biome biome = Biome.valueOf(biomeStr.toUpperCase());
|
||||||
for (int i = 0; i < x.length; i++) {
|
for (int i = 0; i < x.length; i++) {
|
||||||
world.setBiome(x[i], z[i], biomes[biome[i]]);
|
world.setBiome(x[i], z[i], biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,8 +256,8 @@ public class BukkitUtil extends BlockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeighestBlock(final Location loc) {
|
public int getHeighestBlock(String world, int x, int z) {
|
||||||
return getWorld(loc.getWorld()).getHighestBlockAt(loc.getX(), loc.getZ()).getY();
|
return getWorld(world).getHighestBlockAt(x, z).getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -383,4 +380,14 @@ public class BukkitUtil extends BlockManager {
|
|||||||
catch (Exception e) {}
|
catch (Exception e) {}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlotBlock getBlock(Location loc) {
|
||||||
|
final World world = getWorld(loc.getWorld());
|
||||||
|
final Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
if (block == null) {
|
||||||
|
return new PlotBlock((short) 0, (byte) 0);
|
||||||
|
}
|
||||||
|
return new PlotBlock((short) block.getTypeId(), block.getData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ public class CommandManager<T extends CommandCaller> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final public void addCommand(final Command<T> command) {
|
final public void addCommand(final Command<T> command) {
|
||||||
|
if (command.getCommand() == null) {
|
||||||
|
command.create();
|
||||||
|
}
|
||||||
this.commands.put(command.getCommand().toLowerCase(), command);
|
this.commands.put(command.getCommand().toLowerCase(), command);
|
||||||
for (String alias : command.getAliases()) {
|
for (String alias : command.getAliases()) {
|
||||||
this.commands.put(alias.toLowerCase(), command);
|
this.commands.put(alias.toLowerCase(), command);
|
||||||
|
@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.plotsquared.bukkit.listeners.APlotListener;
|
import com.plotsquared.bukkit.listeners.APlotListener;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
import com.plotsquared.bukkit.util.SetupUtils;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.spongepowered.api.Game;
|
import org.spongepowered.api.Game;
|
||||||
import org.spongepowered.api.Server;
|
import org.spongepowered.api.Server;
|
||||||
@ -172,12 +173,6 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleKick(UUID uuid, C c) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskManager getTaskManager() {
|
public TaskManager getTaskManager() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
@ -327,4 +322,16 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startMetrics() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGenerator(String world) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user