diff --git a/src/org/vivecraft/VSE.java b/src/org/vivecraft/VSE.java index 54559b4..5f35bfc 100644 --- a/src/org/vivecraft/VSE.java +++ b/src/org/vivecraft/VSE.java @@ -35,6 +35,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.mcstats.Metrics; import org.spigotmc.SpigotConfig; +import org.vivecraft.command.ConstructTabCompleter; import org.vivecraft.command.ViveCommand; import org.vivecraft.entities.CustomGoalSwell; import org.vivecraft.entities.CustomPathFinderGoalPlayerWhoLookedAtTarget; @@ -69,8 +70,12 @@ public void onEnable() { saveConfig(); // end Config part - this.getCommand("vive").setExecutor(new ViveCommand(this)); - this.getCommand("vse").setExecutor(new ViveCommand(this)); + getCommand("vive").setExecutor(new ViveCommand(this)); + getCommand("vse").setExecutor(new ViveCommand(this)); + getCommand("vive").setTabCompleter(new ConstructTabCompleter()); + getCommand("vse").setTabCompleter(new ConstructTabCompleter()); + + getServer().getMessenger().registerIncomingPluginChannel(this, CHANNEL, new VivecraftNetworkListener(this)); getServer().getMessenger().registerOutgoingPluginChannel(this, CHANNEL); diff --git a/src/org/vivecraft/command/ConstructTabCompleter.java b/src/org/vivecraft/command/ConstructTabCompleter.java new file mode 100644 index 0000000..547d75f --- /dev/null +++ b/src/org/vivecraft/command/ConstructTabCompleter.java @@ -0,0 +1,27 @@ +package org.vivecraft.command; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.command.TabCompleter; +import org.bukkit.entity.Player; + +public class ConstructTabCompleter implements TabCompleter { + + @Override + public List onTabComplete(CommandSender arg0, Command arg1, String arg2, String[] arg3) { + List list = new ArrayList(); + if(arg0 instanceof Player){ + if(arg3.length >= 1){ + for(Cmd cmd: ViveCommand.getCommands()){ + if(cmd.getCommand().startsWith(arg3[0])) + list.add(cmd.getCommand()); + } + return list; + } + } + return null; + } +} diff --git a/src/org/vivecraft/command/ViveCommand.java b/src/org/vivecraft/command/ViveCommand.java index f23e702..a5835ed 100644 --- a/src/org/vivecraft/command/ViveCommand.java +++ b/src/org/vivecraft/command/ViveCommand.java @@ -13,7 +13,7 @@ public class ViveCommand implements CommandExecutor { private VSE plugin; - private ArrayList commands = new ArrayList(); + private static ArrayList commands = new ArrayList(); public ViveCommand(VSE vse) { plugin = vse; @@ -23,6 +23,11 @@ public ViveCommand(VSE vse) { commands.add(new Cmd("sendplayerdata", "set to false to disable sending player to data to clients. Default: true")); commands.add(new Cmd("creeperradius", "type false to disable or type a number to change the radius. Default: 1.75")); commands.add(new Cmd("bow", "Sets the multiplier for bow damage of vive users. Default: 2")); + commands.add(new Cmd("checkforupdate", "Checked for an update every time an OP joins the server")); + } + + public static ArrayList getCommands(){ + return commands; } @Override @@ -116,6 +121,20 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String sendMessage("Version: " + version, player); } else // + if(command.equals("checkforupdate")){ + if(args.length >= 2){ + if(args[1].toLowerCase().equals("true")){ + plugin.getConfig().set("checkforupdate.enabled", true); + sendMessage("Update checker has been enabled.", player); + }else if (args[1].toLowerCase().equals("false")) { + plugin.getConfig().set("checkforupdate.enabled", false); + sendMessage("Update checker has been disabled.", player); + } + }else{ + sendMessage("Check for update: " + plugin.getConfig().get("checkforupdate.enabled"),player); + } + }else + // if (command.equals("help")) { for (Cmd cm : commands) { sendMessage(cm.getCommand() + " - " + cm.getDescription(), player); diff --git a/src/org/vivecraft/listeners/VivecraftNetworkListener.java b/src/org/vivecraft/listeners/VivecraftNetworkListener.java index 6800ed2..07e9308 100644 --- a/src/org/vivecraft/listeners/VivecraftNetworkListener.java +++ b/src/org/vivecraft/listeners/VivecraftNetworkListener.java @@ -73,6 +73,8 @@ public void onPluginMessageReceived(String channel, Player sender, byte[] payloa BufferedReader br = new BufferedReader(is); VSE.vivePlayers.put(sender.getUniqueId(), new VivePlayer(sender)); + sender.sendPluginMessage(vse, vse.CHANNEL, StringToPayload(PacketDiscriminators.VERSION, vse.getDescription().getFullName())); + VivePlayer vivepl = VSE.vivePlayers.get(sender.getUniqueId()); try { String version = br.readLine(); @@ -87,15 +89,17 @@ public void onPluginMessageReceived(String channel, Player sender, byte[] payloa if(vse.getConfig().getBoolean("welcomemsg.enabled")) ViveCommand.sendMessage(vse.getConfig().getString("welcomemsg.welcomeVR"),sender); + + if(vse.getConfig().getBoolean("SendPlayerData.enabled") == true) + sender.sendPluginMessage(vse, vse.CHANNEL, new byte[]{(byte) PacketDiscriminators.REQUESTDATA.ordinal()}); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - sender.sendPluginMessage(vse, vse.CHANNEL, StringToPayload(PacketDiscriminators.VERSION, vse.getDescription().getFullName())); - if(vse.getConfig().getBoolean("SendPlayerData.enabled") == true) - sender.sendPluginMessage(vse, vse.CHANNEL, new byte[]{(byte) PacketDiscriminators.REQUESTDATA.ordinal()}); + + break; case WORLDSCALE: break; diff --git a/version.txt b/version.txt index 1147cfa..362cd94 100644 --- a/version.txt +++ b/version.txt @@ -1,3 +1,4 @@ #this file is used to check for updates 1.11-r3: VSE has a new update download at https://github.com/jrbudda/Vivecraft_Spigot_Extensions/releases -1.11-r4: VSE is up to date! \ No newline at end of file +1.11-r4: VSE is up to date! +1.11-r5: VSE is up to date! \ No newline at end of file