mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-09-11 12:49:32 +00:00
Merge pull request #420 from kingbirdy/bendingevents
Add CommandSender to BendingReloatEvent, cleanup other events
This commit is contained in:
commit
010f4953ec
|
@ -39,6 +39,7 @@ import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
@ -1225,10 +1226,14 @@ public class GeneralMethods {
|
||||||
return mat != null && (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE || mat == Material.WOOD_SPADE || mat == Material.WOOD_SWORD || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE || mat == Material.STONE_SPADE || mat == Material.STONE_SWORD || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE || mat == Material.IRON_SWORD || mat == Material.IRON_SPADE || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SPADE);
|
return mat != null && (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE || mat == Material.WOOD_SPADE || mat == Material.WOOD_SWORD || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE || mat == Material.STONE_SPADE || mat == Material.STONE_SWORD || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE || mat == Material.IRON_SWORD || mat == Material.IRON_SPADE || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SPADE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadPlugin() {
|
public static void reloadPlugin(CommandSender sender) {
|
||||||
ProjectKorra.log.info("Reloading ProjectKorra and configuration");
|
ProjectKorra.log.info("Reloading ProjectKorra and configuration");
|
||||||
BendingReloadEvent event = new BendingReloadEvent();
|
BendingReloadEvent event = new BendingReloadEvent(sender);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Reload event cancelled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (DBConnection.isOpen) {
|
if (DBConnection.isOpen) {
|
||||||
DBConnection.sql.close();
|
DBConnection.sql.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class ReloadCommand extends PKCommand {
|
||||||
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 0)) {
|
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GeneralMethods.reloadPlugin();
|
GeneralMethods.reloadPlugin(sender);
|
||||||
sender.sendMessage(ChatColor.AQUA + "Bending config reloaded.");
|
sender.sendMessage(ChatColor.AQUA + "Bending config reloaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@ import java.util.jar.JarFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an ability is successfully loaded.
|
* Called when an ability is successfully loaded.
|
||||||
*
|
|
||||||
* @author kingbirdy
|
|
||||||
*/
|
*/
|
||||||
public class AbilityLoadEvent<T> extends Event {
|
public class AbilityLoadEvent<T> extends Event {
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
package com.projectkorra.projectkorra.event;
|
package com.projectkorra.projectkorra.event;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
/**
|
/**
|
||||||
* Called when the /bending reload command is executed.
|
* Called when the /bending reload command is executed.
|
||||||
*
|
|
||||||
* @author kingbirdy
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BendingReloadEvent extends Event {
|
public class BendingReloadEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancelled = false;
|
||||||
public BendingReloadEvent() {
|
|
||||||
|
public BendingReloadEvent(CommandSender sender) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,4 +24,21 @@ public class BendingReloadEvent extends Event {
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether the event is cancelled
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if the event is cancelled
|
||||||
|
* @param cancel boolean value indicating whether the event is cancelled or not
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
cancelled = cancel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.bukkit.event.HandlerList;
|
||||||
*
|
*
|
||||||
* @author savior67
|
* @author savior67
|
||||||
*/
|
*/
|
||||||
public class BindChangeEvent extends Event{
|
public class BindChangeEvent extends Event {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class EntityBendingDeathEvent extends Event {
|
||||||
private double damage;
|
private double damage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates a new EntityBendingDeathEvent
|
||||||
*
|
*
|
||||||
* @param victim the player who died
|
* @param victim the player who died
|
||||||
* @param attacker the player who killed the victim
|
* @param attacker the player who killed the victim
|
||||||
|
|
|
@ -9,9 +9,6 @@ import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player's bending element is modified
|
* Called when a player's bending element is modified
|
||||||
*
|
|
||||||
* @author kingbirdy
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class PlayerChangeElementEvent extends Event {
|
public class PlayerChangeElementEvent extends Event {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue