mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 20:39:10 +00:00
feat: Add Block Properties Suggestion to WE & DebugSetBlockCommand
This commit is contained in:
@@ -87,8 +87,6 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
// Event listeners
|
||||
private final BlockEventListener blockEventListener;
|
||||
private final FallingBlockRemoveListener fallingBlockRemoveListener;
|
||||
// WE support
|
||||
private WorldEditBlockRegister weBlockRegister;
|
||||
|
||||
public BukkitBlockManager(BukkitCraftEngine plugin) {
|
||||
super(plugin);
|
||||
@@ -146,8 +144,6 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
this.modBlockStates.clear();
|
||||
if (EmptyBlock.INSTANCE != null)
|
||||
Arrays.fill(this.stateId2ImmutableBlockStates, EmptyBlock.INSTANCE.defaultState());
|
||||
if (weBlockRegister != null)
|
||||
weBlockRegister.unload();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,7 +163,6 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
initSuggestions();
|
||||
resetPacketConsumers();
|
||||
clearCache();
|
||||
loadWorldEditRegister();
|
||||
}
|
||||
|
||||
private void clearCache() {
|
||||
@@ -177,13 +172,11 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
}
|
||||
|
||||
public void initFastAsyncWorldEditHook() {
|
||||
this.weBlockRegister = new WorldEditBlockRegister(this);
|
||||
this.weBlockRegister.enable();
|
||||
new WorldEditBlockRegister(this);
|
||||
}
|
||||
|
||||
public void initWorldEditHook() {
|
||||
this.weBlockRegister = new WorldEditBlockRegister(this);
|
||||
this.weBlockRegister.enable();
|
||||
WorldEditBlockRegister weBlockRegister = new WorldEditBlockRegister(this);
|
||||
try {
|
||||
for (Key newBlockId : this.blockRegisterOrder) {
|
||||
weBlockRegister.register(newBlockId);
|
||||
@@ -193,11 +186,6 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadWorldEditRegister() {
|
||||
if (this.weBlockRegister != null)
|
||||
this.weBlockRegister.load();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getMinecraftBlockHolder(int stateId) {
|
||||
return stateId2BlockHolder.get(stateId);
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.incendo.cloud.suggestion.Suggestion;
|
||||
import org.incendo.cloud.suggestion.SuggestionProvider;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DebugSetBlockCommand extends BukkitCommandFeature<CommandSender> {
|
||||
|
||||
@@ -33,7 +34,7 @@ public class DebugSetBlockCommand extends BukkitCommandFeature<CommandSender> {
|
||||
.required("id", StringParser.stringComponent(StringParser.StringMode.GREEDY_FLAG_YIELDING).suggestionProvider(new SuggestionProvider<>() {
|
||||
@Override
|
||||
public @NonNull CompletableFuture<? extends @NonNull Iterable<? extends @NonNull Suggestion>> suggestionsFuture(@NonNull CommandContext<Object> context, @NonNull CommandInput input) {
|
||||
return CompletableFuture.completedFuture(plugin().blockManager().cachedSuggestions());
|
||||
return CompletableFuture.completedFuture(BlockStateParser.fillSuggestions(input.input(), input.cursor()).stream().map(Suggestion::suggestion).collect(Collectors.toList()));
|
||||
}
|
||||
}))
|
||||
.handler(context -> {
|
||||
|
||||
Reference in New Issue
Block a user