Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
AyhamAl-Ali committed Sep 16, 2023
2 parents 0ea98d4 + 3f08853 commit de8ac0e
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 30 deletions.
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
groupid=ch.njol
name=skript
<<<<<<< HEAD
version=2.8.0-dev
=======
version=2.7.0
>>>>>>> master
jarName=Skript.jar
testEnv=java17/paper-1.20.1
testEnvJavaVersion=17
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@
import org.bukkit.potion.PotionEffectType;
import org.eclipse.jdt.annotation.Nullable;

<<<<<<< HEAD
=======
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

>>>>>>> master
/**
* @author Peter Güttinger
*/
Expand Down
52 changes: 52 additions & 0 deletions src/main/java/ch/njol/skript/conditions/CondIsInfinite.java~master
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* This file is part of Skript.
*
* Skript is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Skript is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Skript. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package ch.njol.skript.conditions;

import org.bukkit.potion.PotionEffect;

import ch.njol.skript.Skript;
import ch.njol.skript.conditions.base.PropertyCondition;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;

// This class can be expanded apon for other types if needed.
@Name("Is Infinite")
@Description("Checks whether potion effects are infinite.")
@Examples("all of the active potion effects of the player are infinite")
@Since("INSERT VERSION")
public class CondIsInfinite extends PropertyCondition<PotionEffect> {

static {
if (Skript.methodExists(PotionEffect.class, "isInfinite"))
register(CondIsInfinite.class, "infinite", "potioneffects");
}

@Override
public boolean check(PotionEffect potion) {
return potion.isInfinite();
}

@Override
protected String getPropertyName() {
return "infinite";
}

}
8 changes: 8 additions & 0 deletions src/main/java/ch/njol/skript/effects/EffPotion.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
potions = (Expression<PotionEffectType>) exprs[0];
tier = (Expression<Number>) exprs[1];
entities = (Expression<LivingEntity>) exprs[2];
<<<<<<< HEAD
if (!infinite)
=======
if (infinite)
>>>>>>> master
duration = (Expression<Timespan>) exprs[3];
}
return true;
Expand All @@ -125,7 +129,11 @@ protected void execute(Event event) {
Timespan timespan = this.duration.getSingle(event);
if (timespan == null)
return;
<<<<<<< HEAD
duration = (int) Math.min(timespan.getTicks_i(), Integer.MAX_VALUE);
=======
duration = (int) Math.max(timespan.getTicks_i(), Integer.MAX_VALUE);
>>>>>>> master
}
for (LivingEntity entity : entities.getArray(event)) {
for (PotionEffectType potionEffectType : potionEffectTypes) {
Expand Down
49 changes: 20 additions & 29 deletions src/main/java/ch/njol/skript/effects/EffStopSound.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,31 @@
@Examples({
"stop sound \"block.chest.open\" for the player",
"stop playing sounds \"ambient.underwater.loop\" and \"ambient.underwater.loop.additions\" to the player",
"stop all sound for all players",
"stop sound in record category"
"stop all sounds for all players",
"stop sound in the record category"
})
@Since("2.4, 2.7 (stop all sounds)")
@RequiredPlugins("MC 1.17.1 (stop all sounds)")
public class EffStopSound extends Effect {

private static final boolean STOP_ALL_SUPPORTED = Skript.methodExists(Player.class, "stopAllSounds");
private static final Pattern KEY_PATTERN = Pattern.compile("([a-z0-9._-]+:)?[a-z0-9/._-]+");


static {
String stopPattern = STOP_ALL_SUPPORTED ? "(all:all sound[s]|sound[s] %strings%)" : "sound[s] %strings%";

String stopPattern = STOP_ALL_SUPPORTED ? "(all:all sound[s]|sound[s] %-strings%)" : "sound[s] %strings%";
Skript.registerEffect(EffStopSound.class,
"stop " + stopPattern + " [(in|from) %-soundcategory%] [(from playing to|for) %players%]",
"stop playing sound[s] %strings% [(in|from) %-soundcategory%] [(to|for) %players%]"
"stop " + stopPattern + " [(in [the]|from) %-soundcategory%] [(from playing to|for) %players%]",
"stop playing sound[s] %strings% [(in [the]|from) %-soundcategory%] [(to|for) %players%]"
);
}

@SuppressWarnings("NotNullFieldNotInitialized")
private Expression<String> sounds;

@Nullable
private Expression<SoundCategory> category;
@SuppressWarnings("NotNullFieldNotInitialized")

@Nullable
private Expression<String> sounds;

private Expression<Player> players;

private boolean allSounds;

@Override
Expand All @@ -90,45 +88,38 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
category = (Expression<SoundCategory>) exprs[1];
players = (Expression<Player>) exprs[2];
}

return true;
}

@Override
protected void execute(Event event) {
// All sounds pattern wants explicitly defined master category
SoundCategory category = this.category == null ? null : this.category.getOptionalSingle(event)
.orElse(allSounds ? null : SoundCategory.MASTER);
.orElse(allSounds ? null : SoundCategory.MASTER);

Player[] targets = players.getArray(event);

if (allSounds) {
if (category == null) {
for (Player player : targets) {
for (Player player : targets)
player.stopAllSounds();
}
} else {
for (Player player : targets) {
for (Player player : targets)
player.stopSound(category);
}
}
} else {
} else if (sounds != null) {
for (String sound : sounds.getArray(event)) {
try {
Sound soundEnum = Sound.valueOf(sound.toUpperCase(Locale.ENGLISH));
for (Player player : targets) {
for (Player player : targets)
player.stopSound(soundEnum, category);
}


continue;
} catch (IllegalArgumentException ignored) { }

} catch (IllegalArgumentException ignored) {}
sound = sound.toLowerCase(Locale.ENGLISH);
if (!KEY_PATTERN.matcher(sound).matches())
continue;

for (Player player : targets) {
for (Player player : targets)
player.stopSound(sound, category);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/entity/SimpleEntityData.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private static void addSuperEntity(String codeName, Class<? extends Entity> enti
addSimpleEntity("item display", ItemDisplay.class);
addSimpleEntity("block display", BlockDisplay.class);
addSimpleEntity("interaction", Interaction.class);
addSimpleEntity("display", Display.class);
addSuperEntity("display", Display.class);
}

// Register zombie after Husk and Drowned to make sure both work
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/ch/njol/skript/events/SimpleEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ public class SimpleEvents {
.requiredPlugins("Paper 1.16+");
}

<<<<<<< HEAD
Skript.registerEvent("Player Pickup Arrow", SimpleEvent.class, PlayerPickupArrowEvent.class, "[player] (pick[ing| ]up [an] arrow|arrow pick[ing| ]up)")
.description("Called when a player picks up an arrow from the ground.")
.examples(
Expand All @@ -721,6 +722,8 @@ public class SimpleEvents {
.since("INSERT VERSION")
.requiredPlugins("Minecraft 1.14+ (event-projectile)");

=======
>>>>>>> master
Skript.registerEvent("Inventory Drag", SimpleEvent.class, InventoryDragEvent.class, "inventory drag[ging]")
.description("Called when a player drags an item in their cursor across the inventory.")
.examples(
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/lang/default.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@ teleport causes:
unknown: unknown
dismount: dismount, dismounted
exit_bed: exit bed, exiting bed, bed exit
<<<<<<< HEAD

# -- Inventory Close Reasons --
inventory close reasons:
Expand All @@ -1328,6 +1329,8 @@ inventory close reasons:
disconnect: disconnected, disconnect
death: death
plugin: plugin
=======
>>>>>>> master

# -- Game Modes --
game modes:
Expand Down

0 comments on commit de8ac0e

Please sign in to comment.