mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
See description
- Catch /locate to be rerouted to /ir std goto - Add "/ir locate", also directly points to /ir std goto
This commit is contained in:
parent
81b1f06eec
commit
44e1b8f159
@ -6,19 +6,29 @@ import com.volmit.iris.util.KList;
|
|||||||
import com.volmit.iris.util.MortarCommand;
|
import com.volmit.iris.util.MortarCommand;
|
||||||
import com.volmit.iris.util.MortarSender;
|
import com.volmit.iris.util.MortarSender;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class CommandLocate extends MortarCommand implements Listener
|
public class CommandLocate extends MortarCommand implements Listener
|
||||||
{
|
{
|
||||||
|
CommandLocate instance;
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||||
if (!event.getMessage().contains("stronghold") && event.getMessage().contains("locate") && IrisWorlds.isIrisWorld(event.getPlayer().getWorld())) {
|
if (IrisWorlds.isIrisWorld(event.getPlayer().getWorld())){
|
||||||
event.setCancelled(true);
|
|
||||||
event.getPlayer().sendMessage("/locate command blocked in Iris worlds. Please use '/ir std goto' instead. You can /locate stronghold!");
|
// Make sure the command starts with /locate and does not locate stronghold
|
||||||
|
if (event.getMessage().contains("/locate") && event.getMessage().contains("stronghold")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.getMessage().contains("/locate")) {
|
||||||
|
event.setCancelled(true); // Cancel the vanilla command process
|
||||||
|
event.getPlayer().sendMessage("/locate command overwritten in Iris worlds. Ran /ir std goto instead");
|
||||||
|
String command = event.getMessage().replace("/locate", "/ir std goto");
|
||||||
|
Bukkit.dispatchCommand(event.getPlayer(), command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,27 +36,13 @@ public class CommandLocate extends MortarCommand implements Listener
|
|||||||
{
|
{
|
||||||
super("locate");
|
super("locate");
|
||||||
requiresPermission(Iris.perm);
|
requiresPermission(Iris.perm);
|
||||||
|
this.instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(MortarSender sender, String[] args)
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
{
|
{
|
||||||
sender.sendMessage("Locate command");
|
Bukkit.dispatchCommand(sender, "/ir std goto " + Arrays.toString(args));
|
||||||
if(sender.isPlayer()) {
|
|
||||||
Player p = sender.player();
|
|
||||||
World world = p.getWorld();
|
|
||||||
if (!IrisWorlds.isIrisWorld(world)) {
|
|
||||||
String cmd = "locate";
|
|
||||||
for (int i = 0; i < args.length; i++){
|
|
||||||
cmd.concat(" " + args[i]);
|
|
||||||
}
|
|
||||||
Bukkit.dispatchCommand(sender, cmd);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage("You are in an Iris world and the /locate command is currently disabled in those.");
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("Players only");
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +54,6 @@ public class CommandLocate extends MortarCommand implements Listener
|
|||||||
@Override
|
@Override
|
||||||
protected String getArgsUsage()
|
protected String getArgsUsage()
|
||||||
{
|
{
|
||||||
return "";
|
return "[biome/region/structure]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user