create has method generator
All checks were successful
studiorailgun/highlevel-netcode-gen/pipeline/head This commit looks good
All checks were successful
studiorailgun/highlevel-netcode-gen/pipeline/head This commit looks good
This commit is contained in:
parent
2c638fca2f
commit
c719513510
@ -0,0 +1,55 @@
|
||||
package electrosphere.main.core.btree.methods;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.main.project.ProjectStructure;
|
||||
import electrosphere.main.source.VirtualMethod;
|
||||
import electrosphere.main.util.TemplateInjectionUtils;
|
||||
|
||||
/**
|
||||
* Check if btree is on entity
|
||||
*/
|
||||
public class HasChecker implements VirtualMethod {
|
||||
|
||||
//The name of the btree
|
||||
String name;
|
||||
|
||||
//The classname of the btree
|
||||
String className;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param name
|
||||
* @param className
|
||||
*/
|
||||
public HasChecker(String name, String className){
|
||||
this.name = name;
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(ProjectStructure projectStructure) {
|
||||
String rVal = "has" + className;
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContent(ProjectStructure projectStructure) {
|
||||
String rVal = TemplateInjectionUtils.getFragmentWithReplacement("/btree/EntityHasMethod.java", this.className, "TREE_" + this.name.toUpperCase());
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getImports(ProjectStructure projectStructure) {
|
||||
List<String> rVal = Arrays.asList(new String[]{
|
||||
});
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldOverwrite(){
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,6 +17,7 @@ import electrosphere.main.core.btree.methods.ClientInterrupt;
|
||||
import electrosphere.main.core.btree.methods.ClientStart;
|
||||
import electrosphere.main.core.btree.methods.Constructor;
|
||||
import electrosphere.main.core.btree.methods.Fetch;
|
||||
import electrosphere.main.core.btree.methods.HasChecker;
|
||||
import electrosphere.main.core.btree.methods.ServerAttach;
|
||||
import electrosphere.main.core.btree.methods.ServerDetach;
|
||||
import electrosphere.main.targets.TargetFile;
|
||||
@ -87,6 +88,7 @@ public class BTreeParser {
|
||||
|
||||
rVal.addMethod(new Constructor(bTreeName, target.getSource().getName()));
|
||||
rVal.addMethod(new Fetch(bTreeName, target.getSource().getName()));
|
||||
rVal.addMethod(new HasChecker(bTreeName, target.getSource().getName()));
|
||||
|
||||
addOptionalMethods(mainAnnotation,rVal);
|
||||
|
||||
|
||||
10
src/main/resources/btree/EntityHasMethod.java
Normal file
10
src/main/resources/btree/EntityHasMethod.java
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* <p>
|
||||
* Checks if the entity has a REPLACE_0_ME component
|
||||
* </p>
|
||||
* @param entity the entity
|
||||
* @return true if the entity contains the component, false otherwise
|
||||
*/
|
||||
public static boolean hasREPLACE_0_ME(Entity entity){
|
||||
return entity.containsKey(EntityDataStrings.REPLACE_1_ME);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user