Claimed wall block

Fixes #28
This commit is contained in:
Sauilitired 2014-11-02 20:01:04 +01:00
parent 45d8556b87
commit 82b17aeebf
10 changed files with 35 additions and 47 deletions

View File

@ -335,9 +335,8 @@ public class Metrics {
else else
playersOnline = ((Player[])Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null, new Object[0])).length; playersOnline = ((Player[])Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null, new Object[0])).length;
} }
catch (NoSuchMethodException ex){} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex){}
catch (InvocationTargetException ex){}
catch (IllegalAccessException ex){}
// END server software specific section -- all code below does not use // END server software specific section -- all code below does not use
// any code outside of this class / Java // any code outside of this class / Java
// Construct the post data // Construct the post data

View File

@ -22,16 +22,12 @@ import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
import com.intellectualcrafters.plot.uuid.UUIDSaver; import com.intellectualcrafters.plot.uuid.UUIDSaver;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import me.confuser.barapi.BarAPI; import me.confuser.barapi.BarAPI;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -680,7 +676,7 @@ public class PlotMain extends JavaPlugin {
add("plot"); add("plot");
} }
}); });
getCommand("plots").setTabCompleter(command); //getCommand("plots").setTabCompleter(command);
getServer().getPluginManager().registerEvents(new PlayerEvents(), this); getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
PlotPlusListener.startRunnable(this); PlotPlusListener.startRunnable(this);
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this); getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);

View File

