Skip to content

Commit

Permalink
Removed shit from code and added handle for incorrect usage of cmds.
Browse files Browse the repository at this point in the history
#5.0.1
  • Loading branch information
thematdev committed Mar 17, 2019
1 parent de2121d commit 46e7d47
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
8 changes: 4 additions & 4 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ auto:
delay: 10
messages:
- icon: 'minecraft:diamond'
header: '228'
footer: '228'
header: 'Привет!'
footer: 'Спасибо, что играешь на сервере Infinity!'
- icon: 'minecraft:gold_ingot'
header: 'gay'
footer: 'gay'
header: 'Тех.поддержка'
footer: 'vk.com/thematdev'
permission: true

25 changes: 16 additions & 9 deletions src/ru/thematdev/cm/auto/AutoMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,23 @@ public AutoMessage() {
configuration = new Configuration();

configuration.getConfig().getConfigurationSection("auto.notifications.chat").getKeys(false).forEach(node -> chatNotifications.add(configuration.getChatNotificationByNode(node)));
for (String node : configuration.config.getConfigurationSection("auto.notifications.advancement").getKeys(false)) {
plugin.getLogger().info("123");
AdvancementNotification notification = new AdvancementNotification(node,
configuration.config.getDouble(configuration.getAdvSection() + "." + node + ".delay"),
configuration.config.getMapList(configuration.getAdvSection() + "." + node + ".messages"),
configuration.config.getBoolean(configuration.getAdvSection() + "." + node + ".permission"));
advancementNotifications.add(notification);

}
configuration.getConfig().getConfigurationSection("auto.notifications.advancement").getKeys(false).forEach(node -> advancementNotifications.add(configuration.getAdvancementNotificationByNode(node)));

}

public void cancelAll() {
chatNotifications.forEach(ChatNotification::cancel);
advancementNotifications.forEach(AdvancementNotification::cancel);
}

public void startAll() {
chatNotifications.forEach(ChatNotification::start);
advancementNotifications.forEach(AdvancementNotification::start);
}

public void restartAll() {
cancelAll();
startAll();
}

}
9 changes: 6 additions & 3 deletions src/ru/thematdev/cm/command/ChatExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ public ChatExecutor(Main plugin) {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) return false;
if (args.length < 1) return false;
CommandEnum command = CommandEnum.valueOf(args[0]);
command.call((Player) sender, plugin);

try {
CommandEnum command = CommandEnum.valueOf(args[0]);
command.call((Player) sender, plugin);
} catch (Exception e) {
Utils.sendMessage((Player) sender, "&4Неккоректное использование команды!");
}
return true;
}

Expand Down

0 comments on commit 46e7d47

Please sign in to comment.