- Баллы
- 66
плагин на историю ip по нику и историю ников по ip, в бд история хранится большим текстом разделенным запятыми, часть с бд особо не трогал, но теперь при написании команды null выводит
Код:
if (args.length == 2 && args[0].equals("infoname") && args[1] != null)
{
if (p.hasPermission("IpHistory.InfoName"))
{
Data data = IpHistory.mysql.GetPlayerStatsFirst(args[1].toLowerCase());
if (!data.iplist.isEmpty())
{
p.sendMessage(ChatColor.GREEN + "-----------------IP LIST-------------------");
for (String s : data.iplist)
{
p.sendMessage(ChatColor.GREEN + " - " + s);
}
p.sendMessage(ChatColor.GREEN + "-------------------------------------------");
return true;
}
else
{
p.sendMessage(ChatColor.RED + Config.configMsg("noplayer"));
return true;
}
}
else
{
p.sendMessage(ChatColor.RED + Config.configMsg("NotPermed"));
return true;
}
}
Код:
package ru.pa4ok.mysql;
import java.util.ArrayList;
import java.util.List;
import ru.pa4ok.iphistory.Config;
public class Data
{
public String name;
public List<String> iplist = new ArrayList<>();
public String ipall;
char[] ipchar = new char[256];
String ipone;
public Data(String Name, String iptxt)
{
name = Name;
ipall = iptxt;
iplist.clear();
ipone = "";
if (ipall != null)
{
ipchar = ipall.toCharArray();
for (int i=0; i<ipchar.length; i++)
{
if (ipchar[i] != ',')
{
ipone = ipone + ipchar[i];
if (i == ipchar.length - 1)
{
iplist.add(ipone);
ipone = "";
}
}
else
{
if (ipall.length() < Config.getInt("length.allip"))
{
iplist.add(ipone);
ipone = "";
}
else
{
ipall = ipall.substring(i+1);
ipone = "";
}
}
}
}
}
}
Код:
if (args.length == 2 && args[0].equalsIgnoreCase("infoname") && args[1] != null)
{
if (p.hasPermission("IpHistory.InfoName"))
{
Data data = IpHistory.mysql.getPlayerStatsFirst(args[1].toLowerCase());
if (!data.getList().isEmpty())
{
p.sendMessage(ChatColor.GREEN + "-----------------IP LIST-------------------");
for (String s : data.getList())
{
p.sendMessage(ChatColor.GREEN + " - " + s);
}
p.sendMessage(ChatColor.GREEN + "-------------------------------------------");
return true;
}
else
{
p.sendMessage(ChatColor.RED + Config.configMsg("noplayer"));
return true;
}
}
else
{
p.sendMessage(ChatColor.RED + Config.configMsg("NotPermed"));
return true;
}
}
Код:
package ru.pa4ok.mysql;
import java.util.ArrayList;
import java.util.List;
import ru.pa4ok.iphistory.Config;
public class Data
{
private char[] ipchar = new char[256];
private String ipone;
private String name;
private List<String> iplist = new ArrayList<>();
private String ipall;
public Data(String name, String ipall)
{
this.name = name;
this.ipall = ipall;
iplist.clear();
ipone = "";
if (ipall != null)
{
ipchar = ipall.toCharArray();
for (int i=0; i<ipchar.length; i++)
{
if (ipchar[i] != ',')
{
ipone = ipone + ipchar[i];
if (i == ipchar.length - 1)
{
iplist.add(ipone);
ipone = "";
}
}
else
{
if (ipall.length() < Config.getInt("length.allip"))
{
iplist.add(ipone);
ipone = "";
}
else
{
ipall = ipall.substring(i+1);
ipone = "";
}
}
}
}
}
public String getName() {
return name;
}
public void setName (String s) {
this.name = s;
}
public String getIpAll() {
return ipall;
}
public void setIpAll(String s) {
this.ipall = s;
}
public List<String> getList() {
return iplist;
}
public void setList (List<String> list) {
this.iplist = list;
}
public void addList (String s) {
this.iplist.add(s);
if (!this.iplist.isEmpty())
{
this.ipall = this.ipall + ",";
}
this.ipall = this.ipall + s;
}
}