Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4721b80
build.gradle.kts - switch skript-parser back to dev/patch branch
ShaneBeee Feb 1, 2026
83b1506
ExprLocationOf - revert back to property expression
ShaneBeee Feb 1, 2026
a832f94
Effects - changes:
ShaneBeee Feb 1, 2026
eda6213
Block - forgot to push
ShaneBeee Feb 1, 2026
8ca64c0
ExprBlockTypeOfBlock - include settings
ShaneBeee Feb 1, 2026
93e01e4
JsonVariableStorage - changed variable format
ShaneBeee Feb 1, 2026
2c9fbe0
ExprCast - new casting
ShaneBeee Feb 1, 2026
ab51fcd
ExprItemType - add option to convert item from block/blocktype
ShaneBeee Feb 1, 2026
9fb993b
EffSendMessage - allowing sending all objects
ShaneBeee Feb 1, 2026
cc16969
ExprHeldItem - add held item expression
ShaneBeee Feb 1, 2026
539b6da
ExprActiveSlot - add slot
ShaneBeee Feb 1, 2026
9e6cc5b
Upstream rename of Functions.getGlobalFunctions()
ShaneBeee Feb 1, 2026
08d62a3
EffectCommands - fix not being able to use functions
ShaneBeee Feb 1, 2026
89e5c2a
PlayerContext - make it easier to get player in different events
ShaneBeee Feb 1, 2026
e9242e4
PlayerContext - global registry
ShaneBeee Feb 1, 2026
9dff9c7
MarkdownDocPrinter - fix missing contexts
ShaneBeee Feb 2, 2026
468e44e
ExprLocationDirection - update docs regarding parser issue
ShaneBeee Feb 2, 2026
14f6c7f
TypesBlock - add interaction type
ShaneBeee Feb 2, 2026
9fe18b0
EffCancelEvent - fix check for event
ShaneBeee Feb 2, 2026
8f89c12
Effects - organize
ShaneBeee Feb 2, 2026
cc33946
EvtPlayerPostUseBlock - add player use block event
ShaneBeee Feb 2, 2026
4a5ed4e
EvtBlockDamage - add block damage event
ShaneBeee Feb 2, 2026
717981e
EvtBlockDamage - add block damage event
ShaneBeee Feb 2, 2026
23a79bb
Events - organization
ShaneBeee Feb 2, 2026
c2a871b
ExprInventorySlots - add expression for inv slots
ShaneBeee Feb 2, 2026
33027a3
ExprDistance - add expression for distance between 2 locations
ShaneBeee Feb 2, 2026
1673d80
EffSendMessage - fix error when sending null object
ShaneBeee Feb 2, 2026
4de72f7
ExprMessage - make some things easier with optional parts
ShaneBeee Feb 2, 2026
602ea76
build.gradle.kts - update skript-parser version
ShaneBeee Feb 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
dependencies {
compileOnly("com.hypixel.hytale:Server:${hytaleVersion}")
compileOnly("org.jetbrains:annotations:26.0.2")
implementation("com.github.SkriptDev:skript-parser:1.0.1") {
implementation("com.github.SkriptDev:skript-parser:1.0.2") {
isTransitive = false
}
implementation("com.github.Zoltus:TinyMessage:2.0.1") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public Block(@NotNull Location location) {
return this.type;
}

public void setType(@NotNull BlockType type) {
public void setType(@NotNull BlockType type, int settings) {
this.type = type;
this.world.setBlock(this.pos.getX(), this.pos.getY(), this.pos.getZ(), type.getId());
this.world.setBlock(this.pos.getX(), this.pos.getY(), this.pos.getZ(), type.getId(), settings);
}

public byte getFluidLevel() {
Expand Down Expand Up @@ -134,9 +134,8 @@ public void setFluid(@NotNull Fluid fluid) {
});
}

public void breakBlock() {
int setting = 0; // TODO not sure what to actually use here
this.world.breakBlock(this.pos.getX(), this.pos.getY(), this.pos.getZ(), setting);
public void breakBlock(int settings) {
this.world.breakBlock(this.pos.getX(), this.pos.getY(), this.pos.getZ(), settings);
}

public @NotNull World getWorld() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private void printExpressions(BsonDocument mainDocs, SkriptRegistration registra
private void printFunctions(BsonDocument mainDocs, SkriptRegistration registration) {
String addonKey = registration.getRegisterer().getAddonName().toLowerCase(Locale.ROOT).replace(" ", "_");
BsonArray functionsArray = mainDocs.getArray("functions", new BsonArray());
Functions.getGlobalFunctions().stream().sorted(Comparator.comparing(Function::getName)).forEach(function -> {
Functions.getJavaFunctions().stream().sorted(Comparator.comparing(Function::getName)).forEach(function -> {
if (function instanceof JavaFunction<?> jf) {
Documentation documentation = jf.getDocumentation();
if (documentation.isNoDoc()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ private static void printEvents(PrintWriter writer, SkriptRegistration registrat

List<ContextValue<?, ?>> valuesForThisEvent = new ArrayList<>();
contextValues.forEach(contextValue -> {
if (event.getContexts().contains(contextValue.getContext())) {
valuesForThisEvent.add(contextValue);
}
event.getContexts().forEach(context -> {
if (contextValue.getContext().isAssignableFrom(context)) {
valuesForThisEvent.add(contextValue);
}
});
});
if (!valuesForThisEvent.isEmpty()) {
writer.println("- **ContextValues**:");
Expand Down Expand Up @@ -198,7 +200,7 @@ private static void printExpressions(PrintWriter exprWriter, PrintWriter condWri

@SuppressWarnings("unchecked")
private static void printFunctions(PrintWriter writer) {
Functions.getGlobalFunctions().stream().sorted(Comparator.comparing(Function::getName)).forEach(function -> {
Functions.getJavaFunctions().stream().sorted(Comparator.comparing(Function::getName)).forEach(function -> {
if (function instanceof JavaFunction<?> jf) {
FunctionParameter<?>[] parameters = jf.getParameters();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.skriptdev.skript.api.skript.event;

import com.hypixel.hytale.server.core.entity.entities.Player;
import io.github.syst3ms.skriptparser.lang.TriggerContext;

/**
* Represents a {@link TriggerContext} which includes a player
*/
public interface PlayerContext extends TriggerContext {

Player[] getPlayer();

}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,17 @@ private void loadVariablesFromFile() {
if (this.bsonDocument == null) {
this.bsonDocument = new BsonDocument();
}
JsonElement jsonElement = BsonUtil.translateBsonToJson(this.bsonDocument);
BsonDocument variablesDocument;
if (this.bsonDocument.containsKey("variables")) {
variablesDocument = this.bsonDocument.getDocument("variables");
} else {
// Legacy file format (TODO remove before first release)
this.logger.warn("Your variables file is outdated. HySkript will create a backup then convert for you.");
Files.move(this.file.toPath(), this.file.toPath().resolveSibling(this.file.getName() + ".bak"));
variablesDocument = this.bsonDocument.clone();
this.bsonDocument = new BsonDocument();
}
JsonElement jsonElement = BsonUtil.translateBsonToJson(variablesDocument);
if (jsonElement instanceof JsonObject jsonObject) {
jsonObject.entrySet().forEach(entry -> {
String name = entry.getKey();
Expand Down Expand Up @@ -167,6 +177,8 @@ protected boolean requiresFile() {
protected boolean save(@NotNull String name, @Nullable String type, @Nullable JsonElement value) {
BsonDocument myDocument = BsonDocument.parse("{}");

BsonDocument variablesDocument = this.bsonDocument.getDocument("variables", new BsonDocument());

if (type != null && value != null) {
try {
BsonValue bsonValue = BsonUtil.translateJsonToBson(value);
Expand Down Expand Up @@ -197,11 +209,12 @@ protected boolean save(@NotNull String name, @Nullable String type, @Nullable Js
} catch (Exception e) {
Utils.error("Failed to parse value: " + value);
}
variablesDocument.put(name, myDocument);
} else {
this.bsonDocument.remove(name);
variablesDocument.remove(name);
}

this.bsonDocument.put(name, myDocument);
this.bsonDocument.put("variables", variablesDocument);
this.changes.incrementAndGet();
return true;
}
Expand Down Expand Up @@ -254,6 +267,7 @@ private void readBsonFile() throws IOException {
}

public void writeBsonFile() throws IOException {
writePluginData();
if (this.type == Type.JSON) {
FileWriter fileWriter = new FileWriter(this.file);
JsonWriterSettings.Builder indent = JsonWriterSettings.builder().indent(true);
Expand All @@ -272,4 +286,10 @@ public void writeBsonFile() throws IOException {
}
}

private void writePluginData() {
BsonDocument pluginData = this.bsonDocument.getDocument("data", new BsonDocument());
pluginData.put("version", new BsonString(HySk.getInstance().getManifest().getVersion().toString()));
this.bsonDocument.put("data", pluginData);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void printSyntaxCount() {
int expsSize = this.registration.getExpressions().size() + mainRegistration.getExpressions().size();
int secSize = this.registration.getSections().size() + mainRegistration.getSections().size();
int typeSize = this.registration.getTypes().size() + mainRegistration.getTypes().size();
int funcSize = Functions.getGlobalFunctions().size();
int funcSize = Functions.getAllFunctions().size();

int total = structureSize + eventSize + effectSize + expsSize + secSize + typeSize + funcSize;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.skriptdev.skript.plugin.command;

import com.github.skriptdev.skript.api.skript.event.PlayerContext;
import com.github.skriptdev.skript.api.utils.Utils;
import com.github.skriptdev.skript.plugin.Skript;
import com.hypixel.hytale.component.Ref;
Expand All @@ -11,23 +12,20 @@
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import io.github.syst3ms.skriptparser.lang.Effect;
import io.github.syst3ms.skriptparser.lang.TriggerContext;
import io.github.syst3ms.skriptparser.log.LogEntry;
import io.github.syst3ms.skriptparser.log.SkriptLogger;
import io.github.syst3ms.skriptparser.parsing.ParserState;
import io.github.syst3ms.skriptparser.parsing.SyntaxParser;
import io.github.syst3ms.skriptparser.registration.context.ContextValue.Usage;

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

public class EffectCommands {

public static void register(Skript skript, String token, boolean allowOps, String permission) {
skript.getSkriptRegistration().newContextValue(PlayerEffectContext.class, Player.class, true, "player", PlayerEffectContext::getPlayer)
.setUsage(Usage.EXPRESSION_OR_ALONE)
.register();
skript.getSkriptRegistration().newContextValue(PlayerEffectContext.class, Player.class, true, "me", PlayerEffectContext::getPlayer)
.setUsage(Usage.EXPRESSION_OR_ALONE)
.register();
Expand All @@ -37,6 +35,7 @@ public static void register(Skript skript, String token, boolean allowOps, Strin
PlayerRef sender = event.getSender();

// PERM CHECK
// Pretty sure the OP stuff doesn't work
PermissionsModule perm = PermissionsModule.get();
Set<String> groupsForUser = perm.getGroupsForUser(sender.getUuid());
if (!allowOps) {
Expand All @@ -49,13 +48,17 @@ public static void register(Skript skript, String token, boolean allowOps, Strin

event.setCancelled(true);

// Create dummy ParserState/Logger for effect commands
ParserState parserState = new ParserState();
parserState.setCurrentContexts(Set.of(PlayerEffectContext.class));
SkriptLogger skriptLogger = new SkriptLogger(true);
skriptLogger.setFileInfo("dummy_cause_this_doesnt_matter.sk", List.of());

// Parse effect
String effectString = event.getContent().substring(1);
Optional<? extends Effect> optionalEffect = SyntaxParser.parseEffect(effectString, parserState, skriptLogger);

// If no effect available, send logs
if (optionalEffect.isEmpty()) {
skriptLogger.finalizeLogs();
for (LogEntry logEntry : skriptLogger.close()) {
Expand Down Expand Up @@ -94,7 +97,7 @@ public static void register(Skript skript, String token, boolean allowOps, Strin
});
}

private record PlayerEffectContext(Player player) implements TriggerContext {
private record PlayerEffectContext(Player player) implements PlayerContext {

public Player[] getPlayer() {
return new Player[]{this.player};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
package com.github.skriptdev.skript.plugin.elements.effects;

import com.github.skriptdev.skript.api.skript.registration.SkriptRegistration;
import com.github.skriptdev.skript.plugin.elements.effects.block.EffBreakBlock;
import com.github.skriptdev.skript.plugin.elements.effects.entity.EffDropItem;
import com.github.skriptdev.skript.plugin.elements.effects.entity.EffKill;
import com.github.skriptdev.skript.plugin.elements.effects.other.EffSendMessage;
import com.github.skriptdev.skript.plugin.elements.effects.entity.EffTeleport;
import com.github.skriptdev.skript.plugin.elements.effects.player.EffBan;
import com.github.skriptdev.skript.plugin.elements.effects.other.EffBroadcast;
import com.github.skriptdev.skript.plugin.elements.effects.other.EffCancelEvent;
import com.github.skriptdev.skript.plugin.elements.effects.other.EffDelay;
import com.github.skriptdev.skript.plugin.elements.effects.player.EffKick;

public class EffectHandler {

public static void register(SkriptRegistration registration) {
EffBan.register(registration);
// BLOCK
EffBreakBlock.register(registration);

// ENTITY
EffDropItem.register(registration);
EffKill.register(registration);
EffTeleport.register(registration);

// OTHER
EffBroadcast.register(registration);
EffCancelEvent.register(registration);
EffDelay.register(registration);
EffDropItem.register(registration);
EffKick.register(registration);
EffKill.register(registration);
EffSendMessage.register(registration);
EffTeleport.register(registration);

// PLAYER
EffBan.register(registration);
EffKick.register(registration);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.github.skriptdev.skript.plugin.elements.effects.block;

import com.github.skriptdev.skript.api.hytale.Block;
import com.github.skriptdev.skript.api.skript.registration.SkriptRegistration;
import io.github.syst3ms.skriptparser.lang.Effect;
import io.github.syst3ms.skriptparser.lang.Expression;
import io.github.syst3ms.skriptparser.lang.TriggerContext;
import io.github.syst3ms.skriptparser.parsing.ParseContext;
import org.jetbrains.annotations.NotNull;

public class EffBreakBlock extends Effect {

public static void register(SkriptRegistration reg) {
reg.newEffect(EffBreakBlock.class, "break %blocks% [with settings %number%]")
.description("Breaks the specified blocks.",
"**Settings**:",
"I don't really know what this does yet, but from testing:",
"- `-1` = Breaks the block without particles and performs update of block above (ie: break if it can't be supported).",
"- `0-3` = Breaks the block with particles.",
"- `4+` = Breaks the block without particles.",
"- `256` = Breaks the block with particles and performs update of block above (default).",
"- Any other number doesn't do anything different than the few stated above.")
.examples("break target block of player with settings 0")
.since("INSERT VERSION")
.register();
}

private Expression<Block> blocks;
private Expression<Number> settings;

@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, @NotNull ParseContext parseContext) {
this.blocks = (Expression<Block>) expressions[0];
if (expressions.length > 1) {
this.settings = (Expression<Number>) expressions[1];
}
return true;
}

@Override
protected void execute(@NotNull TriggerContext ctx) {
int settings = 256; // Break block with particles and neighboring updates.
if (this.settings != null) {
Number number = this.settings.getSingle(ctx).orElse(null);
if (number != null) settings = number.intValue();
}
for (Block block : this.blocks.getArray(ctx)) {
block.breakBlock(settings);
}
}

@Override
public String toString(@NotNull TriggerContext ctx, boolean debug) {
String settings = this.settings == null ? "" : " with settings " + this.settings.toString(ctx, debug);
return "break " + this.blocks.toString(ctx, debug) + settings;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.skriptdev.skript.plugin.elements.effects;
package com.github.skriptdev.skript.plugin.elements.effects.entity;

import com.github.skriptdev.skript.api.hytale.EntityComponentUtils;
import com.github.skriptdev.skript.api.skript.registration.SkriptRegistration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.skriptdev.skript.plugin.elements.effects;
package com.github.skriptdev.skript.plugin.elements.effects.entity;

import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.skriptdev.skript.plugin.elements.effects;
package com.github.skriptdev.skript.plugin.elements.effects.entity;

import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.skriptdev.skript.plugin.elements.effects;
package com.github.skriptdev.skript.plugin.elements.effects.other;

import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.universe.Universe;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.skriptdev.skript.plugin.elements.effects;
package com.github.skriptdev.skript.plugin.elements.effects.other;

import com.github.skriptdev.skript.api.skript.event.CancellableContext;
import com.github.skriptdev.skript.api.utils.Utils;
import io.github.syst3ms.skriptparser.lang.Effect;
import io.github.syst3ms.skriptparser.lang.Expression;
import io.github.syst3ms.skriptparser.lang.TriggerContext;
Expand All @@ -26,6 +27,10 @@ public static void register(SkriptRegistration registration) {
@Override
public boolean init(Expression<?> @NotNull [] expressions, int matchedPattern, ParseContext parseContext) {
this.cancel = matchedPattern == 0;
Utils.log("Contexts:");
for (Class<? extends TriggerContext> currentContext : parseContext.getParserState().getCurrentContexts()) {
Utils.log(" - %s", currentContext.getSimpleName());
}
for (Class<? extends TriggerContext> currentContext : parseContext.getParserState().getCurrentContexts()) {
if (!CancellableContext.class.isAssignableFrom(currentContext)) {
parseContext.getLogger().error("This event cannot be cancelled", ErrorType.SEMANTIC_ERROR);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.skriptdev.skript.plugin.elements.effects;
package com.github.skriptdev.skript.plugin.elements.effects.other;

import com.github.skriptdev.skript.api.skript.registration.SkriptRegistration;
import com.github.skriptdev.skript.api.utils.Utils;
Expand Down
Loading
Loading