Compare commits

...

51 Commits

Author SHA1 Message Date
f00ac79c91 Bump version / misc
Fix regenallroads
Add schematic y_offset
Change visit/list for multi-owner plots
Fix updater (pre-1.7.10)
2016-03-02 17:42:04 +11:00
109715e0d7 Merge branch 'master' of https://github.com/IntellectualSites/PlotSquared 2016-03-02 06:59:05 +11:00
8bf3ceac6f Changes
Plot auto clear confirmation
Add timediff to keep flag
Add expired parameter to list cmd
Fixes some compatibility issues
2016-03-02 06:56:50 +11:00
106c3c5cb4 Temporary fix for 1.9 2016-03-01 14:17:29 +11:00
0bbfd0f49a Begin 1.9 NMS updates 2016-02-29 20:44:58 -05:00
9596544f97 Cleanup Code
I also updated the build.gradle and pom to 1.9 bukkit
2016-02-29 20:13:18 -05:00
5079361fbf Fix negation issue. 2016-02-29 11:50:04 -05:00
b0a3f70cbd Updater now uses GitHub Releases and API 2016-02-29 11:15:51 -05:00
841809b93d Various
Closes #906
Add command confirmation for setowner
Require confirmation delayed by 1 tick
2016-03-01 02:01:52 +11:00
43b7a7aba8 Fixes #910 2016-02-29 15:12:20 +11:00
8906577699 Merge pull request #909 from zombachu/master
Implements the ice-melt flag
2016-02-29 14:08:31 +11:00
224caee56e Implements the ice-melt flag 2016-02-28 15:41:32 -10:00
5c4178b1dd Fixes
Fixes #905
Fixes auto claim limit
2016-02-29 04:09:09 +11:00
911bef974a Stop spectating before being kicked when denied.
Fixes #886
2016-02-27 20:11:18 -05:00
7d340b58b4 Merge branch 'master' of https://github.com/IntellectualSites/PlotSquared 2016-02-27 15:49:45 -05:00
ce8775414a Fix some logic 2016-02-28 07:04:57 +11:00
5da8700f7f Force Core to use Java 7 2016-02-27 13:41:49 -05:00
01710e3ddb Fixes
Notify core of all world loading regardless of generator
Optimize plot area fetching
Fix plot delete not deleting the plot until restart
Fix plot unclaim not removing the owner on any cached plots
Change gradle output directory
Fix plotme conversion sometimes not copying over the floor/main blocks
2016-02-27 21:07:42 +11:00
7d8893b5d7 Fixes #900 2016-02-27 17:07:15 +11:00
7a97c69d4f Fix bed explosion in hell biome when flag not present 2016-02-27 16:44:29 +11:00
1a80b344b9 replace jar with one that's less broken 2016-02-27 16:09:55 +11:00
afe6c5fd69 Merge branch 'master' of https://github.com/IntellectualSites/PlotSquared 2016-02-27 16:05:56 +11:00
f68042bc11 Fixes
Fixes unlink failing if a parameter is provided
Fix plot unlinking not resetting the road biome
Fixes #888
2016-02-27 16:05:21 +11:00
ac77c755d0 Add plot middle permission to plugin.yml 2016-02-26 19:10:59 -05:00
c7870b617c Gradle / maven
Fix archive names (includes project/module name + version)
Generate MD5 hash alongside jar
Improve build time
- asynchronous building
- enable daemon
- change scope of a few statements
- skip building of 3 jars
Add filtering to the plugin.yml (maven/gradle)
Bump version to 3.3.0 in pom
2016-02-26 23:55:21 +11:00
f921db937a Fix plot music duplication when moving between plots in a merged plot 2016-02-26 17:43:49 +11:00
4669f31658 Fixes
Fixes hybridplotworld rotation for stairs
Fixes hybridplotworld skipping non-rotatable blocks on swapped sideroad
schem
Fixes schematic generation using wrong height
Fixes debug spam printed when using download cmd
Fixes pagination having page number instead of total list items
Fixes plot area list page being off by 1
Remove compatibility for a spigot 1.8.0 bug where getting the world name
during initialization crashes the server.
Fixes type 1,2 plot worlds not being fetchable if there are more than 8
plot worlds loaded.
2016-02-26 17:29:31 +11:00
c8ddcd7f54 Fixes
Fix plot cluster command NPE
Fix path iterator (for Plot.getAllCorners()) being off by 1
2016-02-26 04:17:23 +11:00
fb2e949711 Fix rotation for stairs metadata (range:8-15) 2016-02-26 01:21:30 +11:00
7659884e73 Fixes
Fixes #868
Fixes #778
Fixes attributes passing wrong key to persistent meta
Fixes blob compatibility with JDBC driver for persistent meta
Fix stackoverflow from countEntities under certain circumstances
Minor cleanup
2016-02-26 01:17:07 +11:00
efae2c2e63 Finished several core parts of the sponge port
Mass block changes / chunk packet sending
AsyncWorldEdit (buggy)
Fixed world ground cover layers being generated
Fixed tab completion
Fixed plot title color
Fixed worlds unloading when no players are present
Fixed falling blocks not falling where they should
Fixed console color
Fixed chunk regeneration on full plot worlds
Other stuff
2016-02-25 20:13:07 +11:00
d3465b7bde Merge branch 'master' of https://github.com/IntellectualSites/PlotSquared 2016-02-24 05:12:20 +11:00
f73a542b04 Tab completion, fix SpongeUtil.getWorld 2016-02-24 05:12:07 +11:00
6f3485c87d Hard-code version into plugin.yml 2016-02-23 13:08:20 -05:00
bf85ba5833 No they aren't 2016-02-24 04:20:40 +11:00
8a2c44759f Chunk regeneration 2016-02-24 04:04:23 +11:00
882394987b Merge branch 'master' of https://github.com/IntellectualSites/PlotSquared 2016-02-24 03:08:12 +11:00
7a217b2f08 a wild pom appears
fork/pr if you don't like how I've done it
2016-02-24 03:07:49 +11:00
b94e816c55 Sponge changes. 2016-02-23 09:55:40 -05:00
87ee693a49 Fix small Gradle things. 2016-02-22 23:30:49 -05:00
1768651782 Merge pull request #874 from IntellectualSites/gradle
Move from Maven to Gradle
2016-02-22 23:16:03 -05:00
b69e31129d Updated Gradle 2016-02-22 23:11:40 -05:00
7b15d50674 Add PS.get().isPlotWorld() and MainUtil.getPlotID( Location );
@_Cory_
2016-02-23 05:46:57 +11:00
f996b1d95d Using ReflectionUtils simplifies stuff? 2016-02-23 05:38:28 +11:00
14eb3279c0 Revert version 2016-02-23 05:31:35 +11:00
ced342f14e Merge branch 'master' of https://github.com/IntellectualSites/PlotSquared 2016-02-22 17:24:30 +11:00
f5ff82c8cc Sponge / Other
Fix area teleportation for type 0,1 worlds
Add blockstate<>id/data resolving for sponge
Finish world generation for sponge
Add chat color for sponge
Fix economy support for sponge
Fix sponge event system
Other stuff
2016-02-22 17:20:22 +11:00
b255c5db47 Cleanup and Fixes
Fixed StackOverflowError caused by c83378a
2016-02-21 23:29:33 -05:00
ca5e7f4564 Cleanup 2016-02-20 23:07:04 -05:00
ef5846f688 Cleanup 2016-02-20 16:50:10 -05:00
36ebd1983d Use UTF-8 2016-02-19 15:51:04 -05:00
427 changed files with 18818 additions and 19033 deletions

4
.gitignore vendored
View File

@ -3,6 +3,9 @@
*.cmd *.cmd
*.sh *.sh
*.prefs *.prefs
Sponge/build
Core/build
Bukkit/build
### Maven ### ### Maven ###
/target/lib /target/lib
@ -59,6 +62,7 @@ hs_err_pid*
# Gradle: # Gradle:
# .idea/gradle.xml # .idea/gradle.xml
# .idea/libraries # .idea/libraries
.gradle
# Mongo Explorer plugin: # Mongo Explorer plugin:
# .idea/mongoSettings.xml # .idea/mongoSettings.xml

35
Bukkit/build.gradle Normal file
View 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);

View File

@ -1,30 +1,5 @@
package com.plotsquared.bukkit; package com.plotsquared.bukkit;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import com.intellectualcrafters.configuration.ConfigurationSection; import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.IPlotMain; import com.intellectualcrafters.plot.IPlotMain;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
@ -37,67 +12,40 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.ChatManager;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.ConsoleColors;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.InventoryUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotQueue;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.commands.DebugUUID; import com.plotsquared.bukkit.commands.DebugUUID;
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector; import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter; import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017; import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator; import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.plotsquared.bukkit.listeners.ChunkListener; import com.plotsquared.bukkit.listeners.*;
import com.plotsquared.bukkit.listeners.ForceFieldListener;
import com.plotsquared.bukkit.listeners.PlayerEvents;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
import com.plotsquared.bukkit.listeners.PlotPlusListener;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.listeners.worldedit.WEListener; import com.plotsquared.bukkit.listeners.worldedit.WEListener;
import com.plotsquared.bukkit.titles.DefaultTitle; import com.plotsquared.bukkit.titles.DefaultTitle;
import com.plotsquared.bukkit.util.BukkitChatManager; import com.plotsquared.bukkit.util.*;
import com.plotsquared.bukkit.util.BukkitChunkManager;
import com.plotsquared.bukkit.util.BukkitCommand;
import com.plotsquared.bukkit.util.BukkitEconHandler;
import com.plotsquared.bukkit.util.BukkitEventUtil;
import com.plotsquared.bukkit.util.BukkitHybridUtils;
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
import com.plotsquared.bukkit.util.BukkitPlainChatManager;
import com.plotsquared.bukkit.util.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.BukkitSetupUtils;
import com.plotsquared.bukkit.util.BukkitTaskManager;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.Metrics;
import com.plotsquared.bukkit.util.SendChunk;
import com.plotsquared.bukkit.util.SetGenCB;
import com.plotsquared.bukkit.util.block.FastQueue_1_7; import com.plotsquared.bukkit.util.block.FastQueue_1_7;
import com.plotsquared.bukkit.util.block.FastQueue_1_8; import com.plotsquared.bukkit.util.block.FastQueue_1_8;
import com.plotsquared.bukkit.util.block.FastQueue_1_8_3; import com.plotsquared.bukkit.util.block.FastQueue_1_8_3;
import com.plotsquared.bukkit.util.block.SlowQueue; import com.plotsquared.bukkit.util.block.SlowQueue;
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper; import com.plotsquared.bukkit.uuid.*;
import com.plotsquared.bukkit.uuid.FileUUIDHandler;
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import org.bukkit.*;
import org.bukkit.Location;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@ -346,19 +294,10 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override @Override
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
WorldEvents.lastWorld = world;
final HybridGen result = new HybridGen(); final HybridGen result = new HybridGen();
if (!PS.get().setupPlotWorld(world, id, result)) { if (!PS.get().setupPlotWorld(world, id, result)) {
return null; return null;
} }
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
if ((WorldEvents.lastWorld != null) && WorldEvents.lastWorld.equals(world)) {
WorldEvents.lastWorld = null;
}
}
}, 20);
return (ChunkGenerator) result.specify(); return (ChunkGenerator) result.specify();
} }
@ -430,11 +369,11 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) { if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
try { try {
return new FastQueue_1_8_3(); return new FastQueue_1_8_3();
} catch (NoSuchMethodException | RuntimeException e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
try { try {
return new FastQueue_1_8(); return new FastQueue_1_8();
} catch (NoSuchMethodException e2) { } catch (Throwable e2) {
e2.printStackTrace(); e2.printStackTrace();
return new SlowQueue(); return new SlowQueue();
} }
@ -442,7 +381,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
} }
try { try {
return new FastQueue_1_7(); return new FastQueue_1_7();
} catch (NoSuchMethodException e) { } catch (Throwable e) {
e.printStackTrace();
return new SlowQueue(); return new SlowQueue();
} }
} }

View File

@ -20,6 +20,22 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.database.plotme; 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.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -35,22 +51,6 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; 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 * Created 2014-08-17 for PlotSquared
* *
@ -109,10 +109,12 @@ public class LikePlotMeConverter {
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig); YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
for (String key : yml.getKeys(true)) { for (String key : yml.getKeys(true)) {
if (!plotConfig.contains(key)) { if (!plotConfig.contains(key)) {
plotConfig.set(key, yml.get(key)); Object value = yml.get(key);
if (!(value instanceof MemorySection)) {
plotConfig.set(key, value);
}
} }
} }
genConfig.delete();
} }
} }
catch (Exception e) { catch (Exception e) {
@ -221,14 +223,14 @@ public class LikePlotMeConverter {
PS.get().config.set("worlds." + world + ".road.width", pathwidth); PS.get().config.set("worlds." + world + ".road.width", pathwidth);
Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
if ((pathheight == null) || (pathheight == 0)) { if (pathheight == 0) {
pathheight = 64; pathheight = 64;
} }
PS.get().config.set("worlds." + world + ".road.height", pathheight); PS.get().config.set("worlds." + world + ".road.height", pathheight);
PS.get().config.set("worlds." + world + ".wall.height", pathheight); PS.get().config.set("worlds." + world + ".wall.height", pathheight);
PS.get().config.set("worlds." + world + ".plot.height", pathheight); PS.get().config.set("worlds." + world + ".plot.height", pathheight);
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); // Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
if ((plotsize == null) || (plotsize == 0)) { if (plotsize == 0) {
plotsize = 32; plotsize = 32;
} }
PS.get().config.set("worlds." + world + ".plot.size", plotsize); PS.get().config.set("worlds." + world + ".plot.size", plotsize);

View File

@ -24,12 +24,10 @@ import java.util.UUID;
public class PlotMeConnector_017 extends APlotMeConnector { public class PlotMeConnector_017 extends APlotMeConnector {
private String plugin; private String plugin;
private String prefix;
@Override @Override
public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) { public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) {
this.plugin = plugin.toLowerCase(); this.plugin = plugin.toLowerCase();
prefix = plugin + "core_";
try { try {
if (plotConfig.getBoolean("usemySQL")) { if (plotConfig.getBoolean("usemySQL")) {
final String user = plotConfig.getString("mySQLuname"); final String user = plotConfig.getString("mySQLuname");

View File

@ -20,33 +20,27 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.generator; package com.plotsquared.bukkit.generator;
import java.util.ArrayList; import com.intellectualcrafters.plot.PS;
import java.util.List; import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import java.util.Random; import com.intellectualcrafters.plot.generator.HybridGen;
import java.util.Set; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.block.GenChunk;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.PS; import java.util.ArrayList;
import com.intellectualcrafters.plot.generator.GeneratorWrapper; import java.util.List;
import com.intellectualcrafters.plot.generator.HybridGen; import java.util.Random;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; import java.util.Set;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.block.GenChunk;
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> { public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
@ -96,7 +90,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() + " is already a BukkitPlotGenerator!"); throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() + " is already a BukkitPlotGenerator!");
} }
this.full = false; this.full = false;
WorldEvents.lastWorld = world;
PS.get().debug("BukkitPlotGenerator does not fully support: " + cg); PS.get().debug("BukkitPlotGenerator does not fully support: " + cg);
platformGenerator = cg; platformGenerator = cg;
plotGenerator = new IndependentPlotGenerator() { plotGenerator = new IndependentPlotGenerator() {
@ -205,7 +198,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
public List<BlockPopulator> getDefaultPopulators(final World world) { public List<BlockPopulator> getDefaultPopulators(final World world) {
try { try {
if (!loaded) { if (!loaded) {
final String name = WorldEvents.getName(world); final String name = world.getName();
PS.get().loadWorld(name, this); PS.get().loadWorld(name, this);
Set<PlotArea> areas = PS.get().getPlotAreas(name); Set<PlotArea> areas = PS.get().getPlotAreas(name);
if (!areas.isEmpty()) { if (!areas.isEmpty()) {
@ -265,7 +258,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
public void generate(World world, int cx, int cz, GenChunk result) { public void generate(World world, int cx, int cz, GenChunk result) {
// Load if improperly loaded // Load if improperly loaded
if (!loaded) { if (!loaded) {
final String name = WorldEvents.getName(world); final String name = world.getName();
PS.get().loadWorld(name, this); PS.get().loadWorld(name, this);
loaded = true; loaded = true;
} }
@ -295,6 +288,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
// Set the result data // Set the result data
result.result = new short[16][]; result.result = new short[16][];
result.result_data = new byte[16][]; result.result_data = new byte[16][];
result.grid = grid;
// Catch any exceptions (as exceptions usually thrown // Catch any exceptions (as exceptions usually thrown
try { try {
// Fill the result data // Fill the result data

View File

@ -157,7 +157,6 @@ public class ChunkListener implements Listener {
final int z = Z << 4; final int z = Z << 4;
final int x2 = x + 15; final int x2 = x + 15;
final int z2 = z + 15; final int z2 = z + 15;
Thread thread = new Thread();
Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs(); Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) { if (plot != null && plot.hasOwner()) {
return false; return false;

View File

@ -1,16 +1,17 @@
package com.plotsquared.bukkit.listeners; package com.plotsquared.bukkit.listeners;
import java.util.ArrayList; import com.intellectualcrafters.plot.PS;
import java.util.Arrays; import com.intellectualcrafters.plot.config.C;
import java.util.HashSet; import com.intellectualcrafters.plot.config.Settings;
import java.util.Iterator; import com.intellectualcrafters.plot.flag.Flag;
import java.util.List; import com.intellectualcrafters.plot.flag.FlagManager;
import java.util.Map.Entry; import com.intellectualcrafters.plot.object.*;
import java.util.Objects; import com.intellectualcrafters.plot.util.*;
import java.util.Set; import com.plotsquared.bukkit.BukkitMain;
import java.util.UUID; import com.plotsquared.bukkit.object.BukkitLazyBlock;
import java.util.regex.Pattern; import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlayerBlockEventType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -19,64 +20,17 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Animals; import org.bukkit.entity.*;
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.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.*;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.*;
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.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.*;
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.vehicle.VehicleCreateEvent; import org.bukkit.event.vehicle.VehicleCreateEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.StructureGrowEvent;
@ -89,34 +43,9 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.intellectualcrafters.plot.PS; import java.util.*;
import com.intellectualcrafters.plot.config.C; import java.util.Map.Entry;
import com.intellectualcrafters.plot.config.Settings; import java.util.regex.Pattern;
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;
/** /**
* Player Events involving plots * Player Events involving plots
@ -142,10 +71,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
PlotPlayer player = entry.getValue(); PlotPlayer player = entry.getValue();
final Location loc = player.getLocation(); final Location loc = player.getLocation();
if (loc.getWorld().equals(world)) { if (loc.getWorld().equals(world)) {
if (16 * Math.abs(loc.getX() - x) / 16 > distance) { if (16 * Math.abs(loc.getX() - x) / 16 > distance || 16 * Math.abs(loc.getZ() - z) / 16 > distance) {
continue;
}
if (16 * Math.abs(loc.getZ() - z) / 16 > distance) {
continue; continue;
} }
((BukkitPlayer) player).player.sendBlockChange(bloc, type, data); ((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) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPhysicsEvent(final BlockPhysicsEvent event) { public void onPhysicsEvent(final BlockPhysicsEvent event) {
switch (event.getChangedTypeId()) { switch (event.getChangedType()) {
case 149: case REDSTONE_COMPARATOR_OFF:
case 150: { case REDSTONE_COMPARATOR_ON: {
final Block block = event.getBlock(); final Block block = event.getBlock();
final Location loc = BukkitUtil.getLocation(block.getLocation()); final Location loc = BukkitUtil.getLocation(block.getLocation());
PlotArea area = loc.getPlotArea(); PlotArea area = loc.getPlotArea();
@ -252,10 +178,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
return; return;
} }
case 122: case DRAGON_EGG:
case 145: case ANVIL:
case 12: case SAND:
case 13: case GRAVEL:
final Block block = event.getBlock(); final Block block = event.getBlock();
final Location loc = BukkitUtil.getLocation(block.getLocation()); final Location loc = BukkitUtil.getLocation(block.getLocation());
PlotArea area = loc.getPlotArea(); PlotArea area = loc.getPlotArea();
@ -295,10 +221,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
return; return;
} }
if (plot.isAdded(pp.getUUID())) { if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
return;
}
if (Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
return; return;
} }
entity.remove(); entity.remove();
@ -420,14 +343,11 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Location loc = pp.getLocation(); Location loc = pp.getLocation();
PlotArea area = loc.getPlotArea(); PlotArea area = loc.getPlotArea();
final Plot plot;
if (area != null) { if (area != null) {
plot = area.getPlot(loc); Plot plot = area.getPlot(loc);
if (plot != null) { if (plot != null) {
plotEntry(pp, plot); plotEntry(pp, plot);
} }
} else {
plot = null;
} }
// Delayed // Delayed
@ -438,24 +358,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (!player.hasPlayedBefore() && player.isOnline()) { if (!player.hasPlayedBefore() && player.isOnline()) {
player.saveData(); player.saveData();
} }
ExpireManager.dates.put(uuid, System.currentTimeMillis()); EventUtil.manager.doJoinTask(pp);
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);
}
} }
}, 20); }, 20);
} }
@ -468,10 +371,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) { if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final PlotPlayer pp = BukkitUtil.getPlayer(player); final PlotPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); TaskManager.TELEPORT_QUEUE.remove(pp.getName());
// Set last location // Set last location
Location loc = BukkitUtil.getLocation(to); Location loc = BukkitUtil.getLocation(to);
pp.setMeta("location", loc); pp.setMeta("location", loc);
@ -480,7 +381,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
pp.deleteMeta("lastplot"); pp.deleteMeta("lastplot");
return; return;
} }
Plot now = area.getPlotAbs(loc); Plot now = area.getPlot(loc);
final Plot lastPlot = pp.getMeta("lastplot"); final Plot lastPlot = pp.getMeta("lastplot");
if (now == null) { if (now == null) {
if (lastPlot != null && !plotExit(pp, lastPlot)) { if (lastPlot != null && !plotExit(pp, lastPlot)) {
@ -493,20 +394,14 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (lastPlot != null && now.equals(lastPlot)) { } else if (now.equals(lastPlot)) {
return; return;
} else { } else if (!plotEntry(pp, now)) {
if (!plotEntry(pp, now)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(lastPlot)) {
player.teleport(from); player.teleport(from);
} else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
}
final Integer border = area.getBorder(); final Integer border = area.getBorder();
if (x2 > border) { if (x2 > border) {
to.setX(border - 4); 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()))) { if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final PlotPlayer pp = BukkitUtil.getPlayer(player); final PlotPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); TaskManager.TELEPORT_QUEUE.remove(pp.getName());
// Set last location // Set last location
Location loc = BukkitUtil.getLocation(to); Location loc = BukkitUtil.getLocation(to);
pp.setMeta("location", loc); pp.setMeta("location", loc);
PlotArea area = loc.getPlotArea(); PlotArea area = loc.getPlotArea();
if (area == null) { if (area == null) {
pp.deleteMeta("lastplot"); pp.deleteMeta("lastplot");
return; return;
} }
Plot now = area.getPlotAbs(loc); Plot now = area.getPlot(loc);
final Plot lastPlot = pp.getMeta("lastplot"); final Plot lastPlot = pp.getMeta("lastplot");
if (now == null) { if (now == null) {
if (lastPlot != null && !plotExit(pp, lastPlot)) { if (lastPlot != null && !plotExit(pp, lastPlot)) {
@ -551,20 +443,14 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (lastPlot != null && now.equals(lastPlot)) { } else if (now.equals(lastPlot)) {
return; return;
} else { } else if (!plotEntry(pp, now)) {
if (!plotEntry(pp, now)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(lastPlot)) {
player.teleport(from); player.teleport(from);
} else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
}
final Integer border = area.getBorder(); final Integer border = area.getBorder();
if (z2 > border) { if (z2 > border) {
to.setZ(border - 4); to.setZ(border - 4);
@ -847,14 +733,16 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChange(final BlockFromToEvent e) { public void onChange(final BlockFromToEvent e) {
final Block b = e.getBlock(); Block from = e.getBlock();
Location loc = BukkitUtil.getLocation(b.getLocation()); Block to = e.getToBlock();
PlotArea area = loc.getPlotArea(); Location tloc = BukkitUtil.getLocation(to.getLocation());
PlotArea area = tloc.getPlotArea();
if (area == null) { if (area == null) {
return; return;
} }
Plot plot = area.getOwnedPlot(loc); Plot plot = area.getOwnedPlot(tloc);
if (plot == null || FlagManager.isPlotFlagTrue(plot, "disable-physics")) { 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); e.setCancelled(true);
} }
} }
@ -885,6 +773,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return; return;
} }
} }
return;
} }
final Plot plot = area.getOwnedPlot(loc); final Plot plot = area.getOwnedPlot(loc);
if (plot == null) { if (plot == null) {
@ -1000,6 +889,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
blocks.remove(i); blocks.remove(i);
} }
} }
return;
} else { } else {
Plot origin = area.getOwnedPlot(loc); Plot origin = area.getOwnedPlot(loc);
if (origin == null) { if (origin == null) {
@ -1122,11 +1012,11 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (eventType != null && !player.isSneaking()) { if (eventType != null && !player.isSneaking()) {
break; break;
} }
Material type = hand == null ? null : hand.getType(); Material type = (hand == null) ? null : hand.getType();
int id = type == null ? 0 : type.getId(); int id = (type == null) ? 0 : type.getId();
if (id == 0) { if (id == 0) {
eventType = PlayerBlockEventType.INTERACT_BLOCK; eventType = PlayerBlockEventType.INTERACT_BLOCK;
lb = new BukkitLazyBlock(id, block); lb = new BukkitLazyBlock(0, block);
break; break;
} else if (id < 198) { } else if (id < 198) {
loc = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation()); loc = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation());

View File

@ -1,19 +1,18 @@
package com.plotsquared.bukkit.listeners; package com.plotsquared.bukkit.listeners;
import java.util.Iterator;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotArea;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent;
import java.util.Iterator;
public class PlayerEvents_1_8_3 implements Listener { public class PlayerEvents_1_8_3 implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -36,18 +35,16 @@ public class PlayerEvents_1_8_3 implements Listener {
return; return;
} }
Plot plot = area.getOwnedPlot(loc); Plot plot = area.getOwnedPlot(loc);
if (plot == null) { if (plot == null || !FlagManager.isPlotFlagTrue(plot, "explosion")) {
event.setCancelled(true); event.setCancelled(true);
} }
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
final Iterator<Block> iter = event.blockList().iterator(); final Iterator<Block> iter = event.blockList().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
final Block b = iter.next(); final Block b = iter.next();
if (!plot.equals(BukkitUtil.getLocation(b.getLocation()).getPlotAbs())) { if (!plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(b.getLocation())))) {
iter.remove(); iter.remove();
} }
} }
return; return;
} }
} }
}

View File

@ -31,12 +31,14 @@ import com.plotsquared.listener.PlotListener;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
@ -106,6 +108,22 @@ public class PlotPlusListener extends PlotListener implements Listener {
}, 0l, 20l); }, 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) @EventHandler(priority = EventPriority.HIGH)
public void onInteract(final BlockDamageEvent event) { public void onInteract(final BlockDamageEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();

View File

@ -13,28 +13,15 @@ import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
public class WorldEvents implements Listener { public class WorldEvents implements Listener {
public static String lastWorld = null;
public static String getName(final World world) {
if ((lastWorld != null) && !lastWorld.equals("CheckingPlotSquaredGenerator")) {
return lastWorld;
} else {
return world.getName();
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onWorldInit(final WorldInitEvent event) { public static void onWorldInit(final WorldInitEvent event) {
final World world = event.getWorld(); final World world = event.getWorld();
final String name = getName(world); final String name = world.getName();
final ChunkGenerator gen = world.getGenerator(); final ChunkGenerator gen = world.getGenerator();
if (gen instanceof GeneratorWrapper) { if (gen instanceof GeneratorWrapper) {
PS.get().loadWorld(name, (GeneratorWrapper<?>) gen); PS.get().loadWorld(name, (GeneratorWrapper<?>) gen);
} else { } else {
if (PS.get().config.contains("worlds." + name)) {
PS.get().loadWorld(name, new BukkitPlotGenerator(name, gen)); PS.get().loadWorld(name, new BukkitPlotGenerator(name, gen));
} }
} }
lastWorld = null;
}
} }

View File

@ -1,16 +1,5 @@
package com.plotsquared.bukkit.object; package com.plotsquared.bukkit.object;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.WeatherType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.PluginManager;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
@ -19,6 +8,16 @@ import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.WeatherType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.PluginManager;
import java.util.UUID;
public class BukkitPlayer extends PlotPlayer { public class BukkitPlayer extends PlotPlayer {
@ -133,24 +132,6 @@ public class BukkitPlayer extends PlotPlayer {
return BukkitUtil.getLocationFull(player); return BukkitUtil.getLocationFull(player);
} }
@Override
public void setAttribute(String key) {
setPersistentMeta("attrib_" + key, new byte[]{(byte) 1});
}
@Override
public boolean getAttribute(String key) {
if (!hasPersistentMeta(key)) {
return false;
}
return getPersistentMeta("attrib_" + key)[0] == 1;
}
@Override
public void removeAttribute(String key) {
removePersistentMeta("attrib_" + key);
}
@Override @Override
public void loadData() { public void loadData() {
if (!player.isOnline()) { if (!player.isOnline()) {
@ -235,6 +216,12 @@ public class BukkitPlayer extends PlotPlayer {
player.kickPlayer(message); player.kickPlayer(message);
} }
@Override public void stopSpectating() {
if (getGamemode() == PlotGamemode.SPECTATOR) {
player.setSpectatorTarget(null);
}
}
@Override @Override
public boolean isBanned() { public boolean isBanned() {
return player.isBanned(); return player.isBanned();

View File

@ -4,13 +4,17 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.AbstractTitle;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import java.lang.reflect.InvocationTargetException;
public class DefaultTitle extends AbstractTitle { public class DefaultTitle extends AbstractTitle {
@Override @Override
public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) { public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) {
try { try {
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out); final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
title.send(((BukkitPlayer) player).player); title.send(((BukkitPlayer) player).player);
} catch (Exception e) { } catch (ClassNotFoundException | InvocationTargetException | SecurityException | NoSuchMethodException | InstantiationException |
IllegalArgumentException | IllegalAccessException e) {
AbstractTitle.TITLE_CLASS = new DefaultTitle_183(); AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
} }

View File

@ -101,7 +101,8 @@ public class DefaultTitleManager {
* Fade out time * Fade out time
* @throws ClassNotFoundException * @throws ClassNotFoundException
*/ */
public DefaultTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) throws ClassNotFoundException { public DefaultTitleManager(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime)
throws ClassNotFoundException {
this.title = title; this.title = title;
this.subtitle = subtitle; this.subtitle = subtitle;
this.fadeInTime = fadeInTime; this.fadeInTime = fadeInTime;
@ -255,7 +256,8 @@ public class DefaultTitleManager {
final Object connection = getField(handle.getClass(), "playerConnection").get(handle); final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
final Object[] actions = packetActions.getEnumConstants(); final Object[] actions = packetActions.getEnumConstants();
final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); final Method sendPacket = getMethod(connection.getClass(), "sendPacket");
Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], null, fadeInTime * (ticks ? 1 : 20), Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE)
.newInstance(actions[2], null, fadeInTime * (ticks ? 1 : 20),
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20)); stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
// Send if set // Send if set
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) { if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) {
@ -278,7 +280,8 @@ public class DefaultTitleManager {
/** /**
* Broadcast the title to all players * Broadcast the title to all players
* @throws Exception * @throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
SecurityException
*/ */
public void broadcast() public void broadcast()
throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException, throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,

View File

@ -1,15 +1,15 @@
package com.plotsquared.bukkit.titles; package com.plotsquared.bukkit.titles;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
/** /**
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ] * [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
* *
@ -36,7 +36,7 @@ public class DefaultTitleManager_183 {
private int stayTime = -1; private int stayTime = -1;
private int fadeOutTime = -1; private int fadeOutTime = -1;
private boolean ticks = false; private boolean ticks = false;
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<Class<?>, Class<?>>(); private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
/** /**
* Create a new 1.8 title * Create a new 1.8 title
@ -252,7 +252,7 @@ public class DefaultTitleManager_183 {
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}"); "{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized); packet = packetTitle.getConstructor(packetActions, chatBaseComponent).newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet); sendPacket.invoke(connection, packet);
if (subtitle != "") { if (!subtitle.isEmpty()) {
// Send subtitle if present // Send subtitle if present
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null, serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}"); "{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
@ -365,9 +365,7 @@ public class DefaultTitleManager_183 {
private Class<?> getNMSClass(final String className) throws ClassNotFoundException { private Class<?> getNMSClass(final String className) throws ClassNotFoundException {
final String fullName = "net.minecraft.server." + getVersion() + className; final String fullName = "net.minecraft.server." + getVersion() + className;
Class<?> clazz = null; return Class.forName(fullName);
clazz = Class.forName(fullName);
return clazz;
} }
private Field getField(final Class<?> clazz, final String name) { private Field getField(final Class<?> clazz, final String name) {
@ -392,10 +390,10 @@ public class DefaultTitleManager_183 {
} }
private boolean ClassListEqual(final Class<?>[] l1, final Class<?>[] l2) { private boolean ClassListEqual(final Class<?>[] l1, final Class<?>[] l2) {
boolean equal = true;
if (l1.length != l2.length) { if (l1.length != l2.length) {
return false; return false;
} }
boolean equal = true;
for (int i = 0; i < l1.length; i++) { for (int i = 0; i < l1.length; i++) {
if (l1[i] != l2[i]) { if (l1[i] != l2[i]) {
equal = false; equal = false;

View File

@ -12,7 +12,7 @@ public class HackTitle extends AbstractTitle {
try { try {
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out); final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
title.send(((BukkitPlayer) player).player); title.send(((BukkitPlayer) player).player);
} catch (final Throwable e) { } catch (Exception e) {
PS.debug("&cYour server version does not support titles!"); PS.debug("&cYour server version does not support titles!");
Settings.TITLES = false; Settings.TITLES = false;
AbstractTitle.TITLE_CLASS = null; AbstractTitle.TITLE_CLASS = null;

View File

@ -1,14 +1,15 @@
package com.plotsquared.bukkit.titles; package com.plotsquared.bukkit.titles;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/** /**
* Minecraft 1.8 Title * Minecraft 1.8 Title
* *
@ -33,7 +34,7 @@ public class HackTitleManager {
private int stayTime = -1; private int stayTime = -1;
private int fadeOutTime = -1; private int fadeOutTime = -1;
private boolean ticks = false; private boolean ticks = false;
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<Class<?>, Class<?>>(); private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
/** /**
* Create a new 1.8 title * Create a new 1.8 title
@ -244,7 +245,7 @@ public class HackTitleManager {
"{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}"); "{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}");
packet = packetTitle.getConstructor(packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized); packet = packetTitle.getConstructor(packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet); sendPacket.invoke(connection, packet);
if (subtitle != "") { if (!subtitle.isEmpty()) {
// Send subtitle if present // Send subtitle if present
serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null, serialized = getMethod(nmsChatSerializer, "a", String.class).invoke(null,
"{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}"); "{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}");
@ -313,8 +314,7 @@ public class HackTitleManager {
final Object handle = getHandle(player); final Object handle = getHandle(player);
final Object connection = getField(handle.getClass(), "playerConnection").get(handle); final Object connection = getField(handle.getClass(), "playerConnection").get(handle);
final Object networkManager = getValue("networkManager", connection); final Object networkManager = getValue("networkManager", connection);
final Integer version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager); return (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
return version;
} }
/** /**
@ -336,7 +336,8 @@ public class HackTitleManager {
private Class<?> getClass(final String namespace) { private Class<?> getClass(final String namespace) {
try { try {
return Class.forName(namespace); return Class.forName(namespace);
} catch (final Exception e) {} } catch (ClassNotFoundException e) {
}
return null; return null;
} }
@ -378,7 +379,7 @@ public class HackTitleManager {
private Object getHandle(final Object obj) { private Object getHandle(final Object obj) {
try { try {
return getMethod("getHandle", obj.getClass()).invoke(obj); return getMethod("getHandle", obj.getClass()).invoke(obj);
} catch (final Exception e) { } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
@ -397,15 +398,12 @@ public class HackTitleManager {
private String getVersion() { private String getVersion() {
final String name = Bukkit.getServer().getClass().getPackage().getName(); final String name = Bukkit.getServer().getClass().getPackage().getName();
final String version = name.substring(name.lastIndexOf('.') + 1) + "."; return name.substring(name.lastIndexOf('.') + 1) + ".";
return version;
} }
private Class<?> getNMSClass(final String className) throws ClassNotFoundException { private Class<?> getNMSClass(final String className) throws ClassNotFoundException {
final String fullName = "net.minecraft.server." + getVersion() + className; final String fullName = "net.minecraft.server." + getVersion() + className;
Class<?> clazz = null; return Class.forName(fullName);
clazz = Class.forName(fullName);
return clazz;
} }
private Field getField(final Class<?> clazz, final String name) { private Field getField(final Class<?> clazz, final String name) {
@ -413,7 +411,7 @@ public class HackTitleManager {
final Field field = clazz.getDeclaredField(name); final Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field; return field;
} catch (final Exception e) { } catch (SecurityException | NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
@ -430,10 +428,10 @@ public class HackTitleManager {
} }
private boolean ClassListEqual(final Class<?>[] l1, final Class<?>[] l2) { private boolean ClassListEqual(final Class<?>[] l1, final Class<?>[] l2) {
boolean equal = true;
if (l1.length != l2.length) { if (l1.length != l2.length) {
return false; return false;
} }
boolean equal = true;
for (int i = 0; i < l1.length; i++) { for (int i = 0; i < l1.length; i++) {
if (l1[i] != l2[i]) { if (l1[i] != l2[i]) {
equal = false; equal = false;

View File

@ -668,11 +668,8 @@ public class BukkitChunkManager extends ChunkManager {
if (!pLoc.getChunkLoc().equals(loc)) { if (!pLoc.getChunkLoc().equals(loc)) {
continue; continue;
} }
PlotBlock plotblock = WorldUtil.IMP.getBlock(pLoc); pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ()));
if (plotblock.id != 0) { pp.teleport(pLoc);
Plot plot = pp.getCurrentPlot();
pp.teleport(plot.getDefaultHome());
}
} }
} }
@ -996,20 +993,7 @@ public class BukkitChunkManager extends ChunkManager {
final int tx = pos2.getX(); final int tx = pos2.getX();
final int tz = pos2.getZ(); final int tz = pos2.getZ();
for (final Entity entity : entities) { for (final Entity entity : entities) {
if (entity instanceof Player) { if (!(entity instanceof Player)) {
final org.bukkit.Location loc = entity.getLocation();
if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) {
final Player player = (Player) entity;
final PlotPlayer pp = BukkitUtil.getPlayer(player);
final Plot plot = pp.getCurrentPlot();
if (plot != null) {
final Location plotHome = plot.getDefaultHome();
if (pp.getLocation().getY() <= plotHome.getY()) {
pp.teleport(plotHome);
}
}
}
} else {
final org.bukkit.Location loc = entity.getLocation(); final org.bukkit.Location loc = entity.getLocation();
if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) { if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) {
entity.remove(); entity.remove();
@ -1075,9 +1059,11 @@ public class BukkitChunkManager extends ChunkManager {
final Set<Chunk> chunks = new HashSet<>(); final Set<Chunk> chunks = new HashSet<>();
for (int X = bx; X <= tx; X++) { for (int X = bx; X <= tx; X++) {
for (int Z = bz; Z <= tz; Z++) { for (int Z = bz; Z <= tz; Z++) {
if (world.isChunkLoaded(X, Z)) {
chunks.add(world.getChunkAt(X, Z)); chunks.add(world.getChunkAt(X, Z));
} }
} }
}
boolean doWhole = false; boolean doWhole = false;
List<Entity> entities = null; List<Entity> entities = null;

View File

@ -5,17 +5,9 @@ import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -25,12 +17,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData; import org.bukkit.material.*;
import org.bukkit.material.Sandstone;
import org.bukkit.material.Step;
import org.bukkit.material.Tree;
import org.bukkit.material.WoodenStep;
import org.bukkit.material.Wool;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -171,9 +158,6 @@ public class BukkitUtil extends WorldUtil {
public int getBiomeFromString(final String biomeStr) { public int getBiomeFromString(final String biomeStr) {
try { try {
final Biome biome = Biome.valueOf(biomeStr.toUpperCase()); final Biome biome = Biome.valueOf(biomeStr.toUpperCase());
if (biome == null) {
return -1;
}
return Arrays.asList(Biome.values()).indexOf(biome); return Arrays.asList(Biome.values()).indexOf(biome);
} catch (final IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
return -1; return -1;

View File

@ -6,36 +6,21 @@ import com.google.common.collect.HashBiMap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.MapMaker; import com.google.common.collect.MapMaker;
import com.google.common.io.ByteSink; import com.google.common.io.ByteSink;
import com.google.common.io.ByteSource;
import com.google.common.io.Closeables; import com.google.common.io.Closeables;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.common.io.InputSupplier;
import com.google.common.primitives.Primitives; import com.google.common.primitives.Primitives;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.io.BufferedInputStream; import java.io.*;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.AbstractList; import java.util.*;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
@ -162,13 +147,13 @@ public class NbtFactory {
* @return The decoded NBT compound. * @return The decoded NBT compound.
* @throws IOException If anything went wrong. * @throws IOException If anything went wrong.
*/ */
public static NbtCompound fromStream(final ByteSource stream, final StreamOptions option) throws IOException { public static NbtCompound fromStream(final InputSupplier<? extends InputStream> stream, final StreamOptions option) throws IOException {
InputStream input = null; InputStream input = null;
DataInputStream data = null; DataInputStream data = null;
boolean suppress = true; boolean suppress = true;
try { try {
input = stream.openStream(); input = stream.getInput();
data = new DataInputStream(new BufferedInputStream(option == StreamOptions.GZIP_COMPRESSION ? new GZIPInputStream(input) : input)); data = new DataInputStream(new BufferedInputStream(option == StreamOptions.GZIP_COMPRESSION ? new GZIPInputStream(input) : input));
final NbtCompound result = fromCompound(get().LOAD_COMPOUND.loadNbt(data)); final NbtCompound result = fromCompound(get().LOAD_COMPOUND.loadNbt(data));

View File

@ -1,7 +1,5 @@
package com.plotsquared.bukkit.util; package com.plotsquared.bukkit.util;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
@ -19,13 +17,11 @@ import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry; 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) * 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(); final Object c = methodGetHandleChunk.of(chunk).call();
chunks.remove(chunk); chunks.remove(chunk);
final Object con = connection.of(entity).get(); 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); final Object packet = MapChunk.create(c, true, 65535);
send.of(con).call(packet); 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) { public void sendChunk(final String worldname, final List<ChunkLoc> locs) {
final World myworld = Bukkit.getWorld(worldname); final World myworld = Bukkit.getWorld(worldname);
final ArrayList<Chunk> chunks = new ArrayList<>(); final ArrayList<Chunk> chunks = new ArrayList<>();
for (final ChunkLoc loc : locs) { for (final ChunkLoc loc : locs) {
if (myworld.isChunkLoaded(loc.x, loc.z)) {
chunks.add(myworld.getChunkAt(loc.x, loc.z)); chunks.add(myworld.getChunkAt(loc.x, loc.z));
} }
}
sendChunk(chunks); sendChunk(chunks);
} }
} }

View File

@ -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;
}
}

View File

@ -49,11 +49,8 @@ public class FastQueue_1_8_3 extends SlowQueue {
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition"); private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection"); private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
public HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>(); public HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
private RefMethod methodGetHandlePlayer;
private RefMethod methodGetHandleChunk; private RefMethod methodGetHandleChunk;
private RefConstructor MapChunk; private RefConstructor MapChunk;
private RefField connection;
private RefMethod send;
private RefMethod methodInitLighting; private RefMethod methodInitLighting;
private RefConstructor classBlockPositionConstructor; private RefConstructor classBlockPositionConstructor;
private RefConstructor classChunkSectionConstructor; private RefConstructor classChunkSectionConstructor;
@ -64,12 +61,9 @@ public class FastQueue_1_8_3 extends SlowQueue {
private RefMethod methodGetIdArray; private RefMethod methodGetIdArray;
public FastQueue_1_8_3() throws NoSuchMethodException, RuntimeException { public FastQueue_1_8_3() throws NoSuchMethodException, RuntimeException {
methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
methodInitLighting = classChunk.getMethod("initLighting"); methodInitLighting = classChunk.getMethod("initLighting");
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class); MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
connection = classEntityPlayer.getField("playerConnection");
send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class); classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
methodX = classWorld.getMethod("x", classBlockPosition.getRealClass()); methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
fieldSections = classChunk.getField("sections"); fieldSections = classChunk.getField("sections");

View File

@ -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);
}
}

View File

@ -22,7 +22,7 @@ public class GenChunk extends PlotChunk<Chunk> {
public GenChunk(Chunk chunk, ChunkWrapper wrap) { public GenChunk(Chunk chunk, ChunkWrapper wrap) {
super(wrap); super(wrap);
if ((this.chunk = chunk) == null) { if ((this.chunk = chunk) == null && wrap != null) {
World world = BukkitUtil.getWorld(wrap.world); World world = BukkitUtil.getWorld(wrap.world);
if (world != null) { if (world != null) {
chunk = world.getChunkAt(wrap.x, wrap.z); chunk = world.getChunkAt(wrap.x, wrap.z);
@ -34,7 +34,7 @@ public class GenChunk extends PlotChunk<Chunk> {
@Override @Override
public Chunk getChunkAbs() { public Chunk getChunkAbs() {
ChunkWrapper wrap = getChunkWrapper(); ChunkWrapper wrap = getChunkWrapper();
if (wrap.x != chunk.getX() || wrap.z != chunk.getZ()) { if (chunk == null || wrap.x != chunk.getX() || wrap.z != chunk.getZ()) {
chunk = BukkitUtil.getWorld(wrap.world).getChunkAt(wrap.x, wrap.z); chunk = BukkitUtil.getWorld(wrap.world).getChunkAt(wrap.x, wrap.z);
} }
return chunk; return chunk;
@ -65,9 +65,14 @@ public class GenChunk extends PlotChunk<Chunk> {
modified = true; modified = true;
result[i] = v = new short[4096]; result[i] = v = new short[4096];
} }
v[MainUtil.CACHE_J[y][x][z]] = (short) id; int j = MainUtil.CACHE_J[y][x][z];
v[j] = (short) id;
if (data != 0) { if (data != 0) {
getChunk().getBlock(x, y, z).setData(data); byte[] vd = result_data[i];
if (vd == null) {
result_data[i] = vd = new byte[4096];
}
vd[j] = data;
} }
} }

View File

@ -11,7 +11,6 @@ public class SlowChunk extends PlotChunk<Chunk> {
public PlotBlock[][] result = new PlotBlock[16][]; public PlotBlock[][] result = new PlotBlock[16][];
public int[][] biomes; public int[][] biomes;
private PlotBlock lastBlock;
public SlowChunk(ChunkWrapper chunk) { public SlowChunk(ChunkWrapper chunk) {
super(chunk); super(chunk);
} }
@ -35,11 +34,7 @@ public class SlowChunk extends PlotChunk<Chunk> {
if (result[y >> 4] == null) { if (result[y >> 4] == null) {
result[y >> 4] = new PlotBlock[4096]; result[y >> 4] = new PlotBlock[4096];
} }
if (id == lastBlock.id && data == lastBlock.data) { result[MainUtil.CACHE_I[y][x][z]][MainUtil.CACHE_J[y][x][z]] = new PlotBlock((short) id, data);
result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = lastBlock;
} else {
result[MainUtil.CACHE_I[x][y][z]][MainUtil.CACHE_J[x][y][z]] = new PlotBlock((short) id, data);
}
} }
@Override @Override

View File

@ -123,6 +123,9 @@ public class SlowQueue implements PlotQueue<Chunk> {
final int z = MainUtil.z_loc[i][j]; final int z = MainUtil.z_loc[i][j];
Block block = chunk.getBlock(x, y, z); Block block = chunk.getBlock(x, y, z);
PlotBlock newBlock = result2[j]; PlotBlock newBlock = result2[j];
if (newBlock == null) {
continue;
}
switch (newBlock.id) { switch (newBlock.id) {
case -1: case -1:
if (block.getData() == newBlock.data) { if (block.getData() == newBlock.data) {

View File

@ -2,6 +2,7 @@ package com.plotsquared.bukkit.uuid;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
import com.google.common.io.ByteSource; import com.google.common.io.ByteSource;
import com.google.common.io.InputSupplier;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
@ -9,17 +10,14 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.NbtFactory; import com.plotsquared.bukkit.util.NbtFactory;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -102,12 +100,14 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
final UUID uuid = UUID.fromString(s); final UUID uuid = UUID.fromString(s);
if (check || all.remove(uuid)) { if (check || all.remove(uuid)) {
final File file = new File(playerdataFolder + File.separator + current); final File file = new File(playerdataFolder + File.separator + current);
final ByteSource is = com.google.common.io.Files.asByteSource(file); final InputSupplier<FileInputStream> is = com.google.common.io.Files.newInputStreamSupplier(file);
final NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION); final NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
final NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit"); final NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
final String name = (String) bukkit.get("lastKnownName"); final String name = (String) bukkit.get("lastKnownName");
final long last = (long) bukkit.get("lastPlayed"); final long last = (long) bukkit.get("lastPlayed");
ExpireManager.dates.put(uuid, last); if (ExpireManager.IMP != null) {
ExpireManager.IMP.storeDate(uuid, last);
}
toAdd.put(new StringWrapper(name), uuid); toAdd.put(new StringWrapper(name), uuid);
} }
} catch (final Exception e) { } catch (final Exception e) {
@ -173,6 +173,9 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
for (UUID uuid : uuids) { for (UUID uuid : uuids) {
try { try {
final File file = new File(playerdataFolder + File.separator + uuid.toString() + ".dat"); final File file = new File(playerdataFolder + File.separator + uuid.toString() + ".dat");
if (!file.exists()) {
continue;
}
final ByteSource is = com.google.common.io.Files.asByteSource(file); final ByteSource is = com.google.common.io.Files.asByteSource(file);
final NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION); final NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
final NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit"); final NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
@ -187,7 +190,9 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
uuid = new UUID(most, least); uuid = new UUID(most, least);
} }
} }
ExpireManager.dates.put(uuid, last); if (ExpireManager.IMP != null) {
ExpireManager.IMP.storeDate(uuid, last);
}
toAdd.put(new StringWrapper(name), uuid); toAdd.put(new StringWrapper(name), uuid);
} catch (final Throwable e) { } catch (final Throwable e) {
PS.debug(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat"); PS.debug(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
@ -207,7 +212,9 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
final StringWrapper wrap = new StringWrapper(name); final StringWrapper wrap = new StringWrapper(name);
final UUID uuid = uuidWrapper.getUUID(op); final UUID uuid = uuidWrapper.getUUID(op);
toAdd.put(wrap, uuid); toAdd.put(wrap, uuid);
ExpireManager.dates.put(uuid, last); if (ExpireManager.IMP != null) {
ExpireManager.IMP.storeDate(uuid, last);
}
} }
} }
} }

View File

@ -1,6 +1,6 @@
name: ${project.name} name: ${name}
main: com.plotsquared.bukkit.BukkitMain main: com.plotsquared.bukkit.BukkitMain
version: ${project.version} version: ${version}
load: STARTUP load: STARTUP
description: > description: >
Easy, yet powerful Plot World generation and management. Easy, yet powerful Plot World generation and management.
@ -146,6 +146,7 @@ permissions:
plots.save: true plots.save: true
plots.done: true plots.done: true
plots.continue: true plots.continue: true
plots.middle: true
plots.worldedit.bypass: plots.worldedit.bypass:
default: false default: false
plots.gamemode.bypass: plots.gamemode.bypass:

11
Core/build.gradle Normal file
View 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'

View File

@ -20,8 +20,7 @@ public interface Configuration extends ConfigurationSection {
* @param value Value to set the default to. * @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null. * @throws IllegalArgumentException Thrown if path is null.
*/ */
@Override @Override void addDefault(final String path, final Object value);
public void addDefault(final String path, final Object value);
/** /**
* Sets the default values of the given paths as provided. * Sets the default values of the given paths as provided.
@ -33,7 +32,7 @@ public interface Configuration extends ConfigurationSection {
* @param defaults A map of Path->Values to add to defaults. * @param defaults A map of Path->Values to add to defaults.
* @throws IllegalArgumentException Thrown if defaults is null. * @throws IllegalArgumentException Thrown if defaults is null.
*/ */
public void addDefaults(final Map<String, Object> defaults); void addDefaults(final Map<String, Object> defaults);
/** /**
* Sets the default values of the given paths as provided. * Sets the default values of the given paths as provided.
@ -50,7 +49,7 @@ public interface Configuration extends ConfigurationSection {
* @param defaults A configuration holding a list of defaults to copy. * @param defaults A configuration holding a list of defaults to copy.
* @throws IllegalArgumentException Thrown if defaults is null or this. * @throws IllegalArgumentException Thrown if defaults is null or this.
*/ */
public void addDefaults(final Configuration defaults); void addDefaults(final Configuration defaults);
/** /**
* Sets the source of all default values for this {@link Configuration}. * Sets the source of all default values for this {@link Configuration}.
@ -61,7 +60,7 @@ public interface Configuration extends ConfigurationSection {
* @param defaults New source of default values for this configuration. * @param defaults New source of default values for this configuration.
* @throws IllegalArgumentException Thrown if defaults is null or this. * @throws IllegalArgumentException Thrown if defaults is null or this.
*/ */
public void setDefaults(final Configuration defaults); void setDefaults(final Configuration defaults);
/** /**
* Gets the source {@link Configuration} for this configuration. * Gets the source {@link Configuration} for this configuration.
@ -72,7 +71,7 @@ public interface Configuration extends ConfigurationSection {
* *
* @return Configuration source for default values, or null if none exist. * @return Configuration source for default values, or null if none exist.
*/ */
public Configuration getDefaults(); Configuration getDefaults();
/** /**
* Gets the {@link ConfigurationOptions} for this {@link Configuration}. * Gets the {@link ConfigurationOptions} for this {@link Configuration}.
@ -81,5 +80,5 @@ public interface Configuration extends ConfigurationSection {
* *
* @return Options for this configuration * @return Options for this configuration
*/ */
public ConfigurationOptions options(); ConfigurationOptions options();
} }

View File

@ -22,7 +22,7 @@ public interface ConfigurationSection {
* list. * list.
* @return Set of keys contained within this ConfigurationSection. * @return Set of keys contained within this ConfigurationSection.
*/ */
public Set<String> getKeys(final boolean deep); Set<String> getKeys(final boolean deep);
/** /**
* Gets a Map containing all keys and their values for this section. * Gets a Map containing all keys and their values for this section.
@ -38,7 +38,7 @@ public interface ConfigurationSection {
* list. * list.
* @return Map of keys and values of this section. * @return Map of keys and values of this section.
*/ */
public Map<String, Object> getValues(final boolean deep); Map<String, Object> getValues(final boolean deep);
/** /**
* Checks if this {@link ConfigurationSection} contains the given path. * Checks if this {@link ConfigurationSection} contains the given path.
@ -51,7 +51,7 @@ public interface ConfigurationSection {
* default or being set. * default or being set.
* @throws IllegalArgumentException Thrown when path is null. * @throws IllegalArgumentException Thrown when path is null.
*/ */
public boolean contains(final String path); boolean contains(final String path);
/** /**
* Checks if this {@link ConfigurationSection} has a value set for the * Checks if this {@link ConfigurationSection} has a value set for the
@ -65,7 +65,7 @@ public interface ConfigurationSection {
* having a default. * having a default.
* @throws IllegalArgumentException Thrown when path is null. * @throws IllegalArgumentException Thrown when path is null.
*/ */
public boolean isSet(final String path); boolean isSet(final String path);
/** /**
* Gets the path of this {@link ConfigurationSection} from its root {@link * Gets the path of this {@link ConfigurationSection} from its root {@link
@ -82,7 +82,7 @@ public interface ConfigurationSection {
* *
* @return Path of this section relative to its root * @return Path of this section relative to its root
*/ */
public String getCurrentPath(); String getCurrentPath();
/** /**
* Gets the name of this individual {@link ConfigurationSection}, in the * Gets the name of this individual {@link ConfigurationSection}, in the
@ -93,7 +93,7 @@ public interface ConfigurationSection {
* *
* @return Name of this section * @return Name of this section
*/ */
public String getName(); String getName();
/** /**
* Gets the root {@link Configuration} that contains this {@link * Gets the root {@link Configuration} that contains this {@link
@ -107,7 +107,7 @@ public interface ConfigurationSection {
* *
* @return Root configuration containing this section. * @return Root configuration containing this section.
*/ */
public Configuration getRoot(); Configuration getRoot();
/** /**
* Gets the parent {@link ConfigurationSection} that directly contains * Gets the parent {@link ConfigurationSection} that directly contains
@ -120,7 +120,7 @@ public interface ConfigurationSection {
* *
* @return Parent section containing this section. * @return Parent section containing this section.
*/ */
public ConfigurationSection getParent(); ConfigurationSection getParent();
/** /**
* Gets the requested Object by path. * Gets the requested Object by path.
@ -132,7 +132,7 @@ public interface ConfigurationSection {
* @param path Path of the Object to get. * @param path Path of the Object to get.
* @return Requested Object. * @return Requested Object.
*/ */
public Object get(final String path); Object get(final String path);
/** /**
* Gets the requested Object by path, returning a default value if not * Gets the requested Object by path, returning a default value if not
@ -146,7 +146,7 @@ public interface ConfigurationSection {
* @param def The default value to return if the path is not found. * @param def The default value to return if the path is not found.
* @return Requested Object. * @return Requested Object.
*/ */
public Object get(final String path, final Object def); Object get(final String path, final Object def);
/** /**
* Sets the specified path to the given value. * Sets the specified path to the given value.
@ -162,7 +162,7 @@ public interface ConfigurationSection {
* @param path Path of the object to set. * @param path Path of the object to set.
* @param value New value to set the path to. * @param value New value to set the path to.
*/ */
public void set(final String path, final Object value); void set(final String path, final Object value);
/** /**
* Creates an empty {@link ConfigurationSection} at the specified path. * Creates an empty {@link ConfigurationSection} at the specified path.
@ -174,7 +174,7 @@ public interface ConfigurationSection {
* @param path Path to create the section at. * @param path Path to create the section at.
* @return Newly created section * @return Newly created section
*/ */
public ConfigurationSection createSection(final String path); ConfigurationSection createSection(final String path);
/** /**
* Creates a {@link ConfigurationSection} at the specified path, with * Creates a {@link ConfigurationSection} at the specified path, with
@ -188,7 +188,7 @@ public interface ConfigurationSection {
* @param map The values to used. * @param map The values to used.
* @return Newly created section * @return Newly created section
*/ */
public ConfigurationSection createSection(final String path, final Map<?, ?> map); ConfigurationSection createSection(final String path, final Map<?, ?> map);
// Primitives // Primitives
/** /**
@ -201,7 +201,7 @@ public interface ConfigurationSection {
* @param path Path of the String to get. * @param path Path of the String to get.
* @return Requested String. * @return Requested String.
*/ */
public String getString(final String path); String getString(final String path);
/** /**
* Gets the requested String by path, returning a default value if not * Gets the requested String by path, returning a default value if not
@ -216,7 +216,7 @@ public interface ConfigurationSection {
* not a String. * not a String.
* @return Requested String. * @return Requested String.
*/ */
public String getString(final String path, final String def); String getString(final String path, final String def);
/** /**
* Checks if the specified path is a String. * Checks if the specified path is a String.
@ -229,7 +229,7 @@ public interface ConfigurationSection {
* @param path Path of the String to check. * @param path Path of the String to check.
* @return Whether or not the specified path is a String. * @return Whether or not the specified path is a String.
*/ */
public boolean isString(final String path); boolean isString(final String path);
/** /**
* Gets the requested int by path. * Gets the requested int by path.
@ -241,7 +241,7 @@ public interface ConfigurationSection {
* @param path Path of the int to get. * @param path Path of the int to get.
* @return Requested int. * @return Requested int.
*/ */
public int getInt(final String path); int getInt(final String path);
/** /**
* Gets the requested int by path, returning a default value if not found. * Gets the requested int by path, returning a default value if not found.
@ -255,7 +255,7 @@ public interface ConfigurationSection {
* not an int. * not an int.
* @return Requested int. * @return Requested int.
*/ */
public int getInt(final String path, final int def); int getInt(final String path, final int def);
/** /**
* Checks if the specified path is an int. * Checks if the specified path is an int.
@ -268,7 +268,7 @@ public interface ConfigurationSection {
* @param path Path of the int to check. * @param path Path of the int to check.
* @return Whether or not the specified path is an int. * @return Whether or not the specified path is an int.
*/ */
public boolean isInt(final String path); boolean isInt(final String path);
/** /**
* Gets the requested boolean by path. * Gets the requested boolean by path.
@ -280,7 +280,7 @@ public interface ConfigurationSection {
* @param path Path of the boolean to get. * @param path Path of the boolean to get.
* @return Requested boolean. * @return Requested boolean.
*/ */
public boolean getBoolean(final String path); boolean getBoolean(final String path);
/** /**
* Gets the requested boolean by path, returning a default value if not * Gets the requested boolean by path, returning a default value if not
@ -295,7 +295,7 @@ public interface ConfigurationSection {
* not a boolean. * not a boolean.
* @return Requested boolean. * @return Requested boolean.
*/ */
public boolean getBoolean(final String path, final boolean def); boolean getBoolean(final String path, final boolean def);
/** /**
* Checks if the specified path is a boolean. * Checks if the specified path is a boolean.
@ -308,7 +308,7 @@ public interface ConfigurationSection {
* @param path Path of the boolean to check. * @param path Path of the boolean to check.
* @return Whether or not the specified path is a boolean. * @return Whether or not the specified path is a boolean.
*/ */
public boolean isBoolean(final String path); boolean isBoolean(final String path);
/** /**
* Gets the requested double by path. * Gets the requested double by path.
@ -320,7 +320,7 @@ public interface ConfigurationSection {
* @param path Path of the double to get. * @param path Path of the double to get.
* @return Requested double. * @return Requested double.
*/ */
public double getDouble(final String path); double getDouble(final String path);
/** /**
* Gets the requested double by path, returning a default value if not * Gets the requested double by path, returning a default value if not
@ -335,7 +335,7 @@ public interface ConfigurationSection {
* not a double. * not a double.
* @return Requested double. * @return Requested double.
*/ */
public double getDouble(final String path, final double def); double getDouble(final String path, final double def);
/** /**
* Checks if the specified path is a double. * Checks if the specified path is a double.
@ -348,7 +348,7 @@ public interface ConfigurationSection {
* @param path Path of the double to check. * @param path Path of the double to check.
* @return Whether or not the specified path is a double. * @return Whether or not the specified path is a double.
*/ */
public boolean isDouble(final String path); boolean isDouble(final String path);
/** /**
* Gets the requested long by path. * Gets the requested long by path.
@ -360,7 +360,7 @@ public interface ConfigurationSection {
* @param path Path of the long to get. * @param path Path of the long to get.
* @return Requested long. * @return Requested long.
*/ */
public long getLong(final String path); long getLong(final String path);
/** /**
* Gets the requested long by path, returning a default value if not * Gets the requested long by path, returning a default value if not
@ -375,7 +375,7 @@ public interface ConfigurationSection {
* not a long. * not a long.
* @return Requested long. * @return Requested long.
*/ */
public long getLong(final String path, final long def); long getLong(final String path, final long def);
/** /**
* Checks if the specified path is a long. * Checks if the specified path is a long.
@ -388,7 +388,7 @@ public interface ConfigurationSection {
* @param path Path of the long to check. * @param path Path of the long to check.
* @return Whether or not the specified path is a long. * @return Whether or not the specified path is a long.
*/ */
public boolean isLong(final String path); boolean isLong(final String path);
// Java // Java
/** /**
@ -401,7 +401,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List. * @return Requested List.
*/ */
public List<?> getList(final String path); List<?> getList(final String path);
/** /**
* Gets the requested List by path, returning a default value if not * Gets the requested List by path, returning a default value if not
@ -416,7 +416,7 @@ public interface ConfigurationSection {
* not a List. * not a List.
* @return Requested List. * @return Requested List.
*/ */
public List<?> getList(final String path, final List<?> def); List<?> getList(final String path, final List<?> def);
/** /**
* Checks if the specified path is a List. * Checks if the specified path is a List.
@ -429,7 +429,7 @@ public interface ConfigurationSection {
* @param path Path of the List to check. * @param path Path of the List to check.
* @return Whether or not the specified path is a List. * @return Whether or not the specified path is a List.
*/ */
public boolean isList(final String path); boolean isList(final String path);
/** /**
* Gets the requested List of String by path. * Gets the requested List of String by path.
@ -444,7 +444,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of String. * @return Requested List of String.
*/ */
public List<String> getStringList(final String path); List<String> getStringList(final String path);
/** /**
* Gets the requested List of Integer by path. * Gets the requested List of Integer by path.
@ -459,7 +459,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Integer. * @return Requested List of Integer.
*/ */
public List<Integer> getIntegerList(final String path); List<Integer> getIntegerList(final String path);
/** /**
* Gets the requested List of Boolean by path. * Gets the requested List of Boolean by path.
@ -474,7 +474,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Boolean. * @return Requested List of Boolean.
*/ */
public List<Boolean> getBooleanList(final String path); List<Boolean> getBooleanList(final String path);
/** /**
* Gets the requested List of Double by path. * Gets the requested List of Double by path.
@ -489,7 +489,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Double. * @return Requested List of Double.
*/ */
public List<Double> getDoubleList(final String path); List<Double> getDoubleList(final String path);
/** /**
* Gets the requested List of Float by path. * Gets the requested List of Float by path.
@ -504,7 +504,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Float. * @return Requested List of Float.
*/ */
public List<Float> getFloatList(final String path); List<Float> getFloatList(final String path);
/** /**
* Gets the requested List of Long by path. * Gets the requested List of Long by path.
@ -519,7 +519,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Long. * @return Requested List of Long.
*/ */
public List<Long> getLongList(final String path); List<Long> getLongList(final String path);
/** /**
* Gets the requested List of Byte by path. * Gets the requested List of Byte by path.
@ -534,7 +534,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Byte. * @return Requested List of Byte.
*/ */
public List<Byte> getByteList(final String path); List<Byte> getByteList(final String path);
/** /**
* Gets the requested List of Character by path. * Gets the requested List of Character by path.
@ -549,7 +549,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Character. * @return Requested List of Character.
*/ */
public List<Character> getCharacterList(final String path); List<Character> getCharacterList(final String path);
/** /**
* Gets the requested List of Short by path. * Gets the requested List of Short by path.
@ -564,7 +564,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Short. * @return Requested List of Short.
*/ */
public List<Short> getShortList(final String path); List<Short> getShortList(final String path);
/** /**
* Gets the requested List of Maps by path. * Gets the requested List of Maps by path.
@ -579,7 +579,7 @@ public interface ConfigurationSection {
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Maps. * @return Requested List of Maps.
*/ */
public List<Map<?, ?>> getMapList(final String path); List<Map<?, ?>> getMapList(final String path);
/** /**
* Gets the requested ConfigurationSection by path. * Gets the requested ConfigurationSection by path.
@ -592,7 +592,7 @@ public interface ConfigurationSection {
* @param path Path of the ConfigurationSection to get. * @param path Path of the ConfigurationSection to get.
* @return Requested ConfigurationSection. * @return Requested ConfigurationSection.
*/ */
public ConfigurationSection getConfigurationSection(final String path); ConfigurationSection getConfigurationSection(final String path);
/** /**
* Checks if the specified path is a ConfigurationSection. * Checks if the specified path is a ConfigurationSection.
@ -606,7 +606,7 @@ public interface ConfigurationSection {
* @param path Path of the ConfigurationSection to check. * @param path Path of the ConfigurationSection to check.
* @return Whether or not the specified path is a ConfigurationSection. * @return Whether or not the specified path is a ConfigurationSection.
*/ */
public boolean isConfigurationSection(final String path); boolean isConfigurationSection(final String path);
/** /**
* Gets the equivalent {@link ConfigurationSection} from the default * Gets the equivalent {@link ConfigurationSection} from the default
@ -618,7 +618,7 @@ public interface ConfigurationSection {
* *
* @return Equivalent section in root configuration * @return Equivalent section in root configuration
*/ */
public ConfigurationSection getDefaultSection(); ConfigurationSection getDefaultSection();
/** /**
* Sets the default value in the root at the given path as provided. * Sets the default value in the root at the given path as provided.
@ -638,5 +638,5 @@ public interface ConfigurationSection {
* @param value Value to set the default to. * @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null. * @throws IllegalArgumentException Thrown if path is null.
*/ */
public void addDefault(final String path, final Object value); void addDefault(final String path, final Object value);
} }

View File

@ -1,64 +1,26 @@
package com.intellectualcrafters.configuration.file; package com.intellectualcrafters.configuration.file;
import com.intellectualcrafters.configuration.Configuration;
import com.intellectualcrafters.configuration.InvalidConfigurationException;
import com.intellectualcrafters.configuration.MemoryConfiguration;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Reader; import java.io.Reader;
import java.io.Writer; import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import com.intellectualcrafters.configuration.Configuration;
import com.intellectualcrafters.configuration.InvalidConfigurationException;
import com.intellectualcrafters.configuration.MemoryConfiguration;
/** /**
* This is a base class for all File based implementations of {@link * This is a base class for all File based implementations of {@link
* Configuration} * Configuration}
*/ */
public abstract class FileConfiguration extends MemoryConfiguration { public abstract class FileConfiguration extends MemoryConfiguration {
/**
* This value specified that the system default encoding should be
* completely ignored, as it cannot handle the ASCII character set, or it
* is a strict-subset of UTF8 already (plain ASCII).
*
* @deprecated temporary compatibility measure
*/
@Deprecated
public static final boolean UTF8_OVERRIDE;
/**
* This value specifies if the system default encoding is unicode, but
* cannot parse standard ASCII.
*
* @deprecated temporary compatibility measure
*/
@Deprecated
public static final boolean UTF_BIG;
/**
* This value specifies if the system supports unicode.
*
* @deprecated temporary compatibility measure
*/
@Deprecated
public static final boolean SYSTEM_UTF;
static {
final byte[] testBytes = Base64Coder.decode("ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVpbXF1eX2BhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ent8fX4NCg==");
final String testString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\r\n";
final Charset defaultCharset = Charset.defaultCharset();
final String resultString = new String(testBytes, defaultCharset);
final boolean trueUTF = defaultCharset.name().contains("UTF");
UTF8_OVERRIDE = !testString.equals(resultString) || defaultCharset.equals(Charset.forName("US-ASCII"));
SYSTEM_UTF = trueUTF || UTF8_OVERRIDE;
UTF_BIG = trueUTF && UTF8_OVERRIDE;
}
/** /**
* Creates an empty {@link FileConfiguration} with no default values. * Creates an empty {@link FileConfiguration} with no default values.
@ -100,8 +62,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
final String data = saveToString(); final String data = saveToString();
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset())) {
writer.write(data); writer.write(data);
} }
} }
@ -146,9 +107,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
* If the file cannot be loaded for any reason, an exception will be * If the file cannot be loaded for any reason, an exception will be
* thrown. * thrown.
* <p> * <p>
* This will attempt to use the {@link Charset#defaultCharset()} for
* files, unless {@link #UTF8_OVERRIDE} but not {@link #UTF_BIG} is
* specified.
* *
* @param file File to load from. * @param file File to load from.
* @throws FileNotFoundException Thrown when the given file cannot be * @throws FileNotFoundException Thrown when the given file cannot be
@ -165,34 +123,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
final FileInputStream stream = new FileInputStream(file); final FileInputStream stream = new FileInputStream(file);
load(new InputStreamReader(stream, UTF8_OVERRIDE && !UTF_BIG ? StandardCharsets.UTF_8 : Charset.defaultCharset())); load(new InputStreamReader(stream, StandardCharsets.UTF_8));
}
/**
* Loads this {@link FileConfiguration} from the specified stream.
* <p>
* All the values contained within this configuration will be removed,
* leaving only settings and defaults, and the new values will be loaded
* from the given stream.
* <p>
* This will attempt to use the {@link Charset#defaultCharset()}, unless
* {@link #UTF8_OVERRIDE} or {@link #UTF_BIG} is specified.
*
* @param stream Stream to load from
* @throws IOException Thrown when the given file cannot be read.
* @throws InvalidConfigurationException Thrown when the given file is not
* a valid Configuration.
* @throws IllegalArgumentException Thrown when stream is null.
* @deprecated This does not consider encoding
* @see #load(Reader)
*/
@Deprecated
public void load(final InputStream stream) throws IOException, InvalidConfigurationException {
if (stream == null) {
throw new NullPointerException("Stream cannot be null");
}
load(new InputStreamReader(stream, UTF8_OVERRIDE ? StandardCharsets.UTF_8 : Charset.defaultCharset()));
} }
/** /**

Some files were not shown because too many files have changed in this diff Show More