forked from Geoffrey/Geoffrey-MC-Plugin
Added register command
parent
323f5aafa5
commit
d834c95b00
|
@ -0,0 +1,62 @@
|
||||||
|
package com.zerohighdef.geoffrey.Commands;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.zerohighdef.geoffrey.GeoffreyMC;
|
||||||
|
import com.zerohighdef.geoffrey.Objects.GeoffreyAPICallback;
|
||||||
|
import com.zerohighdef.geoffrey.Objects.GeoffreyCommandError;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class RegisterCommand extends GeoffreyCommand{
|
||||||
|
|
||||||
|
public RegisterCommand(GeoffreyMC plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
|
if ((sender instanceof Player)) {
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
Player player = ((Player) sender).getPlayer();
|
||||||
|
|
||||||
|
params.put("player_name", player.getName());
|
||||||
|
params.put("discord_uuid", "");
|
||||||
|
|
||||||
|
RunCommand("register", params, Method.POST , new CommandCallback(sender));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Console can not register!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CommandCallback extends GeoffreyAPICallback {
|
||||||
|
|
||||||
|
CommandCallback(CommandSender sender) {
|
||||||
|
super(sender);
|
||||||
|
errors.put("LocationLookUpError", "You have more than one location. Please specify a name.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(String s) {
|
||||||
|
try {
|
||||||
|
JsonElement json = parseJSON(s);
|
||||||
|
commandSender.sendMessage(ChatColor.GREEN + "You have been registered for Geoffrey!");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (GeoffreyCommandError e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.zerohighdef.geoffrey;
|
||||||
|
|
||||||
import com.zerohighdef.geoffrey.Commands.AddLocationCommand;
|
import com.zerohighdef.geoffrey.Commands.AddLocationCommand;
|
||||||
import com.zerohighdef.geoffrey.Commands.FindCommand;
|
import com.zerohighdef.geoffrey.Commands.FindCommand;
|
||||||
|
import com.zerohighdef.geoffrey.Commands.RegisterCommand;
|
||||||
import com.zerohighdef.geoffrey.Commands.SellingCommand;
|
import com.zerohighdef.geoffrey.Commands.SellingCommand;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
@ -37,6 +38,9 @@ public final class GeoffreyMC extends JavaPlugin {
|
||||||
this.getCommand("geoffrey_add_town").setExecutor(addLocationCommand);
|
this.getCommand("geoffrey_add_town").setExecutor(addLocationCommand);
|
||||||
this.getCommand("geoffrey_add_farm").setExecutor(addLocationCommand);
|
this.getCommand("geoffrey_add_farm").setExecutor(addLocationCommand);
|
||||||
this.getCommand("geoffrey_add_attraction").setExecutor(addLocationCommand);
|
this.getCommand("geoffrey_add_attraction").setExecutor(addLocationCommand);
|
||||||
|
|
||||||
|
RegisterCommand registerCommand = new RegisterCommand(this);
|
||||||
|
this.getCommand("geoffrey_register").setExecutor(registerCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,16 @@ commands:
|
||||||
aliases: [add_market]
|
aliases: [add_market]
|
||||||
permission: geoffrey.add
|
permission: geoffrey.add
|
||||||
usage: Adds a market at your current location to Geoffrey
|
usage: Adds a market at your current location to Geoffrey
|
||||||
|
geoffrey_register:
|
||||||
|
description: Registers a player for Geoffrey
|
||||||
|
aliases: [register]
|
||||||
|
permission: geoffrey.register
|
||||||
|
usage: Registers you in Geoffrey
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
add:
|
add:
|
||||||
description: Permission to add things to Geoffrey
|
description: Permission to add things to Geoffrey
|
||||||
|
default: false
|
||||||
|
register:
|
||||||
|
description: Permission to register in Geoffrey
|
||||||
|
default: false
|
||||||
|
|
Loading…
Reference in New Issue