mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 12:46:46 +01:00
Updated Gradle
This commit is contained in:
parent
7b15d50674
commit
b69e31129d
26
Bukkit/build.gradle
Normal file
26
Bukkit/build.gradle
Normal file
@ -0,0 +1,26 @@
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
|
||||
dependencies {
|
||||
compile project(':Core')
|
||||
compile 'org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT'
|
||||
compile 'net.milkbowl.vault:VaultAPI:1.5'
|
||||
}
|
||||
|
||||
processResources {
|
||||
from('src/main/resources') {
|
||||
include 'plugin.yml'
|
||||
expand(
|
||||
name: project.parent.name,
|
||||
version: project.parent.version
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependencies {
|
||||
include(dependency(':Core'))
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn(shadowJar)
|
File diff suppressed because it is too large
Load Diff
@ -1,404 +1,404 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.database.plotme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
|
||||
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
|
||||
/**
|
||||
* Created 2014-08-17 for PlotSquared
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class LikePlotMeConverter {
|
||||
private final String plugin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param plugin Plugin Used to run the converter
|
||||
*/
|
||||
public LikePlotMeConverter(final String plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static String getWorld(final String world) {
|
||||
for (final World newworld : Bukkit.getWorlds()) {
|
||||
if (newworld.getName().equalsIgnoreCase(world)) {
|
||||
return newworld.getName();
|
||||
}
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
private void sendMessage(final String message) {
|
||||
PS.debug("&3PlotMe&8->&3PlotSquared&8: &7" + message);
|
||||
}
|
||||
|
||||
public String getPlotMePath() {
|
||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
|
||||
}
|
||||
|
||||
public String getAthionPlotsPath() {
|
||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
|
||||
}
|
||||
|
||||
public FileConfiguration getPlotMeConfig(final String dataFolder) {
|
||||
final File plotMeFile = new File(dataFolder + "config.yml");
|
||||
if (!plotMeFile.exists()) {
|
||||
return null;
|
||||
}
|
||||
return YamlConfiguration.loadConfiguration(plotMeFile);
|
||||
}
|
||||
|
||||
public Set<String> getPlotMeWorlds(final FileConfiguration plotConfig) {
|
||||
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||
}
|
||||
|
||||
public void mergeWorldYml(final String plugin, FileConfiguration plotConfig) {
|
||||
try {
|
||||
File genConfig = new File("plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
if (genConfig.exists()) {
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
|
||||
for (String key : yml.getKeys(true)) {
|
||||
if (!plotConfig.contains(key)) {
|
||||
plotConfig.set(key, yml.get(key));
|
||||
}
|
||||
}
|
||||
genConfig.delete();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateWorldYml(final String plugin, final String location) {
|
||||
try {
|
||||
final Path path = Paths.get(location);
|
||||
final File file = new File(location);
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
final Charset charset = StandardCharsets.UTF_8;
|
||||
String content = new String(Files.readAllBytes(path), charset);
|
||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||
content = content.replaceAll(plugin, "PlotSquared");
|
||||
Files.write(path, content.getBytes(charset));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean run(final APlotMeConnector connector) {
|
||||
try {
|
||||
final String dataFolder = getPlotMePath();
|
||||
final FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
||||
if (plotConfig == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String version = plotConfig.getString("Version");
|
||||
if (version == null) {
|
||||
version = plotConfig.getString("version");
|
||||
}
|
||||
if (!connector.accepts(version)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
||||
|
||||
final Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
|
||||
|
||||
if (!connector.isValidConnection(connection)) {
|
||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||
return false;
|
||||
}
|
||||
|
||||
sendMessage(plugin + " conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||
|
||||
mergeWorldYml(plugin, plotConfig);
|
||||
|
||||
sendMessage("Connecting to " + plugin + " DB");
|
||||
|
||||
int plotCount = 0;
|
||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||
|
||||
sendMessage("Collecting plot data");
|
||||
|
||||
final String dbPrefix = plugin.toLowerCase();
|
||||
sendMessage(" - " + dbPrefix + "Plots");
|
||||
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
||||
|
||||
if (Settings.CONVERT_PLOTME) {
|
||||
sendMessage("Updating bukkit.yml");
|
||||
updateWorldYml(plugin, "bukkit.yml");
|
||||
updateWorldYml(plugin, "plugins/Multiverse-Core/worlds.yml");
|
||||
for (final String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
|
||||
sendMessage("Copying config for: " + world);
|
||||
try {
|
||||
final String actualWorldName = getWorld(world);
|
||||
connector.copyConfig(plotConfig, world, actualWorldName);
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
||||
}
|
||||
}
|
||||
}
|
||||
final HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
||||
for (final Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
plotCount += entry.getValue().size();
|
||||
}
|
||||
if (!Settings.CONVERT_PLOTME) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendMessage(" - " + dbPrefix + "Allowed");
|
||||
|
||||
sendMessage("Collected " + plotCount + " plots from PlotMe");
|
||||
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
if (PLOTME_DG_FILE.exists()) {
|
||||
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
||||
try {
|
||||
for (final String world : plots.keySet()) {
|
||||
final String actualWorldName = getWorld(world);
|
||||
final String plotMeWorldName = world.toLowerCase();
|
||||
Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||
/*
|
||||
* TODO: dead code
|
||||
*
|
||||
if (pathwidth == null) {
|
||||
pathwidth = 7;
|
||||
}
|
||||
*/
|
||||
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
|
||||
|
||||
Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if ((pathheight == null) || (pathheight == 0)) {
|
||||
pathheight = 64;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
||||
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||
if ((plotsize == null) || (plotsize == 0)) {
|
||||
plotsize = 32;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.size", plotsize);
|
||||
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
|
||||
if (wallblock == null) {
|
||||
wallblock = "44";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".wall.block", wallblock);
|
||||
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
|
||||
if (floor == null) {
|
||||
floor = "2";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
|
||||
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
||||
if (filling == null) {
|
||||
filling = "3";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
||||
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
||||
if (road == null) {
|
||||
road = "5";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.block", road);
|
||||
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if (height == 0) {
|
||||
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
||||
if (height == 0) {
|
||||
height = 64;
|
||||
}
|
||||
}
|
||||
PS.get().config.set("worlds." + actualWorldName + ".road.height", height);
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.height", height);
|
||||
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
String world = entry.getKey();
|
||||
PlotArea area = PS.get().getPlotArea(world, null);
|
||||
int duplicate = 0;
|
||||
if (area != null) {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
if (area.getOwnedPlotAbs(entry2.getKey()) != null) {
|
||||
duplicate++;
|
||||
} else {
|
||||
createdPlots.add(entry2.getValue());
|
||||
}
|
||||
}
|
||||
if (duplicate > 0) {
|
||||
PS.debug("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
|
||||
}
|
||||
} else {
|
||||
if (PS.get().plots_tmp != null) {
|
||||
HashMap<PlotId, Plot> map = PS.get().plots_tmp.get(world);
|
||||
if (map != null) {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
if (map.containsKey(entry2.getKey())) {
|
||||
duplicate++;
|
||||
} else {
|
||||
createdPlots.add(entry2.getValue());
|
||||
}
|
||||
}
|
||||
if (duplicate > 0) {
|
||||
PS.debug("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
createdPlots.addAll(entry.getValue().values());
|
||||
}
|
||||
}
|
||||
sendMessage("Creating plot DB");
|
||||
Thread.sleep(1000);
|
||||
final AtomicBoolean done = new AtomicBoolean(false);
|
||||
DBFunc.createPlotsAndData(createdPlots, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (done.get()) {
|
||||
done();
|
||||
sendMessage("&aDatabase conversion is now complete!");
|
||||
PS.debug("&c - Stop the server");
|
||||
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||
PS.debug("&c - Start the server");
|
||||
PS.get().setPlots(DBFunc.getPlots());
|
||||
} else {
|
||||
sendMessage("&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
|
||||
done.set(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
sendMessage("Saving configuration...");
|
||||
try {
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
} catch (final IOException e) {
|
||||
sendMessage(" - &cFailed to save configuration.");
|
||||
}
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
boolean MV = false;
|
||||
boolean MW = false;
|
||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||
MV = true;
|
||||
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||
MW = true;
|
||||
}
|
||||
for (final String worldname : worlds) {
|
||||
final World world = Bukkit.getWorld(getWorld(worldname));
|
||||
if (world == null) {
|
||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
||||
}
|
||||
final String actualWorldName = world.getName();
|
||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||
PS.get().removePlotAreas(actualWorldName);
|
||||
if (MV) {
|
||||
// unload world with MV
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (final InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
// load world with MV
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared");
|
||||
} else if (MW) {
|
||||
// unload world with MW
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (final InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
// load world with MW
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared");
|
||||
} else {
|
||||
// Load using Bukkit API
|
||||
// - User must set generator manually
|
||||
Bukkit.getServer().unloadWorld(world, true);
|
||||
final World myworld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
||||
myworld.save();
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (done.get()) {
|
||||
done();
|
||||
sendMessage("&aDatabase conversion is now complete!");
|
||||
PS.debug("&c - Stop the server");
|
||||
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||
PS.debug("&c - Start the server");
|
||||
} else {
|
||||
sendMessage("&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
|
||||
done.set(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&/end/");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void done() {
|
||||
PS.get().setPlots(DBFunc.getPlots());
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.database.plotme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
|
||||
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
|
||||
/**
|
||||
* Created 2014-08-17 for PlotSquared
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class LikePlotMeConverter {
|
||||
private final String plugin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param plugin Plugin Used to run the converter
|
||||
*/
|
||||
public LikePlotMeConverter(final String plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static String getWorld(final String world) {
|
||||
for (final World newworld : Bukkit.getWorlds()) {
|
||||
if (newworld.getName().equalsIgnoreCase(world)) {
|
||||
return newworld.getName();
|
||||
}
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
private void sendMessage(final String message) {
|
||||
PS.debug("&3PlotMe&8->&3PlotSquared&8: &7" + message);
|
||||
}
|
||||
|
||||
public String getPlotMePath() {
|
||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
|
||||
}
|
||||
|
||||
public String getAthionPlotsPath() {
|
||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
|
||||
}
|
||||
|
||||
public FileConfiguration getPlotMeConfig(final String dataFolder) {
|
||||
final File plotMeFile = new File(dataFolder + "config.yml");
|
||||
if (!plotMeFile.exists()) {
|
||||
return null;
|
||||
}
|
||||
return YamlConfiguration.loadConfiguration(plotMeFile);
|
||||
}
|
||||
|
||||
public Set<String> getPlotMeWorlds(final FileConfiguration plotConfig) {
|
||||
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||
}
|
||||
|
||||
public void mergeWorldYml(final String plugin, FileConfiguration plotConfig) {
|
||||
try {
|
||||
File genConfig = new File("plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
if (genConfig.exists()) {
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
|
||||
for (String key : yml.getKeys(true)) {
|
||||
if (!plotConfig.contains(key)) {
|
||||
plotConfig.set(key, yml.get(key));
|
||||
}
|
||||
}
|
||||
genConfig.delete();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateWorldYml(final String plugin, final String location) {
|
||||
try {
|
||||
final Path path = Paths.get(location);
|
||||
final File file = new File(location);
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
final Charset charset = StandardCharsets.UTF_8;
|
||||
String content = new String(Files.readAllBytes(path), charset);
|
||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||
content = content.replaceAll(plugin, "PlotSquared");
|
||||
Files.write(path, content.getBytes(charset));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean run(final APlotMeConnector connector) {
|
||||
try {
|
||||
final String dataFolder = getPlotMePath();
|
||||
final FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
||||
if (plotConfig == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String version = plotConfig.getString("Version");
|
||||
if (version == null) {
|
||||
version = plotConfig.getString("version");
|
||||
}
|
||||
if (!connector.accepts(version)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
||||
|
||||
final Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
|
||||
|
||||
if (!connector.isValidConnection(connection)) {
|
||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||
return false;
|
||||
}
|
||||
|
||||
sendMessage(plugin + " conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||
|
||||
mergeWorldYml(plugin, plotConfig);
|
||||
|
||||
sendMessage("Connecting to " + plugin + " DB");
|
||||
|
||||
int plotCount = 0;
|
||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||
|
||||
sendMessage("Collecting plot data");
|
||||
|
||||
final String dbPrefix = plugin.toLowerCase();
|
||||
sendMessage(" - " + dbPrefix + "Plots");
|
||||
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
||||
|
||||
if (Settings.CONVERT_PLOTME) {
|
||||
sendMessage("Updating bukkit.yml");
|
||||
updateWorldYml(plugin, "bukkit.yml");
|
||||
updateWorldYml(plugin, "plugins/Multiverse-Core/worlds.yml");
|
||||
for (final String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
|
||||
sendMessage("Copying config for: " + world);
|
||||
try {
|
||||
final String actualWorldName = getWorld(world);
|
||||
connector.copyConfig(plotConfig, world, actualWorldName);
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
||||
}
|
||||
}
|
||||
}
|
||||
final HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
||||
for (final Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
plotCount += entry.getValue().size();
|
||||
}
|
||||
if (!Settings.CONVERT_PLOTME) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendMessage(" - " + dbPrefix + "Allowed");
|
||||
|
||||
sendMessage("Collected " + plotCount + " plots from PlotMe");
|
||||
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
if (PLOTME_DG_FILE.exists()) {
|
||||
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
||||
try {
|
||||
for (final String world : plots.keySet()) {
|
||||
final String actualWorldName = getWorld(world);
|
||||
final String plotMeWorldName = world.toLowerCase();
|
||||
Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||
/*
|
||||
* TODO: dead code
|
||||
*
|
||||
if (pathwidth == null) {
|
||||
pathwidth = 7;
|
||||
}
|
||||
*/
|
||||
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
|
||||
|
||||
Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if ((pathheight == null) || (pathheight == 0)) {
|
||||
pathheight = 64;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
||||
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||
if ((plotsize == null) || (plotsize == 0)) {
|
||||
plotsize = 32;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.size", plotsize);
|
||||
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
|
||||
if (wallblock == null) {
|
||||
wallblock = "44";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".wall.block", wallblock);
|
||||
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
|
||||
if (floor == null) {
|
||||
floor = "2";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
|
||||
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
||||
if (filling == null) {
|
||||
filling = "3";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
||||
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
||||
if (road == null) {
|
||||
road = "5";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.block", road);
|
||||
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if (height == 0) {
|
||||
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
||||
if (height == 0) {
|
||||
height = 64;
|
||||
}
|
||||
}
|
||||
PS.get().config.set("worlds." + actualWorldName + ".road.height", height);
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.height", height);
|
||||
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
String world = entry.getKey();
|
||||
PlotArea area = PS.get().getPlotArea(world, null);
|
||||
int duplicate = 0;
|
||||
if (area != null) {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
if (area.getOwnedPlotAbs(entry2.getKey()) != null) {
|
||||
duplicate++;
|
||||
} else {
|
||||
createdPlots.add(entry2.getValue());
|
||||
}
|
||||
}
|
||||
if (duplicate > 0) {
|
||||
PS.debug("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
|
||||
}
|
||||
} else {
|
||||
if (PS.get().plots_tmp != null) {
|
||||
HashMap<PlotId, Plot> map = PS.get().plots_tmp.get(world);
|
||||
if (map != null) {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
if (map.containsKey(entry2.getKey())) {
|
||||
duplicate++;
|
||||
} else {
|
||||
createdPlots.add(entry2.getValue());
|
||||
}
|
||||
}
|
||||
if (duplicate > 0) {
|
||||
PS.debug("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
createdPlots.addAll(entry.getValue().values());
|
||||
}
|
||||
}
|
||||
sendMessage("Creating plot DB");
|
||||
Thread.sleep(1000);
|
||||
final AtomicBoolean done = new AtomicBoolean(false);
|
||||
DBFunc.createPlotsAndData(createdPlots, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (done.get()) {
|
||||
done();
|
||||
sendMessage("&aDatabase conversion is now complete!");
|
||||
PS.debug("&c - Stop the server");
|
||||
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||
PS.debug("&c - Start the server");
|
||||
PS.get().setPlots(DBFunc.getPlots());
|
||||
} else {
|
||||
sendMessage("&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
|
||||
done.set(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
sendMessage("Saving configuration...");
|
||||
try {
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
} catch (final IOException e) {
|
||||
sendMessage(" - &cFailed to save configuration.");
|
||||
}
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
boolean MV = false;
|
||||
boolean MW = false;
|
||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||
MV = true;
|
||||
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||
MW = true;
|
||||
}
|
||||
for (final String worldname : worlds) {
|
||||
final World world = Bukkit.getWorld(getWorld(worldname));
|
||||
if (world == null) {
|
||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
||||
}
|
||||
final String actualWorldName = world.getName();
|
||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||
PS.get().removePlotAreas(actualWorldName);
|
||||
if (MV) {
|
||||
// unload world with MV
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (final InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
// load world with MV
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared");
|
||||
} else if (MW) {
|
||||
// unload world with MW
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (final InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
// load world with MW
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared");
|
||||
} else {
|
||||
// Load using Bukkit API
|
||||
// - User must set generator manually
|
||||
Bukkit.getServer().unloadWorld(world, true);
|
||||
final World myworld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
||||
myworld.save();
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (done.get()) {
|
||||
done();
|
||||
sendMessage("&aDatabase conversion is now complete!");
|
||||
PS.debug("&c - Stop the server");
|
||||
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||
PS.debug("&c - Start the server");
|
||||
} else {
|
||||
sendMessage("&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
|
||||
done.set(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&/end/");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void done() {
|
||||
PS.get().setPlots(DBFunc.getPlots());
|
||||
}
|
||||
}
|
@ -1,89 +1,89 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.events;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
|
||||
/**
|
||||
* Called when a flag is removed from a plot
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class ClusterFlagRemoveEvent extends Event implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
private final PlotCluster cluster;
|
||||
private final Flag flag;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
||||
*
|
||||
* @param flag Flag that was removed
|
||||
* @param cluster PlotCluster from which the flag was removed
|
||||
*/
|
||||
public ClusterFlagRemoveEvent(final Flag flag, final PlotCluster cluster) {
|
||||
this.cluster = cluster;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cluster involved
|
||||
*
|
||||
* @return PlotCluster
|
||||
*/
|
||||
public PlotCluster getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
*
|
||||
* @return Flag
|
||||
*/
|
||||
public Flag getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean b) {
|
||||
cancelled = b;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.events;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
|
||||
/**
|
||||
* Called when a flag is removed from a plot
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class ClusterFlagRemoveEvent extends Event implements Cancellable {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
private final PlotCluster cluster;
|
||||
private final Flag flag;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
||||
*
|
||||
* @param flag Flag that was removed
|
||||
* @param cluster PlotCluster from which the flag was removed
|
||||
*/
|
||||
public ClusterFlagRemoveEvent(final Flag flag, final PlotCluster cluster) {
|
||||
this.cluster = cluster;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cluster involved
|
||||
*
|
||||
* @return PlotCluster
|
||||
*/
|
||||
public PlotCluster getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
*
|
||||
* @return Flag
|
||||
*/
|
||||
public Flag getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean b) {
|
||||
cancelled = b;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,251 +1,251 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created 2014-10-30 for PlotSquared
|
||||
*
|
||||
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation" })
|
||||
public class PlotPlusListener extends PlotListener implements Listener {
|
||||
private final static HashMap<String, Interval> feedRunnable = new HashMap<>();
|
||||
private final static HashMap<String, Interval> healRunnable = new HashMap<>();
|
||||
|
||||
public static void startRunnable(final JavaPlugin plugin) {
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!healRunnable.isEmpty()) {
|
||||
for (final Iterator<Entry<String, Interval>> iter = healRunnable.entrySet().iterator(); iter.hasNext();) {
|
||||
final Entry<String, Interval> entry = iter.next();
|
||||
final Interval value = entry.getValue();
|
||||
++value.count;
|
||||
if (value.count == value.interval) {
|
||||
value.count = 0;
|
||||
final Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player == null) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
final double level = player.getHealth();
|
||||
if (level != value.max) {
|
||||
player.setHealth(Math.min(level + value.amount, value.max));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!feedRunnable.isEmpty()) {
|
||||
for (final Iterator<Entry<String, Interval>> iter = feedRunnable.entrySet().iterator(); iter.hasNext();) {
|
||||
final Entry<String, Interval> entry = iter.next();
|
||||
final Interval value = entry.getValue();
|
||||
++value.count;
|
||||
if (value.count == value.interval) {
|
||||
value.count = 0;
|
||||
final Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player == null) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
final int level = player.getFoodLevel();
|
||||
if (level != value.max) {
|
||||
player.setFoodLevel(Math.min(level + value.amount, value.max));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0l, 20l);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onInteract(final BlockDamageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (player.getGameMode() != GameMode.SURVIVAL) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (FlagManager.isBooleanFlag(plot, "instabreak", false)) {
|
||||
event.getBlock().breakNaturally();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamage(final EntityDamageEvent event) {
|
||||
if (event.getEntityType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) event.getEntity();
|
||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (FlagManager.isBooleanFlag(plot, "invincible", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemPickup(final PlayerPickupItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
final UUID uuid = pp.getUUID();
|
||||
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "drop-protection", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemDrop(final PlayerDropItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
final UUID uuid = pp.getUUID();
|
||||
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "item-drop", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotEnter(final PlayerEnterPlotEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Plot plot = event.getPlot();
|
||||
final Flag feed = FlagManager.getPlotFlagRaw(plot, "feed");
|
||||
if (feed != null) {
|
||||
final Integer[] value = (Integer[]) feed.getValue();
|
||||
feedRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||
}
|
||||
final Flag heal = FlagManager.getPlotFlagRaw(plot, "heal");
|
||||
if (heal != null) {
|
||||
final Integer[] value = (Integer[]) heal.getValue();
|
||||
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName();
|
||||
feedRunnable.remove(name);
|
||||
healRunnable.remove(name);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotLeave(final PlayerLeavePlotEvent event) {
|
||||
final Player leaver = event.getPlayer();
|
||||
final Plot plot = event.getPlot();
|
||||
if (!plot.hasOwner()) {
|
||||
return;
|
||||
}
|
||||
BukkitUtil.getPlayer(leaver);
|
||||
final String name = leaver.getName();
|
||||
feedRunnable.remove(name);
|
||||
healRunnable.remove(name);
|
||||
}
|
||||
|
||||
public static class Interval {
|
||||
public final int interval;
|
||||
public final int amount;
|
||||
public final int max;
|
||||
public int count = 0;
|
||||
|
||||
public Interval(final int interval, final int amount, final int max) {
|
||||
this.interval = interval;
|
||||
this.amount = amount;
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Record Meta Class
|
||||
*
|
||||
|
||||
*/
|
||||
public static class RecordMeta {
|
||||
public final static List<RecordMeta> metaList = new ArrayList<>();
|
||||
static {
|
||||
for (int x = 3; x < 12; x++) {
|
||||
metaList.add(new RecordMeta(x + "", Material.valueOf("RECORD_" + x)));
|
||||
}
|
||||
}
|
||||
private final String name;
|
||||
private final Material material;
|
||||
|
||||
public RecordMeta(final String name, final Material material) {
|
||||
this.name = name;
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created 2014-10-30 for PlotSquared
|
||||
*
|
||||
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation" })
|
||||
public class PlotPlusListener extends PlotListener implements Listener {
|
||||
private final static HashMap<String, Interval> feedRunnable = new HashMap<>();
|
||||
private final static HashMap<String, Interval> healRunnable = new HashMap<>();
|
||||
|
||||
public static void startRunnable(final JavaPlugin plugin) {
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!healRunnable.isEmpty()) {
|
||||
for (final Iterator<Entry<String, Interval>> iter = healRunnable.entrySet().iterator(); iter.hasNext();) {
|
||||
final Entry<String, Interval> entry = iter.next();
|
||||
final Interval value = entry.getValue();
|
||||
++value.count;
|
||||
if (value.count == value.interval) {
|
||||
value.count = 0;
|
||||
final Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player == null) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
final double level = player.getHealth();
|
||||
if (level != value.max) {
|
||||
player.setHealth(Math.min(level + value.amount, value.max));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!feedRunnable.isEmpty()) {
|
||||
for (final Iterator<Entry<String, Interval>> iter = feedRunnable.entrySet().iterator(); iter.hasNext();) {
|
||||
final Entry<String, Interval> entry = iter.next();
|
||||
final Interval value = entry.getValue();
|
||||
++value.count;
|
||||
if (value.count == value.interval) {
|
||||
value.count = 0;
|
||||
final Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player == null) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
final int level = player.getFoodLevel();
|
||||
if (level != value.max) {
|
||||
player.setFoodLevel(Math.min(level + value.amount, value.max));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0l, 20l);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onInteract(final BlockDamageEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (player.getGameMode() != GameMode.SURVIVAL) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (FlagManager.isBooleanFlag(plot, "instabreak", false)) {
|
||||
event.getBlock().breakNaturally();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamage(final EntityDamageEvent event) {
|
||||
if (event.getEntityType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) event.getEntity();
|
||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (FlagManager.isBooleanFlag(plot, "invincible", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemPickup(final PlayerPickupItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
final UUID uuid = pp.getUUID();
|
||||
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "drop-protection", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemDrop(final PlayerDropItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
final UUID uuid = pp.getUUID();
|
||||
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "item-drop", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotEnter(final PlayerEnterPlotEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Plot plot = event.getPlot();
|
||||
final Flag feed = FlagManager.getPlotFlagRaw(plot, "feed");
|
||||
if (feed != null) {
|
||||
final Integer[] value = (Integer[]) feed.getValue();
|
||||
feedRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||
}
|
||||
final Flag heal = FlagManager.getPlotFlagRaw(plot, "heal");
|
||||
if (heal != null) {
|
||||
final Integer[] value = (Integer[]) heal.getValue();
|
||||
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName();
|
||||
feedRunnable.remove(name);
|
||||
healRunnable.remove(name);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotLeave(final PlayerLeavePlotEvent event) {
|
||||
final Player leaver = event.getPlayer();
|
||||
final Plot plot = event.getPlot();
|
||||
if (!plot.hasOwner()) {
|
||||
return;
|
||||
}
|
||||
BukkitUtil.getPlayer(leaver);
|
||||
final String name = leaver.getName();
|
||||
feedRunnable.remove(name);
|
||||
healRunnable.remove(name);
|
||||
}
|
||||
|
||||
public static class Interval {
|
||||
public final int interval;
|
||||
public final int amount;
|
||||
public final int max;
|
||||
public int count = 0;
|
||||
|
||||
public Interval(final int interval, final int amount, final int max) {
|
||||
this.interval = interval;
|
||||
this.amount = amount;
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Record Meta Class
|
||||
*
|
||||
|
||||
*/
|
||||
public static class RecordMeta {
|
||||
public final static List<RecordMeta> metaList = new ArrayList<>();
|
||||
static {
|
||||
for (int x = 3; x < 12; x++) {
|
||||
metaList.add(new RecordMeta(x + "", Material.valueOf("RECORD_" + x)));
|
||||
}
|
||||
}
|
||||
private final String name;
|
||||
private final Material material;
|
||||
|
||||
public RecordMeta(final String name, final Material material) {
|
||||
this.name = name;
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,108 +1,108 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.plotsquared.bukkit.commands.DebugUUID;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created 2015-02-20 for PlotSquared
|
||||
*
|
||||
|
||||
*/
|
||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
public BukkitCommand() {
|
||||
MainCommand.getInstance().addCommand(new DebugUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender commandSender, final org.bukkit.command.Command command, final String commandLabel,
|
||||
final String[] args) {
|
||||
if (commandSender instanceof Player) {
|
||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
|
||||
}
|
||||
if (commandSender == null || commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
|
||||
return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
ConsolePlayer sender = new ConsolePlayer() {
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
commandSender.sendMessage(commandLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return commandSender.hasPermission(commandLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (commandSender.getName().equals("CONSOLE")) {
|
||||
return "*";
|
||||
}
|
||||
return commandSender.getName();
|
||||
}
|
||||
};
|
||||
sender.teleport(ConsolePlayer.getConsole().getLocationFull());
|
||||
boolean result = MainCommand.onCommand(sender, commandLabel, args);
|
||||
ConsolePlayer.getConsole().teleport(sender.getLocationFull());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(final CommandSender commandSender, final org.bukkit.command.Command command, final String s,
|
||||
final String[] strings) {
|
||||
if (!(commandSender instanceof Player)) {
|
||||
return null;
|
||||
}
|
||||
final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
||||
if (strings.length < 1) {
|
||||
if ((strings.length == 0) || "plots".startsWith(s)) {
|
||||
return Collections.singletonList("plots");
|
||||
}
|
||||
}
|
||||
if (strings.length > 1) {
|
||||
return null;
|
||||
}
|
||||
final Set<String> tabOptions = new HashSet<>();
|
||||
final String arg = strings[0].toLowerCase();
|
||||
ArrayList<String> labels = new ArrayList<>();
|
||||
for (final Command<PlotPlayer> cmd : MainCommand.getInstance().getCommands()) {
|
||||
final String label = cmd.getCommand();
|
||||
HashSet<String> aliases = new HashSet<>(cmd.getAliases());
|
||||
aliases.add(label);
|
||||
for (String alias : aliases) {
|
||||
labels.add(alias);
|
||||
if (alias.startsWith(arg)) {
|
||||
if (Permissions.hasPermission(player, cmd.getPermission())) {
|
||||
tabOptions.add(label);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String best = new StringComparison<>(arg, labels).getBestMatch();
|
||||
tabOptions.add(best);
|
||||
if (!tabOptions.isEmpty()) {
|
||||
return new ArrayList<>(tabOptions);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.plotsquared.bukkit.commands.DebugUUID;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created 2015-02-20 for PlotSquared
|
||||
*
|
||||
|
||||
*/
|
||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
public BukkitCommand() {
|
||||
MainCommand.getInstance().addCommand(new DebugUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender commandSender, final org.bukkit.command.Command command, final String commandLabel,
|
||||
final String[] args) {
|
||||
if (commandSender instanceof Player) {
|
||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
|
||||
}
|
||||
if (commandSender == null || commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
|
||||
return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
ConsolePlayer sender = new ConsolePlayer() {
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
commandSender.sendMessage(commandLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return commandSender.hasPermission(commandLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (commandSender.getName().equals("CONSOLE")) {
|
||||
return "*";
|
||||
}
|
||||
return commandSender.getName();
|
||||
}
|
||||
};
|
||||
sender.teleport(ConsolePlayer.getConsole().getLocationFull());
|
||||
boolean result = MainCommand.onCommand(sender, commandLabel, args);
|
||||
ConsolePlayer.getConsole().teleport(sender.getLocationFull());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(final CommandSender commandSender, final org.bukkit.command.Command command, final String s,
|
||||
final String[] strings) {
|
||||
if (!(commandSender instanceof Player)) {
|
||||
return null;
|
||||
}
|
||||
final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
||||
if (strings.length < 1) {
|
||||
if ((strings.length == 0) || "plots".startsWith(s)) {
|
||||
return Collections.singletonList("plots");
|
||||
}
|
||||
}
|
||||
if (strings.length > 1) {
|
||||
return null;
|
||||
}
|
||||
final Set<String> tabOptions = new HashSet<>();
|
||||
final String arg = strings[0].toLowerCase();
|
||||
ArrayList<String> labels = new ArrayList<>();
|
||||
for (final Command<PlotPlayer> cmd : MainCommand.getInstance().getCommands()) {
|
||||
final String label = cmd.getCommand();
|
||||
HashSet<String> aliases = new HashSet<>(cmd.getAliases());
|
||||
aliases.add(label);
|
||||
for (String alias : aliases) {
|
||||
labels.add(alias);
|
||||
if (alias.startsWith(arg)) {
|
||||
if (Permissions.hasPermission(player, cmd.getPermission())) {
|
||||
tabOptions.add(label);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String best = new StringComparison<>(arg, labels).getBestMatch();
|
||||
tabOptions.add(best);
|
||||
if (!tabOptions.isEmpty()) {
|
||||
return new ArrayList<>(tabOptions);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,340 +1,340 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.jnbt.IntTag;
|
||||
import com.intellectualcrafters.jnbt.ListTag;
|
||||
import com.intellectualcrafters.jnbt.ShortTag;
|
||||
import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.object.schematic.StateWrapper;
|
||||
|
||||
/**
|
||||
* Schematic Handler
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class BukkitSchematicHandler extends SchematicHandler {
|
||||
|
||||
@Override
|
||||
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
|
||||
// async
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Main positions
|
||||
Location[] corners = MainUtil.getCorners(world, regions);
|
||||
final Location bot = corners[0];
|
||||
final Location top = corners[1];
|
||||
|
||||
final int width = (top.getX() - bot.getX()) + 1;
|
||||
final int height = (top.getY() - bot.getY()) + 1;
|
||||
final int length = (top.getZ() - bot.getZ()) + 1;
|
||||
// Main Schematic tag
|
||||
final HashMap<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||
schematic.put("Materials", new StringTag("Materials", "Alpha"));
|
||||
schematic.put("WEOriginX", new IntTag("WEOriginX", 0));
|
||||
schematic.put("WEOriginY", new IntTag("WEOriginY", 0));
|
||||
schematic.put("WEOriginZ", new IntTag("WEOriginZ", 0));
|
||||
schematic.put("WEOffsetX", new IntTag("WEOffsetX", 0));
|
||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
||||
// Arrays of data types
|
||||
final List<Tag> tileEntities = new ArrayList<>();
|
||||
final byte[] blocks = new byte[width * height * length];
|
||||
final byte[] blockData = new byte[width * height * length];
|
||||
// Queue
|
||||
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (queue.isEmpty()) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||
whenDone.value = new CompoundTag("Schematic", schematic);
|
||||
TaskManager.runTask(whenDone);
|
||||
System.gc();
|
||||
System.gc();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
final Runnable regionTask = this;
|
||||
RegionWrapper region = queue.poll();
|
||||
Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
|
||||
final int bx = bot.getX();
|
||||
final int bz = bot.getZ();
|
||||
final int p1x = pos1.getX();
|
||||
final int p1z = pos1.getZ();
|
||||
final int p2x = pos2.getX();
|
||||
final int p2z = pos2.getZ();
|
||||
final int bcx = p1x >> 4;
|
||||
final int bcz = p1z >> 4;
|
||||
final int tcx = p2x >> 4;
|
||||
final int tcz = p2z >> 4;
|
||||
final int sy = pos1.getY();
|
||||
final int ey = pos2.getY();
|
||||
// Generate list of chunks
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
for (int x = bcx; x <= tcx; x++) {
|
||||
for (int z = bcz; z <= tcz; z++) {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
}
|
||||
}
|
||||
final World worldObj = Bukkit.getWorld(world);
|
||||
// Main thread
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final long start = System.currentTimeMillis();
|
||||
while ((!chunks.isEmpty()) && ((System.currentTimeMillis() - start) < 20)) {
|
||||
// save schematics
|
||||
final ChunkLoc chunk = chunks.remove(0);
|
||||
final Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
|
||||
if (!bc.load(false)) {
|
||||
continue;
|
||||
}
|
||||
final int X = chunk.x;
|
||||
final int Z = chunk.z;
|
||||
int xxb = X << 4;
|
||||
int zzb = Z << 4;
|
||||
int xxt = xxb + 15;
|
||||
int zzt = zzb + 15;
|
||||
|
||||
if (X == bcx) {
|
||||
xxb = p1x;
|
||||
}
|
||||
if (X == tcx) {
|
||||
xxt = p2x;
|
||||
}
|
||||
if (Z == bcz) {
|
||||
zzb = p1z;
|
||||
}
|
||||
if (Z == tcz) {
|
||||
zzt = p2z;
|
||||
}
|
||||
for (int y = sy; y <= Math.min(255, ey); y++) {
|
||||
final int ry = y - sy;
|
||||
final int i1 = (ry * width * length);
|
||||
for (int z = zzb; z <= zzt; z++) {
|
||||
final int rz = z - bz;
|
||||
final int i2 = i1 + (rz * width);
|
||||
for (int x = xxb; x <= xxt; x++) {
|
||||
final int rx = x - bx;
|
||||
final int index = i2 + rx;
|
||||
final Block block = worldObj.getBlockAt(x, y, z);
|
||||
final int id = block.getTypeId();
|
||||
switch (id) {
|
||||
case 0:
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 24:
|
||||
case 30:
|
||||
case 32:
|
||||
case 37:
|
||||
case 39:
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 51:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 60:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 73:
|
||||
case 74:
|
||||
case 78:
|
||||
case 79:
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
case 83:
|
||||
case 85:
|
||||
case 87:
|
||||
case 88:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 110:
|
||||
case 112:
|
||||
case 113:
|
||||
case 121:
|
||||
case 122:
|
||||
case 129:
|
||||
case 133:
|
||||
case 165:
|
||||
case 166:
|
||||
case 169:
|
||||
case 170:
|
||||
case 172:
|
||||
case 173:
|
||||
case 174:
|
||||
case 181:
|
||||
case 182:
|
||||
case 188:
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192: {
|
||||
break;
|
||||
}
|
||||
case 54:
|
||||
case 130:
|
||||
case 142:
|
||||
case 27:
|
||||
case 137:
|
||||
case 52:
|
||||
case 154:
|
||||
case 84:
|
||||
case 25:
|
||||
case 144:
|
||||
case 138:
|
||||
case 176:
|
||||
case 177:
|
||||
case 63:
|
||||
case 68:
|
||||
case 323:
|
||||
case 117:
|
||||
case 116:
|
||||
case 28:
|
||||
case 66:
|
||||
case 157:
|
||||
case 61:
|
||||
case 62:
|
||||
case 140:
|
||||
case 146:
|
||||
case 149:
|
||||
case 150:
|
||||
case 158:
|
||||
case 23:
|
||||
case 123:
|
||||
case 124:
|
||||
case 29:
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
// TODO implement fully
|
||||
final BlockState state = block.getState();
|
||||
if (state != null) {
|
||||
final StateWrapper wrapper = new StateWrapper(state);
|
||||
final CompoundTag rawTag = wrapper.getTag();
|
||||
if (rawTag != null) {
|
||||
final Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
values.put("id", new StringTag("id", wrapper.getId()));
|
||||
values.put("x", new IntTag("x", x));
|
||||
values.put("y", new IntTag("y", y));
|
||||
values.put("z", new IntTag("z", z));
|
||||
final CompoundTag tileEntityTag = new CompoundTag(values);
|
||||
tileEntities.add(tileEntityTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
blockData[index] = block.getData();
|
||||
}
|
||||
}
|
||||
// For optimization reasons, we are not supporting custom data types
|
||||
// Especially since the most likely reason beyond this range is modded servers in which the blocks
|
||||
// have NBT
|
||||
// if (type > 255) {
|
||||
// if (addBlocks == null) {
|
||||
// addBlocks = new byte[(blocks.length >> 1) + 1];
|
||||
// }
|
||||
// addBlocks[index >> 1] = (byte) (((index & 1) == 0) ?
|
||||
// (addBlocks[index >> 1] & 0xF0) | ((type >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((type
|
||||
// >> 8) & 0xF) << 4));
|
||||
// }
|
||||
blocks[index] = (byte) id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!chunks.isEmpty()) {
|
||||
TaskManager.runTaskLater(this, 1);
|
||||
} else {
|
||||
regionTask.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem) {
|
||||
new StateWrapper(ct).restoreTag(x, y, z, schem);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.jnbt.IntTag;
|
||||
import com.intellectualcrafters.jnbt.ListTag;
|
||||
import com.intellectualcrafters.jnbt.ShortTag;
|
||||
import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.object.schematic.StateWrapper;
|
||||
|
||||
/**
|
||||
* Schematic Handler
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class BukkitSchematicHandler extends SchematicHandler {
|
||||
|
||||
@Override
|
||||
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
|
||||
// async
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Main positions
|
||||
Location[] corners = MainUtil.getCorners(world, regions);
|
||||
final Location bot = corners[0];
|
||||
final Location top = corners[1];
|
||||
|
||||
final int width = (top.getX() - bot.getX()) + 1;
|
||||
final int height = (top.getY() - bot.getY()) + 1;
|
||||
final int length = (top.getZ() - bot.getZ()) + 1;
|
||||
// Main Schematic tag
|
||||
final HashMap<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||
schematic.put("Materials", new StringTag("Materials", "Alpha"));
|
||||
schematic.put("WEOriginX", new IntTag("WEOriginX", 0));
|
||||
schematic.put("WEOriginY", new IntTag("WEOriginY", 0));
|
||||
schematic.put("WEOriginZ", new IntTag("WEOriginZ", 0));
|
||||
schematic.put("WEOffsetX", new IntTag("WEOffsetX", 0));
|
||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
||||
// Arrays of data types
|
||||
final List<Tag> tileEntities = new ArrayList<>();
|
||||
final byte[] blocks = new byte[width * height * length];
|
||||
final byte[] blockData = new byte[width * height * length];
|
||||
// Queue
|
||||
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (queue.isEmpty()) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||
whenDone.value = new CompoundTag("Schematic", schematic);
|
||||
TaskManager.runTask(whenDone);
|
||||
System.gc();
|
||||
System.gc();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
final Runnable regionTask = this;
|
||||
RegionWrapper region = queue.poll();
|
||||
Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
|
||||
final int bx = bot.getX();
|
||||
final int bz = bot.getZ();
|
||||
final int p1x = pos1.getX();
|
||||
final int p1z = pos1.getZ();
|
||||
final int p2x = pos2.getX();
|
||||
final int p2z = pos2.getZ();
|
||||
final int bcx = p1x >> 4;
|
||||
final int bcz = p1z >> 4;
|
||||
final int tcx = p2x >> 4;
|
||||
final int tcz = p2z >> 4;
|
||||
final int sy = pos1.getY();
|
||||
final int ey = pos2.getY();
|
||||
// Generate list of chunks
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
for (int x = bcx; x <= tcx; x++) {
|
||||
for (int z = bcz; z <= tcz; z++) {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
}
|
||||
}
|
||||
final World worldObj = Bukkit.getWorld(world);
|
||||
// Main thread
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final long start = System.currentTimeMillis();
|
||||
while ((!chunks.isEmpty()) && ((System.currentTimeMillis() - start) < 20)) {
|
||||
// save schematics
|
||||
final ChunkLoc chunk = chunks.remove(0);
|
||||
final Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
|
||||
if (!bc.load(false)) {
|
||||
continue;
|
||||
}
|
||||
final int X = chunk.x;
|
||||
final int Z = chunk.z;
|
||||
int xxb = X << 4;
|
||||
int zzb = Z << 4;
|
||||
int xxt = xxb + 15;
|
||||
int zzt = zzb + 15;
|
||||
|
||||
if (X == bcx) {
|
||||
xxb = p1x;
|
||||
}
|
||||
if (X == tcx) {
|
||||
xxt = p2x;
|
||||
}
|
||||
if (Z == bcz) {
|
||||
zzb = p1z;
|
||||
}
|
||||
if (Z == tcz) {
|
||||
zzt = p2z;
|
||||
}
|
||||
for (int y = sy; y <= Math.min(255, ey); y++) {
|
||||
final int ry = y - sy;
|
||||
final int i1 = (ry * width * length);
|
||||
for (int z = zzb; z <= zzt; z++) {
|
||||
final int rz = z - bz;
|
||||
final int i2 = i1 + (rz * width);
|
||||
for (int x = xxb; x <= xxt; x++) {
|
||||
final int rx = x - bx;
|
||||
final int index = i2 + rx;
|
||||
final Block block = worldObj.getBlockAt(x, y, z);
|
||||
final int id = block.getTypeId();
|
||||
switch (id) {
|
||||
case 0:
|
||||
case 2:
|
||||
case 4:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 24:
|
||||
case 30:
|
||||
case 32:
|
||||
case 37:
|
||||
case 39:
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 51:
|
||||
case 55:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 60:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 73:
|
||||
case 74:
|
||||
case 78:
|
||||
case 79:
|
||||
case 80:
|
||||
case 81:
|
||||
case 82:
|
||||
case 83:
|
||||
case 85:
|
||||
case 87:
|
||||
case 88:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 110:
|
||||
case 112:
|
||||
case 113:
|
||||
case 121:
|
||||
case 122:
|
||||
case 129:
|
||||
case 133:
|
||||
case 165:
|
||||
case 166:
|
||||
case 169:
|
||||
case 170:
|
||||
case 172:
|
||||
case 173:
|
||||
case 174:
|
||||
case 181:
|
||||
case 182:
|
||||
case 188:
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192: {
|
||||
break;
|
||||
}
|
||||
case 54:
|
||||
case 130:
|
||||
case 142:
|
||||
case 27:
|
||||
case 137:
|
||||
case 52:
|
||||
case 154:
|
||||
case 84:
|
||||
case 25:
|
||||
case 144:
|
||||
case 138:
|
||||
case 176:
|
||||
case 177:
|
||||
case 63:
|
||||
case 68:
|
||||
case 323:
|
||||
case 117:
|
||||
case 116:
|
||||
case 28:
|
||||
case 66:
|
||||
case 157:
|
||||
case 61:
|
||||
case 62:
|
||||
case 140:
|
||||
case 146:
|
||||
case 149:
|
||||
case 150:
|
||||
case 158:
|
||||
case 23:
|
||||
case 123:
|
||||
case 124:
|
||||
case 29:
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
// TODO implement fully
|
||||
final BlockState state = block.getState();
|
||||
if (state != null) {
|
||||
final StateWrapper wrapper = new StateWrapper(state);
|
||||
final CompoundTag rawTag = wrapper.getTag();
|
||||
if (rawTag != null) {
|
||||
final Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
values.put("id", new StringTag("id", wrapper.getId()));
|
||||
values.put("x", new IntTag("x", x));
|
||||
values.put("y", new IntTag("y", y));
|
||||
values.put("z", new IntTag("z", z));
|
||||
final CompoundTag tileEntityTag = new CompoundTag(values);
|
||||
tileEntities.add(tileEntityTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
blockData[index] = block.getData();
|
||||
}
|
||||
}
|
||||
// For optimization reasons, we are not supporting custom data types
|
||||
// Especially since the most likely reason beyond this range is modded servers in which the blocks
|
||||
// have NBT
|
||||
// if (type > 255) {
|
||||
// if (addBlocks == null) {
|
||||
// addBlocks = new byte[(blocks.length >> 1) + 1];
|
||||
// }
|
||||
// addBlocks[index >> 1] = (byte) (((index & 1) == 0) ?
|
||||
// (addBlocks[index >> 1] & 0xF0) | ((type >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((type
|
||||
// >> 8) & 0xF) << 4));
|
||||
// }
|
||||
blocks[index] = (byte) id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!chunks.isEmpty()) {
|
||||
TaskManager.runTaskLater(this, 1);
|
||||
} else {
|
||||
regionTask.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem) {
|
||||
new StateWrapper(ct).restoreTag(x, y, z, schem);
|
||||
}
|
||||
}
|
@ -1,193 +1,193 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* An utility that can be used to send chunks, rather than using bukkit code to do so (uses heavy NMS)
|
||||
*
|
||||
|
||||
*/
|
||||
public class SendChunk {
|
||||
|
||||
// // Ref Class
|
||||
private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
private final RefClass classPacket = getRefClass("{nms}.Packet");
|
||||
private final RefClass classConnection = getRefClass("{nms}.PlayerConnection");
|
||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
||||
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
private final RefMethod methodGetHandlePlayer;
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
private final RefConstructor MapChunk;
|
||||
private final RefField connection;
|
||||
private final RefMethod send;
|
||||
private final RefMethod methodInitLighting;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SendChunk() {
|
||||
methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
methodInitLighting = classChunk.getMethod("initLighting");
|
||||
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||
connection = classEntityPlayer.getField("playerConnection");
|
||||
send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
|
||||
}
|
||||
|
||||
public void sendChunk(final Collection<Chunk> input) {
|
||||
final HashSet<Chunk> chunks = new HashSet<Chunk>(input);
|
||||
final HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
|
||||
final int view = Bukkit.getServer().getViewDistance();
|
||||
for (final Chunk chunk : chunks) {
|
||||
final String world = chunk.getWorld().getName();
|
||||
ArrayList<Chunk> list = map.get(world);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
map.put(world, list);
|
||||
}
|
||||
list.add(chunk);
|
||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||
methodInitLighting.of(c).call();
|
||||
}
|
||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
PlotPlayer pp = entry.getValue();
|
||||
final Plot plot = pp.getCurrentPlot();
|
||||
Location loc = null;
|
||||
String world;
|
||||
if (plot != null) {
|
||||
world = plot.getArea().worldname;
|
||||
} else {
|
||||
loc = pp.getLocation();
|
||||
world = loc.getWorld();
|
||||
}
|
||||
final ArrayList<Chunk> list = map.get(world);
|
||||
if (list == null) {
|
||||
continue;
|
||||
}
|
||||
if (loc == null) {
|
||||
loc = pp.getLocation();
|
||||
}
|
||||
final int cx = loc.getX() >> 4;
|
||||
final int cz = loc.getZ() >> 4;
|
||||
final Player player = ((BukkitPlayer) pp).player;
|
||||
final Object entity = methodGetHandlePlayer.of(player).call();
|
||||
|
||||
for (final Chunk chunk : list) {
|
||||
final int dx = Math.abs(cx - chunk.getX());
|
||||
final int dz = Math.abs(cz - chunk.getZ());
|
||||
if ((dx > view) || (dz > view)) {
|
||||
continue;
|
||||
}
|
||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||
chunks.remove(chunk);
|
||||
final Object con = connection.of(entity).get();
|
||||
// if (dx != 0 || dz != 0) {
|
||||
// Object packet = MapChunk.create(c, true, 0);
|
||||
// send.of(con).call(packet);
|
||||
// }
|
||||
final Object packet = MapChunk.create(c, true, 65535);
|
||||
send.of(con).call(packet);
|
||||
}
|
||||
}
|
||||
for (final Chunk chunk : chunks) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
chunk.unload(true, false);
|
||||
} catch (final Throwable e) {
|
||||
final String worldname = chunk.getWorld().getName();
|
||||
PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||
PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||
PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname
|
||||
+ "/level_old.dat may be corrupt (try repairing or removing these)");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//
|
||||
//
|
||||
// int diffx, diffz;
|
||||
// << 4;
|
||||
// for (final Chunk chunk : chunks) {
|
||||
// if (!chunk.isLoaded()) {
|
||||
// continue;
|
||||
// }
|
||||
// boolean unload = true;
|
||||
// final Object c = methodGetHandle.of(chunk).call();
|
||||
// final Object w = world.of(c).get();
|
||||
// final Object p = players.of(w).get();
|
||||
// for (final Object ep : (List<Object>) p) {
|
||||
// final int x = ((Double) locX.of(ep).get()).intValue();
|
||||
// final int z = ((Double) locZ.of(ep).get()).intValue();
|
||||
// diffx = Math.abs(x - (chunk.getX() << 4));
|
||||
// diffz = Math.abs(z - (chunk.getZ() << 4));
|
||||
// if ((diffx <= view) && (diffz <= view)) {
|
||||
// unload = false;
|
||||
// if (v1_7_10) {
|
||||
// chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
// chunk.load(true);
|
||||
// }
|
||||
// else {
|
||||
// final Object pair = ChunkCoordIntPairCon.create(chunk.getX(), chunk.getZ());
|
||||
// final Object pq = chunkCoordIntPairQueue.of(ep).get();
|
||||
// ((List) pq).add(pair);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (unload) {
|
||||
// TaskManager.runTask(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// try {
|
||||
// chunk.unload(true, true);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// String worldname = chunk.getWorld().getName();
|
||||
// PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||
// PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||
// PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname + "level_old.dat may be corrupt (try repairing
|
||||
// or removing these)");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
public void sendChunk(final String worldname, final List<ChunkLoc> locs) {
|
||||
final World myworld = Bukkit.getWorld(worldname);
|
||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
for (final ChunkLoc loc : locs) {
|
||||
chunks.add(myworld.getChunkAt(loc.x, loc.z));
|
||||
}
|
||||
sendChunk(chunks);
|
||||
}
|
||||
}
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* An utility that can be used to send chunks, rather than using bukkit code to do so (uses heavy NMS)
|
||||
*
|
||||
|
||||
*/
|
||||
public class SendChunk {
|
||||
|
||||
// // Ref Class
|
||||
private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
private final RefClass classPacket = getRefClass("{nms}.Packet");
|
||||
private final RefClass classConnection = getRefClass("{nms}.PlayerConnection");
|
||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
||||
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||
private final RefMethod methodGetHandlePlayer;
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
private final RefConstructor MapChunk;
|
||||
private final RefField connection;
|
||||
private final RefMethod send;
|
||||
private final RefMethod methodInitLighting;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SendChunk() {
|
||||
methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
methodInitLighting = classChunk.getMethod("initLighting");
|
||||
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||
connection = classEntityPlayer.getField("playerConnection");
|
||||
send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
|
||||
}
|
||||
|
||||
public void sendChunk(final Collection<Chunk> input) {
|
||||
final HashSet<Chunk> chunks = new HashSet<Chunk>(input);
|
||||
final HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
|
||||
final int view = Bukkit.getServer().getViewDistance();
|
||||
for (final Chunk chunk : chunks) {
|
||||
final String world = chunk.getWorld().getName();
|
||||
ArrayList<Chunk> list = map.get(world);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
map.put(world, list);
|
||||
}
|
||||
list.add(chunk);
|
||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||
methodInitLighting.of(c).call();
|
||||
}
|
||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
PlotPlayer pp = entry.getValue();
|
||||
final Plot plot = pp.getCurrentPlot();
|
||||
Location loc = null;
|
||||
String world;
|
||||
if (plot != null) {
|
||||
world = plot.getArea().worldname;
|
||||
} else {
|
||||
loc = pp.getLocation();
|
||||
world = loc.getWorld();
|
||||
}
|
||||
final ArrayList<Chunk> list = map.get(world);
|
||||
if (list == null) {
|
||||
continue;
|
||||
}
|
||||
if (loc == null) {
|
||||
loc = pp.getLocation();
|
||||
}
|
||||
final int cx = loc.getX() >> 4;
|
||||
final int cz = loc.getZ() >> 4;
|
||||
final Player player = ((BukkitPlayer) pp).player;
|
||||
final Object entity = methodGetHandlePlayer.of(player).call();
|
||||
|
||||
for (final Chunk chunk : list) {
|
||||
final int dx = Math.abs(cx - chunk.getX());
|
||||
final int dz = Math.abs(cz - chunk.getZ());
|
||||
if ((dx > view) || (dz > view)) {
|
||||
continue;
|
||||
}
|
||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||
chunks.remove(chunk);
|
||||
final Object con = connection.of(entity).get();
|
||||
// if (dx != 0 || dz != 0) {
|
||||
// Object packet = MapChunk.create(c, true, 0);
|
||||
// send.of(con).call(packet);
|
||||
// }
|
||||
final Object packet = MapChunk.create(c, true, 65535);
|
||||
send.of(con).call(packet);
|
||||
}
|
||||
}
|
||||
for (final Chunk chunk : chunks) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
chunk.unload(true, false);
|
||||
} catch (final Throwable e) {
|
||||
final String worldname = chunk.getWorld().getName();
|
||||
PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||
PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||
PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname
|
||||
+ "/level_old.dat may be corrupt (try repairing or removing these)");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//
|
||||
//
|
||||
// int diffx, diffz;
|
||||
// << 4;
|
||||
// for (final Chunk chunk : chunks) {
|
||||
// if (!chunk.isLoaded()) {
|
||||
// continue;
|
||||
// }
|
||||
// boolean unload = true;
|
||||
// final Object c = methodGetHandle.of(chunk).call();
|
||||
// final Object w = world.of(c).get();
|
||||
// final Object p = players.of(w).get();
|
||||
// for (final Object ep : (List<Object>) p) {
|
||||
// final int x = ((Double) locX.of(ep).get()).intValue();
|
||||
// final int z = ((Double) locZ.of(ep).get()).intValue();
|
||||
// diffx = Math.abs(x - (chunk.getX() << 4));
|
||||
// diffz = Math.abs(z - (chunk.getZ() << 4));
|
||||
// if ((diffx <= view) && (diffz <= view)) {
|
||||
// unload = false;
|
||||
// if (v1_7_10) {
|
||||
// chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
// chunk.load(true);
|
||||
// }
|
||||
// else {
|
||||
// final Object pair = ChunkCoordIntPairCon.create(chunk.getX(), chunk.getZ());
|
||||
// final Object pq = chunkCoordIntPairQueue.of(ep).get();
|
||||
// ((List) pq).add(pair);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (unload) {
|
||||
// TaskManager.runTask(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// try {
|
||||
// chunk.unload(true, true);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// String worldname = chunk.getWorld().getName();
|
||||
// PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||
// PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||
// PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname + "level_old.dat may be corrupt (try repairing
|
||||
// or removing these)");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
public void sendChunk(final String worldname, final List<ChunkLoc> locs) {
|
||||
final World myworld = Bukkit.getWorld(worldname);
|
||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
for (final ChunkLoc loc : locs) {
|
||||
chunks.add(myworld.getChunkAt(loc.x, loc.z));
|
||||
}
|
||||
sendChunk(chunks);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
name: ${project.name}
|
||||
name: $name
|
||||
main: com.plotsquared.bukkit.BukkitMain
|
||||
version: ${project.version}
|
||||
version: $version
|
||||
load: STARTUP
|
||||
description: >
|
||||
Easy, yet powerful Plot World generation and management.
|
2
Core/build.gradle
Normal file
2
Core/build.gradle
Normal file
@ -0,0 +1,2 @@
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user