mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-15 11:54: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
|
||||
*.sh
|
||||
*.prefs
|
||||
Sponge/build
|
||||
Core/build
|
||||
Bukkit/build
|
||||
|
||||
### Maven ###
|
||||
/target/lib
|
||||
@ -59,6 +62,7 @@ hs_err_pid*
|
||||
# Gradle:
|
||||
# .idea/gradle.xml
|
||||
# .idea/libraries
|
||||
.gradle
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
# .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);
|
@ -1,30 +1,5 @@
|
||||
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.plot.IPlotMain;
|
||||
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.HybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
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.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.bukkit.commands.DebugUUID;
|
||||
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
|
||||
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
||||
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import com.plotsquared.bukkit.listeners.ChunkListener;
|
||||
import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
|
||||
import com.plotsquared.bukkit.listeners.PlotPlusListener;
|
||||
import com.plotsquared.bukkit.listeners.WorldEvents;
|
||||
import com.plotsquared.bukkit.listeners.*;
|
||||
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
|
||||
import com.plotsquared.bukkit.titles.DefaultTitle;
|
||||
import com.plotsquared.bukkit.util.BukkitChatManager;
|
||||
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.*;
|
||||
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_3;
|
||||
import com.plotsquared.bukkit.util.block.SlowQueue;
|
||||
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
||||
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.plotsquared.bukkit.uuid.*;
|
||||
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 {
|
||||
|
||||
@ -346,19 +294,10 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
||||
WorldEvents.lastWorld = world;
|
||||
final HybridGen result = new HybridGen();
|
||||
if (!PS.get().setupPlotWorld(world, id, result)) {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -430,11 +369,11 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
||||
try {
|
||||
return new FastQueue_1_8_3();
|
||||
} catch (NoSuchMethodException | RuntimeException e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
return new FastQueue_1_8();
|
||||
} catch (NoSuchMethodException e2) {
|
||||
} catch (Throwable e2) {
|
||||
e2.printStackTrace();
|
||||
return new SlowQueue();
|
||||
}
|
||||
@ -442,7 +381,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
try {
|
||||
return new FastQueue_1_7();
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return new SlowQueue();
|
||||
}
|
||||
}
|
@ -20,6 +20,22 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.database.plotme;
|
||||
|
||||
import com.intellectualcrafters.configuration.MemorySection;
|
||||
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
@ -35,22 +51,6 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
|
||||
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
|
||||
/**
|
||||
* Created 2014-08-17 for PlotSquared
|
||||
*
|
||||
@ -109,10 +109,12 @@ public class LikePlotMeConverter {
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
|
||||
for (String key : yml.getKeys(true)) {
|
||||
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) {
|
||||
@ -221,14 +223,14 @@ public class LikePlotMeConverter {
|
||||
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
|
||||
|
||||
Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if ((pathheight == null) || (pathheight == 0)) {
|
||||
if (pathheight == 0) {
|
||||
pathheight = 64;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
||||
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||
if ((plotsize == null) || (plotsize == 0)) {
|
||||
if (plotsize == 0) {
|
||||
plotsize = 32;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.size", plotsize);
|
@ -24,12 +24,10 @@ import java.util.UUID;
|
||||
|
||||
public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
private String plugin;
|
||||
private String prefix;
|
||||
|
||||
@Override
|
||||
public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) {
|
||||
this.plugin = plugin.toLowerCase();
|
||||
prefix = plugin + "core_";
|
||||
try {
|
||||
if (plotConfig.getBoolean("usemySQL")) {
|
||||
final String user = plotConfig.getString("mySQLuname");
|
@ -20,33 +20,27 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
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.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
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;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
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!");
|
||||
}
|
||||
this.full = false;
|
||||
WorldEvents.lastWorld = world;
|
||||
PS.get().debug("BukkitPlotGenerator does not fully support: " + cg);
|
||||
platformGenerator = cg;
|
||||
plotGenerator = new IndependentPlotGenerator() {
|
||||
@ -205,7 +198,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
public List<BlockPopulator> getDefaultPopulators(final World world) {
|
||||
try {
|
||||
if (!loaded) {
|
||||
final String name = WorldEvents.getName(world);
|
||||
final String name = world.getName();
|
||||
PS.get().loadWorld(name, this);
|
||||
Set<PlotArea> areas = PS.get().getPlotAreas(name);
|
||||
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) {
|
||||
// Load if improperly loaded
|
||||
if (!loaded) {
|
||||
final String name = WorldEvents.getName(world);
|
||||
final String name = world.getName();
|
||||
PS.get().loadWorld(name, this);
|
||||
loaded = true;
|
||||
}
|
||||
@ -295,6 +288,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
// Set the result data
|
||||
result.result = new short[16][];
|
||||
result.result_data = new byte[16][];
|
||||
result.grid = grid;
|
||||
// Catch any exceptions (as exceptions usually thrown
|
||||
try {
|
||||
// Fill the result data
|
@ -157,7 +157,6 @@ public class ChunkListener implements Listener {
|
||||
final int z = Z << 4;
|
||||
final int x2 = x + 15;
|
||||
final int z2 = z + 15;
|
||||
Thread thread = new Thread();
|
||||
Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs();
|
||||
if (plot != null && plot.hasOwner()) {
|
||||
return false;
|
@ -1,16 +1,17 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -19,64 +20,17 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
@ -89,34 +43,9 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.RegExUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Player Events involving plots
|
||||
@ -142,10 +71,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
PlotPlayer player = entry.getValue();
|
||||
final Location loc = player.getLocation();
|
||||
if (loc.getWorld().equals(world)) {
|
||||
if (16 * Math.abs(loc.getX() - x) / 16 > distance) {
|
||||
continue;
|
||||
}
|
||||
if (16 * Math.abs(loc.getZ() - z) / 16 > distance) {
|
||||
if (16 * Math.abs(loc.getX() - x) / 16 > distance || 16 * Math.abs(loc.getZ() - z) / 16 > distance) {
|
||||
continue;
|
||||
}
|
||||
((BukkitPlayer) player).player.sendBlockChange(bloc, type, data);
|
||||
@ -234,9 +160,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPhysicsEvent(final BlockPhysicsEvent event) {
|
||||
switch (event.getChangedTypeId()) {
|
||||
case 149:
|
||||
case 150: {
|
||||
switch (event.getChangedType()) {
|
||||
case REDSTONE_COMPARATOR_OFF:
|
||||
case REDSTONE_COMPARATOR_ON: {
|
||||
final Block block = event.getBlock();
|
||||
final Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
@ -252,10 +178,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 122:
|
||||
case 145:
|
||||
case 12:
|
||||
case 13:
|
||||
case DRAGON_EGG:
|
||||
case ANVIL:
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
final Block block = event.getBlock();
|
||||
final Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
@ -295,10 +221,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (plot.isAdded(pp.getUUID())) {
|
||||
return;
|
||||
}
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
|
||||
return;
|
||||
}
|
||||
entity.remove();
|
||||
@ -420,14 +343,11 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
|
||||
Location loc = pp.getLocation();
|
||||
PlotArea area = loc.getPlotArea();
|
||||
final Plot plot;
|
||||
if (area != null) {
|
||||
plot = area.getPlot(loc);
|
||||
Plot plot = area.getPlot(loc);
|
||||
if (plot != null) {
|
||||
plotEntry(pp, plot);
|
||||
}
|
||||
} else {
|
||||
plot = null;
|
||||
}
|
||||
// Delayed
|
||||
|
||||
@ -438,24 +358,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (!player.hasPlayedBefore() && player.isOnline()) {
|
||||
player.saveData();
|
||||
}
|
||||
ExpireManager.dates.put(uuid, System.currentTimeMillis());
|
||||
if (BukkitMain.worldEdit != null) {
|
||||
if (pp.getAttribute("worldedit")) {
|
||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASSED);
|
||||
}
|
||||
}
|
||||
if (PS.get().update != null && Permissions.hasPermission(pp, C.PERMISSION_ADMIN_UPDATE) && Settings.UPDATE_NOTIFICATIONS) {
|
||||
MainUtil.sendMessage(pp, "&6An update for PlotSquared is available: &7/plot update");
|
||||
}
|
||||
if (Settings.TELEPORT_ON_LOGIN && plot != null) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.teleportPlayer(pp);
|
||||
}
|
||||
});
|
||||
MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD);
|
||||
}
|
||||
EventUtil.manager.doJoinTask(pp);
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
@ -468,10 +371,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
|
||||
// Set last location
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta("location", loc);
|
||||
@ -480,7 +381,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
pp.deleteMeta("lastplot");
|
||||
return;
|
||||
}
|
||||
Plot now = area.getPlotAbs(loc);
|
||||
Plot now = area.getPlot(loc);
|
||||
final Plot lastPlot = pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot)) {
|
||||
@ -493,20 +394,14 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
||||
} else if (now.equals(lastPlot)) {
|
||||
return;
|
||||
} else {
|
||||
if (!plotEntry(pp, now)) {
|
||||
} else if (!plotEntry(pp, now)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(lastPlot)) {
|
||||
player.teleport(from);
|
||||
} else {
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Integer border = area.getBorder();
|
||||
if (x2 > border) {
|
||||
to.setX(border - 4);
|
||||
@ -525,20 +420,17 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
|
||||
// Set last location
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta("location", loc);
|
||||
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
pp.deleteMeta("lastplot");
|
||||
return;
|
||||
}
|
||||
Plot now = area.getPlotAbs(loc);
|
||||
Plot now = area.getPlot(loc);
|
||||
final Plot lastPlot = pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot)) {
|
||||
@ -551,20 +443,14 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
||||
} else if (now.equals(lastPlot)) {
|
||||
return;
|
||||
} else {
|
||||
if (!plotEntry(pp, now)) {
|
||||
} else if (!plotEntry(pp, now)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(lastPlot)) {
|
||||
player.teleport(from);
|
||||
} else {
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Integer border = area.getBorder();
|
||||
if (z2 > border) {
|
||||
to.setZ(border - 4);
|
||||
@ -847,14 +733,16 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onChange(final BlockFromToEvent e) {
|
||||
final Block b = e.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Block from = e.getBlock();
|
||||
Block to = e.getToBlock();
|
||||
Location tloc = BukkitUtil.getLocation(to.getLocation());
|
||||
PlotArea area = tloc.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(loc);
|
||||
if (plot == null || FlagManager.isPlotFlagTrue(plot, "disable-physics")) {
|
||||
Plot plot = area.getOwnedPlot(tloc);
|
||||
Location floc = BukkitUtil.getLocation(from.getLocation());
|
||||
if (!area.contains(floc.getX(), floc.getZ()) || !Objects.equals(plot, area.getOwnedPlot(floc)) || (plot != null && FlagManager.isPlotFlagTrue(plot, "disable-physics"))) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -885,6 +773,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
final Plot plot = area.getOwnedPlot(loc);
|
||||
if (plot == null) {
|
||||
@ -1000,6 +889,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
blocks.remove(i);
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
Plot origin = area.getOwnedPlot(loc);
|
||||
if (origin == null) {
|
||||
@ -1122,11 +1012,11 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (eventType != null && !player.isSneaking()) {
|
||||
break;
|
||||
}
|
||||
Material type = hand == null ? null : hand.getType();
|
||||
int id = type == null ? 0 : type.getId();
|
||||
Material type = (hand == null) ? null : hand.getType();
|
||||
int id = (type == null) ? 0 : type.getId();
|
||||
if (id == 0) {
|
||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||
lb = new BukkitLazyBlock(id, block);
|
||||
lb = new BukkitLazyBlock(0, block);
|
||||
break;
|
||||
} else if (id < 198) {
|
||||
loc = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation());
|
@ -1,19 +1,18 @@
|
||||
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.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
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 {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -36,18 +35,16 @@ public class PlayerEvents_1_8_3 implements Listener {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(loc);
|
||||
if (plot == null) {
|
||||
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
final Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Block b = iter.next();
|
||||
if (!plot.equals(BukkitUtil.getLocation(b.getLocation()).getPlotAbs())) {
|
||||
if (!plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(b.getLocation())))) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -31,12 +31,14 @@ import com.plotsquared.listener.PlotListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
@ -106,6 +108,22 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
}, 0l, 20l);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onMelt(final BlockFadeEvent event) {
|
||||
final BlockState state = event.getNewState();
|
||||
|
||||
if (state.getType() != Material.WATER && state.getType() != Material.STATIONARY_WATER) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = BukkitUtil.getLocation(state.getLocation()).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (!FlagManager.isBooleanFlag(plot, "ice-melt", false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onInteract(final BlockDamageEvent event) {
|
||||
final Player player = event.getPlayer();
|
@ -13,28 +13,15 @@ import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
|
||||
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)
|
||||
public static void onWorldInit(final WorldInitEvent event) {
|
||||
final World world = event.getWorld();
|
||||
final String name = getName(world);
|
||||
final String name = world.getName();
|
||||
final ChunkGenerator gen = world.getGenerator();
|
||||
if (gen instanceof GeneratorWrapper) {
|
||||
PS.get().loadWorld(name, (GeneratorWrapper<?>) gen);
|
||||
} else {
|
||||
if (PS.get().config.contains("worlds." + name)) {
|
||||
PS.get().loadWorld(name, new BukkitPlotGenerator(name, gen));
|
||||
}
|
||||
}
|
||||
lastWorld = null;
|
||||
}
|
||||
}
|
@ -1,16 +1,5 @@
|
||||
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.object.Location;
|
||||
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.UUIDHandler;
|
||||
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 {
|
||||
|
||||
@ -133,24 +132,6 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
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
|
||||
public void loadData() {
|
||||
if (!player.isOnline()) {
|
||||
@ -235,6 +216,12 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
player.kickPlayer(message);
|
||||
}
|
||||
|
||||
@Override public void stopSpectating() {
|
||||
if (getGamemode() == PlotGamemode.SPECTATOR) {
|
||||
player.setSpectatorTarget(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
return player.isBanned();
|
@ -4,13 +4,17 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class DefaultTitle extends AbstractTitle {
|
||||
|
||||
@Override
|
||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
|
||||
try {
|
||||
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
||||
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.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
@ -101,7 +101,8 @@ public class DefaultTitleManager {
|
||||
* Fade out time
|
||||
* @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.subtitle = subtitle;
|
||||
this.fadeInTime = fadeInTime;
|
||||
@ -255,7 +256,8 @@ public class DefaultTitleManager {
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object[] actions = packetActions.getEnumConstants();
|
||||
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)
|
||||
.newInstance(actions[2], null, fadeInTime * (ticks ? 1 : 20),
|
||||
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
|
||||
// Send if set
|
||||
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) {
|
||||
@ -278,7 +280,8 @@ public class DefaultTitleManager {
|
||||
|
||||
/**
|
||||
* Broadcast the title to all players
|
||||
* @throws Exception
|
||||
* @throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
||||
SecurityException
|
||||
*/
|
||||
public void broadcast()
|
||||
throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
@ -1,15 +1,15 @@
|
||||
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.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
|
||||
*
|
||||
@ -36,7 +36,7 @@ public class DefaultTitleManager_183 {
|
||||
private int stayTime = -1;
|
||||
private int fadeOutTime = -1;
|
||||
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
|
||||
@ -252,7 +252,7 @@ public class DefaultTitleManager_183 {
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
||||
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
if (subtitle != "") {
|
||||
if (!subtitle.isEmpty()) {
|
||||
// Send subtitle if present
|
||||
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
||||
@ -365,9 +365,7 @@ public class DefaultTitleManager_183 {
|
||||
|
||||
private Class<?> getNMSClass(final String className) throws ClassNotFoundException {
|
||||
final String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz = null;
|
||||
clazz = Class.forName(fullName);
|
||||
return clazz;
|
||||
return Class.forName(fullName);
|
||||
}
|
||||
|
||||
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) {
|
||||
boolean equal = true;
|
||||
if (l1.length != l2.length) {
|
||||
return false;
|
||||
}
|
||||
boolean equal = true;
|
||||
for (int i = 0; i < l1.length; i++) {
|
||||
if (l1[i] != l2[i]) {
|
||||
equal = false;
|
@ -12,7 +12,7 @@ public class HackTitle extends AbstractTitle {
|
||||
try {
|
||||
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (final Throwable e) {
|
||||
} catch (Exception e) {
|
||||
PS.debug("&cYour server version does not support titles!");
|
||||
Settings.TITLES = false;
|
||||
AbstractTitle.TITLE_CLASS = null;
|
@ -1,14 +1,15 @@
|
||||
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.ChatColor;
|
||||
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
|
||||
*
|
||||
@ -33,7 +34,7 @@ public class HackTitleManager {
|
||||
private int stayTime = -1;
|
||||
private int fadeOutTime = -1;
|
||||
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
|
||||
@ -244,7 +245,7 @@ public class HackTitleManager {
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
|
||||
packet = packetTitle.getConstructor(packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
if (subtitle != "") {
|
||||
if (!subtitle.isEmpty()) {
|
||||
// Send subtitle if present
|
||||
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
|
||||
@ -313,8 +314,7 @@ public class HackTitleManager {
|
||||
final Object handle = getHandle(player);
|
||||
final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
final Object networkManager = getValue("networkManager", connection);
|
||||
final Integer version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
|
||||
return version;
|
||||
return (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -336,7 +336,8 @@ public class HackTitleManager {
|
||||
private Class<?> getClass(final String namespace) {
|
||||
try {
|
||||
return Class.forName(namespace);
|
||||
} catch (final Exception e) {}
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -378,7 +379,7 @@ public class HackTitleManager {
|
||||
private Object getHandle(final Object obj) {
|
||||
try {
|
||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||
} catch (final Exception e) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -397,15 +398,12 @@ public class HackTitleManager {
|
||||
|
||||
private String getVersion() {
|
||||
final String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
final String version = name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
return version;
|
||||
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
private Class<?> getNMSClass(final String className) throws ClassNotFoundException {
|
||||
final String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz = null;
|
||||
clazz = Class.forName(fullName);
|
||||
return clazz;
|
||||
return Class.forName(fullName);
|
||||
}
|
||||
|
||||
private Field getField(final Class<?> clazz, final String name) {
|
||||
@ -413,7 +411,7 @@ public class HackTitleManager {
|
||||
final Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (final Exception e) {
|
||||
} catch (SecurityException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -430,10 +428,10 @@ public class HackTitleManager {
|
||||
}
|
||||
|
||||
private boolean ClassListEqual(final Class<?>[] l1, final Class<?>[] l2) {
|
||||
boolean equal = true;
|
||||
if (l1.length != l2.length) {
|
||||
return false;
|
||||
}
|
||||
boolean equal = true;
|
||||
for (int i = 0; i < l1.length; i++) {
|
||||
if (l1[i] != l2[i]) {
|
||||
equal = false;
|
@ -668,11 +668,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
if (!pLoc.getChunkLoc().equals(loc)) {
|
||||
continue;
|
||||
}
|
||||
PlotBlock plotblock = WorldUtil.IMP.getBlock(pLoc);
|
||||
if (plotblock.id != 0) {
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
pp.teleport(plot.getDefaultHome());
|
||||
}
|
||||
pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ()));
|
||||
pp.teleport(pLoc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -996,20 +993,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
final int tx = pos2.getX();
|
||||
final int tz = pos2.getZ();
|
||||
for (final Entity entity : entities) {
|
||||
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 {
|
||||
if (!(entity instanceof Player)) {
|
||||
final org.bukkit.Location loc = entity.getLocation();
|
||||
if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) {
|
||||
entity.remove();
|
||||
@ -1075,9 +1059,11 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
final Set<Chunk> chunks = new HashSet<>();
|
||||
for (int X = bx; X <= tx; X++) {
|
||||
for (int Z = bz; Z <= tz; Z++) {
|
||||
if (world.isChunkLoaded(X, Z)) {
|
||||
chunks.add(world.getChunkAt(X, Z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean doWhole = false;
|
||||
List<Entity> entities = null;
|
@ -5,17 +5,9 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
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.intellectualcrafters.plot.util.*;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -25,12 +17,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Sandstone;
|
||||
import org.bukkit.material.Step;
|
||||
import org.bukkit.material.Tree;
|
||||
import org.bukkit.material.WoodenStep;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.bukkit.material.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -171,9 +158,6 @@ public class BukkitUtil extends WorldUtil {
|
||||
public int getBiomeFromString(final String biomeStr) {
|
||||
try {
|
||||
final Biome biome = Biome.valueOf(biomeStr.toUpperCase());
|
||||
if (biome == null) {
|
||||
return -1;
|
||||
}
|
||||
return Arrays.asList(Biome.values()).indexOf(biome);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
return -1;
|
@ -6,36 +6,21 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.io.ByteSink;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.google.common.primitives.Primitives;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
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.io.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.AbstractList;
|
||||
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.*;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
@ -162,13 +147,13 @@ public class NbtFactory {
|
||||
* @return The decoded NBT compound.
|
||||
* @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;
|
||||
DataInputStream data = null;
|
||||
boolean suppress = true;
|
||||
|
||||
try {
|
||||
input = stream.openStream();
|
||||
input = stream.getInput();
|
||||
data = new DataInputStream(new BufferedInputStream(option == StreamOptions.GZIP_COMPRESSION ? new GZIPInputStream(input) : input));
|
||||
|
||||
final NbtCompound result = fromCompound(get().LOAD_COMPOUND.loadNbt(data));
|
@ -1,7 +1,5 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -19,13 +17,11 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
/**
|
||||
* An utility that can be used to send chunks, rather than using bukkit code to do so (uses heavy NMS)
|
||||
*
|
||||
@ -107,10 +103,6 @@ public class SendChunk {
|
||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
||||
chunks.remove(chunk);
|
||||
final Object con = connection.of(entity).get();
|
||||
// if (dx != 0 || dz != 0) {
|
||||
// Object packet = MapChunk.create(c, true, 0);
|
||||
// send.of(con).call(packet);
|
||||
// }
|
||||
final Object packet = MapChunk.create(c, true, 65535);
|
||||
send.of(con).call(packet);
|
||||
}
|
||||
@ -131,63 +123,16 @@ public class SendChunk {
|
||||
}
|
||||
});
|
||||
}
|
||||
//
|
||||
//
|
||||
// int diffx, diffz;
|
||||
// << 4;
|
||||
// for (final Chunk chunk : chunks) {
|
||||
// if (!chunk.isLoaded()) {
|
||||
// continue;
|
||||
// }
|
||||
// boolean unload = true;
|
||||
// final Object c = methodGetHandle.of(chunk).call();
|
||||
// final Object w = world.of(c).get();
|
||||
// final Object p = players.of(w).get();
|
||||
// for (final Object ep : (List<Object>) p) {
|
||||
// final int x = ((Double) locX.of(ep).get()).intValue();
|
||||
// final int z = ((Double) locZ.of(ep).get()).intValue();
|
||||
// diffx = Math.abs(x - (chunk.getX() << 4));
|
||||
// diffz = Math.abs(z - (chunk.getZ() << 4));
|
||||
// if ((diffx <= view) && (diffz <= view)) {
|
||||
// unload = false;
|
||||
// if (v1_7_10) {
|
||||
// chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
// chunk.load(true);
|
||||
// }
|
||||
// else {
|
||||
// final Object pair = ChunkCoordIntPairCon.create(chunk.getX(), chunk.getZ());
|
||||
// final Object pq = chunkCoordIntPairQueue.of(ep).get();
|
||||
// ((List) pq).add(pair);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (unload) {
|
||||
// TaskManager.runTask(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// try {
|
||||
// chunk.unload(true, true);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// String worldname = chunk.getWorld().getName();
|
||||
// PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||
// PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||
// PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname + "level_old.dat may be corrupt (try repairing
|
||||
// or removing these)");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
public void sendChunk(final String worldname, final List<ChunkLoc> locs) {
|
||||
final World myworld = Bukkit.getWorld(worldname);
|
||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
for (final ChunkLoc loc : locs) {
|
||||
if (myworld.isChunkLoaded(loc.x, loc.z)) {
|
||||
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 classChunkSection = getRefClass("{nms}.ChunkSection");
|
||||
public HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private RefMethod methodGetHandlePlayer;
|
||||
private RefMethod methodGetHandleChunk;
|
||||
private RefConstructor MapChunk;
|
||||
private RefField connection;
|
||||
private RefMethod send;
|
||||
private RefMethod methodInitLighting;
|
||||
private RefConstructor classBlockPositionConstructor;
|
||||
private RefConstructor classChunkSectionConstructor;
|
||||
@ -64,12 +61,9 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
private RefMethod methodGetIdArray;
|
||||
|
||||
public FastQueue_1_8_3() throws NoSuchMethodException, RuntimeException {
|
||||
methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
methodInitLighting = classChunk.getMethod("initLighting");
|
||||
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||
connection = classEntityPlayer.getField("playerConnection");
|
||||
send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
|
||||
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||
methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
|
||||
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) {
|
||||
super(wrap);
|
||||
if ((this.chunk = chunk) == null) {
|
||||
if ((this.chunk = chunk) == null && wrap != null) {
|
||||
World world = BukkitUtil.getWorld(wrap.world);
|
||||
if (world != null) {
|
||||
chunk = world.getChunkAt(wrap.x, wrap.z);
|
||||
@ -34,7 +34,7 @@ public class GenChunk extends PlotChunk<Chunk> {
|
||||
@Override
|
||||
public Chunk getChunkAbs() {
|
||||
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);
|
||||
}
|
||||
return chunk;
|
||||
@ -65,9 +65,14 @@ public class GenChunk extends PlotChunk<Chunk> {
|
||||
modified = true;
|
||||
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) {
|
||||
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 int[][] biomes;
|
||||
private PlotBlock lastBlock;
|
||||
public SlowChunk(ChunkWrapper chunk) {
|
||||
super(chunk);
|
||||
}
|
||||
@ -35,11 +34,7 @@ public class SlowChunk extends PlotChunk<Chunk> {
|
||||
if (result[y >> 4] == null) {
|
||||
result[y >> 4] = new PlotBlock[4096];
|
||||
}
|
||||
if (id == lastBlock.id && data == lastBlock.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);
|
||||
}
|
||||
result[MainUtil.CACHE_I[y][x][z]][MainUtil.CACHE_J[y][x][z]] = new PlotBlock((short) id, data);
|
||||
}
|
||||
|
||||
@Override
|
@ -123,6 +123,9 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
final int z = MainUtil.z_loc[i][j];
|
||||
Block block = chunk.getBlock(x, y, z);
|
||||
PlotBlock newBlock = result2[j];
|
||||
if (newBlock == null) {
|
||||
continue;
|
||||
}
|
||||
switch (newBlock.id) {
|
||||
case -1:
|
||||
if (block.getData() == newBlock.data) {
|
@ -2,6 +2,7 @@ package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
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.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
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.*;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.bukkit.util.NbtFactory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -102,12 +100,14 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
final UUID uuid = UUID.fromString(s);
|
||||
if (check || all.remove(uuid)) {
|
||||
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 bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
final String name = (String) bukkit.get("lastKnownName");
|
||||
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);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
@ -173,6 +173,9 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
for (UUID uuid : uuids) {
|
||||
try {
|
||||
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 NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
final NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
@ -187,7 +190,9 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
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);
|
||||
} catch (final Throwable e) {
|
||||
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 UUID uuid = uuidWrapper.getUUID(op);
|
||||
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
|
||||
version: ${project.version}
|
||||
version: ${version}
|
||||
load: STARTUP
|
||||
description: >
|
||||
Easy, yet powerful Plot World generation and management.
|
||||
@ -146,6 +146,7 @@ permissions:
|
||||
plots.save: true
|
||||
plots.done: true
|
||||
plots.continue: true
|
||||
plots.middle: true
|
||||
plots.worldedit.bypass:
|
||||
default: false
|
||||
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.
|
||||
* @throws IllegalArgumentException Thrown if path is null.
|
||||
*/
|
||||
@Override
|
||||
public void addDefault(final String path, final Object value);
|
||||
@Override void addDefault(final String path, final Object value);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @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.
|
||||
@ -50,7 +49,7 @@ public interface Configuration extends ConfigurationSection {
|
||||
* @param defaults A configuration holding a list of defaults to copy.
|
||||
* @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}.
|
||||
@ -61,7 +60,7 @@ public interface Configuration extends ConfigurationSection {
|
||||
* @param defaults New source of default values for this configuration.
|
||||
* @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.
|
||||
@ -72,7 +71,7 @@ public interface Configuration extends ConfigurationSection {
|
||||
*
|
||||
* @return Configuration source for default values, or null if none exist.
|
||||
*/
|
||||
public Configuration getDefaults();
|
||||
Configuration getDefaults();
|
||||
|
||||
/**
|
||||
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
|
||||
@ -81,5 +80,5 @@ public interface Configuration extends ConfigurationSection {
|
||||
*
|
||||
* @return Options for this configuration
|
||||
*/
|
||||
public ConfigurationOptions options();
|
||||
ConfigurationOptions options();
|
||||
}
|
@ -22,7 +22,7 @@ public interface ConfigurationSection {
|
||||
* list.
|
||||
* @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.
|
||||
@ -38,7 +38,7 @@ public interface ConfigurationSection {
|
||||
* list.
|
||||
* @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.
|
||||
@ -51,7 +51,7 @@ public interface ConfigurationSection {
|
||||
* default or being set.
|
||||
* @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
|
||||
@ -65,7 +65,7 @@ public interface ConfigurationSection {
|
||||
* having a default.
|
||||
* @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
|
||||
@ -82,7 +82,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Path of this section relative to its root
|
||||
*/
|
||||
public String getCurrentPath();
|
||||
String getCurrentPath();
|
||||
|
||||
/**
|
||||
* Gets the name of this individual {@link ConfigurationSection}, in the
|
||||
@ -93,7 +93,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Name of this section
|
||||
*/
|
||||
public String getName();
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the root {@link Configuration} that contains this {@link
|
||||
@ -107,7 +107,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Root configuration containing this section.
|
||||
*/
|
||||
public Configuration getRoot();
|
||||
Configuration getRoot();
|
||||
|
||||
/**
|
||||
* Gets the parent {@link ConfigurationSection} that directly contains
|
||||
@ -120,7 +120,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Parent section containing this section.
|
||||
*/
|
||||
public ConfigurationSection getParent();
|
||||
ConfigurationSection getParent();
|
||||
|
||||
/**
|
||||
* Gets the requested Object by path.
|
||||
@ -132,7 +132,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the Object to get.
|
||||
* @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
|
||||
@ -146,7 +146,7 @@ public interface ConfigurationSection {
|
||||
* @param def The default value to return if the path is not found.
|
||||
* @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.
|
||||
@ -162,7 +162,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the object to set.
|
||||
* @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.
|
||||
@ -174,7 +174,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path to create the section at.
|
||||
* @return Newly created section
|
||||
*/
|
||||
public ConfigurationSection createSection(final String path);
|
||||
ConfigurationSection createSection(final String path);
|
||||
|
||||
/**
|
||||
* Creates a {@link ConfigurationSection} at the specified path, with
|
||||
@ -188,7 +188,7 @@ public interface ConfigurationSection {
|
||||
* @param map The values to used.
|
||||
* @return Newly created section
|
||||
*/
|
||||
public ConfigurationSection createSection(final String path, final Map<?, ?> map);
|
||||
ConfigurationSection createSection(final String path, final Map<?, ?> map);
|
||||
|
||||
// Primitives
|
||||
/**
|
||||
@ -201,7 +201,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the String to get.
|
||||
* @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
|
||||
@ -216,7 +216,7 @@ public interface ConfigurationSection {
|
||||
* not a 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.
|
||||
@ -229,7 +229,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the String to check.
|
||||
* @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.
|
||||
@ -241,7 +241,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the int to get.
|
||||
* @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.
|
||||
@ -255,7 +255,7 @@ public interface ConfigurationSection {
|
||||
* not an 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.
|
||||
@ -268,7 +268,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the int to check.
|
||||
* @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.
|
||||
@ -280,7 +280,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the boolean to get.
|
||||
* @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
|
||||
@ -295,7 +295,7 @@ public interface ConfigurationSection {
|
||||
* not a 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.
|
||||
@ -308,7 +308,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the boolean to check.
|
||||
* @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.
|
||||
@ -320,7 +320,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the double to get.
|
||||
* @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
|
||||
@ -335,7 +335,7 @@ public interface ConfigurationSection {
|
||||
* not a 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.
|
||||
@ -348,7 +348,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the double to check.
|
||||
* @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.
|
||||
@ -360,7 +360,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the long to get.
|
||||
* @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
|
||||
@ -375,7 +375,7 @@ public interface ConfigurationSection {
|
||||
* not a 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.
|
||||
@ -388,7 +388,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the long to check.
|
||||
* @return Whether or not the specified path is a long.
|
||||
*/
|
||||
public boolean isLong(final String path);
|
||||
boolean isLong(final String path);
|
||||
|
||||
// Java
|
||||
/**
|
||||
@ -401,7 +401,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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
|
||||
@ -416,7 +416,7 @@ public interface ConfigurationSection {
|
||||
* not a 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.
|
||||
@ -429,7 +429,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to check.
|
||||
* @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.
|
||||
@ -444,7 +444,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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.
|
||||
@ -459,7 +459,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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.
|
||||
@ -474,7 +474,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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.
|
||||
@ -489,7 +489,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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.
|
||||
@ -504,7 +504,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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.
|
||||
@ -519,7 +519,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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.
|
||||
@ -534,7 +534,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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.
|
||||
@ -549,7 +549,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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.
|
||||
@ -564,7 +564,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @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.
|
||||
@ -579,7 +579,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Maps.
|
||||
*/
|
||||
public List<Map<?, ?>> getMapList(final String path);
|
||||
List<Map<?, ?>> getMapList(final String path);
|
||||
|
||||
/**
|
||||
* Gets the requested ConfigurationSection by path.
|
||||
@ -592,7 +592,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the ConfigurationSection to get.
|
||||
* @return Requested ConfigurationSection.
|
||||
*/
|
||||
public ConfigurationSection getConfigurationSection(final String path);
|
||||
ConfigurationSection getConfigurationSection(final String path);
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a ConfigurationSection.
|
||||
@ -606,7 +606,7 @@ public interface ConfigurationSection {
|
||||
* @param path Path of the ConfigurationSection to check.
|
||||
* @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
|
||||
@ -618,7 +618,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* @return Equivalent section in root configuration
|
||||
*/
|
||||
public ConfigurationSection getDefaultSection();
|
||||
ConfigurationSection getDefaultSection();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @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,64 +1,26 @@
|
||||
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.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
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
|
||||
* Configuration}
|
||||
*/
|
||||
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.
|
||||
@ -100,8 +62,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
|
||||
final String data = saveToString();
|
||||
|
||||
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file),
|
||||
UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset())) {
|
||||
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
|
||||
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
|
||||
* thrown.
|
||||
* <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.
|
||||
* @throws FileNotFoundException Thrown when the given file cannot be
|
||||
@ -165,34 +123,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
|
||||
final FileInputStream stream = new FileInputStream(file);
|
||||
|
||||
load(new InputStreamReader(stream, UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()));
|
||||
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
/**
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user