mirror of
https://github.com/YouHaveTrouble/QuickerStacker.git
synced 2026-05-12 06:06:55 +00:00
interaction types are now data driven from config (#6)
This commit is contained in:
@@ -17,6 +17,8 @@ import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import com.hypixel.hytale.server.core.universe.world.World;
|
||||
import com.hypixel.hytale.server.core.util.Config;
|
||||
import me.youhavetrouble.quickerstacker.config.QuickerStackerConfig;
|
||||
import me.youhavetrouble.quickerstacker.interaction.QuickStackInteraction;
|
||||
import me.youhavetrouble.quickerstacker.interaction.QuickStackToChestInteraction;
|
||||
import me.youhavetrouble.quickerstacker.interaction.QuickStackToNearbyChestsInteraction;
|
||||
@@ -30,12 +32,16 @@ import java.util.logging.Level;
|
||||
|
||||
public class QuickerStacker extends JavaPlugin {
|
||||
|
||||
private final Config<QuickerStackerConfig> config = this.withConfig("QSConfig", QuickerStackerConfig.CODEC);
|
||||
|
||||
public QuickerStacker(@NonNullDecl JavaPluginInit init) {
|
||||
super(init);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
config.save();
|
||||
|
||||
this.getCodecRegistry(Interaction.CODEC)
|
||||
.register(
|
||||
"Yht_QuickerStacker_QuickStack",
|
||||
@@ -96,9 +102,8 @@ public class QuickerStacker extends JavaPlugin {
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
private static boolean isBlockContainer(BlockType blockType) {
|
||||
if ("Open_Container".equals(blockType.getInteractions().get(InteractionType.Use))) return true;
|
||||
return false;
|
||||
private boolean isBlockContainer(BlockType blockType) {
|
||||
return config.get().getQuickStackContainers().contains(blockType.getInteractions().get(InteractionType.Use));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,22 +8,27 @@ import java.util.*;
|
||||
|
||||
public class QuickerStackerConfig {
|
||||
|
||||
private String[] quickStackContainers;
|
||||
private Set<String> quickStackContainerSet;
|
||||
private String[] quickStackInteractions = {
|
||||
"Open_Container",
|
||||
"Open_SimpleStorage",
|
||||
};
|
||||
private Set<String> quickStackInteractionSet = Set.of(quickStackInteractions);
|
||||
|
||||
public static final BuilderCodec<QuickerStackerConfig> CODEC = BuilderCodec.builder(QuickerStackerConfig.class, QuickerStackerConfig::new)
|
||||
.append(new KeyedCodec<>("quickStackContainers", Codec.STRING_ARRAY),
|
||||
.append(new KeyedCodec<>("QuickStackInteractions", Codec.STRING_ARRAY),
|
||||
(config, value) -> {
|
||||
config.quickStackContainers = value;
|
||||
config.quickStackContainerSet = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(config.quickStackContainers)));
|
||||
config.quickStackInteractions = value;
|
||||
config.quickStackInteractionSet = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(config.quickStackInteractions)));
|
||||
},
|
||||
(config) -> config.quickStackContainers).add()
|
||||
(config) -> config.quickStackInteractions)
|
||||
.documentation("List of interaction IDs that when detected on a block will cause QuickerStacker to attempt to add its own right click quick stack interaction. This only takes `Use` interaction type.")
|
||||
.add()
|
||||
.build();
|
||||
|
||||
public QuickerStackerConfig() {}
|
||||
|
||||
public Set<String> getQuickStackContainers() {
|
||||
return quickStackContainerSet;
|
||||
return quickStackInteractionSet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user