mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-23 08:49:18 +00:00
cleanup
This commit is contained in:
@@ -1,87 +0,0 @@
|
|||||||
package org.bxteam.divinemc.event.entity;
|
|
||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.entity.EntityEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.jspecify.annotations.NullMarked;
|
|
||||||
import org.jspecify.annotations.Nullable;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when some item needs a projectile for further actions
|
|
||||||
*/
|
|
||||||
@NullMarked
|
|
||||||
public class EntityLoadsProjectileEvent extends EntityEvent {
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private final ItemStack weapon;
|
|
||||||
private final Predicate<ItemStack> projectileValidator;
|
|
||||||
private ItemStack projectile;
|
|
||||||
|
|
||||||
public EntityLoadsProjectileEvent(LivingEntity entity, ItemStack weapon, @Nullable ItemStack projectile, Predicate<ItemStack> projectileValidator) {
|
|
||||||
super(entity);
|
|
||||||
this.weapon = weapon;
|
|
||||||
this.projectile = projectile == null ? ItemStack.empty() : projectile;
|
|
||||||
this.projectileValidator = projectileValidator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the entity firing the weapon
|
|
||||||
*
|
|
||||||
* @return the entity firing the weapon
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public LivingEntity getEntity() {
|
|
||||||
return (LivingEntity) this.entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the weapon requesting the projectile
|
|
||||||
*
|
|
||||||
* @return weapon
|
|
||||||
*/
|
|
||||||
public ItemStack getWeapon() {
|
|
||||||
return weapon;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the projectile that will be submitted to the weapon.
|
|
||||||
* {@link ItemStack#isEmpty()} items mean no projectile.
|
|
||||||
*
|
|
||||||
* @return projectile
|
|
||||||
*/
|
|
||||||
public ItemStack getProjectile() {
|
|
||||||
return projectile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the projectile that will be used by the weapon
|
|
||||||
*
|
|
||||||
* @param projectile projectile
|
|
||||||
*/
|
|
||||||
public void setProjectile(@Nullable ItemStack projectile) {
|
|
||||||
this.projectile = projectile == null ? ItemStack.empty() : projectile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the provided item can be fired from the weapon.
|
|
||||||
* <br>
|
|
||||||
* You may still provide a non-fireable projectile to it.
|
|
||||||
*
|
|
||||||
* @param item projectile item
|
|
||||||
* @return whether the provided item can be fired from the weapon
|
|
||||||
*/
|
|
||||||
public boolean canBeFired(@Nullable ItemStack item) {
|
|
||||||
return item != null && this.projectileValidator.test(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
package org.bxteam.divinemc.event.entity;
|
|
||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.entity.EntityEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.jspecify.annotations.NullMarked;
|
|
||||||
|
|
||||||
@NullMarked
|
|
||||||
public class EntityStartUsingItemEvent extends EntityEvent implements Cancellable {
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private final ItemStack item;
|
|
||||||
private int useDuration;
|
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
public EntityStartUsingItemEvent(LivingEntity entity, ItemStack item, int useDuration) {
|
|
||||||
super(entity);
|
|
||||||
this.item = item;
|
|
||||||
this.useDuration = useDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LivingEntity getEntity() {
|
|
||||||
return (LivingEntity) this.entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the item that's being used
|
|
||||||
*
|
|
||||||
* @return the item that's being used
|
|
||||||
*/
|
|
||||||
public ItemStack getItem() {
|
|
||||||
return this.item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets for how long in ticks the item should be used until it's ready
|
|
||||||
*
|
|
||||||
* @return item use duration
|
|
||||||
*/
|
|
||||||
public int getUseDuration() {
|
|
||||||
return this.useDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets for how long in ticks the item should be used until it's ready
|
|
||||||
*
|
|
||||||
* @param useDuration item use duration in ticks
|
|
||||||
*/
|
|
||||||
public void setUseDuration(int useDuration) {
|
|
||||||
this.useDuration = useDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @return if cancelled, the item will stop being in use
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether to cancel item use. If canceled,
|
|
||||||
* the item will stop being in use.
|
|
||||||
*
|
|
||||||
* @param cancel whether you wish to cancel this event
|
|
||||||
*/
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
this.cancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
force_run=false
|
|
||||||
|
|
||||||
if [[ "$1" == "--force" ]]; then
|
|
||||||
force_run=true
|
|
||||||
echo "Force mode enabled. All Gradle tasks will run."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Processing file patches..."
|
|
||||||
|
|
||||||
declare -A gradle_tasks
|
|
||||||
|
|
||||||
process_changes() {
|
|
||||||
local dir="$1"
|
|
||||||
local project="$2"
|
|
||||||
|
|
||||||
if [ ! -d "$dir" ]; then
|
|
||||||
echo "Error: The directory '$dir' does not exist or is not valid."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$dir"
|
|
||||||
|
|
||||||
if $force_run || ! git diff --quiet || ! git diff --cached --quiet; then
|
|
||||||
echo "Changes detected in $dir (or force mode enabled). Running Gradle fixup and rebuild tasks."
|
|
||||||
gradle_tasks["fixup${project}FilePatches"]="true"
|
|
||||||
gradle_tasks["rebuild${project}FilePatches"]="true"
|
|
||||||
else
|
|
||||||
echo "No changes detected in $dir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd - > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
run_gradle_task() {
|
|
||||||
local task="$1"
|
|
||||||
if [ "${gradle_tasks[$task]}" = "true" ]; then
|
|
||||||
echo "Running Gradle task: $task"
|
|
||||||
./gradlew "$task" || echo "Gradle task '$task' failed, continuing..."
|
|
||||||
echo "Gradle task '$task' completed (or failed but continuing)."
|
|
||||||
else
|
|
||||||
echo "Skipping Gradle task '$task' as no changes were detected."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
process_changes "./purpur-server/" "PurpurServer"
|
|
||||||
process_changes "./purpur-api/" "PurpurApi"
|
|
||||||
process_changes "./paper-server/" "PaperServer"
|
|
||||||
process_changes "./paper-api/" "PaperApi"
|
|
||||||
process_changes "./divinemc-server/src/minecraft/java" "Minecraft"
|
|
||||||
|
|
||||||
gradle_rebuild_task=false
|
|
||||||
|
|
||||||
if $force_run || ! git diff --quiet "./divinemc-server/build.gradle.kts" || ! git diff --cached --quiet "./divinemc-server/build.gradle.kts"; then
|
|
||||||
echo "Changes detected in ./divinemc-server/build.gradle.kts"
|
|
||||||
gradle_rebuild_task=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $force_run || ! git diff --quiet "./divinemc-api/build.gradle.kts" || ! git diff --cached --quiet "./divinemc-api/build.gradle.kts"; then
|
|
||||||
echo "Changes detected in ./divinemc-api/build.gradle.kts"
|
|
||||||
gradle_rebuild_task=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $gradle_rebuild_task; then
|
|
||||||
gradle_tasks["rebuildPurpurSingleFilePatches"]="true"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Running fixup tasks..."
|
|
||||||
run_gradle_task "fixupPurpurApiFilePatches"
|
|
||||||
run_gradle_task "fixupPaperApiFilePatches"
|
|
||||||
run_gradle_task "fixupPurpurServerFilePatches"
|
|
||||||
run_gradle_task "fixupPaperServerFilePatches"
|
|
||||||
run_gradle_task "fixupMinecraftFilePatches"
|
|
||||||
|
|
||||||
echo "Running rebuild tasks..."
|
|
||||||
run_gradle_task "rebuildPurpurApiFilePatches"
|
|
||||||
run_gradle_task "rebuildPaperApiFilePatches"
|
|
||||||
run_gradle_task "rebuildPurpurServerFilePatches"
|
|
||||||
run_gradle_task "rebuildPaperServerFilePatches"
|
|
||||||
run_gradle_task "rebuildMinecraftFilePatches"
|
|
||||||
run_gradle_task "rebuildPurpurSingleFilePatches"
|
|
||||||
@@ -39,7 +39,7 @@ mv divinemc-server/build/libs/divinemc-paperclip-"$version"-mojmap.jar "$jarName
|
|||||||
} >> "$GITHUB_ENV"
|
} >> "$GITHUB_ENV"
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "### 📜 Commits:"
|
echo "### 📜 Commits"
|
||||||
if [ "$experimental" = "true" ]; then
|
if [ "$experimental" = "true" ]; then
|
||||||
echo "> [!WARNING]"
|
echo "> [!WARNING]"
|
||||||
echo "> This is an experimental build, it may contain bugs and issues. Use at your own risk."
|
echo "> This is an experimental build, it may contain bugs and issues. Use at your own risk."
|
||||||
@@ -49,11 +49,11 @@ mv divinemc-server/build/libs/divinemc-paperclip-"$version"-mojmap.jar "$jarName
|
|||||||
} >> $changelog
|
} >> $changelog
|
||||||
|
|
||||||
number=$(git log --oneline master ^"$(git describe --tags --abbrev=0)" | wc -l)
|
number=$(git log --oneline master ^"$(git describe --tags --abbrev=0)" | wc -l)
|
||||||
git log --pretty='- [%h](https://github.com/BX-Team/DivineMC/commit/%H) %s' "-$number" >> $changelog
|
git log --pretty='- [`%h`](https://github.com/BX-Team/DivineMC/commit/%H) %s' "-$number" >> $changelog
|
||||||
|
|
||||||
{
|
{
|
||||||
echo ""
|
echo ""
|
||||||
echo "### 🔒 Checksums:"
|
echo "### 🔒 Checksums"
|
||||||
echo "| File | $jarName |"
|
echo "| File | $jarName |"
|
||||||
echo "| ---- | ---- |"
|
echo "| ---- | ---- |"
|
||||||
echo "| MD5 | $(md5 "$jarName") |"
|
echo "| MD5 | $(md5 "$jarName") |"
|
||||||
|
|||||||
Reference in New Issue
Block a user