Last active
August 29, 2015 14:14
-
-
Save boformer/5b69e034ed176dd28ebe to your computer and use it in GitHub Desktop.
Creating a Request class
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
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