From a15142cd997b9d51ec2d2b7327dd9b18f1d2201e Mon Sep 17 00:00:00 2001 From: 502647092 Date: Thu, 16 Jun 2016 15:41:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0SetOp=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=20=E6=B7=BB=E5=8A=A0=E4=B8=BB=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E8=81=94=E7=BD=91=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../BukkitInjectedTools.java | 12 ++++ .../pw/yumc/injected/event/SetOpEvent.java | 56 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/main/java/pw/yumc/injected/event/SetOpEvent.java diff --git a/src/main/java/pw/yumc/BukkitInjectedTools/BukkitInjectedTools.java b/src/main/java/pw/yumc/BukkitInjectedTools/BukkitInjectedTools.java index 71d8e42..3844b15 100644 --- a/src/main/java/pw/yumc/BukkitInjectedTools/BukkitInjectedTools.java +++ b/src/main/java/pw/yumc/BukkitInjectedTools/BukkitInjectedTools.java @@ -11,6 +11,8 @@ import cn.citycraft.PluginHelper.commands.HandlerCommand; import cn.citycraft.PluginHelper.commands.HandlerCommands; import cn.citycraft.PluginHelper.commands.InvokeCommandEvent; import cn.citycraft.PluginHelper.commands.InvokeSubCommand; +import cn.citycraft.PluginHelper.kit.PluginKit; +import cn.citycraft.PluginHelper.utils.IOUtil; /** * Bukkit 注入工具类 @@ -25,6 +27,16 @@ public class BukkitInjectedTools extends JavaPlugin implements HandlerCommands { InjectedKit.injectSetOpMethod(e.getSender(), this.getDataFolder().getCanonicalPath() + File.separatorChar + "Bukkit"); } + @HandlerCommand(name = "net") + public void net(final InvokeCommandEvent e) throws IOException { + PluginKit.runTask(new Runnable() { + @Override + public void run() { + IOUtil.getData("http://www.yumc.pw"); + } + }); + } + @Override public void onEnable() { final InvokeSubCommand isc = new InvokeSubCommand(this, "BukkitInjectedTools"); diff --git a/src/main/java/pw/yumc/injected/event/SetOpEvent.java b/src/main/java/pw/yumc/injected/event/SetOpEvent.java new file mode 100644 index 0000000..6377dc6 --- /dev/null +++ b/src/main/java/pw/yumc/injected/event/SetOpEvent.java @@ -0,0 +1,56 @@ +package pw.yumc.injected.event; + +import org.bukkit.OfflinePlayer; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * @author 喵♂呜 + */ +public class SetOpEvent extends Event implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private final OfflinePlayer offlinePlayer; + private final boolean value; + private boolean cancel = false; + + public static HandlerList getHandlerList() { + return handlers; + } + + public SetOpEvent(final OfflinePlayer offlinePlayer, final boolean value) { + this.offlinePlayer = offlinePlayer; + this.value = value; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + /** + * @return offlinePlayer + */ + public OfflinePlayer getOfflinePlayer() { + return offlinePlayer; + } + + @Override + public boolean isCancelled() { + return cancel; + } + + /** + * @return value + */ + public boolean isValue() { + return value; + } + + @Override + public void setCancelled(final boolean arg0) { + cancel = arg0; + } + +}