Created
December 10, 2014 21:17
-
-
Save Limeth/d95345c5f9ab21c2edbf to your computer and use it in GitHub Desktop.
Command varargs test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sun.xml.internal.ws.util.StringUtils; | |
import org.terasology.entitySystem.entity.EntityRef; | |
import org.terasology.entitySystem.systems.BaseComponentSystem; | |
import org.terasology.entitySystem.systems.RegisterSystem; | |
import org.terasology.logic.console.Command; | |
import org.terasology.logic.console.CommandParam; | |
import java.lang.reflect.Constructor; | |
/** | |
* Created by Limeth on 8.12.2014. | |
*/ | |
@RegisterSystem | |
public class CommandSelect extends BaseComponentSystem | |
{ | |
@Command( | |
shortDescription = "Test command for the new system", | |
helpText = "You're beyond any help.", | |
runOnServer = true | |
) | |
public String tell(@CommandParam("players") String[] players, //Yes, you can use different array types. | |
@CommandParam(value = "Message", arrayDelimiter = ' ') String[] rawMessage, | |
EntityRef sender) | |
{ | |
if(rawMessage.length <= 0) | |
return "Provide a message to send, please. :<"; | |
String message = rawMessage[0]; | |
for(int i = 1; i < rawMessage.length; i++) | |
message += " " + rawMessage[i]; | |
String reply = ""; | |
for(String player : players) | |
reply += "You -> " + player + ": " + message + "\n"; | |
return reply; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment