mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-26 18:57:40 +01:00
Update API
This commit is contained in:
parent
5de079917e
commit
6ae9ec8292
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.api.hologram.line;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -17,11 +16,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface ClickListener {
|
||||
|
||||
/**
|
||||
* Called when a player clicks on a hologram line.
|
||||
*
|
||||
* @param player the player who clicked
|
||||
* @since 1
|
||||
*/
|
||||
void onClick(@NotNull Player player);
|
||||
void onClick(@NotNull HologramLineClickEvent clickEvent);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.api.hologram.line;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface HologramLineClickEvent {
|
||||
|
||||
Player getPlayer();
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.api.hologram.line;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface HologramLinePickupEvent {
|
||||
|
||||
Player getPlayer();
|
||||
|
||||
}
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.api.hologram.line;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -17,11 +16,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface PickupListener {
|
||||
|
||||
/**
|
||||
* Called when a player picks up the item.
|
||||
*
|
||||
* @param player the player who picked up the item
|
||||
* @since 1
|
||||
*/
|
||||
void onPickup(@NotNull Player player);
|
||||
void onPickup(@NotNull HologramLinePickupEvent pickupEvent);
|
||||
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ package me.filoghost.example.powerups;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI;
|
||||
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
||||
import me.filoghost.holographicdisplays.api.hologram.line.HologramLinePickupEvent;
|
||||
import me.filoghost.holographicdisplays.api.hologram.line.ItemHologramLine;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
@ -52,12 +52,12 @@ public class PowerUps extends JavaPlugin implements Listener {
|
||||
hologram.getLines().appendText(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
|
||||
ItemHologramLine itemLine = hologram.getLines().appendItem(new ItemStack(Material.SUGAR));
|
||||
|
||||
itemLine.setPickupListener((Player player) -> {
|
||||
itemLine.setPickupListener((HologramLinePickupEvent pickupEvent) -> {
|
||||
// Play an effect
|
||||
player.playEffect(hologram.getPosition().toLocation(), Effect.MOBSPAWNER_FLAMES, null);
|
||||
pickupEvent.getPlayer().playEffect(hologram.getPosition().toLocation(), Effect.MOBSPAWNER_FLAMES, null);
|
||||
|
||||
// 30 seconds of speed II
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true);
|
||||
pickupEvent.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true);
|
||||
|
||||
// Delete the hologram
|
||||
hologram.delete();
|
||||
|
@ -22,7 +22,7 @@ public interface APIClickableHologramLine extends ClickableHologramLine, APIHolo
|
||||
try {
|
||||
ClickListener clickListener = getClickListener();
|
||||
if (clickListener != null) {
|
||||
clickListener.onClick(player);
|
||||
clickListener.onClick(new SimpleHologramLineClickEvent(player));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logClickCallbackException(getCreatorPlugin(), player, t);
|
||||
|
@ -22,7 +22,7 @@ public interface APICollectableHologramLine extends CollectableHologramLine, API
|
||||
try {
|
||||
PickupListener pickupListener = getPickupListener();
|
||||
if (pickupListener != null) {
|
||||
pickupListener.onPickup(player);
|
||||
pickupListener.onPickup(new SimpleHologramLinePickupEvent(player));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logPickupCallbackException(getCreatorPlugin(), player, t);
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.plugin.api.current;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.hologram.line.HologramLineClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SimpleHologramLineClickEvent implements HologramLineClickEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
public SimpleHologramLineClickEvent(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.plugin.api.current;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.hologram.line.HologramLinePickupEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SimpleHologramLinePickupEvent implements HologramLinePickupEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
public SimpleHologramLinePickupEvent(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user