|
38 | 38 | import java.util.*;
|
39 | 39 |
|
40 | 40 | public class ScriptWorld implements IWorld {
|
41 |
| - private static final Map<String,Object> tempData = new HashMap<>(); |
42 | 41 | public WorldServer world;
|
43 | 42 | public ScriptWorld(WorldServer world){
|
44 | 43 | this.world = world;
|
@@ -1159,113 +1158,64 @@ public IParticle createEntityParticle(String directory){
|
1159 | 1158 | return NpcAPI.Instance().createEntityParticle(directory);
|
1160 | 1159 | }
|
1161 | 1160 |
|
1162 |
| - /** |
1163 |
| - * @param key Get temp data for this key |
1164 |
| - * @return Returns the stored temp data |
1165 |
| - */ |
| 1161 | + @Deprecated |
1166 | 1162 | public Object getTempData(String key){
|
1167 |
| - return tempData.get(key); |
| 1163 | + return NpcAPI.Instance().getTempData(key); |
1168 | 1164 | }
|
1169 | 1165 |
|
1170 |
| - /** |
1171 |
| - * Tempdata gets cleared when the server restarts. All worlds share the same temp data. |
1172 |
| - * @param key The key for the data stored |
1173 |
| - * @param value The data stored |
1174 |
| - */ |
| 1166 | + @Deprecated |
1175 | 1167 | public void setTempData(String key, Object value){
|
1176 |
| - tempData.put(key, value); |
| 1168 | + NpcAPI.Instance().setTempData(key, value); |
1177 | 1169 | }
|
1178 | 1170 |
|
1179 |
| - /** |
1180 |
| - * @param key The key thats going to be tested against the temp data |
1181 |
| - * @return Whether or not temp data containes the key |
1182 |
| - */ |
| 1171 | + @Deprecated |
1183 | 1172 | public boolean hasTempData(String key){
|
1184 |
| - return tempData.containsKey(key); |
| 1173 | + return NpcAPI.Instance().hasTempData(key); |
1185 | 1174 | }
|
1186 | 1175 |
|
1187 |
| - /** |
1188 |
| - * @param key The key for the temp data to be removed |
1189 |
| - */ |
| 1176 | + @Deprecated |
1190 | 1177 | public void removeTempData(String key){
|
1191 |
| - tempData.remove(key); |
| 1178 | + NpcAPI.Instance().removeTempData(key); |
1192 | 1179 | }
|
1193 | 1180 |
|
1194 |
| - /** |
1195 |
| - * Removes all tempdata |
1196 |
| - */ |
| 1181 | + @Deprecated |
1197 | 1182 | public void clearTempData(){
|
1198 |
| - tempData.clear(); |
| 1183 | + NpcAPI.Instance().clearTempData(); |
1199 | 1184 | }
|
1200 | 1185 |
|
| 1186 | + @Deprecated |
1201 | 1187 | public String[] getTempDataKeys() {
|
1202 |
| - return tempData.keySet().toArray(new String[0]); |
| 1188 | + return NpcAPI.Instance().getTempDataKeys(); |
1203 | 1189 | }
|
1204 | 1190 |
|
1205 |
| - /** |
1206 |
| - * @param key The key of the data to be returned |
1207 |
| - * @return Returns the stored data |
1208 |
| - */ |
| 1191 | + @Deprecated |
1209 | 1192 | public Object getStoredData(String key){
|
1210 |
| - NBTTagCompound compound = ScriptController.Instance.compound; |
1211 |
| - if(!compound.hasKey(key)) |
1212 |
| - return null; |
1213 |
| - NBTBase base = compound.getTag(key); |
1214 |
| - if(base instanceof NBTPrimitive) |
1215 |
| - return ((NBTPrimitive)base).func_150286_g(); |
1216 |
| - return ((NBTTagString)base).func_150285_a_(); |
| 1193 | + return NpcAPI.Instance().getStoredData(key); |
1217 | 1194 | }
|
1218 | 1195 |
|
1219 |
| - /** |
1220 |
| - * Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved |
1221 |
| - * @param key The key for the data stored |
1222 |
| - * @param value The data stored. This data can be either a Number or a String. Other data is not stored |
1223 |
| - */ |
| 1196 | + @Deprecated |
1224 | 1197 | public void setStoredData(String key, Object value){
|
1225 |
| - NBTTagCompound compound = ScriptController.Instance.compound; |
1226 |
| - if(value instanceof Number) |
1227 |
| - compound.setDouble(key, ((Number) value).doubleValue()); |
1228 |
| - else if(value instanceof String) |
1229 |
| - compound.setString(key, (String)value); |
1230 |
| - ScriptController.Instance.shouldSave = true; |
| 1198 | + NpcAPI.Instance().setStoredData(key, value); |
1231 | 1199 | }
|
1232 | 1200 |
|
1233 |
| - /** |
1234 |
| - * @param key The key of the data to be checked |
1235 |
| - * @return Returns whether or not the stored data contains the key |
1236 |
| - */ |
| 1201 | + @Deprecated |
1237 | 1202 | public boolean hasStoredData(String key){
|
1238 |
| - return ScriptController.Instance.compound.hasKey(key); |
| 1203 | + return NpcAPI.Instance().hasStoredData(key); |
1239 | 1204 | }
|
1240 | 1205 |
|
1241 |
| - /** |
1242 |
| - * @param key The key of the data to be removed |
1243 |
| - */ |
| 1206 | + @Deprecated |
1244 | 1207 | public void removeStoredData(String key){
|
1245 |
| - ScriptController.Instance.compound.removeTag(key); |
1246 |
| - ScriptController.Instance.shouldSave = true; |
| 1208 | + NpcAPI.Instance().removeStoredData(key); |
1247 | 1209 | }
|
1248 | 1210 |
|
1249 |
| - /** |
1250 |
| - * Remove all stored data |
1251 |
| - */ |
| 1211 | + @Deprecated |
1252 | 1212 | public void clearStoredData(){
|
1253 |
| - ScriptController.Instance.compound = new NBTTagCompound(); |
1254 |
| - ScriptController.Instance.shouldSave = true; |
| 1213 | + NpcAPI.Instance().clearStoredData(); |
1255 | 1214 | }
|
1256 | 1215 |
|
| 1216 | + @Deprecated |
1257 | 1217 | public String[] getStoredDataKeys() {
|
1258 |
| - NBTTagCompound compound = ScriptController.Instance.compound; |
1259 |
| - if (compound != null) { |
1260 |
| - Set keySet = compound.func_150296_c(); |
1261 |
| - List<String> list = new ArrayList<>(); |
1262 |
| - for(Object o : keySet){ |
1263 |
| - list.add((String) o); |
1264 |
| - } |
1265 |
| - String[] array = list.toArray(new String[list.size()]); |
1266 |
| - return array; |
1267 |
| - } |
1268 |
| - return new String[0]; |
| 1218 | + return NpcAPI.Instance().getStoredDataKeys(); |
1269 | 1219 | }
|
1270 | 1220 |
|
1271 | 1221 | /**
|
|
0 commit comments