mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-03 18:53:43 +01:00 
			
		
		
		
	Fixed PlotMe converter for MultiWorld and vanilla Bukkit
This commit is contained in:
		@@ -44,255 +44,256 @@ public class PlotMeConverter {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void runAsync() throws Exception {
 | 
						public void runAsync() throws Exception {
 | 
				
			||||||
 | 
						    Bukkit.getScheduler().runTaskLater(this.plugin, new Runnable() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void run() {
 | 
				
			||||||
 | 
					        		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has started");
 | 
				
			||||||
 | 
					        		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata...");
 | 
				
			||||||
 | 
					        		ArrayList<com.intellectualcrafters.plot.Plot> createdPlots =
 | 
				
			||||||
 | 
					        				new ArrayList<com.intellectualcrafters.plot.Plot>();
 | 
				
			||||||
 | 
					        		boolean online = Bukkit.getServer().getOnlineMode();
 | 
				
			||||||
        		
 | 
					        		
 | 
				
			||||||
		final PrintStream stream = new PrintStream("converter_log.txt");
 | 
					        		Plugin plotMePlugin = Bukkit.getPluginManager().getPlugin("PlotMe");
 | 
				
			||||||
 | 
					        		FileConfiguration plotConfig = plotMePlugin.getConfig();
 | 
				
			||||||
        		
 | 
					        		
 | 
				
			||||||
		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has started");
 | 
					        		Set<String> worlds = new HashSet<String>();
 | 
				
			||||||
		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata...");
 | 
					 | 
				
			||||||
		ArrayList<com.intellectualcrafters.plot.Plot> createdPlots =
 | 
					 | 
				
			||||||
				new ArrayList<com.intellectualcrafters.plot.Plot>();
 | 
					 | 
				
			||||||
		boolean online = Bukkit.getServer().getOnlineMode();
 | 
					 | 
				
			||||||
        		
 | 
					        		
 | 
				
			||||||
		Plugin plotMePlugin = Bukkit.getPluginManager().getPlugin("PlotMe");
 | 
					        		for (World world : Bukkit.getWorlds()) {
 | 
				
			||||||
		FileConfiguration plotConfig = plotMePlugin.getConfig();
 | 
					        			int duplicate = 0;
 | 
				
			||||||
 | 
					        			HashMap<String, Plot> plots = PlotManager.getPlots(world);
 | 
				
			||||||
 | 
					        			if (plots != null) {
 | 
				
			||||||
        			    
 | 
					        			    
 | 
				
			||||||
		Set<String> worlds = new HashSet<String>();
 | 
					        			    worlds.add(world.getName());
 | 
				
			||||||
        			    
 | 
					        			    
 | 
				
			||||||
		for (World world : Bukkit.getWorlds()) {
 | 
					        				PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting configuration for world '"+world.getName()+"'...");
 | 
				
			||||||
			int duplicate = 0;
 | 
					 | 
				
			||||||
			HashMap<String, Plot> plots = PlotManager.getPlots(world);
 | 
					 | 
				
			||||||
			if (plots != null) {
 | 
					 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
			    worlds.add(world.getName());
 | 
					        				try {
 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
				PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting configuration for world '"+world.getName()+"'...");
 | 
					        			    Integer pathwidth = plotConfig.getInt("worlds."+world.getName()+".PathWidth"); //
 | 
				
			||||||
 | 
					        			    PlotMain.config.set("worlds."+world.getName()+".road.width", pathwidth);
 | 
				
			||||||
        			    
 | 
					        			    
 | 
				
			||||||
				try {
 | 
					        			    Integer plotsize = plotConfig.getInt("worlds."+world.getName()+".PlotSize"); //
 | 
				
			||||||
 | 
					        			    PlotMain.config.set("worlds."+world.getName()+".plot.size", plotsize);
 | 
				
			||||||
        			    
 | 
					        			    
 | 
				
			||||||
			    Integer pathwidth = plotConfig.getInt("worlds."+world.getName()+".PathWidth"); //
 | 
					        				String wallblock = plotConfig.getString("worlds."+world.getName()+".WallBlockId"); //
 | 
				
			||||||
			    PlotMain.config.set("worlds."+world.getName()+".road.width", pathwidth);
 | 
					        				PlotMain.config.set("worlds."+world.getName()+".wall.block", wallblock);
 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
			    Integer plotsize = plotConfig.getInt("worlds."+world.getName()+".PlotSize"); //
 | 
					        				String floor = plotConfig.getString("worlds."+world.getName()+".PlotFloorBlockId"); //
 | 
				
			||||||
			    PlotMain.config.set("worlds."+world.getName()+".plot.size", plotsize);
 | 
					        				PlotMain.config.set("worlds."+world.getName()+".plot.floor", Arrays.asList(new String[] {floor}));
 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
				String wallblock = plotConfig.getString("worlds."+world.getName()+".WallBlockId"); //
 | 
					        				String filling = plotConfig.getString("worlds."+world.getName()+".PlotFillingBlockId"); //
 | 
				
			||||||
				PlotMain.config.set("worlds."+world.getName()+".wall.block", wallblock);
 | 
					        				PlotMain.config.set("worlds."+world.getName()+".plot.filling", Arrays.asList(new String[] {filling}));
 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
				String floor = plotConfig.getString("worlds."+world.getName()+".PlotFloorBlockId"); //
 | 
					        				String road = plotConfig.getString("worlds."+world.getName()+".RoadMainBlockId"); 
 | 
				
			||||||
				PlotMain.config.set("worlds."+world.getName()+".plot.floor", Arrays.asList(new String[] {floor}));
 | 
					        				PlotMain.config.set("worlds."+world.getName()+".road.block", road);
 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
				String filling = plotConfig.getString("worlds."+world.getName()+".PlotFillingBlockId"); //
 | 
					        				String road_stripe = plotConfig.getString("worlds."+world.getName()+".RoadStripeBlockId");
 | 
				
			||||||
				PlotMain.config.set("worlds."+world.getName()+".plot.filling", Arrays.asList(new String[] {filling}));
 | 
					        				PlotMain.config.set("worlds."+world.getName()+".road.stripes", road_stripe);
 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
				String road = plotConfig.getString("worlds."+world.getName()+".RoadMainBlockId"); 
 | 
					        				Integer height = plotConfig.getInt("worlds."+world.getName()+".RoadHeight"); //
 | 
				
			||||||
				PlotMain.config.set("worlds."+world.getName()+".road.block", road);
 | 
					        				PlotMain.config.set("worlds."+world.getName()+".road.height", height);
 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
				String road_stripe = plotConfig.getString("worlds."+world.getName()+".RoadStripeBlockId");
 | 
					        				Boolean auto_link = plotConfig.getBoolean("worlds."+world.getName()+".AutoLinkPlots"); // 
 | 
				
			||||||
				PlotMain.config.set("worlds."+world.getName()+".road.stripes", road_stripe);
 | 
					        				PlotMain.config.set("worlds."+world.getName()+".plot.auto_merge", auto_link);
 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
				Integer height = plotConfig.getInt("worlds."+world.getName()+".RoadHeight"); //
 | 
					        				}
 | 
				
			||||||
				PlotMain.config.set("worlds."+world.getName()+".road.height", height);
 | 
					        				catch (Exception e) {
 | 
				
			||||||
 | 
					        				    PlotMain.sendConsoleSenderMessage(" - Failed to save configuration for world '"+world.getName()+"'. This will need to be done using the setup command or manually.");
 | 
				
			||||||
 | 
					        				}
 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
				Boolean auto_link = plotConfig.getBoolean("worlds."+world.getName()+".AutoLinkPlots"); // 
 | 
					        				PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size() + "' plots for world '" + world.getName() + "'");
 | 
				
			||||||
				PlotMain.config.set("worlds."+world.getName()+".plot.auto_merge", auto_link);
 | 
					 | 
				
			||||||
        				
 | 
					        				
 | 
				
			||||||
				}
 | 
					        				for (Plot plot : plots.values()) {
 | 
				
			||||||
				catch (Exception e) {
 | 
					        					ArrayList<UUID> psAdded = new ArrayList<>();
 | 
				
			||||||
				    PlotMain.sendConsoleSenderMessage(" - Failed to save configuration for world '"+world.getName()+"'. This will need to be done using the setup command or manually.");
 | 
					        					ArrayList<UUID> psTrusted = new ArrayList<>();
 | 
				
			||||||
				}
 | 
					        					ArrayList<UUID> psDenied = new ArrayList<>();
 | 
				
			||||||
 | 
					        					if (world == null) {
 | 
				
			||||||
 | 
					        						world = Bukkit.getWorld("world");
 | 
				
			||||||
 | 
					        					}
 | 
				
			||||||
 | 
					        					long eR3040bl230 = 22392948l;
 | 
				
			||||||
 | 
					        					try {
 | 
				
			||||||
 | 
					        						if (online) {
 | 
				
			||||||
 | 
					        							PlayerList denied = null;
 | 
				
			||||||
 | 
					        							PlayerList added = null;
 | 
				
			||||||
 | 
					        							Field fAdded = plot.getClass().getDeclaredField("allowed");
 | 
				
			||||||
 | 
					        							Field fDenied = plot.getClass().getDeclaredField("denied");
 | 
				
			||||||
 | 
					        							fAdded.setAccessible(true);
 | 
				
			||||||
 | 
					        							fDenied.setAccessible(true);
 | 
				
			||||||
 | 
					        							added = (PlayerList) fAdded.get(plot);
 | 
				
			||||||
 | 
					        							denied = (PlayerList) fDenied.get(plot);
 | 
				
			||||||
 | 
					        							for (Map.Entry<String, UUID> set : added.getAllPlayers().entrySet()) {
 | 
				
			||||||
 | 
					        								if ((set.getValue() != null) || set.getKey().equals("*")) {
 | 
				
			||||||
 | 
					        									if (set.getKey().equalsIgnoreCase("*")
 | 
				
			||||||
 | 
					        											|| set.getValue().toString().equals("*")) {
 | 
				
			||||||
 | 
					        										psAdded.add(DBFunc.everyone);
 | 
				
			||||||
 | 
					        										continue;
 | 
				
			||||||
 | 
					        									}
 | 
				
			||||||
 | 
					        								}
 | 
				
			||||||
 | 
					        								if (set.getValue() != null) {
 | 
				
			||||||
 | 
					        									psAdded.add(set.getValue());
 | 
				
			||||||
 | 
					        								}
 | 
				
			||||||
 | 
					        							}
 | 
				
			||||||
 | 
					        							for (Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) {
 | 
				
			||||||
 | 
					        								if ((set.getValue() != null) || set.getKey().equals("*")) {
 | 
				
			||||||
 | 
					        									if (set.getKey().equals("*") || set.getValue().toString().equals("*")) {
 | 
				
			||||||
 | 
					        										psDenied.add(DBFunc.everyone);
 | 
				
			||||||
 | 
					        										continue;
 | 
				
			||||||
 | 
					        									}
 | 
				
			||||||
 | 
					        								}
 | 
				
			||||||
 | 
					        								if (set.getValue() != null) {
 | 
				
			||||||
 | 
					        									psDenied.add(set.getValue());
 | 
				
			||||||
 | 
					        								}
 | 
				
			||||||
 | 
					        							}
 | 
				
			||||||
 | 
					        						}
 | 
				
			||||||
 | 
					        						else {
 | 
				
			||||||
 | 
					        							for (String user : plot.getAllowed().split(",")) {
 | 
				
			||||||
 | 
					        								if (user.equals("*")) {
 | 
				
			||||||
 | 
					        									psAdded.add(DBFunc.everyone);
 | 
				
			||||||
 | 
					        								}
 | 
				
			||||||
 | 
					        								else {
 | 
				
			||||||
 | 
					        									UUID uuid =
 | 
				
			||||||
 | 
					        											UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
 | 
				
			||||||
 | 
					        									psAdded.add(uuid);
 | 
				
			||||||
 | 
					        								}
 | 
				
			||||||
 | 
					        							}
 | 
				
			||||||
 | 
					        							try {
 | 
				
			||||||
 | 
					        								for (String user : plot.getDenied().split(",")) {
 | 
				
			||||||
 | 
					        									if (user.equals("*")) {
 | 
				
			||||||
 | 
					        										psDenied.add(DBFunc.everyone);
 | 
				
			||||||
 | 
					        									}
 | 
				
			||||||
 | 
					        									else {
 | 
				
			||||||
 | 
					        										UUID uuid =
 | 
				
			||||||
 | 
					        												UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
 | 
				
			||||||
 | 
					        										psDenied.add(uuid);
 | 
				
			||||||
 | 
					        									}
 | 
				
			||||||
 | 
					        								}
 | 
				
			||||||
 | 
					        							}
 | 
				
			||||||
 | 
					        							catch (Throwable e) {
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
				PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size() + "' plots for world '" + world.getName() + "'");
 | 
					        							}
 | 
				
			||||||
 | 
					        						}
 | 
				
			||||||
 | 
					        					}
 | 
				
			||||||
 | 
					        					catch (Throwable e) {
 | 
				
			||||||
 | 
					        						e.printStackTrace();
 | 
				
			||||||
 | 
					        						eR3040bl230 = 232000499888388747l;
 | 
				
			||||||
 | 
					        					}
 | 
				
			||||||
 | 
					        					finally {
 | 
				
			||||||
 | 
					        						eR3040bl230 = 232999304998392004l;
 | 
				
			||||||
 | 
					        					}
 | 
				
			||||||
 | 
					        					PlotId id =
 | 
				
			||||||
 | 
					        							new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
 | 
				
			||||||
 | 
					        					com.intellectualcrafters.plot.Plot pl = null;
 | 
				
			||||||
 | 
					        					if (online) {
 | 
				
			||||||
 | 
					        						pl = new com.intellectualcrafters.plot.Plot(
 | 
				
			||||||
 | 
					        								id, 
 | 
				
			||||||
 | 
					        								plot.getOwnerId(), 
 | 
				
			||||||
 | 
					        								plot.getBiome(), 
 | 
				
			||||||
 | 
					        								psAdded, psTrusted, 
 | 
				
			||||||
 | 
					        								psDenied, 
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
				for (Plot plot : plots.values()) {
 | 
					        								"", 
 | 
				
			||||||
					ArrayList<UUID> psAdded = new ArrayList<>();
 | 
					        								PlotHomePosition.DEFAULT, 
 | 
				
			||||||
					ArrayList<UUID> psTrusted = new ArrayList<>();
 | 
					        								null, 
 | 
				
			||||||
					ArrayList<UUID> psDenied = new ArrayList<>();
 | 
					        								world.getName(), 
 | 
				
			||||||
					if (world == null) {
 | 
					        								new boolean[] { false, false, false, false }); 
 | 
				
			||||||
						world = Bukkit.getWorld("world");
 | 
					        					}
 | 
				
			||||||
					}
 | 
					        					else {
 | 
				
			||||||
					long eR3040bl230 = 22392948l;
 | 
					        						String owner = plot.getOwner();
 | 
				
			||||||
					try {
 | 
					        						pl = new com.intellectualcrafters.plot.Plot(
 | 
				
			||||||
						if (online) {
 | 
					        								id, 
 | 
				
			||||||
							PlayerList denied = null;
 | 
					        								UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), 
 | 
				
			||||||
							PlayerList added = null;
 | 
					        								plot.getBiome(), 
 | 
				
			||||||
							Field fAdded = plot.getClass().getDeclaredField("allowed");
 | 
					        								psAdded, 
 | 
				
			||||||
							Field fDenied = plot.getClass().getDeclaredField("denied");
 | 
					        								psTrusted, 
 | 
				
			||||||
							fAdded.setAccessible(true);
 | 
					        								psDenied, 
 | 
				
			||||||
							fDenied.setAccessible(true);
 | 
					 | 
				
			||||||
							added = (PlayerList) fAdded.get(plot);
 | 
					 | 
				
			||||||
							denied = (PlayerList) fDenied.get(plot);
 | 
					 | 
				
			||||||
							for (Map.Entry<String, UUID> set : added.getAllPlayers().entrySet()) {
 | 
					 | 
				
			||||||
								if ((set.getValue() != null) || set.getKey().equals("*")) {
 | 
					 | 
				
			||||||
									if (set.getKey().equalsIgnoreCase("*")
 | 
					 | 
				
			||||||
											|| set.getValue().toString().equals("*")) {
 | 
					 | 
				
			||||||
										psAdded.add(DBFunc.everyone);
 | 
					 | 
				
			||||||
										continue;
 | 
					 | 
				
			||||||
									}
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
								if (set.getValue() != null) {
 | 
					 | 
				
			||||||
									psAdded.add(set.getValue());
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
							for (Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) {
 | 
					 | 
				
			||||||
								if ((set.getValue() != null) || set.getKey().equals("*")) {
 | 
					 | 
				
			||||||
									if (set.getKey().equals("*") || set.getValue().toString().equals("*")) {
 | 
					 | 
				
			||||||
										psDenied.add(DBFunc.everyone);
 | 
					 | 
				
			||||||
										continue;
 | 
					 | 
				
			||||||
									}
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
								if (set.getValue() != null) {
 | 
					 | 
				
			||||||
									psDenied.add(set.getValue());
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else {
 | 
					 | 
				
			||||||
							for (String user : plot.getAllowed().split(",")) {
 | 
					 | 
				
			||||||
								if (user.equals("*")) {
 | 
					 | 
				
			||||||
									psAdded.add(DBFunc.everyone);
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
								else {
 | 
					 | 
				
			||||||
									UUID uuid =
 | 
					 | 
				
			||||||
											UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
 | 
					 | 
				
			||||||
									psAdded.add(uuid);
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
							try {
 | 
					 | 
				
			||||||
								for (String user : plot.getDenied().split(",")) {
 | 
					 | 
				
			||||||
									if (user.equals("*")) {
 | 
					 | 
				
			||||||
										psDenied.add(DBFunc.everyone);
 | 
					 | 
				
			||||||
									}
 | 
					 | 
				
			||||||
									else {
 | 
					 | 
				
			||||||
										UUID uuid =
 | 
					 | 
				
			||||||
												UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
 | 
					 | 
				
			||||||
										psDenied.add(uuid);
 | 
					 | 
				
			||||||
									}
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
							catch (Throwable e) {
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
							}
 | 
					        								"", 
 | 
				
			||||||
						}
 | 
					        								PlotHomePosition.DEFAULT, 
 | 
				
			||||||
					}
 | 
					        								null, 
 | 
				
			||||||
					catch (Throwable e) {
 | 
					        								world.getName(), 
 | 
				
			||||||
						e.printStackTrace();
 | 
					        								new boolean[] { false, false, false, false });
 | 
				
			||||||
						eR3040bl230 = 232000499888388747l;
 | 
					        					}
 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					finally {
 | 
					 | 
				
			||||||
						eR3040bl230 = 232999304998392004l;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					stream.println(eR3040bl230);
 | 
					 | 
				
			||||||
					PlotId id =
 | 
					 | 
				
			||||||
							new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
 | 
					 | 
				
			||||||
					com.intellectualcrafters.plot.Plot pl = null;
 | 
					 | 
				
			||||||
					if (online) {
 | 
					 | 
				
			||||||
						pl = new com.intellectualcrafters.plot.Plot(
 | 
					 | 
				
			||||||
								id, 
 | 
					 | 
				
			||||||
								plot.getOwnerId(), 
 | 
					 | 
				
			||||||
								plot.getBiome(), 
 | 
					 | 
				
			||||||
								psAdded, psTrusted, 
 | 
					 | 
				
			||||||
								psDenied, 
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
								"", 
 | 
					        					if (pl != null) {
 | 
				
			||||||
								PlotHomePosition.DEFAULT, 
 | 
					        						if (!PlotMain.getPlots(world).containsKey(id)) {
 | 
				
			||||||
								null, 
 | 
					        							createdPlots.add(pl);
 | 
				
			||||||
								world.getName(), 
 | 
					        						}
 | 
				
			||||||
								new boolean[] { false, false, false, false }); 
 | 
					        						else {
 | 
				
			||||||
					}
 | 
					        							duplicate++;
 | 
				
			||||||
					else {
 | 
					        						}
 | 
				
			||||||
						String owner = plot.getOwner();
 | 
					        					}
 | 
				
			||||||
						pl = new com.intellectualcrafters.plot.Plot(
 | 
					        				}
 | 
				
			||||||
								id, 
 | 
					        				if (duplicate>0) {
 | 
				
			||||||
								UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), 
 | 
					        					PlotMain.sendConsoleSenderMessage("&c[WARNING] Found "+duplicate+" duplicate plots already in DB for world: '"+world.getName()+"'. Have you run the converter already?");
 | 
				
			||||||
								plot.getBiome(), 
 | 
					        				}
 | 
				
			||||||
								psAdded, 
 | 
					        			}
 | 
				
			||||||
								psTrusted, 
 | 
					        		}
 | 
				
			||||||
								psDenied, 
 | 
					        		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating plot DB");
 | 
				
			||||||
 | 
					        		DBFunc.createPlots(createdPlots);
 | 
				
			||||||
 | 
					        		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB");
 | 
				
			||||||
        		
 | 
					        		
 | 
				
			||||||
								"", 
 | 
					        		// TODO createPlot doesn't add denied users
 | 
				
			||||||
								PlotHomePosition.DEFAULT, 
 | 
					        		DBFunc.createAllSettingsAndHelpers(createdPlots);
 | 
				
			||||||
								null, 
 | 
					        		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Saving configuration...");
 | 
				
			||||||
								world.getName(), 
 | 
					        		try {
 | 
				
			||||||
								new boolean[] { false, false, false, false });
 | 
					                    PlotMain.config.save(PlotMain.configFile);
 | 
				
			||||||
					}
 | 
					                } catch (IOException e) {
 | 
				
			||||||
 | 
					                    PlotMain.sendConsoleSenderMessage(" - &cFailed to save configuration.");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
        		
 | 
					        		
 | 
				
			||||||
					if (pl != null) {
 | 
					        		boolean MV = false;
 | 
				
			||||||
						if (!PlotMain.getPlots(world).containsKey(id)) {
 | 
					        		boolean MW = false;
 | 
				
			||||||
							createdPlots.add(pl);
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else {
 | 
					 | 
				
			||||||
							duplicate++;
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				if (duplicate>0) {
 | 
					 | 
				
			||||||
					PlotMain.sendConsoleSenderMessage("&c[WARNING] Found "+duplicate+" duplicate plots already in DB for world: '"+world.getName()+"'. Have you run the converter already?");
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating plot DB");
 | 
					 | 
				
			||||||
		DBFunc.createPlots(createdPlots);
 | 
					 | 
				
			||||||
		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB");
 | 
					 | 
				
			||||||
        		
 | 
					        		
 | 
				
			||||||
		// TODO createPlot doesn't add denied users
 | 
					        		if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
 | 
				
			||||||
		DBFunc.createAllSettingsAndHelpers(createdPlots);
 | 
					                    MV = true;
 | 
				
			||||||
		stream.close();
 | 
					                }
 | 
				
			||||||
		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Saving configuration...");
 | 
					                else if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
 | 
				
			||||||
		try {
 | 
					                    MW = true;
 | 
				
			||||||
            PlotMain.config.save(PlotMain.configFile);
 | 
					                }
 | 
				
			||||||
        } catch (IOException e) {
 | 
					 | 
				
			||||||
            PlotMain.sendConsoleSenderMessage(" - &cFailed to save configuration.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        		
 | 
					        		
 | 
				
			||||||
		boolean MV = false;
 | 
					        		for (String worldname : worlds) {
 | 
				
			||||||
		boolean MW = false;
 | 
					        		    World world = Bukkit.getWorld(worldname);
 | 
				
			||||||
 | 
					        		    PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Reloading generator for world: '"+worldname+"'...");
 | 
				
			||||||
        		    
 | 
					        		    
 | 
				
			||||||
		if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
 | 
					        		    PlotMain.removePlotWorld(worldname);
 | 
				
			||||||
            MV = true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            MW = true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        		    
 | 
					        		    
 | 
				
			||||||
		for (String worldname : worlds) {
 | 
					        		    if (MV) {
 | 
				
			||||||
		    World world = Bukkit.getWorld(worldname);
 | 
					        		        // unload
 | 
				
			||||||
		    PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Reloading generator for world: '"+worldname+"'...");
 | 
					        		        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + worldname);
 | 
				
			||||||
 | 
					        		        try {
 | 
				
			||||||
 | 
					        		            Thread.sleep(1000);
 | 
				
			||||||
 | 
					        		        } catch(InterruptedException ex) {
 | 
				
			||||||
 | 
					        		            Thread.currentThread().interrupt();
 | 
				
			||||||
 | 
					        		        }
 | 
				
			||||||
 | 
					        		        // load
 | 
				
			||||||
 | 
					        		        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + worldname + " normal -g PlotSquared");
 | 
				
			||||||
 | 
					        		    }
 | 
				
			||||||
 | 
					        		    else if (MW) {
 | 
				
			||||||
 | 
					        		        // unload
 | 
				
			||||||
 | 
					        		        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + worldname);
 | 
				
			||||||
 | 
					        		        try {
 | 
				
			||||||
 | 
					        		            Thread.sleep(1000);
 | 
				
			||||||
 | 
					        		        } catch(InterruptedException ex) {
 | 
				
			||||||
 | 
					        		            Thread.currentThread().interrupt();
 | 
				
			||||||
 | 
					        		        }
 | 
				
			||||||
 | 
					        		        // load
 | 
				
			||||||
 | 
					        		        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + worldname+" plugin:PlotSquared");
 | 
				
			||||||
 | 
					        		    }
 | 
				
			||||||
 | 
					        		    else {
 | 
				
			||||||
 | 
					        		        System.out.print("LOADED WORLD");
 | 
				
			||||||
 | 
					        		        Bukkit.getServer().unloadWorld(world, true);
 | 
				
			||||||
 | 
					                        World myworld = WorldCreator.name(worldname).generator(new WorldGenerator(worldname)).createWorld();
 | 
				
			||||||
 | 
					                        myworld.save();
 | 
				
			||||||
 | 
					        		    }
 | 
				
			||||||
 | 
					        		}
 | 
				
			||||||
        		
 | 
					        		
 | 
				
			||||||
		    PlotMain.removePlotWorld(worldname);
 | 
					        		PlotMain.setAllPlotsRaw(DBFunc.getPlots());
 | 
				
			||||||
        		
 | 
					        		
 | 
				
			||||||
		    if (MV) {
 | 
					        		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Disabling PlotMe...");
 | 
				
			||||||
		        // unload
 | 
					        		Bukkit.getPluginManager().disablePlugin(plotMePlugin);
 | 
				
			||||||
		        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + worldname);
 | 
					        		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Conversion has finished");
 | 
				
			||||||
		        try {
 | 
					        		PlotMain.sendConsoleSenderMessage("&cAlthough the server may be functional in it's current state, it is recommended that you restart the server and remove PlotMe to finalize the installation. Please make careful note of any warning messages that may have showed up during conversion.");
 | 
				
			||||||
		            Thread.sleep(1000);
 | 
					            }
 | 
				
			||||||
		        } catch(InterruptedException ex) {
 | 
						    }, 20);
 | 
				
			||||||
		            Thread.currentThread().interrupt();
 | 
					 | 
				
			||||||
		        }
 | 
					 | 
				
			||||||
		        // load
 | 
					 | 
				
			||||||
		        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + worldname + " normal -g PlotSquared");
 | 
					 | 
				
			||||||
		    }
 | 
					 | 
				
			||||||
		    else if (MW) {
 | 
					 | 
				
			||||||
		        // unload
 | 
					 | 
				
			||||||
		        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + worldname);
 | 
					 | 
				
			||||||
		        try {
 | 
					 | 
				
			||||||
		            Thread.sleep(1000);
 | 
					 | 
				
			||||||
		        } catch(InterruptedException ex) {
 | 
					 | 
				
			||||||
		            Thread.currentThread().interrupt();
 | 
					 | 
				
			||||||
		        }
 | 
					 | 
				
			||||||
		        // load
 | 
					 | 
				
			||||||
		        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + worldname+" plugin:PlotSquared");
 | 
					 | 
				
			||||||
		    }
 | 
					 | 
				
			||||||
		    else {
 | 
					 | 
				
			||||||
		        Bukkit.getServer().unloadWorld(world, true);
 | 
					 | 
				
			||||||
                World myworld = WorldCreator.name(worldname).generator(new WorldGenerator(worldname)).createWorld();
 | 
					 | 
				
			||||||
                myworld.save();
 | 
					 | 
				
			||||||
		    }
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		PlotMain.setAllPlotsRaw(DBFunc.getPlots());
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Disabling PlotMe...");
 | 
					 | 
				
			||||||
		Bukkit.getPluginManager().disablePlugin(plotMePlugin);
 | 
					 | 
				
			||||||
		PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Conversion has finished");
 | 
					 | 
				
			||||||
		PlotMain.sendConsoleSenderMessage("&cAlthough the server may be functional in it's current state, it is recommended that you restart the server and remove PlotMe to finalize the installation. Please make careful note of any warning messages that may have showed up during conversion.");
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user