1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-12 12:16:51 +01:00
Jobs/com/gamingmesh/jobs/commands/list/give.java

56 lines
1.8 KiB
Java
Raw Normal View History

2016-03-30 15:42:36 +02:00
package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobItems;
import com.gamingmesh.jobs.stuff.GiveItem;
public class give implements Cmd {
2016-06-25 17:56:59 +02:00
@Override
2016-03-30 15:42:36 +02:00
@JobCommand(2500)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
2016-03-30 15:42:36 +02:00
if (args.length < 1 || Jobs.getJob(args[0]) == null && Jobs.getJob(args[1]) == null) {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
if (args.length == 2 && sender instanceof Player) {
Job job = Jobs.getJob(args[0]);
for (JobItems item : job.getItems()) {
if (item.getNode().equalsIgnoreCase(args[1])) {
GiveItem.GiveItemForPlayer((Player) sender, item.getId(), 0, 1, item.getName(), item.getLore(), item.getEnchants());
2016-03-30 15:42:36 +02:00
return true;
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
} else if (args.length == 3) {
Job job = Jobs.getJob(args[1]);
Player player = Bukkit.getPlayer(args[0]);
if (player == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.notonline", "%playername%", args[0]));
return true;
}
for (JobItems item : job.getItems()) {
if (item.getNode().equalsIgnoreCase(args[2])) {
GiveItem.GiveItemForPlayer(player, item.getId(), 0, 1, item.getName(), item.getLore(), item.getEnchants());
2016-03-30 15:42:36 +02:00
return true;
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.give.output.noitem"));
return true;
} else {
Jobs.getCommandManager().sendUsage(sender, "give");
return true;
}
}
}