mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2026-02-04 11:31:02 +00:00
add trident throws
This commit is contained in:
@@ -175,6 +175,10 @@ public class AnvilEvent implements Listener {
|
||||
addToken(event, tokenType, "critical-strikes", clone);
|
||||
return;
|
||||
}
|
||||
if (tokenType.equalsIgnoreCase("trident-throws")) {
|
||||
addToken(event, tokenType, "trident-throws", clone);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (firstSlotMaterial == Material.BOW || firstSlotMaterial == Material.CROSSBOW) {
|
||||
@@ -350,6 +354,15 @@ public class AnvilEvent implements Listener {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "trident-throws": {
|
||||
if (toolStats.config.getBoolean("enabled.trident-throws")) {
|
||||
newItem.setItemMeta(toolStats.itemLore.updateTridentThrows(newItem, 0));
|
||||
} else {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
event.setResult(newItem);
|
||||
event.getView().setRepairCost(toolStats.itemChecker.getCost(targetToken));
|
||||
@@ -475,6 +488,14 @@ public class AnvilEvent implements Listener {
|
||||
meta = toolStats.itemLore.updateCriticalStrikes(finalItem, -criticalStrikes);
|
||||
finalItem.setItemMeta(meta);
|
||||
}
|
||||
if (container.has(toolStats.tridentThrows)) {
|
||||
Integer tridentThrows = container.get(toolStats.tridentThrows, PersistentDataType.INTEGER);
|
||||
if (tridentThrows == null) {
|
||||
return;
|
||||
}
|
||||
meta = toolStats.itemLore.updateTridentThrows(finalItem, -tridentThrows);
|
||||
finalItem.setItemMeta(meta);
|
||||
}
|
||||
event.setResult(finalItem);
|
||||
event.getView().setRepairCost(toolStats.itemChecker.getCost("reset"));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user