use of com.elmakers.mine.bukkit.wand.LostWand in project MagicPlugin by elBukkit.
the class MagicController method loadLostWands.
protected void loadLostWands() {
try {
ConfigurationSection lostWandConfiguration = loadDataFile(LOST_WANDS_FILE);
if (lostWandConfiguration != null) {
Set<String> wandIds = lostWandConfiguration.getKeys(false);
for (String wandId : wandIds) {
if (wandId == null || wandId.length() == 0)
continue;
LostWand lostWand = new LostWand(wandId, lostWandConfiguration.getConfigurationSection(wandId));
if (!lostWand.isValid()) {
getLogger().info("Skipped invalid entry in lostwands.yml file, entry will be deleted. The wand is really lost now!");
continue;
}
addLostWand(lostWand);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
getLogger().info("Loaded " + lostWands.size() + " lost wands");
}
use of com.elmakers.mine.bukkit.wand.LostWand in project MagicPlugin by elBukkit.
the class MagicController method removeLostWand.
public boolean removeLostWand(String wandId) {
if (wandId == null || wandId.length() == 0 || !lostWands.containsKey(wandId))
return false;
LostWand lostWand = lostWands.get(wandId);
lostWands.remove(wandId);
String chunkKey = getChunkKey(lostWand.getLocation());
if (chunkKey == null)
return false;
Set<String> chunkWands = lostWandChunks.get(chunkKey);
if (chunkWands != null) {
chunkWands.remove(wandId);
if (chunkWands.size() == 0) {
lostWandChunks.remove(chunkKey);
}
}
if (dynmapShowWands) {
if (removeMarker("wand-" + wandId, "Wands")) {
info("Wand removed from map");
}
}
return true;
}
use of com.elmakers.mine.bukkit.wand.LostWand in project MagicPlugin by elBukkit.
the class MagicController method saveLostWands.
protected void saveLostWands(Collection<YamlDataFile> stores) {
String lastKey = "";
try {
YamlDataFile lostWandsConfiguration = createDataFile(LOST_WANDS_FILE);
for (Entry<String, LostWand> wandEntry : lostWands.entrySet()) {
lastKey = wandEntry.getKey();
if (lastKey == null || lastKey.length() == 0)
continue;
ConfigurationSection wandNode = lostWandsConfiguration.createSection(lastKey);
if (wandNode == null) {
getLogger().warning("Error saving lost wand data for " + lastKey);
continue;
}
if (!wandEntry.getValue().isValid()) {
getLogger().warning("Invalid lost and data for " + lastKey);
continue;
}
wandEntry.getValue().save(wandNode);
}
stores.add(lostWandsConfiguration);
} catch (Throwable ex) {
getLogger().warning("Error saving lost wand data for " + lastKey);
ex.printStackTrace();
}
}
Aggregations