mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-28 12:56:05 +01:00
forgot to save to DB.
This commit is contained in:
parent
edfbc8d474
commit
5601315c41
@ -35,7 +35,7 @@ public class Flag {
|
|||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
Flag other = (Flag) obj;
|
Flag other = (Flag) obj;
|
||||||
return (this.key==other.key);
|
return (this.key==other.key && this.value == other.value);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -144,6 +144,10 @@ public class PlotMain extends JavaPlugin {
|
|||||||
return registeredFlags.add(flag);
|
return registeredFlags.add(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean unRegisterFlag(Flag flag) {
|
||||||
|
return registeredFlags.remove(flag);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all plots
|
* Get all plots
|
||||||
*
|
*
|
||||||
|
@ -133,6 +133,9 @@ public class PlotSettings {
|
|||||||
* @param flag
|
* @param flag
|
||||||
*/
|
*/
|
||||||
public void addFlag(Flag flag) {
|
public void addFlag(Flag flag) {
|
||||||
|
Flag hasFlag = getFlag(flag.getKey());
|
||||||
|
if (hasFlag!=null)
|
||||||
|
flags.remove(hasFlag);
|
||||||
this.flags.add(flag);
|
this.flags.add(flag);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -156,19 +159,11 @@ public class PlotSettings {
|
|||||||
*/
|
*/
|
||||||
public Flag getFlag(String flag) {
|
public Flag getFlag(String flag) {
|
||||||
for (Flag myflag:flags) {
|
for (Flag myflag:flags) {
|
||||||
if (myflag.getKey()==flag)
|
if (myflag.getKey().equals(flag))
|
||||||
return myflag;
|
return myflag;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param flag
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean hasFlag(Flag flag) {
|
|
||||||
return this.flags.contains(flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlotHomePosition getPosition() { return this.position; }
|
public PlotHomePosition getPosition() { return this.position; }
|
||||||
public void setPosition(PlotHomePosition position) { this.position = position; }
|
public void setPosition(PlotHomePosition position) { this.position = position; }
|
||||||
|
@ -78,7 +78,7 @@ public class Info extends SubCommand{
|
|||||||
info = info.replaceAll("%weather%", plot.settings.getRain() ? "rain" : "default");
|
info = info.replaceAll("%weather%", plot.settings.getRain() ? "rain" : "default");
|
||||||
info = info.replaceAll("%helpers%", getPlayerList(plot.helpers));
|
info = info.replaceAll("%helpers%", getPlayerList(plot.helpers));
|
||||||
info = info.replaceAll("%denied%", getPlayerList(plot.denied));
|
info = info.replaceAll("%denied%", getPlayerList(plot.denied));
|
||||||
info = info.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(),"").length() > 0 ? StringUtils.join(plot.settings.getFlags(),"") : "none");
|
info = info.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(),"").length() > 0 ? StringUtils.join(plot.settings.getFlags(),",") : "none");
|
||||||
PlayerFunctions.sendMessage(player, info);
|
PlayerFunctions.sendMessage(player, info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class Set extends SubCommand{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length==2) {
|
if (args.length==2) {
|
||||||
if (!plot.settings.hasFlag(new Flag(args[1], ""))) {
|
if (plot.settings.getFlag(args[1].toLowerCase())==null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -109,8 +109,11 @@ public class Set extends SubCommand{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
java.util.Set<Flag> newflags = plot.settings.getFlags();
|
java.util.Set<Flag> newflags = plot.settings.getFlags();
|
||||||
newflags.remove(flag);
|
Flag oldFlag = plot.settings.getFlag(args[1].toLowerCase());
|
||||||
|
if (oldFlag!=null)
|
||||||
|
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]));
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -125,6 +128,7 @@ public class Set extends SubCommand{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plot.settings.addFlag(flag);
|
plot.settings.addFlag(flag);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
@ -150,23 +150,23 @@ public class DBFunc {
|
|||||||
/**
|
/**
|
||||||
* `plot`
|
* `plot`
|
||||||
*/
|
*/
|
||||||
int target_len = 6;
|
// int target_len = 6;
|
||||||
ArrayList<String> ids = new ArrayList<String>();
|
// ArrayList<String> ids = new ArrayList<String>();
|
||||||
stmt = connection.createStatement();
|
// stmt = connection.createStatement();
|
||||||
String table = "plot";
|
// String table = "plot";
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM `"+table+"`");
|
// ResultSet rs = stmt.executeQuery("SELECT * FROM `"+table+"`");
|
||||||
ResultSetMetaData md = rs.getMetaData();
|
// ResultSetMetaData md = rs.getMetaData();
|
||||||
int len = md.getColumnCount();
|
// int len = md.getColumnCount();
|
||||||
if (len<target_len) {
|
// if (len<target_len) {
|
||||||
HashSet<String> cols = new HashSet<String>();
|
// HashSet<String> cols = new HashSet<String>();
|
||||||
for (int i = 1; i <= len; i++) {
|
// for (int i = 1; i <= len; i++) {
|
||||||
cols.add(md.getColumnName(i));
|
// cols.add(md.getColumnName(i));
|
||||||
}
|
// }
|
||||||
while (rs.next()) {
|
// while (rs.next()) {
|
||||||
ids.add(rs.getString("plot_id"));
|
// ids.add(rs.getString("plot_id"));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
stmt.close();
|
// stmt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user