1
0
mirror of https://e.coding.net/circlecloud/BukkitInjectedTools.git synced 2024-11-25 02:08:49 +00:00

feat: 添加SetOp事件 添加主线程联网操作

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-06-16 15:41:12 +08:00
parent 079dc9da0d
commit a15142cd99
2 changed files with 68 additions and 0 deletions

View File

@ -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");

View File

@ -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;
}
}