我想从EventsClass.class更改放置在Cmds.class 中的记录变量。
但我对这条线有问题:
private EventsClass plugin = EventsClass.getPlugin(EventsClass.class);
编译器无法解析 getPlugin。
代码:
主.java:
package com.github.noisersup.serverrust.LoginMe;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
loadConfig();
getServer().getPluginManager().registerEvents(new EventsClass(),this);
}
public void loadConfig(){
getConfig().options().copyDefaults(true);
this.saveConfig();
}
}
事件类.java:
package com.github.noisersup.serverrust.LoginMe;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import java.util.UUID;
public class EventsClass implements Listener {
public boolean logged;
@EventHandler
public void onJoin(PlayerJoinEvent e){
Player p = e.getPlayer();
UUID uuid = p.getUniqueId();
logged = false;
if("player."+uuid+".password"!=null){
//login
p.sendMessage("§2Welcome again "+p.getName()+"! Please login with command: §6§n/login <password>");
}else{
//register
p.sendMessage("§2Welcome "+p.getName()+"! Please register with command: + §6§n/register <password> <repeat_password>");
}
}
@EventHandler
public void onMove(PlayerMoveEvent e){
if(!logged){
e.setCancelled(true);
}
}
}
守候你守候我
饮歌长啸
相关分类