mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-15 03:44:43 +02:00
Compare commits
51 Commits
Author | SHA1 | Date | |
---|---|---|---|
f00ac79c91 | |||
109715e0d7 | |||
8bf3ceac6f | |||
106c3c5cb4 | |||
0bbfd0f49a | |||
9596544f97 | |||
5079361fbf | |||
b0a3f70cbd | |||
841809b93d | |||
43b7a7aba8 | |||
8906577699 | |||
224caee56e | |||
5c4178b1dd | |||
911bef974a | |||
7d340b58b4 | |||
ce8775414a | |||
5da8700f7f | |||
01710e3ddb | |||
7d8893b5d7 | |||
7a97c69d4f | |||
1a80b344b9 | |||
afe6c5fd69 | |||
f68042bc11 | |||
ac77c755d0 | |||
c7870b617c | |||
f921db937a | |||
4669f31658 | |||
c8ddcd7f54 | |||
fb2e949711 | |||
7659884e73 | |||
efae2c2e63 | |||
d3465b7bde | |||
f73a542b04 | |||
6f3485c87d | |||
bf85ba5833 | |||
8a2c44759f | |||
882394987b | |||
7a217b2f08 | |||
b94e816c55 | |||
87ee693a49 | |||
1768651782 | |||
b69e31129d | |||
7b15d50674 | |||
f996b1d95d | |||
14eb3279c0 | |||
ced342f14e | |||
f5ff82c8cc | |||
b255c5db47 | |||
ca5e7f4564 | |||
ef5846f688 | |||
36ebd1983d |
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,6 +3,9 @@
|
|||||||
*.cmd
|
*.cmd
|
||||||
*.sh
|
*.sh
|
||||||
*.prefs
|
*.prefs
|
||||||
|
Sponge/build
|
||||||
|
Core/build
|
||||||
|
Bukkit/build
|
||||||
|
|
||||||
### Maven ###
|
### Maven ###
|
||||||
/target/lib
|
/target/lib
|
||||||
@ -59,6 +62,7 @@ hs_err_pid*
|
|||||||
# Gradle:
|
# Gradle:
|
||||||
# .idea/gradle.xml
|
# .idea/gradle.xml
|
||||||
# .idea/libraries
|
# .idea/libraries
|
||||||
|
.gradle
|
||||||
|
|
||||||
# Mongo Explorer plugin:
|
# Mongo Explorer plugin:
|
||||||
# .idea/mongoSettings.xml
|
# .idea/mongoSettings.xml
|
||||||
|
35
Bukkit/build.gradle
Normal file
35
Bukkit/build.gradle
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
dependencies {
|
||||||
|
compile project(':Core')
|
||||||
|
compile 'org.bukkit:bukkit:1.9-R0.1-SNAPSHOT'
|
||||||
|
compile 'net.milkbowl.vault:VaultAPI:1.5'
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = 1.7
|
||||||
|
targetCompatibility = 1.7
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
from('src/main/resources') {
|
||||||
|
include 'plugin.yml'
|
||||||
|
expand(
|
||||||
|
name: project.parent.name,
|
||||||
|
version: project.parent.version
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.github.johnrengelman.shadow'
|
||||||
|
// We only want the shadow jar produced
|
||||||
|
jar.enabled = false
|
||||||
|
shadowJar {
|
||||||
|
dependencies {
|
||||||
|
include(dependency(':Core'))
|
||||||
|
}
|
||||||
|
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
||||||
|
destinationDir = file '../target'
|
||||||
|
}
|
||||||
|
shadowJar.doLast {
|
||||||
|
task ->
|
||||||
|
ant.checksum file: task.archivePath
|
||||||
|
}
|
||||||
|
|
||||||
|
build.dependsOn(shadowJar);
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +1,5 @@
|
|||||||
package com.plotsquared.bukkit;
|
package com.plotsquared.bukkit;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
import org.bukkit.metadata.MetadataValue;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||||
import com.intellectualcrafters.plot.IPlotMain;
|
import com.intellectualcrafters.plot.IPlotMain;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
@ -37,67 +12,40 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
|||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
|
||||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
|
||||||
import com.intellectualcrafters.plot.util.ChatManager;
|
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
|
||||||
import com.intellectualcrafters.plot.util.ConsoleColors;
|
|
||||||
import com.intellectualcrafters.plot.util.EconHandler;
|
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.InventoryUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.PlotQueue;
|
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
|
||||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
import com.plotsquared.bukkit.commands.DebugUUID;
|
import com.plotsquared.bukkit.commands.DebugUUID;
|
||||||
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
|
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
|
||||||
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
||||||
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.plotsquared.bukkit.listeners.ChunkListener;
|
import com.plotsquared.bukkit.listeners.*;
|
||||||
import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
|
||||||
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
|
||||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
|
||||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
|
|
||||||
import com.plotsquared.bukkit.listeners.PlotPlusListener;
|
|
||||||
import com.plotsquared.bukkit.listeners.WorldEvents;
|
|
||||||
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
|
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
|
||||||
import com.plotsquared.bukkit.titles.DefaultTitle;
|
import com.plotsquared.bukkit.titles.DefaultTitle;
|
||||||
import com.plotsquared.bukkit.util.BukkitChatManager;
|
import com.plotsquared.bukkit.util.*;
|
||||||
import com.plotsquared.bukkit.util.BukkitChunkManager;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitCommand;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitEconHandler;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitEventUtil;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitPlainChatManager;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitSchematicHandler;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
|
||||||
import com.plotsquared.bukkit.util.Metrics;
|
|
||||||
import com.plotsquared.bukkit.util.SendChunk;
|
|
||||||
import com.plotsquared.bukkit.util.SetGenCB;
|
|
||||||
import com.plotsquared.bukkit.util.block.FastQueue_1_7;
|
import com.plotsquared.bukkit.util.block.FastQueue_1_7;
|
||||||
import com.plotsquared.bukkit.util.block.FastQueue_1_8;
|
import com.plotsquared.bukkit.util.block.FastQueue_1_8;
|
||||||
import com.plotsquared.bukkit.util.block.FastQueue_1_8_3;
|
import com.plotsquared.bukkit.util.block.FastQueue_1_8_3;
|
||||||
import com.plotsquared.bukkit.util.block.SlowQueue;
|
import com.plotsquared.bukkit.util.block.SlowQueue;
|
||||||
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
import com.plotsquared.bukkit.uuid.*;
|
||||||
import com.plotsquared.bukkit.uuid.FileUUIDHandler;
|
|
||||||
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
|
||||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
|
||||||
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||||
|
|
||||||
@ -346,19 +294,10 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
||||||
WorldEvents.lastWorld = world;
|
|
||||||
final HybridGen result = new HybridGen();
|
final HybridGen result = new HybridGen();
|
||||||
if (!PS.get().setupPlotWorld(world, id, result)) {
|
if (!PS.get().setupPlotWorld(world, id, result)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if ((WorldEvents.lastWorld != null) && WorldEvents.lastWorld.equals(world)) {
|
|
||||||
WorldEvents.lastWorld = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
return (ChunkGenerator) result.specify();
|
return (ChunkGenerator) result.specify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,11 +369,11 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
||||||
try {
|
try {
|
||||||
return new FastQueue_1_8_3();
|
return new FastQueue_1_8_3();
|
||||||
} catch (NoSuchMethodException | RuntimeException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
try {
|
try {
|
||||||
return new FastQueue_1_8();
|
return new FastQueue_1_8();
|
||||||
} catch (NoSuchMethodException e2) {
|
} catch (Throwable e2) {
|
||||||
e2.printStackTrace();
|
e2.printStackTrace();
|
||||||
return new SlowQueue();
|
return new SlowQueue();
|
||||||
}
|
}
|
||||||
@ -442,7 +381,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return new FastQueue_1_7();
|
return new FastQueue_1_7();
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
return new SlowQueue();
|
return new SlowQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,404 +1,406 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
// /
|
// /
|
||||||
// This program is free software; you can redistribute it and/or modify /
|
// 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 /
|
// it under the terms of the GNU General Public License as published by /
|
||||||
// the Free Software Foundation; either version 3 of the License, or /
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
// (at your option) any later version. /
|
// (at your option) any later version. /
|
||||||
// /
|
// /
|
||||||
// This program is distributed in the hope that it will be useful, /
|
// This program is distributed in the hope that it will be useful, /
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
// GNU General Public License for more details. /
|
// GNU General Public License for more details. /
|
||||||
// /
|
// /
|
||||||
// You should have received a copy of the GNU General Public License /
|
// You should have received a copy of the GNU General Public License /
|
||||||
// along with this program; if not, write to the Free Software Foundation, /
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.plotsquared.bukkit.database.plotme;
|
package com.plotsquared.bukkit.database.plotme;
|
||||||
|
|
||||||
import java.io.File;
|
import com.intellectualcrafters.configuration.MemorySection;
|
||||||
import java.io.IOException;
|
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
||||||
import java.nio.charset.Charset;
|
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||||
import java.nio.charset.StandardCharsets;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import java.nio.file.Files;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import java.nio.file.Path;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import java.nio.file.Paths;
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
import java.sql.Connection;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import java.util.ArrayList;
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
import java.util.Collections;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import java.util.HashMap;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import java.util.Map.Entry;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import java.util.Set;
|
import org.bukkit.Bukkit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
import java.io.File;
|
||||||
import org.bukkit.WorldCreator;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
import java.nio.charset.StandardCharsets;
|
||||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
import java.nio.file.Files;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import java.nio.file.Path;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import java.nio.file.Paths;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import java.sql.Connection;
|
||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
import java.util.ArrayList;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import java.util.Collections;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import java.util.HashMap;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import java.util.Map.Entry;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import java.util.Set;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created 2014-08-17 for PlotSquared
|
* Created 2014-08-17 for PlotSquared
|
||||||
*
|
*
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public class LikePlotMeConverter {
|
public class LikePlotMeConverter {
|
||||||
private final String plugin;
|
private final String plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param plugin Plugin Used to run the converter
|
* @param plugin Plugin Used to run the converter
|
||||||
*/
|
*/
|
||||||
public LikePlotMeConverter(final String plugin) {
|
public LikePlotMeConverter(final String plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getWorld(final String world) {
|
public static String getWorld(final String world) {
|
||||||
for (final World newworld : Bukkit.getWorlds()) {
|
for (final World newworld : Bukkit.getWorlds()) {
|
||||||
if (newworld.getName().equalsIgnoreCase(world)) {
|
if (newworld.getName().equalsIgnoreCase(world)) {
|
||||||
return newworld.getName();
|
return newworld.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(final String message) {
|
private void sendMessage(final String message) {
|
||||||
PS.debug("&3PlotMe&8->&3PlotSquared&8: &7" + message);
|
PS.debug("&3PlotMe&8->&3PlotSquared&8: &7" + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlotMePath() {
|
public String getPlotMePath() {
|
||||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
|
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAthionPlotsPath() {
|
public String getAthionPlotsPath() {
|
||||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
|
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileConfiguration getPlotMeConfig(final String dataFolder) {
|
public FileConfiguration getPlotMeConfig(final String dataFolder) {
|
||||||
final File plotMeFile = new File(dataFolder + "config.yml");
|
final File plotMeFile = new File(dataFolder + "config.yml");
|
||||||
if (!plotMeFile.exists()) {
|
if (!plotMeFile.exists()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return YamlConfiguration.loadConfiguration(plotMeFile);
|
return YamlConfiguration.loadConfiguration(plotMeFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getPlotMeWorlds(final FileConfiguration plotConfig) {
|
public Set<String> getPlotMeWorlds(final FileConfiguration plotConfig) {
|
||||||
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mergeWorldYml(final String plugin, FileConfiguration plotConfig) {
|
public void mergeWorldYml(final String plugin, FileConfiguration plotConfig) {
|
||||||
try {
|
try {
|
||||||
File genConfig = new File("plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
File genConfig = new File("plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||||
if (genConfig.exists()) {
|
if (genConfig.exists()) {
|
||||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
|
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
|
||||||
for (String key : yml.getKeys(true)) {
|
for (String key : yml.getKeys(true)) {
|
||||||
if (!plotConfig.contains(key)) {
|
if (!plotConfig.contains(key)) {
|
||||||
plotConfig.set(key, yml.get(key));
|
Object value = yml.get(key);
|
||||||
}
|
if (!(value instanceof MemorySection)) {
|
||||||
}
|
plotConfig.set(key, value);
|
||||||
genConfig.delete();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
}
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
catch (Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
public void updateWorldYml(final String plugin, final String location) {
|
}
|
||||||
try {
|
|
||||||
final Path path = Paths.get(location);
|
public void updateWorldYml(final String plugin, final String location) {
|
||||||
final File file = new File(location);
|
try {
|
||||||
if (!file.exists()) {
|
final Path path = Paths.get(location);
|
||||||
return;
|
final File file = new File(location);
|
||||||
}
|
if (!file.exists()) {
|
||||||
final Charset charset = StandardCharsets.UTF_8;
|
return;
|
||||||
String content = new String(Files.readAllBytes(path), charset);
|
}
|
||||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
final Charset charset = StandardCharsets.UTF_8;
|
||||||
content = content.replaceAll(plugin, "PlotSquared");
|
String content = new String(Files.readAllBytes(path), charset);
|
||||||
Files.write(path, content.getBytes(charset));
|
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||||
} catch (IOException e) {
|
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();
|
public boolean run(final APlotMeConnector connector) {
|
||||||
final FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
try {
|
||||||
if (plotConfig == null) {
|
final String dataFolder = getPlotMePath();
|
||||||
return false;
|
final FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
||||||
}
|
if (plotConfig == null) {
|
||||||
|
return false;
|
||||||
String version = plotConfig.getString("Version");
|
}
|
||||||
if (version == null) {
|
|
||||||
version = plotConfig.getString("version");
|
String version = plotConfig.getString("Version");
|
||||||
}
|
if (version == null) {
|
||||||
if (!connector.accepts(version)) {
|
version = plotConfig.getString("version");
|
||||||
return false;
|
}
|
||||||
}
|
if (!connector.accepts(version)) {
|
||||||
|
return false;
|
||||||
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
}
|
||||||
|
|
||||||
final Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
|
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
||||||
|
|
||||||
if (!connector.isValidConnection(connection)) {
|
final Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
|
||||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
|
||||||
return false;
|
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(plugin + " conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||||
|
|
||||||
sendMessage("Connecting to " + plugin + " DB");
|
mergeWorldYml(plugin, plotConfig);
|
||||||
|
|
||||||
int plotCount = 0;
|
sendMessage("Connecting to " + plugin + " DB");
|
||||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
|
||||||
|
int plotCount = 0;
|
||||||
sendMessage("Collecting plot data");
|
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||||
|
|
||||||
final String dbPrefix = plugin.toLowerCase();
|
sendMessage("Collecting plot data");
|
||||||
sendMessage(" - " + dbPrefix + "Plots");
|
|
||||||
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
final String dbPrefix = plugin.toLowerCase();
|
||||||
|
sendMessage(" - " + dbPrefix + "Plots");
|
||||||
if (Settings.CONVERT_PLOTME) {
|
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
||||||
sendMessage("Updating bukkit.yml");
|
|
||||||
updateWorldYml(plugin, "bukkit.yml");
|
if (Settings.CONVERT_PLOTME) {
|
||||||
updateWorldYml(plugin, "plugins/Multiverse-Core/worlds.yml");
|
sendMessage("Updating bukkit.yml");
|
||||||
for (final String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
|
updateWorldYml(plugin, "bukkit.yml");
|
||||||
sendMessage("Copying config for: " + world);
|
updateWorldYml(plugin, "plugins/Multiverse-Core/worlds.yml");
|
||||||
try {
|
for (final String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
|
||||||
final String actualWorldName = getWorld(world);
|
sendMessage("Copying config for: " + world);
|
||||||
connector.copyConfig(plotConfig, world, actualWorldName);
|
try {
|
||||||
PS.get().config.save(PS.get().configFile);
|
final String actualWorldName = getWorld(world);
|
||||||
} catch (final Exception e) {
|
connector.copyConfig(plotConfig, world, actualWorldName);
|
||||||
e.printStackTrace();
|
PS.get().config.save(PS.get().configFile);
|
||||||
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
} 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();
|
final HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
||||||
}
|
for (final Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||||
if (!Settings.CONVERT_PLOTME) {
|
plotCount += entry.getValue().size();
|
||||||
return false;
|
}
|
||||||
}
|
if (!Settings.CONVERT_PLOTME) {
|
||||||
|
return false;
|
||||||
sendMessage(" - " + dbPrefix + "Allowed");
|
}
|
||||||
|
|
||||||
sendMessage("Collected " + plotCount + " plots from PlotMe");
|
sendMessage(" - " + dbPrefix + "Allowed");
|
||||||
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
|
||||||
if (PLOTME_DG_FILE.exists()) {
|
sendMessage("Collected " + plotCount + " plots from PlotMe");
|
||||||
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||||
try {
|
if (PLOTME_DG_FILE.exists()) {
|
||||||
for (final String world : plots.keySet()) {
|
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
||||||
final String actualWorldName = getWorld(world);
|
try {
|
||||||
final String plotMeWorldName = world.toLowerCase();
|
for (final String world : plots.keySet()) {
|
||||||
Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
final String actualWorldName = getWorld(world);
|
||||||
/*
|
final String plotMeWorldName = world.toLowerCase();
|
||||||
* TODO: dead code
|
Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||||
*
|
/*
|
||||||
if (pathwidth == null) {
|
* TODO: dead code
|
||||||
pathwidth = 7;
|
*
|
||||||
}
|
if (pathwidth == null) {
|
||||||
*/
|
pathwidth = 7;
|
||||||
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
|
}
|
||||||
|
*/
|
||||||
Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
|
||||||
if ((pathheight == null) || (pathheight == 0)) {
|
|
||||||
pathheight = 64;
|
Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||||
}
|
if (pathheight == 0) {
|
||||||
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
pathheight = 64;
|
||||||
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
}
|
||||||
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
||||||
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
||||||
if ((plotsize == null) || (plotsize == 0)) {
|
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
||||||
plotsize = 32;
|
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||||
}
|
if (plotsize == 0) {
|
||||||
PS.get().config.set("worlds." + world + ".plot.size", plotsize);
|
plotsize = 32;
|
||||||
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
|
}
|
||||||
if (wallblock == null) {
|
PS.get().config.set("worlds." + world + ".plot.size", plotsize);
|
||||||
wallblock = "44";
|
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
|
||||||
}
|
if (wallblock == null) {
|
||||||
PS.get().config.set("worlds." + world + ".wall.block", wallblock);
|
wallblock = "44";
|
||||||
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
|
}
|
||||||
if (floor == null) {
|
PS.get().config.set("worlds." + world + ".wall.block", wallblock);
|
||||||
floor = "2";
|
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
|
||||||
}
|
if (floor == null) {
|
||||||
PS.get().config.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
|
floor = "2";
|
||||||
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
}
|
||||||
if (filling == null) {
|
PS.get().config.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
|
||||||
filling = "3";
|
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
||||||
}
|
if (filling == null) {
|
||||||
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
filling = "3";
|
||||||
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
}
|
||||||
if (road == null) {
|
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
||||||
road = "5";
|
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
||||||
}
|
if (road == null) {
|
||||||
PS.get().config.set("worlds." + world + ".road.block", road);
|
road = "5";
|
||||||
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
}
|
||||||
if (height == 0) {
|
PS.get().config.set("worlds." + world + ".road.block", road);
|
||||||
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||||
if (height == 0) {
|
if (height == 0) {
|
||||||
height = 64;
|
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.set("worlds." + actualWorldName + ".road.height", height);
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.set("worlds." + actualWorldName + ".plot.height", height);
|
||||||
}
|
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
|
||||||
} catch (IOException e) {
|
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);
|
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||||
int duplicate = 0;
|
String world = entry.getKey();
|
||||||
if (area != null) {
|
PlotArea area = PS.get().getPlotArea(world, null);
|
||||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
int duplicate = 0;
|
||||||
if (area.getOwnedPlotAbs(entry2.getKey()) != null) {
|
if (area != null) {
|
||||||
duplicate++;
|
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||||
} else {
|
if (area.getOwnedPlotAbs(entry2.getKey()) != null) {
|
||||||
createdPlots.add(entry2.getValue());
|
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?");
|
}
|
||||||
}
|
if (duplicate > 0) {
|
||||||
} else {
|
PS.debug("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
|
||||||
if (PS.get().plots_tmp != null) {
|
}
|
||||||
HashMap<PlotId, Plot> map = PS.get().plots_tmp.get(world);
|
} else {
|
||||||
if (map != null) {
|
if (PS.get().plots_tmp != null) {
|
||||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
HashMap<PlotId, Plot> map = PS.get().plots_tmp.get(world);
|
||||||
if (map.containsKey(entry2.getKey())) {
|
if (map != null) {
|
||||||
duplicate++;
|
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||||
} else {
|
if (map.containsKey(entry2.getKey())) {
|
||||||
createdPlots.add(entry2.getValue());
|
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?");
|
}
|
||||||
}
|
if (duplicate > 0) {
|
||||||
continue;
|
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());
|
}
|
||||||
}
|
}
|
||||||
}
|
createdPlots.addAll(entry.getValue().values());
|
||||||
sendMessage("Creating plot DB");
|
}
|
||||||
Thread.sleep(1000);
|
}
|
||||||
final AtomicBoolean done = new AtomicBoolean(false);
|
sendMessage("Creating plot DB");
|
||||||
DBFunc.createPlotsAndData(createdPlots, new Runnable() {
|
Thread.sleep(1000);
|
||||||
@Override
|
final AtomicBoolean done = new AtomicBoolean(false);
|
||||||
public void run() {
|
DBFunc.createPlotsAndData(createdPlots, new Runnable() {
|
||||||
if (done.get()) {
|
@Override
|
||||||
done();
|
public void run() {
|
||||||
sendMessage("&aDatabase conversion is now complete!");
|
if (done.get()) {
|
||||||
PS.debug("&c - Stop the server");
|
done();
|
||||||
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
sendMessage("&aDatabase conversion is now complete!");
|
||||||
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
PS.debug("&c - Stop the server");
|
||||||
PS.debug("&c - Start the server");
|
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||||
PS.get().setPlots(DBFunc.getPlots());
|
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||||
} else {
|
PS.debug("&c - Start the server");
|
||||||
sendMessage("&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
|
PS.get().setPlots(DBFunc.getPlots());
|
||||||
done.set(true);
|
} 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);
|
sendMessage("Saving configuration...");
|
||||||
} catch (final IOException e) {
|
try {
|
||||||
sendMessage(" - &cFailed to save configuration.");
|
PS.get().config.save(PS.get().configFile);
|
||||||
}
|
} catch (final IOException e) {
|
||||||
TaskManager.runTask(new Runnable() {
|
sendMessage(" - &cFailed to save configuration.");
|
||||||
@Override
|
}
|
||||||
public void run() {
|
TaskManager.runTask(new Runnable() {
|
||||||
try {
|
@Override
|
||||||
boolean MV = false;
|
public void run() {
|
||||||
boolean MW = false;
|
try {
|
||||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
boolean MV = false;
|
||||||
MV = true;
|
boolean MW = false;
|
||||||
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||||
MW = true;
|
MV = true;
|
||||||
}
|
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||||
for (final String worldname : worlds) {
|
MW = true;
|
||||||
final World world = Bukkit.getWorld(getWorld(worldname));
|
}
|
||||||
if (world == null) {
|
for (final String worldname : worlds) {
|
||||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
final World world = Bukkit.getWorld(getWorld(worldname));
|
||||||
}
|
if (world == null) {
|
||||||
final String actualWorldName = world.getName();
|
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
||||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
}
|
||||||
PS.get().removePlotAreas(actualWorldName);
|
final String actualWorldName = world.getName();
|
||||||
if (MV) {
|
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||||
// unload world with MV
|
PS.get().removePlotAreas(actualWorldName);
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
if (MV) {
|
||||||
try {
|
// unload world with MV
|
||||||
Thread.sleep(1000);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
||||||
} catch (final InterruptedException ex) {
|
try {
|
||||||
Thread.currentThread().interrupt();
|
Thread.sleep(1000);
|
||||||
}
|
} catch (final InterruptedException ex) {
|
||||||
// load world with MV
|
Thread.currentThread().interrupt();
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared");
|
}
|
||||||
} else if (MW) {
|
// load world with MV
|
||||||
// unload world with MW
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared");
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
} else if (MW) {
|
||||||
try {
|
// unload world with MW
|
||||||
Thread.sleep(1000);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
||||||
} catch (final InterruptedException ex) {
|
try {
|
||||||
Thread.currentThread().interrupt();
|
Thread.sleep(1000);
|
||||||
}
|
} catch (final InterruptedException ex) {
|
||||||
// load world with MW
|
Thread.currentThread().interrupt();
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared");
|
}
|
||||||
} else {
|
// load world with MW
|
||||||
// Load using Bukkit API
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared");
|
||||||
// - User must set generator manually
|
} else {
|
||||||
Bukkit.getServer().unloadWorld(world, true);
|
// Load using Bukkit API
|
||||||
final World myworld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
// - User must set generator manually
|
||||||
myworld.save();
|
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();
|
}
|
||||||
}
|
} catch (final Exception e) {
|
||||||
if (done.get()) {
|
e.printStackTrace();
|
||||||
done();
|
}
|
||||||
sendMessage("&aDatabase conversion is now complete!");
|
if (done.get()) {
|
||||||
PS.debug("&c - Stop the server");
|
done();
|
||||||
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
sendMessage("&aDatabase conversion is now complete!");
|
||||||
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
PS.debug("&c - Stop the server");
|
||||||
PS.debug("&c - Start the server");
|
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||||
} else {
|
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||||
sendMessage("&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
|
PS.debug("&c - Start the server");
|
||||||
done.set(true);
|
} 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/");
|
} catch (final Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
return true;
|
PS.debug("&/end/");
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
public void done() {
|
}
|
||||||
PS.get().setPlots(DBFunc.getPlots());
|
|
||||||
}
|
public void done() {
|
||||||
}
|
PS.get().setPlots(DBFunc.getPlots());
|
||||||
|
}
|
||||||
|
}
|
@ -24,12 +24,10 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class PlotMeConnector_017 extends APlotMeConnector {
|
public class PlotMeConnector_017 extends APlotMeConnector {
|
||||||
private String plugin;
|
private String plugin;
|
||||||
private String prefix;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) {
|
public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) {
|
||||||
this.plugin = plugin.toLowerCase();
|
this.plugin = plugin.toLowerCase();
|
||||||
prefix = plugin + "core_";
|
|
||||||
try {
|
try {
|
||||||
if (plotConfig.getBoolean("usemySQL")) {
|
if (plotConfig.getBoolean("usemySQL")) {
|
||||||
final String user = plotConfig.getString("mySQLuname");
|
final String user = plotConfig.getString("mySQLuname");
|
@ -1,89 +1,89 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
// /
|
// /
|
||||||
// This program is free software; you can redistribute it and/or modify /
|
// 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 /
|
// it under the terms of the GNU General Public License as published by /
|
||||||
// the Free Software Foundation; either version 3 of the License, or /
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
// (at your option) any later version. /
|
// (at your option) any later version. /
|
||||||
// /
|
// /
|
||||||
// This program is distributed in the hope that it will be useful, /
|
// This program is distributed in the hope that it will be useful, /
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
// GNU General Public License for more details. /
|
// GNU General Public License for more details. /
|
||||||
// /
|
// /
|
||||||
// You should have received a copy of the GNU General Public License /
|
// You should have received a copy of the GNU General Public License /
|
||||||
// along with this program; if not, write to the Free Software Foundation, /
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.plotsquared.bukkit.events;
|
package com.plotsquared.bukkit.events;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a flag is removed from a plot
|
* Called when a flag is removed from a plot
|
||||||
*
|
*
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public class ClusterFlagRemoveEvent extends Event implements Cancellable {
|
public class ClusterFlagRemoveEvent extends Event implements Cancellable {
|
||||||
private static HandlerList handlers = new HandlerList();
|
private static HandlerList handlers = new HandlerList();
|
||||||
private final PlotCluster cluster;
|
private final PlotCluster cluster;
|
||||||
private final Flag flag;
|
private final Flag flag;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
||||||
*
|
*
|
||||||
* @param flag Flag that was removed
|
* @param flag Flag that was removed
|
||||||
* @param cluster PlotCluster from which the flag was removed
|
* @param cluster PlotCluster from which the flag was removed
|
||||||
*/
|
*/
|
||||||
public ClusterFlagRemoveEvent(final Flag flag, final PlotCluster cluster) {
|
public ClusterFlagRemoveEvent(final Flag flag, final PlotCluster cluster) {
|
||||||
this.cluster = cluster;
|
this.cluster = cluster;
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cluster involved
|
* Get the cluster involved
|
||||||
*
|
*
|
||||||
* @return PlotCluster
|
* @return PlotCluster
|
||||||
*/
|
*/
|
||||||
public PlotCluster getCluster() {
|
public PlotCluster getCluster() {
|
||||||
return cluster;
|
return cluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the flag involved
|
* Get the flag involved
|
||||||
*
|
*
|
||||||
* @return Flag
|
* @return Flag
|
||||||
*/
|
*/
|
||||||
public Flag getFlag() {
|
public Flag getFlag() {
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(final boolean b) {
|
public void setCancelled(final boolean b) {
|
||||||
cancelled = b;
|
cancelled = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,33 +20,27 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.plotsquared.bukkit.generator;
|
package com.plotsquared.bukkit.generator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import java.util.List;
|
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||||
import java.util.Random;
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
import java.util.Set;
|
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||||
|
import com.intellectualcrafters.plot.object.*;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||||
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
|
import com.plotsquared.bukkit.util.block.GenChunk;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import java.util.ArrayList;
|
||||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
import java.util.List;
|
||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
import java.util.Random;
|
||||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
import java.util.Set;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
|
||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
|
||||||
import com.intellectualcrafters.plot.util.SetQueue;
|
|
||||||
import com.plotsquared.bukkit.listeners.WorldEvents;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
|
||||||
import com.plotsquared.bukkit.util.block.GenChunk;
|
|
||||||
|
|
||||||
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
||||||
|
|
||||||
@ -96,7 +90,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() + " is already a BukkitPlotGenerator!");
|
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() + " is already a BukkitPlotGenerator!");
|
||||||
}
|
}
|
||||||
this.full = false;
|
this.full = false;
|
||||||
WorldEvents.lastWorld = world;
|
|
||||||
PS.get().debug("BukkitPlotGenerator does not fully support: " + cg);
|
PS.get().debug("BukkitPlotGenerator does not fully support: " + cg);
|
||||||
platformGenerator = cg;
|
platformGenerator = cg;
|
||||||
plotGenerator = new IndependentPlotGenerator() {
|
plotGenerator = new IndependentPlotGenerator() {
|
||||||
@ -205,7 +198,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
public List<BlockPopulator> getDefaultPopulators(final World world) {
|
public List<BlockPopulator> getDefaultPopulators(final World world) {
|
||||||
try {
|
try {
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
final String name = WorldEvents.getName(world);
|
final String name = world.getName();
|
||||||
PS.get().loadWorld(name, this);
|
PS.get().loadWorld(name, this);
|
||||||
Set<PlotArea> areas = PS.get().getPlotAreas(name);
|
Set<PlotArea> areas = PS.get().getPlotAreas(name);
|
||||||
if (!areas.isEmpty()) {
|
if (!areas.isEmpty()) {
|
||||||
@ -265,7 +258,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
public void generate(World world, int cx, int cz, GenChunk result) {
|
public void generate(World world, int cx, int cz, GenChunk result) {
|
||||||
// Load if improperly loaded
|
// Load if improperly loaded
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
final String name = WorldEvents.getName(world);
|
final String name = world.getName();
|
||||||
PS.get().loadWorld(name, this);
|
PS.get().loadWorld(name, this);
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
@ -295,6 +288,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
// Set the result data
|
// Set the result data
|
||||||
result.result = new short[16][];
|
result.result = new short[16][];
|
||||||
result.result_data = new byte[16][];
|
result.result_data = new byte[16][];
|
||||||
|
result.grid = grid;
|
||||||
// Catch any exceptions (as exceptions usually thrown
|
// Catch any exceptions (as exceptions usually thrown
|
||||||
try {
|
try {
|
||||||
// Fill the result data
|
// Fill the result data
|
@ -157,7 +157,6 @@ public class ChunkListener implements Listener {
|
|||||||
final int z = Z << 4;
|
final int z = Z << 4;
|
||||||
final int x2 = x + 15;
|
final int x2 = x + 15;
|
||||||
final int z2 = z + 15;
|
final int z2 = z + 15;
|
||||||
Thread thread = new Thread();
|
|
||||||
Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs();
|
Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs();
|
||||||
if (plot != null && plot.hasOwner()) {
|
if (plot != null && plot.hasOwner()) {
|
||||||
return false;
|
return false;
|
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,18 @@
|
|||||||
package com.plotsquared.bukkit.listeners;
|
package com.plotsquared.bukkit.listeners;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockExplodeEvent;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockExplodeEvent;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class PlayerEvents_1_8_3 implements Listener {
|
public class PlayerEvents_1_8_3 implements Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -36,18 +35,16 @@ public class PlayerEvents_1_8_3 implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlot(loc);
|
Plot plot = area.getOwnedPlot(loc);
|
||||||
if (plot == null) {
|
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
final Iterator<Block> iter = event.blockList().iterator();
|
||||||
final Iterator<Block> iter = event.blockList().iterator();
|
while (iter.hasNext()) {
|
||||||
while (iter.hasNext()) {
|
final Block b = iter.next();
|
||||||
final Block b = iter.next();
|
if (!plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(b.getLocation())))) {
|
||||||
if (!plot.equals(BukkitUtil.getLocation(b.getLocation()).getPlotAbs())) {
|
iter.remove();
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,251 +1,269 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
// /
|
// /
|
||||||
// This program is free software; you can redistribute it and/or modify /
|
// 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 /
|
// it under the terms of the GNU General Public License as published by /
|
||||||
// the Free Software Foundation; either version 3 of the License, or /
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
// (at your option) any later version. /
|
// (at your option) any later version. /
|
||||||
// /
|
// /
|
||||||
// This program is distributed in the hope that it will be useful, /
|
// This program is distributed in the hope that it will be useful, /
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
// GNU General Public License for more details. /
|
// GNU General Public License for more details. /
|
||||||
// /
|
// /
|
||||||
// You should have received a copy of the GNU General Public License /
|
// You should have received a copy of the GNU General Public License /
|
||||||
// along with this program; if not, write to the Free Software Foundation, /
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.plotsquared.bukkit.listeners;
|
package com.plotsquared.bukkit.listeners;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||||
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.listener.PlotListener;
|
import com.plotsquared.listener.PlotListener;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.block.BlockFadeEvent;
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import java.util.ArrayList;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
/**
|
import java.util.UUID;
|
||||||
* Created 2014-10-30 for PlotSquared
|
|
||||||
*
|
/**
|
||||||
|
* Created 2014-10-30 for PlotSquared
|
||||||
*/
|
*
|
||||||
@SuppressWarnings({ "deprecation" })
|
|
||||||
public class PlotPlusListener extends PlotListener implements Listener {
|
*/
|
||||||
private final static HashMap<String, Interval> feedRunnable = new HashMap<>();
|
@SuppressWarnings({ "deprecation" })
|
||||||
private final static HashMap<String, Interval> healRunnable = new HashMap<>();
|
public class PlotPlusListener extends PlotListener implements Listener {
|
||||||
|
private final static HashMap<String, Interval> feedRunnable = new HashMap<>();
|
||||||
public static void startRunnable(final JavaPlugin plugin) {
|
private final static HashMap<String, Interval> healRunnable = new HashMap<>();
|
||||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
|
||||||
@Override
|
public static void startRunnable(final JavaPlugin plugin) {
|
||||||
public void run() {
|
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
if (!healRunnable.isEmpty()) {
|
@Override
|
||||||
for (final Iterator<Entry<String, Interval>> iter = healRunnable.entrySet().iterator(); iter.hasNext();) {
|
public void run() {
|
||||||
final Entry<String, Interval> entry = iter.next();
|
if (!healRunnable.isEmpty()) {
|
||||||
final Interval value = entry.getValue();
|
for (final Iterator<Entry<String, Interval>> iter = healRunnable.entrySet().iterator(); iter.hasNext();) {
|
||||||
++value.count;
|
final Entry<String, Interval> entry = iter.next();
|
||||||
if (value.count == value.interval) {
|
final Interval value = entry.getValue();
|
||||||
value.count = 0;
|
++value.count;
|
||||||
final Player player = Bukkit.getPlayer(entry.getKey());
|
if (value.count == value.interval) {
|
||||||
if (player == null) {
|
value.count = 0;
|
||||||
iter.remove();
|
final Player player = Bukkit.getPlayer(entry.getKey());
|
||||||
continue;
|
if (player == null) {
|
||||||
}
|
iter.remove();
|
||||||
final double level = player.getHealth();
|
continue;
|
||||||
if (level != value.max) {
|
}
|
||||||
player.setHealth(Math.min(level + value.amount, value.max));
|
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();
|
if (!feedRunnable.isEmpty()) {
|
||||||
final Interval value = entry.getValue();
|
for (final Iterator<Entry<String, Interval>> iter = feedRunnable.entrySet().iterator(); iter.hasNext();) {
|
||||||
++value.count;
|
final Entry<String, Interval> entry = iter.next();
|
||||||
if (value.count == value.interval) {
|
final Interval value = entry.getValue();
|
||||||
value.count = 0;
|
++value.count;
|
||||||
final Player player = Bukkit.getPlayer(entry.getKey());
|
if (value.count == value.interval) {
|
||||||
if (player == null) {
|
value.count = 0;
|
||||||
iter.remove();
|
final Player player = Bukkit.getPlayer(entry.getKey());
|
||||||
continue;
|
if (player == null) {
|
||||||
}
|
iter.remove();
|
||||||
final int level = player.getFoodLevel();
|
continue;
|
||||||
if (level != value.max) {
|
}
|
||||||
player.setFoodLevel(Math.min(level + value.amount, value.max));
|
final int level = player.getFoodLevel();
|
||||||
}
|
if (level != value.max) {
|
||||||
}
|
player.setFoodLevel(Math.min(level + value.amount, value.max));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0l, 20l);
|
}
|
||||||
}
|
}
|
||||||
|
}, 0l, 20l);
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
}
|
||||||
public void onInteract(final BlockDamageEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
if (player.getGameMode() != GameMode.SURVIVAL) {
|
public void onMelt(final BlockFadeEvent event) {
|
||||||
return;
|
final BlockState state = event.getNewState();
|
||||||
}
|
|
||||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
if (state.getType() != Material.WATER && state.getType() != Material.STATIONARY_WATER) {
|
||||||
if (plot == null) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
final Plot plot = BukkitUtil.getLocation(state.getLocation()).getOwnedPlot();
|
||||||
if (FlagManager.isBooleanFlag(plot, "instabreak", false)) {
|
if (plot == null) {
|
||||||
event.getBlock().breakNaturally();
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (!FlagManager.isBooleanFlag(plot, "ice-melt", false)) {
|
||||||
|
event.setCancelled(true);
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
}
|
||||||
public void onDamage(final EntityDamageEvent event) {
|
}
|
||||||
if (event.getEntityType() != EntityType.PLAYER) {
|
|
||||||
return;
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
}
|
public void onInteract(final BlockDamageEvent event) {
|
||||||
final Player player = (Player) event.getEntity();
|
final Player player = event.getPlayer();
|
||||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
if (player.getGameMode() != GameMode.SURVIVAL) {
|
||||||
if (plot == null) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||||
if (FlagManager.isBooleanFlag(plot, "invincible", false)) {
|
if (plot == null) {
|
||||||
event.setCancelled(true);
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (FlagManager.isBooleanFlag(plot, "instabreak", false)) {
|
||||||
|
event.getBlock().breakNaturally();
|
||||||
@EventHandler
|
}
|
||||||
public void onItemPickup(final PlayerPickupItemEvent event) {
|
}
|
||||||
final Player player = event.getPlayer();
|
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
public void onDamage(final EntityDamageEvent event) {
|
||||||
if (plot == null) {
|
if (event.getEntityType() != EntityType.PLAYER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final UUID uuid = pp.getUUID();
|
final Player player = (Player) event.getEntity();
|
||||||
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "drop-protection", false)) {
|
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||||
event.setCancelled(true);
|
if (plot == null) {
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
if (FlagManager.isBooleanFlag(plot, "invincible", false)) {
|
||||||
@EventHandler
|
event.setCancelled(true);
|
||||||
public void onItemDrop(final PlayerDropItemEvent event) {
|
}
|
||||||
final Player player = event.getPlayer();
|
}
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
|
||||||
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
@EventHandler
|
||||||
if (plot == null) {
|
public void onItemPickup(final PlayerPickupItemEvent event) {
|
||||||
return;
|
final Player player = event.getPlayer();
|
||||||
}
|
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
final UUID uuid = pp.getUUID();
|
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||||
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "item-drop", false)) {
|
if (plot == null) {
|
||||||
event.setCancelled(true);
|
return;
|
||||||
}
|
}
|
||||||
}
|
final UUID uuid = pp.getUUID();
|
||||||
|
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "drop-protection", false)) {
|
||||||
@EventHandler
|
event.setCancelled(true);
|
||||||
public void onPlotEnter(final PlayerEnterPlotEvent event) {
|
}
|
||||||
final Player player = event.getPlayer();
|
}
|
||||||
final Plot plot = event.getPlot();
|
|
||||||
final Flag feed = FlagManager.getPlotFlagRaw(plot, "feed");
|
@EventHandler
|
||||||
if (feed != null) {
|
public void onItemDrop(final PlayerDropItemEvent event) {
|
||||||
final Integer[] value = (Integer[]) feed.getValue();
|
final Player player = event.getPlayer();
|
||||||
feedRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
}
|
final Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||||
final Flag heal = FlagManager.getPlotFlagRaw(plot, "heal");
|
if (plot == null) {
|
||||||
if (heal != null) {
|
return;
|
||||||
final Integer[] value = (Integer[]) heal.getValue();
|
}
|
||||||
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
final UUID uuid = pp.getUUID();
|
||||||
}
|
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "item-drop", false)) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
@EventHandler
|
}
|
||||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
@EventHandler
|
||||||
final String name = player.getName();
|
public void onPlotEnter(final PlayerEnterPlotEvent event) {
|
||||||
feedRunnable.remove(name);
|
final Player player = event.getPlayer();
|
||||||
healRunnable.remove(name);
|
final Plot plot = event.getPlot();
|
||||||
}
|
final Flag feed = FlagManager.getPlotFlagRaw(plot, "feed");
|
||||||
|
if (feed != null) {
|
||||||
@EventHandler
|
final Integer[] value = (Integer[]) feed.getValue();
|
||||||
public void onPlotLeave(final PlayerLeavePlotEvent event) {
|
feedRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||||
final Player leaver = event.getPlayer();
|
}
|
||||||
final Plot plot = event.getPlot();
|
final Flag heal = FlagManager.getPlotFlagRaw(plot, "heal");
|
||||||
if (!plot.hasOwner()) {
|
if (heal != null) {
|
||||||
return;
|
final Integer[] value = (Integer[]) heal.getValue();
|
||||||
}
|
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
|
||||||
BukkitUtil.getPlayer(leaver);
|
}
|
||||||
final String name = leaver.getName();
|
}
|
||||||
feedRunnable.remove(name);
|
|
||||||
healRunnable.remove(name);
|
@EventHandler
|
||||||
}
|
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
public static class Interval {
|
final String name = player.getName();
|
||||||
public final int interval;
|
feedRunnable.remove(name);
|
||||||
public final int amount;
|
healRunnable.remove(name);
|
||||||
public final int max;
|
}
|
||||||
public int count = 0;
|
|
||||||
|
@EventHandler
|
||||||
public Interval(final int interval, final int amount, final int max) {
|
public void onPlotLeave(final PlayerLeavePlotEvent event) {
|
||||||
this.interval = interval;
|
final Player leaver = event.getPlayer();
|
||||||
this.amount = amount;
|
final Plot plot = event.getPlot();
|
||||||
this.max = max;
|
if (!plot.hasOwner()) {
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
BukkitUtil.getPlayer(leaver);
|
||||||
/**
|
final String name = leaver.getName();
|
||||||
* Record Meta Class
|
feedRunnable.remove(name);
|
||||||
*
|
healRunnable.remove(name);
|
||||||
|
}
|
||||||
*/
|
|
||||||
public static class RecordMeta {
|
public static class Interval {
|
||||||
public final static List<RecordMeta> metaList = new ArrayList<>();
|
public final int interval;
|
||||||
static {
|
public final int amount;
|
||||||
for (int x = 3; x < 12; x++) {
|
public final int max;
|
||||||
metaList.add(new RecordMeta(x + "", Material.valueOf("RECORD_" + x)));
|
public int count = 0;
|
||||||
}
|
|
||||||
}
|
public Interval(final int interval, final int amount, final int max) {
|
||||||
private final String name;
|
this.interval = interval;
|
||||||
private final Material material;
|
this.amount = amount;
|
||||||
|
this.max = max;
|
||||||
public RecordMeta(final String name, final Material material) {
|
}
|
||||||
this.name = name;
|
}
|
||||||
this.material = material;
|
|
||||||
}
|
/**
|
||||||
|
* Record Meta Class
|
||||||
@Override
|
*
|
||||||
public String toString() {
|
|
||||||
return name;
|
*/
|
||||||
}
|
public static class RecordMeta {
|
||||||
|
public final static List<RecordMeta> metaList = new ArrayList<>();
|
||||||
@Override
|
static {
|
||||||
public int hashCode() {
|
for (int x = 3; x < 12; x++) {
|
||||||
return name.hashCode();
|
metaList.add(new RecordMeta(x + "", Material.valueOf("RECORD_" + x)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public Material getMaterial() {
|
private final String name;
|
||||||
return material;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,28 +13,15 @@ import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
|||||||
|
|
||||||
public class WorldEvents implements Listener {
|
public class WorldEvents implements Listener {
|
||||||
|
|
||||||
public static String lastWorld = null;
|
|
||||||
|
|
||||||
public static String getName(final World world) {
|
|
||||||
if ((lastWorld != null) && !lastWorld.equals("CheckingPlotSquaredGenerator")) {
|
|
||||||
return lastWorld;
|
|
||||||
} else {
|
|
||||||
return world.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onWorldInit(final WorldInitEvent event) {
|
public static void onWorldInit(final WorldInitEvent event) {
|
||||||
final World world = event.getWorld();
|
final World world = event.getWorld();
|
||||||
final String name = getName(world);
|
final String name = world.getName();
|
||||||
final ChunkGenerator gen = world.getGenerator();
|
final ChunkGenerator gen = world.getGenerator();
|
||||||
if (gen instanceof GeneratorWrapper) {
|
if (gen instanceof GeneratorWrapper) {
|
||||||
PS.get().loadWorld(name, (GeneratorWrapper<?>) gen);
|
PS.get().loadWorld(name, (GeneratorWrapper<?>) gen);
|
||||||
} else {
|
} else {
|
||||||
if (PS.get().config.contains("worlds." + name)) {
|
PS.get().loadWorld(name, new BukkitPlotGenerator(name, gen));
|
||||||
PS.get().loadWorld(name, new BukkitPlotGenerator(name, gen));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
lastWorld = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,5 @@
|
|||||||
package com.plotsquared.bukkit.object;
|
package com.plotsquared.bukkit.object;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Effect;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.WeatherType;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
|
||||||
import org.bukkit.permissions.Permission;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -19,6 +8,16 @@ import com.intellectualcrafters.plot.util.PlotGamemode;
|
|||||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.WeatherType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BukkitPlayer extends PlotPlayer {
|
public class BukkitPlayer extends PlotPlayer {
|
||||||
|
|
||||||
@ -133,24 +132,6 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
return BukkitUtil.getLocationFull(player);
|
return BukkitUtil.getLocationFull(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAttribute(String key) {
|
|
||||||
setPersistentMeta("attrib_" + key, new byte[]{(byte) 1});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getAttribute(String key) {
|
|
||||||
if (!hasPersistentMeta(key)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return getPersistentMeta("attrib_" + key)[0] == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeAttribute(String key) {
|
|
||||||
removePersistentMeta("attrib_" + key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadData() {
|
public void loadData() {
|
||||||
if (!player.isOnline()) {
|
if (!player.isOnline()) {
|
||||||
@ -234,7 +215,13 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
public void kick(final String message) {
|
public void kick(final String message) {
|
||||||
player.kickPlayer(message);
|
player.kickPlayer(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void stopSpectating() {
|
||||||
|
if (getGamemode() == PlotGamemode.SPECTATOR) {
|
||||||
|
player.setSpectatorTarget(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBanned() {
|
public boolean isBanned() {
|
||||||
return player.isBanned();
|
return player.isBanned();
|
@ -4,13 +4,17 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
public class DefaultTitle extends AbstractTitle {
|
public class DefaultTitle extends AbstractTitle {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
||||||
try {
|
try {
|
||||||
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
||||||
title.send(((BukkitPlayer) player).player);
|
title.send(((BukkitPlayer) player).player);
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException | InvocationTargetException | SecurityException | NoSuchMethodException | InstantiationException |
|
||||||
|
IllegalArgumentException | IllegalAccessException e) {
|
||||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
||||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||||
}
|
}
|
@ -101,7 +101,8 @@ public class DefaultTitleManager {
|
|||||||
* Fade out time
|
* Fade out time
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public DefaultTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) throws ClassNotFoundException {
|
public DefaultTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime)
|
||||||
|
throws ClassNotFoundException {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
this.fadeInTime = fadeInTime;
|
this.fadeInTime = fadeInTime;
|
||||||
@ -255,21 +256,22 @@ public class DefaultTitleManager {
|
|||||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||||
final Object[] actions = packetActions.getEnumConstants();
|
final Object[] actions = packetActions.getEnumConstants();
|
||||||
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||||
Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], null, fadeInTime * (ticks ? 1 : 20),
|
Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE)
|
||||||
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
|
.newInstance(actions[2], null, fadeInTime * (ticks ? 1 : 20),
|
||||||
|
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
|
||||||
// Send if set
|
// Send if set
|
||||||
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) {
|
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) {
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
// Send title
|
// Send title
|
||||||
Object serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
Object serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
||||||
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized);
|
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
if (!subtitle.isEmpty()) {
|
if (!subtitle.isEmpty()) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
||||||
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[1], serialized);
|
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[1], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
@ -278,7 +280,8 @@ public class DefaultTitleManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast the title to all players
|
* Broadcast the title to all players
|
||||||
* @throws Exception
|
* @throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
||||||
|
SecurityException
|
||||||
*/
|
*/
|
||||||
public void broadcast()
|
public void broadcast()
|
||||||
throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
@ -1,15 +1,15 @@
|
|||||||
package com.plotsquared.bukkit.titles;
|
package com.plotsquared.bukkit.titles;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
|
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
|
||||||
*
|
*
|
||||||
@ -36,7 +36,7 @@ public class DefaultTitleManager_183 {
|
|||||||
private int stayTime = -1;
|
private int stayTime = -1;
|
||||||
private int fadeOutTime = -1;
|
private int fadeOutTime = -1;
|
||||||
private boolean ticks = false;
|
private boolean ticks = false;
|
||||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<Class<?>, Class<?>>();
|
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new 1.8 title
|
* Create a new 1.8 title
|
||||||
@ -252,7 +252,7 @@ public class DefaultTitleManager_183 {
|
|||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
||||||
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized);
|
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
if (subtitle != "") {
|
if (!subtitle.isEmpty()) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
||||||
@ -365,9 +365,7 @@ public class DefaultTitleManager_183 {
|
|||||||
|
|
||||||
private Class<?> getNMSClass(final String className) throws ClassNotFoundException {
|
private Class<?> getNMSClass(final String className) throws ClassNotFoundException {
|
||||||
final String fullName = "net.minecraft.server." + getVersion() + className;
|
final String fullName = "net.minecraft.server." + getVersion() + className;
|
||||||
Class<?> clazz = null;
|
return Class.forName(fullName);
|
||||||
clazz = Class.forName(fullName);
|
|
||||||
return clazz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Field getField(final Class<?> clazz, final String name) {
|
private Field getField(final Class<?> clazz, final String name) {
|
||||||
@ -392,10 +390,10 @@ public class DefaultTitleManager_183 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean ClassListEqual(final Class<?>[] l1, final Class<?>[] l2) {
|
private boolean ClassListEqual(final Class<?>[] l1, final Class<?>[] l2) {
|
||||||
boolean equal = true;
|
|
||||||
if (l1.length != l2.length) {
|
if (l1.length != l2.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
boolean equal = true;
|
||||||
for (int i = 0; i < l1.length; i++) {
|
for (int i = 0; i < l1.length; i++) {
|
||||||
if (l1[i] != l2[i]) {
|
if (l1[i] != l2[i]) {
|
||||||
equal = false;
|
equal = false;
|
@ -12,7 +12,7 @@ public class HackTitle extends AbstractTitle {
|
|||||||
try {
|
try {
|
||||||
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
||||||
title.send(((BukkitPlayer) player).player);
|
title.send(((BukkitPlayer) player).player);
|
||||||
} catch (final Throwable e) {
|
} catch (Exception e) {
|
||||||
PS.debug("&cYour server version does not support titles!");
|
PS.debug("&cYour server version does not support titles!");
|
||||||
Settings.TITLES = false;
|
Settings.TITLES = false;
|
||||||
AbstractTitle.TITLE_CLASS = null;
|
AbstractTitle.TITLE_CLASS = null;
|
@ -1,14 +1,15 @@
|
|||||||
package com.plotsquared.bukkit.titles;
|
package com.plotsquared.bukkit.titles;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minecraft 1.8 Title
|
* Minecraft 1.8 Title
|
||||||
*
|
*
|
||||||
@ -33,7 +34,7 @@ public class HackTitleManager {
|
|||||||
private int stayTime = -1;
|
private int stayTime = -1;
|
||||||
private int fadeOutTime = -1;
|
private int fadeOutTime = -1;
|
||||||
private boolean ticks = false;
|
private boolean ticks = false;
|
||||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<Class<?>, Class<?>>();
|
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new 1.8 title
|
* Create a new 1.8 title
|
||||||
@ -244,7 +245,7 @@ public class HackTitleManager {
|
|||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
||||||
packet = packetTitle.getConstructor(packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized);
|
packet = packetTitle.getConstructor(packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
if (subtitle != "") {
|
if (!subtitle.isEmpty()) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
||||||
@ -313,8 +314,7 @@ public class HackTitleManager {
|
|||||||
final Object handle = getHandle(player);
|
final Object handle = getHandle(player);
|
||||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||||
final Object networkManager = getValue("networkManager", connection);
|
final Object networkManager = getValue("networkManager", connection);
|
||||||
final Integer version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
|
return (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
|
||||||
return version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -336,7 +336,8 @@ public class HackTitleManager {
|
|||||||
private Class<?> getClass(final String namespace) {
|
private Class<?> getClass(final String namespace) {
|
||||||
try {
|
try {
|
||||||
return Class.forName(namespace);
|
return Class.forName(namespace);
|
||||||
} catch (final Exception e) {}
|
} catch (ClassNotFoundException e) {
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +379,7 @@ public class HackTitleManager {
|
|||||||
private Object getHandle(final Object obj) {
|
private Object getHandle(final Object obj) {
|
||||||
try {
|
try {
|
||||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||||
} catch (final Exception e) {
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -397,15 +398,12 @@ public class HackTitleManager {
|
|||||||
|
|
||||||
private String getVersion() {
|
private String getVersion() {
|
||||||
final String name = Bukkit.getServer().getClass().getPackage().getName();
|
final String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
final String version = name.substring(name.lastIndexOf('.') + 1) + ".";
|
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||||
return version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> getNMSClass(final String className) throws ClassNotFoundException {
|
private Class<?> getNMSClass(final String className) throws ClassNotFoundException {
|
||||||
final String fullName = "net.minecraft.server." + getVersion() + className;
|
final String fullName = "net.minecraft.server." + getVersion() + className;
|
||||||
Class<?> clazz = null;
|
return Class.forName(fullName);
|
||||||
clazz = Class.forName(fullName);
|
|
||||||
return clazz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Field getField(final Class<?> clazz, final String name) {
|
private Field getField(final Class<?> clazz, final String name) {
|
||||||
@ -413,7 +411,7 @@ public class HackTitleManager {
|
|||||||
final Field field = clazz.getDeclaredField(name);
|
final Field field = clazz.getDeclaredField(name);
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
return field;
|
return field;
|
||||||
} catch (final Exception e) {
|
} catch (SecurityException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -430,10 +428,10 @@ public class HackTitleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean ClassListEqual(final Class<?>[] l1, final Class<?>[] l2) {
|
private boolean ClassListEqual(final Class<?>[] l1, final Class<?>[] l2) {
|
||||||
boolean equal = true;
|
|
||||||
if (l1.length != l2.length) {
|
if (l1.length != l2.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
boolean equal = true;
|
||||||
for (int i = 0; i < l1.length; i++) {
|
for (int i = 0; i < l1.length; i++) {
|
||||||
if (l1[i] != l2[i]) {
|
if (l1[i] != l2[i]) {
|
||||||
equal = false;
|
equal = false;
|
@ -668,11 +668,8 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (!pLoc.getChunkLoc().equals(loc)) {
|
if (!pLoc.getChunkLoc().equals(loc)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PlotBlock plotblock = WorldUtil.IMP.getBlock(pLoc);
|
pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ()));
|
||||||
if (plotblock.id != 0) {
|
pp.teleport(pLoc);
|
||||||
Plot plot = pp.getCurrentPlot();
|
|
||||||
pp.teleport(plot.getDefaultHome());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -996,20 +993,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
final int tx = pos2.getX();
|
final int tx = pos2.getX();
|
||||||
final int tz = pos2.getZ();
|
final int tz = pos2.getZ();
|
||||||
for (final Entity entity : entities) {
|
for (final Entity entity : entities) {
|
||||||
if (entity instanceof Player) {
|
if (!(entity instanceof Player)) {
|
||||||
final org.bukkit.Location loc = entity.getLocation();
|
|
||||||
if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) {
|
|
||||||
final Player player = (Player) entity;
|
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
|
||||||
final Plot plot = pp.getCurrentPlot();
|
|
||||||
if (plot != null) {
|
|
||||||
final Location plotHome = plot.getDefaultHome();
|
|
||||||
if (pp.getLocation().getY() <= plotHome.getY()) {
|
|
||||||
pp.teleport(plotHome);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
final org.bukkit.Location loc = entity.getLocation();
|
final org.bukkit.Location loc = entity.getLocation();
|
||||||
if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) {
|
if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@ -1075,7 +1059,9 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
final Set<Chunk> chunks = new HashSet<>();
|
final Set<Chunk> chunks = new HashSet<>();
|
||||||
for (int X = bx; X <= tx; X++) {
|
for (int X = bx; X <= tx; X++) {
|
||||||
for (int Z = bz; Z <= tz; Z++) {
|
for (int Z = bz; Z <= tz; Z++) {
|
||||||
chunks.add(world.getChunkAt(X, Z));
|
if (world.isChunkLoaded(X, Z)) {
|
||||||
|
chunks.add(world.getChunkAt(X, Z));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,108 +1,108 @@
|
|||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
import com.plotsquared.bukkit.commands.DebugUUID;
|
import com.plotsquared.bukkit.commands.DebugUUID;
|
||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created 2015-02-20 for PlotSquared
|
* Created 2015-02-20 for PlotSquared
|
||||||
*
|
*
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
public BukkitCommand() {
|
public BukkitCommand() {
|
||||||
MainCommand.getInstance().addCommand(new DebugUUID());
|
MainCommand.getInstance().addCommand(new DebugUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender commandSender, final org.bukkit.command.Command command, final String commandLabel,
|
public boolean onCommand(final CommandSender commandSender, final org.bukkit.command.Command command, final String commandLabel,
|
||||||
final String[] args) {
|
final String[] args) {
|
||||||
if (commandSender instanceof Player) {
|
if (commandSender instanceof Player) {
|
||||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
|
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
|
||||||
}
|
}
|
||||||
if (commandSender == null || commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
|
if (commandSender == null || commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
|
||||||
return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
|
return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
|
||||||
}
|
}
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
ConsolePlayer sender = new ConsolePlayer() {
|
ConsolePlayer sender = new ConsolePlayer() {
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
commandSender.sendMessage(commandLabel);
|
commandSender.sendMessage(commandLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String perm) {
|
public boolean hasPermission(String perm) {
|
||||||
return commandSender.hasPermission(commandLabel);
|
return commandSender.hasPermission(commandLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (commandSender.getName().equals("CONSOLE")) {
|
if (commandSender.getName().equals("CONSOLE")) {
|
||||||
return "*";
|
return "*";
|
||||||
}
|
}
|
||||||
return commandSender.getName();
|
return commandSender.getName();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
sender.teleport(ConsolePlayer.getConsole().getLocationFull());
|
sender.teleport(ConsolePlayer.getConsole().getLocationFull());
|
||||||
boolean result = MainCommand.onCommand(sender, commandLabel, args);
|
boolean result = MainCommand.onCommand(sender, commandLabel, args);
|
||||||
ConsolePlayer.getConsole().teleport(sender.getLocationFull());
|
ConsolePlayer.getConsole().teleport(sender.getLocationFull());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(final CommandSender commandSender, final org.bukkit.command.Command command, final String s,
|
public List<String> onTabComplete(final CommandSender commandSender, final org.bukkit.command.Command command, final String s,
|
||||||
final String[] strings) {
|
final String[] strings) {
|
||||||
if (!(commandSender instanceof Player)) {
|
if (!(commandSender instanceof Player)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
||||||
if (strings.length < 1) {
|
if (strings.length < 1) {
|
||||||
if ((strings.length == 0) || "plots".startsWith(s)) {
|
if ((strings.length == 0) || "plots".startsWith(s)) {
|
||||||
return Collections.singletonList("plots");
|
return Collections.singletonList("plots");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strings.length > 1) {
|
if (strings.length > 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Set<String> tabOptions = new HashSet<>();
|
final Set<String> tabOptions = new HashSet<>();
|
||||||
final String arg = strings[0].toLowerCase();
|
final String arg = strings[0].toLowerCase();
|
||||||
ArrayList<String> labels = new ArrayList<>();
|
ArrayList<String> labels = new ArrayList<>();
|
||||||
for (final Command<PlotPlayer> cmd : MainCommand.getInstance().getCommands()) {
|
for (final Command<PlotPlayer> cmd : MainCommand.getInstance().getCommands()) {
|
||||||
final String label = cmd.getCommand();
|
final String label = cmd.getCommand();
|
||||||
HashSet<String> aliases = new HashSet<>(cmd.getAliases());
|
HashSet<String> aliases = new HashSet<>(cmd.getAliases());
|
||||||
aliases.add(label);
|
aliases.add(label);
|
||||||
for (String alias : aliases) {
|
for (String alias : aliases) {
|
||||||
labels.add(alias);
|
labels.add(alias);
|
||||||
if (alias.startsWith(arg)) {
|
if (alias.startsWith(arg)) {
|
||||||
if (Permissions.hasPermission(player, cmd.getPermission())) {
|
if (Permissions.hasPermission(player, cmd.getPermission())) {
|
||||||
tabOptions.add(label);
|
tabOptions.add(label);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String best = new StringComparison<>(arg, labels).getBestMatch();
|
String best = new StringComparison<>(arg, labels).getBestMatch();
|
||||||
tabOptions.add(best);
|
tabOptions.add(best);
|
||||||
if (!tabOptions.isEmpty()) {
|
if (!tabOptions.isEmpty()) {
|
||||||
return new ArrayList<>(tabOptions);
|
return new ArrayList<>(tabOptions);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,340 +1,340 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
// /
|
// /
|
||||||
// This program is free software; you can redistribute it and/or modify /
|
// 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 /
|
// it under the terms of the GNU General Public License as published by /
|
||||||
// the Free Software Foundation; either version 3 of the License, or /
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
// (at your option) any later version. /
|
// (at your option) any later version. /
|
||||||
// /
|
// /
|
||||||
// This program is distributed in the hope that it will be useful, /
|
// This program is distributed in the hope that it will be useful, /
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
// GNU General Public License for more details. /
|
// GNU General Public License for more details. /
|
||||||
// /
|
// /
|
||||||
// You should have received a copy of the GNU General Public License /
|
// You should have received a copy of the GNU General Public License /
|
||||||
// along with this program; if not, write to the Free Software Foundation, /
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
// /
|
// /
|
||||||
// You can contact us via: support@intellectualsites.com /
|
// You can contact us via: support@intellectualsites.com /
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
|
||||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||||
import com.intellectualcrafters.jnbt.IntTag;
|
import com.intellectualcrafters.jnbt.IntTag;
|
||||||
import com.intellectualcrafters.jnbt.ListTag;
|
import com.intellectualcrafters.jnbt.ListTag;
|
||||||
import com.intellectualcrafters.jnbt.ShortTag;
|
import com.intellectualcrafters.jnbt.ShortTag;
|
||||||
import com.intellectualcrafters.jnbt.StringTag;
|
import com.intellectualcrafters.jnbt.StringTag;
|
||||||
import com.intellectualcrafters.jnbt.Tag;
|
import com.intellectualcrafters.jnbt.Tag;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.bukkit.object.schematic.StateWrapper;
|
import com.plotsquared.bukkit.object.schematic.StateWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schematic Handler
|
* Schematic Handler
|
||||||
*
|
*
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public class BukkitSchematicHandler extends SchematicHandler {
|
public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
|
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) {
|
||||||
// async
|
// async
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Main positions
|
// Main positions
|
||||||
Location[] corners = MainUtil.getCorners(world, regions);
|
Location[] corners = MainUtil.getCorners(world, regions);
|
||||||
final Location bot = corners[0];
|
final Location bot = corners[0];
|
||||||
final Location top = corners[1];
|
final Location top = corners[1];
|
||||||
|
|
||||||
final int width = (top.getX() - bot.getX()) + 1;
|
final int width = (top.getX() - bot.getX()) + 1;
|
||||||
final int height = (top.getY() - bot.getY()) + 1;
|
final int height = (top.getY() - bot.getY()) + 1;
|
||||||
final int length = (top.getZ() - bot.getZ()) + 1;
|
final int length = (top.getZ() - bot.getZ()) + 1;
|
||||||
// Main Schematic tag
|
// Main Schematic tag
|
||||||
final HashMap<String, Tag> schematic = new HashMap<>();
|
final HashMap<String, Tag> schematic = new HashMap<>();
|
||||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||||
schematic.put("Materials", new StringTag("Materials", "Alpha"));
|
schematic.put("Materials", new StringTag("Materials", "Alpha"));
|
||||||
schematic.put("WEOriginX", new IntTag("WEOriginX", 0));
|
schematic.put("WEOriginX", new IntTag("WEOriginX", 0));
|
||||||
schematic.put("WEOriginY", new IntTag("WEOriginY", 0));
|
schematic.put("WEOriginY", new IntTag("WEOriginY", 0));
|
||||||
schematic.put("WEOriginZ", new IntTag("WEOriginZ", 0));
|
schematic.put("WEOriginZ", new IntTag("WEOriginZ", 0));
|
||||||
schematic.put("WEOffsetX", new IntTag("WEOffsetX", 0));
|
schematic.put("WEOffsetX", new IntTag("WEOffsetX", 0));
|
||||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
||||||
// Arrays of data types
|
// Arrays of data types
|
||||||
final List<Tag> tileEntities = new ArrayList<>();
|
final List<Tag> tileEntities = new ArrayList<>();
|
||||||
final byte[] blocks = new byte[width * height * length];
|
final byte[] blocks = new byte[width * height * length];
|
||||||
final byte[] blockData = new byte[width * height * length];
|
final byte[] blockData = new byte[width * height * length];
|
||||||
// Queue
|
// Queue
|
||||||
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
|
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (queue.isEmpty()) {
|
if (queue.isEmpty()) {
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||||
whenDone.value = new CompoundTag("Schematic", schematic);
|
whenDone.value = new CompoundTag("Schematic", schematic);
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
System.gc();
|
System.gc();
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Runnable regionTask = this;
|
final Runnable regionTask = this;
|
||||||
RegionWrapper region = queue.poll();
|
RegionWrapper region = queue.poll();
|
||||||
Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
|
Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
|
||||||
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
|
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
|
||||||
final int bx = bot.getX();
|
final int bx = bot.getX();
|
||||||
final int bz = bot.getZ();
|
final int bz = bot.getZ();
|
||||||
final int p1x = pos1.getX();
|
final int p1x = pos1.getX();
|
||||||
final int p1z = pos1.getZ();
|
final int p1z = pos1.getZ();
|
||||||
final int p2x = pos2.getX();
|
final int p2x = pos2.getX();
|
||||||
final int p2z = pos2.getZ();
|
final int p2z = pos2.getZ();
|
||||||
final int bcx = p1x >> 4;
|
final int bcx = p1x >> 4;
|
||||||
final int bcz = p1z >> 4;
|
final int bcz = p1z >> 4;
|
||||||
final int tcx = p2x >> 4;
|
final int tcx = p2x >> 4;
|
||||||
final int tcz = p2z >> 4;
|
final int tcz = p2z >> 4;
|
||||||
final int sy = pos1.getY();
|
final int sy = pos1.getY();
|
||||||
final int ey = pos2.getY();
|
final int ey = pos2.getY();
|
||||||
// Generate list of chunks
|
// Generate list of chunks
|
||||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||||
for (int x = bcx; x <= tcx; x++) {
|
for (int x = bcx; x <= tcx; x++) {
|
||||||
for (int z = bcz; z <= tcz; z++) {
|
for (int z = bcz; z <= tcz; z++) {
|
||||||
chunks.add(new ChunkLoc(x, z));
|
chunks.add(new ChunkLoc(x, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final World worldObj = Bukkit.getWorld(world);
|
final World worldObj = Bukkit.getWorld(world);
|
||||||
// Main thread
|
// Main thread
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
while ((!chunks.isEmpty()) && ((System.currentTimeMillis() - start) < 20)) {
|
while ((!chunks.isEmpty()) && ((System.currentTimeMillis() - start) < 20)) {
|
||||||
// save schematics
|
// save schematics
|
||||||
final ChunkLoc chunk = chunks.remove(0);
|
final ChunkLoc chunk = chunks.remove(0);
|
||||||
final Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
|
final Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
|
||||||
if (!bc.load(false)) {
|
if (!bc.load(false)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final int X = chunk.x;
|
final int X = chunk.x;
|
||||||
final int Z = chunk.z;
|
final int Z = chunk.z;
|
||||||
int xxb = X << 4;
|
int xxb = X << 4;
|
||||||
int zzb = Z << 4;
|
int zzb = Z << 4;
|
||||||
int xxt = xxb + 15;
|
int xxt = xxb + 15;
|
||||||
int zzt = zzb + 15;
|
int zzt = zzb + 15;
|
||||||
|
|
||||||
if (X == bcx) {
|
if (X == bcx) {
|
||||||
xxb = p1x;
|
xxb = p1x;
|
||||||
}
|
}
|
||||||
if (X == tcx) {
|
if (X == tcx) {
|
||||||
xxt = p2x;
|
xxt = p2x;
|
||||||
}
|
}
|
||||||
if (Z == bcz) {
|
if (Z == bcz) {
|
||||||
zzb = p1z;
|
zzb = p1z;
|
||||||
}
|
}
|
||||||
if (Z == tcz) {
|
if (Z == tcz) {
|
||||||
zzt = p2z;
|
zzt = p2z;
|
||||||
}
|
}
|
||||||
for (int y = sy; y <= Math.min(255, ey); y++) {
|
for (int y = sy; y <= Math.min(255, ey); y++) {
|
||||||
final int ry = y - sy;
|
final int ry = y - sy;
|
||||||
final int i1 = (ry * width * length);
|
final int i1 = (ry * width * length);
|
||||||
for (int z = zzb; z <= zzt; z++) {
|
for (int z = zzb; z <= zzt; z++) {
|
||||||
final int rz = z - bz;
|
final int rz = z - bz;
|
||||||
final int i2 = i1 + (rz * width);
|
final int i2 = i1 + (rz * width);
|
||||||
for (int x = xxb; x <= xxt; x++) {
|
for (int x = xxb; x <= xxt; x++) {
|
||||||
final int rx = x - bx;
|
final int rx = x - bx;
|
||||||
final int index = i2 + rx;
|
final int index = i2 + rx;
|
||||||
final Block block = worldObj.getBlockAt(x, y, z);
|
final Block block = worldObj.getBlockAt(x, y, z);
|
||||||
final int id = block.getTypeId();
|
final int id = block.getTypeId();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0:
|
case 0:
|
||||||
case 2:
|
case 2:
|
||||||
case 4:
|
case 4:
|
||||||
case 13:
|
case 13:
|
||||||
case 14:
|
case 14:
|
||||||
case 15:
|
case 15:
|
||||||
case 20:
|
case 20:
|
||||||
case 21:
|
case 21:
|
||||||
case 22:
|
case 22:
|
||||||
case 24:
|
case 24:
|
||||||
case 30:
|
case 30:
|
||||||
case 32:
|
case 32:
|
||||||
case 37:
|
case 37:
|
||||||
case 39:
|
case 39:
|
||||||
case 40:
|
case 40:
|
||||||
case 41:
|
case 41:
|
||||||
case 42:
|
case 42:
|
||||||
case 45:
|
case 45:
|
||||||
case 46:
|
case 46:
|
||||||
case 47:
|
case 47:
|
||||||
case 48:
|
case 48:
|
||||||
case 49:
|
case 49:
|
||||||
case 51:
|
case 51:
|
||||||
case 55:
|
case 55:
|
||||||
case 56:
|
case 56:
|
||||||
case 57:
|
case 57:
|
||||||
case 58:
|
case 58:
|
||||||
case 60:
|
case 60:
|
||||||
case 7:
|
case 7:
|
||||||
case 8:
|
case 8:
|
||||||
case 9:
|
case 9:
|
||||||
case 10:
|
case 10:
|
||||||
case 11:
|
case 11:
|
||||||
case 73:
|
case 73:
|
||||||
case 74:
|
case 74:
|
||||||
case 78:
|
case 78:
|
||||||
case 79:
|
case 79:
|
||||||
case 80:
|
case 80:
|
||||||
case 81:
|
case 81:
|
||||||
case 82:
|
case 82:
|
||||||
case 83:
|
case 83:
|
||||||
case 85:
|
case 85:
|
||||||
case 87:
|
case 87:
|
||||||
case 88:
|
case 88:
|
||||||
case 101:
|
case 101:
|
||||||
case 102:
|
case 102:
|
||||||
case 103:
|
case 103:
|
||||||
case 110:
|
case 110:
|
||||||
case 112:
|
case 112:
|
||||||
case 113:
|
case 113:
|
||||||
case 121:
|
case 121:
|
||||||
case 122:
|
case 122:
|
||||||
case 129:
|
case 129:
|
||||||
case 133:
|
case 133:
|
||||||
case 165:
|
case 165:
|
||||||
case 166:
|
case 166:
|
||||||
case 169:
|
case 169:
|
||||||
case 170:
|
case 170:
|
||||||
case 172:
|
case 172:
|
||||||
case 173:
|
case 173:
|
||||||
case 174:
|
case 174:
|
||||||
case 181:
|
case 181:
|
||||||
case 182:
|
case 182:
|
||||||
case 188:
|
case 188:
|
||||||
case 189:
|
case 189:
|
||||||
case 190:
|
case 190:
|
||||||
case 191:
|
case 191:
|
||||||
case 192: {
|
case 192: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 54:
|
case 54:
|
||||||
case 130:
|
case 130:
|
||||||
case 142:
|
case 142:
|
||||||
case 27:
|
case 27:
|
||||||
case 137:
|
case 137:
|
||||||
case 52:
|
case 52:
|
||||||
case 154:
|
case 154:
|
||||||
case 84:
|
case 84:
|
||||||
case 25:
|
case 25:
|
||||||
case 144:
|
case 144:
|
||||||
case 138:
|
case 138:
|
||||||
case 176:
|
case 176:
|
||||||
case 177:
|
case 177:
|
||||||
case 63:
|
case 63:
|
||||||
case 68:
|
case 68:
|
||||||
case 323:
|
case 323:
|
||||||
case 117:
|
case 117:
|
||||||
case 116:
|
case 116:
|
||||||
case 28:
|
case 28:
|
||||||
case 66:
|
case 66:
|
||||||
case 157:
|
case 157:
|
||||||
case 61:
|
case 61:
|
||||||
case 62:
|
case 62:
|
||||||
case 140:
|
case 140:
|
||||||
case 146:
|
case 146:
|
||||||
case 149:
|
case 149:
|
||||||
case 150:
|
case 150:
|
||||||
case 158:
|
case 158:
|
||||||
case 23:
|
case 23:
|
||||||
case 123:
|
case 123:
|
||||||
case 124:
|
case 124:
|
||||||
case 29:
|
case 29:
|
||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178: {
|
case 178: {
|
||||||
// TODO implement fully
|
// TODO implement fully
|
||||||
final BlockState state = block.getState();
|
final BlockState state = block.getState();
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
final StateWrapper wrapper = new StateWrapper(state);
|
final StateWrapper wrapper = new StateWrapper(state);
|
||||||
final CompoundTag rawTag = wrapper.getTag();
|
final CompoundTag rawTag = wrapper.getTag();
|
||||||
if (rawTag != null) {
|
if (rawTag != null) {
|
||||||
final Map<String, Tag> values = new HashMap<String, Tag>();
|
final Map<String, Tag> values = new HashMap<String, Tag>();
|
||||||
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
for (final Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||||
values.put(entry.getKey(), entry.getValue());
|
values.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
values.put("id", new StringTag("id", wrapper.getId()));
|
values.put("id", new StringTag("id", wrapper.getId()));
|
||||||
values.put("x", new IntTag("x", x));
|
values.put("x", new IntTag("x", x));
|
||||||
values.put("y", new IntTag("y", y));
|
values.put("y", new IntTag("y", y));
|
||||||
values.put("z", new IntTag("z", z));
|
values.put("z", new IntTag("z", z));
|
||||||
final CompoundTag tileEntityTag = new CompoundTag(values);
|
final CompoundTag tileEntityTag = new CompoundTag(values);
|
||||||
tileEntities.add(tileEntityTag);
|
tileEntities.add(tileEntityTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
blockData[index] = block.getData();
|
blockData[index] = block.getData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// For optimization reasons, we are not supporting custom data types
|
// 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
|
// Especially since the most likely reason beyond this range is modded servers in which the blocks
|
||||||
// have NBT
|
// have NBT
|
||||||
// if (type > 255) {
|
// if (type > 255) {
|
||||||
// if (addBlocks == null) {
|
// if (addBlocks == null) {
|
||||||
// addBlocks = new byte[(blocks.length >> 1) + 1];
|
// addBlocks = new byte[(blocks.length >> 1) + 1];
|
||||||
// }
|
// }
|
||||||
// addBlocks[index >> 1] = (byte) (((index & 1) == 0) ?
|
// addBlocks[index >> 1] = (byte) (((index & 1) == 0) ?
|
||||||
// (addBlocks[index >> 1] & 0xF0) | ((type >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((type
|
// (addBlocks[index >> 1] & 0xF0) | ((type >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((type
|
||||||
// >> 8) & 0xF) << 4));
|
// >> 8) & 0xF) << 4));
|
||||||
// }
|
// }
|
||||||
blocks[index] = (byte) id;
|
blocks[index] = (byte) id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!chunks.isEmpty()) {
|
if (!chunks.isEmpty()) {
|
||||||
TaskManager.runTaskLater(this, 1);
|
TaskManager.runTaskLater(this, 1);
|
||||||
} else {
|
} else {
|
||||||
regionTask.run();
|
regionTask.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem) {
|
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem) {
|
||||||
new StateWrapper(ct).restoreTag(x, y, z, schem);
|
new StateWrapper(ct).restoreTag(x, y, z, schem);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,17 +5,9 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||||
import com.intellectualcrafters.plot.util.MathMan;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@ -25,12 +17,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.*;
|
||||||
import org.bukkit.material.Sandstone;
|
|
||||||
import org.bukkit.material.Step;
|
|
||||||
import org.bukkit.material.Tree;
|
|
||||||
import org.bukkit.material.WoodenStep;
|
|
||||||
import org.bukkit.material.Wool;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -171,9 +158,6 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
public int getBiomeFromString(final String biomeStr) {
|
public int getBiomeFromString(final String biomeStr) {
|
||||||
try {
|
try {
|
||||||
final Biome biome = Biome.valueOf(biomeStr.toUpperCase());
|
final Biome biome = Biome.valueOf(biomeStr.toUpperCase());
|
||||||
if (biome == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return Arrays.asList(Biome.values()).indexOf(biome);
|
return Arrays.asList(Biome.values()).indexOf(biome);
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
return -1;
|
return -1;
|
@ -6,36 +6,21 @@ import com.google.common.collect.HashBiMap;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import com.google.common.io.ByteSink;
|
import com.google.common.io.ByteSink;
|
||||||
import com.google.common.io.ByteSource;
|
|
||||||
import com.google.common.io.Closeables;
|
import com.google.common.io.Closeables;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
|
import com.google.common.io.InputSupplier;
|
||||||
import com.google.common.primitives.Primitives;
|
import com.google.common.primitives.Primitives;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.*;
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.AbstractList;
|
import java.util.*;
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.AbstractSet;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
@ -162,13 +147,13 @@ public class NbtFactory {
|
|||||||
* @return The decoded NBT compound.
|
* @return The decoded NBT compound.
|
||||||
* @throws IOException If anything went wrong.
|
* @throws IOException If anything went wrong.
|
||||||
*/
|
*/
|
||||||
public static NbtCompound fromStream(final ByteSource stream, final StreamOptions option) throws IOException {
|
public static NbtCompound fromStream(final InputSupplier<? extends InputStream> stream, final StreamOptions option) throws IOException {
|
||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
DataInputStream data = null;
|
DataInputStream data = null;
|
||||||
boolean suppress = true;
|
boolean suppress = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
input = stream.openStream();
|
input = stream.getInput();
|
||||||
data = new DataInputStream(new BufferedInputStream(option == StreamOptions.GZIP_COMPRESSION ? new GZIPInputStream(input) : input));
|
data = new DataInputStream(new BufferedInputStream(option == StreamOptions.GZIP_COMPRESSION ? new GZIPInputStream(input) : input));
|
||||||
|
|
||||||
final NbtCompound result = fromCompound(get().LOAD_COMPOUND.loadNbt(data));
|
final NbtCompound result = fromCompound(get().LOAD_COMPOUND.loadNbt(data));
|
@ -1,193 +1,138 @@
|
|||||||
package com.plotsquared.bukkit.util;
|
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.PS;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import org.bukkit.Bukkit;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.World;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
/**
|
||||||
import java.util.List;
|
* An utility that can be used to send chunks, rather than using bukkit code to do so (uses heavy NMS)
|
||||||
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");
|
||||||
public class SendChunk {
|
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||||
|
private final RefClass classPacket = getRefClass("{nms}.Packet");
|
||||||
// // Ref Class
|
private final RefClass classConnection = getRefClass("{nms}.PlayerConnection");
|
||||||
private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
||||||
private final RefClass classPacket = getRefClass("{nms}.Packet");
|
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||||
private final RefClass classConnection = getRefClass("{nms}.PlayerConnection");
|
private final RefMethod methodGetHandlePlayer;
|
||||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
private final RefMethod methodGetHandleChunk;
|
||||||
private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
private final RefConstructor MapChunk;
|
||||||
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
private final RefField connection;
|
||||||
private final RefMethod methodGetHandlePlayer;
|
private final RefMethod send;
|
||||||
private final RefMethod methodGetHandleChunk;
|
private final RefMethod methodInitLighting;
|
||||||
private final RefConstructor MapChunk;
|
|
||||||
private final RefField connection;
|
/**
|
||||||
private final RefMethod send;
|
* Constructor
|
||||||
private final RefMethod methodInitLighting;
|
*/
|
||||||
|
public SendChunk() {
|
||||||
/**
|
methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
||||||
* Constructor
|
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||||
*/
|
methodInitLighting = classChunk.getMethod("initLighting");
|
||||||
public SendChunk() {
|
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||||
methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
connection = classEntityPlayer.getField("playerConnection");
|
||||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
|
||||||
methodInitLighting = classChunk.getMethod("initLighting");
|
}
|
||||||
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
|
||||||
connection = classEntityPlayer.getField("playerConnection");
|
public void sendChunk(final Collection<Chunk> input) {
|
||||||
send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
|
final HashSet<Chunk> chunks = new HashSet<Chunk>(input);
|
||||||
}
|
final HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
|
||||||
|
final int view = Bukkit.getServer().getViewDistance();
|
||||||
public void sendChunk(final Collection<Chunk> input) {
|
for (final Chunk chunk : chunks) {
|
||||||
final HashSet<Chunk> chunks = new HashSet<Chunk>(input);
|
final String world = chunk.getWorld().getName();
|
||||||
final HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
|
ArrayList<Chunk> list = map.get(world);
|
||||||
final int view = Bukkit.getServer().getViewDistance();
|
if (list == null) {
|
||||||
for (final Chunk chunk : chunks) {
|
list = new ArrayList<>();
|
||||||
final String world = chunk.getWorld().getName();
|
map.put(world, list);
|
||||||
ArrayList<Chunk> list = map.get(world);
|
}
|
||||||
if (list == null) {
|
list.add(chunk);
|
||||||
list = new ArrayList<>();
|
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||||
map.put(world, list);
|
methodInitLighting.of(c).call();
|
||||||
}
|
}
|
||||||
list.add(chunk);
|
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
PlotPlayer pp = entry.getValue();
|
||||||
methodInitLighting.of(c).call();
|
final Plot plot = pp.getCurrentPlot();
|
||||||
}
|
Location loc = null;
|
||||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
String world;
|
||||||
PlotPlayer pp = entry.getValue();
|
if (plot != null) {
|
||||||
final Plot plot = pp.getCurrentPlot();
|
world = plot.getArea().worldname;
|
||||||
Location loc = null;
|
} else {
|
||||||
String world;
|
loc = pp.getLocation();
|
||||||
if (plot != null) {
|
world = loc.getWorld();
|
||||||
world = plot.getArea().worldname;
|
}
|
||||||
} else {
|
final ArrayList<Chunk> list = map.get(world);
|
||||||
loc = pp.getLocation();
|
if (list == null) {
|
||||||
world = loc.getWorld();
|
continue;
|
||||||
}
|
}
|
||||||
final ArrayList<Chunk> list = map.get(world);
|
if (loc == null) {
|
||||||
if (list == null) {
|
loc = pp.getLocation();
|
||||||
continue;
|
}
|
||||||
}
|
final int cx = loc.getX() >> 4;
|
||||||
if (loc == null) {
|
final int cz = loc.getZ() >> 4;
|
||||||
loc = pp.getLocation();
|
final Player player = ((BukkitPlayer) pp).player;
|
||||||
}
|
final Object entity = methodGetHandlePlayer.of(player).call();
|
||||||
final int cx = loc.getX() >> 4;
|
|
||||||
final int cz = loc.getZ() >> 4;
|
for (final Chunk chunk : list) {
|
||||||
final Player player = ((BukkitPlayer) pp).player;
|
final int dx = Math.abs(cx - chunk.getX());
|
||||||
final Object entity = methodGetHandlePlayer.of(player).call();
|
final int dz = Math.abs(cz - chunk.getZ());
|
||||||
|
if ((dx > view) || (dz > view)) {
|
||||||
for (final Chunk chunk : list) {
|
continue;
|
||||||
final int dx = Math.abs(cx - chunk.getX());
|
}
|
||||||
final int dz = Math.abs(cz - chunk.getZ());
|
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||||
if ((dx > view) || (dz > view)) {
|
chunks.remove(chunk);
|
||||||
continue;
|
final Object con = connection.of(entity).get();
|
||||||
}
|
final Object packet = MapChunk.create(c, true, 65535);
|
||||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
send.of(con).call(packet);
|
||||||
chunks.remove(chunk);
|
}
|
||||||
final Object con = connection.of(entity).get();
|
}
|
||||||
// if (dx != 0 || dz != 0) {
|
for (final Chunk chunk : chunks) {
|
||||||
// Object packet = MapChunk.create(c, true, 0);
|
TaskManager.runTask(new Runnable() {
|
||||||
// send.of(con).call(packet);
|
@Override
|
||||||
// }
|
public void run() {
|
||||||
final Object packet = MapChunk.create(c, true, 65535);
|
try {
|
||||||
send.of(con).call(packet);
|
chunk.unload(true, false);
|
||||||
}
|
} catch (final Throwable e) {
|
||||||
}
|
final String worldname = chunk.getWorld().getName();
|
||||||
for (final Chunk chunk : chunks) {
|
PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||||
TaskManager.runTask(new Runnable() {
|
PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||||
@Override
|
PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname
|
||||||
public void run() {
|
+ "/level_old.dat may be corrupt (try repairing or removing these)");
|
||||||
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
|
public void sendChunk(final String worldname, final List<ChunkLoc> locs) {
|
||||||
+ "/level_old.dat may be corrupt (try repairing or removing these)");
|
final World myworld = Bukkit.getWorld(worldname);
|
||||||
}
|
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
}
|
for (final ChunkLoc loc : locs) {
|
||||||
});
|
if (myworld.isChunkLoaded(loc.x, loc.z)) {
|
||||||
}
|
chunks.add(myworld.getChunkAt(loc.x, loc.z));
|
||||||
//
|
}
|
||||||
//
|
}
|
||||||
// int diffx, diffz;
|
sendChunk(chunks);
|
||||||
// << 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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.plotsquared.bukkit.util.block;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||||
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
|
||||||
|
public class FastChunk_1_9 extends PlotChunk<Chunk> {
|
||||||
|
|
||||||
|
public FastChunk_1_9(SetQueue.ChunkWrapper wrap) {
|
||||||
|
super(wrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Chunk getChunkAbs() {
|
||||||
|
SetQueue.ChunkWrapper loc = getChunkWrapper();
|
||||||
|
return BukkitUtil.getWorld(loc.world).getChunkAt(loc.x, loc.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setBlock(int x, int y, int z, int id, byte data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setBiome(int x, int z, int biome) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotChunk clone() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public PlotChunk shallowClone() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -49,11 +49,8 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||||
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
||||||
public HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
public HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||||
private RefMethod methodGetHandlePlayer;
|
|
||||||
private RefMethod methodGetHandleChunk;
|
private RefMethod methodGetHandleChunk;
|
||||||
private RefConstructor MapChunk;
|
private RefConstructor MapChunk;
|
||||||
private RefField connection;
|
|
||||||
private RefMethod send;
|
|
||||||
private RefMethod methodInitLighting;
|
private RefMethod methodInitLighting;
|
||||||
private RefConstructor classBlockPositionConstructor;
|
private RefConstructor classBlockPositionConstructor;
|
||||||
private RefConstructor classChunkSectionConstructor;
|
private RefConstructor classChunkSectionConstructor;
|
||||||
@ -64,12 +61,9 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
private RefMethod methodGetIdArray;
|
private RefMethod methodGetIdArray;
|
||||||
|
|
||||||
public FastQueue_1_8_3() throws NoSuchMethodException, RuntimeException {
|
public FastQueue_1_8_3() throws NoSuchMethodException, RuntimeException {
|
||||||
methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
|
||||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||||
methodInitLighting = classChunk.getMethod("initLighting");
|
methodInitLighting = classChunk.getMethod("initLighting");
|
||||||
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||||
connection = classEntityPlayer.getField("playerConnection");
|
|
||||||
send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
|
|
||||||
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||||
methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
|
methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
|
||||||
fieldSections = classChunk.getField("sections");
|
fieldSections = classChunk.getField("sections");
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.plotsquared.bukkit.util.block;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||||
|
import com.intellectualcrafters.plot.util.SetQueue;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
|
||||||
|
public class FastQueue_1_9 extends SlowQueue {
|
||||||
|
|
||||||
|
@Override public PlotChunk<Chunk> getChunk(SetQueue.ChunkWrapper wrap) {
|
||||||
|
return new FastChunk_1_9(wrap);
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@ public class GenChunk extends PlotChunk<Chunk> {
|
|||||||
|
|
||||||
public GenChunk(Chunk chunk, ChunkWrapper wrap) {
|
public GenChunk(Chunk chunk, ChunkWrapper wrap) {
|
||||||
super(wrap);
|
super(wrap);
|
||||||
if ((this.chunk = chunk) == null) {
|
if ((this.chunk = chunk) == null && wrap != null) {
|
||||||
World world = BukkitUtil.getWorld(wrap.world);
|
World world = BukkitUtil.getWorld(wrap.world);
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
chunk = world.getChunkAt(wrap.x, wrap.z);
|
chunk = world.getChunkAt(wrap.x, wrap.z);
|
||||||
@ -34,7 +34,7 @@ public class GenChunk extends PlotChunk<Chunk> {
|
|||||||
@Override
|
@Override
|
||||||
public Chunk getChunkAbs() {
|
public Chunk getChunkAbs() {
|
||||||
ChunkWrapper wrap = getChunkWrapper();
|
ChunkWrapper wrap = getChunkWrapper();
|
||||||
if (wrap.x != chunk.getX() || wrap.z != chunk.getZ()) {
|
if (chunk == null || wrap.x != chunk.getX() || wrap.z != chunk.getZ()) {
|
||||||
chunk = BukkitUtil.getWorld(wrap.world).getChunkAt(wrap.x, wrap.z);
|
chunk = BukkitUtil.getWorld(wrap.world).getChunkAt(wrap.x, wrap.z);
|
||||||
}
|
}
|
||||||
return chunk;
|
return chunk;
|
||||||
@ -65,9 +65,14 @@ public class GenChunk extends PlotChunk<Chunk> {
|
|||||||
modified = true;
|
modified = true;
|
||||||
result[i] = v = new short[4096];
|
result[i] = v = new short[4096];
|
||||||
}
|
}
|
||||||
v[MainUtil.CACHE_J[y][x][z]] = (short) id;
|
int j = MainUtil.CACHE_J[y][x][z];
|
||||||
|
v[j] = (short) id;
|
||||||
if (data != 0) {
|
if (data != 0) {
|
||||||
getChunk().getBlock(x, y, z).setData(data);
|
byte[] vd = result_data[i];
|
||||||
|
if (vd == null) {
|
||||||
|
result_data[i] = vd = new byte[4096];
|
||||||
|
}
|
||||||
|
vd[j] = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,7 +11,6 @@ public class SlowChunk extends PlotChunk<Chunk> {
|
|||||||
|
|
||||||
public PlotBlock[][] result = new PlotBlock[16][];
|
public PlotBlock[][] result = new PlotBlock[16][];
|
||||||
public int[][] biomes;
|
public int[][] biomes;
|
||||||
private PlotBlock lastBlock;
|
|
||||||
public SlowChunk(ChunkWrapper chunk) {
|
public SlowChunk(ChunkWrapper chunk) {
|
||||||
super(chunk);
|
super(chunk);
|
||||||
}
|
}
|
||||||
@ -35,11 +34,7 @@ public class SlowChunk extends PlotChunk<Chunk> {
|
|||||||
if (result[y >> 4] == null) {
|
if (result[y >> 4] == null) {
|
||||||
result[y >> 4] = new PlotBlock[4096];
|
result[y >> 4] = new PlotBlock[4096];
|
||||||
}
|
}
|
||||||
if (id == lastBlock.id && data == lastBlock.data) {
|
result[MainUtil.CACHE_I[y][x][z]][MainUtil.CACHE_J[y][x][z]] = new PlotBlock((short) id, data);
|
||||||
result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = lastBlock;
|
|
||||||
} else {
|
|
||||||
result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = new PlotBlock((short) id, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -123,6 +123,9 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
|||||||
final int z = MainUtil.z_loc[i][j];
|
final int z = MainUtil.z_loc[i][j];
|
||||||
Block block = chunk.getBlock(x, y, z);
|
Block block = chunk.getBlock(x, y, z);
|
||||||
PlotBlock newBlock = result2[j];
|
PlotBlock newBlock = result2[j];
|
||||||
|
if (newBlock == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch (newBlock.id) {
|
switch (newBlock.id) {
|
||||||
case -1:
|
case -1:
|
||||||
if (block.getData() == newBlock.data) {
|
if (block.getData() == newBlock.data) {
|
@ -2,6 +2,7 @@ package com.plotsquared.bukkit.uuid;
|
|||||||
|
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.google.common.io.ByteSource;
|
import com.google.common.io.ByteSource;
|
||||||
|
import com.google.common.io.InputSupplier;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
@ -9,17 +10,14 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
|||||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
import com.plotsquared.bukkit.util.NbtFactory;
|
import com.plotsquared.bukkit.util.NbtFactory;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -102,12 +100,14 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
final UUID uuid = UUID.fromString(s);
|
final UUID uuid = UUID.fromString(s);
|
||||||
if (check || all.remove(uuid)) {
|
if (check || all.remove(uuid)) {
|
||||||
final File file = new File(playerdataFolder + File.separator + current);
|
final File file = new File(playerdataFolder + File.separator + current);
|
||||||
final ByteSource is = com.google.common.io.Files.asByteSource(file);
|
final InputSupplier<FileInputStream> is = com.google.common.io.Files.newInputStreamSupplier(file);
|
||||||
final NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
final NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||||
final NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
final NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||||
final String name = (String) bukkit.get("lastKnownName");
|
final String name = (String) bukkit.get("lastKnownName");
|
||||||
final long last = (long) bukkit.get("lastPlayed");
|
final long last = (long) bukkit.get("lastPlayed");
|
||||||
ExpireManager.dates.put(uuid, last);
|
if (ExpireManager.IMP != null) {
|
||||||
|
ExpireManager.IMP.storeDate(uuid, last);
|
||||||
|
}
|
||||||
toAdd.put(new StringWrapper(name), uuid);
|
toAdd.put(new StringWrapper(name), uuid);
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
@ -173,6 +173,9 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
try {
|
try {
|
||||||
final File file = new File(playerdataFolder + File.separator + uuid.toString() + ".dat");
|
final File file = new File(playerdataFolder + File.separator + uuid.toString() + ".dat");
|
||||||
|
if (!file.exists()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
final ByteSource is = com.google.common.io.Files.asByteSource(file);
|
final ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||||
final NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
final NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||||
final NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
final NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||||
@ -187,7 +190,9 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
uuid = new UUID(most, least);
|
uuid = new UUID(most, least);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExpireManager.dates.put(uuid, last);
|
if (ExpireManager.IMP != null) {
|
||||||
|
ExpireManager.IMP.storeDate(uuid, last);
|
||||||
|
}
|
||||||
toAdd.put(new StringWrapper(name), uuid);
|
toAdd.put(new StringWrapper(name), uuid);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
PS.debug(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
|
PS.debug(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
|
||||||
@ -207,7 +212,9 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
final StringWrapper wrap = new StringWrapper(name);
|
final StringWrapper wrap = new StringWrapper(name);
|
||||||
final UUID uuid = uuidWrapper.getUUID(op);
|
final UUID uuid = uuidWrapper.getUUID(op);
|
||||||
toAdd.put(wrap, uuid);
|
toAdd.put(wrap, uuid);
|
||||||
ExpireManager.dates.put(uuid, last);
|
if (ExpireManager.IMP != null) {
|
||||||
|
ExpireManager.IMP.storeDate(uuid, last);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
name: ${project.name}
|
name: ${name}
|
||||||
main: com.plotsquared.bukkit.BukkitMain
|
main: com.plotsquared.bukkit.BukkitMain
|
||||||
version: ${project.version}
|
version: ${version}
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
description: >
|
description: >
|
||||||
Easy, yet powerful Plot World generation and management.
|
Easy, yet powerful Plot World generation and management.
|
||||||
@ -146,6 +146,7 @@ permissions:
|
|||||||
plots.save: true
|
plots.save: true
|
||||||
plots.done: true
|
plots.done: true
|
||||||
plots.continue: true
|
plots.continue: true
|
||||||
|
plots.middle: true
|
||||||
plots.worldedit.bypass:
|
plots.worldedit.bypass:
|
||||||
default: false
|
default: false
|
||||||
plots.gamemode.bypass:
|
plots.gamemode.bypass:
|
11
Core/build.gradle
Normal file
11
Core/build.gradle
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
dependencies {
|
||||||
|
testCompile 'junit:junit:4.12'
|
||||||
|
compile 'org.yaml:snakeyaml:1.16'
|
||||||
|
compile 'com.google.code.gson:gson:2.2.4'
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = 1.7
|
||||||
|
targetCompatibility = 1.7
|
||||||
|
|
||||||
|
jar.archiveName="PlotSquared-API-${parent.version}.jar"
|
||||||
|
jar.destinationDir = file '../target'
|
@ -20,8 +20,7 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
* @param value Value to set the default to.
|
* @param value Value to set the default to.
|
||||||
* @throws IllegalArgumentException Thrown if path is null.
|
* @throws IllegalArgumentException Thrown if path is null.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override void addDefault(final String path, final Object value);
|
||||||
public void addDefault(final String path, final Object value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default values of the given paths as provided.
|
* Sets the default values of the given paths as provided.
|
||||||
@ -33,7 +32,7 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
* @param defaults A map of Path->Values to add to defaults.
|
* @param defaults A map of Path->Values to add to defaults.
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null.
|
* @throws IllegalArgumentException Thrown if defaults is null.
|
||||||
*/
|
*/
|
||||||
public void addDefaults(final Map<String, Object> defaults);
|
void addDefaults(final Map<String, Object> defaults);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default values of the given paths as provided.
|
* Sets the default values of the given paths as provided.
|
||||||
@ -50,7 +49,7 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
* @param defaults A configuration holding a list of defaults to copy.
|
* @param defaults A configuration holding a list of defaults to copy.
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
||||||
*/
|
*/
|
||||||
public void addDefaults(final Configuration defaults);
|
void addDefaults(final Configuration defaults);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the source of all default values for this {@link Configuration}.
|
* Sets the source of all default values for this {@link Configuration}.
|
||||||
@ -61,7 +60,7 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
* @param defaults New source of default values for this configuration.
|
* @param defaults New source of default values for this configuration.
|
||||||
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
* @throws IllegalArgumentException Thrown if defaults is null or this.
|
||||||
*/
|
*/
|
||||||
public void setDefaults(final Configuration defaults);
|
void setDefaults(final Configuration defaults);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the source {@link Configuration} for this configuration.
|
* Gets the source {@link Configuration} for this configuration.
|
||||||
@ -72,7 +71,7 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
*
|
*
|
||||||
* @return Configuration source for default values, or null if none exist.
|
* @return Configuration source for default values, or null if none exist.
|
||||||
*/
|
*/
|
||||||
public Configuration getDefaults();
|
Configuration getDefaults();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
|
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
|
||||||
@ -81,5 +80,5 @@ public interface Configuration extends ConfigurationSection {
|
|||||||
*
|
*
|
||||||
* @return Options for this configuration
|
* @return Options for this configuration
|
||||||
*/
|
*/
|
||||||
public ConfigurationOptions options();
|
ConfigurationOptions options();
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ public interface ConfigurationSection {
|
|||||||
* list.
|
* list.
|
||||||
* @return Set of keys contained within this ConfigurationSection.
|
* @return Set of keys contained within this ConfigurationSection.
|
||||||
*/
|
*/
|
||||||
public Set<String> getKeys(final boolean deep);
|
Set<String> getKeys(final boolean deep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a Map containing all keys and their values for this section.
|
* Gets a Map containing all keys and their values for this section.
|
||||||
@ -38,7 +38,7 @@ public interface ConfigurationSection {
|
|||||||
* list.
|
* list.
|
||||||
* @return Map of keys and values of this section.
|
* @return Map of keys and values of this section.
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> getValues(final boolean deep);
|
Map<String, Object> getValues(final boolean deep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this {@link ConfigurationSection} contains the given path.
|
* Checks if this {@link ConfigurationSection} contains the given path.
|
||||||
@ -51,7 +51,7 @@ public interface ConfigurationSection {
|
|||||||
* default or being set.
|
* default or being set.
|
||||||
* @throws IllegalArgumentException Thrown when path is null.
|
* @throws IllegalArgumentException Thrown when path is null.
|
||||||
*/
|
*/
|
||||||
public boolean contains(final String path);
|
boolean contains(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this {@link ConfigurationSection} has a value set for the
|
* Checks if this {@link ConfigurationSection} has a value set for the
|
||||||
@ -65,7 +65,7 @@ public interface ConfigurationSection {
|
|||||||
* having a default.
|
* having a default.
|
||||||
* @throws IllegalArgumentException Thrown when path is null.
|
* @throws IllegalArgumentException Thrown when path is null.
|
||||||
*/
|
*/
|
||||||
public boolean isSet(final String path);
|
boolean isSet(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the path of this {@link ConfigurationSection} from its root {@link
|
* Gets the path of this {@link ConfigurationSection} from its root {@link
|
||||||
@ -82,7 +82,7 @@ public interface ConfigurationSection {
|
|||||||
*
|
*
|
||||||
* @return Path of this section relative to its root
|
* @return Path of this section relative to its root
|
||||||
*/
|
*/
|
||||||
public String getCurrentPath();
|
String getCurrentPath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of this individual {@link ConfigurationSection}, in the
|
* Gets the name of this individual {@link ConfigurationSection}, in the
|
||||||
@ -93,7 +93,7 @@ public interface ConfigurationSection {
|
|||||||
*
|
*
|
||||||
* @return Name of this section
|
* @return Name of this section
|
||||||
*/
|
*/
|
||||||
public String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the root {@link Configuration} that contains this {@link
|
* Gets the root {@link Configuration} that contains this {@link
|
||||||
@ -107,7 +107,7 @@ public interface ConfigurationSection {
|
|||||||
*
|
*
|
||||||
* @return Root configuration containing this section.
|
* @return Root configuration containing this section.
|
||||||
*/
|
*/
|
||||||
public Configuration getRoot();
|
Configuration getRoot();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the parent {@link ConfigurationSection} that directly contains
|
* Gets the parent {@link ConfigurationSection} that directly contains
|
||||||
@ -120,7 +120,7 @@ public interface ConfigurationSection {
|
|||||||
*
|
*
|
||||||
* @return Parent section containing this section.
|
* @return Parent section containing this section.
|
||||||
*/
|
*/
|
||||||
public ConfigurationSection getParent();
|
ConfigurationSection getParent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested Object by path.
|
* Gets the requested Object by path.
|
||||||
@ -132,7 +132,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the Object to get.
|
* @param path Path of the Object to get.
|
||||||
* @return Requested Object.
|
* @return Requested Object.
|
||||||
*/
|
*/
|
||||||
public Object get(final String path);
|
Object get(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested Object by path, returning a default value if not
|
* Gets the requested Object by path, returning a default value if not
|
||||||
@ -146,7 +146,7 @@ public interface ConfigurationSection {
|
|||||||
* @param def The default value to return if the path is not found.
|
* @param def The default value to return if the path is not found.
|
||||||
* @return Requested Object.
|
* @return Requested Object.
|
||||||
*/
|
*/
|
||||||
public Object get(final String path, final Object def);
|
Object get(final String path, final Object def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the specified path to the given value.
|
* Sets the specified path to the given value.
|
||||||
@ -162,7 +162,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the object to set.
|
* @param path Path of the object to set.
|
||||||
* @param value New value to set the path to.
|
* @param value New value to set the path to.
|
||||||
*/
|
*/
|
||||||
public void set(final String path, final Object value);
|
void set(final String path, final Object value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@link ConfigurationSection} at the specified path.
|
* Creates an empty {@link ConfigurationSection} at the specified path.
|
||||||
@ -174,7 +174,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path to create the section at.
|
* @param path Path to create the section at.
|
||||||
* @return Newly created section
|
* @return Newly created section
|
||||||
*/
|
*/
|
||||||
public ConfigurationSection createSection(final String path);
|
ConfigurationSection createSection(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link ConfigurationSection} at the specified path, with
|
* Creates a {@link ConfigurationSection} at the specified path, with
|
||||||
@ -188,7 +188,7 @@ public interface ConfigurationSection {
|
|||||||
* @param map The values to used.
|
* @param map The values to used.
|
||||||
* @return Newly created section
|
* @return Newly created section
|
||||||
*/
|
*/
|
||||||
public ConfigurationSection createSection(final String path, final Map<?, ?> map);
|
ConfigurationSection createSection(final String path, final Map<?, ?> map);
|
||||||
|
|
||||||
// Primitives
|
// Primitives
|
||||||
/**
|
/**
|
||||||
@ -201,7 +201,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the String to get.
|
* @param path Path of the String to get.
|
||||||
* @return Requested String.
|
* @return Requested String.
|
||||||
*/
|
*/
|
||||||
public String getString(final String path);
|
String getString(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested String by path, returning a default value if not
|
* Gets the requested String by path, returning a default value if not
|
||||||
@ -216,7 +216,7 @@ public interface ConfigurationSection {
|
|||||||
* not a String.
|
* not a String.
|
||||||
* @return Requested String.
|
* @return Requested String.
|
||||||
*/
|
*/
|
||||||
public String getString(final String path, final String def);
|
String getString(final String path, final String def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a String.
|
* Checks if the specified path is a String.
|
||||||
@ -229,7 +229,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the String to check.
|
* @param path Path of the String to check.
|
||||||
* @return Whether or not the specified path is a String.
|
* @return Whether or not the specified path is a String.
|
||||||
*/
|
*/
|
||||||
public boolean isString(final String path);
|
boolean isString(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested int by path.
|
* Gets the requested int by path.
|
||||||
@ -241,7 +241,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the int to get.
|
* @param path Path of the int to get.
|
||||||
* @return Requested int.
|
* @return Requested int.
|
||||||
*/
|
*/
|
||||||
public int getInt(final String path);
|
int getInt(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested int by path, returning a default value if not found.
|
* Gets the requested int by path, returning a default value if not found.
|
||||||
@ -255,7 +255,7 @@ public interface ConfigurationSection {
|
|||||||
* not an int.
|
* not an int.
|
||||||
* @return Requested int.
|
* @return Requested int.
|
||||||
*/
|
*/
|
||||||
public int getInt(final String path, final int def);
|
int getInt(final String path, final int def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is an int.
|
* Checks if the specified path is an int.
|
||||||
@ -268,7 +268,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the int to check.
|
* @param path Path of the int to check.
|
||||||
* @return Whether or not the specified path is an int.
|
* @return Whether or not the specified path is an int.
|
||||||
*/
|
*/
|
||||||
public boolean isInt(final String path);
|
boolean isInt(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested boolean by path.
|
* Gets the requested boolean by path.
|
||||||
@ -280,7 +280,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the boolean to get.
|
* @param path Path of the boolean to get.
|
||||||
* @return Requested boolean.
|
* @return Requested boolean.
|
||||||
*/
|
*/
|
||||||
public boolean getBoolean(final String path);
|
boolean getBoolean(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested boolean by path, returning a default value if not
|
* Gets the requested boolean by path, returning a default value if not
|
||||||
@ -295,7 +295,7 @@ public interface ConfigurationSection {
|
|||||||
* not a boolean.
|
* not a boolean.
|
||||||
* @return Requested boolean.
|
* @return Requested boolean.
|
||||||
*/
|
*/
|
||||||
public boolean getBoolean(final String path, final boolean def);
|
boolean getBoolean(final String path, final boolean def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a boolean.
|
* Checks if the specified path is a boolean.
|
||||||
@ -308,7 +308,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the boolean to check.
|
* @param path Path of the boolean to check.
|
||||||
* @return Whether or not the specified path is a boolean.
|
* @return Whether or not the specified path is a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean isBoolean(final String path);
|
boolean isBoolean(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested double by path.
|
* Gets the requested double by path.
|
||||||
@ -320,7 +320,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the double to get.
|
* @param path Path of the double to get.
|
||||||
* @return Requested double.
|
* @return Requested double.
|
||||||
*/
|
*/
|
||||||
public double getDouble(final String path);
|
double getDouble(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested double by path, returning a default value if not
|
* Gets the requested double by path, returning a default value if not
|
||||||
@ -335,7 +335,7 @@ public interface ConfigurationSection {
|
|||||||
* not a double.
|
* not a double.
|
||||||
* @return Requested double.
|
* @return Requested double.
|
||||||
*/
|
*/
|
||||||
public double getDouble(final String path, final double def);
|
double getDouble(final String path, final double def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a double.
|
* Checks if the specified path is a double.
|
||||||
@ -348,7 +348,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the double to check.
|
* @param path Path of the double to check.
|
||||||
* @return Whether or not the specified path is a double.
|
* @return Whether or not the specified path is a double.
|
||||||
*/
|
*/
|
||||||
public boolean isDouble(final String path);
|
boolean isDouble(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested long by path.
|
* Gets the requested long by path.
|
||||||
@ -360,7 +360,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the long to get.
|
* @param path Path of the long to get.
|
||||||
* @return Requested long.
|
* @return Requested long.
|
||||||
*/
|
*/
|
||||||
public long getLong(final String path);
|
long getLong(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested long by path, returning a default value if not
|
* Gets the requested long by path, returning a default value if not
|
||||||
@ -375,7 +375,7 @@ public interface ConfigurationSection {
|
|||||||
* not a long.
|
* not a long.
|
||||||
* @return Requested long.
|
* @return Requested long.
|
||||||
*/
|
*/
|
||||||
public long getLong(final String path, final long def);
|
long getLong(final String path, final long def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a long.
|
* Checks if the specified path is a long.
|
||||||
@ -388,7 +388,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the long to check.
|
* @param path Path of the long to check.
|
||||||
* @return Whether or not the specified path is a long.
|
* @return Whether or not the specified path is a long.
|
||||||
*/
|
*/
|
||||||
public boolean isLong(final String path);
|
boolean isLong(final String path);
|
||||||
|
|
||||||
// Java
|
// Java
|
||||||
/**
|
/**
|
||||||
@ -401,7 +401,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List.
|
* @return Requested List.
|
||||||
*/
|
*/
|
||||||
public List<?> getList(final String path);
|
List<?> getList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List by path, returning a default value if not
|
* Gets the requested List by path, returning a default value if not
|
||||||
@ -416,7 +416,7 @@ public interface ConfigurationSection {
|
|||||||
* not a List.
|
* not a List.
|
||||||
* @return Requested List.
|
* @return Requested List.
|
||||||
*/
|
*/
|
||||||
public List<?> getList(final String path, final List<?> def);
|
List<?> getList(final String path, final List<?> def);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a List.
|
* Checks if the specified path is a List.
|
||||||
@ -429,7 +429,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to check.
|
* @param path Path of the List to check.
|
||||||
* @return Whether or not the specified path is a List.
|
* @return Whether or not the specified path is a List.
|
||||||
*/
|
*/
|
||||||
public boolean isList(final String path);
|
boolean isList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of String by path.
|
* Gets the requested List of String by path.
|
||||||
@ -444,7 +444,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of String.
|
* @return Requested List of String.
|
||||||
*/
|
*/
|
||||||
public List<String> getStringList(final String path);
|
List<String> getStringList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Integer by path.
|
* Gets the requested List of Integer by path.
|
||||||
@ -459,7 +459,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Integer.
|
* @return Requested List of Integer.
|
||||||
*/
|
*/
|
||||||
public List<Integer> getIntegerList(final String path);
|
List<Integer> getIntegerList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Boolean by path.
|
* Gets the requested List of Boolean by path.
|
||||||
@ -474,7 +474,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Boolean.
|
* @return Requested List of Boolean.
|
||||||
*/
|
*/
|
||||||
public List<Boolean> getBooleanList(final String path);
|
List<Boolean> getBooleanList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Double by path.
|
* Gets the requested List of Double by path.
|
||||||
@ -489,7 +489,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Double.
|
* @return Requested List of Double.
|
||||||
*/
|
*/
|
||||||
public List<Double> getDoubleList(final String path);
|
List<Double> getDoubleList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Float by path.
|
* Gets the requested List of Float by path.
|
||||||
@ -504,7 +504,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Float.
|
* @return Requested List of Float.
|
||||||
*/
|
*/
|
||||||
public List<Float> getFloatList(final String path);
|
List<Float> getFloatList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Long by path.
|
* Gets the requested List of Long by path.
|
||||||
@ -519,7 +519,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Long.
|
* @return Requested List of Long.
|
||||||
*/
|
*/
|
||||||
public List<Long> getLongList(final String path);
|
List<Long> getLongList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Byte by path.
|
* Gets the requested List of Byte by path.
|
||||||
@ -534,7 +534,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Byte.
|
* @return Requested List of Byte.
|
||||||
*/
|
*/
|
||||||
public List<Byte> getByteList(final String path);
|
List<Byte> getByteList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Character by path.
|
* Gets the requested List of Character by path.
|
||||||
@ -549,7 +549,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Character.
|
* @return Requested List of Character.
|
||||||
*/
|
*/
|
||||||
public List<Character> getCharacterList(final String path);
|
List<Character> getCharacterList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Short by path.
|
* Gets the requested List of Short by path.
|
||||||
@ -564,7 +564,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Short.
|
* @return Requested List of Short.
|
||||||
*/
|
*/
|
||||||
public List<Short> getShortList(final String path);
|
List<Short> getShortList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Maps by path.
|
* Gets the requested List of Maps by path.
|
||||||
@ -579,7 +579,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Maps.
|
* @return Requested List of Maps.
|
||||||
*/
|
*/
|
||||||
public List<Map<?, ?>> getMapList(final String path);
|
List<Map<?, ?>> getMapList(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested ConfigurationSection by path.
|
* Gets the requested ConfigurationSection by path.
|
||||||
@ -592,7 +592,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the ConfigurationSection to get.
|
* @param path Path of the ConfigurationSection to get.
|
||||||
* @return Requested ConfigurationSection.
|
* @return Requested ConfigurationSection.
|
||||||
*/
|
*/
|
||||||
public ConfigurationSection getConfigurationSection(final String path);
|
ConfigurationSection getConfigurationSection(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a ConfigurationSection.
|
* Checks if the specified path is a ConfigurationSection.
|
||||||
@ -606,7 +606,7 @@ public interface ConfigurationSection {
|
|||||||
* @param path Path of the ConfigurationSection to check.
|
* @param path Path of the ConfigurationSection to check.
|
||||||
* @return Whether or not the specified path is a ConfigurationSection.
|
* @return Whether or not the specified path is a ConfigurationSection.
|
||||||
*/
|
*/
|
||||||
public boolean isConfigurationSection(final String path);
|
boolean isConfigurationSection(final String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the equivalent {@link ConfigurationSection} from the default
|
* Gets the equivalent {@link ConfigurationSection} from the default
|
||||||
@ -618,7 +618,7 @@ public interface ConfigurationSection {
|
|||||||
*
|
*
|
||||||
* @return Equivalent section in root configuration
|
* @return Equivalent section in root configuration
|
||||||
*/
|
*/
|
||||||
public ConfigurationSection getDefaultSection();
|
ConfigurationSection getDefaultSection();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the default value in the root at the given path as provided.
|
* Sets the default value in the root at the given path as provided.
|
||||||
@ -638,5 +638,5 @@ public interface ConfigurationSection {
|
|||||||
* @param value Value to set the default to.
|
* @param value Value to set the default to.
|
||||||
* @throws IllegalArgumentException Thrown if path is null.
|
* @throws IllegalArgumentException Thrown if path is null.
|
||||||
*/
|
*/
|
||||||
public void addDefault(final String path, final Object value);
|
void addDefault(final String path, final Object value);
|
||||||
}
|
}
|
@ -1,65 +1,27 @@
|
|||||||
package com.intellectualcrafters.configuration.file;
|
package com.intellectualcrafters.configuration.file;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.configuration.Configuration;
|
||||||
|
import com.intellectualcrafters.configuration.InvalidConfigurationException;
|
||||||
|
import com.intellectualcrafters.configuration.MemoryConfiguration;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.configuration.Configuration;
|
|
||||||
import com.intellectualcrafters.configuration.InvalidConfigurationException;
|
|
||||||
import com.intellectualcrafters.configuration.MemoryConfiguration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a base class for all File based implementations of {@link
|
* This is a base class for all File based implementations of {@link
|
||||||
* Configuration}
|
* Configuration}
|
||||||
*/
|
*/
|
||||||
public abstract class FileConfiguration extends MemoryConfiguration {
|
public abstract class FileConfiguration extends MemoryConfiguration {
|
||||||
/**
|
|
||||||
* This value specified that the system default encoding should be
|
|
||||||
* completely ignored, as it cannot handle the ASCII character set, or it
|
|
||||||
* is a strict-subset of UTF8 already (plain ASCII).
|
|
||||||
*
|
|
||||||
* @deprecated temporary compatibility measure
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static final boolean UTF8_OVERRIDE;
|
|
||||||
/**
|
|
||||||
* This value specifies if the system default encoding is unicode, but
|
|
||||||
* cannot parse standard ASCII.
|
|
||||||
*
|
|
||||||
* @deprecated temporary compatibility measure
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static final boolean UTF_BIG;
|
|
||||||
/**
|
|
||||||
* This value specifies if the system supports unicode.
|
|
||||||
*
|
|
||||||
* @deprecated temporary compatibility measure
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static final boolean SYSTEM_UTF;
|
|
||||||
static {
|
|
||||||
final byte[] testBytes = Base64Coder.decode("ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVpbXF1eX2BhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ent8fX4NCg==");
|
|
||||||
final String testString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\r\n";
|
|
||||||
final Charset defaultCharset = Charset.defaultCharset();
|
|
||||||
final String resultString = new String(testBytes, defaultCharset);
|
|
||||||
final boolean trueUTF = defaultCharset.name().contains("UTF");
|
|
||||||
UTF8_OVERRIDE = !testString.equals(resultString) || defaultCharset.equals(Charset.forName("US-ASCII"));
|
|
||||||
SYSTEM_UTF = trueUTF || UTF8_OVERRIDE;
|
|
||||||
UTF_BIG = trueUTF && UTF8_OVERRIDE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@link FileConfiguration} with no default values.
|
* Creates an empty {@link FileConfiguration} with no default values.
|
||||||
*/
|
*/
|
||||||
@ -100,8 +62,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
|
|
||||||
final String data = saveToString();
|
final String data = saveToString();
|
||||||
|
|
||||||
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file),
|
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
|
||||||
UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset())) {
|
|
||||||
writer.write(data);
|
writer.write(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,9 +107,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* If the file cannot be loaded for any reason, an exception will be
|
* If the file cannot be loaded for any reason, an exception will be
|
||||||
* thrown.
|
* thrown.
|
||||||
* <p>
|
* <p>
|
||||||
* This will attempt to use the {@link Charset#defaultCharset()} for
|
|
||||||
* files, unless {@link #UTF8_OVERRIDE} but not {@link #UTF_BIG} is
|
|
||||||
* specified.
|
|
||||||
*
|
*
|
||||||
* @param file File to load from.
|
* @param file File to load from.
|
||||||
* @throws FileNotFoundException Thrown when the given file cannot be
|
* @throws FileNotFoundException Thrown when the given file cannot be
|
||||||
@ -165,36 +123,9 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
|
|
||||||
final FileInputStream stream = new FileInputStream(file);
|
final FileInputStream stream = new FileInputStream(file);
|
||||||
|
|
||||||
load(new InputStreamReader(stream, UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset()));
|
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads this {@link FileConfiguration} from the specified stream.
|
|
||||||
* <p>
|
|
||||||
* All the values contained within this configuration will be removed,
|
|
||||||
* leaving only settings and defaults, and the new values will be loaded
|
|
||||||
* from the given stream.
|
|
||||||
* <p>
|
|
||||||
* This will attempt to use the {@link Charset#defaultCharset()}, unless
|
|
||||||
* {@link #UTF8_OVERRIDE} or {@link #UTF_BIG} is specified.
|
|
||||||
*
|
|
||||||
* @param stream Stream to load from
|
|
||||||
* @throws IOException Thrown when the given file cannot be read.
|
|
||||||
* @throws InvalidConfigurationException Thrown when the given file is not
|
|
||||||
* a valid Configuration.
|
|
||||||
* @throws IllegalArgumentException Thrown when stream is null.
|
|
||||||
* @deprecated This does not consider encoding
|
|
||||||
* @see #load(Reader)
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void load(final InputStream stream) throws IOException, InvalidConfigurationException {
|
|
||||||
if (stream == null) {
|
|
||||||
throw new NullPointerException("Stream cannot be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
load(new InputStreamReader(stream, UTF8_OVERRIDE ? StandardCharsets.UTF_8 : Charset.defaultCharset()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads this {@link FileConfiguration} from the specified reader.
|
* Loads this {@link FileConfiguration} from the specified reader.
|
||||||
* <p>
|
* <p>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user