这是我的世界的插件。它应该使用在配置中设置的客户 ID 拉出玩家并在游戏中显示他们。相反,它会吸引所有人,无论他们的客户 ID 是什么。
if(cmd.getName().equalsIgnoreCase("getaward"))
{
Player player = (Player)sender;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection (dbUrl,dbUser,dbPass);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM `votesdb` WHERE `nick` = '"+player.getName().substring(0,player.getName().length()/2)+"' AND `customer_id` LIKE "+config.getString("customer_id")+"");
//ResultSet rs = stmt.executeQuery("SELECT nick,votes FROM `votesdb` WHERE nick='"+player.getName()+" LIMIT 1");
if(rs.next())
{
if(rs.getInt("votes")!=0)
{
player.sendMessage(ChatColor.GREEN+"[VFD]"+ChatColor.AQUA+"Thanks for voting! You will find something special in your inventory. :)");
bukkit.broadcastMessage(ChatColor.GREEN+"[VFD]"+ChatColor.AQUA+player.getDisplayName()+" has been rewarded for Voting for the Server!");
stmt.executeUpdate("UPDATE `votesdb` SET flag=0 WHERE `nick` LIKE '"+player.getDisplayName().substring(0,player.getDisplayName().length()/2)+"'");
player.getInventory().addItem(new ItemStack(this.matID,this.matAmt));
}
else
{
player.sendMessage(ChatColor.RED+"You have already claimed your reward.");
}
}
else
{
player.sendMessage(ChatColor.RED+"We could not find you in the database! Please make sure you used the correct name when you voted!");
}