mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2024-11-13 04:33:33 +00:00
pbs kids
This commit is contained in:
parent
fb97a8e65b
commit
d0e8d6e361
@ -0,0 +1,94 @@
|
||||
package me.totalfreedom.datura.cmd;
|
||||
|
||||
|
||||
import me.totalfreedom.base.Patchwork;
|
||||
import me.totalfreedom.base.Shortcuts;
|
||||
import me.totalfreedom.command.Commander;
|
||||
import me.totalfreedom.command.annotation.Base;
|
||||
import me.totalfreedom.command.annotation.Completion;
|
||||
import me.totalfreedom.command.annotation.Info;
|
||||
import me.totalfreedom.command.annotation.Permissive;
|
||||
import me.totalfreedom.command.annotation.Subcommand;
|
||||
import me.totalfreedom.datura.Datura;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Info(name = "cleardrops", description = "Clears all item drops in the world" + ".", usage = "/<command>", aliases =
|
||||
{"cd", "clearitems", "ci", "wipeitems", "wi"})
|
||||
@Permissive(perm = "datura.cleardrops")
|
||||
public class ClearDropsCommand extends Commander
|
||||
{
|
||||
/**
|
||||
* Initializes this command object. The provided {@link JavaPlugin}
|
||||
* should be the plugin which contains the
|
||||
* command.
|
||||
* <p>
|
||||
* This constructor will automatically register all subcommands and
|
||||
* completions for this command. It will also
|
||||
* automatically infer all required information from the provided
|
||||
* {@link Info} and {@link Permissive} annotations.
|
||||
*
|
||||
* @param plugin The plugin which contains this command.
|
||||
*/
|
||||
protected ClearDropsCommand(final @NotNull JavaPlugin plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Base
|
||||
public void clearDrops(final CommandSender sender)
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
sender.sendPlainMessage("You must define a world.");
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) sender;
|
||||
Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.delayedExecutor(Shortcuts.provideModule(Datura.class), 20 * 10L)
|
||||
.execute(() ->
|
||||
{
|
||||
int i = 0;
|
||||
for (final Entity entity : player.getWorld().getEntities())
|
||||
{
|
||||
if (entity instanceof Item)
|
||||
{
|
||||
entity.remove();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendPlainMessage("Successfully removed " + i + " items.");
|
||||
});
|
||||
}
|
||||
|
||||
@Subcommand(permission = "datura.cleardrops", args = {World.class})
|
||||
@Completion(index = 0, args = {"%world%"})
|
||||
public void clearDrops(final CommandSender sender, final World world)
|
||||
{
|
||||
Patchwork.getInstance()
|
||||
.getExecutor()
|
||||
.delayedExecutor(Shortcuts.provideModule(Datura.class), 20 * 10L)
|
||||
.execute(() ->
|
||||
{
|
||||
int i = 0;
|
||||
for (final Entity entity : world.getEntities())
|
||||
{
|
||||
if (entity instanceof Item)
|
||||
{
|
||||
entity.remove();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendPlainMessage("Successfully removed " + i + " items.");
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package me.totalfreedom.datura.cmd;
|
||||
|
||||
import me.totalfreedom.command.Commander;
|
||||
import me.totalfreedom.command.annotation.Base;
|
||||
import me.totalfreedom.command.annotation.Completion;
|
||||
import me.totalfreedom.command.annotation.Subcommand;
|
||||
import me.totalfreedom.utils.Tagged;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClearEntitiesCommand extends Commander
|
||||
{
|
||||
/**
|
||||
* Initializes this command object. The provided {@link JavaPlugin} should be the plugin which contains the
|
||||
* command.
|
||||
* <p>
|
||||
* This constructor will automatically register all subcommands and completions for this command. It will also
|
||||
* automatically infer all required information from the provided {@link Info} and {@link Permissive} annotations.
|
||||
*
|
||||
* @param plugin The plugin which contains this command.
|
||||
*/
|
||||
protected ClearEntitiesCommand(final @NotNull JavaPlugin plugin)
|
||||
{
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Base
|
||||
public void clearEntities(final CommandSender sender)
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
sender.sendPlainMessage("You must specify a world to clear entities from.");
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = (Player) sender;
|
||||
|
||||
int i = 0;
|
||||
for (final Entity entity : player.getWorld().getEntities())
|
||||
{
|
||||
if (!Tagged.NON_WIPEABLE.isTagged(entity.getType()))
|
||||
{
|
||||
entity.remove();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
sender.sendPlainMessage("Cleared " + i + " entities.");
|
||||
}
|
||||
|
||||
@Subcommand(permission = "datura.clearentities", args = {World.class})
|
||||
@Completion(index = 0, args = {"%world%"})
|
||||
public void clearEntities(final CommandSender sender, final World world)
|
||||
{
|
||||
int i = 0;
|
||||
for (final Entity entity : world.getEntities())
|
||||
{
|
||||
if (!Tagged.NON_WIPEABLE.isTagged(entity.getType()))
|
||||
{
|
||||
entity.remove();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
sender.sendPlainMessage("Cleared " + i + " entities.");
|
||||
}
|
||||
}
|
99
Patchwork/src/main/java/me/totalfreedom/utils/Tagged.java
Normal file
99
Patchwork/src/main/java/me/totalfreedom/utils/Tagged.java
Normal file
@ -0,0 +1,99 @@
|
||||
package me.totalfreedom.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class Tagged<T>
|
||||
{
|
||||
public static final Tagged<EntityType> NON_WIPEABLE = new Tagged<>(EntityType.ITEM_FRAME, EntityType.BLOCK_DISPLAY,
|
||||
EntityType.ITEM_DISPLAY, EntityType.LEASH_HITCH,
|
||||
EntityType.CHEST_BOAT, EntityType.BOAT,
|
||||
EntityType.TEXT_DISPLAY,
|
||||
EntityType.GLOW_ITEM_FRAME,
|
||||
EntityType.ARMOR_STAND, EntityType.PAINTING,
|
||||
EntityType.PLAYER, EntityType.DROPPED_ITEM,
|
||||
EntityType.MINECART, EntityType.MINECART_CHEST,
|
||||
EntityType.MINECART_COMMAND,
|
||||
EntityType.MINECART_FURNACE,
|
||||
EntityType.MINECART_HOPPER,
|
||||
EntityType.FISHING_HOOK, EntityType.DONKEY,
|
||||
EntityType.HORSE, EntityType.IRON_GOLEM,
|
||||
EntityType.RABBIT, EntityType.SNOWMAN,
|
||||
EntityType.VILLAGER, EntityType.WOLF);
|
||||
|
||||
public static final Tagged<EntityType> MINECARTS = new Tagged<>(EntityType.MINECART, EntityType.MINECART_CHEST,
|
||||
EntityType.MINECART_COMMAND,
|
||||
EntityType.MINECART_FURNACE,
|
||||
EntityType.MINECART_HOPPER,
|
||||
EntityType.MINECART_MOB_SPAWNER,
|
||||
EntityType.MINECART_TNT);
|
||||
|
||||
public static final Tagged<EntityType> BOATS = new Tagged<>(EntityType.BOAT, EntityType.CHEST_BOAT);
|
||||
|
||||
public static final Tagged<EntityType> HOSTILE = new Tagged<>(EntityType.BLAZE, EntityType.CAVE_SPIDER,
|
||||
EntityType.CREEPER, EntityType.DROWNED,
|
||||
EntityType.ELDER_GUARDIAN, EntityType.ENDER_CRYSTAL,
|
||||
EntityType.ENDER_DRAGON, EntityType.ENDERMAN,
|
||||
EntityType.ENDERMITE, EntityType.EVOKER,
|
||||
EntityType.EVOKER_FANGS, EntityType.GHAST,
|
||||
EntityType.GIANT, EntityType.GUARDIAN,
|
||||
EntityType.HOGLIN, EntityType.HUSK,
|
||||
EntityType.ILLUSIONER, EntityType.MAGMA_CUBE,
|
||||
EntityType.PHANTOM, EntityType.PIGLIN,
|
||||
EntityType.PIGLIN_BRUTE, EntityType.PILLAGER,
|
||||
EntityType.RAVAGER, EntityType.SHULKER,
|
||||
EntityType.SILVERFISH, EntityType.SKELETON,
|
||||
EntityType.SLIME, EntityType.SPIDER, EntityType.STRAY,
|
||||
EntityType.VEX, EntityType.VINDICATOR,
|
||||
EntityType.WARDEN, EntityType.WITCH,
|
||||
EntityType.WITHER, EntityType.WITHER_SKELETON,
|
||||
EntityType.ZOGLIN, EntityType.ZOMBIE,
|
||||
EntityType.ZOMBIE_VILLAGER,
|
||||
EntityType.ZOMBIFIED_PIGLIN);
|
||||
|
||||
public static final Tagged<EntityType> PASSIVE = new Tagged<>(EntityType.BAT, EntityType.BEE, EntityType.CAT,
|
||||
EntityType.CHICKEN, EntityType.COD, EntityType.COW,
|
||||
EntityType.DOLPHIN, EntityType.DONKEY, EntityType.FOX,
|
||||
EntityType.GOAT, EntityType.HORSE,
|
||||
EntityType.IRON_GOLEM, EntityType.LLAMA,
|
||||
EntityType.MULE, EntityType.MUSHROOM_COW,
|
||||
EntityType.OCELOT, EntityType.PANDA,
|
||||
EntityType.PARROT, EntityType.PIG,
|
||||
EntityType.POLAR_BEAR, EntityType.PUFFERFISH,
|
||||
EntityType.RABBIT, EntityType.SALMON,
|
||||
EntityType.SHEEP, EntityType.SKELETON_HORSE,
|
||||
EntityType.SNOWMAN, EntityType.SQUID,
|
||||
EntityType.STRIDER, EntityType.TRADER_LLAMA,
|
||||
EntityType.TROPICAL_FISH, EntityType.TURTLE,
|
||||
EntityType.VILLAGER, EntityType.WANDERING_TRADER,
|
||||
EntityType.WOLF);
|
||||
|
||||
public static final Tagged<EntityType> PLAYER_RELATED = new Tagged<>(EntityType.PLAYER, EntityType.ARMOR_STAND,
|
||||
EntityType.DROPPED_ITEM, EntityType.PAINTING,
|
||||
EntityType.ITEM_FRAME,
|
||||
EntityType.GLOW_ITEM_FRAME,
|
||||
EntityType.LEASH_HITCH,
|
||||
EntityType.FISHING_HOOK,
|
||||
EntityType.TEXT_DISPLAY,
|
||||
EntityType.BLOCK_DISPLAY,
|
||||
EntityType.ITEM_DISPLAY);
|
||||
|
||||
private final List<T> tagged;
|
||||
|
||||
private Tagged(final T... tagged)
|
||||
{
|
||||
this.tagged = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean isTagged(final @NotNull T object)
|
||||
{
|
||||
for (final T t : this.tagged)
|
||||
{
|
||||
if (object.equals(t))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,30 +1,5 @@
|
||||
package me.totalfreedom.utils.container;
|
||||
|
||||
public final class Trio<A, B, C>
|
||||
public record Trio<A, B, C>(A primary, B secondary, C tertiary)
|
||||
{
|
||||
private final A a;
|
||||
private final B b;
|
||||
private final C c;
|
||||
|
||||
public Trio(final A a, final B b, final C c)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public A getPrimary()
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
public B getSecondary()
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
public C getTertiary()
|
||||
{
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
package me.totalfreedom.utils.container;
|
||||
|
||||
public record UnaryPair<T>(T first, T second)
|
||||
{
|
||||
}
|
@ -1,30 +1,5 @@
|
||||
package me.totalfreedom.utils.container;
|
||||
|
||||
public class UnaryTrio<T>
|
||||
public record UnaryTrio<T>(T primary, T secondary, T tertiary)
|
||||
{
|
||||
private final T primary;
|
||||
private final T secondary;
|
||||
private final T tertiary;
|
||||
|
||||
public UnaryTrio(final T primary, final T secondary, final T tertiary)
|
||||
{
|
||||
this.primary = primary;
|
||||
this.secondary = secondary;
|
||||
this.tertiary = tertiary;
|
||||
}
|
||||
|
||||
public T getPrimary()
|
||||
{
|
||||
return primary;
|
||||
}
|
||||
|
||||
public T getSecondary()
|
||||
{
|
||||
return secondary;
|
||||
}
|
||||
|
||||
public T getTertiary()
|
||||
{
|
||||
return tertiary;
|
||||
}
|
||||
}
|
||||
|
73
codestyle.xml
Normal file
73
codestyle.xml
Normal file
@ -0,0 +1,73 @@
|
||||
<code_scheme name="Freedom Network Suite" version="173">
|
||||
<option name="RIGHT_MARGIN" value="80" />
|
||||
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
|
||||
<DBN-PSQL>
|
||||
<case-options enabled="true">
|
||||
<option name="KEYWORD_CASE" value="lower" />
|
||||
<option name="FUNCTION_CASE" value="lower" />
|
||||
<option name="PARAMETER_CASE" value="lower" />
|
||||
<option name="DATATYPE_CASE" value="lower" />
|
||||
<option name="OBJECT_CASE" value="preserve" />
|
||||
</case-options>
|
||||
<formatting-settings enabled="false" />
|
||||
</DBN-PSQL>
|
||||
<DBN-SQL>
|
||||
<case-options enabled="true">
|
||||
<option name="KEYWORD_CASE" value="lower" />
|
||||
<option name="FUNCTION_CASE" value="lower" />
|
||||
<option name="PARAMETER_CASE" value="lower" />
|
||||
<option name="DATATYPE_CASE" value="lower" />
|
||||
<option name="OBJECT_CASE" value="preserve" />
|
||||
</case-options>
|
||||
<formatting-settings enabled="false">
|
||||
<option name="STATEMENT_SPACING" value="one_line" />
|
||||
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
|
||||
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
|
||||
</formatting-settings>
|
||||
</DBN-SQL>
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="ALIGN_MULTILINE_TEXT_BLOCKS" value="true" />
|
||||
<option name="CLASS_NAMES_IN_JAVADOC" value="3" />
|
||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="8" />
|
||||
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="8" />
|
||||
<option name="IMPORT_LAYOUT_TABLE">
|
||||
<value>
|
||||
<package name="" withSubpackages="true" static="false" />
|
||||
<emptyLine />
|
||||
<package name="javax" withSubpackages="false" static="false" />
|
||||
<package name="java" withSubpackages="false" static="false" />
|
||||
<emptyLine />
|
||||
<package name="" withSubpackages="true" static="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="MULTI_CATCH_TYPES_WRAP" value="0" />
|
||||
</JavaCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="RIGHT_MARGIN" value="120" />
|
||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
|
||||
<option name="BRACE_STYLE" value="2" />
|
||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||
<option name="METHOD_BRACE_STYLE" value="2" />
|
||||
<option name="LAMBDA_BRACE_STYLE" value="2" />
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1" />
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1" />
|
||||
<option name="RESOURCE_LIST_WRAP" value="1" />
|
||||
<option name="EXTENDS_LIST_WRAP" value="1" />
|
||||
<option name="THROWS_LIST_WRAP" value="1" />
|
||||
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
|
||||
<option name="THROWS_KEYWORD_WRAP" value="1" />
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
|
||||
<option name="WRAP_LONG_LINES" value="true" />
|
||||
<option name="WRAP_ON_TYPING" value="1" />
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
Loading…
Reference in New Issue
Block a user