Skip to content

Instantly share code, notes, and snippets.

@boformer
Last active August 29, 2015 14:14
Show Gist options
  • Save boformer/5b69e034ed176dd28ebe to your computer and use it in GitHub Desktop.
Save boformer/5b69e034ed176dd28ebe to your computer and use it in GitHub Desktop.
Creating a Request class
package example.request;
import java.util.Arrays;
import java.util.List;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.text.message.Message;
import org.spongepowered.api.text.message.Messages;
import com.github.boformer.doublecheck.api.AbstractRequest;
public class TeleportRequest extends AbstractRequest
{
private final Player fromPlayer;
private final Player toPlayer;
public TeleportRequest(Player fromPlayer, Player toPlayer, int expirationTime)
{
super(toPlayer, expirationTime);
this.fromPlayer = fromPlayer;
this.toPlayer = toPlayer;
}
@Override
public Message getMessage()
{
return (Message) Messages.of(fromPlayer.getName() + " requested a teleport to you.");
}
@Override
public void confirm()
{
fromPlayer.sendMessage("Teleporting...");
fromPlayer.setLocation(toPlayer.getLocation());
}
@Override
public void deny()
{
fromPlayer.sendMessage("Teleport request denied by " + toPlayer.getName() + "!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment