mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-19 07:17:37 +01:00
Rename module "legacy" to "legacy-v1"
This commit is contained in:
parent
6f64e09508
commit
fb41de5651
@ -1,39 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-legacy</artifactId>
|
||||
<name>HolographicDisplays Legacy</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>me.filoghost.holographicdisplays</groupId>
|
||||
<artifactId>holographicdisplays-parent</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>holographicdisplays-legacy-v1</artifactId>
|
||||
<name>HolographicDisplays Legacy v1</name>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-utils</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,83 +1,83 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface FloatingItem {
|
||||
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
|
||||
@Deprecated
|
||||
public void hide();
|
||||
|
||||
@Deprecated
|
||||
public void setItemStack(ItemStack itemstack);
|
||||
|
||||
@Deprecated
|
||||
public ItemStack getItemStack();
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(ItemTouchHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public ItemTouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public void setPickupHandler(PickupHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public PickupHandler getPickupHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasPickupHandler();
|
||||
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface FloatingItem {
|
||||
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
|
||||
@Deprecated
|
||||
public void hide();
|
||||
|
||||
@Deprecated
|
||||
public void setItemStack(ItemStack itemstack);
|
||||
|
||||
@Deprecated
|
||||
public ItemStack getItemStack();
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(ItemTouchHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public ItemTouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public void setPickupHandler(PickupHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public PickupHandler getPickupHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasPickupHandler();
|
||||
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
}
|
@ -1,92 +1,92 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Hologram {
|
||||
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
|
||||
@Deprecated
|
||||
public void hide();
|
||||
|
||||
@Deprecated
|
||||
public void addLine(String text);
|
||||
|
||||
@Deprecated
|
||||
public void removeLine(int index);
|
||||
|
||||
@Deprecated
|
||||
public void setLine(int index, String text);
|
||||
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text);
|
||||
|
||||
@Deprecated
|
||||
public String[] getLines();
|
||||
|
||||
@Deprecated
|
||||
public int getLinesLength();
|
||||
|
||||
@Deprecated
|
||||
public void clearLines();
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
@Deprecated
|
||||
public void setLocation(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Hologram {
|
||||
|
||||
@Deprecated
|
||||
public boolean update();
|
||||
|
||||
@Deprecated
|
||||
public void hide();
|
||||
|
||||
@Deprecated
|
||||
public void addLine(String text);
|
||||
|
||||
@Deprecated
|
||||
public void removeLine(int index);
|
||||
|
||||
@Deprecated
|
||||
public void setLine(int index, String text);
|
||||
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text);
|
||||
|
||||
@Deprecated
|
||||
public String[] getLines();
|
||||
|
||||
@Deprecated
|
||||
public int getLinesLength();
|
||||
|
||||
@Deprecated
|
||||
public void clearLines();
|
||||
|
||||
@Deprecated
|
||||
public Location getLocation();
|
||||
|
||||
@Deprecated
|
||||
public double getX();
|
||||
|
||||
@Deprecated
|
||||
public double getY();
|
||||
|
||||
@Deprecated
|
||||
public double getZ();
|
||||
|
||||
@Deprecated
|
||||
public World getWorld();
|
||||
|
||||
@Deprecated
|
||||
public void setLocation(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void teleport(Location location);
|
||||
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler);
|
||||
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler();
|
||||
|
||||
@Deprecated
|
||||
public long getCreationTimestamp();
|
||||
|
||||
@Deprecated
|
||||
public void delete();
|
||||
|
||||
@Deprecated
|
||||
public boolean isDeleted();
|
||||
|
||||
}
|
@ -1,167 +1,167 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.adapter.FloatingItemAdapter;
|
||||
import com.gmail.filoghost.holograms.api.adapter.HologramAdapter;
|
||||
import me.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import me.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import me.filoghost.holographicdisplays.util.Validator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public class HolographicDisplaysAPI {
|
||||
|
||||
private static Set<String> notifiedPlugins = new HashSet<>();
|
||||
|
||||
private static void notifyOldAPI(Plugin plugin) {
|
||||
Validator.notNull(plugin, "plugin");
|
||||
|
||||
if (notifiedPlugins.add(plugin.getName())) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Holographic Displays] The plugin \"" + plugin.getName() + "\" is still using the old API of Holographic Displays. "
|
||||
+ "Please notify the author and ask them to update it, the old API will be removed soon.");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createHologram(Plugin plugin, Location source, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createFloatingItem(Plugin plugin, Location source, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualHologram(plugin, source, Arrays.asList(whoCanSee), lines);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, List<Player> whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualFloatingItem(plugin, source, Arrays.asList(whoCanSee), itemstack);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List<Player> whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram[] getHolograms(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<HologramAdapter> pluginHolograms = HologramAdapter.activeHolograms.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginHolograms.toArray(new HologramAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<FloatingItemAdapter> pluginFloatingItems = FloatingItemAdapter.activeFloatingItems.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginFloatingItems.toArray(new FloatingItemAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||
return HologramsAPI.isHologramEntity(bukkitEntity);
|
||||
}
|
||||
|
||||
private static void validateLocation(Location loc) {
|
||||
Validator.notNull(loc, "location");
|
||||
Validator.notNull(loc.getWorld(), "location's world");
|
||||
}
|
||||
|
||||
private static void validateItem(ItemStack itemstack) {
|
||||
Validator.notNull(itemstack, "itemstack");
|
||||
Validator.isTrue(itemstack.getType() != Material.AIR, "itemstack cannot be AIR");
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.adapter.FloatingItemAdapter;
|
||||
import com.gmail.filoghost.holograms.api.adapter.HologramAdapter;
|
||||
import me.filoghost.holographicdisplays.api.HologramsAPI;
|
||||
import me.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import me.filoghost.holographicdisplays.util.Validator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public class HolographicDisplaysAPI {
|
||||
|
||||
private static Set<String> notifiedPlugins = new HashSet<>();
|
||||
|
||||
private static void notifyOldAPI(Plugin plugin) {
|
||||
Validator.notNull(plugin, "plugin");
|
||||
|
||||
if (notifiedPlugins.add(plugin.getName())) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Holographic Displays] The plugin \"" + plugin.getName() + "\" is still using the old API of Holographic Displays. "
|
||||
+ "Please notify the author and ask them to update it, the old API will be removed soon.");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createHologram(Plugin plugin, Location source, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createFloatingItem(Plugin plugin, Location source, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualHologram(plugin, source, Arrays.asList(whoCanSee), lines);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, List<Player> whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
}
|
||||
|
||||
return new HologramAdapter(plugin, hologram);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
return createIndividualFloatingItem(plugin, source, Arrays.asList(whoCanSee), itemstack);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List<Player> whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
validateLocation(source);
|
||||
validateItem(itemstack);
|
||||
|
||||
me.filoghost.holographicdisplays.api.Hologram hologram = HologramsAPI.createHologram(plugin, source);
|
||||
ItemLine itemLine = hologram.appendItemLine(itemstack);
|
||||
|
||||
hologram.getVisibilityManager().setVisibleByDefault(false);
|
||||
if (whoCanSee != null) {
|
||||
for (Player player : whoCanSee) {
|
||||
hologram.getVisibilityManager().showTo(player);
|
||||
}
|
||||
}
|
||||
|
||||
return new FloatingItemAdapter(plugin, hologram, itemLine);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Hologram[] getHolograms(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<HologramAdapter> pluginHolograms = HologramAdapter.activeHolograms.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginHolograms.toArray(new HologramAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
|
||||
Collection<FloatingItemAdapter> pluginFloatingItems = FloatingItemAdapter.activeFloatingItems.getOrDefault(plugin, Collections.emptyList());
|
||||
return pluginFloatingItems.toArray(new FloatingItemAdapter[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isHologramEntity(Entity bukkitEntity) {
|
||||
return HologramsAPI.isHologramEntity(bukkitEntity);
|
||||
}
|
||||
|
||||
private static void validateLocation(Location loc) {
|
||||
Validator.notNull(loc, "location");
|
||||
Validator.notNull(loc.getWorld(), "location's world");
|
||||
}
|
||||
|
||||
private static void validateItem(ItemStack itemstack) {
|
||||
Validator.notNull(itemstack, "itemstack");
|
||||
Validator.isTrue(itemstack.getType() != Material.AIR, "itemstack cannot be AIR");
|
||||
}
|
||||
|
||||
}
|
@ -1,28 +1,28 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ItemTouchHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(FloatingItem floatingItem, Player player);
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ItemTouchHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(FloatingItem floatingItem, Player player);
|
||||
|
||||
}
|
@ -1,28 +1,28 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface PickupHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onPickup(FloatingItem floatingItem, Player player);
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface PickupHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onPickup(FloatingItem floatingItem, Player player);
|
||||
|
||||
}
|
@ -1,28 +1,28 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface TouchHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(Hologram hologram, Player player);
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @deprecated Please use the new API!
|
||||
*/
|
||||
@Deprecated
|
||||
public interface TouchHandler {
|
||||
|
||||
@Deprecated
|
||||
public void onTouch(Hologram hologram, Player player);
|
||||
|
||||
}
|
@ -1,160 +1,160 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||
import com.gmail.filoghost.holograms.api.ItemTouchHandler;
|
||||
import com.gmail.filoghost.holograms.api.PickupHandler;
|
||||
import me.filoghost.holographicdisplays.api.Hologram;
|
||||
import me.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class FloatingItemAdapter implements FloatingItem {
|
||||
|
||||
public static Map<Plugin, Collection<FloatingItemAdapter>> activeFloatingItems = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
public Hologram hologram;
|
||||
private ItemLine itemLine;
|
||||
private ItemTouchHandler touchHandler;
|
||||
private PickupHandler pickupHandler;
|
||||
|
||||
public FloatingItemAdapter(Plugin plugin, Hologram delegateHologram, ItemLine delegateItemLine) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegateHologram;
|
||||
this.itemLine = delegateItemLine;
|
||||
|
||||
activeFloatingItems.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStack(ItemStack itemstack) {
|
||||
itemLine.setItemStack(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return itemLine.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTouchHandler(ItemTouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setTouchHandler(new ItemTouchHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPickupHandler(PickupHandler handler) {
|
||||
this.pickupHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setPickupHandler(new PickupHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setPickupHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PickupHandler getPickupHandler() {
|
||||
return pickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPickupHandler() {
|
||||
return pickupHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeFloatingItems.get(plugin).remove(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||
import com.gmail.filoghost.holograms.api.ItemTouchHandler;
|
||||
import com.gmail.filoghost.holograms.api.PickupHandler;
|
||||
import me.filoghost.holographicdisplays.api.Hologram;
|
||||
import me.filoghost.holographicdisplays.api.line.ItemLine;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class FloatingItemAdapter implements FloatingItem {
|
||||
|
||||
public static Map<Plugin, Collection<FloatingItemAdapter>> activeFloatingItems = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
public Hologram hologram;
|
||||
private ItemLine itemLine;
|
||||
private ItemTouchHandler touchHandler;
|
||||
private PickupHandler pickupHandler;
|
||||
|
||||
public FloatingItemAdapter(Plugin plugin, Hologram delegateHologram, ItemLine delegateItemLine) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegateHologram;
|
||||
this.itemLine = delegateItemLine;
|
||||
|
||||
activeFloatingItems.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemStack(ItemStack itemstack) {
|
||||
itemLine.setItemStack(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return itemLine.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTouchHandler(ItemTouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setTouchHandler(new ItemTouchHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemTouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPickupHandler(PickupHandler handler) {
|
||||
this.pickupHandler = handler;
|
||||
|
||||
if (handler != null) {
|
||||
itemLine.setPickupHandler(new PickupHandlerAdapter(this, handler));
|
||||
} else {
|
||||
itemLine.setPickupHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PickupHandler getPickupHandler() {
|
||||
return pickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPickupHandler() {
|
||||
return pickupHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeFloatingItems.get(plugin).remove(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
|
||||
}
|
@ -1,201 +1,201 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.Hologram;
|
||||
import com.gmail.filoghost.holograms.api.TouchHandler;
|
||||
import me.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import me.filoghost.holographicdisplays.api.line.TextLine;
|
||||
import me.filoghost.holographicdisplays.api.line.TouchableLine;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HologramAdapter implements Hologram {
|
||||
|
||||
public static Map<Plugin, Collection<HologramAdapter>> activeHolograms = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
private me.filoghost.holographicdisplays.api.Hologram hologram;
|
||||
private TouchHandler touchHandler;
|
||||
|
||||
public HologramAdapter(Plugin plugin, me.filoghost.holographicdisplays.api.Hologram delegate) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegate;
|
||||
|
||||
activeHolograms.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addLine(String text) {
|
||||
hologram.appendTextLine(text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLine(int index, String text) {
|
||||
hologram.removeLine(index);
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text) {
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] getLines() {
|
||||
String[] lines = new String[hologram.size()];
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
HologramLine lineObject = hologram.getLine(i);
|
||||
if (lineObject instanceof TextLine) {
|
||||
lines[i] = ((TextLine) lineObject).getText();
|
||||
} else {
|
||||
lines[i] = "";
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getLinesLength() {
|
||||
return hologram.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLocation(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
private void updateTouchHandler() {
|
||||
for (int i = 0; i < hologram.size(); i++) {
|
||||
HologramLine line = hologram.getLine(i);
|
||||
if (!(line instanceof TouchableLine)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TouchableLine touchableLine = (TouchableLine) line;
|
||||
|
||||
if (touchHandler != null) {
|
||||
touchableLine.setTouchHandler(new HologramTouchHandlerAdapter(this, touchHandler));
|
||||
} else {
|
||||
touchableLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLine(int index) {
|
||||
hologram.removeLine(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLines() {
|
||||
hologram.clearLines();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeHolograms.get(plugin).remove(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.Hologram;
|
||||
import com.gmail.filoghost.holograms.api.TouchHandler;
|
||||
import me.filoghost.holographicdisplays.api.line.HologramLine;
|
||||
import me.filoghost.holographicdisplays.api.line.TextLine;
|
||||
import me.filoghost.holographicdisplays.api.line.TouchableLine;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HologramAdapter implements Hologram {
|
||||
|
||||
public static Map<Plugin, Collection<HologramAdapter>> activeHolograms = new HashMap<>();
|
||||
|
||||
private Plugin plugin;
|
||||
private me.filoghost.holographicdisplays.api.Hologram hologram;
|
||||
private TouchHandler touchHandler;
|
||||
|
||||
public HologramAdapter(Plugin plugin, me.filoghost.holographicdisplays.api.Hologram delegate) {
|
||||
this.plugin = plugin;
|
||||
this.hologram = delegate;
|
||||
|
||||
activeHolograms.computeIfAbsent(plugin, __ -> new ArrayList<>()).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean update() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void hide() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addLine(String text) {
|
||||
hologram.appendTextLine(text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLine(int index, String text) {
|
||||
hologram.removeLine(index);
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void insertLine(int index, String text) {
|
||||
hologram.insertTextLine(index, text);
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] getLines() {
|
||||
String[] lines = new String[hologram.size()];
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
HologramLine lineObject = hologram.getLine(i);
|
||||
if (lineObject instanceof TextLine) {
|
||||
lines[i] = ((TextLine) lineObject).getText();
|
||||
} else {
|
||||
lines[i] = "";
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getLinesLength() {
|
||||
return hologram.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setLocation(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setTouchHandler(TouchHandler handler) {
|
||||
this.touchHandler = handler;
|
||||
updateTouchHandler();
|
||||
}
|
||||
|
||||
private void updateTouchHandler() {
|
||||
for (int i = 0; i < hologram.size(); i++) {
|
||||
HologramLine line = hologram.getLine(i);
|
||||
if (!(line instanceof TouchableLine)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TouchableLine touchableLine = (TouchableLine) line;
|
||||
|
||||
if (touchHandler != null) {
|
||||
touchableLine.setTouchHandler(new HologramTouchHandlerAdapter(this, touchHandler));
|
||||
} else {
|
||||
touchableLine.setTouchHandler(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public TouchHandler getTouchHandler() {
|
||||
return touchHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean hasTouchHandler() {
|
||||
return touchHandler != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLine(int index) {
|
||||
hologram.removeLine(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLines() {
|
||||
hologram.clearLines();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return hologram.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return hologram.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return hologram.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return hologram.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return hologram.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
hologram.teleport(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTimestamp() {
|
||||
return hologram.getCreationTimestamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
hologram.delete();
|
||||
|
||||
activeHolograms.get(plugin).remove(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return hologram.isDeleted();
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +1,37 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.Hologram;
|
||||
import com.gmail.filoghost.holograms.api.TouchHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HologramTouchHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.TouchHandler {
|
||||
|
||||
protected TouchHandler oldHandler;
|
||||
private Hologram hologram;
|
||||
|
||||
public HologramTouchHandlerAdapter(Hologram hologram, TouchHandler oldHandler) {
|
||||
this.hologram = hologram;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(hologram, player);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.Hologram;
|
||||
import com.gmail.filoghost.holograms.api.TouchHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class HologramTouchHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.TouchHandler {
|
||||
|
||||
protected TouchHandler oldHandler;
|
||||
private Hologram hologram;
|
||||
|
||||
public HologramTouchHandlerAdapter(Hologram hologram, TouchHandler oldHandler) {
|
||||
this.hologram = hologram;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(hologram, player);
|
||||
}
|
||||
|
||||
}
|
@ -1,38 +1,38 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||
import com.gmail.filoghost.holograms.api.ItemTouchHandler;
|
||||
import me.filoghost.holographicdisplays.api.handler.TouchHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ItemTouchHandlerAdapter implements TouchHandler {
|
||||
|
||||
protected ItemTouchHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public ItemTouchHandlerAdapter(FloatingItem item, ItemTouchHandler oldHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(item, player);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||
import com.gmail.filoghost.holograms.api.ItemTouchHandler;
|
||||
import me.filoghost.holographicdisplays.api.handler.TouchHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ItemTouchHandlerAdapter implements TouchHandler {
|
||||
|
||||
protected ItemTouchHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public ItemTouchHandlerAdapter(FloatingItem item, ItemTouchHandler oldHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(Player player) {
|
||||
oldHandler.onTouch(item, player);
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +1,37 @@
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||
import com.gmail.filoghost.holograms.api.PickupHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PickupHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.PickupHandler {
|
||||
|
||||
public PickupHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public PickupHandlerAdapter(FloatingItem item, PickupHandler oldPickupHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldPickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickup(Player player) {
|
||||
oldHandler.onPickup(item, player);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.filoghost.holograms.api.adapter;
|
||||
|
||||
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||
import com.gmail.filoghost.holograms.api.PickupHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PickupHandlerAdapter implements me.filoghost.holographicdisplays.api.handler.PickupHandler {
|
||||
|
||||
public PickupHandler oldHandler;
|
||||
private FloatingItem item;
|
||||
|
||||
public PickupHandlerAdapter(FloatingItem item, PickupHandler oldPickupHandler) {
|
||||
this.item = item;
|
||||
this.oldHandler = oldPickupHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickup(Player player) {
|
||||
oldHandler.onPickup(item, player);
|
||||
}
|
||||
|
||||
}
|
@ -42,7 +42,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-legacy</artifactId>
|
||||
<artifactId>holographicdisplays-legacy-v1</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
4
pom.xml
4
pom.xml
@ -32,7 +32,7 @@
|
||||
<module>api</module>
|
||||
<module>utils</module>
|
||||
<module>config</module>
|
||||
<module>legacy</module>
|
||||
<module>legacy-v1</module>
|
||||
<module>nms</module>
|
||||
<module>plugin</module>
|
||||
<module>example</module>
|
||||
@ -54,7 +54,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>holographicdisplays-legacy</artifactId>
|
||||
<artifactId>holographicdisplays-legacy-v1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user