mirror of
https://github.com/5vl/DoubleJump.git
synced 2025-05-24 06:27:02 +00:00
yeah im done
This commit is contained in:
parent
266921adb4
commit
8ac759620a
@ -77,7 +77,7 @@ public class Main extends JavaPlugin {
|
||||
sql.setPort(credentials[1]);
|
||||
sql.setDatabase(credentials[2]);
|
||||
sql.connect();
|
||||
sql.execute("CREATE TABLE IF NOT EXISTS `settings` (`uuid` VARCHAR(36) NOT NULL, `strength` DOUBLE NOT NULL DEFAULT '1', PRIMARY KEY (`uuid`))");
|
||||
sql.execute("CREATE TABLE IF NOT EXISTS `settings` (`uuid` VARCHAR(36) NOT NULL, `strength` INT NOT NULL DEFAULT '1', PRIMARY KEY (`uuid`))");
|
||||
}
|
||||
|
||||
public static String color(String s) {
|
||||
|
@ -22,7 +22,7 @@ public class OnFly implements Listener {
|
||||
Main.doDoubleJump.remove(p);
|
||||
CachedRowSet rs = Main.getMySQL().query("SELECT * FROM `settings` WHERE `uuid` = '" + p.getUniqueId() + "'");
|
||||
rs.next();
|
||||
p.setVelocity(p.getLocation().getDirection().multiply(rs.getDouble("strength")));
|
||||
p.setVelocity(p.getLocation().getDirection().multiply(rs.getInt("strength")));
|
||||
p.setFallDistance(0);
|
||||
}
|
||||
}
|
||||
|
@ -25,16 +25,13 @@ public class OnInventoryClick implements Listener {
|
||||
e.setCancelled(true);
|
||||
CachedRowSet rs = Main.getMySQL().query("SELECT * FROM `settings` WHERE `uuid` = '" + p.getUniqueId() + "'");
|
||||
rs.next();
|
||||
double strength = rs.getDouble("strength");
|
||||
double newStrength = strength;
|
||||
if (e.getRawSlot() == 12) newStrength = strength - 0.2;
|
||||
if (e.getRawSlot() == 14) newStrength = strength + 0.2;
|
||||
int strength = rs.getInt("strength");
|
||||
int newStrength = strength;
|
||||
if (e.getRawSlot() == 12) newStrength = strength - 1;
|
||||
if (e.getRawSlot() == 14) newStrength = strength + 1;
|
||||
if (newStrength < 1) newStrength = 1;
|
||||
if (newStrength > 5) newStrength = 5;
|
||||
if (strength == newStrength) return;
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
df.setRoundingMode(RoundingMode.CEILING);
|
||||
newStrength = Double.parseDouble(df.format(newStrength).replace(",", "."));
|
||||
Inventory inv = e.getClickedInventory();
|
||||
ItemStack item = inv.getItem(13);
|
||||
ItemMeta currentStrengthMeta = item.getItemMeta();
|
||||
|
@ -14,6 +14,10 @@ public class OnJump implements Listener {
|
||||
Player p = e.getPlayer();
|
||||
if (p.hasPermission("doublejump.use") && (p.getGameMode() == GameMode.ADVENTURE || p.getGameMode() == GameMode.SURVIVAL)) {
|
||||
p.setAllowFlight(true);
|
||||
if (Main.doDoubleJump.containsKey(p)) {
|
||||
Bukkit.getScheduler().cancelTask(Main.doDoubleJump.get(p));
|
||||
Main.doDoubleJump.remove(p);
|
||||
}
|
||||
int id = Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
|
||||
p.setAllowFlight(false);
|
||||
Main.doDoubleJump.remove(p);
|
||||
|
@ -42,7 +42,7 @@ public class JumpGui {
|
||||
ItemStack currentStrength = new ItemStack(Material.FEATHER, 1);
|
||||
ItemMeta currentStrengthMeta = currentStrength.getItemMeta();
|
||||
currentStrengthMeta.setDisplayName(Main.color("&2Current Jump Strength"));
|
||||
currentStrengthMeta.setLore(Collections.singletonList(Main.color("&e" + rs.getDouble("strength"))));
|
||||
currentStrengthMeta.setLore(Collections.singletonList(Main.color("&e" + rs.getInt("strength"))));
|
||||
currentStrength.setItemMeta(currentStrengthMeta);
|
||||
inv.setItem(13, currentStrength);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user