Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-07 20:10:06 +01:00
Merge pull request #435 from sk89q/feature/trace-unflushed-sessions
Add tracing for unflushed EditSessions
Dieser Commit ist enthalten in:
Commit
53bc730909
@ -139,6 +139,9 @@ history:
|
|||||||
calculation:
|
calculation:
|
||||||
timeout: 100
|
timeout: 100
|
||||||
|
|
||||||
|
debugging:
|
||||||
|
trace-unflushed-sessions: false
|
||||||
|
|
||||||
wand-item: minecraft:wooden_axe
|
wand-item: minecraft:wooden_axe
|
||||||
shell-save-type:
|
shell-save-type:
|
||||||
no-double-slash: false
|
no-double-slash: false
|
||||||
|
@ -107,7 +107,6 @@ import com.sk89q.worldedit.util.eventbus.EventBus;
|
|||||||
import com.sk89q.worldedit.world.NullWorld;
|
import com.sk89q.worldedit.world.NullWorld;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
@ -235,6 +234,17 @@ public class EditSession implements Extent, AutoCloseable {
|
|||||||
return event.getExtent();
|
return event.getExtent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pkg private for TracedEditSession only, may later become public API
|
||||||
|
boolean commitRequired() {
|
||||||
|
if (isQueueEnabled() && reorderExtent.commitRequired()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (isBatchingChunks() && chunkBatchingExtent.commitRequired()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns on specific features for a normal WorldEdit session, such as
|
* Turns on specific features for a normal WorldEdit session, such as
|
||||||
* {@link #enableQueue() queuing} and {@link #setBatchingChunks(boolean)
|
* {@link #enableQueue() queuing} and {@link #setBatchingChunks(boolean)
|
||||||
|
@ -152,21 +152,24 @@ public class EditSessionFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSession getEditSession(World world, int maxBlocks) {
|
public EditSession getEditSession(World world, int maxBlocks) {
|
||||||
return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, null, maxBlocks, null));
|
return getEditSession(world, maxBlocks, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSession getEditSession(World world, int maxBlocks, Player player) {
|
public EditSession getEditSession(World world, int maxBlocks, Player player) {
|
||||||
return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, player, maxBlocks, null));
|
return getEditSession(world, maxBlocks, null, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag) {
|
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag) {
|
||||||
return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, null, maxBlocks, null));
|
return getEditSession(world, maxBlocks, blockBag, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag, Player player) {
|
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag, Player player) {
|
||||||
|
if (WorldEdit.getInstance().getConfiguration().traceUnflushedSessions) {
|
||||||
|
return new TracedEditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks, null));
|
||||||
|
}
|
||||||
return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks, null));
|
return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ public abstract class LocalConfiguration {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public boolean profile = false;
|
public boolean profile = false;
|
||||||
|
public boolean traceUnflushedSessions = false;
|
||||||
public Set<String> disallowedBlocks = new HashSet<>();
|
public Set<String> disallowedBlocks = new HashSet<>();
|
||||||
public int defaultChangeLimit = -1;
|
public int defaultChangeLimit = -1;
|
||||||
public int maxChangeLimit = -1;
|
public int maxChangeLimit = -1;
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class TracedEditSession extends EditSession {
|
||||||
|
|
||||||
|
TracedEditSession(EventBus eventBus, World world, int maxBlocks, BlockBag blockBag, EditSessionEvent event) {
|
||||||
|
super(eventBus, world, maxBlocks, blockBag, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Throwable stacktrace = new Throwable("Creation trace.");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void finalize() throws Throwable {
|
||||||
|
super.finalize();
|
||||||
|
|
||||||
|
if (commitRequired()) {
|
||||||
|
WorldEdit.logger.warning("####### LEFTOVER BUFFER BLOCKS DETECTED #######");
|
||||||
|
WorldEdit.logger.warning("This means that some code did not flush their EditSession.");
|
||||||
|
WorldEdit.logger.log(Level.WARNING, "Here is a stacktrace from the creation of this EditSession:", stacktrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -72,6 +72,10 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent {
|
|||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean commitRequired() {
|
||||||
|
return batches.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
|
@ -93,6 +93,10 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
|||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean commitRequired() {
|
||||||
|
return stage1.size() > 0 || stage2.size() > 0 || stage3.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||||
BlockState existing = getBlock(location);
|
BlockState existing = getBlock(location);
|
||||||
|
@ -75,6 +75,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
|
|||||||
loadExtra();
|
loadExtra();
|
||||||
|
|
||||||
profile = getBool("profile", profile);
|
profile = getBool("profile", profile);
|
||||||
|
traceUnflushedSessions = getBool("trace-unflushed-sessions", traceUnflushedSessions);
|
||||||
disallowedBlocks = getStringSet("disallowed-blocks", defaultDisallowedBlocks);
|
disallowedBlocks = getStringSet("disallowed-blocks", defaultDisallowedBlocks);
|
||||||
defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit);
|
defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit);
|
||||||
maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit);
|
maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit);
|
||||||
|
@ -54,6 +54,7 @@ public class YAMLConfiguration extends LocalConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
profile = config.getBoolean("debug", profile);
|
profile = config.getBoolean("debug", profile);
|
||||||
|
traceUnflushedSessions = config.getBoolean("debugging.trace-unflushed-sessions", traceUnflushedSessions);
|
||||||
wandItem = convertLegacyItem(config.getString("wand-item", wandItem));
|
wandItem = convertLegacyItem(config.getString("wand-item", wandItem));
|
||||||
|
|
||||||
defaultChangeLimit = Math.max(-1, config.getInt(
|
defaultChangeLimit = Math.max(-1, config.getInt(
|
||||||
|
@ -5,6 +5,7 @@ super-pickaxe-many-drop-items=true
|
|||||||
register-help=true
|
register-help=true
|
||||||
nav-wand-item=minecraft:compass
|
nav-wand-item=minecraft:compass
|
||||||
profile=false
|
profile=false
|
||||||
|
trace-unflushed-sessions=false
|
||||||
super-pickaxe-drop-items=true
|
super-pickaxe-drop-items=true
|
||||||
disallowed-blocks=minecraft:oak_sapling,minecraft:jungle_sapling,minecraft:dark_oak_sapling,minecraft:spruce_sapling,minecraft:birch_sapling,minecraft:acacia_sapling,minecraft:black_bed,minecraft:blue_bed,minecraft:brown_bed,minecraft:cyan_bed,minecraft:gray_bed,minecraft:green_bed,minecraft:light_blue_bed,minecraft:light_gray_bed,minecraft:lime_bed,minecraft:magenta_bed,minecraft:orange_bed,minecraft:pink_bed,minecraft:purple_bed,minecraft:red_bed,minecraft:white_bed,minecraft:yellow_bed,minecraft:powered_rail,minecraft:detector_rail,minecraft:grass,minecraft:dead_bush,minecraft:moving_piston,minecraft:piston_head,minecraft:sunflower,minecraft:rose_bush,minecraft:dandelion,minecraft:poppy,minecraft:brown_mushroom,minecraft:red_mushroom,minecraft:tnt,minecraft:torch,minecraft:fire,minecraft:redstone_wire,minecraft:wheat,minecraft:potatoes,minecraft:carrots,minecraft:melon_stem,minecraft:pumpkin_stem,minecraft:beetroots,minecraft:rail,minecraft:lever,minecraft:redstone_torch,minecraft:redstone_wall_torch,minecraft:repeater,minecraft:comparator,minecraft:stone_button,minecraft:birch_button,minecraft:acacia_button,minecraft:dark_oak_button,minecraft:jungle_button,minecraft:oak_button,minecraft:spruce_button,minecraft:cactus,minecraft:sugar_cane,minecraft:bedrock
|
disallowed-blocks=minecraft:oak_sapling,minecraft:jungle_sapling,minecraft:dark_oak_sapling,minecraft:spruce_sapling,minecraft:birch_sapling,minecraft:acacia_sapling,minecraft:black_bed,minecraft:blue_bed,minecraft:brown_bed,minecraft:cyan_bed,minecraft:gray_bed,minecraft:green_bed,minecraft:light_blue_bed,minecraft:light_gray_bed,minecraft:lime_bed,minecraft:magenta_bed,minecraft:orange_bed,minecraft:pink_bed,minecraft:purple_bed,minecraft:red_bed,minecraft:white_bed,minecraft:yellow_bed,minecraft:powered_rail,minecraft:detector_rail,minecraft:grass,minecraft:dead_bush,minecraft:moving_piston,minecraft:piston_head,minecraft:sunflower,minecraft:rose_bush,minecraft:dandelion,minecraft:poppy,minecraft:brown_mushroom,minecraft:red_mushroom,minecraft:tnt,minecraft:torch,minecraft:fire,minecraft:redstone_wire,minecraft:wheat,minecraft:potatoes,minecraft:carrots,minecraft:melon_stem,minecraft:pumpkin_stem,minecraft:beetroots,minecraft:rail,minecraft:lever,minecraft:redstone_torch,minecraft:redstone_wall_torch,minecraft:repeater,minecraft:comparator,minecraft:stone_button,minecraft:birch_button,minecraft:acacia_button,minecraft:dark_oak_button,minecraft:jungle_button,minecraft:oak_button,minecraft:spruce_button,minecraft:cactus,minecraft:sugar_cane,minecraft:bedrock
|
||||||
max-super-pickaxe-size=5
|
max-super-pickaxe-size=5
|
||||||
|
@ -58,6 +58,7 @@ public class ConfigurateConfiguration extends LocalConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
profile = node.getNode("debug").getBoolean(profile);
|
profile = node.getNode("debug").getBoolean(profile);
|
||||||
|
traceUnflushedSessions = node.getNode("debugging", "trace-unflushed-sessions").getBoolean(traceUnflushedSessions);
|
||||||
wandItem = node.getNode("wand-item").getString(wandItem);
|
wandItem = node.getNode("wand-item").getString(wandItem);
|
||||||
try {
|
try {
|
||||||
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId();
|
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren