mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-24 06:06:45 +01:00
Forgot to merge... Bleh...
This commit is contained in:
parent
1e6ae5c467
commit
c60bd3bbc8
File diff suppressed because it is too large
Load Diff
@ -6,32 +6,27 @@
|
|||||||
* >> File = Auto.java
|
* >> File = Auto.java
|
||||||
* >> Generated by: Citymonstret at 2014-08-09 01:40
|
* >> Generated by: Citymonstret at 2014-08-09 01:40
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
import com.intellectualcrafters.plot.PlotHelper;
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class Auto extends SubCommand {
|
public class Auto extends SubCommand {
|
||||||
|
|
||||||
public Auto() {
|
public Auto() {
|
||||||
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING);
|
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO auto claim a mega plot!!!!!!!!!!!!
|
// TODO auto claim a mega plot!!!!!!!!!!!!
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Player plr, String... args) {
|
public boolean execute(Player plr, String... args) {
|
||||||
World world;
|
World world;
|
||||||
|
int size_x = 1;
|
||||||
|
int size_z = 1;
|
||||||
if (PlotMain.getPlotWorlds().length == 1) {
|
if (PlotMain.getPlotWorlds().length == 1) {
|
||||||
world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]);
|
world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]);
|
||||||
} else {
|
} else {
|
||||||
@ -41,7 +36,6 @@ public class Auto extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (PlotMain.hasPermission(plr, "plots.auto.mega")) {
|
if (PlotMain.hasPermission(plr, "plots.auto.mega")) {
|
||||||
@ -91,38 +85,6 @@ public class Auto extends SubCommand {
|
|||||||
x = q;
|
x = q;
|
||||||
z = 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 {
|
else {
|
||||||
@ -130,9 +92,7 @@ public class Auto extends SubCommand {
|
|||||||
PlotId start = new PlotId(x, z);
|
PlotId start = new PlotId(x, z);
|
||||||
PlotId end = new PlotId(x+size_x-1, z+size_z-1);
|
PlotId end = new PlotId(x+size_x-1, z+size_z-1);
|
||||||
if (isUnowned(world, start, end)) {
|
if (isUnowned(world, start, end)) {
|
||||||
|
|
||||||
// TODO claim event
|
// TODO claim event
|
||||||
|
|
||||||
for (int i = start.x; i <= end.x; i++) {
|
for (int i = start.x; i <= end.x; i++) {
|
||||||
for (int j = start.y; j <= end.y; j++) {
|
for (int j = start.y; j <= end.y; j++) {
|
||||||
Plot plot = PlotHelper.getPlot(world, new PlotId(i,j));
|
Plot plot = PlotHelper.getPlot(world, new PlotId(i,j));
|
||||||
|
@ -46,8 +46,12 @@ public class Set extends SubCommand {
|
|||||||
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS);
|
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[] values = new String[] {
|
||||||
public static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "r", "fl" };
|
"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")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
@ -88,10 +92,10 @@ public class Set extends SubCommand {
|
|||||||
|
|
||||||
if(args[0].equalsIgnoreCase("flag")) {
|
if(args[0].equalsIgnoreCase("flag")) {
|
||||||
if(args.length < 2) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
if (FlagManager.getFlag(args[1])==null) {
|
if (!PlotMain.isRegisteredFlag(args[1])) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -114,9 +118,8 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
java.util.Set<Flag> newflags = plot.settings.getFlags();
|
java.util.Set<Flag> newflags = plot.settings.getFlags();
|
||||||
Flag oldFlag = plot.settings.getFlag(args[1].toLowerCase());
|
Flag oldFlag = plot.settings.getFlag(args[1].toLowerCase());
|
||||||
if (oldFlag != null) {
|
if (oldFlag!=null)
|
||||||
newflags.remove(oldFlag);
|
newflags.remove(oldFlag);
|
||||||
}
|
|
||||||
plot.settings.setFlags(newflags.toArray(new Flag[0]));
|
plot.settings.setFlags(newflags.toArray(new Flag[0]));
|
||||||
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
|
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
||||||
@ -124,7 +127,7 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length)," ");
|
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);
|
PlotFlagAddEvent event = new PlotFlagAddEvent(flag,plot);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if(event.isCancelled()) {
|
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]));
|
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
PlayerFunctions.sendMessage(plr, "&c"+e.getMessage());
|
PlayerFunctions.sendMessage(plr, "&c"+e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -156,11 +160,8 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.SETTING_UPDATED);
|
PlayerFunctions.sendMessage(plr, C.SETTING_UPDATED);
|
||||||
for(Player p : Bukkit.getOnlinePlayers()) {
|
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||||
if(PlayerFunctions.getCurrentPlot(plr).id == plot.id) {
|
if(PlayerFunctions.getCurrentPlot(plr).id == plot.id) {
|
||||||
if (b) {
|
if(b) p.setPlayerWeather(WeatherType.DOWNFALL);
|
||||||
p.setPlayerWeather(WeatherType.DOWNFALL);
|
else p.resetPlayerWeather();
|
||||||
} else {
|
|
||||||
p.resetPlayerWeather();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -173,9 +174,7 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
PlotHomePosition position = null;
|
PlotHomePosition position = null;
|
||||||
for(PlotHomePosition p : PlotHomePosition.values()) {
|
for(PlotHomePosition p : PlotHomePosition.values()) {
|
||||||
if (p.isMatching(args[1])) {
|
if(p.isMatching(args[1])) position = p;
|
||||||
position = p;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(position == null) {
|
if(position == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
|
PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
|
||||||
@ -233,14 +232,14 @@ public class Set extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Material material = null;
|
Material material = null;
|
||||||
for (Material m : PlotWorld.BLOCKS) {
|
for(Material m : plotworld.BLOCKS) {
|
||||||
if(m.toString().equalsIgnoreCase(args[1])) {
|
if(m.toString().equalsIgnoreCase(args[1])) {
|
||||||
material = m;
|
material = m;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(material == null) {
|
if(material == null) {
|
||||||
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
byte data = 0;
|
byte data = 0;
|
||||||
@ -269,7 +268,7 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ArrayList<Material> materials = (ArrayList<Material>) PlotWorld.BLOCKS.clone();
|
ArrayList<Material> materials = (ArrayList<Material>) plotworld.BLOCKS.clone();
|
||||||
materials.add(Material.AIR);
|
materials.add(Material.AIR);
|
||||||
//
|
//
|
||||||
String[] strings = args[1].split(",");
|
String[] strings = args[1].split(",");
|
||||||
@ -324,14 +323,14 @@ public class Set extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Material material = null;
|
Material material = null;
|
||||||
for (Material m : PlotWorld.BLOCKS) {
|
for(Material m : plotworld.BLOCKS) {
|
||||||
if(m.toString().equalsIgnoreCase(args[1])) {
|
if(m.toString().equalsIgnoreCase(args[1])) {
|
||||||
material = m;
|
material = m;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(material == null) {
|
if(material == null) {
|
||||||
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
byte data = 0;
|
byte data = 0;
|
||||||
@ -389,4 +388,5 @@ public class Set extends SubCommand {
|
|||||||
return builder.toString().substring(1,builder.toString().length() - 1);
|
return builder.toString().substring(1,builder.toString().length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user