diff --git a/src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/acceptWarp.java b/src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/acceptWarp.java index 16e0f1f..a5b142a 100644 --- a/src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/acceptWarp.java +++ b/src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/acceptWarp.java @@ -4,34 +4,34 @@ public class acceptWarp { - static Player recivier; - static Player sender; + private warpreq req; - public acceptWarp(Player send, Player recv) { - recivier = recv; - sender = send; + public acceptWarp(warpreq request) { + this.req = request; } //TODO impostare il controllo del warp in classe a parte - public static boolean acceptRequest() { - warpreq req = warpreq.getRequestBySenderAndRecivier(sender, recivier); + public void acceptRequest() { + + Player sender = req.getRequester(); + Player recivier = req.getResponder(); + if (req == null) { - return false; + sender.sendMessage("Sesso"); }else { - //Warp the player + //Warp the player1 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; + warpreq.warpTo(sender, recivier); + warpreq.removeRequest(req); }else { //Warp the recivier of the request to the sender - req.warpTo(recivier, sender); - warpreq.removeRequest(req); + //Request type = WPHERE recivier.sendMessage("Ti stai warpando da " + recivier.getName()); sender.sendMessage(sender.getName() + " Si sta warpando da te"); - return true; + warpreq.warpTo(recivier, sender); + warpreq.removeRequest(req); } } } diff --git a/src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/warpreq.java b/src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/warpreq.java index 9b61869..d658c3c 100644 --- a/src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/warpreq.java +++ b/src/main/java/com/minecraftplugin/Utils/warpRequest/Commands/warpreq.java @@ -8,8 +8,8 @@ public class warpreq { public static List requestlist = new ArrayList<>(); - static Player recivier; //Player that receive the request - static Player sender; //Player that send request + private Player recivier; //Player that receive the request + private Player sender; //Player that send request private warpType type; public warpreq(Player sender, Player recivier, warpType tpType) { @@ -47,7 +47,7 @@ public static List getRequestsByRevier(Player recivier) { public static warpreq getRequestBySenderAndRecivier(Player sender, Player recivier) { for (warpreq req : requestlist) { - if (req.getRequester() == sender && req.getResponder() == recivier) { + if (req.getRequester() == recivier && req.getResponder() == sender) { return req; } } @@ -57,7 +57,7 @@ public static warpreq getRequestBySenderAndRecivier(Player sender, Player recivi public static List getRequestBySender(Player sender) { List requests = new ArrayList<>(); for (warpreq req : requestlist) { - if (req.getRequester() == sender) { + if (req.sender == sender) { requests.add(req); } } diff --git a/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/WarpTo.java b/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/WarpTo.java index 60075b2..2ee1838 100644 --- a/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/WarpTo.java +++ b/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/WarpTo.java @@ -27,14 +27,18 @@ public boolean onCommand(CommandSender sender, Command command, String label, St Player target = Bukkit.getPlayer(args[0]); if (target != null) { if (target != p) { - //TOFIX + //FIX 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()); + if (warpreq.getRequestBySender(p).size() >= 1) { + p.sendMessage("You have already sent a request to " + target.getName()); + }else { + 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 diff --git a/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpAccept.java b/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpAccept.java index dda56c4..e2f1376 100644 --- a/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpAccept.java +++ b/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpAccept.java @@ -1,6 +1,7 @@ package com.minecraftplugin.Utils.warpRequest.Executor; import com.minecraftplugin.Utils.warpRequest.Commands.acceptWarp; +import com.minecraftplugin.Utils.warpRequest.Commands.warpreq; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -29,16 +30,30 @@ public boolean onCommand(CommandSender sender, Command command, String label, St Player target = Bukkit.getPlayer(args[0]); if (target != null) { if (target != p) { - acceptWarp accept = new acceptWarp(target, p); - acceptWarp.acceptRequest(); + warpreq req = warpreq.getRequestBySenderAndRecivier(p, target); + if (req != null) { + if (p == req.getResponder()) { + acceptWarp accept = new acceptWarp(req); + accept.acceptRequest(); + }else { + p.sendMessage("Tou cannot accept your request"); + } + }else{ + p.sendMessage("There is no request"); + } }else { - p.sendMessage("Non hai richieste da accettare"); + p.sendMessage("Why are you doing this"); } }else { p.sendMessage("Questo player non esiste"); } }else { - //TODO accetta tutte le richieste verso di te + //Accept the last request + if (warpreq.getRequestBySender(p).size() == 1){ + warpreq request = warpreq.getRequestBySender(p).get(0); + acceptWarp accept_all = new acceptWarp(request); + accept_all.acceptRequest(); + } } } return true; diff --git a/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpHereExecutor.java b/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpHereExecutor.java index 564959d..aa7488c 100644 --- a/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpHereExecutor.java +++ b/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpHereExecutor.java @@ -18,6 +18,7 @@ public boolean onCommand(CommandSender sender, Command command, String s, String Player target = Bukkit.getPlayer(args[0]); if (target != null) { if (target != p) { + //TODO add one request only warpreq req = new warpreq(p, target, warpreq.warpType.WARPHERE); warpreq.addRequest(req); p.sendMessage("Sent warp request to you at " + target.getName()); diff --git a/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpNo.java b/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpNo.java index 38ff640..76de243 100644 --- a/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpNo.java +++ b/src/main/java/com/minecraftplugin/Utils/warpRequest/Executor/warpNo.java @@ -8,6 +8,8 @@ import org.bukkit.entity.Player; public class warpNo implements CommandExecutor { + + //TODO remove all @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -16,11 +18,25 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if (command.getName().equals("warpno")){ if (args.length > 0) { Player target = Bukkit.getPlayer(args[0]); - warpreq req = warpreq.getRequestBySenderAndRecivier(p, target); - if (req.getRequester() == p) { - req.removeRequest(req); + if (target != null) { + if (target != p) { + warpreq req = warpreq.getRequestBySenderAndRecivier(p, target); + if (req != null) { + if (req.getResponder() == p) { + warpreq.removeRequest(req); + p.sendMessage("Declined request"); + target.sendMessage(p.getName() + " declined your request"); + } else { + p.sendMessage("You have no request from this player"); + } + }else { + p.sendMessage("Tardino"); + } + }else { + p.sendMessage("Ma si babb"); + } }else { - p.sendMessage("You have no request from this player"); + p.sendMessage("Il player non esiste"); } } } diff --git a/src/main/java/com/minecraftplugin/minecraftplugin/Main.java b/src/main/java/com/minecraftplugin/minecraftplugin/Main.java index 356dec2..47b4895 100644 --- a/src/main/java/com/minecraftplugin/minecraftplugin/Main.java +++ b/src/main/java/com/minecraftplugin/minecraftplugin/Main.java @@ -2,11 +2,8 @@ import com.minecraftplugin.Completer.Tabcompleter; import com.minecraftplugin.Executors.*; -import com.minecraftplugin.Utils.warpRequest.Executor.warpAccept; -import com.minecraftplugin.Utils.warpRequest.Executor.warpHereExecutor; -import com.minecraftplugin.Utils.warpRequest.Executor.warpList; +import com.minecraftplugin.Utils.warpRequest.Executor.*; import com.minecraftplugin.data.data; -import com.minecraftplugin.Utils.warpRequest.Executor.WarpTo; import org.bukkit.plugin.java.JavaPlugin; import java.util.logging.Logger; @@ -40,7 +37,7 @@ public void onEnable() { this.getCommand("warpaccept").setExecutor(new warpAccept()); this.getCommand("warphere").setExecutor(new warpHereExecutor()); this.getCommand("warplist").setExecutor(new warpList()); - this.getCommand("warpno").setExecutor(new warpList()); + this.getCommand("warpno").setExecutor(new warpNo()); this.saveDefaultConfig(); this.reloadConfig(); data = new data(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 52ddb78..e8cda88 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ #Config file for all commands and possibilities -#If you have some isessues look at the source code https://github.com/PepegaBruh/EasyWarpPlugin +#If you have some issues look at the source code https://github.com/PepegaBruh/EasyWarpPlugin #By default is set to true #if is set to true only the owner of the warp can delete itself. @@ -18,15 +18,15 @@ sendRequest: true #By default you can't disable the request from a player to him -#Modify this to change the prefix of the messagies in the chat +#Modify this to change the prefix of the messages in the chat #Dont remove the space at the end of the line, or everything will be written attached messagiesPrefix: "&5[EasyWarp] " messagies: - #In this section you can change the messagies for the warp + #In this section you can change the messages for the warp #Chenge the number after the "&" to change the color warp: - warped: "&6You warped yoursef" + warped: "&6You warped yourself" notExist: "&6There is no warp with this name" arg: "%cInsert a warp name" permission: "&cYou not have this permission"