From 17d165e62846b73b13f82af0e93b84704db4e11a Mon Sep 17 00:00:00 2001 From: "Luis C.M." <42545778+c0508383@users.noreply.github.com> Date: Sun, 22 Dec 2024 17:26:09 -0600 Subject: [PATCH] Moved world stored/temp data into the API, functionally the data is the same since different worlds don't have different data. --- java/noppes/npcs/api/AbstractNpcAPI.java | 62 ++++++++++++++++++++++++ java/noppes/npcs/api/IWorld.java | 49 +++++-------------- 2 files changed, 73 insertions(+), 38 deletions(-) diff --git a/java/noppes/npcs/api/AbstractNpcAPI.java b/java/noppes/npcs/api/AbstractNpcAPI.java index 6bb911f..96df371 100644 --- a/java/noppes/npcs/api/AbstractNpcAPI.java +++ b/java/noppes/npcs/api/AbstractNpcAPI.java @@ -37,6 +37,68 @@ public abstract class AbstractNpcAPI { public AbstractNpcAPI() { } + /** + * @param key Get temp data for this key + * @return Returns the stored temp data + */ + public abstract Object getTempData(String key); + + /** + * Tempdata gets cleared when the server restarts. All worlds share the same temp data. + * @param key The key for the data stored + * @param value The data stored + */ + public abstract void setTempData(String key, Object value); + + /** + * @param key The key thats going to be tested against the temp data + * @return Whether or not temp data containes the key + */ + public abstract boolean hasTempData(String key); + + /** + * @param key The key for the temp data to be removed + */ + public abstract void removeTempData(String key); + + /** + * Removes all tempdata + */ + public abstract void clearTempData(); + + public abstract String[] getTempDataKeys(); + + /** + * @param key The key of the data to be returned + * @return Returns the stored data + */ + public abstract Object getStoredData(String key); + + /** + * Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved + * @param key The key for the data stored + * @param value The data stored. This data can be either a Number or a String. Other data is not stored + */ + public abstract void setStoredData(String key, Object value); + + /** + * @param key The key of the data to be checked + * @return Returns whether or not the stored data contains the key + */ + public abstract boolean hasStoredData(String key); + + /** + * @param key The key of the data to be removed + */ + public abstract void removeStoredData(String key); + + /** + * Remove all stored data + */ + public abstract void clearStoredData(); + + public abstract String[] getStoredDataKeys(); + public abstract void registerICommand(ICommand command); public abstract ICommand getICommand(String commandName, int priorityLevel); diff --git a/java/noppes/npcs/api/IWorld.java b/java/noppes/npcs/api/IWorld.java index cfc55ca..be3cfab 100644 --- a/java/noppes/npcs/api/IWorld.java +++ b/java/noppes/npcs/api/IWorld.java @@ -320,64 +320,37 @@ public interface IWorld { @Deprecated IParticle createEntityParticle(String directory); - /** - * @param key Get temp data for this key - * @return Returns the stored temp data - */ + @Deprecated Object getTempData(String key); - /** - * Tempdata gets cleared when the server restarts. All worlds share the same temp data. - * @param key The key for the data stored - * @param value The data stored - */ + @Deprecated void setTempData(String key, Object value); - /** - * @param key The key thats going to be tested against the temp data - * @return Whether or not temp data containes the key - */ + @Deprecated boolean hasTempData(String key); - /** - * @param key The key for the temp data to be removed - */ + @Deprecated void removeTempData(String key); - /** - * Removes all tempdata - */ + @Deprecated void clearTempData(); + @Deprecated String[] getTempDataKeys(); - /** - * @param key The key of the data to be returned - * @return Returns the stored data - */ + @Deprecated Object getStoredData(String key); - /** - * Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved - * @param key The key for the data stored - * @param value The data stored. This data can be either a Number or a String. Other data is not stored - */ + @Deprecated void setStoredData(String key, Object value); - /** - * @param key The key of the data to be checked - * @return Returns whether or not the stored data contains the key - */ + @Deprecated boolean hasStoredData(String key); - /** - * @param key The key of the data to be removed - */ + @Deprecated void removeStoredData(String key); - /** - * Remove all stored data - */ + @Deprecated void clearStoredData(); String[] getStoredDataKeys();