- added some custom food and drinks
- added kand coins - started working on the blazing set
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package fantasypvp.kand.commands;
|
||||
|
||||
import fantasypvp.kand.items.LightningGear;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CmdLightningSword implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players can use this command");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(player.hasPermission("kand.lightning_sword")) {
|
||||
if (command.getName().equalsIgnoreCase("lightning_sword")) {
|
||||
player.getInventory().addItem(LightningGear.lightning_sword);
|
||||
}
|
||||
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED+"You don't have permission to run this command.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package fantasypvp.kand.commands;
|
||||
//Was made by DanThePythonMan
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CmdTeleportSpawn implements CommandExecutor {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
|
||||
|
||||
public CmdTeleportSpawn(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
boolean success = false;
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("You must be a player to execute this command!");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "Sending you to spawn");
|
||||
|
||||
String coordinates = getCoordinates();
|
||||
|
||||
if (coordinates == null) {
|
||||
player.sendMessage(ChatColor.RED + "An error occurred, you will not be teleported.");
|
||||
} else {
|
||||
|
||||
int x, y, z;
|
||||
|
||||
String[] coordsList = coordinates.split(" ");
|
||||
|
||||
x = Integer.parseInt(coordsList[0]);
|
||||
y = Integer.parseInt(coordsList[1]);
|
||||
z = Integer.parseInt(coordsList[2]);
|
||||
|
||||
Location location = new Location(player.getWorld(), x,y,z);
|
||||
|
||||
location.setPitch(player.getLocation().getPitch());
|
||||
location.setYaw(player.getLocation().getYaw());
|
||||
|
||||
player.teleport(location);
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private String getCoordinates() {
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
if (!dataFolder.exists()) {
|
||||
dataFolder.mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
File file = new File(dataFolder, "spawnCoords.txt");
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FileReader fileReader = new FileReader(file);
|
||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||
String line = bufferedReader.readLine();
|
||||
bufferedReader.close();
|
||||
|
||||
return line;
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("Error occurred while reading spawn coordinates: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package fantasypvp.kand.commands;
|
||||
|
||||
import fantasypvp.kand.items.DashItem;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class GiveDashItemCmd implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
|
||||
if(!(sender instanceof Player)){
|
||||
sender.sendMessage("You must be a player to execute this command");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(!(player.hasPermission("giveDashItem"))){
|
||||
player.sendMessage(ChatColor.RED+"You don't have permission to run this command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack dashItem = new DashItem().createDashItem();
|
||||
|
||||
player.getInventory().addItem(dashItem);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package fantasypvp.kand.commands;
|
||||
|
||||
import fantasypvp.kand.items.KandCoin;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static org.bukkit.Bukkit.broadcastMessage;
|
||||
|
||||
public class KandCoinCmd implements CommandExecutor, Listener {
|
||||
@Override
|
||||
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players can use this command");
|
||||
return true;
|
||||
}
|
||||
|
||||
broadcastMessage("Kand Coin: ");
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
|
||||
if (player.hasPermission("kand.economy.admin")) {
|
||||
if (command.getName().equalsIgnoreCase("get_currency")) {
|
||||
|
||||
ItemStack k = KandCoin.kandCoin;
|
||||
|
||||
int quantity;
|
||||
try {
|
||||
quantity = Integer.parseInt(args[0]);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(ChatColor.RED + "Invalid quantity");
|
||||
return true;
|
||||
}
|
||||
|
||||
broadcastMessage(quantity + " " + k.getItemMeta().getDisplayName() + " added to your inventory.");
|
||||
|
||||
k.setAmount(quantity);
|
||||
player.getInventory().addItem(KandCoin.kandCoin);
|
||||
}
|
||||
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to run this command.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public boolean onPlayerJoin(PlayerJoinEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (!p.hasPlayedBefore()) {
|
||||
ItemStack k = KandCoin.kandCoin;
|
||||
int quantity = 16;
|
||||
k.setAmount(quantity);
|
||||
p.sendMessage(quantity + " " + k.getItemMeta().getDisplayName() + " welcome to KandSMP\n you have received 16 Kand coins to get you started!");
|
||||
p.getInventory().addItem(k);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package fantasypvp.kand.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SetSpawnCommand implements CommandExecutor {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
public SetSpawnCommand(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("You must be a player to execute this command!");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
if(!player.hasPermission("kand.setglobalspawn")){
|
||||
|
||||
player.sendMessage(ChatColor.RED+"You don't have permission to run this.");
|
||||
|
||||
}else{
|
||||
|
||||
String coordinates = getCoordinates(player);
|
||||
|
||||
try {
|
||||
if (SetCoordinates(coordinates)) {
|
||||
player.sendMessage(ChatColor.GREEN + "Spawn Coordinates set!");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
player.sendMessage(ChatColor.RED + "Unable to set spawn coordinates");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getCoordinates(Player player) {
|
||||
// return (player.getLocation().getX() + " " + player.getLocation().getY() + " " + player.getLocation().getZ());
|
||||
|
||||
String x,y,z;
|
||||
|
||||
x=String.format("%.0f",player.getLocation().getX());
|
||||
y=String.format("%.0f",player.getLocation().getY());
|
||||
z=String.format("%.0f",player.getLocation().getZ());
|
||||
|
||||
return (x +" " + y + " "+ z);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private boolean SetCoordinates(String coordinates) throws IOException {
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
if (!dataFolder.exists()) {
|
||||
dataFolder.mkdirs();
|
||||
}
|
||||
|
||||
File file = new File(dataFolder, "spawnCoords.txt");
|
||||
try (FileWriter fileWriter = new FileWriter(file, false)) {
|
||||
fileWriter.write(coordinates);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("Spawn TP Plugin couldn't save coordinates. Error: " + e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user