- Fixed Factions Hook trying to get a leader for WarZone, SafeZone and
Wilderness
- Errors no longer thrown when changing db version on mysql
This commit is contained in:
Rsl1122 2017-02-22 18:17:32 +02:00
parent 964954c674
commit 0a9f994049
3 changed files with 27 additions and 11 deletions

View File

@ -31,18 +31,21 @@ public class FactionsHook extends Hook {
super("com.massivecraft.factions.Factions");
this.plugin = plugin;
}
public FactionsHook() {
super();
plugin = null;
plugin = null;
}
/**
* @return List of Faction names sorted by power
*/
public List<String> getTopFactions() {
List<Faction> topFactions = new ArrayList<>();
topFactions.addAll(FactionColl.get().getAll());
topFactions.remove(FactionColl.get().getWarzone());
topFactions.remove(FactionColl.get().getSafezone());
topFactions.remove(FactionColl.get().getNone());
Collections.sort(topFactions, new FactionComparator());
List<String> factionNames = topFactions.stream()
.map(faction -> faction.getName())
@ -61,9 +64,20 @@ public class FactionsHook extends Hook {
public HashMap<String, Serializable> getFactionInfo(String factionName) {
HashMap<String, Serializable> info = new HashMap<>();
Faction faction = FactionColl.get().getByName(factionName);
info.put("LEADER", faction.getLeader().getNameAndSomething("", ""));
info.put("POWER", faction.getPower());
info.put("LAND", faction.getPower());
if (faction != null) {
MPlayer leader = faction.getLeader();
if (leader != null) {
info.put("LEADER", leader.getNameAndSomething("", ""));
} else {
info.put("LEADER", "No leader");
}
info.put("POWER", faction.getPower());
info.put("LAND", faction.getPower());
} else {
info.put("LEADER", "Faction not found");
info.put("POWER", "Faction not found");
info.put("LAND", "Faction not found");
}
return info;
}
@ -87,7 +101,7 @@ public class FactionsHook extends Hook {
info.put("FACTION", "Not in faction");
}
} else {
info.put("POWER",0);
info.put("POWER", 0);
info.put("MAXPOWER", 0);
info.put("FACTION", "Not in faction");
}

View File

@ -292,11 +292,13 @@ public abstract class SQLDB extends Database {
try {
query(query);
} catch (Exception e) {
e.printStackTrace();
}
}
if (usingMySQL) {
query("ALTER TABLE " + userName + " DROP INDEX " + userColumnPlayerKills);
try {
if (usingMySQL) {
query("ALTER TABLE " + userName + " DROP INDEX " + userColumnPlayerKills);
}
} catch (Exception e) {
}
setVersion(3);
}

View File

@ -1,7 +1,7 @@
name: Plan
author: Rsl1122
main: main.java.com.djrapitops.plan.Plan
version: 2.6.1
version: 2.6.2
softdepend:
- OnTime