Finish /acceptRequest
This commit is contained in:
parent
fd1e4db3d3
commit
7d452469c4
13 changed files with 82 additions and 2 deletions
|
|
@ -1,17 +1,46 @@
|
|||
package org.gsdistance.grimmsServer.Constructable;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.security.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Request {
|
||||
private UUID uuid;
|
||||
private Function<?, ?> onAccept;
|
||||
private String forPlayer;
|
||||
public String forPurpose;
|
||||
private Function<Object, ?> onAccept;
|
||||
private LocalDateTime timestamp;
|
||||
private Object requestData;
|
||||
|
||||
public Request(Function<?, ?> onAccept) {
|
||||
public Request(Function<Object, ?> onAccept, Player forPlayer, String forPurpose, Object requestData) {
|
||||
uuid = UUID.randomUUID();
|
||||
this.onAccept = onAccept;
|
||||
this.forPlayer = forPlayer.getName();
|
||||
this.forPurpose = forPurpose;
|
||||
this.requestData = requestData;
|
||||
this.timestamp = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public boolean canAccept(Player player){
|
||||
if(player.getName().equalsIgnoreCase(forPlayer)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean acceptRequest(Player player){
|
||||
if(canAccept(player)){
|
||||
onAccept.apply(requestData);
|
||||
onAccept = (Object object) -> object;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue