mirror of
https://bitbucket.org/HeshamTB/greet.git
synced 2024-11-05 16:22:16 +01:00
Bed Event Command
added a command to enable/disable bed leave event
This commit is contained in:
parent
ab43705ec0
commit
40bcb592a6
@ -16,3 +16,6 @@ commands:
|
|||||||
setspwan:
|
setspwan:
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
description: sets your current location as bed spwan.
|
description: sets your current location as bed spwan.
|
||||||
|
beds:
|
||||||
|
usage: /<command>
|
||||||
|
description: enable or disable bed feature.
|
@ -11,8 +11,10 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
public class commands extends JavaPlugin {
|
public class commands extends JavaPlugin {
|
||||||
|
|
||||||
public void onEnable() {
|
protected static boolean IsBedEvent;
|
||||||
|
|
||||||
|
public void onEnable() {
|
||||||
|
IsBedEvent = true;
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "greet plugin is Enabled");
|
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "greet plugin is Enabled");
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new events(), this);
|
Bukkit.getServer().getPluginManager().registerEvents(new events(), this);
|
||||||
|
|
||||||
@ -58,6 +60,33 @@ public class commands extends JavaPlugin {
|
|||||||
p.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
|
p.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
|
||||||
p.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
|
p.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd.getName().equalsIgnoreCase("beds")){
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("disable")) {
|
||||||
|
if (!IsBedEvent) p.sendMessage(greetprefix + "Bed feature is already disabled!");
|
||||||
|
else {
|
||||||
|
|
||||||
|
IsBedEvent = false;
|
||||||
|
Bukkit.getServer().broadcastMessage(greetprefix + ChatColor.BOLD + ChatColor.DARK_RED + p.getDisplayName() + " has Disabled bed feature");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("enable")) {
|
||||||
|
|
||||||
|
if (IsBedEvent) p.sendMessage(greetprefix + "Bed feature is already enabled!");
|
||||||
|
|
||||||
|
else {
|
||||||
|
IsBedEvent = true;
|
||||||
|
Bukkit.getServer().broadcastMessage(greetprefix + ChatColor.BOLD + ChatColor.DARK_RED + p.getDisplayName() + " has Enabled bed feature");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else p.sendMessage(greetprefix + "Unknown argument\n Try disable/enable");
|
||||||
|
}
|
||||||
|
|
||||||
/*if(cmd.getName().equalsIgnoreCase("setspwan")) { // TODO: give option of new arg to set cords &
|
/*if(cmd.getName().equalsIgnoreCase("setspwan")) { // TODO: give option of new arg to set cords &
|
||||||
p.setBedSpawnLocation(p.getLocation());
|
p.setBedSpawnLocation(p.getLocation());
|
||||||
p.sendMessage(ChatColor.GREEN +"Your bed Spwan has been updated to currnet location");
|
p.sendMessage(ChatColor.GREEN +"Your bed Spwan has been updated to currnet location");
|
||||||
|
@ -47,9 +47,11 @@ public class events implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void player(PlayerBedLeaveEvent e) {
|
public void player(PlayerBedLeaveEvent e) {
|
||||||
|
|
||||||
|
if (commands.IsBedEvent) {
|
||||||
p = e.getPlayer();
|
p = e.getPlayer();
|
||||||
Bukkit.getWorld("world").setFullTime(1);
|
Bukkit.getWorld("world").setFullTime(1);
|
||||||
p.sendMessage(PREFIX+" Good Morning!");
|
p.sendMessage(PREFIX+" Good Morning!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user