Hallo,
Ich habe heute mal wieder ein Problem mit meinem Plugin. Das Plugin soll an einem Random Punkt eine Plattform erstellen. Auf dieser Plattform steht eine Kiste, die komischer weiße da ist, aber leider nicht die Plattform. Ich hoffe ihr könnt mir helfen.
Hinweis: Es gibt kein Fehler in der Console!
Hier mein Code:
Ich habe heute mal wieder ein Problem mit meinem Plugin. Das Plugin soll an einem Random Punkt eine Plattform erstellen. Auf dieser Plattform steht eine Kiste, die komischer weiße da ist, aber leider nicht die Plattform. Ich hoffe ihr könnt mir helfen.
Hinweis: Es gibt kein Fehler in der Console!
Hier mein Code:
public class ClickSign implements Listener {
public String user = "Username";
public String pass = "473983";
public String url = "jdbc:mysql://Adresse
ORT/Datenbank";
@EventHandler
public void onClick(PlayerInteractEvent e) {
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Player p = e.getPlayer();
if(e.getClickedBlock().getState() instanceof Sign) {
Sign s = (Sign) e.getClickedBlock().getState();
if(s.getLine(0).equalsIgnoreCase("[Farm]")) {
if(s.getLine(1).equalsIgnoreCase("Erstellen")) {
Random xg = new Random();
int x = xg.nextInt(20000);
int y = 64;
int z = xg.nextInt(20000);
try {
String pname = p.getName();
Connection con = DriverManager.getConnection(url, user, pass);
PreparedStatement QA = con.prepareStatement("INSERT INTO users(name, x, y, z) VALUES ('"+pname+"', '"+x+"', '"+y+"', '"+z+"');");
QA.executeUpdate();
QA.close();
con.close();
Location loc = p.getLocation();
loc.setX(x);
loc.setY(y);
loc.setZ(z);
p.teleport(loc);
generatePlot(loc, 25, y);
loc.setX(loc.getBlockX() + 1);
World w = loc.getWorld();
Block b = w.getBlockAt(loc);
b.setType(Material.CHEST);
} catch (SQLException ex) {
p.sendMessage(ChatColor.RED + "Sie besitzen bereits eine Farm.");
p.sendMessage(ChatColor.GRAY + "Falls Sie keine Farm besitzen sollten, kontaktieren Sie bitte den Support.");
Logger.getLogger(ClickSign.class.getName()).log(Level.SEVERE, null, ex);
}
} else if (s.getLine(1).equalsIgnoreCase("Ab nach Hause!")) {
} else if (s.getLine(1).equalsIgnoreCase("Restart")) {
}
}
}
}
}
public void generatePlot(Location loc, int length, int yloc) {
World w = loc.getWorld();
int x_start = loc.getBlockY();
int z_start = loc.getBlockZ();
int x_length = x_start + length;
int z_length = z_start + length;
for(int x_operate = x_start; x_operate <= x_length; x_operate++) {
for(int z_operate = z_start; z_operate <= z_length; z_operate++) {
Block b = w.getBlockAt(x_operate, yloc, z_operate);
b.setType(Material.DIRT);
}
}
}
}
public String user = "Username";
public String pass = "473983";
public String url = "jdbc:mysql://Adresse
@EventHandler
public void onClick(PlayerInteractEvent e) {
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Player p = e.getPlayer();
if(e.getClickedBlock().getState() instanceof Sign) {
Sign s = (Sign) e.getClickedBlock().getState();
if(s.getLine(0).equalsIgnoreCase("[Farm]")) {
if(s.getLine(1).equalsIgnoreCase("Erstellen")) {
Random xg = new Random();
int x = xg.nextInt(20000);
int y = 64;
int z = xg.nextInt(20000);
try {
String pname = p.getName();
Connection con = DriverManager.getConnection(url, user, pass);
PreparedStatement QA = con.prepareStatement("INSERT INTO users(name, x, y, z) VALUES ('"+pname+"', '"+x+"', '"+y+"', '"+z+"');");
QA.executeUpdate();
QA.close();
con.close();
Location loc = p.getLocation();
loc.setX(x);
loc.setY(y);
loc.setZ(z);
p.teleport(loc);
generatePlot(loc, 25, y);
loc.setX(loc.getBlockX() + 1);
World w = loc.getWorld();
Block b = w.getBlockAt(loc);
b.setType(Material.CHEST);
} catch (SQLException ex) {
p.sendMessage(ChatColor.RED + "Sie besitzen bereits eine Farm.");
p.sendMessage(ChatColor.GRAY + "Falls Sie keine Farm besitzen sollten, kontaktieren Sie bitte den Support.");
Logger.getLogger(ClickSign.class.getName()).log(Level.SEVERE, null, ex);
}
} else if (s.getLine(1).equalsIgnoreCase("Ab nach Hause!")) {
} else if (s.getLine(1).equalsIgnoreCase("Restart")) {
}
}
}
}
}
public void generatePlot(Location loc, int length, int yloc) {
World w = loc.getWorld();
int x_start = loc.getBlockY();
int z_start = loc.getBlockZ();
int x_length = x_start + length;
int z_length = z_start + length;
for(int x_operate = x_start; x_operate <= x_length; x_operate++) {
for(int z_operate = z_start; z_operate <= z_length; z_operate++) {
Block b = w.getBlockAt(x_operate, yloc, z_operate);
b.setType(Material.DIRT);
}
}
}
}