我能够非常快速地学习和学习东西,但这仍然让我感到困惑:
这是在主类(DCFlags)中:
private WGCustomFlagsPlugin pluginWGCustomFlags;
private WorldGuardPlugin pluginWorldGuard;
private DCPvPToggle pluginDCPvPToggle;
private RegionListener listener;
public WGCustomFlagsPlugin getWGCFP(){
return this.pluginWGCustomFlags;
}
public WorldGuardPlugin getWGP() {
return this.pluginWorldGuard;
}
public DCPvPToggle getPPT(){
return this.pluginDCPvPToggle;
}
public void onEnable(){
this.pluginWorldGuard = Utils.getWorldGuard(this);
this.pluginWGCustomFlags = Utils.getWGCustomFlags(this);
this.pluginDCPvPToggle = Utils.getDCPvPToggle(this);
this.listener = new RegionListener(this);
}
这在不同的类(Utils)中:
public static WGCustomFlagsPlugin getWGCustomFlags(DCFlags plugin){
Plugin wgcf = plugin.getServer().getPluginManager().getPlugin("WGCustomFlags");
if ((wgcf == null) || (!(wgcf instanceof WGCustomFlagsPlugin))) {
return null;
}
return (WGCustomFlagsPlugin)wgcf;
}
public static WorldGuardPlugin getWorldGuard(DCFlags plugin){
Plugin wg = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
if ((wg == null) || (!(wg instanceof WorldGuardPlugin))) {
return null;
}
return (WorldGuardPlugin)wg;
}
public static DCPvPToggle getDCPvPToggle(DCFlags plugin){
Plugin ppt = plugin.getServer().getPluginManager().getPlugin("DCPvPToggle");
if ((ppt == null) || (!(ppt instanceof DCPvPToggle))) {
return null;
}
return (DCPvPToggle)ppt;
}
我知道这是为了能够使用其他插件的方法,但什么是“this”。为什么需要它?