Skip to content

Commit

Permalink
Merge branch 'dev/feature' into dev/CamelSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
Efnilite authored Jan 3, 2025
2 parents 1cf58cd + 57e8fe5 commit d592e38
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 72 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "skript-aliases"]
path = skript-aliases
url = https://github.com/SkriptLang/skript-aliases
branch = minimized-aliases
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ protected void afterErrors() {
Bukkit.getServer().shutdown();
}, shutdownDelay.get());
});
}, 20); // 20 ticks is necessary on 1.19.4 to allow the server time to properly load/start ticking, for some reason
}, 50); // 50 ticks is necessary on 1.19.4/1.20.4 to allow the server time to properly load/start ticking, for some reason
}

Skript.metrics = new Metrics(Skript.getInstance(), 722); // 722 is our bStats plugin ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ExprFireTicks extends SimplePropertyExpression<Entity, Timespan> {
@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
max = (parseResult.hasTag("max"));
return true;
return super.init(expressions, matchedPattern, isDelayed, parseResult);
}

@Override
Expand Down
83 changes: 36 additions & 47 deletions src/main/java/ch/njol/skript/expressions/ExprName.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ch.njol.skript.doc.Since;
import ch.njol.skript.expressions.base.SimplePropertyExpression;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.function.DynamicFunctionReference;
import ch.njol.skript.lang.util.common.AnyNamed;
Expand Down Expand Up @@ -38,56 +39,40 @@
import org.skriptlang.skript.lang.script.Script;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Name("Name / Display Name / Tab List Name")
@Description({
"Represents the Minecraft account, display or tab list name of a player, or the custom name of an item, entity, "
+ "block, inventory, gamerule, world, script or function.",
"",
"<ul>",
"\t<li><strong>Players</strong>",
"\t\t<ul>",
"\t\t\t<li><strong>Name:</strong> The Minecraft account name of the player. Can't be changed, but 'display name' can be changed.</li>",
"\t\t\t<li><strong>Display Name:</strong> The name of the player that is displayed in messages. " +
"This name can be changed freely and can include color codes, and is shared among all plugins (e.g. chat plugins will use the display name).</li>",
"\t\t</ul>",
"\t</li>",
"\t<li><strong>Entities</strong>",
"\t\t<ul>",
"\t\t\t<li><strong>Name:</strong> The custom name of the entity. Can be changed. But for living entities, " +
"the players will have to target the entity to see its name tag. For non-living entities, the name will not be visible at all. To prevent this, use 'display name'.</li>",
"\t\t\t<li><strong>Display Name:</strong> The custom name of the entity. Can be changed, " +
"which will also enable <em>custom name visibility</em> of the entity so name tag of the entity will be visible always.</li>",
"\t\t</ul>",
"\t</li>",
"\t<li><strong>Items</strong>",
"\t\t<ul>",
"\t\t\t<li><strong>Name and Display Name:</strong> The <em>custom</em> name of the item (not the Minecraft locale name). Can be changed.</li>",
"\t\t</ul>",
"\t</li>",
"\t<li><strong>Inventories</strong>",
"\t\t<ul>",
"\t\t\t<li><strong>Name and Display Name:</strong> The name/title of the inventory. " +
"Changing name of an inventory means opening the same inventory with the same contents but with a different name to its current viewers.</li>",
"\t\t</ul>",
"\t</li>",
"\t<li><strong>Gamerules (1.13+)</strong>",
"\t\t<ul>",
"\t\t\t<li><strong>Name:</strong> The name of the gamerule. Cannot be changed.</li>",
"\t\t</ul>",
"\t</li>",
"\t<li><strong>Worlds</strong>",
"\t\t<ul>",
"\t\t\t<li><strong>Name:</strong> The name of the world. Cannot be changed.</li>",
"\t\t</ul>",
"\t</li>",
"\t<li><strong>Scripts</strong>",
"\t\t<ul>",
"\t\t\t<li><strong>Name:</strong> The name of a script, excluding its file extension.</li>",
"\t\t</ul>",
"\t</li>",
"</ul>"
"<strong>Players:</strong>",
"\t<strong>Name:</strong> The Minecraft account name of the player. Can't be changed, but 'display name' can be changed.",
"\t<strong>Display Name:</strong> The name of the player that is displayed in messages. " +
"This name can be changed freely and can include color codes, and is shared among all plugins (e.g. chat plugins will use the display name).",
"",
"<strong>Entities:</strong>",
"\t<strong>Name:</strong> The custom name of the entity. Can be changed. But for living entities, " +
"the players will have to target the entity to see its name tag. For non-living entities, the name will not be visible at all. To prevent this, use 'display name'.",
"\t<strong>Display Name:</strong> The custom name of the entity. Can be changed, " +
"which will also enable <em>custom name visibility</em> of the entity so name tag of the entity will be visible always.",
"",
"<strong>Items:</strong>",
"\t<strong>Name and Display Name:</strong> The <em>custom</em> name of the item (not the Minecraft locale name). Can be changed.",
"",
"<strong>Inventories:</strong>",
"\t<strong>Name and Display Name:</strong> The name/title of the inventory. " +
"Changing name of an inventory means opening the same inventory with the same contents but with a different name to its current viewers.",
"",
"<strong>Gamerules:</strong>",
"\t<strong>Name:</strong> The name of the gamerule. Cannot be changed.",
"",
"<strong>Worlds:</strong>",
"\t<strong>Name:</strong> The name of the world. Cannot be changed.",
"",
"<strong>Scripts:</strong>",
"\t<strong>Name:</strong> The name of a script, excluding its file extension."
})
@Examples({
"on join:",
Expand All @@ -107,9 +92,13 @@ public class ExprName extends SimplePropertyExpression<Object, String> {
if (Skript.classExists("net.kyori.adventure.text.Component") &&
Skript.methodExists(Bukkit.class, "createInventory", InventoryHolder.class, int.class, Component.class))
serializer = BungeeComponentSerializer.get();
register(ExprName.class, String.class, "(1:name[s])", "offlineplayers/entities/inventories/nameds");
register(ExprName.class, String.class, "(2:(display|nick|chat|custom)[ ]name[s])", "offlineplayers/entities/inventories/nameds");
register(ExprName.class, String.class, "(3:(player|tab)[ ]list name[s])", "players");

List<String> patterns = new ArrayList<>();
patterns.addAll(Arrays.asList(getPatterns("name[s]", "offlineplayers/entities/inventories/nameds")));
patterns.addAll(Arrays.asList(getPatterns("(display|nick|chat|custom)[ ]name[s]", "offlineplayers/entities/inventories/nameds")));
patterns.addAll(Arrays.asList(getPatterns("(player|tab)[ ]list name[s]", "players")));

Skript.registerExpression(ExprName.class, String.class, ExpressionType.COMBINED, patterns.toArray(new String[0]));
// we keep the entity input because we want to do something special with entities
}

Expand All @@ -123,7 +112,7 @@ public class ExprName extends SimplePropertyExpression<Object, String> {

@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
this.mark = parseResult.mark;
this.mark = (matchedPattern / 2) + 1;
this.setExpr(exprs[0]);
this.scriptResolvedName = this.getParser().hasExperiment(Feature.SCRIPT_REFLECTION);
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.skriptlang.skript.bukkit.fishing.elements;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.*;
import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptEvent;
import ch.njol.skript.lang.SkriptParser.ParseResult;
Expand All @@ -15,21 +14,6 @@
import java.util.ArrayList;
import java.util.List;

@Name("Fishing")
@Description({
"Called when a player triggers a fishing event.",
"An entity hooked event is triggered when an entity gets caught by a fishing rod.",
"A fish escape event is called when the player fails to click on time, and the fish escapes.",
"A fish approaching event is when the bobber is waiting to be hooked, and a fish is approaching."
})
@Examples({
"on fishing line cast:",
"\tsend \"You caught a fish!\" to player",
"on fishing state of caught entity:",
"\tpush event-entity vector from entity to player"
})
@RequiredPlugins("Paper (bobber lured)")
@Since("2.10")
public class EvtFish extends SkriptEvent {

private enum State {
Expand Down Expand Up @@ -71,7 +55,21 @@ private static PlayerFishEvent.State getOptional(String name) {
patterns.add(state.pattern);
}

Skript.registerEvent("Fishing", EvtFish.class, PlayerFishEvent.class, patterns.toArray(new String[0]));
Skript.registerEvent("Fishing", EvtFish.class, PlayerFishEvent.class, patterns.toArray(new String[0]))
.description(
"Called when a player triggers a fishing event.",
"An entity hooked event is triggered when an entity gets caught by a fishing rod.",
"A fish escape event is called when the player fails to click on time, and the fish escapes.",
"A fish approaching event is when the bobber is waiting to be hooked, and a fish is approaching."
)
.examples(
"on fishing line cast:",
"\tsend \"You caught a fish!\" to player",
"on fishing state of caught entity:",
"\tpush event-entity vector from entity to player"
)
.requiredPlugins("Paper (bobber lured)")
.since("2.10");

EventValues.registerEventValue(PlayerFishEvent.class, Entity.class, PlayerFishEvent::getCaught);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import ch.njol.skript.lang.parser.ParserInstance;
import ch.njol.util.Kleenean;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;

/**
* An enum containing {@link Script} warnings that can be suppressed.
Expand Down Expand Up @@ -46,7 +45,7 @@ public enum ScriptWarning {

private final String warningName;
private final String pattern;
private final @UnknownNullability String deprecationMessage;
private final @Nullable String deprecationMessage;

ScriptWarning(String warningName) {
this(warningName, warningName);
Expand Down Expand Up @@ -75,16 +74,15 @@ public boolean isDeprecated() {
}

/**
* Returns the deprecation message of this warning, or null if the warning isn't deprecated.
* @return The deprecation message.
* @return The deprecation message of this warning, or null if the warning isn't deprecated.
* @see #isDeprecated()
*/
public @UnknownNullability String getDeprecationMessage() {
public String getDeprecationMessage() {
return deprecationMessage;
}

/**
* Prints the given message using {@link Skript#warning(String)} iff the current script does not suppress deprecation warnings.
* Prints the given message using {@link Skript#warning(String)} if and only if the current script does not suppress deprecation warnings.
* Intended for use in {@link ch.njol.skript.lang.SyntaxElement#init(Expression[], int, Kleenean, SkriptParser.ParseResult)}.
* The given message is prefixed with {@code "[Deprecated] "} to provide a common link between deprecation warnings.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test "7373 burning time section":
spawn a pig at event-location:
set burning time of event-entity to 9000 ticks
set {_e} to entity
delete entity within {_e}

0 comments on commit d592e38

Please sign in to comment.