Witam, pisze sobie plugin na ranking - proszę nie krytykować, uczę się! A więc tak, mam sobie klase User:
import org.bukkit.entity.Player;
public class User {
private int Kills;
private int Deaths;
private int Points;
public User(Player p){
this.Kills = 0;
this.Deaths = 0;
this.Points = 500;
}
public int getKills(){
return this.Kills;
}
public int getDeaths(){
return this.Deaths;
}
public int getPoints(){
return this.Points;
}
public void setKills(int i){
this.Kills = i;
}
public void setDeaths(int i){
this.Deaths = i;
}
public void setPoints(int i){
this.Points = i;
}
}
Pytanie
KrejzolekPRO 598
Witam, pisze sobie plugin na ranking - proszę nie krytykować, uczę się! A więc tak, mam sobie klase User:
import org.bukkit.entity.Player; public class User { private int Kills; private int Deaths; private int Points; public User(Player p){ this.Kills = 0; this.Deaths = 0; this.Points = 500; } public int getKills(){ return this.Kills; } public int getDeaths(){ return this.Deaths; } public int getPoints(){ return this.Points; } public void setKills(int i){ this.Kills = i; } public void setDeaths(int i){ this.Deaths = i; } public void setPoints(int i){ this.Points = i; } }
I mam też klase RankingCommand:
import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class RankingCommand implements CommandExecutor { public boolean onCommand(CommandSender cs, Command cmd, String lebel, String[] args){ if(cmd.getName().equalsIgnoreCase("ranking")){ if(args[0].equalsIgnoreCase("check")){ if(cs instanceof Player){ User user = (User) ((Player) cs).getPlayer(); cs.sendMessage("§fGracz: §9" + cs.getName()); cs.sendMessage("§fPunkty: §9" + user.getPoints()); cs.sendMessage("§fZabojstwa: §9" + user.getKills()); cs.sendMessage("§fSmierci: §9" + user.getDeaths()); } else { if(args[0].equalsIgnoreCase("setKills")){ if(args[1] != null){ if(args[2] != null){ Integer value = ParseUtils.parseOrNull(args[2]); if(value != null){ if(value > 0){ if(value <= 10){ User user = (User) Bukkit.getPlayer(args[1]); user.setKills(value); Bukkit.getPlayer(args[1]).sendMessage("§fWartosc §azabojstwa §fzostala zmieniona na: §9" + value + " §fprzez: §9Konsole§f."); } else { cs.sendMessage("§cZa duzo."); } } else { cs.sendMessage("§cZa malo."); } } else { cs.sendMessage("§cTo nie liczba."); } } else { cs.sendMessage("§cUzycie: /ranking setKills [nick] [ilosc]"); } } else { cs.sendMessage("§cUzycie: /ranking setKills [nick] [ilosc]"); } } } } } return false; } }
No i wszystko okej, ALE sypie errorami, gdy wykonam komendę: /ranking check - nie nie wykonuje w konsoli. Dokładniej w linijce:
User user = (User) ((Player) cs).getPlayer();
Nie będę kłamał wzoruję się trochę na iRank.
Odnośnik do komentarza
Udostępnij na innych stronach
6 odpowiedzi na to pytanie
Rekomendowane odpowiedzi