Added cast command for casting lightning bolts. Added chat and kick events for lightning bolts. Support for PermissionsBukkit. Removed Legacy Permissions support. (This is due to the Inactivity of the plugin.)main
parent
694fb28c21
commit
4f01a30c07
@ -0,0 +1,99 @@ |
||||
package net.mcbat.LightningEvent.Commands; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.command.Command; |
||||
import org.bukkit.command.CommandSender; |
||||
import org.bukkit.command.ConsoleCommandSender; |
||||
|
||||
import net.mcbat.LightningEvent.LightningEvent; |
||||
|
||||
public class CommandCast { |
||||
private final LightningEvent _plugin; |
||||
|
||||
private final SubcommandFake _fake; |
||||
private final SubcommandReal _real; |
||||
|
||||
public CommandCast(LightningEvent plugin) { |
||||
_plugin = plugin; |
||||
_fake = new SubcommandFake(plugin, this); |
||||
_real = new SubcommandReal(plugin, this); |
||||
} |
||||
|
||||
public boolean checkPlayer(String p) { |
||||
return (_plugin.getServer().getPlayer(p) != null); |
||||
} |
||||
|
||||
public boolean checkWorld(String w) { |
||||
return (_plugin.getServer().getWorld(w) != null); |
||||
} |
||||
|
||||
public boolean checkLocation(String x, String y, String z) { |
||||
return (x.matches("[-]?[0-9]+") && y.matches("[-]?[0-9]+") && z.matches("[-]?[0-9]+")); |
||||
} |
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { |
||||
if (sender instanceof ConsoleCommandSender) { |
||||
if (args.length >= 1 && args[0].equalsIgnoreCase("fake")) |
||||
return _fake.onConsoleCommand(sender, command, label, args); |
||||
else if (args.length >= 1 && args[0].equalsIgnoreCase("real")) |
||||
return _real.onConsoleCommand(sender, command, label, args); |
||||
else |
||||
return commandUsage(sender, label, false); |
||||
} |
||||
else { |
||||
if (args.length >= 1 && args[0].equalsIgnoreCase("fake")) { |
||||
if (!sender.hasPermission("lightningevent.commands.cast.fake")) |
||||
return noAccess(sender); |
||||
|
||||
return _fake.onPlayerCommand(sender, command, label, args); |
||||
} |
||||
else if (args.length >= 1 && args[0].equalsIgnoreCase("real")) { |
||||
if (!sender.hasPermission("lightningevent.commands.cast.real")) |
||||
return noAccess(sender); |
||||
|
||||
return _real.onPlayerCommand(sender, command, label, args); |
||||
} |
||||
else |
||||
return commandUsage(sender, label, true); |
||||
} |
||||
} |
||||
|
||||
private boolean noAccess(CommandSender sender) { |
||||
sender.sendMessage(ChatColor.DARK_RED+"You do not have access to that command."); |
||||
return true; |
||||
} |
||||
|
||||
private boolean commandUsage(CommandSender sender, String label, boolean isPlayer) { |
||||
if (!isPlayer) { |
||||
sender.sendMessage(ChatColor.RED+"[==== "+ChatColor.GREEN+"/"+label+ChatColor.RED+" ====]"); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<world> <x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<player>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt on a player."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<world> <x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<player>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt on a player."); |
||||
return true; |
||||
} |
||||
else { |
||||
if (sender.hasPermission("lightningevent.commands.cast.fake") || sender.hasPermission("lightningevent.commands.cast.real")) { |
||||
sender.sendMessage(ChatColor.RED+"[==== "+ChatColor.GREEN+"/"+label+ChatColor.RED+" ====]"); |
||||
|
||||
if (sender.hasPermission("lightningevent.commmands.cast.fake")) { |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<world> <x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt in the specified world and location."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt in the current world at the specified location."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<player>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt on a player."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt where you are looking."); |
||||
} |
||||
|
||||
if (sender.hasPermission("lightningevent.commands.cast.real")) { |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<world> <x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt in the specified world and location."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt in the current world at the specified location."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<player>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt on a player."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt where you are looking."); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
else |
||||
return noAccess(sender); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,86 @@ |
||||
package net.mcbat.LightningEvent.Commands; |
||||
|
||||
import net.mcbat.LightningEvent.LightningEvent; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Location; |
||||
import org.bukkit.command.Command; |
||||
import org.bukkit.command.CommandSender; |
||||
import org.bukkit.entity.Player; |
||||
|
||||
public class SubcommandFake { |
||||
private final LightningEvent _plugin; |
||||
private final CommandCast _command; |
||||
|
||||
public SubcommandFake(LightningEvent plugin, CommandCast command) { |
||||
_plugin = plugin; |
||||
_command = command; |
||||
} |
||||
|
||||
public boolean onConsoleCommand(CommandSender sender, Command command, String label, String[] args) { |
||||
switch (args.length) { |
||||
case 5: |
||||
if (_command.checkWorld(args[1]) && _command.checkLocation(args[2], args[3], args[4])) |
||||
_plugin.castFakeLightningAtLocation(new Location(_plugin.getServer().getWorld(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4]))); |
||||
else |
||||
commandUsage(sender, label, false); |
||||
break; |
||||
case 2: |
||||
if (_command.checkPlayer(args[1])) |
||||
_plugin.castFakeLightningAtLocation(_plugin.getServer().getPlayer(args[1]).getLocation()); |
||||
else |
||||
commandUsage(sender, label, false); |
||||
break; |
||||
default: |
||||
commandUsage(sender, label, false); |
||||
break; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
public boolean onPlayerCommand(CommandSender sender, Command command, String label, String[] args) { |
||||
switch (args.length) { |
||||
case 5: |
||||
if (_command.checkWorld(args[1]) && _command.checkLocation(args[2], args[3], args[4])) |
||||
_plugin.castFakeLightningAtLocation(new Location(_plugin.getServer().getWorld(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4]))); |
||||
else |
||||
commandUsage(sender, label, true); |
||||
break; |
||||
case 4: |
||||
if (_command.checkLocation(args[1], args[2], args[3])) |
||||
_plugin.castFakeLightningAtLocation(new Location(((Player) sender).getWorld(), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]))); |
||||
else |
||||
commandUsage(sender, label, true); |
||||
break; |
||||
case 2: |
||||
if (_command.checkPlayer(args[1])) |
||||
_plugin.castFakeLightningAtLocation(_plugin.getServer().getPlayer(args[1]).getLocation()); |
||||
else |
||||
commandUsage(sender, label, true); |
||||
break; |
||||
case 1: |
||||
_plugin.castFakeLightningAtLocation(((Player) sender).getTargetBlock(null, 600).getLocation()); |
||||
break; |
||||
default: |
||||
commandUsage(sender, label, true); |
||||
break; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
private void commandUsage(CommandSender sender, String label, boolean isPlayer) { |
||||
if (!isPlayer) { |
||||
sender.sendMessage(ChatColor.RED+"[==== "+ChatColor.GREEN+"/"+label+" fake"+ChatColor.RED+" ====]"); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<world> <x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<player>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt on a player."); |
||||
} |
||||
else { |
||||
sender.sendMessage(ChatColor.RED+"[==== "+ChatColor.GREEN+"/"+label+" fake"+ChatColor.RED+" ====]"); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<world> <x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt in the specified world and location."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt in the current world at the specified location."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.LIGHT_PURPLE+"<player>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt on a player."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" fake "+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a fake lightning bolt where you are looking."); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,86 @@ |
||||
package net.mcbat.LightningEvent.Commands; |
||||
|
||||
import net.mcbat.LightningEvent.LightningEvent; |
||||
|
||||
import org.bukkit.ChatColor; |
||||
import org.bukkit.Location; |
||||
import org.bukkit.command.Command; |
||||
import org.bukkit.command.CommandSender; |
||||
import org.bukkit.entity.Player; |
||||
|
||||
public class SubcommandReal { |
||||
private final LightningEvent _plugin; |
||||
private final CommandCast _command; |
||||
|
||||
public SubcommandReal(LightningEvent plugin, CommandCast command) { |
||||
_plugin = plugin; |
||||
_command = command; |
||||
} |
||||
|
||||
public boolean onConsoleCommand(CommandSender sender, Command command, String label, String[] args) { |
||||
switch (args.length) { |
||||
case 5: |
||||
if (_command.checkWorld(args[1]) && _command.checkLocation(args[2], args[3], args[4])) |
||||
_plugin.castRealLightningAtLocation(new Location(_plugin.getServer().getWorld(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4]))); |
||||
else |
||||
commandUsage(sender, label, false); |
||||
break; |
||||
case 2: |
||||
if (_command.checkPlayer(args[1])) |
||||
_plugin.castRealLightningAtLocation(_plugin.getServer().getPlayer(args[1]).getLocation()); |
||||
else |
||||
commandUsage(sender, label, false); |
||||
break; |
||||
default: |
||||
commandUsage(sender, label, false); |
||||
break; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
public boolean onPlayerCommand(CommandSender sender, Command command, String label, String[] args) { |
||||
switch (args.length) { |
||||
case 5: |
||||
if (_command.checkWorld(args[1]) && _command.checkLocation(args[2], args[3], args[4])) |
||||
_plugin.castRealLightningAtLocation(new Location(_plugin.getServer().getWorld(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), Integer.parseInt(args[4]))); |
||||
else |
||||
commandUsage(sender, label, true); |
||||
break; |
||||
case 4: |
||||
if (_command.checkLocation(args[1], args[2], args[3])) |
||||
_plugin.castRealLightningAtLocation(new Location(((Player) sender).getWorld(), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]))); |
||||
else |
||||
commandUsage(sender, label, true); |
||||
break; |
||||
case 2: |
||||
if (_command.checkPlayer(args[1])) |
||||
_plugin.castRealLightningAtLocation(_plugin.getServer().getPlayer(args[1]).getLocation()); |
||||
else |
||||
commandUsage(sender, label, true); |
||||
break; |
||||
case 1: |
||||
_plugin.castRealLightningAtLocation(((Player) sender).getTargetBlock(null, 600).getLocation()); |
||||
break; |
||||
default: |
||||
commandUsage(sender, label, true); |
||||
break; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
private void commandUsage(CommandSender sender, String label, boolean isPlayer) { |
||||
if (!isPlayer) { |
||||
sender.sendMessage(ChatColor.RED+"[==== "+ChatColor.GREEN+"/"+label+" real"+ChatColor.RED+" ====]"); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<world> <x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<player>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt on a player."); |
||||
} |
||||
else { |
||||
sender.sendMessage(ChatColor.RED+"[==== "+ChatColor.GREEN+"/"+label+" real"+ChatColor.RED+" ====]"); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<world> <x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt in the specified world and location."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<x> <y> <z>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt in the current world at the specified location."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.LIGHT_PURPLE+"<player>"+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt on a player."); |
||||
sender.sendMessage(ChatColor.GREEN+"/"+label+" real "+ChatColor.GREEN+" - "+ChatColor.WHITE+"Casts a lightning bolt where you are looking."); |
||||
} |
||||
} |
||||
} |
@ -1,41 +0,0 @@ |
||||
package net.mcbat.LightningEvent.Listeners; |
||||
|
||||
import net.mcbat.LightningEvent.LightningEvent; |
||||
|
||||
import org.bukkit.event.Event; |
||||
import org.bukkit.event.Event.Priority; |
||||
import org.bukkit.event.server.PluginDisableEvent; |
||||
import org.bukkit.event.server.PluginEnableEvent; |
||||
import org.bukkit.event.server.ServerListener; |
||||
import org.bukkit.plugin.PluginManager; |
||||
|
||||
import com.nijikokun.bukkit.Permissions.Permissions; |
||||
|
||||
public class LightningEventServerListener extends ServerListener { |
||||
private final LightningEvent _plugin; |
||||
|
||||
public LightningEventServerListener(LightningEvent plugin) { |
||||
_plugin = plugin; |
||||
} |
||||
|
||||
public void registerEvents() { |
||||
PluginManager pm = _plugin.getServer().getPluginManager(); |
||||
|
||||
pm.registerEvent(Event.Type.PLUGIN_ENABLE, this, Priority.Monitor, _plugin); |
||||
pm.registerEvent(Event.Type.PLUGIN_DISABLE, this, Priority.Monitor, _plugin); |
||||
} |
||||
|
||||
public void onPluginEnable(PluginEnableEvent event) { |
||||
if (_plugin.Permissions == null && event.getPlugin().getDescription().getName().equals("Permissions")) { |
||||
_plugin.Permissions = ((Permissions)event.getPlugin()).getHandler(); |
||||
_plugin.getMinecraftLogger().info("[LightningEvent] hooked into Permissions/GroupManager."); |
||||
} |
||||
} |
||||
|
||||
public void onPluginDisable(PluginDisableEvent event) { |
||||
if (_plugin.Permissions != null && event.getPlugin().getDescription().getName().equals("Permissions")) { |
||||
_plugin.Permissions = null; |
||||
_plugin.getMinecraftLogger().info("[LightningEvent] un-hooked from Permissions/GroupManager"); |
||||
} |
||||
} |
||||
} |
@ -1,6 +1,83 @@ |
||||
name: LightningEvent |
||||
main: net.mcbat.LightningEvent.LightningEvent |
||||
version: 1.00 |
||||
version: 1.01 |
||||
website: http://mc-bat.net |
||||
author: Steven Mattera |
||||
description: Simple plugin that casts lightning on events. |
||||
description: Simple plugin that casts lightning on events. |
||||
commands: |
||||
cast: |
||||
aliases: [c] |
||||
description: Commands for casting lightning bolts. |
||||
usage: | |
||||
/<command> fake <world> <x> <y> <z> - Casts a fake lightning bolt in the specified world and location. |
||||
/<command> fake <x> <y> <z> - Casts a fake lightning bolt in the current world at the specified location. |
||||
/<command> fake <player> - Casts a fake lightning bolt on a player. |
||||
/<command> fake - Casts a fake lightning bolt where you are looking. |
||||
/<command> real <world> <x> <y> <z> - Casts a lightning bolt in the specified world and location. |
||||
/<command> real <x> <y> <z> - Casts a lightning bolt in the current world at the specified location. |
||||
/<command> real <player> - Casts a lightning bolt on a player. |
||||
/<command> real - Casts a lightning bolt where you are looking. |
||||
permissions: |
||||
lightningevent.*: |
||||
description: Allows use of all commands and lightning events. |
||||
children: |
||||
lightningevent.commands.*: true |
||||
lightningevent.events.*: true |
||||
lightningevent.commands.*: |
||||
default: op |
||||
description: Allows use of all commands. |
||||
children: |
||||
lightningevent.commands.cast.*: true |
||||
lightningevent.commands.cast.*: |
||||
description: Casts lightning bolts. |
||||
children: |
||||
lightningevent.commands.cast.fake: true |
||||
lightningevent.commands.cast.real: true |
||||
lightningevent.commands.cast.fake: |
||||
description: Casts fake lightning bolts. |
||||
lightningevent.commands.cast.real: |
||||
description: Casts real lightning bolts. |
||||
lightningevent.events.*: |
||||
description: Allows use of all lightning events. |
||||
children: |
||||
lightningevent.events.bed.*: true |
||||
lightningevent.events.chat: true |
||||
lightningevent.events.death: true |
||||
lightningevent.events.join: true |
||||
lightningevent.events.kick: true |
||||
lightningevent.events.quit: true |
||||
lightningevent.events.move: true |
||||
lightningevent.events.teleport.*: true |
||||
lightningevent.events.respawn: true |
||||
lightningevent.events.bed.*: |
||||
description: Allows use of all bed lightning events. |
||||
children: |
||||
lightningevent.events.bed.enter: true |
||||
lightningevent.events.bed.leave: true |
||||
lightningevent.events.bed.enter: |
||||
description: Allows for a lightning strike when a player enters a bed. |
||||
lightningevent.events.bed.leave: |
||||
description: Allows for a lightning strike when a player leaves a bed. |
||||
lightningevent.events.chat: |
||||
description: Allows for a lightning strike when a player talks in chat. |
||||
lightningevent.events.death: |
||||
description: Allows for a lightning strike when a player dies. |
||||
lightningevent.events.join: |
||||
description: Allows for a lightning strike when a player joins. |
||||
lightningevent.events.kick: |
||||
description: Allows for a lightning strike when a player is kicked. |
||||
lightningevent.events.quit: |
||||
description: Allows for a lightning strike when a player quits. |
||||
lightningevent.events.move: |
||||
description: Allows for a lightning strike when a player moves. |
||||
lightningevent.events.teleport.*: |
||||
description: Allows use of all teleport lightning events. |
||||
children: |
||||
lightningevent.events.teleport.from: true |
||||
lightningevent.events.teleport.to: true |
||||
lightningevent.events.teleport.from: |
||||
description: Allows for a lightning strike when a player teleports at the location that they are teleporting from. |
||||
lightningevent.events.teleport.to: |
||||
description: Allows for a lightning strike when a player teleports at the location that they are teleporting to. |
||||
lightningevent.events.respawn: |
||||
description: Allows for a lightning strike when a player respawns. |
Loading…
Reference in new issue