mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +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())
|
||||
return false;
|
||||
Flag other = (Flag) obj;
|
||||
return (this.key==other.key);
|
||||
return (this.key==other.key && this.value == other.value);
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -144,6 +144,10 @@ public class PlotMain extends JavaPlugin {
|
||||
return registeredFlags.add(flag);
|
||||
}
|
||||
|
||||
public static boolean unRegisterFlag(Flag flag) {
|
||||
return registeredFlags.remove(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plots
|
||||
*
|
||||
|
@ -133,6 +133,9 @@ public class PlotSettings {
|
||||
* @param flag
|
||||
*/
|
||||
public void addFlag(Flag flag) {
|
||||
Flag hasFlag = getFlag(flag.getKey());
|
||||
if (hasFlag!=null)
|
||||
flags.remove(hasFlag);
|
||||
this.flags.add(flag);
|
||||
}
|
||||
/**
|
||||
@ -156,19 +159,11 @@ public class PlotSettings {
|
||||
*/
|
||||
public Flag getFlag(String flag) {
|
||||
for (Flag myflag:flags) {
|
||||
if (myflag.getKey()==flag)
|
||||
if (myflag.getKey().equals(flag))
|
||||
return myflag;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param flag
|
||||
* @return
|
||||
*/
|
||||
public boolean hasFlag(Flag flag) {
|
||||
return this.flags.contains(flag);
|
||||
}
|
||||
|
||||
public PlotHomePosition getPosition() { return this.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("%helpers%", getPlayerList(plot.helpers));
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class Set extends SubCommand{
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
@ -109,8 +109,11 @@ public class Set extends SubCommand{
|
||||
return false;
|
||||
}
|
||||
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]));
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
||||
return true;
|
||||
}
|
||||
@ -125,6 +128,7 @@ public class Set extends SubCommand{
|
||||
return false;
|
||||
}
|
||||
plot.settings.addFlag(flag);
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
||||
return true;
|
||||
}
|
||||
|
@ -150,23 +150,23 @@ public class DBFunc {
|
||||
/**
|
||||
* `plot`
|
||||
*/
|
||||
int target_len = 6;
|
||||
ArrayList<String> ids = new ArrayList<String>();
|
||||
stmt = connection.createStatement();
|
||||
String table = "plot";
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM `"+table+"`");
|
||||
ResultSetMetaData md = rs.getMetaData();
|
||||
int len = md.getColumnCount();
|
||||
if (len<target_len) {
|
||||
HashSet<String> cols = new HashSet<String>();
|
||||
for (int i = 1; i <= len; i++) {
|
||||
cols.add(md.getColumnName(i));
|
||||
}
|
||||
while (rs.next()) {
|
||||
ids.add(rs.getString("plot_id"));
|
||||
}
|
||||
}
|
||||
stmt.close();
|
||||
// int target_len = 6;
|
||||
// ArrayList<String> ids = new ArrayList<String>();
|
||||
// stmt = connection.createStatement();
|
||||
// String table = "plot";
|
||||
// ResultSet rs = stmt.executeQuery("SELECT * FROM `"+table+"`");
|
||||
// ResultSetMetaData md = rs.getMetaData();
|
||||
// int len = md.getColumnCount();
|
||||
// if (len<target_len) {
|
||||
// HashSet<String> cols = new HashSet<String>();
|
||||
// for (int i = 1; i <= len; i++) {
|
||||
// cols.add(md.getColumnName(i));
|
||||
// }
|
||||
// while (rs.next()) {
|
||||
// ids.add(rs.getString("plot_id"));
|
||||
// }
|
||||
// }
|
||||
// stmt.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user