Beta6. Supports CB493
This commit is contained in:
parent
afde3e188b
commit
429e86fd4b
@ -36,13 +36,13 @@ Note that you may optionally skip the slash and just write
|
|||||||
|
|
||||||
Installing
|
Installing
|
||||||
----------
|
----------
|
||||||
1. Download the latest release: [https://github.com/oloflarsson/Factions/tree/master/releases](https://github.com/oloflarsson/Factions/tree/master/releases)<br/>
|
1. Download the latest release: [https://github.com/oloflarsson/Factions/tree/master/releases](https://github.com/oloflarsson/Factions/tree/master/releases)<br>
|
||||||
1. Put Factions.jar in the plugins folder.
|
1. Put Factions.jar in the plugins folder.
|
||||||
|
|
||||||
A default config file will be created on the first run.
|
A default config file will be created on the first run.
|
||||||
|
|
||||||
License
|
License
|
||||||
----------
|
----------
|
||||||
This project has a LGPL license just like the Bukkit project.
|
This project has a LGPL license just like the Bukkit project.<br>
|
||||||
This project uses [GSON](http://code.google.com/p/google-gson/) which has a [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0 ).
|
This project uses [GSON](http://code.google.com/p/google-gson/) which has a [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0 ).
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
name: Factions
|
name: Factions
|
||||||
version: 1.0 beta5
|
version: 1.0 beta6
|
||||||
main: com.bukkit.mcteam.factions.Factions
|
main: com.bukkit.mcteam.factions.Factions
|
BIN
releases/factions 1.0beta6.zip
Normal file
BIN
releases/factions 1.0beta6.zip
Normal file
Binary file not shown.
@ -13,7 +13,7 @@ import com.bukkit.mcteam.util.AsciiCompass;
|
|||||||
//import com.bukkit.mcteam.factions.util.*;
|
//import com.bukkit.mcteam.factions.util.*;
|
||||||
|
|
||||||
public class Board {
|
public class Board {
|
||||||
public transient Long id;
|
public transient String worldName;
|
||||||
protected Map<Coord, Integer> coordFactionIds;
|
protected Map<Coord, Integer> coordFactionIds;
|
||||||
|
|
||||||
public Board() {
|
public Board() {
|
||||||
@ -72,7 +72,7 @@ public class Board {
|
|||||||
|
|
||||||
public static void cleanAll() {
|
public static void cleanAll() {
|
||||||
for (Board board : getAll()) {
|
for (Board board : getAll()) {
|
||||||
Log.debug("Cleaning board: "+board.id);
|
Log.debug("Cleaning board for world "+board.worldName);
|
||||||
board.clean();
|
board.clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ public class Board {
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
public boolean save() {
|
public boolean save() {
|
||||||
return EM.boardSave(this.id);
|
return EM.boardSave(this.worldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Board get(World world) {
|
public static Board get(World world) {
|
||||||
|
@ -20,7 +20,7 @@ import com.bukkit.mcteam.gson.*;
|
|||||||
public class EM {
|
public class EM {
|
||||||
protected static Map<String, Follower> followers = new HashMap<String, Follower>(); // Where String is a lowercase playername
|
protected static Map<String, Follower> followers = new HashMap<String, Follower>(); // Where String is a lowercase playername
|
||||||
protected static Map<Integer, Faction> factions = new HashMap<Integer, Faction>(); // Where Integer is a primary auto increment key
|
protected static Map<Integer, Faction> factions = new HashMap<Integer, Faction>(); // Where Integer is a primary auto increment key
|
||||||
protected static Map<Long, Board> boards = new HashMap<Long, Board>(); // Where Long is the semi (sadly) unique world id.
|
protected static Map<String, Board> boards = new HashMap<String, Board>(); // Where Long is the semi (sadly) unique world id.
|
||||||
protected static int nextFactionId;
|
protected static int nextFactionId;
|
||||||
|
|
||||||
// hardcoded config
|
// hardcoded config
|
||||||
@ -139,8 +139,8 @@ public class EM {
|
|||||||
name = name.substring(0, name.length() - ext.length());
|
name = name.substring(0, name.length() - ext.length());
|
||||||
try {
|
try {
|
||||||
Board board = gson.fromJson(DiscUtil.read(jsonFile), Board.class);
|
Board board = gson.fromJson(DiscUtil.read(jsonFile), Board.class);
|
||||||
board.id = Long.parseLong(name);
|
board.worldName = name;
|
||||||
boards.put(board.id, board);
|
boards.put(board.worldName, board);
|
||||||
Log.debug("loaded board "+name);
|
Log.debug("loaded board "+name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -158,37 +158,37 @@ public class EM {
|
|||||||
* A new Board will be created if the world did not have one
|
* A new Board will be created if the world did not have one
|
||||||
*/
|
*/
|
||||||
public static Board boardGet(World world) {
|
public static Board boardGet(World world) {
|
||||||
if (boards.containsKey(world.getId())) {
|
if (boards.containsKey(world.getName())) {
|
||||||
return boards.get(world.getId());
|
return boards.get(world.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return boardCreate(world);
|
return boardCreate(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean boardSave(long id) {
|
public static boolean boardSave(String worldName) {
|
||||||
Object obj = boards.get(id);
|
Object obj = boards.get(worldName);
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
Log.warn("Could not save board "+id+" as it was not loaded");
|
Log.warn("Could not save board "+worldName+" as it was not loaded");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
folderBoard.mkdirs();
|
folderBoard.mkdirs();
|
||||||
File file = new File(folderBoard, id+ext);
|
File file = new File(folderBoard, worldName+ext);
|
||||||
try {
|
try {
|
||||||
DiscUtil.write(file, gson.toJson(obj));
|
DiscUtil.write(file, gson.toJson(obj));
|
||||||
Log.debug("Saved the board "+id);
|
Log.debug("Saved the board "+worldName);
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log.warn("Failed to save the board "+id);
|
Log.warn("Failed to save the board "+worldName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Board boardCreate(World world) {
|
protected static Board boardCreate(World world) {
|
||||||
Log.debug("Creating new board "+world.getId());
|
Log.debug("Creating new board for "+world.getName());
|
||||||
Board board = new Board();
|
Board board = new Board();
|
||||||
board.id = world.getId();
|
board.worldName = world.getName();
|
||||||
boards.put(board.id, board);
|
boards.put(board.worldName, board);
|
||||||
board.save();
|
board.save();
|
||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user