mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-29 20:19:06 +00:00
Schemas
This commit is contained in:
@@ -13,12 +13,23 @@ public class B
|
||||
private static final KMap<String, BlockData> bdc = new KMap<>();
|
||||
private static final KList<String> nulls = new KList<>();
|
||||
private static final IrisDimension defaultCompat = new IrisDimension();
|
||||
private static final KMap<Material, Boolean> solid = new KMap<>();
|
||||
|
||||
public static BlockData get(String bd)
|
||||
{
|
||||
return getBlockData(bd);
|
||||
}
|
||||
|
||||
public static boolean isSolid(Material mat)
|
||||
{
|
||||
if(!solid.containsKey(mat))
|
||||
{
|
||||
solid.put(mat, mat.isSolid());
|
||||
}
|
||||
|
||||
return solid.get(mat);
|
||||
}
|
||||
|
||||
public static Material mat(String bd)
|
||||
{
|
||||
return getBlockData(bd).getMaterial();
|
||||
@@ -214,4 +225,21 @@ public class B
|
||||
|| m.equals(B.mat("SOUL_TORCH"));
|
||||
//@done
|
||||
}
|
||||
|
||||
public static KList<BlockData> getBlockData(KList<String> find)
|
||||
{
|
||||
KList<BlockData> b = new KList<>();
|
||||
|
||||
for(String i : find)
|
||||
{
|
||||
BlockData bd = getBlockData(i);
|
||||
|
||||
if(bd != null)
|
||||
{
|
||||
b.add(bd);
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,9 @@ package com.volmit.iris.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
@Data
|
||||
public class FileWatcher
|
||||
{
|
||||
@Getter
|
||||
private final File file;
|
||||
protected final File file;
|
||||
private boolean exists;
|
||||
private long lastModified;
|
||||
private long size;
|
||||
@@ -20,11 +15,11 @@ public class FileWatcher
|
||||
readProperties();
|
||||
}
|
||||
|
||||
private void readProperties()
|
||||
protected void readProperties()
|
||||
{
|
||||
exists = file.exists();
|
||||
lastModified = exists ? file.lastModified() : -1;
|
||||
size = exists ? file.length() : -1;
|
||||
size = exists ? file.isDirectory() ? -2 : file.length() : -1;
|
||||
}
|
||||
|
||||
public boolean checkModified()
|
||||
|
||||
122
src/main/java/com/volmit/iris/util/FolderWatcher.java
Normal file
122
src/main/java/com/volmit/iris/util/FolderWatcher.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FolderWatcher extends FileWatcher
|
||||
{
|
||||
private KMap<File, FolderWatcher> watchers;
|
||||
private KList<File> changed;
|
||||
private KList<File> created;
|
||||
private KList<File> deleted;
|
||||
|
||||
public FolderWatcher(File file)
|
||||
{
|
||||
super(file);
|
||||
}
|
||||
|
||||
protected void readProperties()
|
||||
{
|
||||
if(watchers == null)
|
||||
{
|
||||
watchers = new KMap<>();
|
||||
changed = new KList<>();
|
||||
created = new KList<>();
|
||||
deleted = new KList<>();
|
||||
}
|
||||
|
||||
if(file.isDirectory())
|
||||
{
|
||||
for(File i : file.listFiles())
|
||||
{
|
||||
if(!watchers.containsKey(i))
|
||||
{
|
||||
watchers.put(i, new FolderWatcher(i));
|
||||
}
|
||||
}
|
||||
|
||||
if(watchers == null)
|
||||
{
|
||||
System.out.print("wtf");
|
||||
}
|
||||
|
||||
for(File i : watchers.k())
|
||||
{
|
||||
if(!i.exists())
|
||||
{
|
||||
watchers.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
super.readProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkModified()
|
||||
{
|
||||
changed.clear();
|
||||
created.clear();
|
||||
deleted.clear();
|
||||
|
||||
if(file.isDirectory())
|
||||
{
|
||||
KMap<File, FolderWatcher> w = watchers.copy();
|
||||
readProperties();
|
||||
|
||||
for(File i : w.k())
|
||||
{
|
||||
if(!watchers.containsKey(i))
|
||||
{
|
||||
deleted.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
for(File i : watchers.k())
|
||||
{
|
||||
if(!w.containsKey(i))
|
||||
{
|
||||
created.add(i);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
FolderWatcher fw = watchers.get(i);
|
||||
if(fw.checkModified())
|
||||
{
|
||||
changed.add(fw.file);
|
||||
}
|
||||
|
||||
changed.addAll(fw.getChanged());
|
||||
created.addAll(fw.getCreated());
|
||||
deleted.addAll(fw.getDeleted());
|
||||
}
|
||||
}
|
||||
|
||||
return !changed.isEmpty() || !created.isEmpty() || !deleted.isEmpty();
|
||||
}
|
||||
|
||||
return super.checkModified();
|
||||
}
|
||||
|
||||
public KMap<File, FolderWatcher> getWatchers()
|
||||
{
|
||||
return watchers;
|
||||
}
|
||||
|
||||
public KList<File> getChanged()
|
||||
{
|
||||
return changed;
|
||||
}
|
||||
|
||||
public KList<File> getCreated()
|
||||
{
|
||||
return created;
|
||||
}
|
||||
|
||||
public KList<File> getDeleted()
|
||||
{
|
||||
return deleted;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@ package com.volmit.iris.util;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public interface IObjectPlacer {
|
||||
public interface IObjectPlacer
|
||||
{
|
||||
public int getHighest(int x, int z);
|
||||
|
||||
public int getHighest(int x, int z, boolean ignoreFluid);
|
||||
@@ -16,4 +17,6 @@ public interface IObjectPlacer {
|
||||
public boolean isSolid(int x, int y, int z);
|
||||
|
||||
public boolean isUnderwater(int x, int z);
|
||||
|
||||
public int getFluidHeight();
|
||||
}
|
||||
|
||||
@@ -100,6 +100,43 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getPossibleKeys()
|
||||
{
|
||||
if(possibleKeys != null)
|
||||
{
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
Iris.info("Building " + resourceTypeName + " Possibility Lists");
|
||||
KSet<String> m = new KSet<>();
|
||||
|
||||
for(File i : getFolders())
|
||||
{
|
||||
for(File j : i.listFiles())
|
||||
{
|
||||
if(j.isFile() && j.getName().endsWith(".iob"))
|
||||
{
|
||||
m.add(j.getName().replaceAll("\\Q.json\\E", ""));
|
||||
}
|
||||
|
||||
else if(j.isDirectory())
|
||||
{
|
||||
for(File k : j.listFiles())
|
||||
{
|
||||
if(k.isFile() && k.getName().endsWith(".iob"))
|
||||
{
|
||||
m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.iob\\E", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KList<String> v = new KList<>(m);
|
||||
possibleKeys = v.toArray(new String[v.size()]);
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
public File findFile(String name)
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
14
src/main/java/com/volmit/iris/util/RegistryListBiome.java
Normal file
14
src/main/java/com/volmit/iris/util/RegistryListBiome.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListBiome
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListDimension
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListGenerator
|
||||
{
|
||||
|
||||
}
|
||||
14
src/main/java/com/volmit/iris/util/RegistryListObject.java
Normal file
14
src/main/java/com/volmit/iris/util/RegistryListObject.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListObject
|
||||
{
|
||||
|
||||
}
|
||||
14
src/main/java/com/volmit/iris/util/RegistryListRegion.java
Normal file
14
src/main/java/com/volmit/iris/util/RegistryListRegion.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListRegion
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target({PARAMETER, TYPE, FIELD})
|
||||
public @interface RegistryListStructure
|
||||
{
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public class ResourceLoader<T extends IrisRegistrant>
|
||||
protected String cname;
|
||||
protected IrisLock lock;
|
||||
protected String preferredFolder = null;
|
||||
protected String[] possibleKeys = null;
|
||||
|
||||
public ResourceLoader(File root, String folderName, String resourceTypeName, Class<? extends T> objectClass)
|
||||
{
|
||||
@@ -34,6 +35,43 @@ public class ResourceLoader<T extends IrisRegistrant>
|
||||
loadCache = new KMap<>();
|
||||
}
|
||||
|
||||
public String[] getPossibleKeys()
|
||||
{
|
||||
if(possibleKeys != null)
|
||||
{
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
Iris.info("Building " + resourceTypeName + " Possibility Lists");
|
||||
KSet<String> m = new KSet<>();
|
||||
|
||||
for(File i : getFolders())
|
||||
{
|
||||
for(File j : i.listFiles())
|
||||
{
|
||||
if(j.isFile() && j.getName().endsWith(".json"))
|
||||
{
|
||||
m.add(j.getName().replaceAll("\\Q.json\\E", ""));
|
||||
}
|
||||
|
||||
else if(j.isDirectory())
|
||||
{
|
||||
for(File k : j.listFiles())
|
||||
{
|
||||
if(k.isFile() && k.getName().endsWith(".json"))
|
||||
{
|
||||
m.add(j.getName() + "/" + k.getName().replaceAll("\\Q.json\\E", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KList<String> v = new KList<>(m);
|
||||
possibleKeys = v.toArray(new String[v.size()]);
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
public long count()
|
||||
{
|
||||
return loadCache.size();
|
||||
@@ -155,6 +193,7 @@ public class ResourceLoader<T extends IrisRegistrant>
|
||||
|
||||
public void clearCache()
|
||||
{
|
||||
possibleKeys = null;
|
||||
loadCache.clear();
|
||||
folderCache = null;
|
||||
}
|
||||
@@ -191,4 +230,10 @@ public class ResourceLoader<T extends IrisRegistrant>
|
||||
{
|
||||
preferredFolder = name;
|
||||
}
|
||||
|
||||
public void clearList()
|
||||
{
|
||||
folderCache = null;
|
||||
possibleKeys = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user