Forgot to merge... Bleh...

This commit is contained in:
Sauilitired 2014-09-29 19:11:21 +02:00
parent 1e6ae5c467
commit c60bd3bbc8
3 changed files with 651 additions and 690 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,32 +6,27 @@
* >> File = Auto.java
* >> Generated by: Citymonstret at 2014-08-09 01:40
*/
package com.intellectualcrafters.plot.commands;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
@SuppressWarnings("deprecation")
public class Auto extends SubCommand {
public Auto() {
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING);
}
// TODO auto claim a mega plot!!!!!!!!!!!!
@Override
public boolean execute(Player plr, String... args) {
World world;
int size_x = 1;
int size_z = 1;
if (PlotMain.getPlotWorlds().length == 1) {
world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]);
} else {
@ -41,7 +36,6 @@ public class Auto extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
return false;
}
}
if (args.length == 1) {
if (PlotMain.hasPermission(plr, "plots.auto.mega")) {
@ -91,38 +85,6 @@ public class Auto extends SubCommand {
x = q;
z = q;
}
while (!br) {
id = new PlotId(x, z);
if (PlotHelper.getPlot(world, id).owner == null) {
Plot plot = PlotHelper.getPlot(world, id);
PlotWorld plotworld = PlotMain.getWorldSettings(plot.getWorld());
if(PlotMain.useEconomy && plotworld.USE_ECONOMY) {
double cost = plotworld.PLOT_PRICE;
if(cost > 0d) {
Economy economy = PlotMain.economy;
if(economy.getBalance(plr) < cost) {
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
return true;
}
economy.withdrawPlayer(plr, cost);
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
}
}
String schematic;
if(args.length > 0 && !(schematic = args[0]).equals("")) {
if(plotworld.SCHEMATIC_CLAIM_SPECIFY) {
if(!plotworld.SCHEMATICS.contains(schematic.toLowerCase())) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
return true;
}
if(!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
return true;
}
}
}
boolean result = Claim.claimPlot(plr, plot, true);
br = !result;
}
}
else {
@ -130,9 +92,7 @@ public class Auto extends SubCommand {
PlotId start = new PlotId(x, z);
PlotId end = new PlotId(x+size_x-1, z+size_z-1);
if (isUnowned(world, start, end)) {
// TODO claim event
for (int i = start.x; i <= end.x; i++) {
for (int j = start.y; j <= end.y; j++) {
Plot plot = PlotHelper.getPlot(world, new PlotId(i,j));

View File

@ -46,8 +46,12 @@ public class Set extends SubCommand {
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS);
}
public static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "rain", "flag" };
public static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "r", "fl" };
public static String[] values = new String[] {
"biome", "wall", "wall_filling", "floor", "alias", "home", "rain", "flag"
};
public static String[] aliases = new String[] {
"b", "w", "wf", "f", "a", "h", "r", "fl"
};
@SuppressWarnings("deprecation")
@Override
@ -88,10 +92,10 @@ public class Set extends SubCommand {
if(args[0].equalsIgnoreCase("flag")) {
if(args.length < 2) {
PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", StringUtils.join(FlagManager.getFlags(), "&c, &6")));
PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", StringUtils.join(PlotMain.getFlags(),"&c, &6")));
return false;
}
if (FlagManager.getFlag(args[1])==null) {
if (!PlotMain.isRegisteredFlag(args[1])) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
return false;
}
@ -114,9 +118,8 @@ public class Set extends SubCommand {
}
java.util.Set<Flag> newflags = plot.settings.getFlags();
Flag oldFlag = plot.settings.getFlag(args[1].toLowerCase());
if (oldFlag != null) {
if (oldFlag!=null)
newflags.remove(oldFlag);
}
plot.settings.setFlags(newflags.toArray(new Flag[0]));
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
@ -124,7 +127,7 @@ public class Set extends SubCommand {
}
try {
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length)," ");
Flag flag = new Flag(new AbstractFlag(args[1]), value);
Flag flag = new Flag(args[1], value);
PlotFlagAddEvent event = new PlotFlagAddEvent(flag,plot);
Bukkit.getServer().getPluginManager().callEvent(event);
if(event.isCancelled()) {
@ -136,7 +139,8 @@ public class Set extends SubCommand {
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
return true;
} catch (Exception e) {
}
catch (Exception e) {
PlayerFunctions.sendMessage(plr, "&c"+e.getMessage());
return false;
}
@ -156,11 +160,8 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.SETTING_UPDATED);
for(Player p : Bukkit.getOnlinePlayers()) {
if(PlayerFunctions.getCurrentPlot(plr).id == plot.id) {
if (b) {
p.setPlayerWeather(WeatherType.DOWNFALL);
} else {
p.resetPlayerWeather();
}
if(b) p.setPlayerWeather(WeatherType.DOWNFALL);
else p.resetPlayerWeather();
}
}
return true;
@ -173,9 +174,7 @@ public class Set extends SubCommand {
}
PlotHomePosition position = null;
for(PlotHomePosition p : PlotHomePosition.values()) {
if (p.isMatching(args[1])) {
position = p;
}
if(p.isMatching(args[1])) position = p;
}
if(position == null) {
PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
@ -233,14 +232,14 @@ public class Set extends SubCommand {
return true;
}
Material material = null;
for (Material m : PlotWorld.BLOCKS) {
for(Material m : plotworld.BLOCKS) {
if(m.toString().equalsIgnoreCase(args[1])) {
material = m;
break;
}
}
if(material == null) {
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
return true;
}
byte data = 0;
@ -269,7 +268,7 @@ public class Set extends SubCommand {
}
//
@SuppressWarnings("unchecked")
ArrayList<Material> materials = (ArrayList<Material>) PlotWorld.BLOCKS.clone();
ArrayList<Material> materials = (ArrayList<Material>) plotworld.BLOCKS.clone();
materials.add(Material.AIR);
//
String[] strings = args[1].split(",");
@ -324,14 +323,14 @@ public class Set extends SubCommand {
return true;
}
Material material = null;
for (Material m : PlotWorld.BLOCKS) {
for(Material m : plotworld.BLOCKS) {
if(m.toString().equalsIgnoreCase(args[1])) {
material = m;
break;
}
}
if(material == null) {
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
return true;
}
byte data = 0;
@ -389,4 +388,5 @@ public class Set extends SubCommand {
return builder.toString().substring(1,builder.toString().length() - 1);
}
}