use of com.solinia.solinia.Interfaces.ISoliniaGod in project solinia3-core by mixxit.
the class CommandEditGod method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!sender.isOp() && !sender.hasPermission("solinia.editgod")) {
player.sendMessage("This is an operator only command");
return false;
}
}
if (args.length == 0) {
return false;
}
int godid = Integer.parseInt(args[0]);
if (args.length == 1) {
try {
ISoliniaGod solgod = StateManager.getInstance().getConfigurationManager().getGod(godid);
if (solgod != null) {
solgod.sendGodSettingsToSender(sender);
} else {
sender.sendMessage("ID doesnt exist");
}
return true;
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
if (args.length < 3) {
sender.sendMessage("Insufficient arguments: godid setting value");
return false;
}
String setting = args[1];
String value = args[2];
// a string
if (args.length > 3 && setting.toLowerCase().contains("description")) {
value = "";
int current = 0;
for (String entry : args) {
current++;
if (current <= 2)
continue;
value = value + entry + " ";
}
value = value.trim();
}
if (godid < 1) {
sender.sendMessage("Invalid god id");
return false;
}
try {
if (StateManager.getInstance().getConfigurationManager().getGod(godid) == null) {
sender.sendMessage("Cannot locate god id: " + godid);
return false;
}
StateManager.getInstance().getConfigurationManager().editGod(godid, setting, value);
sender.sendMessage("Updating setting on god");
} catch (InvalidGodSettingException ne) {
sender.sendMessage("Invalid god setting: " + ne.getMessage());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaGod in project solinia3-core by mixxit.
the class SoliniaGodFactory method CreateGod.
public static ISoliniaGod CreateGod(String name) throws CoreStateInitException {
SoliniaGod entry = new SoliniaGod();
entry.setId(StateManager.getInstance().getConfigurationManager().getNextGodId());
entry.setName(name);
return StateManager.getInstance().getConfigurationManager().addGod(entry);
}
use of com.solinia.solinia.Interfaces.ISoliniaGod in project solinia3-core by mixxit.
the class ChatUtils method sendGodInfo.
public static void sendGodInfo(CommandSender sender) throws CoreStateInitException {
for (ISoliniaGod entry : StateManager.getInstance().getConfigurationManager().getGods()) {
TextComponent tc = new TextComponent();
tc.setText(ChatColor.RED + "~ GOD: " + ChatColor.GOLD + entry.getName().toUpperCase() + ChatColor.GRAY + " [" + entry.getId() + "] - " + ChatColor.RESET);
TextComponent tc2 = new TextComponent();
tc2.setText("Hover for more details");
String details = ChatColor.GOLD + entry.getName() + ChatColor.RESET + System.lineSeparator() + "Recommended Alignment: " + ChatColor.GOLD + entry.getAlignment() + ChatColor.RESET + System.lineSeparator() + entry.getDescription();
tc2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create()));
tc.addExtra(tc2);
sender.spigot().sendMessage(tc);
}
}
use of com.solinia.solinia.Interfaces.ISoliniaGod in project solinia3-core by mixxit.
the class CommandCreateGod method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
try {
if (!sender.isOp() && !sender.hasPermission("solinia.creategod")) {
sender.sendMessage("You do not have permission to access this command");
return false;
}
if (args.length < 1) {
sender.sendMessage("Insufficient arguments: name");
return false;
}
// args
// defaultnpcid
// spawngroupname
String godname = args[0];
if (godname.equals("")) {
sender.sendMessage("Blank name not allowed when creating god");
return false;
}
godname = godname.replace(" ", "_").toUpperCase();
if (StateManager.getInstance().getConfigurationManager().getGod(godname) != null) {
sender.sendMessage("God already exists");
return true;
}
ISoliniaGod god = SoliniaGodFactory.CreateGod(godname);
sender.sendMessage("Created god: " + god.getId());
return true;
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaGod in project solinia3-core by mixxit.
the class JsonGodRepository method reload.
@Override
public void reload() {
List<ISoliniaGod> file = new ArrayList<ISoliniaGod>();
try {
Gson gson = new Gson();
BufferedReader br = new BufferedReader(new FileReader(filePath));
file = gson.fromJson(br, new TypeToken<List<SoliniaGod>>() {
}.getType());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Gods.clear();
for (ISoliniaGod i : file) {
Gods.put(i.getId(), i);
}
System.out.println("Reloaded " + Gods.size() + " Gods");
}
Aggregations