refactor: fix latest commits
This commit is contained in:
parent
190be306ef
commit
fd2a1b7953
3 changed files with 13 additions and 13 deletions
|
@ -20,7 +20,7 @@ public class Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() throws SQLException {
|
private void init() throws SQLException {
|
||||||
final Statement s = conn.createStatement();
|
final Statement s = this.conn.createStatement();
|
||||||
s.executeUpdate(
|
s.executeUpdate(
|
||||||
"CREATE TABLE IF NOT EXISTS kills (`player` VARCHAR(32) NOT NULL, `victim` VARCHAR(32) NOT NULL);");
|
"CREATE TABLE IF NOT EXISTS kills (`player` VARCHAR(32) NOT NULL, `victim` VARCHAR(32) NOT NULL);");
|
||||||
s.executeUpdate(
|
s.executeUpdate(
|
||||||
|
@ -38,7 +38,7 @@ public class Database {
|
||||||
|
|
||||||
public void addKill(final String uuid, final String victimUuid) {
|
public void addKill(final String uuid, final String victimUuid) {
|
||||||
try {
|
try {
|
||||||
final Statement s = conn.createStatement();
|
final Statement s = this.conn.createStatement();
|
||||||
s.executeUpdate("INSERT INTO kills (`player`, `victim`) VALUES ('" + uuid + "', '" + victimUuid + "');");
|
s.executeUpdate("INSERT INTO kills (`player`, `victim`) VALUES ('" + uuid + "', '" + victimUuid + "');");
|
||||||
s.close();
|
s.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
|
@ -48,7 +48,7 @@ public class Database {
|
||||||
|
|
||||||
public int getKills(final String uuid) {
|
public int getKills(final String uuid) {
|
||||||
try {
|
try {
|
||||||
final Statement s = conn.createStatement();
|
final Statement s = this.conn.createStatement();
|
||||||
final ResultSet rs = s.executeQuery("SELECT COUNT(`victim`) FROM kills WHERE `player` ='" + uuid + "';");
|
final ResultSet rs = s.executeQuery("SELECT COUNT(`victim`) FROM kills WHERE `player` ='" + uuid + "';");
|
||||||
final int kills = rs.getInt("COUNT(`victim`)");
|
final int kills = rs.getInt("COUNT(`victim`)");
|
||||||
s.close();
|
s.close();
|
||||||
|
@ -61,7 +61,7 @@ public class Database {
|
||||||
|
|
||||||
public void updatePlayerCache(final String uuid, final String type, final Object value) {
|
public void updatePlayerCache(final String uuid, final String type, final Object value) {
|
||||||
try {
|
try {
|
||||||
final Statement s = conn.createStatement();
|
final Statement s = this.conn.createStatement();
|
||||||
if (s.executeUpdate(
|
if (s.executeUpdate(
|
||||||
"UPDATE playercache SET `" + type + "`='" + value + "' WHERE `player`='" + uuid + "';") == 0) {
|
"UPDATE playercache SET `" + type + "`='" + value + "' WHERE `player`='" + uuid + "';") == 0) {
|
||||||
s.executeUpdate(
|
s.executeUpdate(
|
||||||
|
@ -75,7 +75,7 @@ public class Database {
|
||||||
|
|
||||||
public Object getPlayerCache(final String uuid, final String type) {
|
public Object getPlayerCache(final String uuid, final String type) {
|
||||||
try {
|
try {
|
||||||
final Statement s = conn.createStatement();
|
final Statement s = this.conn.createStatement();
|
||||||
final ResultSet rs = s.executeQuery("SELECT " + type + " FROM playercache WHERE `player` ='" + uuid + "';");
|
final ResultSet rs = s.executeQuery("SELECT " + type + " FROM playercache WHERE `player` ='" + uuid + "';");
|
||||||
final Object obj = rs.getObject(type);
|
final Object obj = rs.getObject(type);
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -68,12 +68,12 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
e.getPlayer().setResourcePack("http://cdn.cliffbreak.de/varo.zip",
|
e.getPlayer().setResourcePack("http://cdn.cliffbreak.de/varo.zip",
|
||||||
"73046237cc843964dbe32fb9c76c0144cdbf90af");
|
"73046237cc843964dbe32fb9c76c0144cdbf90af");
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 5); // wait 5 ticks
|
}.runTaskLater(this.plugin, 5); // wait 5 ticks
|
||||||
|
|
||||||
// Login cooldown + Animation
|
// Login cooldown + Animation
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
World w = null;
|
World w = null;
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (final World world : Bukkit.getWorlds()) {
|
||||||
if (world.getEnvironment().equals(Environment.THE_END)) {
|
if (world.getEnvironment().equals(Environment.THE_END)) {
|
||||||
w = world;
|
w = world;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
final BukkitTask hidePlayersTask = new BukkitRunnable() {
|
final BukkitTask hidePlayersTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (final Player player : Bukkit.getOnlinePlayers())
|
||||||
p.hidePlayer(plugin, player);
|
p.hidePlayer(plugin, player);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(this.plugin, 0l, 1l);
|
}.runTaskTimer(this.plugin, 0l, 1l);
|
||||||
|
@ -103,7 +103,7 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
p.setFlying(false);
|
p.setFlying(false);
|
||||||
p.teleport(plugin.getPlayerCache().getPlayerLocationCache(p.getUniqueId().toString().replace("-", "")));
|
p.teleport(plugin.getPlayerCache().getPlayerLocationCache(p.getUniqueId().toString().replace("-", "")));
|
||||||
hidePlayersTask.cancel();
|
hidePlayersTask.cancel();
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (final Player player : Bukkit.getOnlinePlayers())
|
||||||
p.showPlayer(plugin, player);
|
p.showPlayer(plugin, player);
|
||||||
}
|
}
|
||||||
}.runTaskLater(this.plugin, 10 * 20);
|
}.runTaskLater(this.plugin, 10 * 20);
|
||||||
|
@ -122,13 +122,13 @@ public class PlayerJoinQuitListener implements Listener {
|
||||||
e.setHidePlayers(true);
|
e.setHidePlayers(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Instant instant = Instant.ofEpochMilli(this.plugin.getConfig().getLong("Varo.Start"));
|
final Instant instant = Instant.ofEpochMilli(this.plugin.getConfig().getLong("Varo.Start"));
|
||||||
LocalDateTime start = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
|
final LocalDateTime start = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||||
final LocalDateTime current = LocalDateTime.now();
|
final LocalDateTime current = LocalDateTime.now();
|
||||||
|
|
||||||
e.setMotd("§9§l" + "VARO" + "§b§l " + "Tag: " + (Duration.between(start, current).toDays() + 1) + "\n§r§7"
|
e.setMotd("§9§l" + "VARO" + "§b§l " + "Tag: " + (Duration.between(start, current).toDays() + 1) + "\n§r§7"
|
||||||
+ "powered by " + "§4" + "Cliffbreak.de");
|
+ "powered by " + "§4" + "Cliffbreak.de");
|
||||||
} catch (Exception ex) {
|
} catch (final Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
e.setMotd("§9§l" + "VARO" + "§b§l " + "Tag: -1" + "\n§r§7" + "powered by " + "§4" + "Cliffbreak.de");
|
e.setMotd("§9§l" + "VARO" + "§b§l " + "Tag: -1" + "\n§r§7" + "powered by " + "§4" + "Cliffbreak.de");
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class PlayerCache {
|
||||||
public Location getPlayerLocationCache(final String uuid) {
|
public Location getPlayerLocationCache(final String uuid) {
|
||||||
if ((String) this.plugin.getDatabase().getPlayerCache(uuid,
|
if ((String) this.plugin.getDatabase().getPlayerCache(uuid,
|
||||||
PlayerCacheType.WORLD.toString().toLowerCase()) == null) {
|
PlayerCacheType.WORLD.toString().toLowerCase()) == null) {
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (final World world : Bukkit.getWorlds()) {
|
||||||
if (world.getEnvironment().equals(Environment.NORMAL))
|
if (world.getEnvironment().equals(Environment.NORMAL))
|
||||||
return world.getSpawnLocation();
|
return world.getSpawnLocation();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue