mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 04:48:34 +00:00
Merge remote-tracking branch 'upstream/master' into merge
This commit is contained in:
@ -39,6 +39,7 @@ import com.sk89q.worldedit.session.storage.JsonFileSessionStore;
|
||||
import com.sk89q.worldedit.session.storage.SessionStore;
|
||||
import com.sk89q.worldedit.session.storage.VoidStore;
|
||||
import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors;
|
||||
import com.sk89q.worldedit.extension.platform.Locatable;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
@ -200,6 +201,11 @@ public class SessionManager {
|
||||
&& (owner.hasPermission("worldedit.inventory.unrestricted")
|
||||
|| (config.useInventoryCreativeOverride && (!(owner instanceof Player) || ((Player) owner).getGameMode() == GameModes.CREATIVE)))));
|
||||
|
||||
// Force non-locatable actors to use placeAtPos1
|
||||
if (!(owner instanceof Locatable)) {
|
||||
session.setPlaceAtPos1(true);
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,15 @@ public class JsonFileSessionStore implements SessionStore {
|
||||
try (Closer closer = Closer.create()) {
|
||||
FileReader fr = closer.register(new FileReader(file));
|
||||
BufferedReader br = closer.register(new BufferedReader(fr));
|
||||
return gson.fromJson(br, LocalSession.class);
|
||||
LocalSession session = gson.fromJson(br, LocalSession.class);
|
||||
if (session == null) {
|
||||
log.warn("Loaded a null session from {}, creating new session", file);
|
||||
if (!file.delete()) {
|
||||
log.warn("Failed to delete corrupted session {}", file);
|
||||
}
|
||||
session = new LocalSession();
|
||||
}
|
||||
return session;
|
||||
} catch (JsonParseException e) {
|
||||
throw new IOException(e);
|
||||
} catch (FileNotFoundException e) {
|
||||
@ -98,6 +106,7 @@ public class JsonFileSessionStore implements SessionStore {
|
||||
|
||||
@Override
|
||||
public void save(UUID id, LocalSession session) throws IOException {
|
||||
checkNotNull(session);
|
||||
File finalFile = getPath(id);
|
||||
File tempFile = new File(finalFile.getParentFile(), finalFile.getName() + ".tmp");
|
||||
|
||||
@ -115,6 +124,10 @@ public class JsonFileSessionStore implements SessionStore {
|
||||
}
|
||||
}
|
||||
|
||||
if (tempFile.length() == 0) {
|
||||
throw new IllegalStateException("Gson wrote zero bytes");
|
||||
}
|
||||
|
||||
if (!tempFile.renameTo(finalFile)) {
|
||||
log.warn("Failed to rename temporary session file to " + finalFile.getPath());
|
||||
}
|
||||
|
Reference in New Issue
Block a user