This repository was archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c68a86
commit 7d462e8
Showing
15 changed files
with
390 additions
and
99 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/acceptWarp.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.minecraftplugin.Utils.warpRequest.Commands; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
public class acceptWarp { | ||
|
||
static Player recivier; | ||
static Player sender; | ||
|
||
public acceptWarp(Player send, Player recv) { | ||
recivier = recv; | ||
sender = send; | ||
} | ||
|
||
//TODO impostare il controllo del warp in classe a parte | ||
public static boolean acceptRequest() { | ||
warpreq req = warpreq.getRequestBySenderAndRecivier(sender, recivier); | ||
if (req == null) { | ||
return false; | ||
}else { | ||
//Warp the player | ||
if (req.getType() == warpreq.warpType.WARPTO) { | ||
req.warpTo(sender, recivier); | ||
warpreq.removeRequest(req); | ||
sender.sendMessage("Ti stai warpando da " + recivier.getName()); | ||
recivier.sendMessage(sender.getName() + " Si sta warpando da te"); | ||
return true; | ||
}else { | ||
//Warp the recivier of the request to the sender | ||
req.warpTo(recivier, sender); | ||
warpreq.removeRequest(req); | ||
recivier.sendMessage("Ti stai warpando da " + recivier.getName()); | ||
sender.sendMessage(sender.getName() + " Si sta warpando da te"); | ||
return true; | ||
} | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/warpreq.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.minecraftplugin.Utils.warpRequest.Commands; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class warpreq { | ||
|
||
public static List<warpreq> requestlist = new ArrayList<>(); | ||
|
||
static Player recivier; //Player that receive the request | ||
static Player sender; //Player that send request | ||
private warpType type; | ||
|
||
public warpreq(Player sender, Player recivier, warpType tpType) { | ||
this.recivier = recivier; | ||
this.sender = sender; | ||
this.type = tpType; | ||
} | ||
|
||
public Player getRequester() { | ||
return sender; | ||
} | ||
|
||
public Player getResponder() { | ||
return recivier; | ||
} | ||
|
||
public warpType getType() { | ||
return type; | ||
} | ||
|
||
public enum warpType { | ||
WARPHERE, | ||
WARPTO | ||
} | ||
|
||
public static List<warpreq> getRequestsByRevier(Player recivier) { | ||
List<warpreq> requests = new ArrayList<>(); | ||
for (warpreq request : requestlist) { | ||
if (request.recivier == recivier) { | ||
requests.add(request); | ||
} | ||
} | ||
return requests; | ||
} | ||
|
||
public static warpreq getRequestBySenderAndRecivier(Player sender, Player recivier) { | ||
for (warpreq req : requestlist) { | ||
if (req.getRequester() == sender && req.getResponder() == recivier) { | ||
return req; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public static List<warpreq> getRequestBySender(Player sender) { | ||
List<warpreq> requests = new ArrayList<>(); | ||
for (warpreq req : requestlist) { | ||
if (req.getRequester() == sender) { | ||
requests.add(req); | ||
} | ||
} | ||
return requests; | ||
} | ||
|
||
|
||
public static void addRequest(warpreq request) { | ||
requestlist.add(request); | ||
} | ||
|
||
public static void removeRequest(warpreq request) { | ||
requestlist.remove(request); | ||
} | ||
|
||
public static void warpTo(Player send, Player recv) { | ||
send.teleport(recv.getLocation()); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/wpPending.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.minecraftplugin.Utils.warpRequest.Commands; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
public class wpPending { | ||
|
||
public static String pendingRequestsRecivier(Player recv) { | ||
String requests; | ||
requests = String.valueOf(warpreq.getRequestsByRevier(recv).size()); | ||
return requests; | ||
} | ||
|
||
public static String pendingRequestsSender(Player send) { | ||
String requests; | ||
requests = String.valueOf(warpreq.getRequestBySender(send).size()); | ||
return requests; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/WarpTo.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.minecraftplugin.Utils.warpRequest.Executor; | ||
|
||
import com.minecraftplugin.Utils.warpRequest.Commands.warpreq; | ||
import com.minecraftplugin.minecraftplugin.Main; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class WarpTo implements CommandExecutor { | ||
|
||
/* | ||
* Class for the exeecutor for the warp requeto to another player | ||
* | ||
* If tou send a request you can warp yourself to him only if it accept | ||
*/ | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
|
||
if (sender instanceof Player) { | ||
//Player who send the request | ||
Player p = (Player) sender; | ||
if (args.length > 0) { | ||
//Player who recive the request | ||
Player target = Bukkit.getPlayer(args[0]); | ||
if (target != null) { | ||
if (target != p) { | ||
//TOFIX | ||
if (Boolean.parseBoolean(Main.getInstance().getConfig().getString("sendRequest"))) { | ||
//Create a new request | ||
warpreq request = new warpreq(p, target, warpreq.warpType.WARPTO); | ||
//Add it | ||
warpreq.addRequest(request); | ||
p.sendMessage("Sent request to " + target.getName()); | ||
target.sendMessage("Recivied a requesto from " + p.getName()); | ||
}else { | ||
warpreq.warpTo(p, target); | ||
//TODO messagies | ||
} | ||
}else { | ||
p.sendMessage("WTF are you doing WHY"); | ||
} | ||
}else { | ||
p.sendMessage("Questo player non esiste"); | ||
} | ||
}else { | ||
p.sendMessage("inserisci il nome del player a cui vuoi fare la richiesta"); | ||
} | ||
} | ||
return false; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpAccept.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.minecraftplugin.Utils.warpRequest.Executor; | ||
|
||
import com.minecraftplugin.Utils.warpRequest.Commands.acceptWarp; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class warpAccept implements CommandExecutor { | ||
|
||
/* | ||
* With this class you can handle the executor for accept a request pending to you | ||
* | ||
* (You accept to teleport the player tat sand to your location) | ||
*/ | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
|
||
//TODO messaggi custom yaml | ||
if (sender instanceof Player ) { | ||
//TODO switch to permission | ||
if (command.getName().equals("warpaccept")) { | ||
//Who accept | ||
Player p = (Player) sender; | ||
if (args.length > 0) { | ||
//Who sended the request | ||
Player target = Bukkit.getPlayer(args[0]); | ||
if (target != null) { | ||
if (target != p) { | ||
acceptWarp accept = new acceptWarp(target, p); | ||
acceptWarp.acceptRequest(); | ||
}else { | ||
p.sendMessage("Non hai richieste da accettare"); | ||
} | ||
}else { | ||
p.sendMessage("Questo player non esiste"); | ||
} | ||
}else { | ||
//TODO accetta tutte le richieste verso di te | ||
} | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpHereExecutor.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.minecraftplugin.Utils.warpRequest.Executor; | ||
|
||
import com.minecraftplugin.Utils.warpRequest.Commands.warpreq; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class warpHereExecutor implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { | ||
|
||
if (sender instanceof Player) { | ||
Player p = (Player)sender; | ||
if (command.getName().equals("warphere")) { | ||
if (args.length > 0) { | ||
Player target = Bukkit.getPlayer(args[0]); | ||
if (target != null) { | ||
if (target != p) { | ||
warpreq req = new warpreq(p, target, warpreq.warpType.WARPHERE); | ||
warpreq.addRequest(req); | ||
p.sendMessage("Sent warp request to you at " + target.getName()); | ||
target.sendMessage("Recivied warp request to him from " + p.getName()); | ||
}else { | ||
p.sendMessage("WHYYYYYYYYYYYYYYYY"); | ||
} | ||
}else { | ||
p.sendMessage("Questo player non esiste"); | ||
} | ||
}else { | ||
p.sendMessage("Inserisci il nome del player"); | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpList.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.minecraftplugin.Utils.warpRequest.Executor; | ||
|
||
import com.minecraftplugin.Utils.warpRequest.Commands.wpPending; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class warpList implements CommandExecutor { | ||
|
||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
|
||
if (sender instanceof Player) { | ||
Player p = (Player) sender; | ||
if (command.getName().equals("warplist")) { | ||
wpPending list = new wpPending(); | ||
p.sendMessage(wpPending.pendingRequestsSender(p)); | ||
p.sendMessage("To you " + wpPending.pendingRequestsRecivier(p)); | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.