Fixing some more things

This commit is contained in:
boy0001
2015-07-31 00:25:16 +10:00
parent bfa877e607
commit e1dad77d8f
264 changed files with 6920 additions and 2146 deletions

View File

@ -24,6 +24,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
import com.intellectualcrafters.plot.util.ChunkManager;
@ -32,7 +33,7 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.InventoryUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlayerManager;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
@ -48,20 +49,18 @@ import com.plotsquared.bukkit.listeners.ForceFieldListener;
import com.plotsquared.bukkit.listeners.PlayerEvents;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8_3;
import com.plotsquared.bukkit.listeners.PlotListener;
import com.plotsquared.bukkit.listeners.PlotPlusListener;
import com.plotsquared.bukkit.listeners.TNTListener;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
import com.plotsquared.bukkit.listeners.worldedit.WESubscriber;
import com.plotsquared.bukkit.titles.AbstractTitle;
import com.plotsquared.bukkit.titles.DefaultTitle;
import com.plotsquared.bukkit.util.BukkitHybridUtils;
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager;
import com.plotsquared.bukkit.util.bukkit.BukkitEconHandler;
import com.plotsquared.bukkit.util.bukkit.BukkitEventUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitInventoryUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitPlayerManager;
import com.plotsquared.bukkit.util.bukkit.BukkitSchematicHandler;
import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager;
import com.plotsquared.bukkit.util.bukkit.BukkitSetupUtils;
import com.plotsquared.bukkit.util.bukkit.BukkitTaskManager;
@ -77,7 +76,6 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.listener.APlotListener;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
@ -494,11 +492,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
BukkitUtil.removePlayer(player.getName());
}
@Override
public APlotListener initPlotListener() {
return new PlotListener();
}
@Override
public void registerChunkProcessor() {
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
@ -509,11 +502,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
}
@Override
public PlayerManager initPlayerManager() {
return new BukkitPlayerManager();
}
@Override
public InventoryUtil initInventoryUtil() {
return new BukkitInventoryUtil();
@ -544,4 +532,15 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
Bukkit.getServer().unloadWorld(world, false);
}
}
@Override
public SchematicHandler initSchematicHandler() {
return new BukkitSchematicHandler();
}
@Override
public AbstractTitle initTitleManager() {
// Already initialized in UUID handler
return AbstractTitle.TITLE_CLASS;
}
}

View File

@ -1,17 +1,23 @@
package com.plotsquared.bukkit.commands;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.commands.DebugUUID;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.StringComparison;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import com.plotsquared.general.commands.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.*;
/**
* Created 2015-02-20 for PlotSquared
@ -20,6 +26,10 @@ import java.util.*;
*/
public class BukkitCommand implements CommandExecutor, TabCompleter {
public BukkitCommand() {
MainCommand.getInstance().addCommand(new DebugUUID());
}
@Override
public boolean onCommand(final CommandSender commandSender, final org.bukkit.command.Command command, final String commandLabel, final String[] args) {
if (commandSender instanceof Player) {

View File

@ -1,17 +1,18 @@
package com.plotsquared.bukkit.database.plotme;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.World;
import com.intellectualcrafters.configuration.file.FileConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashMap;
public abstract class APlotMeConnector {
public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder);

View File

@ -1,5 +1,15 @@
package com.plotsquared.bukkit.database.plotme;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
import com.intellectualcrafters.configuration.file.FileConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
@ -12,12 +22,6 @@ import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.UUIDHandler;
import java.io.File;
import java.sql.*;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
public class ClassicPlotMeConnector extends APlotMeConnector {
private String plugin;

View File

@ -20,19 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.database.plotme;
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.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.generator.HybridGen;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
@ -47,6 +34,20 @@ import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Set;
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.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.generator.HybridGen;
/**
* Created 2014-08-17 for PlotSquared
*
@ -75,7 +76,7 @@ public class LikePlotMeConverter {
}
private void sendMessage(final String message) {
PS.log("&3PlotMe&8->&3PlotSquared&8: &7" + message);
PS.debug("&3PlotMe&8->&3PlotSquared&8: &7" + message);
}
public String getPlotMePath() {
@ -128,7 +129,7 @@ public class LikePlotMeConverter {
return false;
}
PS.log("&3Using connector: " + connector.getClass().getCanonicalName());
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
@ -238,7 +239,7 @@ public class LikePlotMeConverter {
}
}
if (duplicate > 0) {
PS.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
PS.debug("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
}
}
sendMessage("Creating plot DB");
@ -247,10 +248,10 @@ public class LikePlotMeConverter {
@Override
public void run() {
sendMessage("&aDatabase conversion is now complete!");
PS.log("&c - Stop the server");
PS.log("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
PS.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
PS.log("&c - Start the server");
PS.debug("&c - Stop the server");
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
PS.debug("&c - Start the server");
PS.get().setAllPlotsRaw(DBFunc.getPlots());
}
});
@ -315,7 +316,7 @@ public class LikePlotMeConverter {
});
} catch (final Exception e) {
e.printStackTrace();
PS.log("&/end/");
PS.debug("&/end/");
}
return true;
}

View File

@ -1,5 +1,15 @@
package com.plotsquared.bukkit.database.plotme;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
import com.intellectualcrafters.configuration.file.FileConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
@ -12,12 +22,6 @@ import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.UUIDHandler;
import java.io.File;
import java.sql.*;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
public class PlotMeConnector_017 extends APlotMeConnector {
private String plugin;

View File

@ -20,12 +20,13 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.PlotCluster;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.PlotCluster;
/**
* Called when a flag is removed from a plot
*

View File

@ -20,12 +20,13 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.intellectualcrafters.plot.object.Plot;
/**
* @author Citymonstret
* @author Empire92

View File

@ -20,11 +20,12 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.intellectualcrafters.plot.object.Plot;
/**
* @author Citymonstret
* @author Empire92

View File

@ -20,11 +20,12 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.intellectualcrafters.plot.object.Plot;
/**
* @author Citymonstret
* @author Empire92

View File

@ -20,11 +20,12 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import java.util.UUID;
import com.intellectualcrafters.plot.object.Plot;
/**
* @author Citymonstret

View File

@ -20,11 +20,12 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import java.util.UUID;
import com.intellectualcrafters.plot.object.Plot;
/**
* @author Empire92

View File

@ -20,11 +20,12 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import java.util.UUID;
import com.intellectualcrafters.plot.object.Plot;
/**
* @author Citymonstret

View File

@ -20,13 +20,14 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
/**
* Called when a player teleports to a plot
*

View File

@ -20,11 +20,12 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.intellectualcrafters.plot.object.PlotId;
/**
* Called when a plot is cleared
*
@ -38,7 +39,7 @@ public class PlotClearEvent extends Event implements Cancellable {
private boolean cancelled;
/**
* PlotDeleteEvent: Called when a plot is cleared
* PlotClearEvent: Called when a plot is cleared
*
* @param world The world in which the plot was cleared
* @param id The plot that was cleared

View File

@ -20,10 +20,11 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.PlotId;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.intellectualcrafters.plot.object.PlotId;
/**
* Called when a plot is deleted
*

View File

@ -1,8 +1,9 @@
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.event.Event;
import com.intellectualcrafters.plot.object.Plot;
public abstract class PlotEvent extends Event {
private final Plot plot;

View File

@ -20,11 +20,12 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.Plot;
/**
* Called when a Flag is added to a plot
*

View File

@ -20,11 +20,12 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.Plot;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.Plot;
/**
* Called when a flag is removed from a plot
*

View File

@ -20,14 +20,15 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import java.util.ArrayList;
import org.bukkit.World;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.util.ArrayList;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
/**
* @author Empire92

View File

@ -1,8 +1,10 @@
package com.plotsquared.bukkit.events;
import org.bukkit.event.HandlerList;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import org.bukkit.event.HandlerList;
import com.intellectualcrafters.plot.object.Rating;
/**
* Created 2015-07-13 for PlotSquaredGit
@ -13,9 +15,9 @@ public class PlotRateEvent extends PlotEvent {
private static HandlerList handlers = new HandlerList();
private final PlotPlayer rater;
private int rating;
private Rating rating;
public PlotRateEvent(final PlotPlayer rater, final int rating, final Plot plot) {
public PlotRateEvent(final PlotPlayer rater, final Rating rating, final Plot plot) {
super(plot);
this.rater = rater;
this.rating = rating;
@ -29,11 +31,11 @@ public class PlotRateEvent extends PlotEvent {
return this.rater;
}
public void setRating(int rating) {
public void setRating(Rating rating) {
this.rating = rating;
}
public int getRating() {
public Rating getRating() {
return this.rating;
}

View File

@ -20,13 +20,14 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.PlotId;
import java.util.ArrayList;
import org.bukkit.World;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.util.ArrayList;
import com.intellectualcrafters.plot.object.PlotId;
/**
* @author Empire92

View File

@ -1,11 +1,9 @@
package com.plotsquared.bukkit.generator;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager;
import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
@ -13,15 +11,22 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Random;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.BlockWrapper;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager;
import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager;
public class AugmentedPopulator extends BlockPopulator {
public static short[][] x_loc;
public static short[][] y_loc;
public static short[][] z_loc;
public final PlotWorld plotworld;
public final PlotManager manager;
public final BukkitPlotGenerator generator;
@ -36,7 +41,7 @@ public class AugmentedPopulator extends BlockPopulator {
private final int tz;
public AugmentedPopulator(final String world, final BukkitPlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) {
initCache();
MainUtil.initCache();
this.cluster = cluster;
this.generator = generator;
this.plotworld = PS.get().getPlotWorld(world);
@ -77,27 +82,7 @@ public class AugmentedPopulator extends BlockPopulator {
}
}
}
public static void initCache() {
if (x_loc == null) {
x_loc = new short[16][4096];
y_loc = new short[16][4096];
z_loc = new short[16][4096];
for (int i = 0; i < 16; i++) {
int i4 = i << 4;
for (int j = 0; j < 4096; j++) {
final int y = (i4) + (j >> 8);
final int a = (j - ((y & 0xF) << 8));
final int z1 = (a >> 4);
final int x1 = a - (z1 << 4);
x_loc[i][j] = (short) x1;
y_loc[i][j] = (short) y;
z_loc[i][j] = (short) z1;
}
}
}
}
public BlockWrapper get(final int x, final int z, final int i, final int j, final short[][] r, final boolean c) {
final int y = (i << 4) + (j >> 8);
final int a = (j - ((y & 0xF) << 8));
@ -221,9 +206,9 @@ public class AugmentedPopulator extends BlockPopulator {
for (int i = 0; i < result.length; i++) {
if (result[i] != null) {
for (int j = 0; j < 4096; j++) {
int x1 = x_loc[i][j];
int y = y_loc[i][j];
int z1 = z_loc[i][j];
int x1 = MainUtil.x_loc[i][j];
int y = MainUtil.y_loc[i][j];
int z1 = MainUtil.z_loc[i][j];
short id = result[i][j];
final int xx = x + x1;
final int zz = z + z1;
@ -243,7 +228,7 @@ public class AugmentedPopulator extends BlockPopulator {
}
}
else {
short y_min = y_loc[i][0];
short y_min = MainUtil.y_loc[i][0];
if (y_min < 128) {
for (int x1 = x; x1 < x + 16; x1++) {
for (int z1 = z; z1 < z + 16; z1++) {

View File

@ -1,5 +1,7 @@
package com.plotsquared.bukkit.generator;
import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotCluster;
@ -7,8 +9,6 @@ import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.SetupObject;
import org.bukkit.generator.ChunkGenerator;
public class BukkitGeneratorWrapper extends PlotGenerator<ChunkGenerator> {
public final boolean full;

View File

@ -20,22 +20,28 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.generator;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
public abstract class BukkitPlotGenerator extends ChunkGenerator {
public static short[][][] CACHE_I = null;

View File

@ -20,20 +20,24 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.generator;
import com.intellectualcrafters.plot.generator.HybridPlotManager;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.generator.HybridPop;
import com.intellectualcrafters.plot.object.*;
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Biome;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Biome;
import com.intellectualcrafters.plot.generator.HybridPlotManager;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
/**
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -
* You will see a lot of slower implementations have a single for loop. - This is perfectly fine to do, it will just

View File

@ -0,0 +1,234 @@
package com.plotsquared.bukkit.generator;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.World;
import org.bukkit.block.Biome;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.BlockManager;
import com.plotsquared.bukkit.object.BukkitPlotPopulator;
/**
* @author Citymonstret
*/
public class HybridPop extends BukkitPlotPopulator {
/*
* Sorry, this isn't well documented at the moment.
* We advise you to take a look at a world generation tutorial for
* information about how a BlockPopulator works.
*/
final short plotsize;
final short pathsize;
final byte wall;
final byte wallfilling;
final byte roadblock;
final int size;
final int roadheight;
final int wallheight;
final int plotheight;
final byte[] plotfloors;
final byte[] filling;
final short pathWidthLower;
final short pathWidthUpper;
private final HybridPlotWorld plotworld;
Biome biome;
private long state;
private boolean doFilling = false;
private boolean doFloor = false;
private boolean doState = false;
public HybridPop(final PlotWorld pw) {
this.plotworld = (HybridPlotWorld) pw;
// save configuration
this.plotsize = (short) this.plotworld.PLOT_WIDTH;
this.pathsize = (short) this.plotworld.ROAD_WIDTH;
this.roadblock = this.plotworld.ROAD_BLOCK.data;
this.wallfilling = this.plotworld.WALL_FILLING.data;
this.size = this.pathsize + this.plotsize;
this.wall = this.plotworld.WALL_BLOCK.data;
int count1 = 0;
int count2 = 0;
this.plotfloors = new byte[this.plotworld.TOP_BLOCK.length];
for (int i = 0; i < this.plotworld.TOP_BLOCK.length; i++) {
count1++;
this.plotfloors[i] = this.plotworld.TOP_BLOCK[i].data;
if (this.plotworld.TOP_BLOCK[i].data != 0) {
this.doFloor = true;
}
}
this.filling = new byte[this.plotworld.MAIN_BLOCK.length];
for (int i = 0; i < this.plotworld.MAIN_BLOCK.length; i++) {
count2++;
this.filling[i] = this.plotworld.MAIN_BLOCK[i].data;
if (this.plotworld.MAIN_BLOCK[i].data != 0) {
this.doFilling = true;
}
}
if (((count1 > 0) && this.doFloor) || ((count2 > 0) && this.doFilling)) {
this.doState = true;
}
this.wallheight = this.plotworld.WALL_HEIGHT;
this.roadheight = this.plotworld.ROAD_HEIGHT;
this.plotheight = this.plotworld.PLOT_HEIGHT;
if (this.pathsize == 0) {
this.pathWidthLower = (short) -1;
this.pathWidthUpper = (short) (this.plotsize + 1);
}
else {
if ((this.pathsize % 2) == 0) {
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1);
} else {
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2));
}
this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1);
}
}
public final long nextLong() {
final long a = this.state;
this.state = xorShift64(a);
return a;
}
public final long xorShift64(long a) {
a ^= (a << 21);
a ^= (a >>> 35);
a ^= (a << 4);
return a;
}
public final int random(final int n) {
final long result = ((nextLong() >>> 32) * n) >> 32;
return (int) result;
}
@Override
public void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz) {
PS.get().getPlotManager(world.getName());
int sx = (short) ((this.X - this.plotworld.ROAD_OFFSET_X) % this.size);
int sz = (short) ((this.Z - this.plotworld.ROAD_OFFSET_Z) % this.size);
if (sx < 0) {
sx += this.size;
}
if (sz < 0) {
sz += this.size;
}
if (requiredRegion != null) {
for (short x = 0; x < 16; x++) {
for (short z = 0; z < 16; z++) {
if (contains(requiredRegion, x, z)) {
if (this.doFilling) {
for (short y = 1; y < this.plotheight; y++) {
setBlock(x, y, z, this.filling);
}
}
if (this.doFloor) {
setBlock(x, (short) this.plotheight, z, this.plotfloors);
}
if (this.plotworld.PLOT_SCHEMATIC) {
final int absX = ((sx + x) % this.size);
final int absZ = ((sz + z) % this.size);
final PlotLoc loc = new PlotLoc(absX, absZ);
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
if (blocks != null) {
for (final short y : blocks.keySet()) {
setBlockAbs(x, (short) (this.plotheight + y), z, blocks.get(y));
}
}
if (this.plotworld.G_SCH_STATE != null) {
HashSet<PlotItem> states = this.plotworld.G_SCH_STATE.get(loc);
if (states != null) {
for (PlotItem items : states) {
BlockManager.manager.addItems(this.plotworld.worldname, items);
}
}
}
}
}
}
}
return;
}
for (short x = 0; x < 16; x++) {
for (short z = 0; z < 16; z++) {
final int absX = ((sx + x) % this.size);
final int absZ = ((sz + z) % this.size);
final boolean gx = absX > this.pathWidthLower;
final boolean gz = absZ > this.pathWidthLower;
final boolean lx = absX < this.pathWidthUpper;
final boolean lz = absZ < this.pathWidthUpper;
// inside plot
if (gx && gz && lx && lz) {
for (short y = 1; y < this.plotheight; y++) {
setBlock(x, y, z, this.filling);
}
setBlock(x, (short) this.plotheight, z, this.plotfloors);
if (this.plotworld.PLOT_SCHEMATIC) {
final PlotLoc loc = new PlotLoc(absX, absZ);
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
if (blocks != null) {
for (final short y : blocks.keySet()) {
setBlockAbs(x, (short) (this.plotheight + y), z, blocks.get(y));
}
}
if (this.plotworld.G_SCH_STATE != null) {
HashSet<PlotItem> states = this.plotworld.G_SCH_STATE.get(loc);
if (states != null) {
for (PlotItem items : states) {
items.x = this.X + x;
items.z = this.Z + z;
BlockManager.manager.addItems(this.plotworld.worldname, items);
}
}
}
}
} else if (pathsize != 0) {
// wall
if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) {
for (short y = 1; y <= this.wallheight; y++) {
setBlock(x, y, z, this.wallfilling);
}
if (!this.plotworld.ROAD_SCHEMATIC_ENABLED) {
setBlock(x, this.wallheight + 1, z, this.wall);
}
}
// road
else {
for (short y = 1; y <= this.roadheight; y++) {
setBlock(x, y, z, this.roadblock);
}
}
if (this.plotworld.ROAD_SCHEMATIC_ENABLED) {
final PlotLoc loc = new PlotLoc(absX, absZ);
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
if (blocks != null) {
for (final short y : blocks.keySet()) {
setBlockAbs(x, (short) (this.roadheight + y), z, blocks.get(y));
}
}
}
}
}
}
}
private void setBlock(final short x, final short y, final short z, final byte[] blkids) {
if (blkids.length == 1) {
setBlock(x, y, z, blkids[0]);
} else {
final int i = random(blkids.length);
setBlock(x, y, z, blkids[i]);
}
}
}

View File

@ -1,10 +1,7 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -13,7 +10,15 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.Set;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
/**
* Created 2015-07-13 for PlotSquaredGit

View File

@ -1,8 +1,5 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.util.TaskManager;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
@ -20,6 +17,10 @@ import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.util.TaskManager;
public class ChunkListener implements Listener {
private Chunk lastChunk = null;
@ -100,7 +101,7 @@ public class ChunkListener implements Listener {
if (!chunk.isLoaded()) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PS.log("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
PS.debug("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
@ -108,7 +109,7 @@ public class ChunkListener implements Listener {
if (tiles.length == 0) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PS.log("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
PS.debug("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
@ -118,7 +119,7 @@ public class ChunkListener implements Listener {
if (i >= tiles.length) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PS.log("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
PS.debug("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
@ -142,11 +143,11 @@ public class ChunkListener implements Listener {
ent.remove();
}
}
PS.log("[PlotSquared] &a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
PS.debug("[PlotSquared] &a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
}
if (tiles.length > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) {
if (unload) {
PS.log("[PlotSquared] &c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
PS.debug("[PlotSquared] &c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
cleanChunk(chunk);
return true;
}

View File

@ -20,6 +20,16 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.listeners;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
@ -28,15 +38,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.util.bukkit.BukkitPlayerFunctions;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* @author Citymonstret

View File

@ -1,36 +1,110 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.plotsquared.bukkit.listeners.worldedit.WEManager;
import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import org.bukkit.*;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_ANIMAL_INTERACT;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_DISABLE_PHYSICS;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_HANGING_BREAK;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_HANGING_PLACE;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_HOSTILE_INTERACT;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_PLACE;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_PVP;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_TAMED_INTERACT;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_USE;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_VEHICLE_USE;
import static com.intellectualcrafters.plot.object.StaticStrings.META_INVENTORY;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_ROAD;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_DESTROY_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_DESTROY_ROAD;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_DESTROY_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_ENTRY_DENIED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_EXIT_DENIED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_ROAD;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_COMMANDS_CHAT;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_PROJECTILE_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_PROJECTILE_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_WORLDEDIT_BYPASS;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.*;
import org.bukkit.entity.Animals;
import org.bukkit.entity.ArmorStand;
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.FallingBlock;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.minecart.RideableMinecart;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
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.ProjectileHitEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result;
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.VehicleDestroyEvent;
import org.bukkit.event.world.ChunkLoadEvent;
@ -41,10 +115,35 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.regex.Pattern;
import static com.intellectualcrafters.plot.object.StaticStrings.*;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
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.PlotBlock;
import com.intellectualcrafters.plot.object.PlotHandler;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotInventory;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.MainUtil;
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.listeners.worldedit.WEManager;
import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
/**
* Player Events involving plots
@ -53,7 +152,7 @@ import static com.intellectualcrafters.plot.object.StaticStrings.*;
* @author Empire92
*/
@SuppressWarnings({"unused","deprecation","unchecked"})
public class PlayerEvents extends com.plotsquared.bukkit.listeners.PlotListener implements Listener {
public class PlayerEvents extends com.plotsquared.listener.PlotListener implements Listener {
private boolean pistonBlocks = true;
@ -1492,7 +1591,7 @@ public class PlayerEvents extends com.plotsquared.bukkit.listeners.PlotListener
final Collection<Plot> plots = PS.get().getPlots(pp.getName()).values();
for (final Plot plot : plots) {
plot.delete();
PS.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
}
}
BukkitUtil.removePlayer(pp.getName());

View File

@ -1,13 +1,9 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.ArmorStand;
@ -24,9 +20,15 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import com.plotsquared.listener.PlotListener;
public class PlayerEvents_1_8 extends PlotListener implements Listener {

View File

@ -1,18 +1,19 @@
package com.plotsquared.bukkit.listeners;
import java.util.Iterator;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent;
import java.util.Iterator;
public class PlayerEvents_1_8_3 implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -20,18 +20,13 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotHandler;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -48,8 +43,19 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.*;
import java.util.Map.Entry;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotHandler;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import com.plotsquared.listener.PlotListener;
/**
* Created 2014-10-30 for PlotSquared

View File

@ -1,11 +1,7 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import java.util.List;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -16,7 +12,12 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.util.Vector;
import java.util.List;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
public class TNTListener implements Listener {
private double lastRadius;

View File

@ -1,17 +1,16 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.PS;
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
public class WorldEvents implements Listener {
public static String lastWorld = null;

View File

@ -1,5 +1,8 @@
package com.plotsquared.bukkit.listeners.worldedit;
import java.util.ArrayList;
import java.util.List;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
@ -12,9 +15,6 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.util.ArrayList;
import java.util.List;
public class NullExtent implements Extent {
@Override

View File

@ -1,5 +1,7 @@
package com.plotsquared.bukkit.listeners.worldedit;
import java.util.HashSet;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.RegionWrapper;
@ -14,8 +16,6 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.util.HashSet;
public class ProcessedWEExtent extends AbstractDelegateExtent {
private final HashSet<RegionWrapper> mask;
int BScount = 0;
@ -72,7 +72,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
BScount++;
if (BScount > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) {
BSblocked = true;
PS.log("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ()));
PS.debug("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ()));
}
}
}
@ -90,7 +90,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
Ecount++;
if (Ecount > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
Eblocked = true;
PS.log("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ()));
PS.debug("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ()));
}
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
return super.createEntity(location, entity);

View File

@ -1,5 +1,7 @@
package com.plotsquared.bukkit.listeners.worldedit;
import java.util.HashSet;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
@ -12,8 +14,6 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.util.HashSet;
public class WEExtent extends AbstractDelegateExtent {
private final HashSet<RegionWrapper> mask;

View File

@ -1,5 +1,16 @@
package com.plotsquared.bukkit.listeners.worldedit;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@ -11,16 +22,6 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.bukkit.selections.Selection;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
public class WEListener implements Listener {

View File

@ -1,5 +1,8 @@
package com.plotsquared.bukkit.listeners.worldedit;
import java.util.HashSet;
import java.util.UUID;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location;
@ -8,9 +11,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.MainUtil;
import java.util.HashSet;
import java.util.UUID;
public class WEManager {
public static HashSet<String> bypass = new HashSet<>();

View File

@ -1,5 +1,7 @@
package com.plotsquared.bukkit.listeners.worldedit;
import java.util.HashSet;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@ -13,8 +15,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe;
import java.util.HashSet;
public class WESubscriber {
@Subscribe(priority=Priority.VERY_EARLY)
public void onEditSession(EditSessionEvent event) {

View File

@ -1,8 +1,9 @@
package com.plotsquared.bukkit.object;
import org.bukkit.block.Block;
import com.intellectualcrafters.plot.object.LazyBlock;
import com.intellectualcrafters.plot.object.PlotBlock;
import org.bukkit.block.Block;
public class BukkitLazyBlock extends LazyBlock {

View File

@ -1,9 +1,10 @@
package com.plotsquared.bukkit.object;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
import java.util.UUID;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
public class BukkitOfflinePlayer implements OfflinePlotPlayer {

View File

@ -1,5 +1,18 @@
package com.plotsquared.bukkit.object;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.WeatherType;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@ -7,16 +20,10 @@ import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
public class BukkitPlayer implements PlotPlayer {
@ -199,4 +206,69 @@ public class BukkitPlayer implements PlotPlayer {
public RequiredType getSuperCaller() {
return RequiredType.PLAYER;
}
@Override
public void setWeather(PlotWeather weather) {
switch (weather) {
case CLEAR:
player.setPlayerWeather(WeatherType.CLEAR);
return;
case RAIN: {
player.setPlayerWeather(WeatherType.DOWNFALL);
return;
}
case RESET:
player.resetPlayerWeather();
return;
}
}
@Override
public PlotGamemode getGamemode() {
switch (player.getGameMode()) {
case ADVENTURE:
return PlotGamemode.ADVENTURE;
case CREATIVE:
return PlotGamemode.CREATIVE;
case SPECTATOR:
return PlotGamemode.SPECTATOR;
case SURVIVAL:
return PlotGamemode.SURVIVAL;
}
return null;
}
@Override
public void setGamemode(PlotGamemode gamemode) {
switch (gamemode) {
case ADVENTURE:
player.setGameMode(GameMode.ADVENTURE);
case CREATIVE:
player.setGameMode(GameMode.CREATIVE);
case SPECTATOR:
player.setGameMode(GameMode.SPECTATOR);
case SURVIVAL:
player.setGameMode(GameMode.SURVIVAL);
}
}
@Override
public void setTime(long time) {
player.setPlayerTime(time, false);
}
@Override
public void setFlight(boolean fly) {
player.setAllowFlight(fly);
}
@Override
public void playMusic(Location loc, int id) {
player.playEffect(BukkitUtil.getLocation(loc), Effect.RECORD_PLAY, Material.getMaterial(id));
}
@Override
public void kick(String message) {
player.kickPlayer(message);
}
}

View File

@ -1,23 +1,19 @@
package com.plotsquared.bukkit.object;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SetBlockQueue;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import com.plotsquared.bukkit.util.bukkit.SetBlockFast;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Random;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PseudoRandom;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.SetBlockQueue;
public abstract class BukkitPlotPopulator extends BlockPopulator {

View File

@ -1,23 +1,41 @@
package com.plotsquared.bukkit.object.entity;
import org.bukkit.Art;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Rotation;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Item;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Rabbit.Type;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.entity.AgeableStats;
import com.intellectualcrafters.plot.object.entity.ArmorStandStats;
import com.intellectualcrafters.plot.object.entity.EntityBaseStats;
import com.intellectualcrafters.plot.object.entity.HorseStats;
import org.bukkit.*;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.*;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Rabbit.Type;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
public class EntityWrapper {
public short id;
@ -198,7 +216,7 @@ public class EntityWrapper {
return;
}
default: {
PS.log("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
PS.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
return;
}
// MISC //
@ -455,7 +473,7 @@ public class EntityWrapper {
return entity;
}
default: {
PS.log("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
PS.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
return entity;
}
// MISC //

View File

@ -1,10 +1,10 @@
package com.plotsquared.bukkit.object.entity;
import java.util.Collection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import java.util.Collection;
public class LivingEntityStats {
public boolean loot;
public String name;

View File

@ -1,21 +1,26 @@
package com.plotsquared.bukkit.object.schematic;
import com.intellectualcrafters.jnbt.*;
import com.intellectualcrafters.plot.object.schematic.ItemType;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import com.intellectualcrafters.jnbt.ByteTag;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.jnbt.ListTag;
import com.intellectualcrafters.jnbt.ShortTag;
import com.intellectualcrafters.jnbt.Tag;
import com.intellectualcrafters.plot.object.schematic.ItemType;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
public class StateWrapper {
public BlockState state = null;

View File

@ -1,16 +0,0 @@
package com.plotsquared.bukkit.titles;
import com.intellectualcrafters.plot.object.PlotPlayer;
import org.bukkit.ChatColor;
public abstract class AbstractTitle {
public static AbstractTitle TITLE_CLASS;
public static void sendTitle(PlotPlayer player, String head, String sub) {
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
TITLE_CLASS.sendTitle(player, head, sub, 1, 2, 1);
}
}
public abstract void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out);
}

View File

@ -1,8 +1,8 @@
package com.plotsquared.bukkit.titles;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.ChatColor;
public class DefaultTitle extends AbstractTitle {
@Override

View File

@ -1,15 +1,15 @@
package com.plotsquared.bukkit.titles;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
/**
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
*

View File

@ -1,15 +1,15 @@
package com.plotsquared.bukkit.titles;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
/**
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
*

View File

@ -1,8 +1,8 @@
package com.plotsquared.bukkit.titles;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.ChatColor;
public class DefaultTitle_183 extends AbstractTitle {
@Override

View File

@ -3,8 +3,8 @@ package com.plotsquared.bukkit.titles;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.ChatColor;
public class HackTitle extends AbstractTitle {
@Override
@ -13,7 +13,7 @@ public class HackTitle extends AbstractTitle {
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
title.send(((BukkitPlayer) player).player);
} catch (final Throwable e) {
PS.log("&cYour server version does not support titles!");
PS.debug("&cYour server version does not support titles!");
Settings.TITLES = false;
AbstractTitle.TITLE_CLASS = null;
}

View File

@ -1,14 +1,14 @@
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.Method;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
/**
* Minecraft 1.8 Title
*

View File

@ -1,19 +1,11 @@
package com.plotsquared.bukkit.util;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.generator.AugmentedPopulator;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
@ -27,8 +19,25 @@ import org.bukkit.material.Directional;
import org.bukkit.material.MaterialData;
import org.bukkit.plugin.Plugin;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
public class BukkitHybridUtils extends HybridUtils {
@ -72,7 +81,7 @@ public class BukkitHybridUtils extends HybridUtils {
final int ctx = tx >> 4;
final int ctz = tz >> 4;
final Random r = new Random();
AugmentedPopulator.initCache();
MainUtil.initCache();
final int width = tx - bx + 1;
final int length = tz - bz + 1;
@ -102,21 +111,21 @@ public class BukkitHybridUtils extends HybridUtils {
for (int i = 0; i < result.length; i++) {
if (result[i] == null) {
for (int j = 0; j < 4096; j++) {
int x = AugmentedPopulator.x_loc[i][j] + xb;
int x = MainUtil.x_loc[i][j] + xb;
if (x < 0 || x >= width) continue;
int z = AugmentedPopulator.z_loc[i][j] + zb;
int z = MainUtil.z_loc[i][j] + zb;
if (z < 0 || z >= length) continue;
int y = AugmentedPopulator.y_loc[i][j];
int y = MainUtil.y_loc[i][j];
oldblocks[y][x][z] = 0;
}
continue;
}
for (int j = 0; j < result[i].length; j++) {
int x = AugmentedPopulator.x_loc[i][j] + xb;
int x = MainUtil.x_loc[i][j] + xb;
if (x < 0 || x >= width) continue;
int z = AugmentedPopulator.z_loc[i][j] + zb;
int z = MainUtil.z_loc[i][j] + zb;
if (z < 0 || z >= length) continue;
int y = AugmentedPopulator.y_loc[i][j];
int y = MainUtil.y_loc[i][j];
oldblocks[y][x][z] = result[i][j];
}
}
@ -206,7 +215,7 @@ public class BukkitHybridUtils extends HybridUtils {
}
};
System.gc();
AugmentedPopulator.initCache();
MainUtil.initCache();
TaskManager.index.incrementAndGet();
final Integer currentIndex = TaskManager.index.get();
final Integer task = TaskManager.runTaskRepeat(new Runnable() {
@ -412,11 +421,11 @@ public class BukkitHybridUtils extends HybridUtils {
public void run() {
count.incrementAndGet();
if (count.intValue() % 20 == 0) {
PS.log("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%");
PS.debug("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%");
}
if (regions.size() == 0 && chunks.size() == 0) {
BukkitHybridUtils.UPDATE = false;
PS.log(C.PREFIX.s() + "Finished road conversion");
PS.debug(C.PREFIX.s() + "Finished road conversion");
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
return;
} else {
@ -424,8 +433,8 @@ public class BukkitHybridUtils extends HybridUtils {
if (chunks.size() < 1024) {
if (regions.size() > 0) {
final ChunkLoc loc = regions.get(0);
PS.log("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)");
PS.log(" - Remaining: " + regions.size());
PS.debug("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)");
PS.debug(" - Remaining: " + regions.size());
chunks.addAll(getChunks(loc));
regions.remove(0);
System.gc();
@ -435,7 +444,7 @@ public class BukkitHybridUtils extends HybridUtils {
long diff = System.currentTimeMillis() + 25;
if (System.currentTimeMillis() - last > 1200 && last != 0) {
last = 0;
PS.log(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
while (chunks.size() > 0) {
ChunkLoc chunk = chunks.get(0);
chunks.remove(0);
@ -464,7 +473,7 @@ public class BukkitHybridUtils extends HybridUtils {
} catch (final Exception e) {
e.printStackTrace();
final ChunkLoc loc = regions.get(0);
PS.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)");
PS.debug("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)");
final int sx = loc.x << 5;
final int sz = loc.z << 5;
for (int x = sx; x < (sx + 32); x++) {
@ -472,8 +481,8 @@ public class BukkitHybridUtils extends HybridUtils {
ChunkManager.manager.unloadChunk(world, new ChunkLoc(x, z), true, true);
}
}
PS.log("&d - Potentially skipping 1024 chunks");
PS.log("&d - TODO: recommend chunkster if corrupt");
PS.debug("&d - Potentially skipping 1024 chunks");
PS.debug("&d - TODO: recommend chunkster if corrupt");
}
}
}

View File

@ -1,12 +1,12 @@
package com.plotsquared.bukkit.util;
import org.bukkit.Bukkit;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.Bukkit;
/**
* Reflection Utilities for minecraft
*

View File

@ -1,5 +1,9 @@
package com.plotsquared.bukkit.util;
import java.io.File;
import org.bukkit.Bukkit;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotId;
@ -8,9 +12,6 @@ import com.sk89q.worldedit.CuboidClipboard;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import org.bukkit.Bukkit;
import java.io.File;
public class WorldEditSchematic {
public void saveSchematic(String file, final String world, final PlotId id) {

View File

@ -1,8 +1,62 @@
package com.plotsquared.bukkit.util.bukkit;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.SkullType;
import org.bukkit.World;
import org.bukkit.block.Banner;
import org.bukkit.block.Beacon;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.block.Chest;
import org.bukkit.block.CommandBlock;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.Dispenser;
import org.bukkit.block.Dropper;
import org.bukkit.block.Furnace;
import org.bukkit.block.Hopper;
import org.bukkit.block.Jukebox;
import org.bukkit.block.NoteBlock;
import org.bukkit.block.Sign;
import org.bukkit.block.Skull;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotLoc;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.MainUtil;
@ -11,19 +65,6 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.generator.AugmentedPopulator;
import com.plotsquared.bukkit.object.entity.EntityWrapper;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.*;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
public class BukkitChunkManager extends ChunkManager {
@Override
@ -81,7 +122,7 @@ public class BukkitChunkManager extends ChunkManager {
public void run() {
final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
final File file = new File(directory);
PS.log("&6 - Deleting region: " + file.getName() + " (approx 1024 chunks)");
PS.debug("&6 - Deleting region: " + file.getName() + " (approx 1024 chunks)");
if (file.exists()) {
file.delete();
}
@ -100,7 +141,7 @@ public class BukkitChunkManager extends ChunkManager {
for (ChunkLoc loc : chunks) {
final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
final File file = new File(directory);
PS.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
PS.debug("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
if (file.exists()) {
file.delete();
}
@ -508,7 +549,7 @@ public class BukkitChunkManager extends ChunkManager {
try {
entity.spawn(world, x_offset, z_offset);
} catch (final Exception e) {
PS.log("Failed to restore entity " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id + " : " + EntityType.fromId(entity.id));
PS.debug("Failed to restore entity " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id + " : " + EntityType.fromId(entity.id));
e.printStackTrace();
}
}
@ -524,10 +565,10 @@ public class BukkitChunkManager extends ChunkManager {
chest.getInventory().setContents(chestContents.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate chest: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate chest: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate chest: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate chest: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : signContents.keySet()) {
@ -543,10 +584,10 @@ public class BukkitChunkManager extends ChunkManager {
}
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate sign: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate sign: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate sign: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate sign: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : dispenserContents.keySet()) {
@ -557,10 +598,10 @@ public class BukkitChunkManager extends ChunkManager {
((Dispenser) (state)).getInventory().setContents(dispenserContents.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : dropperContents.keySet()) {
@ -571,10 +612,10 @@ public class BukkitChunkManager extends ChunkManager {
((Dropper) (state)).getInventory().setContents(dropperContents.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : beaconContents.keySet()) {
@ -585,10 +626,10 @@ public class BukkitChunkManager extends ChunkManager {
((Beacon) (state)).getInventory().setContents(beaconContents.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate beacon: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate beacon: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate beacon: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate beacon: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : jukeDisc.keySet()) {
@ -599,10 +640,10 @@ public class BukkitChunkManager extends ChunkManager {
((Jukebox) (state)).setPlaying(Material.getMaterial(jukeDisc.get(loc)));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to restore jukebox: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore jukebox: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate jukebox: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate jukebox: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : skullData.keySet()) {
@ -622,10 +663,10 @@ public class BukkitChunkManager extends ChunkManager {
}
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to restore skull: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore skull: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate skull: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate skull: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : hopperContents.keySet()) {
@ -636,10 +677,10 @@ public class BukkitChunkManager extends ChunkManager {
((Hopper) (state)).getInventory().setContents(hopperContents.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate hopper: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate hopper: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate hopper: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate hopper: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : noteBlockContents.keySet()) {
@ -650,10 +691,10 @@ public class BukkitChunkManager extends ChunkManager {
((NoteBlock) (state)).setNote(noteBlockContents.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate note block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate note block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate note block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate note block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : brewTime.keySet()) {
@ -663,10 +704,10 @@ public class BukkitChunkManager extends ChunkManager {
if (state instanceof BrewingStand) {
((BrewingStand) (state)).setBrewingTime(brewTime.get(loc));
} else {
PS.log("&c[WARN] Plot clear failed to restore brewing stand cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to restore brewing stand cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : spawnerData.keySet()) {
@ -677,10 +718,10 @@ public class BukkitChunkManager extends ChunkManager {
((CreatureSpawner) (state)).setCreatureTypeId(spawnerData.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to restore spawner type: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore spawner type: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to restore spawner type: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore spawner type: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : cmdData.keySet()) {
@ -691,10 +732,10 @@ public class BukkitChunkManager extends ChunkManager {
((CommandBlock) (state)).setCommand(cmdData.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to restore command block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore command block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to restore command block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore command block: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : brewingStandContents.keySet()) {
@ -705,10 +746,10 @@ public class BukkitChunkManager extends ChunkManager {
((BrewingStand) (state)).getInventory().setContents(brewingStandContents.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate brewing stand: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate brewing stand: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : furnaceTime.keySet()) {
@ -720,10 +761,10 @@ public class BukkitChunkManager extends ChunkManager {
((Furnace) (state)).setBurnTime(time[0]);
((Furnace) (state)).setCookTime(time[1]);
} else {
PS.log("&c[WARN] Plot clear failed to restore furnace cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore furnace cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to restore furnace cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to restore furnace cooking: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : furnaceContents.keySet()) {
@ -734,10 +775,10 @@ public class BukkitChunkManager extends ChunkManager {
((Furnace) (state)).getInventory().setContents(furnaceContents.get(loc));
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate furnace: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate furnace: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate furnace: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate furnace: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
for (final BlockLoc loc : bannerBase.keySet()) {
@ -754,10 +795,10 @@ public class BukkitChunkManager extends ChunkManager {
}
state.update(true);
} else {
PS.log("&c[WARN] Plot clear failed to regenerate banner: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate banner: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
} catch (final Exception e) {
PS.log("&c[WARN] Plot clear failed to regenerate banner: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
PS.debug("&c[WARN] Plot clear failed to regenerate banner: " + loc.x + x_offset + "," + loc.y + "," + loc.z + z_offset);
}
}
}

View File

@ -1,14 +1,16 @@
package com.plotsquared.bukkit.util.bukkit;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.EconHandler;
import com.plotsquared.bukkit.object.BukkitOfflinePlayer;
import com.plotsquared.bukkit.object.BukkitPlayer;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
public class BukkitEconHandler extends EconHandler {

View File

@ -1,17 +1,35 @@
package com.plotsquared.bukkit.util.bukkit;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.EventUtil;
import com.plotsquared.bukkit.events.*;
import com.plotsquared.bukkit.object.BukkitPlayer;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import java.util.ArrayList;
import java.util.UUID;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.EventUtil;
import com.plotsquared.bukkit.events.ClusterFlagRemoveEvent;
import com.plotsquared.bukkit.events.PlayerClaimPlotEvent;
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.plotsquared.bukkit.events.PlayerPlotDeniedEvent;
import com.plotsquared.bukkit.events.PlayerPlotHelperEvent;
import com.plotsquared.bukkit.events.PlayerPlotTrustedEvent;
import com.plotsquared.bukkit.events.PlayerTeleportToPlotEvent;
import com.plotsquared.bukkit.events.PlotClearEvent;
import com.plotsquared.bukkit.events.PlotDeleteEvent;
import com.plotsquared.bukkit.events.PlotFlagAddEvent;
import com.plotsquared.bukkit.events.PlotFlagRemoveEvent;
import com.plotsquared.bukkit.events.PlotMergeEvent;
import com.plotsquared.bukkit.events.PlotUnlinkEvent;
import com.plotsquared.bukkit.object.BukkitPlayer;
public class BukkitEventUtil extends EventUtil {

View File

@ -1,10 +1,8 @@
package com.plotsquared.bukkit.util.bukkit;
import com.intellectualcrafters.plot.object.PlotInventory;
import com.intellectualcrafters.plot.object.PlotItemStack;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.InventoryUtil;
import com.plotsquared.bukkit.object.BukkitPlayer;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.InventoryType;
@ -14,8 +12,11 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import com.intellectualcrafters.plot.object.PlotInventory;
import com.intellectualcrafters.plot.object.PlotItemStack;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.InventoryUtil;
import com.plotsquared.bukkit.object.BukkitPlayer;
public class BukkitInventoryUtil extends InventoryUtil {

View File

@ -20,18 +20,19 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* Functions involving players, plots and locations.

View File

@ -1,14 +0,0 @@
package com.plotsquared.bukkit.util.bukkit;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.PlayerManager;
import com.plotsquared.bukkit.object.BukkitPlayer;
public class BukkitPlayerManager extends PlayerManager {
@Override
public void kickPlayer(PlotPlayer player, String reason) {
((BukkitPlayer) player).player.kickPlayer(reason);
}
}

View File

@ -20,24 +20,31 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit;
import com.intellectualcrafters.jnbt.*;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.object.schematic.StateWrapper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.intellectualcrafters.jnbt.ByteArrayTag;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.jnbt.IntTag;
import com.intellectualcrafters.jnbt.ListTag;
import com.intellectualcrafters.jnbt.ShortTag;
import com.intellectualcrafters.jnbt.StringTag;
import com.intellectualcrafters.jnbt.Tag;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.object.schematic.StateWrapper;
/**
* Schematic Handler

View File

@ -1,13 +1,14 @@
package com.plotsquared.bukkit.util.bukkit;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
import org.bukkit.Chunk;
import org.bukkit.World;
import java.util.ArrayList;
import java.util.Collection;
import org.bukkit.Chunk;
import org.bukkit.World;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
public abstract class BukkitSetBlockManager extends BlockUpdateUtil {
public static BukkitSetBlockManager setBlockManager = null;

View File

@ -1,5 +1,15 @@
package com.plotsquared.bukkit.util.bukkit;
import java.io.IOException;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.ConfigurationNode;
import com.intellectualcrafters.plot.generator.PlotGenerator;
@ -9,16 +19,6 @@ import com.intellectualcrafters.plot.util.SetupUtils;
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import java.io.IOException;
import java.util.Map.Entry;
public class BukkitSetupUtils extends SetupUtils {
@Override

View File

@ -1,8 +1,9 @@
package com.plotsquared.bukkit.util.bukkit;
import org.bukkit.Bukkit;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.BukkitMain;
import org.bukkit.Bukkit;
public class BukkitTaskManager extends TaskManager {
@Override

View File

@ -23,6 +23,7 @@ import org.bukkit.material.Step;
import org.bukkit.material.Tree;
import org.bukkit.material.WoodenStep;
import org.bukkit.material.Wool;
import org.spongepowered.api.world.extent.Extent;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotBlock;
@ -285,12 +286,12 @@ public class BukkitUtil extends BlockManager {
}
@Override
public int getBlockIdFromString(final String block) {
public PlotBlock getPlotBlockFromString(final String block) {
final Material material = Material.valueOf(block.toUpperCase());
if (material == null) {
return -1;
return new PlotBlock((short) -1, (byte) 0);
}
return material.getId();
return new PlotBlock((short) material.getId(), (byte) 0);
}
@Override

View File

@ -20,24 +20,36 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit;
import com.intellectualcrafters.configuration.InvalidConfigurationException;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.*;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
import com.intellectualcrafters.configuration.InvalidConfigurationException;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
public class Metrics {
/**
@ -513,7 +525,7 @@ public class Metrics {
connection.addRequestProperty("Connection", "close");
connection.setDoOutput(true);
if (this.debug) {
PS.log("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
}
// Write the data
final OutputStream os = connection.getOutputStream();

View File

@ -1,15 +1,21 @@
package com.plotsquared.bukkit.util.bukkit;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import static com.intellectualcrafters.plot.util.ReflectionUtils.callConstructor;
import static com.intellectualcrafters.plot.util.ReflectionUtils.callMethod;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getCbClass;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getNmsClass;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getUtilClass;
import static com.intellectualcrafters.plot.util.ReflectionUtils.makeConstructor;
import static com.intellectualcrafters.plot.util.ReflectionUtils.makeMethod;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.UUID;
import static com.intellectualcrafters.plot.util.ReflectionUtils.*;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class OfflinePlayerUtil {

View File

@ -1,20 +1,21 @@
package com.plotsquared.bukkit.util.bukkit;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
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)

View File

@ -20,17 +20,18 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import java.util.Collection;
import java.util.HashMap;
import org.bukkit.Chunk;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.TaskManager;
import org.bukkit.Chunk;
import java.util.Collection;
import java.util.HashMap;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
/**
* SetBlockFast class<br> Used to do fast world editing

View File

@ -20,15 +20,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util.bukkit;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.TaskManager;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import java.util.ArrayList;
import java.util.Collection;
@ -36,7 +28,16 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.TaskManager;
/**
* SetBlockFast class<br> Used to do fast world editing

View File

@ -1,11 +1,12 @@
package com.plotsquared.bukkit.util.bukkit;
import com.intellectualcrafters.plot.util.MainUtil;
import java.util.Collection;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
import java.util.Collection;
import com.intellectualcrafters.plot.util.MainUtil;
public class SetBlockSlow extends BukkitSetBlockManager {
@Override

View File

@ -1,19 +1,19 @@
package com.plotsquared.bukkit.util.bukkit;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.plotsquared.bukkit.generator.AugmentedPopulator;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.plotsquared.bukkit.generator.AugmentedPopulator;
public class SetGenCB {
public static void setGenerator(World world) throws Exception {
SetupUtils.manager.updateGenerators();

View File

@ -1,11 +1,11 @@
package com.plotsquared.bukkit.util.bukkit.chat;
import org.apache.commons.lang.Validate;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
import org.apache.commons.lang.Validate;
/**
* Represents a wrapper around an array class of an arbitrary reference type,
* which properly implements "value" hash code and equality functions.

View File

@ -1,5 +1,33 @@
package com.plotsquared.bukkit.util.bukkit.chat;
import static com.plotsquared.bukkit.util.bukkit.chat.TextualComponent.rawText;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import org.bukkit.Achievement;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.Statistic.Type;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@ -7,20 +35,6 @@ import com.google.gson.JsonParser;
import com.google.gson.stream.JsonWriter;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
import org.bukkit.*;
import org.bukkit.Statistic.Type;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.*;
import java.util.*;
import java.util.logging.Level;
import static com.plotsquared.bukkit.util.bukkit.chat.TextualComponent.rawText;
/**
* Represents a formattable message. Such messages can use elements such as colors, formatting codes, hover and click data, and other features provided by the vanilla Minecraft <a href="http://minecraft.gamepedia.com/Tellraw#Raw_JSON_Text">JSON message formatter</a>.

View File

@ -1,9 +1,9 @@
package com.plotsquared.bukkit.util.bukkit.chat;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import com.google.gson.stream.JsonWriter;
/**
* Represents an object that can be serialized to a JSON writer instance.
*/

View File

@ -1,12 +1,12 @@
package com.plotsquared.bukkit.util.bukkit.chat;
import com.google.gson.stream.JsonWriter;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.stream.JsonWriter;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
/**
* Represents a JSON string value.
* Writes by this object will not write name values nor begin/end objects in the JSON stream.

View File

@ -1,19 +1,20 @@
package com.plotsquared.bukkit.util.bukkit.chat;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.gson.stream.JsonWriter;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.gson.stream.JsonWriter;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
/**
* Internal class: Represents a component of a JSON-serializable {@link FancyMessage}.
*/

View File

@ -1,13 +1,13 @@
package com.plotsquared.bukkit.util.bukkit.chat;
import org.bukkit.Bukkit;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
/**
* A class containing static utility methods and caches which are intended as reflective conveniences.
* Unless otherwise noted, upon failure methods will return {@code null}.

View File

@ -1,15 +1,15 @@
package com.plotsquared.bukkit.util.bukkit.chat;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.gson.stream.JsonWriter;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Represents a textual component of a message part.
* This can be used to not only represent string literals in a JSON message,

View File

@ -1,5 +1,16 @@
package com.plotsquared.bukkit.util.bukkit.uuid;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.World;
import com.google.common.collect.HashBiMap;
import com.google.common.io.Files;
import com.google.common.io.InputSupplier;
@ -10,18 +21,12 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.NbtFactory;
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 org.bukkit.Bukkit;
import org.bukkit.World;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
public class FileUUIDHandler extends UUIDHandlerImplementation {
@ -50,12 +55,12 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
PS.log(C.PREFIX.s() + "&6Starting player data caching for: " + world);
PS.debug(C.PREFIX.s() + "&6Starting player data caching for: " + world);
final HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
toAdd.put(new StringWrapper("*"), DBFunc.everyone);
if (Settings.TWIN_MODE_UUID) {
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
PS.log("&aFast mode UUID caching enabled!");
PS.debug("&aFast mode UUID caching enabled!");
final File playerdataFolder = new File(container, world + File.separator + "playerdata");
String[] dat = playerdataFolder.list(new FilenameFilter() {
@Override
@ -81,7 +86,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
}
} catch (final Exception e) {
e.printStackTrace();
PS.log(C.PREFIX.s() + "Invalid playerdata: " + current);
PS.debug(C.PREFIX.s() + "Invalid playerdata: " + current);
}
}
}
@ -111,7 +116,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
final UUID uuid = UUID.fromString(s);
uuids.add(uuid);
} catch (final Exception e) {
PS.log(C.PREFIX.s() + "Invalid playerdata: " + current);
PS.debug(C.PREFIX.s() + "Invalid playerdata: " + current);
}
}
break;
@ -151,7 +156,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
ExpireManager.dates.put(uuid, last);
toAdd.put(new StringWrapper(name), uuid);
} catch (final Throwable e) {
PS.log(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
PS.debug(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
}
}
for (final String name : names) {

View File

@ -1,5 +1,20 @@
package com.plotsquared.bukkit.util.bukkit.uuid;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import com.google.common.collect.HashBiMap;
import com.intellectualcrafters.json.JSONObject;
import com.intellectualcrafters.plot.PS;
@ -14,17 +29,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
public class SQLUUIDHandler extends UUIDHandlerImplementation {
public SQLUUIDHandler(UUIDWrapper wrapper) {
@ -109,7 +113,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
return;
}
if (!Settings.OFFLINE_MODE) {
PS.log(C.PREFIX.s() + "&cWill fetch &6" + toFetch.size() + "&c from mojang!");
PS.debug(C.PREFIX.s() + "&cWill fetch &6" + toFetch.size() + "&c from mojang!");
int i = 0;
Iterator<UUID> iterator = toFetch.iterator();
while (iterator.hasNext()) {
@ -123,7 +127,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
}
currentIteration.add(_uuid);
}
PS.log(C.PREFIX.s() + "&cWill attempt to fetch &6" + currentIteration.size() + "&c uuids from: &6" + url.toString());
PS.debug(C.PREFIX.s() + "&cWill attempt to fetch &6" + currentIteration.size() + "&c uuids from: &6" + url.toString());
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url.toString()).openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
@ -161,7 +165,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
@Override
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
PS.log(C.PREFIX.s() + "UUID for '" + name + "' was null. We'll cache this from the mojang servers!");
PS.debug(C.PREFIX.s() + "UUID for '" + name + "' was null. We'll cache this from the mojang servers!");
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
@ -209,7 +213,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
statement.setString(1, uuid.toString());
statement.setString(2, name.toString());
statement.execute();
PS.log(C.PREFIX.s() + "&cAdded '&6" + uuid + "&c' - '&6" + name + "&c'");
PS.debug(C.PREFIX.s() + "&cAdded '&6" + uuid + "&c' - '&6" + name + "&c'");
} catch (SQLException e) {
e.printStackTrace();
}
@ -227,7 +231,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
*/
@Deprecated
public String getName__unused__(final UUID uuid) {
PS.log(C.PREFIX.s() + "Name for '" + uuid + "' was null. We'll cache this from the mojang servers!");
PS.debug(C.PREFIX.s() + "Name for '" + uuid + "' was null. We'll cache this from the mojang servers!");
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
@ -264,7 +268,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
statement.setString(1, name.value);
statement.setString(2, uuid.toString());
statement.execute();
PS.log(C.PREFIX.s() + "Name change for '" + uuid + "' to '" + name.value + "'");
PS.debug(C.PREFIX.s() + "Name change for '" + uuid + "' to '" + name.value + "'");
} catch (SQLException e) {
e.printStackTrace();
}

View File

@ -1,14 +1,15 @@
package com.plotsquared.bukkit.uuid;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.object.BukkitOfflinePlayer;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import java.util.UUID;
public class DefaultUUIDWrapper extends UUIDWrapper {
@Override

View File

@ -1,5 +1,14 @@
package com.plotsquared.bukkit.uuid;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.PS;
@ -8,14 +17,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.object.BukkitOfflinePlayer;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.UUID;
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
private Method getOnline = null;
@ -82,7 +83,7 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
return p.toArray(new Player[0]);
}
} catch (final Exception e) {
PS.log("Failed to resolve online players");
PS.debug("Failed to resolve online players");
this.getOnline = null;
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
}

View File

@ -1,5 +1,14 @@
package com.plotsquared.bukkit.uuid;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.PS;
@ -9,14 +18,6 @@ import com.intellectualcrafters.plot.object.StringWrapper;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.object.BukkitOfflinePlayer;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.UUID;
public class OfflineUUIDWrapper extends UUIDWrapper {
private Method getOnline = null;
@ -83,7 +84,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
return p.toArray(new Player[0]);
}
} catch (final Exception e) {
PS.log("Failed to resolve online players");
PS.debug("Failed to resolve online players");
this.getOnline = null;
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
}

View File

@ -1,14 +1,14 @@
package com.plotsquared.general.commands;
import com.intellectualcrafters.plot.commands.CommandCategory;
import com.intellectualcrafters.plot.commands.RequiredType;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.intellectualcrafters.plot.commands.CommandCategory;
import com.intellectualcrafters.plot.commands.RequiredType;
public abstract class Command<E extends CommandCaller> extends CommandManager {
private RequiredType requiredType = RequiredType.NONE;
@ -121,6 +121,9 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
}
final public String getPermission() {
if (this.permission == null || this.permission.length() == 0) {
this.permission = "plots." + command.toLowerCase();
}
return this.permission;
}

View File

@ -1,13 +1,13 @@
package com.plotsquared.general.commands;
import com.intellectualcrafters.plot.commands.CommandCategory;
import com.intellectualcrafters.plot.commands.RequiredType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.intellectualcrafters.plot.commands.CommandCategory;
import com.intellectualcrafters.plot.commands.RequiredType;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandDeclaration {

View File

@ -1,13 +1,13 @@
package com.plotsquared.general.commands;
import com.intellectualcrafters.plot.config.C;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import com.intellectualcrafters.plot.config.C;
@SuppressWarnings("unused")
public class CommandManager<T extends CommandCaller> {

View File

@ -1,13 +0,0 @@
package com.plotsquared.listener;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
public abstract class APlotListener {
public static APlotListener manager;
public abstract boolean plotEntry(final PlotPlayer player, final Plot plot);
public abstract boolean plotExit(final PlotPlayer player, final Plot plot);
}

View File

@ -18,83 +18,38 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.listeners;
package com.plotsquared.listener;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.*;
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.titles.AbstractTitle;
import com.plotsquared.listener.APlotListener;
import org.bukkit.*;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.CommentManager;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
/**
* @author Citymonstret
* @author Empire92
*/
public class PlotListener extends APlotListener {
public class PlotListener {
// FIXME if we add a few more functions to PlotPlayer, we could make this generic and not implementation specific
// TODO Alternatively we could move functions into BukkitPlayerManager which seems to be heavily lacking
public void textures(final Player p) {
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && PS.get().isPlotWorld(p.getWorld().getName())) {
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
}
}
private String getName(final UUID id) {
if (id == null) {
return "none";
}
final String name = UUIDHandler.getName(id);
if (name == null) {
return "unknown";
}
return name;
}
private void setWeather(Player player, String str) {
switch (str.toLowerCase()) {
case "clear": {
player.setPlayerWeather(WeatherType.CLEAR);
return;
}
case "rain": {
player.setPlayerWeather(WeatherType.DOWNFALL);
return;
}
}
}
private GameMode getGameMode(final String str) {
switch (str) {
case "creative":
return GameMode.CREATIVE;
case "survival":
return GameMode.SURVIVAL;
case "adventure":
return GameMode.ADVENTURE;
default:
return Bukkit.getDefaultGameMode();
}
}
public boolean plotEntry(final PlotPlayer pp, final Plot plot) {
public static boolean plotEntry(final PlotPlayer pp, final Plot plot) {
if (plot.isDenied(pp.getUUID()) && !Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
return false;
}
@ -103,9 +58,7 @@ public class PlotListener extends APlotListener {
plotExit(pp, last);
}
pp.setMeta("lastplot", plot);
final Player player = ((BukkitPlayer) pp).player;
final PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(callEvent);
EventUtil.manager.callEntry(pp, plot);
if (plot.hasOwner()) {
HashMap<String, Flag> flags = FlagManager.getPlotFlags(plot);
int size = flags.size();
@ -127,9 +80,9 @@ public class PlotListener extends APlotListener {
final Flag gamemodeFlag = flags.get("gamemode");
if (gamemodeFlag != null) {
if (player.getGameMode() != getGameMode(gamemodeFlag.getValueString())) {
if (!player.hasPermission("plots.gamemode.bypass")) {
player.setGameMode(getGameMode(gamemodeFlag.getValueString()));
if (pp.getGamemode() != gamemodeFlag.getValue()) {
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
pp.setGamemode((PlotGamemode) gamemodeFlag.getValue());
}
else {
MainUtil.sendMessage(pp, StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.id, "{gamemode}", gamemodeFlag.getValue()));
@ -138,30 +91,30 @@ public class PlotListener extends APlotListener {
}
final Flag flyFlag = flags.get("fly");
if (flyFlag != null) {
player.setAllowFlight((boolean) flyFlag.getValue());
pp.setFlight((boolean) flyFlag.getValue());
}
final Flag timeFlag = flags.get("time");
if (timeFlag != null) {
try {
final long time = (long) timeFlag.getValue();
player.setPlayerTime(time, false);
pp.setTime(time);
} catch (final Exception e) {
FlagManager.removePlotFlag(plot, "time");
}
}
final Flag weatherFlag = flags.get("weather");
if (weatherFlag != null) {
setWeather(player, weatherFlag.getValueString());
pp.setWeather((PlotWeather) weatherFlag.getValue());
}
Flag musicFlag = flags.get("music");
if (musicFlag != null) {
final Integer id = (Integer) musicFlag.getValue();
if ((id >= 2256 && id <= 2267) || id == 0) {
final org.bukkit.Location loc = player.getLocation();
org.bukkit.Location lastLoc = (org.bukkit.Location) pp.getMeta("music");
Location loc = pp.getLocation();
Location lastLoc = (Location) pp.getMeta("music");
if (lastLoc != null) {
player.playEffect(lastLoc, Effect.RECORD_PLAY, 0);
pp.playMusic(lastLoc, 0);
if (id == 0) {
pp.deleteMeta("music");
}
@ -169,17 +122,17 @@ public class PlotListener extends APlotListener {
if (id != 0) {
try {
pp.setMeta("music", loc);
player.playEffect(loc, Effect.RECORD_PLAY, Material.getMaterial(id));
pp.playMusic(loc, id);
}
catch (Exception e) {}
}
}
}
else {
org.bukkit.Location lastLoc = (org.bukkit.Location) pp.getMeta("music");
Location lastLoc = (Location) pp.getMeta("music");
if (lastLoc != null) {
pp.deleteMeta("music");
player.playEffect(lastLoc, Effect.RECORD_PLAY, 0);
pp.playMusic(lastLoc, 0);
}
}
CommentManager.sendTitle(pp, plot);
@ -203,7 +156,7 @@ public class PlotListener extends APlotListener {
replacements.put("%world%", plot.world);
replacements.put("%greeting%", greeting);
replacements.put("%alias", plot.toString());
replacements.put("%s", getName(plot.owner));
replacements.put("%s", MainUtil.getName(plot.owner));
String main = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT.s(), replacements);
String sub = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT_SUB.s(), replacements);
AbstractTitle.sendTitle(pp, main, sub);
@ -217,35 +170,40 @@ public class PlotListener extends APlotListener {
return true;
}
public boolean plotExit(final PlotPlayer pp, final Plot plot) {
public static boolean plotExit(final PlotPlayer pp, final Plot plot) {
pp.deleteMeta("lastplot");
Player player = ((BukkitPlayer) pp).player;
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(callEvent);
EventUtil.manager.callLeave(pp, plot);
if (plot.hasOwner()) {
if (FlagManager.getPlotFlag(plot, "fly") != null) {
player.setAllowFlight(Bukkit.getAllowFlight());
PlotWorld pw = PS.get().getPlotWorld(pp.getLocation().getWorld());
if (pw == null) {
return true;
}
if (FlagManager.getPlotFlag(plot, "gamemode") != null) {
if (player.getGameMode() != Bukkit.getDefaultGameMode()) {
if (!player.hasPermission("plots.gamemode.bypass")) {
player.setGameMode(Bukkit.getDefaultGameMode());
if (pp.getGamemode() != pw.GAMEMODE) {
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
pp.setGamemode(pw.GAMEMODE);
}
else {
MainUtil.sendMessage(pp, StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.world, "{gamemode}", Bukkit.getDefaultGameMode().name().toLowerCase()));
MainUtil.sendMessage(pp, StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.world, "{gamemode}", pw.GAMEMODE.name().toLowerCase()));
}
}
}
if (FlagManager.getPlotFlag(plot, "fly") != null) {
PlotGamemode gamemode = pp.getGamemode();
if (gamemode == PlotGamemode.SURVIVAL || gamemode == PlotGamemode.ADVENTURE) {
pp.setFlight(false);
}
}
if (FlagManager.getPlotFlag(plot, "time") != null) {
player.resetPlayerTime();
pp.setTime(Long.MAX_VALUE);
}
if (FlagManager.getPlotFlag(plot, "weather") != null) {
player.resetPlayerWeather();
pp.setWeather(PlotWeather.RESET);
}
org.bukkit.Location lastLoc = (org.bukkit.Location) pp.getMeta("music");
Location lastLoc = (Location) pp.getMeta("music");
if (lastLoc != null) {
pp.deleteMeta("music");
player.playEffect(lastLoc, Effect.RECORD_PLAY, 0);
pp.playMusic(lastLoc, 0);
}
}
return true;

View File

@ -1,158 +0,0 @@
package com.plotsquared.sponge;
import com.flowpowered.math.vector.Vector3i;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.extent.ImmutableBiomeArea;
import org.spongepowered.api.world.extent.MutableBlockVolume;
import org.spongepowered.api.world.gen.GeneratorPopulator;
public class PlotGen implements GeneratorPopulator {
public String worldname;
public long seed;
public final int PLOT_HEIGHT = 64; // Plot height of 64
public final int PLOT_WIDTH = 42; // Plot width of 42
public final int ROAD_WIDTH = 7; // Road width of 7
public final BlockState ROAD_BLOCK = BlockTypes.QUARTZ_BLOCK.getDefaultState(); // Quartz
public final BlockState MAIN_BLOCK = BlockTypes.STONE.getDefaultState(); // Stone
public final BlockState WALL_BLOCK = BlockTypes.BEDROCK.getDefaultState(); // Bedrock
public final BlockState BORDER_BLOCK = BlockTypes.STONE_SLAB.getDefaultState(); // Stone slab
public final BlockState[] FLOOR_BLOCK = new BlockState[] {BlockTypes.GRASS.getDefaultState(), BlockTypes.SPONGE.getDefaultState()}; // Grass and sponge
public final int total_width;
public final int road_width_lower;
public final int road_width_upper;
/**
* I'm using my PseudoRandom class as it's more efficient and we don't need secure randomness
*/
public final PseudoRandom RANDOM = new PseudoRandom();
private SpongeMain main;
public PlotGen(SpongeMain main, String worldname, long seed) {
this.main = main;
this.worldname = worldname;
this.seed = seed;
total_width = PLOT_WIDTH + ROAD_WIDTH;
// Calculating the bottom and top road portions (this is for a PlotSquared compatible generator, but you can have any offset you want)
if ((ROAD_WIDTH % 2) == 0) {
road_width_lower = ROAD_WIDTH / 2 - 1;
} else {
road_width_lower = ROAD_WIDTH / 2;
}
road_width_upper = road_width_lower + PLOT_WIDTH + 1;
main.log("LOADED GEN FOR: " + worldname);
}
/**
* This simple pairing function is used for the seed for each chunk,
* - This is useful if you want generation to appear random, but be the same each time
* - You could also use a simple hash function like `return x + y * 31` - but this looks fancier
* @param x
* @param y
* @return
*/
public int pair(int x, int y) {
long hash;
if (x >= 0) {
if (y >= 0) {
hash = (x * x) + (3 * x) + (2 * x * y) + y + (y * y) + 2;
} else {
final int y1 = -y;
hash = (x * x) + (3 * x) + (2 * x * y1) + y1 + (y1 * y1) + 1;
}
} else {
final int x1 = -x;
if (y >= 0) {
hash = -((x1 * x1) + (3 * x1) + (2 * x1 * y) + y + (y * y));
} else {
final int y1 = -y;
hash = -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1);
}
}
return (int) (hash % Integer.MAX_VALUE);
}
@Override
public void populate(World world, MutableBlockVolume buffer, ImmutableBiomeArea biomeBase) {
try {
Vector3i min = buffer.getBlockMin();
int X = min.getX();
int Z = min.getZ();
int cx = X >> 4;
int cz = Z >> 4;
main.log("POPULATING " + worldname + " | " + cx + "," + cz);
// If you have any random elements to your generation, you will want to set the state of the random class
RANDOM.state = pair(cx, cz);
// TODO set bedrock
// We want all plots to be the same
// To do this we will need to reduce the coordinates to the same base location
// To get the world coord from a chunk coord we multiply by 16 `cx << 4`
// Then we find the remainder of that `(cx << 4) % total_width`
// We don't want negative numbers though so add the `total_width` if the remainder is less than 0
// We have to do this as the plot size will not necessarily have to be a multiple of 16, and so it won't always align to the chunk
// If the total width is a multiple of 16, you can in fact make some neat optimizations, see PlotSquaredMG source for more info
int bx = (cx << 4) % total_width + (cx < 0 ? total_width : 0);
int bz = (cz << 4) % total_width + (cz < 0 ? total_width : 0);
// This is our main loop where we go over all the columns in the chunk and set the blocks
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
// Getting the reduced coordinate
int xx = (x + bx);
int zz = (z + bz);
// If it's greater than the total width, we need to reduce it
// Although we reduced the chunk coordinates before, that only means the base coordinate of the chunk is reduced
// The top coordinate could still be outside our desired range
if (xx >= total_width) xx -= total_width;
if (zz >= total_width) zz -= total_width;
// ROAD
if (xx < road_width_lower || zz < road_width_lower || xx > road_width_upper || zz > road_width_upper) {
for (int y = 0; y < PLOT_HEIGHT; y++) setBlock(buffer, X + x, y, Z + z, ROAD_BLOCK);
}
// WALL
else if (xx == road_width_lower || zz == road_width_lower || xx == road_width_upper || zz == road_width_upper) {
// Set the wall block
for (int y = 0; y < PLOT_HEIGHT; y++) setBlock(buffer, X + x, y, Z + z, WALL_BLOCK);
// Set the border block (on top of the wall)
setBlock(buffer, X + x, PLOT_HEIGHT, Z + z, BORDER_BLOCK);
}
// PLOT
else {
// Set the main plot block
for (int y = 0; y < PLOT_HEIGHT - 1; y++) setBlock(buffer, X + x, y, Z + z, MAIN_BLOCK);
// Set the plot floor
setBlock(buffer, X + x, PLOT_HEIGHT - 1, Z + z, FLOOR_BLOCK);
}
}
}
main.log("SUCCESS " + worldname + " | " + cx + "," + cz);
}
catch (Exception e) {
// Normally if something goes wrong in your code it will fail silently with world generators
// Having this try/catch will help recover the exception
e.printStackTrace();
}
}
public void setBlock(MutableBlockVolume buffer, int x, int y, int z, BlockState...states) {
if (states.length == 1) {
setBlock(buffer, x, y, z, states[0]);
}
setBlock(buffer, x, y, z, states[RANDOM.random(states.length)]);
}
public void setBlock(MutableBlockVolume buffer, int x, int y, int z, BlockState state) {
buffer.setBlock(x, y, z, state);
}
}

View File

@ -1,26 +0,0 @@
package com.plotsquared.sponge;
public class PseudoRandom {
public long state = 1;
public long nextLong() {
final long a = state;
state = xorShift64(a);
return a;
}
public long xorShift64(long a) {
a ^= (a << 21);
a ^= (a >>> 35);
a ^= (a << 4);
return a;
}
public int random(final int n) {
if (n == 1) {
return 0;
}
final long r = ((nextLong() >>> 32) * n) >> 32;
return (int) r;
}
}

View File

@ -0,0 +1,128 @@
package com.plotsquared.sponge;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.spongepowered.api.data.DataContainer;
import org.spongepowered.api.world.Chunk;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.storage.ChunkDataStream;
import org.spongepowered.api.world.storage.WorldStorage;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
import com.plotsquared.sponge.util.SpongeUtil;
public class SpongeChunkManager extends ChunkManager {
@Override
public void setChunk(ChunkWrapper loc, PlotBlock[][] result) {
// TODO Auto-generated method stub
}
@Override
public int[] countEntities(Plot plot) {
// TODO Auto-generated method stub
return new int[5];
}
@Override
public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
World worldObj = SpongeUtil.getWorld(world);
return worldObj.loadChunk(loc.x << 4, 0, loc.z << 4, force).isPresent();
}
@Override
public boolean unloadChunk(String world, ChunkLoc loc, boolean save, boolean safe) {
World worldObj = SpongeUtil.getWorld(world);
Optional<Chunk> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
if (chunk.isPresent()) {
return worldObj.unloadChunk(chunk.get());
}
return false;
}
@Override
public List<ChunkLoc> getChunkChunks(String world) {
ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
World worldObj = SpongeUtil.getWorld(world);
ChunkDataStream storage = worldObj.getWorldStorage().getGeneratedChunks();
while (storage.hasNext()) {
DataContainer data = storage.next();
// TODO get chunk from DataContainer
}
return chunks;
}
@Override
public void regenerateChunk(String world, ChunkLoc loc) {
World worldObj = SpongeUtil.getWorld(world);
Optional<Chunk> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
if (chunk.isPresent()) {
// TODO regenerate chunk
}
}
@Override
public void deleteRegionFile(String world, ChunkLoc loc) {
// TODO Auto-generated method stub
}
@Override
public void deleteRegionFiles(String world, List<ChunkLoc> chunks) {
// TODO Auto-generated method stub
}
@Override
public Plot hasPlot(String world, ChunkLoc chunk) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean copyRegion(Location pos1, Location pos2, Location newPos, Runnable whenDone) {
// TODO Auto-generated method stub
TaskManager.runTask(whenDone);
return false;
}
@Override
public boolean regenerateRegion(Location pos1, Location pos2, Runnable whenDone) {
// TODO Auto-generated method stub
TaskManager.runTask(whenDone);
return false;
}
@Override
public void clearAllEntities(Plot plot) {
// TODO Auto-generated method stub
}
@Override
public void swap(String world, PlotId id, PlotId plotid) {
// TODO Auto-generated method stub
}
@Override
public void swap(String worldname, Location bot1, Location top1, Location bot2, Location top2) {
// TODO Auto-generated method stub
}
}

View File

@ -1,65 +0,0 @@
package com.plotsquared.sponge;
import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.SetupObject;
import org.spongepowered.api.world.gen.WorldGenerator;
public class SpongeGeneratorWrapper extends PlotGenerator<WorldGenerator>{
public SpongeGeneratorWrapper(String world, WorldGenerator generator) {
super(world, generator);
// TODO Auto-generated constructor stub
}
@Override
public void initialize(PlotWorld plotworld) {
// TODO Auto-generated method stub
}
@Override
public void augment(PlotCluster cluster, PlotWorld plotworld) {
// TODO Auto-generated method stub
}
@Override
public void setGenerator(String generator) {
// TODO Auto-generated method stub
}
@Override
public PlotWorld getNewPlotWorld(String world) {
// TODO Auto-generated method stub
return null;
}
@Override
public PlotManager getPlotManager() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isFull() {
// TODO Auto-generated method stub
return false;
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
@Override
public void processSetup(SetupObject object) {
// TODO Auto-generated method stub
}
}

View File

@ -1,24 +1,29 @@
package com.plotsquared.sponge;
import com.google.inject.Inject;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.IPlotMain;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.listener.APlotListener;
import java.io.File;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.spongepowered.api.CatalogType;
import org.spongepowered.api.Game;
import org.spongepowered.api.GameRegistry;
import org.spongepowered.api.MinecraftVersion;
import org.spongepowered.api.Server;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.data.manipulator.block.StoneData;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.entity.player.gamemode.GameModes;
import org.spongepowered.api.event.EventHandler;
import org.spongepowered.api.event.Subscribe;
import org.spongepowered.api.event.entity.player.PlayerChatEvent;
import org.spongepowered.api.event.state.PreInitializationEvent;
@ -26,13 +31,56 @@ import org.spongepowered.api.event.state.ServerAboutToStartEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.service.profile.GameProfileResolver;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.text.translation.Translatable;
import org.spongepowered.api.text.translation.Translation;
import org.spongepowered.api.world.DimensionTypes;
import org.spongepowered.api.world.GeneratorTypes;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
import java.io.File;
import java.util.Collection;
import java.util.UUID;
import com.google.common.base.Optional;
import com.google.inject.Inject;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.IPlotMain;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.BlockManager;
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.SchematicHandler;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.sponge.generator.SpongeBasicGen;
import com.plotsquared.sponge.generator.SpongeGeneratorWrapper;
import com.plotsquared.sponge.generator.WorldModify;
import com.plotsquared.sponge.listener.MainListener;
import com.plotsquared.sponge.util.KillRoadMobs;
import com.plotsquared.sponge.util.SpongeBlockManager;
import com.plotsquared.sponge.util.SpongeCommand;
import com.plotsquared.sponge.util.SpongeEventUtil;
import com.plotsquared.sponge.util.SpongeInventoryUtil;
import com.plotsquared.sponge.util.SpongeMetrics;
import com.plotsquared.sponge.util.SpongeTaskManager;
import com.plotsquared.sponge.util.SpongeUtil;
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
/**
* Created by robin on 01/11/2014
@ -70,7 +118,68 @@ public class SpongeMain implements IPlotMain, PluginContainer {
}
public Object getPlugin() {
return this.plugin;
return plugin;
}
public Text getText(String m) {
return Texts.of(m);
}
public Translatable getTranslation(final String m) {
return new Translatable() {
@Override
public Translation getTranslation() {
return new Translation() {
@Override
public String getId() {
return m;
}
@Override
public String get(Locale l, Object... args) {
return m;
}
@Override
public String get(Locale l) {
return m;
}
};
}
};
}
private PlotBlock NULL_BLOCK = new PlotBlock((short) 0, (byte) 0);
private BlockState[][] blockMap;
private Map<BlockState, PlotBlock> blockMapReverse;
public BlockState getBlockState(PlotBlock block) {
if (blockMap[block.id] == null) {
log("UNKNOWN BLOCK: " + block.toString());
return null;
}
else if (blockMap[block.id].length <= block.data) {
log("UNKNOWN BLOCK: " + block.toString() + " -> Using " + block.id + ":0 instead");
return blockMap[block.id][0];
}
return blockMap[block.id][block.data];
}
public BlockState getBlockState(int id) {
return blockMap[id][0];
}
public Collection<BlockState> getAllStates() {
return this.blockMapReverse.keySet();
}
public PlotBlock getPlotBlock(BlockState state) {
PlotBlock val = blockMapReverse.get(state);
if (val == null) {
return NULL_BLOCK;
}
return val;
}
/////////
@ -114,43 +223,159 @@ public class SpongeMain implements IPlotMain, PluginContainer {
log("INIT");
THIS = this;
// resolver
//
resolver = game.getServiceManager().provide(GameProfileResolver.class).get();
plugin = game.getPluginManager().getPlugin("PlotSquared").get().getInstance();
log("PLUGIN IS THIS: " + (plugin == this));
plugin = this;
server = game.getServer();
//
PS.instance = new PS(this);
// Set the generators for each world...
server = game.getServer();
Collection<World> worlds = server.getWorlds();
if (worlds.size() > 0) {
log("INJECTING WORLDS!!!!!!!");
for (World world : server.getWorlds()) {
log("INJECTING WORLD: " + world.getName());
world.setWorldGenerator(new SpongePlotGenerator(world.getName()));
}
}
// TODO Until P^2 has json chat stuff for sponge, disable this
Settings.FANCY_CHAT = false;
// done
registerBlocks();
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
if (worldSection != null) {
for (String world : worldSection.getKeys(false)) {
this.modify = new WorldModify(this);
SpongeBasicGen generator = new SpongeBasicGen(world);
PS.get().loadWorld(world, new SpongeGeneratorWrapper(world, generator));
this.modify = new WorldModify(generator);
Game game = event.getGame();
game.getRegistry().registerWorldGeneratorModifier(modify);
game.getRegistry().getWorldBuilder()
Optional<World> builder = game.getRegistry().getWorldBuilder()
.name(world)
.enabled(true)
.loadsOnStartup(true)
.keepsSpawnLoaded(true)
.dimensionType(DimensionTypes.OVERWORLD)
.generator(GeneratorTypes.DEBUG)
.generator(GeneratorTypes.FLAT)
.gameMode(GameModes.CREATIVE)
.usesMapFeatures(false)
.generatorModifiers(modify)
.build();
World worldObj = builder.get();
}
}
}
public void registerBlock(PlotBlock block, BlockState state) {
BlockState[] val = blockMap[block.id];
if (val == null) {
blockMap[block.id] = new BlockState[block.data + 1];
}
else if (val.length <= block.data) {
blockMap[block.id] = Arrays.copyOf(val, block.data + 1);
}
else if (val[block.data] != null) {
return;
}
blockMap[block.id][block.data] = state;
blockMapReverse.put(state, block);
}
public PlotBlock registerBlock(BlockState state) {
PlotBlock val = blockMapReverse.get(state);
if (val != null) {
return val;
}
byte data;
if (blockMap[0] == null) {
blockMap[0] = new BlockState[1];
data = 0;
}
else {
data = (byte) (blockMap[0].length);
}
PlotBlock block = new PlotBlock((short) 0, data);
registerBlock(block, state);
return block;
}
public void registerBlocks() {
blockMap = new BlockState[256][];
blockMapReverse = new ConcurrentHashMap<BlockState, PlotBlock>();
HashMap<String, BlockState> states = new HashMap<>();
PS.get().copyFile("ids.txt", "config");
PS.get().copyFile("data.txt", "config");
try {
File id_file = new File(getDirectory(), "config" + File.separator + "ids.txt");
List<String> id_lines = Files.readAllLines(id_file.toPath(), StandardCharsets.UTF_8);
File data_file = new File(getDirectory(), "config" + File.separator + "data.txt");
List<String> data_lines = Files.readAllLines(data_file.toPath(), StandardCharsets.UTF_8);
Field[] fields = BlockTypes.class.getDeclaredFields();
for (Field field : fields) {
BlockType type = (BlockType) field.get(null);
BlockState state = type.getDefaultState();
if (state != null) {
try {
states.put(type.getId() + ":" + 0, state);
}
catch (Exception e) {}
}
}
String packaze = "org.spongepowered.api.data.type.";
for (int i = 0; i < data_lines.size(); i++) {
String classname = packaze + data_lines.get(i).trim();
try {
Class<?> clazz = Class.forName(classname);
fields = clazz.getDeclaredFields();
for (Field field : fields) {
CatalogType type = (CatalogType) field.get(null);
String minecraft_id = type.getId();
BlockState state = states.get(minecraft_id + ":" + 0);
if (state == null) {
continue;
}
state.getManipulator(StoneData.class);
}
}
catch (Throwable e) {}
}
PlotBlock block = null;
for (int i = 0; i < id_lines.size(); i++) {
String line = id_lines.get(i).trim();
switch(i%3) {
case 0: {
block = Configuration.BLOCK.parseString(line);
break;
}
case 1: {
break;
}
case 2: {
String minecraft_id = line;
BlockState state = states.remove(minecraft_id + ":" + block.data);
if (state == null) {
continue;
}
registerBlock(block, state);
break;
}
}
}
for (Entry<String, BlockState> state : states.entrySet()) {
log("REGISTERING: " + registerBlock(state.getValue()) + " | " + state.getValue().getType());
}
}
catch (Exception e) {
e.printStackTrace();
}
}
@Subscribe
public void onPlayerChat(PlayerChatEvent event) {
// This is how events sort of work?
@ -160,8 +385,15 @@ public class SpongeMain implements IPlotMain, PluginContainer {
@Override
public void log(String message) {
message = ConsoleColors.fromString(message);
logger.info(message);
message = C.format(message, C.replacements);
if (!Settings.CONSOLE_COLOR) {
message = message.replaceAll('\u00a7' + "[a-z|0-9]", "");
}
if (server == null || server.getConsole() == null) {
logger.info(message);
return;
}
server.getConsole().sendMessage(Texts.of(message));
}
@Override
@ -191,6 +423,66 @@ public class SpongeMain implements IPlotMain, PluginContainer {
String[] split = version.split("\\.");
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
}
@Override
public InventoryUtil initInventoryUtil() {
return new SpongeInventoryUtil();
}
@Override
public SpongeGeneratorWrapper getGenerator(String world, String name) {
if (name == null) {
return new SpongeGeneratorWrapper(world, null);
}
if (name.equals("PlotSquared")) {
return new SpongeGeneratorWrapper(world, null);
}
else {
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
}
@Override
public EconHandler getEconomyHandler() {
// TODO Auto-generated method stub
// Nothing like Vault exists yet
PS.log("getEconomyHandler NOT IMPLEMENTED YET");
return null;
}
@Override
public BlockManager initBlockManager() {
return new SpongeBlockManager();
}
@Override
public EventUtil initEventUtil() {
return new SpongeEventUtil();
}
@Override
public ChunkManager initChunkManager() {
return new SpongeChunkManager();
}
@Override
public SetupUtils initSetupUtils() {
// TODO Auto-generated method stub
return null;
}
@Override
public HybridUtils initHybridUtils() {
// TODO Auto-generated method stub
return null;
}
@Override
public SchematicHandler initSchematicHandler() {
// TODO Auto-generated method stub
return null;
}
@Override
public TaskManager getTaskManager() {
@ -199,20 +491,17 @@ public class SpongeMain implements IPlotMain, PluginContainer {
@Override
public void runEntityTask() {
// TODO Auto-generated method stub
log("runEntityTask is not implemented!");
new KillRoadMobs().run();
}
@Override
public void registerCommands() {
// TODO Auto-generated method stub
log("registerCommands is not implemented!");
getGame().getCommandDispatcher().register(plugin, new SpongeCommand(), "plots", "p", "plot", "ps", "plotsquared", "p2");
}
@Override
public void registerPlayerEvents() {
// TODO Auto-generated method stub
log("registerPlayerEvents is not implemented!");
game.getEventManager().register(this, new MainListener());
}
@Override
@ -245,42 +534,6 @@ public class SpongeMain implements IPlotMain, PluginContainer {
log("registerTNTListener is not implemented!");
}
@Override
public EconHandler getEconomyHandler() {
// TODO Auto-generated method stub
return null;
}
@Override
public BlockManager initBlockManager() {
// TODO Auto-generated method stub
return null;
}
@Override
public EventUtil initEventUtil() {
// TODO Auto-generated method stub
return null;
}
@Override
public ChunkManager initChunkManager() {
// TODO Auto-generated method stub
return null;
}
@Override
public SetupUtils initSetupUtils() {
// TODO Auto-generated method stub
return null;
}
@Override
public HybridUtils initHybridUtils() {
// TODO Auto-generated method stub
return null;
}
@Override
public UUIDHandlerImplementation initUUIDHandler() {
UUIDWrapper wrapper;
@ -293,57 +546,33 @@ public class SpongeMain implements IPlotMain, PluginContainer {
return new SpongeUUIDHandler(wrapper);
}
@Override
public InventoryUtil initInventoryUtil() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean initPlotMeConverter() {
// TODO Auto-generated method stub
PS.log("initPlotMeConverter NOT IMPLEMENTED YET");
return false;
}
@Override
public void unregister(PlotPlayer player) {
// TODO Auto-generated method stub
}
@Override
public SpongeGeneratorWrapper getGenerator(String world, String name) {
// TODO Auto-generated method stub
return null;
}
@Override
public APlotListener initPlotListener() {
// TODO Auto-generated method stub
return null;
SpongeUtil.removePlayer(player.getName());
}
@Override
public void registerChunkProcessor() {
// TODO Auto-generated method stub
PS.log("registerChunkProcessor NOT IMPLEMENTED YET");
}
@Override
public void registerWorldEvents() {
// TODO Auto-generated method stub
}
@Override
public PlayerManager initPlayerManager() {
// TODO Auto-generated method stub
return null;
PS.log("registerWorldEvents NOT IMPLEMENTED YET");
}
@Override
public String getServerName() {
// TODO FIXME
// TODO FIXME
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@ -360,7 +589,11 @@ public class SpongeMain implements IPlotMain, PluginContainer {
@Override
public void setGenerator(String world) {
// TODO Auto-generated method stub
// THIS IS DONE DURING STARTUP ALREADY
}
@Override
public AbstractTitle initTitleManager() {
return new SpongeTitleManager();
}
}

View File

@ -4,13 +4,17 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.entity.player.gamemode.GameMode;
import org.spongepowered.api.entity.player.gamemode.GameModes;
import org.spongepowered.api.service.permission.PermissionService;
import org.spongepowered.api.text.Texts;
import org.spongepowered.api.text.chat.ChatTypes;
import org.spongepowered.api.text.title.Title;
import org.spongepowered.api.world.World;
import com.flowpowered.math.vector.Vector3d;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@ -18,7 +22,10 @@ import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.sponge.util.SpongeUtil;
public class SpongePlayer implements PlotPlayer {
@ -97,12 +104,13 @@ public class SpongePlayer implements PlotPlayer {
@Override
public void teleport(Location loc) {
String world = player.getWorld().getName();
if (world != loc.getWorld()) {
player.transferToWorld(world, new Vector3d(loc.getX(), loc.getY(), loc.getZ()));
if (!world.equals(loc.getWorld())) {
player.transferToWorld(loc.getWorld(), new Vector3d(loc.getX(), loc.getY(), loc.getZ()));
}
else {
org.spongepowered.api.world.Location current = player.getLocation();
player.setLocationSafely(current.setPosition(new Vector3d(loc.getX(), loc.getY(), loc.getZ())));
current = current.setPosition(new Vector3d(loc.getX(), loc.getY(), loc.getZ()));
player.setLocation(current);
}
}
@ -188,13 +196,10 @@ public class SpongePlayer implements PlotPlayer {
@Override
public boolean getAttribute(String key) {
key = "plotsquared_user_attributes." + key;
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key);
if (perm == null) {
perm = new Permission(key, PermissionDefault.FALSE);
Bukkit.getServer().getPluginManager().addPermission(perm);
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
}
return player.hasPermission(key);
// TODO register attributes
return false;
}
@Override
@ -202,4 +207,71 @@ public class SpongePlayer implements PlotPlayer {
key = "plotsquared_user_attributes." + key;
EconHandler.manager.setPermission(this, key, false);
}
@Override
public void setWeather(PlotWeather weather) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@Override
public PlotGamemode getGamemode() {
// TODO Auto-generated method stub
GameMode gamemode = player.getGameModeData().getValue();
if (gamemode == GameModes.ADVENTURE) {
return PlotGamemode.ADVENTURE;
}
if (gamemode == GameModes.CREATIVE) {
return PlotGamemode.CREATIVE;
}
if (gamemode == GameModes.SPECTATOR) {
return PlotGamemode.SPECTATOR;
}
if (gamemode == GameModes.SURVIVAL) {
return PlotGamemode.SURVIVAL;
}
throw new UnsupportedOperationException("INVALID GAMEMODE");
}
@Override
public void setGamemode(PlotGamemode gamemode) {
// TODO Auto-generated method stub
switch (gamemode) {
case ADVENTURE:
player.getGameModeData().setGameMode(GameModes.ADVENTURE);
return;
case CREATIVE:
player.getGameModeData().setGameMode(GameModes.CREATIVE);
return;
case SPECTATOR:
player.getGameModeData().setGameMode(GameModes.SPECTATOR);
return;
case SURVIVAL:
player.getGameModeData().setGameMode(GameModes.SURVIVAL);
return;
}
}
@Override
public void setTime(long time) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@Override
public void setFlight(boolean fly) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@Override
public void playMusic(Location loc, int id) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@Override
public void kick(String message) {
player.kick(SpongeMain.THIS.getText(message));
}
}

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