add trident throws

This commit is contained in:
hyperdefined
2026-01-14 17:44:33 -05:00
parent 25e5a13095
commit 8a4da8ad56
7 changed files with 272 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
/*
* This file is part of ToolStats.
*
* ToolStats 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.
*
* ToolStats 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 ToolStats. If not, see <https://www.gnu.org/licenses/>.
*/
package lol.hyper.toolstats.events;
import com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent;
import lol.hyper.toolstats.ToolStats;
import org.bukkit.entity.Trident;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
;
public class ProjectileShoot implements Listener {
private final ToolStats toolStats;
public ProjectileShoot(ToolStats toolStats) {
this.toolStats = toolStats;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onProjectileLaunch(PlayerLaunchProjectileEvent event) {
if (!(event.getProjectile() instanceof Trident tridentEntity)) {
return;
}
tridentEntity.getScheduler().runDelayed(toolStats, scheduledTask -> {
ItemStack tridentStack = tridentEntity.getItemStack();
ItemMeta newTridentMeta = toolStats.itemLore.updateTridentThrows(tridentStack, 1);
if (newTridentMeta == null) {
return;
}
tridentStack.setItemMeta(newTridentMeta);
tridentEntity.setItemStack(tridentStack);
}, null, 1);
}
}