Fix for subplugins

This commit is contained in:
fullwall 2012-09-13 20:39:52 +08:00
parent 9b1a53fcab
commit 1b96cdf34b
3 changed files with 16 additions and 5 deletions

View File

@ -54,6 +54,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginLoadOrder;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -82,9 +83,17 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString()); File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString());
if (!root.exists() || !root.isDirectory()) if (!root.exists() || !root.isDirectory())
return; return;
Plugin[] plugins = Bukkit.getPluginManager().loadPlugins(root); File[] files = root.listFiles();
// code beneath modified from CraftServer for (File file : files) {
for (Plugin plugin : plugins) { Plugin plugin;
try {
plugin = Bukkit.getPluginManager().loadPlugin(file);
} catch (Exception e) {
continue;
}
if (plugin == null)
continue;
// code beneath modified from CraftServer
try { try {
Messaging.logF("Loading %s", plugin.getDescription().getFullName()); Messaging.logF("Loading %s", plugin.getDescription().getFullName());
plugin.onLoad(); plugin.onLoad();
@ -93,6 +102,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
((CraftServer) Bukkit.getServer()).enablePlugins(PluginLoadOrder.POSTWORLD);
} }
public Iterable<CommandInfo> getCommands(String base) { public Iterable<CommandInfo> getCommands(String base) {

View File

@ -191,7 +191,8 @@ public class EventListen implements Listener {
if (npc.getTrait(Owner.class).isOwnedBy(event.getCreator())) if (npc.getTrait(Owner.class).isOwnedBy(event.getCreator()))
owned++; owned++;
} }
if (limit >= owned + 1 || limit == 0) { int wouldOwn = owned + 1;
if (wouldOwn >= limit) {
event.setCancelled(true); event.setCancelled(true);
event.setCancelReason(String.format("Over the NPC limit of %d.", limit)); event.setCancelReason(String.format("Over the NPC limit of %d.", limit));
} }

View File

@ -35,7 +35,7 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
// set the head yaw in another tick - if done immediately, // set the head yaw in another tick - if done immediately,
// minecraft will not update it. // minecraft will not update it.
} }
}, 5); }, 3);
handle.getBukkitEntity().setSleepingIgnored(true); handle.getBukkitEntity().setSleepingIgnored(true);
return handle; return handle;
} }