Skip to content

Commit

Permalink
Added the ninjar (put it in coremods in your dev environment and it does
Browse files Browse the repository at this point in the history
magic!) Updated to 1.4.7 obf, working on the ClassLoader...
  • Loading branch information
keepcalm committed Jan 5, 2013
1 parent 29cf0bc commit cc5c138
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 28 deletions.
Binary file added BukkitForgeNin.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions src/keepcalm/mods/bukkit/bukkitAPI/BukkitClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ public class BukkitClassLoader extends URLClassLoader {

public BukkitClassLoader(URL[] urls, ClassLoader parent) {
super(urls, parent);
System.out.println("Hello there, my parent is " + parent.getClass().getName());
}

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
String newName = name;

System.out.println("Find class: "+ name);

if (newName.startsWith("org.bukkit.craftbukkit")) {
newName.replace("org.bukkit.craftbukkit", "keepcalm.mods.bukkit.bukkitAPI");
newName.replace("Craft", "Bukkit");
Expand All @@ -24,8 +27,6 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
newName = "guava10." + newName;
System.out.println(" to " + newName);
}


return super.findClass(newName);
}

Expand Down
49 changes: 36 additions & 13 deletions src/keepcalm/mods/bukkit/bukkitAPI/BukkitServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import keepcalm.mods.bukkit.bukkitAPI.command.BukkitCommandMap;
import keepcalm.mods.bukkit.bukkitAPI.entity.BukkitEntity;
import keepcalm.mods.bukkit.bukkitAPI.entity.BukkitPlayer;
import keepcalm.mods.bukkit.bukkitAPI.generator.NormalChunkGenerator;
import keepcalm.mods.bukkit.bukkitAPI.help.CommandHelpTopic;
import keepcalm.mods.bukkit.bukkitAPI.help.SimpleHelpMap;
import keepcalm.mods.bukkit.bukkitAPI.inventory.BukkitInventoryCustom;
Expand Down Expand Up @@ -53,6 +54,7 @@
import net.minecraft.world.EnumGameType;
import net.minecraft.world.IWorldAccess;
import net.minecraft.world.WorldManager;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.WorldType;
Expand Down Expand Up @@ -104,7 +106,6 @@
import org.bukkit.plugin.PluginLoadOrder;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.ServicesManager;
import org.bukkit.plugin.SimplePluginManager;
import org.bukkit.plugin.SimpleServicesManager;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.bukkit.plugin.messaging.Messenger;
Expand All @@ -127,6 +128,7 @@
import cpw.mods.fml.common.registry.GameRegistry;
//import cpw.mods.fml.common.FMLCommonHandler;
//import jline.console.ConsoleReader;
import cpw.mods.fml.relauncher.RelaunchClassLoader;


