This commit is contained in:
boy0001 2014-10-04 16:01:45 +10:00
parent 34f0428d06
commit 5f0d914b07

View File

@ -44,8 +44,8 @@ public class PlotMeConverter {
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata..."); PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata...");
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>(); ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>();
Map<String, UUID> uuidMap = new HashMap<String, UUID>(); Map<String, UUID> uuidMap = new HashMap<String, UUID>();
boolean online = Bukkit.getServer().getOnlineMode();
if (!Bukkit.getServer().getOnlineMode()) { if (!online) {
File playersFolder = new File("world" + File.separator + "playerdata"); File playersFolder = new File("world" + File.separator + "playerdata");
String[] dat = playersFolder.list(new FilenameFilter() { String[] dat = playersFolder.list(new FilenameFilter() {
public boolean accept(File f, String s) { public boolean accept(File f, String s) {
@ -72,27 +72,6 @@ public class PlotMeConverter {
HashMap<String, Plot> plots = PlotManager.getPlots(world); HashMap<String, Plot> plots = PlotManager.getPlots(world);
if (plots != null) { if (plots != null) {
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '"+plots.size()+"' plots for world '"+world.getName()+"'"); PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '"+plots.size()+"' plots for world '"+world.getName()+"'");
// TODO generate configuration based on PlotMe config
// - Plugin doesn't display a message if database is not
// setup at all
// List<String> names = new ArrayList<String>();
// for (Plot plot : plots.values()) {
// try {
// String owner = plot.getOwner();
// names.add(owner);
// }
// catch (Exception e) {
//
// }
//
// }
// UUIDFetcher fetcher = new UUIDFetcher(names);
// try {
// uuidMap = fetcher.call();
// } catch (Exception e) {
// e.printStackTrace();
// }
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting " + plots.size() + " plots for '" + world.toString() + "'..."); PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting " + plots.size() + " plots for '" + world.toString() + "'...");
for (Plot plot : plots.values()) { for (Plot plot : plots.values()) {
@ -104,9 +83,9 @@ public class PlotMeConverter {
} }
long eR3040bl230 = 22392948l; long eR3040bl230 = 22392948l;
try { try {
if (online) {
PlayerList denied = null; PlayerList denied = null;
PlayerList added = null; PlayerList added = null;
if (Bukkit.getServer().getOnlineMode()) {
Field fAdded = plot.getClass().getDeclaredField("allowed"); Field fAdded = plot.getClass().getDeclaredField("allowed");
Field fDenied = plot.getClass().getDeclaredField("denied"); Field fDenied = plot.getClass().getDeclaredField("denied");
fAdded.setAccessible(true); fAdded.setAccessible(true);
@ -138,34 +117,18 @@ public class PlotMeConverter {
} }
else { else {
for (String user : plot.getAllowed().split(",")) { for (String user : plot.getAllowed().split(",")) {
try {
if (user.equals("*")) { if (user.equals("*")) {
psAdded.add(DBFunc.everyone); psAdded.add(DBFunc.everyone);
} else if (uuidMap.containsKey(user)) { } else if (uuidMap.containsKey(user)) {
psAdded.add(uuidMap.get(user)); psAdded.add(uuidMap.get(user));
} else {
UUID uuid = Bukkit.getOfflinePlayer(user).getUniqueId();
uuidMap.put(user, uuid);
psAdded.add(uuid);
}
} catch (Exception e2) {
e2.printStackTrace();
} }
} }
try { try {
for (String user : plot.getDenied().split(",")) { for (String user : plot.getDenied().split(",")) {
try {
if (user.equals("*")) { if (user.equals("*")) {
psDenied.add(DBFunc.everyone); psDenied.add(DBFunc.everyone);
} else if (uuidMap.containsKey(user)) { } else if (uuidMap.containsKey(user)) {
psDenied.add(uuidMap.get(user)); psDenied.add(uuidMap.get(user));
} else {
UUID uuid = Bukkit.getOfflinePlayer(user).getUniqueId();
uuidMap.put(user, uuid);
psDenied.add(uuid);
}
} catch (Exception e2) {
e2.printStackTrace();
} }
} }
} }
@ -181,21 +144,25 @@ public class PlotMeConverter {
} }
stream.println(eR3040bl230); stream.println(eR3040bl230);
PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1])); PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
com.intellectualcrafters.plot.Plot pl; com.intellectualcrafters.plot.Plot pl = null;
if (Bukkit.getServer().getOnlineMode()) { if (online) {
pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false }); pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false });
} }
else { else {
pl = new com.intellectualcrafters.plot.Plot(id, Bukkit.getOfflinePlayer(plot.getOwner()).getUniqueId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false }); String owner = plot.getOwner();
if (uuidMap.containsKey(owner)) {
pl = new com.intellectualcrafters.plot.Plot(id, uuidMap.get(owner), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false });
}
} }
// TODO createPlot doesn't add helpers / denied // TODO createPlot doesn't add helpers / denied
// users // users
if (pl!=null) {
createdPlots.add(pl); createdPlots.add(pl);
} }
} }
} }
}
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating plot DB"); PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating plot DB");
DBFunc.createPlots(createdPlots); DBFunc.createPlots(createdPlots);
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB"); PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB");