mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-27 21:05:35 +01:00
Notify about the usage of the old API
This commit is contained in:
parent
f339a98a75
commit
aeb3991337
@ -15,8 +15,12 @@
|
||||
package com.gmail.filoghost.holograms.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -39,8 +43,18 @@ import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||
@Deprecated
|
||||
public class HolographicDisplaysAPI {
|
||||
|
||||
private static Set<String> notifiedPlugins = new HashSet<String>();
|
||||
|
||||
private static void notifyOldAPI(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);
|
||||
CraftHologram hologram = (CraftHologram) BackendAPI.getImplementation().createHologram(plugin, source);
|
||||
for (String line : lines) {
|
||||
hologram.appendTextLine(line);
|
||||
@ -50,6 +64,7 @@ public class HolographicDisplaysAPI {
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createFloatingItem(Plugin plugin, Location source, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
Validator.notNull(itemstack, "itemstack");
|
||||
Validator.isTrue(itemstack.getType() != Material.AIR, "itemstack cannot be AIR");
|
||||
|
||||
@ -60,6 +75,7 @@ public class HolographicDisplaysAPI {
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, Player whoCanSee, String... lines) {
|
||||
notifyOldAPI(plugin);
|
||||
List<Player> whoCanSeeList = new ArrayList<Player>();
|
||||
whoCanSeeList.add(whoCanSee);
|
||||
return createIndividualHologram(plugin, source, whoCanSeeList, lines);
|
||||
@ -67,7 +83,7 @@ public class HolographicDisplaysAPI {
|
||||
|
||||
@Deprecated
|
||||
public static Hologram createIndividualHologram(Plugin plugin, Location source, List<Player> whoCanSee, String... lines) {
|
||||
|
||||
notifyOldAPI(plugin);
|
||||
Validator.notNull(plugin, "plugin");
|
||||
Validator.notNull(source, "source");
|
||||
Validator.notNull(source.getWorld(), "source's world");
|
||||
@ -90,6 +106,7 @@ public class HolographicDisplaysAPI {
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, Player whoCanSee, ItemStack itemstack) {
|
||||
notifyOldAPI(plugin);
|
||||
List<Player> whoCanSeeList = new ArrayList<Player>();
|
||||
whoCanSeeList.add(whoCanSee);
|
||||
return createIndividualFloatingItem(plugin, source, whoCanSeeList, itemstack);
|
||||
@ -97,7 +114,7 @@ public class HolographicDisplaysAPI {
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem createIndividualFloatingItem(Plugin plugin, Location source, List<Player> whoCanSee, ItemStack itemstack) {
|
||||
|
||||
notifyOldAPI(plugin);
|
||||
Validator.notNull(plugin, "plugin cannot be null");
|
||||
Validator.notNull(source, "source cannot be null");
|
||||
Validator.notNull(source.getWorld(), "source's world cannot be null");
|
||||
@ -119,6 +136,7 @@ public class HolographicDisplaysAPI {
|
||||
|
||||
@Deprecated
|
||||
public static Hologram[] getHolograms(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
Validator.notNull(plugin, "plugin cannot be null");
|
||||
|
||||
List<Hologram> pluginHolograms = Utils.newList();
|
||||
@ -133,6 +151,7 @@ public class HolographicDisplaysAPI {
|
||||
|
||||
@Deprecated
|
||||
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
||||
notifyOldAPI(plugin);
|
||||
Validator.notNull(plugin, "plugin cannot be null");
|
||||
return new FloatingItem[0];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user