mirror of
https://github.com/5vl/DoubleJump.git
synced 2025-05-24 06:06:59 +00:00
jump gui command
This commit is contained in:
parent
2262ca36a6
commit
82b08ff1d5
26
src/main/java/me/fivevl/doublejump/JumpCommand.java
Normal file
26
src/main/java/me/fivevl/doublejump/JumpCommand.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package me.fivevl.doublejump;
|
||||||
|
|
||||||
|
import me.fivevl.doublejump.guis.JumpGui;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class JumpCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Only players can use this command!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (!p.hasPermission("doublejump.gui")) {
|
||||||
|
p.sendMessage("You don't have permission to use this command!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
p.openInventory(JumpGui.getGui(p));
|
||||||
|
Main.inGui.add(p);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -9,9 +9,11 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Main extends JavaPlugin {
|
public class Main extends JavaPlugin {
|
||||||
public static List<Player> doDoubleJump = new ArrayList<>();
|
public static List<Player> doDoubleJump = new ArrayList<>();
|
||||||
|
public static List<Player> inGui = new ArrayList<>();
|
||||||
private static Main instance;
|
private static Main instance;
|
||||||
public static Main getInstance() {
|
public static Main getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
@ -23,6 +25,7 @@ public class Main extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
saveDefaultConfig();
|
||||||
sql = new MySQL();
|
sql = new MySQL();
|
||||||
try {
|
try {
|
||||||
setupDatabase();
|
setupDatabase();
|
||||||
@ -31,6 +34,7 @@ public class Main extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
Bukkit.getPluginManager().registerEvents(new OnFly(), this);
|
Bukkit.getPluginManager().registerEvents(new OnFly(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new OnJump(), this);
|
Bukkit.getPluginManager().registerEvents(new OnJump(), this);
|
||||||
|
Objects.requireNonNull(getCommand("jump")).setExecutor(new JumpCommand());
|
||||||
getLogger().info("DoubleJump enabled!");
|
getLogger().info("DoubleJump enabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,9 @@ public class MySQL implements Database {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect() throws SQLException {
|
public void disconnect() throws SQLException {
|
||||||
connection.close();
|
if (isConnected()) {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
14
src/main/java/me/fivevl/doublejump/guis/JumpGui.java
Normal file
14
src/main/java/me/fivevl/doublejump/guis/JumpGui.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package me.fivevl.doublejump.guis;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
public class JumpGui {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static Inventory getGui(Player p) {
|
||||||
|
Inventory inv = Bukkit.createInventory(null, 27, "Jump Strength");
|
||||||
|
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
database: # Database configuration, please change it to a valid one.
|
database: # Database configuration, please change it to a valid one.
|
||||||
host: "12.34.56.78"
|
host: "12.34.56.78"
|
||||||
port: 3306
|
port: "3306"
|
||||||
username: "admin"
|
username: "admin"
|
||||||
password: "password"
|
password: "password"
|
||||||
database: "database"
|
database: "database"
|
Loading…
x
Reference in New Issue
Block a user