mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Added an option to disable the "Ignoring duplicate block" message
This commit is contained in:
parent
c212345a92
commit
33f7c42e2c
@ -27,6 +27,7 @@
|
||||
* Added a [Metrics module](https://github.com/Slimefun/MetricsModule) which allows us to release updates to metrics (bStats) independently from the main plugin
|
||||
* Added "Compressed Carbon -> Carbon" recipe to the Ore Crusher
|
||||
* Added "Carbon -> Coal" recipe to the Ore Crusher
|
||||
* Added an option to disable the message "Ignoring duplicate block"
|
||||
|
||||
#### Changes
|
||||
* Refactored and reworked the Generator API
|
||||
|
@ -64,10 +64,11 @@ public class SlimefunRegistry {
|
||||
private boolean enableResearches;
|
||||
private boolean freeCreativeResearches;
|
||||
private boolean researchFireworks;
|
||||
private boolean logDuplicateBlockEntries;
|
||||
|
||||
private final Set<String> tickers = new HashSet<>();
|
||||
private final Set<SlimefunItem> radioactive = new HashSet<>();
|
||||
private final Set<String> activeChunks = new HashSet<>();
|
||||
private final Set<String> activeChunks = ConcurrentHashMap.newKeySet();
|
||||
|
||||
private final KeyMap<GEOResource> geoResources = new KeyMap<>();
|
||||
|
||||
@ -82,7 +83,7 @@ public class SlimefunRegistry {
|
||||
private final Map<Class<? extends ItemHandler>, Set<ItemHandler>> globalItemHandlers = new HashMap<>();
|
||||
private final Map<String, SlimefunBlockHandler> blockHandlers = new HashMap<>();
|
||||
|
||||
private final Map<String, Set<Location>> activeTickers = new HashMap<>();
|
||||
private final Map<String, Set<Location>> activeTickers = new ConcurrentHashMap<>();
|
||||
|
||||
private final Map<String, ItemStack> automatedCraftingChamberRecipes = new HashMap<>();
|
||||
|
||||
@ -98,6 +99,7 @@ public class SlimefunRegistry {
|
||||
backwardsCompatibility = cfg.getBoolean("options.backwards-compatibility") || SlimefunPlugin.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_14);
|
||||
freeCreativeResearches = cfg.getBoolean("researches.free-in-creative-mode");
|
||||
researchFireworks = cfg.getBoolean("researches.enable-fireworks");
|
||||
logDuplicateBlockEntries = cfg.getBoolean("options.log-duplicate-block-entries");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,4 +267,8 @@ public class SlimefunRegistry {
|
||||
return automatedCraftingChamberRecipes;
|
||||
}
|
||||
|
||||
public boolean logDuplicateBlockEntries() {
|
||||
return logDuplicateBlockEntries;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ abstract class GitHubConnector {
|
||||
writeCacheFile(resp.getBody());
|
||||
}
|
||||
else {
|
||||
Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] {repository + getURLSuffix(), resp.getStatus(), resp.getBody().toString()});
|
||||
Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] {repository + getURLSuffix(), resp.getStatus(), resp.getBody()});
|
||||
}
|
||||
}
|
||||
catch (UnirestException e) {
|
||||
|
@ -16,7 +16,6 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -151,11 +150,35 @@ public class BlockStorage {
|
||||
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
for (String key : cfg.getKeys(false)) {
|
||||
loadBlock(file, cfg, key);
|
||||
totalBlocks++;
|
||||
}
|
||||
|
||||
done++;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
long time = (System.currentTimeMillis() - start);
|
||||
Slimefun.getLogger().log(Level.INFO, "Loading Blocks... 100% (FINISHED - {0}ms)", time);
|
||||
Slimefun.getLogger().log(Level.INFO, "Loaded a total of {0} Blocks for World \"{1}\"", new Object[] { totalBlocks, world.getName() });
|
||||
|
||||
if (totalBlocks > 0) {
|
||||
Slimefun.getLogger().log(Level.INFO, "Avg: {0}ms/Block", DoubleHandler.fixDouble((double) time / (double) totalBlocks, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBlock(File file, FileConfiguration cfg, String key) {
|
||||
Location l = deserializeLocation(key);
|
||||
String chunkString = locationToChunkString(l);
|
||||
|
||||
if (l == null) {
|
||||
// That location was malformed, we will skip this one
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
totalBlocks++;
|
||||
String chunkString = locationToChunkString(l);
|
||||
String json = cfg.getString(key);
|
||||
Config blockInfo = parseBlockInfo(l, json);
|
||||
|
||||
@ -163,10 +186,11 @@ public class BlockStorage {
|
||||
if (storage.containsKey(l)) {
|
||||
// It should not be possible to have two blocks on the same location. Ignore the
|
||||
// new entry if a block is already present and print an error to the console.
|
||||
if (SlimefunPlugin.getRegistry().logDuplicateBlockEntries()) {
|
||||
Slimefun.getLogger().log(Level.INFO, "Ignoring duplicate block @ {0}, {1}, {2} ({3} -> {4})", new Object[] { l.getBlockX(), l.getBlockY(), l.getBlockZ(), blockInfo.getString("id"), storage.get(l).getString("id") });
|
||||
}
|
||||
|
||||
Slimefun.getLogger().log(Level.INFO, "Ignoring duplicate block @ {0}, {1}, {2}", new Object[] { l.getBlockX(), l.getBlockY(), l.getBlockZ() });
|
||||
Slimefun.getLogger().log(Level.INFO, "New: {0} | Old: {1}", new Object[] { key, serializeBlockInfo(storage.get(l)) });
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
storage.put(l, blockInfo);
|
||||
@ -187,21 +211,6 @@ public class BlockStorage {
|
||||
}
|
||||
}
|
||||
|
||||
done++;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
long time = (System.currentTimeMillis() - start);
|
||||
Slimefun.getLogger().log(Level.INFO, "Loading Blocks... 100% (FINISHED - {0}ms)", time);
|
||||
Slimefun.getLogger().log(Level.INFO, "Loaded a total of {0} Blocks for World \"{1}\"", new Object[] { totalBlocks, world.getName() });
|
||||
|
||||
if (totalBlocks > 0) {
|
||||
Slimefun.getLogger().log(Level.INFO, "Avg: {0}ms/Block", DoubleHandler.fixDouble((double) time / (double) totalBlocks, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadChunks() {
|
||||
File chunks = new File(PATH_CHUNKS + "chunks.sfc");
|
||||
|
||||
@ -211,7 +220,8 @@ public class BlockStorage {
|
||||
for (String key : cfg.getKeys(false)) {
|
||||
try {
|
||||
if (world.getName().equals(PatternUtils.SEMICOLON.split(key)[0])) {
|
||||
SlimefunPlugin.getRegistry().getChunks().put(key, new BlockInfoConfig(parseJSON(cfg.getString(key))));
|
||||
BlockInfoConfig data = new BlockInfoConfig(parseJSON(cfg.getString(key)));
|
||||
SlimefunPlugin.getRegistry().getChunks().put(key, data);
|
||||
}
|
||||
}
|
||||
catch (Exception x) {
|
||||
@ -381,6 +391,7 @@ public class BlockStorage {
|
||||
*
|
||||
* @param block
|
||||
* the block to retrieve the ItemStack from
|
||||
*
|
||||
* @return the SlimefunItem's ItemStack corresponding to the block if it has one, otherwise null
|
||||
*
|
||||
* @since 4.0
|
||||
@ -424,6 +435,7 @@ public class BlockStorage {
|
||||
map.put(entry.getKey(), entry.getValue().getAsString());
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@ -530,12 +542,14 @@ public class BlockStorage {
|
||||
}
|
||||
else if (!storage.hasInventory(l)) {
|
||||
File file = new File(PATH_INVENTORIES + serializeLocation(l) + ".sfi");
|
||||
BlockMenuPreset preset = BlockMenuPreset.getPreset(id);
|
||||
|
||||
if (file.exists()) {
|
||||
storage.inventories.put(l, new BlockMenu(BlockMenuPreset.getPreset(id), l, new io.github.thebusybiscuit.cscorelib2.config.Config(file)));
|
||||
BlockMenu inventory = new BlockMenu(preset, l, new io.github.thebusybiscuit.cscorelib2.config.Config(file));
|
||||
storage.inventories.put(l, inventory);
|
||||
}
|
||||
else {
|
||||
storage.loadInventory(l, BlockMenuPreset.getPreset(id));
|
||||
storage.loadInventory(l, preset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -732,15 +746,11 @@ public class BlockStorage {
|
||||
}
|
||||
|
||||
public static Set<String> getTickingChunks() {
|
||||
return new HashSet<>(SlimefunPlugin.getRegistry().getActiveChunks());
|
||||
}
|
||||
|
||||
public static Set<Location> getTickingLocations(Chunk chunk) {
|
||||
return getTickingLocations(chunk.toString());
|
||||
return SlimefunPlugin.getRegistry().getActiveChunks();
|
||||
}
|
||||
|
||||
public static Set<Location> getTickingLocations(String chunk) {
|
||||
return new HashSet<>(SlimefunPlugin.getRegistry().getActiveTickers().get(chunk));
|
||||
return SlimefunPlugin.getRegistry().getActiveTickers().getOrDefault(chunk, new HashSet<>());
|
||||
}
|
||||
|
||||
public BlockMenu loadInventory(Location l, BlockMenuPreset preset) {
|
||||
@ -769,7 +779,8 @@ public class BlockStorage {
|
||||
}
|
||||
|
||||
public void loadUniversalInventory(BlockMenuPreset preset) {
|
||||
SlimefunPlugin.getRegistry().getUniversalInventories().put(preset.getID(), new UniversalBlockMenu(preset));
|
||||
UniversalBlockMenu inventory = new UniversalBlockMenu(preset);
|
||||
SlimefunPlugin.getRegistry().getUniversalInventories().put(preset.getID(), inventory);
|
||||
}
|
||||
|
||||
public void clearInventory(Location l) {
|
||||
|
@ -16,6 +16,7 @@ options:
|
||||
legacy-ore-grinder: true
|
||||
language: en
|
||||
enable-translations: true
|
||||
log-duplicate-block-entries: true
|
||||
|
||||
guide:
|
||||
default-view-book: false
|
||||
|
Loading…
Reference in New Issue
Block a user