Finish impementing /dial
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package net.TheDgtl.StargateCommand;
|
package net.TheDgtl.StargateCommand;
|
||||||
|
|
||||||
import net.TheDgtl.Stargate.Gate;
|
import net.TheDgtl.Stargate.Gate;
|
||||||
|
import net.TheDgtl.Stargate.Portal;
|
||||||
|
import net.TheDgtl.Stargate.Stargate;
|
||||||
import net.TheDgtl.Stargate.event.StargateActivateEvent;
|
import net.TheDgtl.Stargate.event.StargateActivateEvent;
|
||||||
import net.TheDgtl.StargateCommand.StargateCommand.Action;
|
import net.TheDgtl.StargateCommand.StargateCommand.Action;
|
||||||
|
|
||||||
@@ -80,15 +82,25 @@ public class SGCListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onStargateActivate(StargateActivateEvent event) {
|
public void onStargateActivate(StargateActivateEvent event) {
|
||||||
|
Portal portal = event.getPortal();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
SGCPlayer sPlayer = sgc.players.get(player);
|
SGCPlayer sPlayer = sgc.players.get(player);
|
||||||
if (sPlayer == null) return;
|
if (sPlayer == null) return;
|
||||||
if (sPlayer.action != Action.DIAL) return;
|
if (sPlayer.action != Action.DIAL) return;
|
||||||
if (event.getDestinations().contains(sPlayer.args[0])) {
|
|
||||||
event.setDestination(sPlayer.args[0]);
|
|
||||||
} else {
|
|
||||||
StargateCommand.sendMessage(player, "The specified destination does not exist for this gate. Exiting", true);
|
|
||||||
sgc.players.remove(player);
|
sgc.players.remove(player);
|
||||||
|
Portal destPortal = Portal.getByName(sPlayer.args[0], portal.getNetwork());
|
||||||
|
if (destPortal == null) {
|
||||||
|
StargateCommand.sendMessage(player, "The specified destination does not exist for this gate. Exiting", true);
|
||||||
|
} else {
|
||||||
|
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||||
|
StargateCommand.sendMessage(player, "You do not have access to that network.", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
portal.activate(player);
|
||||||
|
portal.setDestination(destPortal);
|
||||||
|
Stargate.openPortal(player, portal);
|
||||||
|
portal.drawSign();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,11 +279,10 @@ public class StargateCommand extends JavaPlugin {
|
|||||||
sendMessage(player, "You do not have access to that gate network", true);
|
sendMessage(player, "You do not have access to that gate network", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sourcePortal.activate(player);
|
||||||
sourcePortal.setDestination(destPortal);
|
sourcePortal.setDestination(destPortal);
|
||||||
if (!sourcePortal.open(player, false)) {
|
Stargate.openPortal(player, sourcePortal);
|
||||||
sendMessage(player, "There was an error opening the gate", true);
|
sourcePortal.drawSign();
|
||||||
return;
|
|
||||||
}
|
|
||||||
sendMessage(player, "The gate has been connected and opened", false);
|
sendMessage(player, "The gate has been connected and opened", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,22 +344,23 @@ public class StargateCommand extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (command.getName().equalsIgnoreCase("dial")) {
|
} else if (command.getName().equalsIgnoreCase("dial")) {
|
||||||
if (args.length < 1 || args.length > 2) return false;
|
if (args.length < 1 || args.length > 3) return false;
|
||||||
String dest = null;
|
String dest = null;
|
||||||
String source = null;
|
String source = null;
|
||||||
String network = null;
|
String network = null;
|
||||||
|
if (args.length == 1) {
|
||||||
dest = args[0];
|
dest = args[0];
|
||||||
if (args.length > 1) {
|
|
||||||
if (args.length < 2) {
|
|
||||||
sendMessage(player, "You must provide a network to direct dial a gate", true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
source = args[1];
|
|
||||||
network = args[2];
|
|
||||||
dialGate(player, dest, source, network);
|
|
||||||
} else {
|
|
||||||
players.put(player, new SGCPlayer(player, Action.DIAL, args));
|
players.put(player, new SGCPlayer(player, Action.DIAL, args));
|
||||||
sendMessage(player, "The next Stargate you activate will have " + dest + " set as the destination if available", false);
|
sendMessage(player, "The next Stargate you activate will connect to " + dest + " if available", false);
|
||||||
|
} else if (args.length > 1) {
|
||||||
|
source = args[0];
|
||||||
|
dest = args[1];
|
||||||
|
if (args.length < 2) {
|
||||||
|
network = args[2];
|
||||||
|
} else {
|
||||||
|
network = Stargate.getDefaultNetwork();
|
||||||
|
}
|
||||||
|
dialGate(player, dest, source, network);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ commands:
|
|||||||
Type: "/<command> cancel" to cancel any pending SGC action
|
Type: "/<command> cancel" to cancel any pending SGC action
|
||||||
dial:
|
dial:
|
||||||
description: Dial a stargate
|
description: Dial a stargate
|
||||||
usage: /<command> <destination> [source] [network]
|
usage: |
|
||||||
|
/<command> <destination>
|
||||||
|
/<command> <source> <destination> [network]
|
||||||
permissions:
|
permissions:
|
||||||
stargate.command.import:
|
stargate.command.import:
|
||||||
description: Allow the use of /sgc import
|
description: Allow the use of /sgc import
|
||||||
|
|||||||
Reference in New Issue
Block a user