mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 17:43:44 +01:00 
			
		
		
		
	not much actually changed, but it seems to be working fine now.
This commit is contained in:
		| @@ -140,7 +140,6 @@ public class DBFunc { | |||||||
|                      |                      | ||||||
|                     stmt.setInt((counter * 2) + 1, id); |                     stmt.setInt((counter * 2) + 1, id); | ||||||
|                     stmt.setString((counter * 2) + 2, helper.toString()); |                     stmt.setString((counter * 2) + 2, helper.toString()); | ||||||
|  |  | ||||||
|                     counter++; |                     counter++; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -214,7 +213,6 @@ public class DBFunc { | |||||||
|      */ |      */ | ||||||
|     public static void createTables(String database, boolean add_constraint) throws SQLException { |     public static void createTables(String database, boolean add_constraint) throws SQLException { | ||||||
|         boolean mysql = database.equals("mysql"); |         boolean mysql = database.equals("mysql"); | ||||||
|  |  | ||||||
|         Statement stmt = connection.createStatement(); |         Statement stmt = connection.createStatement(); | ||||||
|  |  | ||||||
|         if (mysql) { |         if (mysql) { | ||||||
| @@ -236,7 +234,6 @@ public class DBFunc { | |||||||
|             stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + "  `plot_plot_id` INT(11) NOT NULL," + "  `biome` VARCHAR(45) DEFAULT 'FOREST'," + "  `rain` INT(1) DEFAULT 0," + "  `custom_time` TINYINT(1) DEFAULT '0'," + "  `time` INT(11) DEFAULT '8000'," + "  `deny_entry` TINYINT(1) DEFAULT '0'," + "  `alias` VARCHAR(50) DEFAULT NULL," + "  `flags` VARCHAR(512) DEFAULT NULL," + "  `merged` INT(11) DEFAULT NULL," + "  `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + "  PRIMARY KEY (`plot_plot_id`)" + ")"); |             stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + "  `plot_plot_id` INT(11) NOT NULL," + "  `biome` VARCHAR(45) DEFAULT 'FOREST'," + "  `rain` INT(1) DEFAULT 0," + "  `custom_time` TINYINT(1) DEFAULT '0'," + "  `time` INT(11) DEFAULT '8000'," + "  `deny_entry` TINYINT(1) DEFAULT '0'," + "  `alias` VARCHAR(50) DEFAULT NULL," + "  `flags` VARCHAR(512) DEFAULT NULL," + "  `merged` INT(11) DEFAULT NULL," + "  `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + "  PRIMARY KEY (`plot_plot_id`)" + ")"); | ||||||
|             stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))"); |             stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         stmt.executeBatch(); |         stmt.executeBatch(); | ||||||
|         stmt.clearBatch(); |         stmt.clearBatch(); | ||||||
|         stmt.close(); |         stmt.close(); | ||||||
|   | |||||||
| @@ -4,15 +4,18 @@ import java.io.PrintStream; | |||||||
| import java.lang.reflect.Field; | import java.lang.reflect.Field; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
|  | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  |  | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
|  | import org.bukkit.OfflinePlayer; | ||||||
| import org.bukkit.World; | import org.bukkit.World; | ||||||
|  |  | ||||||
| import com.intellectualcrafters.plot.PlotHomePosition; | import com.intellectualcrafters.plot.PlotHomePosition; | ||||||
| import com.intellectualcrafters.plot.PlotId; | import com.intellectualcrafters.plot.PlotId; | ||||||
| import com.intellectualcrafters.plot.PlotMain; | import com.intellectualcrafters.plot.PlotMain; | ||||||
|  | import com.intellectualcrafters.plot.uuid.UUIDFetcher; | ||||||
| import com.worldcretornica.plotme.PlayerList; | import com.worldcretornica.plotme.PlayerList; | ||||||
| import com.worldcretornica.plotme.Plot; | import com.worldcretornica.plotme.Plot; | ||||||
| import com.worldcretornica.plotme.PlotManager; | import com.worldcretornica.plotme.PlotManager; | ||||||
| @@ -30,16 +33,14 @@ public class PlotMeConverter { | |||||||
|  |  | ||||||
|     public void runAsync() throws Exception { |     public void runAsync() throws Exception { | ||||||
|  |  | ||||||
|         Bukkit.getOnlineMode(); |  | ||||||
|  |  | ||||||
|         final PrintStream stream = new PrintStream("converter_log.txt"); |         final PrintStream stream = new PrintStream("converter_log.txt"); | ||||||
|  |  | ||||||
|         PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has started"); |  | ||||||
|         Bukkit.getScheduler().runTaskAsynchronously(this.plugin, new Runnable() { |         Bukkit.getScheduler().runTaskAsynchronously(this.plugin, new Runnable() { | ||||||
|             @Override |             @Override | ||||||
|             public void run() { |             public void run() { | ||||||
|  |                 PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has started"); | ||||||
|                 ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>(); |                 ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>(); | ||||||
|                 HashMap<String, UUID> uuidMap = new HashMap<String, UUID>(); |                 Map<String, UUID> uuidMap = new HashMap<String, UUID>(); | ||||||
|                 for (World world : Bukkit.getWorlds()) { |                 for (World world : Bukkit.getWorlds()) { | ||||||
|                     HashMap<String, Plot> plots = PlotManager.getPlots(world); |                     HashMap<String, Plot> plots = PlotManager.getPlots(world); | ||||||
|                     if (plots != null) { |                     if (plots != null) { | ||||||
| @@ -48,10 +49,26 @@ public class PlotMeConverter { | |||||||
|                         // - Plugin doesn't display a message if database is not |                         // - Plugin doesn't display a message if database is not | ||||||
|                         // setup at all |                         // 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("Converting " + plots.size() + " plots for '" + world.toString() + "'..."); |                         PlotMain.sendConsoleSenderMessage("Converting " + plots.size() + " plots for '" + world.toString() + "'..."); | ||||||
|                         for (Plot plot : plots.values()) { |                         for (Plot plot : plots.values()) { | ||||||
|                             PlayerList denied = null; |  | ||||||
|                             PlayerList added = null; |  | ||||||
|                             ArrayList<UUID> psAdded = new ArrayList<>(); |                             ArrayList<UUID> psAdded = new ArrayList<>(); | ||||||
|                             ArrayList<UUID> psTrusted = new ArrayList<>(); |                             ArrayList<UUID> psTrusted = new ArrayList<>(); | ||||||
|                             ArrayList<UUID> psDenied = new ArrayList<>(); |                             ArrayList<UUID> psDenied = new ArrayList<>(); | ||||||
| @@ -60,10 +77,9 @@ public class PlotMeConverter { | |||||||
|                             } |                             } | ||||||
|                             long eR3040bl230 = 22392948l; |                             long eR3040bl230 = 22392948l; | ||||||
|                             try { |                             try { | ||||||
|  |                                 PlayerList denied = null; | ||||||
|                                 // TODO It just comes up with a |                                 PlayerList added = null; | ||||||
|                                 // NoSuchFieldException. Y U NO WORK!!! (I |                                 if (Bukkit.getServer().getOnlineMode()) { | ||||||
|                                 // didn't change anything here btw) |  | ||||||
|                                     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); | ||||||
| @@ -76,48 +92,24 @@ public class PlotMeConverter { | |||||||
|                                                 psAdded.add(DBFunc.everyone); |                                                 psAdded.add(DBFunc.everyone); | ||||||
|                                                 continue; |                                                 continue; | ||||||
|                                             } |                                             } | ||||||
|                                     } else { |  | ||||||
|  |  | ||||||
|                                         /* |  | ||||||
|                                          * Does this work for offline mode |  | ||||||
|                                          * servers? |  | ||||||
|                                          */ |  | ||||||
|  |  | ||||||
|                                         if (uuidMap.containsKey(set.getKey())) { |  | ||||||
|                                             psAdded.add(uuidMap.get(set.getKey())); |  | ||||||
|                                             continue; |  | ||||||
|                                         } |  | ||||||
|                                         UUID value = Bukkit.getOfflinePlayer(set.getKey()).getUniqueId(); |  | ||||||
|                                         if (value != null) { |  | ||||||
|                                             uuidMap.put(set.getKey(), value); |  | ||||||
|                                             psAdded.add(value); |  | ||||||
|                                             continue; |  | ||||||
|                                         } |  | ||||||
|                                         } |                                         } | ||||||
|  |                                         if (set.getValue()!=null) { | ||||||
|                                             psAdded.add(set.getValue()); |                                             psAdded.add(set.getValue()); | ||||||
|                                         } |                                         } | ||||||
|  |                                     } | ||||||
|                                     for (Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) { |                                     for (Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) { | ||||||
|                                         if ((set.getValue() != null) || set.getKey().equals("*")) { |                                         if ((set.getValue() != null) || set.getKey().equals("*")) { | ||||||
|                                             if (set.getKey().equals("*") || set.getValue().toString().equals("*")) { |                                             if (set.getKey().equals("*") || set.getValue().toString().equals("*")) { | ||||||
|                                                 psDenied.add(DBFunc.everyone); |                                                 psDenied.add(DBFunc.everyone); | ||||||
|                                                 continue; |                                                 continue; | ||||||
|                                             } |                                             } | ||||||
|                                     } else { |  | ||||||
|                                         if (uuidMap.containsKey(set.getKey())) { |  | ||||||
|                                             psDenied.add(uuidMap.get(set.getKey())); |  | ||||||
|                                             continue; |  | ||||||
|                                         } |  | ||||||
|                                         UUID value = Bukkit.getOfflinePlayer(set.getKey()).getUniqueId(); |  | ||||||
|                                         if (value != null) { |  | ||||||
|                                             uuidMap.put(set.getKey(), value); |  | ||||||
|                                             psDenied.add(value); |  | ||||||
|                                             continue; |  | ||||||
|                                         } |  | ||||||
|                                         } |                                         } | ||||||
|  |                                         if (set.getValue()!=null) { | ||||||
|                                             psDenied.add(set.getValue()); |                                             psDenied.add(set.getValue()); | ||||||
|                                         } |                                         } | ||||||
|                             } catch (Exception e) { |                                     } | ||||||
|                                 // Doing it the slow way like a n00b. |                                 } | ||||||
|  |                                 else { | ||||||
|                                     for (String user : plot.getAllowed().split(",")) { |                                     for (String user : plot.getAllowed().split(",")) { | ||||||
|                                         try { |                                         try { | ||||||
|                                             if (user.equals("*")) { |                                             if (user.equals("*")) { | ||||||
| @@ -130,8 +122,10 @@ public class PlotMeConverter { | |||||||
|                                                 psAdded.add(uuid); |                                                 psAdded.add(uuid); | ||||||
|                                             } |                                             } | ||||||
|                                         } catch (Exception e2) { |                                         } catch (Exception e2) { | ||||||
|  |                                             e2.printStackTrace(); | ||||||
|                                         } |                                         } | ||||||
|                                     } |                                     } | ||||||
|  |                                     try { | ||||||
|                                         for (String user : plot.getDenied().split(",")) { |                                         for (String user : plot.getDenied().split(",")) { | ||||||
|                                             try { |                                             try { | ||||||
|                                                 if (user.equals("*")) { |                                                 if (user.equals("*")) { | ||||||
| @@ -144,15 +138,29 @@ public class PlotMeConverter { | |||||||
|                                                     psDenied.add(uuid); |                                                     psDenied.add(uuid); | ||||||
|                                                 } |                                                 } | ||||||
|                                             } catch (Exception e2) { |                                             } catch (Exception e2) { | ||||||
|  |                                                 e2.printStackTrace(); | ||||||
|                                             } |                                             } | ||||||
|                                         } |                                         } | ||||||
|  |                                     } | ||||||
|  |                                     catch (Throwable e) { | ||||||
|  |                                          | ||||||
|  |                                     } | ||||||
|  |                                 } | ||||||
|  |                             } catch (Throwable e) { | ||||||
|  |                                 e.printStackTrace(); | ||||||
|                                 eR3040bl230 = 232000499888388747l; |                                 eR3040bl230 = 232000499888388747l; | ||||||
|                             } finally { |                             } finally { | ||||||
|                                 eR3040bl230 = 232999304998392004l; |                                 eR3040bl230 = 232999304998392004l; | ||||||
|                             } |                             } | ||||||
|                             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 = 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 }); |                             com.intellectualcrafters.plot.Plot pl; | ||||||
|  |                             if (Bukkit.getServer().getOnlineMode()) { | ||||||
|  |                                 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 { | ||||||
|  |                                 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 }); | ||||||
|  |                             } | ||||||
|  |  | ||||||
|                             // TODO createPlot doesn't add helpers / denied |                             // TODO createPlot doesn't add helpers / denied | ||||||
|                             // users |                             // users | ||||||
| @@ -165,10 +173,8 @@ public class PlotMeConverter { | |||||||
|                 DBFunc.createPlots(createdPlots); |                 DBFunc.createPlots(createdPlots); | ||||||
|                 PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Creating settings/helpers DB"); |                 PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Creating settings/helpers DB"); | ||||||
|                 DBFunc.createAllSettingsAndHelpers(createdPlots); |                 DBFunc.createAllSettingsAndHelpers(createdPlots); | ||||||
|  |  | ||||||
|                 stream.close(); |                 stream.close(); | ||||||
|                 PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has finished"); |                 PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has finished"); | ||||||
|  |  | ||||||
|                 // TODO disable PlotMe -> Unload all plot worlds, change the |                 // TODO disable PlotMe -> Unload all plot worlds, change the | ||||||
|                 // generator, restart the server automatically |                 // generator, restart the server automatically | ||||||
|                 // Possibly use multiverse / multiworld if it's to difficult |                 // Possibly use multiverse / multiworld if it's to difficult | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 boy0001
					boy0001