-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #700 from ShaneBeee/dev/patch
Dev/Patch - future update
- Loading branch information
Showing
15 changed files
with
417 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...main/java/com/shanebeestudios/skbee/elements/other/effects/EffBreakBlocksWithEffects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.shanebeestudios.skbee.elements.other.effects; | ||
|
||
import ch.njol.skript.Skript; | ||
import ch.njol.skript.aliases.ItemType; | ||
import ch.njol.skript.doc.Description; | ||
import ch.njol.skript.doc.Examples; | ||
import ch.njol.skript.doc.Name; | ||
import ch.njol.skript.doc.Since; | ||
import ch.njol.skript.lang.Effect; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.util.Kleenean; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@Name("Break Blocks with Effects") | ||
@Description({"Breaks blocks as if a player had broken them. Will drop items, play particles and sounds. Requires PaperMC.", | ||
"Optionally you can trigger it to drop experience as well.", | ||
"Optionally you can include an item which is used to determine which drops the block will drop."}) | ||
@Examples({"break blocks in radius 2 around target block with effects", | ||
"break {_blocks::*} with effects and with xp", | ||
"break {_blocks::*} with effects and with xp using player's tool"}) | ||
@Since("INSERT VERSION") | ||
public class EffBreakBlocksWithEffects extends Effect { | ||
|
||
private static final boolean HAS_EFFECTS = Skript.methodExists(Block.class, "breakNaturally", boolean.class, boolean.class); | ||
|
||
static { | ||
Skript.registerEffect(EffBreakBlocksWithEffects.class, | ||
"break %blocks% [naturally] with effects [exp:[and] with (experience|exp|xp)] [using %-itemtype%]"); | ||
} | ||
|
||
private boolean exp; | ||
private Expression<Block> blocks; | ||
private Expression<ItemType> itemType; | ||
|
||
@SuppressWarnings({"NullableProblems", "unchecked"}) | ||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
if (!HAS_EFFECTS) { | ||
Skript.error("'break %blocks% with effects' requires PaperMC. Use Skript's 'break %blocks%' effect instead."); | ||
return false; | ||
} | ||
this.exp = parseResult.hasTag("exp"); | ||
this.blocks = (Expression<Block>) exprs[0]; | ||
this.itemType = (Expression<ItemType>) exprs[1]; | ||
return true; | ||
} | ||
|
||
@SuppressWarnings("NullableProblems") | ||
@Override | ||
protected void execute(Event event) { | ||
ItemStack itemStack = null; | ||
if (this.itemType != null) { | ||
ItemType it = this.itemType.getSingle(event); | ||
if (it != null) itemStack = it.getRandom(); | ||
} | ||
|
||
for (Block block : this.blocks.getArray(event)) { | ||
if (itemStack != null) block.breakNaturally(itemStack, true, this.exp); | ||
else block.breakNaturally(true, this.exp); | ||
} | ||
} | ||
|
||
@Override | ||
public @NotNull String toString(Event e, boolean d) { | ||
String blocks = this.blocks.toString(e, d); | ||
String xp = this.exp ? " and with experience" : ""; | ||
String it = this.itemType != null ? (" using " + this.itemType.toString(e, d)) : ""; | ||
return "break " + blocks + " naturally with effects" + xp + it; | ||
} | ||
|
||
} |
88 changes: 88 additions & 0 deletions
88
...ain/java/com/shanebeestudios/skbee/elements/other/expressions/ExprChunksWithinCuboid.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package com.shanebeestudios.skbee.elements.other.expressions; | ||
|
||
import ch.njol.skript.Skript; | ||
import ch.njol.skript.doc.Description; | ||
import ch.njol.skript.doc.Examples; | ||
import ch.njol.skript.doc.Name; | ||
import ch.njol.skript.doc.Since; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.ExpressionType; | ||
import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
import ch.njol.skript.lang.util.SimpleExpression; | ||
import ch.njol.util.Kleenean; | ||
import org.bukkit.Chunk; | ||
import org.bukkit.Location; | ||
import org.bukkit.World; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
@Name("Chunks Within Locations") | ||
@Description("Get a list of all chunks within 2 locations.") | ||
@Examples({"loop all chunks within {_l1} and {_l2}:", | ||
"refresh all chunks within {_l1} and {_l2}"}) | ||
@Since("INSERT VERSION") | ||
public class ExprChunksWithinCuboid extends SimpleExpression<Chunk> { | ||
|
||
static { | ||
Skript.registerExpression(ExprChunksWithinCuboid.class, Chunk.class, ExpressionType.COMBINED, | ||
"all chunks within %location% and %location%"); | ||
} | ||
|
||
private Expression<Location> loc1, loc2; | ||
|
||
@SuppressWarnings({"NullableProblems", "unchecked"}) | ||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
this.loc1 = (Expression<Location>) exprs[0]; | ||
this.loc2 = (Expression<Location>) exprs[1]; | ||
return true; | ||
} | ||
|
||
@SuppressWarnings("NullableProblems") | ||
@Override | ||
protected Chunk @Nullable [] get(Event event) { | ||
Location loc1 = this.loc1.getSingle(event); | ||
Location loc2 = this.loc2.getSingle(event); | ||
if (loc1 == null || loc2 == null) return null; | ||
|
||
World world = loc1.getWorld(); | ||
if (world != loc2.getWorld()) return null; | ||
|
||
List<Chunk> chunks = new ArrayList<>(); | ||
int minX = Math.min(loc1.getBlockX(), loc2.getBlockX()) >> 4; | ||
int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ()) >> 4; | ||
int maxX = (Math.max(loc1.getBlockX(), loc2.getBlockX()) + 1) >> 4; | ||
int maxZ = (Math.max(loc1.getBlockZ(), loc2.getBlockZ()) + 1) >> 4; | ||
for (int x = minX; x <= maxX; x++) { | ||
for (int z = minZ; z <= maxZ; z++) { | ||
chunks.add(world.getChunkAt(x, z, false)); | ||
} | ||
} | ||
|
||
Iterator<Entity> e; | ||
|
||
return chunks.toArray(new Chunk[0]); | ||
} | ||
|
||
@Override | ||
public boolean isSingle() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public @NotNull Class<? extends Chunk> getReturnType() { | ||
return Chunk.class; | ||
} | ||
|
||
@Override | ||
public @NotNull String toString(Event e, boolean d) { | ||
return "all chunks within " + this.loc1.toString(e, d) + " and " + this.loc2.toString(e, d); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.