Skip to content

Commit

Permalink
Merge remote-tracking branch 'fork/feature/loottable' into feature/lo…
Browse files Browse the repository at this point in the history
…ottable
  • Loading branch information
Burbulinis committed Dec 15, 2024
2 parents d6658aa + 70977bc commit 8620a07
Show file tree
Hide file tree
Showing 93 changed files with 3,222 additions and 1,172 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/ScriptLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
item = Statement.parse(expr, items, "Can't understand this condition/effect: " + expr);
if (item == null)
continue;
long requiredTime = SkriptConfig.longParseTimeWarningThreshold.value().getMilliSeconds();
long requiredTime = SkriptConfig.longParseTimeWarningThreshold.value().getAs(Timespan.TimePeriod.MILLISECOND);
if (requiredTime > 0) {
long timeTaken = System.currentTimeMillis() - start;
if (timeTaken > requiredTime)
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,16 @@ public void onEnable() {
classLoadError = e;
}

// Warn about pausing
if (Skript.methodExists(Server.class, "getPauseWhenEmptyTime")) {
int pauseThreshold = getServer().getPauseWhenEmptyTime();
if (pauseThreshold > -1) {
Skript.warning("Minecraft server pausing is enabled!");
Skript.warning("Scripts that interact with the world or entities may not work as intended when the server is paused and may crash your server.");
Skript.warning("Consider setting 'pause-when-empty-seconds' to -1 in server.properties to make sure you don't encounter any issues.");
}
}

// Config must be loaded after Java and Skript classes are parseable
// ... but also before platform check, because there is a config option to ignore some errors
SkriptConfig.load();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/SkriptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class SkriptConfig {
.setter(t -> {
SkriptUpdater updater = Skript.getInstance().getUpdater();
if (updater != null)
updater.setCheckFrequency(t.getTicks());
updater.setCheckFrequency(t.getAs(Timespan.TimePeriod.TICK));
});
static final Option<Integer> updaterDownloadTries = new Option<>("updater download tries", 7)
.optional(true);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/ch/njol/skript/classes/data/BukkitClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.Metadatable;
import org.bukkit.potion.PotionEffect;
Expand Down Expand Up @@ -1529,6 +1530,11 @@ public String toVariableNameString(EnchantmentOffer eo) {
.description("Represents a transform reason of an <a href='events.html#entity transform'>entity transform event</a>.")
.since("2.8.0"));

Classes.registerClass(new EnumClassInfo<>(ItemFlag.class, "itemflag", "item flags")
.user("item ?flags?")
.name("Item Flag")
.description("Represents flags that may be applied to hide certain attributes of an item.")
.since("INSERT VERSION"));

Classes.registerClass(new EnumClassInfo<>(EntityPotionEffectEvent.Cause.class, "entitypotioncause", "entity potion causes")
.user("(entity )?potion ?effect ?cause")
Expand Down
25 changes: 24 additions & 1 deletion src/main/java/ch/njol/skript/classes/data/BukkitEventValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
import ch.njol.skript.util.EnchantmentType;
import ch.njol.skript.util.Getter;
import ch.njol.skript.util.Timespan;
import ch.njol.skript.util.Color;
import ch.njol.skript.util.SkriptColor;
import ch.njol.skript.util.ColorRGB;
import ch.njol.skript.util.slot.InventorySlot;
import ch.njol.skript.util.slot.Slot;
import com.destroystokyo.paper.event.block.AnvilDamagedEvent;
Expand Down Expand Up @@ -1640,6 +1643,26 @@ public FireworkEffect get(FireworkExplodeEvent e) {
return effects.get(0);
}
}, 0);
EventValues.registerEventValue(FireworkExplodeEvent.class, Color[].class, new Getter<Color[], FireworkExplodeEvent>() {
@Override
public Color @Nullable [] get(FireworkExplodeEvent event) {
List<FireworkEffect> effects = event.getEntity().getFireworkMeta().getEffects();
if (effects.isEmpty())
return null;
List<Color> colors = new ArrayList<>();
for (FireworkEffect fireworkEffect : effects) {
for (org.bukkit.Color color : fireworkEffect.getColors()) {
if (SkriptColor.fromBukkitColor(color) != null)
colors.add(SkriptColor.fromBukkitColor(color));
else
colors.add(ColorRGB.fromBukkitColor(color));
}
}
if (colors.isEmpty())
return null;
return colors.toArray(Color[]::new);
}
}, EventValues.TIME_NOW);
//PlayerRiptideEvent
EventValues.registerEventValue(PlayerRiptideEvent.class, ItemStack.class, new Getter<ItemStack, PlayerRiptideEvent>() {
@Override
Expand Down Expand Up @@ -1781,7 +1804,7 @@ public Egg get(PlayerEggThrowEvent event) {
EventValues.registerEventValue(PlayerStopUsingItemEvent.class, Timespan.class, new Getter<Timespan, PlayerStopUsingItemEvent>() {
@Override
public Timespan get(PlayerStopUsingItemEvent event) {
return Timespan.fromTicks(event.getTicksHeldFor());
return new Timespan(Timespan.TimePeriod.TICK, event.getTicksHeldFor());
}
}, EventValues.TIME_NOW);
EventValues.registerEventValue(PlayerStopUsingItemEvent.class, ItemType.class, new Getter<ItemType, PlayerStopUsingItemEvent>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ public boolean supportsOrdering() {
Comparators.registerComparator(Timespan.class, Timespan.class, new Comparator<Timespan, Timespan>() {
@Override
public Relation compare(Timespan t1, Timespan t2) {
return Relation.get(t1.getMilliSeconds() - t2.getMilliSeconds());
return Relation.get(t1.getAs(Timespan.TimePeriod.MILLISECOND) - t2.getAs(Timespan.TimePeriod.MILLISECOND));
}

@Override
Expand Down
Loading

0 comments on commit 8620a07

Please sign in to comment.