Skip to content

Commit

Permalink
Merge pull request #4 from JustAHuman-xD/fix/bstats-and-wand-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
J3fftw1 authored Mar 15, 2024
2 parents b0bc0d9 + 68b0dcf commit b682812
Show file tree
Hide file tree
Showing 12 changed files with 781 additions and 123 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,28 @@ This can especially be helpful for addon creators, server owners and people who
This can be helpful with testing how optimized the blocks are or if they would cause any issues in mass usage.

## Commands
- `/wesf pos1` This command sets the location for position 1 for your paste/clear command.
- `/wesf pos2` This command sets the location for position 2 for your paste/clear command.
- `/wesf paste <Slimefun ID>` This command pastes the block you specified in the world with the position you chose. It has 1 argument that is the slimefun item id. This can be any placeable Slimefun or Slimefun Addon block.
- `/wesf clear <boolean>` This command clears the blocks you have selected with the position commands. When `true` it fires a blockbreakevent coming from a player. This is used to clear all the handlers. When `false` it just removes the block and the blockstorage data.
- `/wesf wand`
- This command gives a player the selection wand
- `/wesf pos1`
- This command sets position 1.
- `/wesf pos2`
- This command sets position 2.
- `/wesf paste <slimefun_block> [flags...]`
- This command pastes the block specified in the area selected.
- `<slimefun_block>`, a string id, it can be any slimefun or slimefun addon block
- `[energy]`, a boolean, charges the pasted blocks to max integer so they can process pseudo-infinitely (if possible)
- `[inputs]`, a string array, places these items in the blocks input slots (if possible)
- `[refill_inputs_task]`, a boolean, if the inputs should be refilled every slimefun tick (if possible)
- Uses the inputs provided by the `[inputs]` flag, if none are provided, the task is not scheduled
- Lasts for a default of 5 minutes, however can be overridden by the `[task_timeout]` flag
- If a block is broken it is removed from the task, if all blocks are broken, the task ends automatically
- `[void_outputs_task]`, a boolean, if the outputs should be voided every slimefun tick (if possible)
- Lasts for a default of 5 minutes, however can be overridden by the `[task_timeout]` flag
- If a block is broken it is removed from the task, if all blocks are broken, the task ends automatically
- `[task_timeout]`, a string (`30s` `5m` `1h`), the amount of time any tasks should run for (if possible)
- `/wesf clear [call_event]`
- This command clears the blocks you have selected with the position commands.
- `[call_event]`, a boolean, if a `BlockBreakEvent` should be used to trigger item handlers. (defaults to `false`)

## Download
You can find the download of this addon in on [Blob Builds](https://blob.build/project/WorldEditSlimefun).
66 changes: 15 additions & 51 deletions src/main/java/dev/j3fftw/worldeditslimefun/WorldEditSlimefun.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
package dev.j3fftw.worldeditslimefun;

import co.aikar.commands.PaperCommandManager;
import dev.j3fftw.worldeditslimefun.commands.WorldEditSlimefunCommands;
import dev.j3fftw.worldeditslimefun.slimefun.Items;
import dev.j3fftw.worldeditslimefun.slimefun.WandListener;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock;
import io.github.thebusybiscuit.slimefun4.libraries.dough.blocks.BlockPosition;
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.BlobBuildUpdater;
import org.bstats.bukkit.Metrics;
import org.bukkit.entity.Player;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public final class WorldEditSlimefun extends JavaPlugin implements SlimefunAddon {

@Nonnull
private static final Map<UUID, BlockPosition> STORED_POSITION_ONE = new HashMap<>();

@Nonnull
private static final Map<UUID, BlockPosition> STORED_POSITION_TWO = new HashMap<>();
private static WorldEditSlimefun instance;

@Override
public void onEnable() {
instance = this;

if (!new File(getDataFolder(), "config.yml").exists()) {
saveDefaultConfig();
}
Expand All @@ -42,51 +30,27 @@ public void onEnable() {

new Metrics(this, 20799);

PaperCommandManager paperCommandManager = new PaperCommandManager(this);
paperCommandManager.registerCommand(new WorldEditSlimefunCommands());
paperCommandManager.getCommandCompletions().registerCompletion("boolean", context -> List.of("true", "false"));
paperCommandManager.getCommandCompletions().registerCompletion("slimefun_items", context -> {
List<SlimefunItem> slimefunItems = Slimefun.getRegistry().getEnabledSlimefunItems();
List<String> placeableItems = new ArrayList<>();
for (SlimefunItem item : slimefunItems) {
if (!(item instanceof UnplaceableBlock) && item.getItem().getType().isBlock()) {
placeableItems.add(item.getId());
}
}
return placeableItems;
});
Items.init(this);
WorldEditSlimefunCommands.init(this);
Bukkit.getPluginManager().registerEvents(new WandListener(), this);
}

@Override
public void onDisable() {}

public static void addPositionOne(@Nonnull Player player) {
STORED_POSITION_ONE.put(player.getUniqueId(), new BlockPosition(player.getLocation()));
}

public static void addPositionTwo(@Nonnull Player player) {
STORED_POSITION_TWO.put(player.getUniqueId(), new BlockPosition(player.getLocation()));
}

@Nullable
public static BlockPosition getPositionOne(@Nonnull Player player) {
return STORED_POSITION_ONE.get(player.getUniqueId());
}

@Nullable
public static BlockPosition getPositionTwo(@Nonnull Player player) {
return STORED_POSITION_TWO.get(player.getUniqueId());
}

@NotNull
@Nonnull
@Override
public JavaPlugin getJavaPlugin() {
return this;
}

@Nullable
@Nonnull
@Override
public String getBugTrackerURL() {
return "https://github.com/Slimefun-Addon-Community/WorldEditSlimefun/issues";
}

public static WorldEditSlimefun getInstance() {
return instance;
}
}
Loading

0 comments on commit b682812

Please sign in to comment.