public class BukkitServer implements Server {
Expand All @@ -146,7 +148,7 @@ public class BukkitServer implements Server {
private PluginManager pluginManager;// = new SimplePluginManager(this, commandMap);


private BukkitClassLoader thePluginLoader = new BukkitClassLoader(((URLClassLoader) getClass().getClassLoader()).getURLs(), getClass().getClassLoader());
private BukkitClassLoader thePluginLoader;// = new BukkitClassLoader(((URLClassLoader) getClass().getClassLoader()).getURLs(), getClass().getClassLoader());
//private BukkitScheduler scheduler = new BukkitScheduler();
// private ServicesManager servicesManager = new SimpleServicesManager();
public Map<Integer,BukkitWorld> worlds = new LinkedHashMap<Integer,BukkitWorld>();
Expand Down Expand Up @@ -187,20 +189,22 @@ public BukkitServer(MinecraftServer server) {
Iterator<Integer> _ = ids.iterator();


/*try {
thePluginLoader = new BukkitClassLoader(((RelaunchClassLoader)getClass().getClassLoader()).getURLs(), getClass().getClassLoader());
try {
System.out.println("This is a test of the SPM Loader!");
// this *should* load simplepluginamanger via BukkitClassLoader
Class<?> pluginMan = thePluginLoader.loadClass("org.bukkit.plugin.SimplePluginManager");
System.out.println("Loaded class: " + pluginMan.getCanonicalName() + " via " + thePluginLoader.getClass().getCanonicalName());
Method insn = pluginMan.getMethod("newInstance");
insn.setAccessible(true);
this.pluginManager = (PluginManager) insn.invoke(null);


} catch (Exception e1) {
throw new RuntimeException("BukkitForge encountered an error (most likely it was installed incorrectly!)", e1);
}*/
pluginManager = new SimplePluginManager(this, commandMap);
}

//pluginManager = new SimplePluginManager(this, commandMap);
bukkitConfig = new YamlConfiguration();
YamlConfiguration yml = new YamlConfiguration();
try {
Expand Down Expand Up @@ -721,6 +725,20 @@ public World getWorld(String name) {
public World getWorld(int dimID) {
if (worlds.containsKey(dimID))
return worlds.get(dimID);
else if (!worlds.containsKey(dimID) && Arrays.asList(DimensionManager.getIDs()).contains(dimID)) {
// dim there but not registered with us.
WorldServer internal = DimensionManager.getWorld(dimID);
int dim = internal.getWorldInfo().getDimension();
System.out.println("Registering dimension with BukkitForge: " + dim + "..." );
WorldProvider w = internal.provider;

Environment env = w.isHellWorld ? Environment.NETHER : Environment.NORMAL;
ChunkGenerator cg = new NormalChunkGenerator(internal);//(((WorldServer)ev.world).theChunkProviderServer);
BukkitWorld bukkit = new BukkitWorld(internal, cg, env);
BukkitServer.instance().worlds.put(dim, bukkit);
return bukkit;

}
return null;
}

Expand Down Expand Up @@ -775,20 +793,25 @@ public MapView createMap(World world) {
@Override
public void reload() {
bukkitConfig = YamlConfiguration.loadConfiguration(new File("bukkit.yml"));
PropertyManager config = new PropertyManager(theServer.getFile("server.properties"));
//

((DedicatedServer) theServer).settings = config;
if (theServer instanceof DedicatedServer) {
PropertyManager config = new PropertyManager(theServer.getFile("server.properties"));
((DedicatedServer) theServer).settings = config;
}

//

boolean animals = config.getBooleanProperty("spawn-animals", theServer.getCanSpawnAnimals());
boolean monsters = config.getBooleanProperty("spawn-monsters", theServer.worldServerForDimension(0).difficultySetting > 0);
int difficulty = config.getIntProperty("difficulty", theServer.worldServerForDimension(0).difficultySetting);
boolean animals = theServer.getCanSpawnAnimals();
boolean monsters = theServer.worldServerForDimension(0).difficultySetting > 0;
int difficulty = theServer.worldServerForDimension(0).difficultySetting;

//theServer.pro
theServer.setOnlineMode(config.getBooleanProperty("online-mode", theServer.isServerInOnlineMode()));
/*theServer.setOnlineMode(theServer.isServerInOnlineMode());
theServer.setCanSpawnAnimals(config.getBooleanProperty("spawn-animals", theServer.getCanSpawnAnimals()));
theServer.setAllowPvp(config.getBooleanProperty("pvp", theServer.isPVPEnabled()));
theServer.setAllowFlight(config.getBooleanProperty("allow-flight", theServer.isFlightAllowed()));
theServer.setMOTD(config.getProperty("motd", theServer.getMOTD()));
theServer.setMOTD(config.getProperty("motd", theServer.getMOTD()));*/
monsterSpawn = bukkitConfig.getInt("spawn-limits.monsters");
animalSpawn = bukkitConfig.getInt("spawn-limits.animals");
waterAnimalSpawn = bukkitConfig.getInt("spawn-limits.water-animals");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public boolean isVillager() {

@Override
public void setVillager(boolean flag) {
getHandle().setIsVillager(true);
getHandle().setVillager(true);
}
}
16 changes: 4 additions & 12 deletions src/keepcalm/mods/bukkit/forgeHandler/ForgeEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ else if (ds == ds.fall)
dc = DamageCause.FALL;
else if (ds == ds.fallingBlock)
dc = DamageCause.FALL;
else if (ds == ds.field_76375_l)
else if (ds == ds.explosion2)
dc = DamageCause.ENTITY_EXPLOSION;
else if (ds == ds.generic)
dc = DamageCause.CUSTOM;
Expand Down Expand Up @@ -476,26 +476,18 @@ public void saplingGrow(SaplingGrowTreeEvent ev) {
}
}

@ForgeSubscribe
/*@ForgeSubscribe
public void worldLoad(WorldEvent.Load ev) {
if (!ForgeEventHandler.ready || FMLCommonHandler.instance().getEffectiveSide().isClient())
return;
int dim = ev.world.getWorldInfo().getDimension();
if (BukkitServer.instance().getWorld(dim) == null) {
System.out.println("Registering dimension with BukkitForge: " + dim + "..." );
WorldProvider w = ev.world.provider;

Environment env = w.isHellWorld ? Environment.NETHER : Environment.NORMAL;
ChunkGenerator cg = new NormalChunkGenerator(ev.world);//(((WorldServer)ev.world).theChunkProviderServer);
BukkitWorld bukkit = new BukkitWorld((WorldServer) ev.world, cg, env);
BukkitServer.instance().worlds.put(dim, bukkit);
WorldLoadEvent bev = new WorldLoadEvent(bukkit);
Bukkit.getPluginManager().callEvent(bev);
}
}
}*/
// begin BukkitForge-added events

// used PlayerInteractEvent for this
Expand Down

0 comments on commit cc5c138

Please sign in to comment.