net.minecraft.world.storage.SaveHandler Java Examples
The following examples show how to use
net.minecraft.world.storage.SaveHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftServer.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override public File getWorldContainer() { // Cauldron start - return the proper container if (DimensionManager.getWorld(0) != null) { return ((SaveHandler) DimensionManager.getWorld(0).getSaveHandler()).getWorldDirectory(); } // Cauldron end if (this.getServer().anvilFile != null) { return this.getServer().anvilFile; } if (container == null) { container = new File(configuration.getString("settings.world-container", ".")); } return container; }
Example #2
Source File: CraftServer.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override public OfflinePlayer[] getOfflinePlayers() { SaveHandler storage = (SaveHandler) console.worlds[0].getSaveHandler(); String[] files = storage.getPlayerDir().list(new DatFileFilter()); Set<OfflinePlayer> players = new HashSet<OfflinePlayer>(); for (String file : files) { try { players.add(getOfflinePlayer(UUID.fromString(file.substring(0, file.length() - 4)))); } catch (IllegalArgumentException ex) { // Who knows what is in this directory, just ignore invalid files } } players.addAll(getOnlinePlayers()); return players.toArray(new OfflinePlayer[players.size()]); }
Example #3
Source File: CraftServer.java From Thermos with GNU General Public License v3.0 | 6 votes |
@Override public OfflinePlayer[] getOfflinePlayers() { net.minecraft.world.storage.SaveHandler storage = (net.minecraft.world.storage.SaveHandler) console.worlds.get(0).getSaveHandler(); String[] files = storage.getPlayerDir().list(new DatFileFilter()); Set<OfflinePlayer> players = new HashSet<OfflinePlayer>(); for (String file : files) { try { players.add(getOfflinePlayer(UUID.fromString(file.substring(0, file.length() - 4)))); } catch (IllegalArgumentException ex) { // Who knows what is in this directory, just ignore invalid files } } players.addAll(getOnlinePlayers()); return players.toArray(new OfflinePlayer[players.size()]); }
Example #4
Source File: TileInfusionClaw.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
private void loadResearch(EntityPlayer fakePlayer) { boolean online = false; for(String username : MinecraftServer.getServer().getAllUsernames()) { if(username.equals(player)) { online = true; break; } } if(online) { this.research = ResearchManager.getResearchForPlayer(player); } else { if(research == null) { Thaumcraft.proxy.getCompletedResearch().put(fakePlayer.getCommandSenderName(), new ArrayList<String>()); IPlayerFileData playerNBTManagerObj = MinecraftServer.getServer().worldServerForDimension(0).getSaveHandler().getSaveHandler(); SaveHandler sh = (SaveHandler)playerNBTManagerObj; File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, "playersDirectory", "field_75771_c"); File file1 = new File(dir, player + ".thaum"); File file2 = new File(dir, player + ".thaumbak"); ResearchManager.loadPlayerData(fakePlayer, file1, file2, false); this.research = ResearchManager.getResearchForPlayerSafe(fakePlayer.getCommandSenderName()); } } Thaumcraft.proxy.getCompletedResearch().put(fakePlayer.getCommandSenderName(), research == null ? new ArrayList<String>() : research); }
Example #5
Source File: NBTStructureLoader.java From BoundingBoxOutlineReloaded with MIT License | 5 votes |
void configure(SaveHandler saveHandler, File worldDirectory) { this.saveHandler = saveHandler; if (worldDirectory != null) { this.chunkSaveLocation = new File(dimensionId.getDimensionType().getDirectory(worldDirectory), "region"); this.chunkLoader = new ChunkLoader(this.chunkSaveLocation); } }
Example #6
Source File: CraftOfflinePlayer.java From Kettle with GNU General Public License v3.0 | 4 votes |
protected CraftOfflinePlayer(CraftServer server, GameProfile profile) { this.server = server; this.profile = profile; this.storage = (SaveHandler) (server.console.worldServerList.get(0).getSaveHandler()); }
Example #7
Source File: NBTStructureLoader.java From BoundingBoxOutlineReloaded with MIT License | 4 votes |
NBTStructureLoader(DimensionId dimensionId, SaveHandler saveHandler, File worldDirectory) { this.dimensionId = dimensionId; this.configure(saveHandler, worldDirectory); }
Example #8
Source File: MoCTools.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
/** * Reduces the counter on the offline player * * @param playername */ public static void reduceTamedByOfflinePlayer(String playername) { NBTTagCompound compound = ((SaveHandler) ((WorldServer) MinecraftServer.getServer().worldServerForDimension(0)).getSaveHandler()).getPlayerData(playername); if (compound != null && compound.hasKey("ForgeData")) { NBTTagCompound nbtt = compound.getCompoundTag("ForgeData"); int count = nbtt.getInteger("NumberTamed"); //System.out.println("tamed entities for player " + playername + " =" + count); count--; if (count < 0) { count = 0; } nbtt.setInteger("NumberTamed", count); compound.setCompoundTag("ForgeData", nbtt); try { SaveHandler saveHandler = ((SaveHandler) ((WorldServer) MinecraftServer.getServer().worldServerForDimension(0)).getSaveHandler()); // as long as we know the world folder name we can generate the path to players directory // still need to test how other worlds will work String playersDirectory = ".\\" + saveHandler.getWorldDirectoryName() + "\\players\\"; File playerFile = new File(playersDirectory + playername + ".dat"); File playerFileNew = new File(playersDirectory, playername + ".tmp"); //System.out.println("playerFile = " + playerFile + ", playerFileNew = " + playerFileNew + ", playerFile parent = " + playerFile.getParent()); CompressedStreamTools.writeCompressed(compound, new FileOutputStream(playerFileNew)); if (playerFile.exists()) { playerFile.delete(); } playerFileNew.renameTo(playerFile); // test to see if changes took effect compound = ((SaveHandler) ((WorldServer) MinecraftServer.getServer().worldServerForDimension(0)).getSaveHandler()).getPlayerData(playername); if (compound.hasKey("ForgeData")) { NBTTagCompound nbttest = compound.getCompoundTag("ForgeData"); //System.out.println("tamed entities for player " + playername + " is now " + nbttest.getInteger("NumberTamed")); } } catch (Exception e) { e.printStackTrace(); } } }