@ -88,6 +88,7 @@ public abstract class PlotWorld {
public boolean SPAWN_BREEDING; public boolean SPAWN_BREEDING;
public static boolean SPAWN_BREEDING_DEFAULT = false; public static boolean SPAWN_BREEDING_DEFAULT = false;
public PlotWorld(String worldname) { public PlotWorld(String worldname) {
this.worldname = worldname; this.worldname = worldname;
} }

View File

@ -36,8 +36,6 @@ public class RUtils {
double s = sec % 60; double s = sec % 60;
String string = C.TIME_FORMAT.s(); String string = C.TIME_FORMAT.s();
@SuppressWarnings("unused")
// String s_d = (int) d + " " + (d != 1 ? "days" : "day");
String s_h = (int) h + " " + ((int) h != 1 ? "hours" : "hour"); String s_h = (int) h + " " + ((int) h != 1 ? "hours" : "hour");
String s_m = (int) m + " " + ((int) m != 1 ? "minutes" : "minute"); String s_m = (int) m + " " + ((int) m != 1 ? "minutes" : "minute");
String s_s = (int) s + " " + ((int) s != 1 ? "seconds" : "second"); String s_s = (int) s + " " + ((int) s != 1 ? "seconds" : "second");
@ -68,7 +66,6 @@ public class RUtils {
double d = ((l.getYaw() * 4.0F) / 360.0F) + 0.5D; double d = ((l.getYaw() * 4.0F) / 360.0F) + 0.5D;
int i = (int) d; int i = (int) d;
int x = d < i ? i - 1 : i; int x = d < i ? i - 1 : i;
switch (x) { switch (x) {
case 0: case 0:
return Direction.SOUTH; return Direction.SOUTH;

View File

@ -130,6 +130,7 @@ public class Auto extends SubCommand {
while (!br) { while (!br) {
PlotId start = getNextPlot(Auto.lastPlot, 1); PlotId start = getNextPlot(Auto.lastPlot, 1);
//FIXME: Wtf is going on here?
if (claimed) { if (claimed) {
if (PlotMain.getPlots(world).get(start) == null || PlotMain.getPlots(world).get(start).owner == null) { if (PlotMain.getPlots(world).get(start) == null || PlotMain.getPlots(world).get(start).owner == null) {
Auto.lastPlot = start; Auto.lastPlot = start;
@ -181,7 +182,7 @@ public class Auto extends SubCommand {
} }
} }
else { else {
if (id.x==id.y && id.x > 0) { if (id.x.equals(id.y) && id.x > 0) {
return new PlotId(id.x, id.y + step); return new PlotId(id.x, id.y + step);
} }
if (id.x==absX) { if (id.x==absX) {

View File

@ -8,21 +8,13 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.SchematicHandler;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
/** /**
* @author Citymonstret * @author Citymonstret
*/ */
@ -118,6 +110,12 @@ public class Claim extends SubCommand {
if (world.DEFAULT_FLAGS != null && world.DEFAULT_FLAGS.size() > 0) { if (world.DEFAULT_FLAGS != null && world.DEFAULT_FLAGS.size() > 0) {
plot2.settings.setFlags(FlagManager.parseFlags(world.DEFAULT_FLAGS)); plot2.settings.setFlags(FlagManager.parseFlags(world.DEFAULT_FLAGS));
} }
if (world instanceof DefaultPlotWorld) {
DefaultPlotWorld pW = (DefaultPlotWorld) world;
if(pW.CLAIMED_WALL_BLOCK != pW.WALL_BLOCK) {
PlotMain.getPlotManager(plot.getWorld()).setWall(plot.getWorld(), world, plot.getId(), pW.CLAIMED_WALL_BLOCK);
}
}
} }
return event.isCancelled(); return event.isCancelled();
} }

View File

@ -86,6 +86,10 @@ public enum Command {
/** /**
* *
*/ */
INTERFACE("interface", "int", new CommandPermission("plots.interface")),
/**
*
*/
HOME("home", "h"), HOME("home", "h"),
/** /**
* *

View File

@ -64,8 +64,7 @@ public class MainCommand implements CommandExecutor, TabCompleter {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(C.HELP_INFO.s()); builder.append(C.HELP_INFO.s());
for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
builder.append("\n" builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
+ C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
} }
PlayerFunctions.sendMessage(player, builder.toString()); PlayerFunctions.sendMessage(player, builder.toString());
return true; return true;
@ -82,15 +81,14 @@ public class MainCommand implements CommandExecutor, TabCompleter {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(C.HELP_INFO.s()); builder.append(C.HELP_INFO.s());
for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
builder.append("\n" builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
+ C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
} }
PlayerFunctions.sendMessage(player, builder.toString()); PlayerFunctions.sendMessage(player, builder.toString());
return true; return true;
} }
StringBuilder help = new StringBuilder(); StringBuilder help = new StringBuilder();
for (String string : helpMenu(player, cato)) { for (String string : helpMenu(player, cato)) {
help.append(string + "\n"); help.append(string).append("\n");
} }
PlayerFunctions.sendMessage(player, help.toString()); PlayerFunctions.sendMessage(player, help.toString());
return true; return true;
@ -99,15 +97,13 @@ public class MainCommand implements CommandExecutor, TabCompleter {
for (SubCommand command : subCommands) { for (SubCommand command : subCommands) {
if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.equalsIgnoreCase(args[0])) { if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.equalsIgnoreCase(args[0])) {
String[] arguments = new String[args.length - 1]; String[] arguments = new String[args.length - 1];
for (int x = 1; x < args.length; x++) { System.arraycopy(args, 1, arguments, 0, args.length - 1);
arguments[x - 1] = args[x];
}
if (command.permission.hasPermission(player)) { if (command.permission.hasPermission(player)) {
if (player!=null || !command.isPlayer ) { if (player!=null || !command.isPlayer ) {
return command.execute(player, arguments); return command.execute(player, arguments);
} }
else { else {
PlayerFunctions.sendMessage(player, C.IS_CONSOLE); PlayerFunctions.sendMessage(null, C.IS_CONSOLE);
return false; return false;
} }
} }

View File

@ -1,22 +1,13 @@
package com.intellectualcrafters.plot.generator; package com.intellectualcrafters.plot.generator;
import java.util.ArrayList; import com.intellectualcrafters.plot.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.PlayerFunctions; import java.util.ArrayList;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotBlock;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotManager;
import com.intellectualcrafters.plot.PlotWorld;
public class DefaultPlotManager extends PlotManager { public class DefaultPlotManager extends PlotManager {
@ -233,8 +224,10 @@ public class DefaultPlotManager extends PlotManager {
PlotBlock[] plotfloor = dpw.TOP_BLOCK; PlotBlock[] plotfloor = dpw.TOP_BLOCK;
PlotBlock[] filling = dpw.MAIN_BLOCK; PlotBlock[] filling = dpw.MAIN_BLOCK;
PlotBlock wall = dpw.WALL_BLOCK; //PlotBlock wall = dpw.WALL_BLOCK;
PlotBlock wall_filling = dpw.WALL_FILLING; PlotBlock wall = plot.hasOwner() ? dpw.CLAIMED_WALL_BLOCK : dpw.WALL_BLOCK;
PlotBlock wall_filling = dpw.WALL_FILLING;
Block block = world.getBlockAt(new Location(world, pos1.getBlockX()-1, 1, pos1.getBlockZ())); Block block = world.getBlockAt(new Location(world, pos1.getBlockX()-1, 1, pos1.getBlockZ()));
if (block.getTypeId()!=wall_filling.id || block.getData()!=wall_filling.data) { if (block.getTypeId()!=wall_filling.id || block.getData()!=wall_filling.data) {

View File

@ -87,6 +87,8 @@ public class DefaultPlotWorld extends PlotWorld {
* Default wall block: 44 * Default wall block: 44
*/ */
public static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0); public static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0);
public PlotBlock CLAIMED_WALL_BLOCK;
public static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1);
/** /**
* Wall filling * Wall filling
@ -144,6 +146,7 @@ public class DefaultPlotWorld extends PlotWorld {
new ConfigurationNode("plot.filling", DefaultPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true), new ConfigurationNode("plot.filling", DefaultPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true),
new ConfigurationNode("plot.floor", DefaultPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true), new ConfigurationNode("plot.floor", DefaultPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true),
new ConfigurationNode("wall.block", DefaultPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true), new ConfigurationNode("wall.block", DefaultPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true),
new ConfigurationNode("wall.block.claimed", DefaultPlotWorld.CLAIMED_WALL_BLOCK_DEFAULT, "Wall block (claimed)", Configuration.BLOCK, true),
new ConfigurationNode("road.width", DefaultPlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true), new ConfigurationNode("road.width", DefaultPlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true),
new ConfigurationNode("road.height", DefaultPlotWorld.ROAD_HEIGHT_DEFAULT, "Road height", Configuration.INTEGER, true), new ConfigurationNode("road.height", DefaultPlotWorld.ROAD_HEIGHT_DEFAULT, "Road height", Configuration.INTEGER, true),
new ConfigurationNode("road.enable_stripes", DefaultPlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", Configuration.BOOLEAN, true), new ConfigurationNode("road.enable_stripes", DefaultPlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", Configuration.BOOLEAN, true),
@ -179,6 +182,6 @@ public class DefaultPlotWorld extends PlotWorld {
this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.stripes")); this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.stripes"));
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling")); this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling"));
this.WALL_HEIGHT = config.getInt("wall.height"); this.WALL_HEIGHT = config.getInt("wall.height");
this.CLAIMED_WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block.claimed"));
} }
} }