Java Code Examples for openperipheral.api.adapter.method.ReturnType#STRING

The following examples show how to use openperipheral.api.adapter.method.ReturnType#STRING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdapterSkull.java    From OpenPeripheral-Integration with MIT License 6 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING)
public String getType(TileEntitySkull skull) {
	int skullType = skull.func_145904_a();

	switch (skullType) {
		case 0:
			return "skeleton";
		case 1:
			return "wither_skeleton";
		case 2:
			return "zombie";
		case 3:
			return "player";
		case 4:
			return "creeper";
	}

	return "unknown";
}
 
Example 2
Source File: AdapterStorage.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(returnTypes = { ReturnType.NUMBER, ReturnType.STRING })
public IMultiReturn getCellStatus(IChestOrDrive target, @Arg(name = "slot") Index slot) {
	try {
		int status = target.getCellStatus(slot.value);
		return MultiReturn.wrap(status, intToState(status));
	} catch (IndexOutOfBoundsException e) {
		throw new IllegalArgumentException("Invalid cell index: " + slot);
	}
}
 
Example 3
Source File: AdapterSkull.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@MultipleReturn
@ScriptCallable(returnTypes = { ReturnType.STRING, ReturnType.STRING })
public Object[] getPlayer(TileEntitySkull skull) {
	if (skull.func_145904_a() != 3) return new Object[] { null, null };

	GameProfile profile = skull.func_152108_a();
	if (profile == null) return new Object[] { null, null };

	return new Object[] { profile.getId(), profile.getName() };
}
 
Example 4
Source File: MethodDescriptionTest.java    From OpenPeripheral with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING)
public String test(T target, @Env("env1") E access, @Arg(name = "a") P a) {
	return String.valueOf(a);
}
 
Example 5
Source File: AdapterBeacon.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING, description = "Get the primary effect of the beacon")
public String getPrimaryEffect(TileEntityBeacon beacon) {
	Integer effectId = beacon.getPrimaryEffect();
	return getEffectName(effectId);
}
 
Example 6
Source File: AdapterInventory.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING, description = "Get the name of this inventory")
public String getInventoryName(IInventory target) {
	IInventory inventory = InventoryUtils.getInventory(target);
	return inventory != null? inventory.getInventoryName() : null;
}
 
Example 7
Source File: AdapterEssentiaTransport.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING, description = "Returns the type of essentia in the tube")
public String getEssentiaType(IEssentiaTransport pipe,
		@Arg(description = "Direction suction coming from", name = "direction") ForgeDirection direction) {
	Aspect asp = pipe.getEssentiaType(direction);
	return (asp != null)? asp.getTag() : "";
}
 
Example 8
Source File: AdapterDeconstructor.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING, description = "What aspect does the Table contain")
public String getAspect(Object target) throws Exception {
	Aspect aspect = ASPECT.get(target);
	return aspect != null? aspect.getTag() : "";
}
 
Example 9
Source File: MethodDescriptionTest.java    From OpenPeripheral with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING)
public String test(B target, @Optionals @Arg(name = "a") String b) {
	return "A";
}
 
Example 10
Source File: AdapterNode.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING, description = "Get the type of the node")
public String getNodeType(INode node) {
	NodeType nodeType = node.getNodeType();
	return (nodeType != null? nodeType.name() : NONE);
}
 
Example 11
Source File: AdapterCrop.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING)
public String getID(ICropTile target) {
	final CropCard crop = target.getCrop();
	return crop != null? crop.name() : "";
}
 
Example 12
Source File: AdapterPipe.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Get type of pipe", returnTypes = ReturnType.STRING)
public PipeType getPipeType(IPipeTile target) {
	return target.getPipeType();
}
 
Example 13
Source File: AdapterRedstoneControl.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING)
public ControlMode getRedstoneControl(IRedstoneControl target) {
	return target.getControl();
}
 
Example 14
Source File: AdapterSecureTile.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Gets the AccessMode of this machine.", returnTypes = ReturnType.STRING)
public AccessMode getAccess(ISecurable tile) {
	return tile.getAccess();
}
 
Example 15
Source File: MethodsListerHelper.java    From OpenPeripheral with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING, description = "Brief description of method")
public String doc(@Arg(name = "method") String methodName) {
	IMethodExecutor method = methods.get(methodName);
	Preconditions.checkArgument(method != null, "Method not found");
	return DocUtils.doc(method.description());
}
 
Example 16
Source File: AdapterSecureTile.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@ScriptCallable(description = "Gets the owner of the machine.", returnTypes = ReturnType.STRING)
public String getOwnerName(ISecurable tile) {
	return tile.getOwnerName();
}
 
Example 17
Source File: LuaReflectionHelper.java    From OpenPeripheral with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING)
public String getSuperclass(@Env("target") Object owner) {
	return owner.getClass().getSuperclass().toString();
}
 
Example 18
Source File: MethodDescriptionTest.java    From OpenPeripheral with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING)
public String test(B target, @Arg(name = "a") int a, @Optionals @Arg(name = "b") String b) {
	return "A";
}
 
Example 19
Source File: MethodDescriptionTest.java    From OpenPeripheral with MIT License 4 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING)
public String test(B target, @Env("env1") D access, @Arg(name = "a") Integer a) {
	return access.toString();
}
 
Example 20
Source File: AdapterSign.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@Asynchronous
@ScriptCallable(returnTypes = ReturnType.STRING, description = "Gets the text on the sign")
public String getText(TileEntitySign sign) {
	return StringUtils.join(sign.signText, '\n');
}