Разрешается выкладывание кода, файлов конфигураций, логов и т.д. только под BB-код CODE
проблема: в мене є клас коли ти водиш команду ти добавляешься в список religioni після того в том самому класе проверка якщо ти їсиш свинину тоді перевіряється чи ти є в списку, якщо так то дається ефект. Все прекрасно робе без проверки на список игроков і сам список (проверяв на ефект в sposobnost) що треба добавити щоб воно заработало?(якщо можна то можете засунуть активаторь евента в sposobnost) сам код
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
public class Islam implements CommandExecutor, Listener {
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
Player player = (Player) sender;
religioni.add(player.getName());
sposobnost(player);
player.sendMessage("Ви приняли " + relig);
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL, 1f,1f);
//religionb.remove(player.getName());
return true;
}
ArrayList<String> religioni = new ArrayList<>();
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (religioni.contains(player.getName())) {
sposobnost(player);
}
}
private void sposobnost(Player player) {
}
@EventHandler
private void onPlayerConsume(PlayerItemConsumeEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem();
if (item.getType() == Material.PORKCHOP || item.getType() == Material.COOKED_PORKCHOP) {
if (religioni.contains(player.getName())) {
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 160, 2));
sposobnost(player);
}
}
}
private String relig = "Іслам";
}
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
public class Islam implements CommandExecutor, Listener {
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
Player player = (Player) sender;
religioni.add(player.getName());
sposobnost(player);
player.sendMessage("Ви приняли " + relig);
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL, 1f,1f);
//religionb.remove(player.getName());
return true;
}
ArrayList<String> religioni = new ArrayList<>();
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (religioni.contains(player.getName())) {
sposobnost(player);
}
}
private void sposobnost(Player player) {
}
@EventHandler
private void onPlayerConsume(PlayerItemConsumeEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem();
if (item.getType() == Material.PORKCHOP || item.getType() == Material.COOKED_PORKCHOP) {
if (religioni.contains(player.getName())) {
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 160, 2));
sposobnost(player);
}
}
}
private String relig = "Іслам";
}