Changing Movecraft to soft-depend

Needs testing
This commit is contained in:
Norbi Peti 2016-04-07 09:00:25 +02:00
parent 429a6fc175
commit 433fc0c5a8

View file

@ -40,7 +40,7 @@ public class PluginMain extends JavaPlugin
{
ConsoleCommandSender ccs = getServer().getConsoleSender();
this.getCommand("computer").setExecutor(new Commands());
ccs.sendMessage("§bExtracting necessary libraries...");
ccs.sendMessage("§bExtracting necessary libraries...");
final File[] libs = new File[] { // added to class path
new File(getDataFolder(), "jni4net.j-0.8.8.0.jar"),
new File(getDataFolder(), "VirtualComputerSender.j4n.jar") };
@ -75,17 +75,17 @@ public class PluginMain extends JavaPlugin
}
addClassPath(JarUtils.getJarUrl(lib));
}
ccs.sendMessage("§bInitializing bridge...");
ccs.sendMessage("§bInitializing bridge...");
// Bridge.setVerbose(true);
// Bridge.setDebug(true);
Bridge.init(new File(getDataFolder(),
"jni4net.n.w64.v40-0.8.8.0.dll").getAbsoluteFile());
Bridge.LoadAndRegisterAssemblyFrom(new File(getDataFolder(),
"VirtualComputerSender.j4n.dll"));
ccs.sendMessage("§bInititalizing VirtualBox interface...");
ccs.sendMessage("§bInititalizing VirtualBox interface...");
computer = new Computer();
//ccs.sendMessage("§bLoading ArmorStands...");
ccs.sendMessage("§bLoading SketchMap...");
//ccs.sendMessage("§bLoading ArmorStands...");
ccs.sendMessage("§bLoading SketchMap...");
/*
* for (ArmorStand as : Bukkit.getWorlds().get(0)
* .getEntitiesByClass(ArmorStand.class))
@ -127,7 +127,7 @@ public class PluginMain extends JavaPlugin
for (int j = 0; j < 4; j++)
map.put((short) (i * 4 + j), new RelativeLocation(i, j));
smap = new SketchMap(img, "Screen", 5, 4, false, map);
ccs.sendMessage("§bLoaded!");
ccs.sendMessage("§bLoaded!");
DoStart();
} catch (final Exception e)
{
@ -140,8 +140,8 @@ public class PluginMain extends JavaPlugin
public void onDisable()
{
ConsoleCommandSender ccs = getServer().getConsoleSender();
//ccs.sendMessage("§aSaving ArmorStands...");
//ccs.sendMessage("§aSaving Maps...");
//ccs.sendMessage("§aSaving ArmorStands...");
//ccs.sendMessage("§aSaving Maps...");
/*
* for (int i = 0; i < iframes.length; i++)
* {
@ -154,7 +154,7 @@ public class PluginMain extends JavaPlugin
* }
* }
*/
ccs.sendMessage("§aHuh.");
ccs.sendMessage("§aHuh.");
saveConfig();
}
@ -169,9 +169,9 @@ public class PluginMain extends JavaPlugin
public void Start(CommandSender sender)
{
sender.sendMessage("§eStarting computer...");
sender.sendMessage("§eStarting computer...");
computer.Start();
sender.sendMessage("§eComputer started.");
sender.sendMessage("§eComputer started.");
DoStart();
/*
* this.getServer().getScheduler()
@ -284,6 +284,7 @@ public class PluginMain extends JavaPlugin
*/
}
}, 1, 10);
if (getServer().getPluginManager().isPluginEnabled("Movecraft")) {
this.getServer().getScheduler()
.scheduleSyncRepeatingTask(this, new Runnable()
{
@ -324,6 +325,7 @@ public class PluginMain extends JavaPlugin
}
}
}, 1, 1);
}
getServer().getPluginManager().registerEvents(
new MouseLockerPlayerListener(), this);
@ -331,7 +333,7 @@ public class PluginMain extends JavaPlugin
public void Stop(CommandSender sender)
{
sender.sendMessage("§eStopping computer...");
sender.sendMessage("§eStopping computer...");
computer.PowerOff();
/*
* if (taskid != -1)
@ -341,13 +343,13 @@ public class PluginMain extends JavaPlugin
* taskid = -1;
* }
*/
sender.sendMessage("§eComputer stopped.");
sender.sendMessage("§eComputer stopped.");
}
@SuppressWarnings("deprecation")
public void PowerButton(CommandSender sender)
{
sender.sendMessage("§eStarting/stoppping computer...");
sender.sendMessage("§eStarting/stoppping computer...");
final CommandSender s = sender;
getServer().getScheduler().scheduleAsyncDelayedTask(this,
new Runnable()
@ -358,25 +360,25 @@ public class PluginMain extends JavaPlugin
if (computer.PowerButton())
{
DoStart();
s.sendMessage("§eComputer started.");
s.sendMessage("§eComputer started.");
} else
s.sendMessage("§ePowerbutton pressed.");
s.sendMessage("§ePowerbutton pressed.");
}
});
}
public void Reset(CommandSender sender)
{
sender.sendMessage("§eResetting computer...");
sender.sendMessage("§eResetting computer...");
computer.Reset();
sender.sendMessage("§eComputer reset.");
sender.sendMessage("§eComputer reset.");
}
public void FixScreen(CommandSender sender)
{
sender.sendMessage("§eFixing screen...");
sender.sendMessage("§eFixing screen...");
computer.FixScreen();
sender.sendMessage("§eScreen fixed.");
sender.sendMessage("§eScreen fixed.");
}
public void PressKey(CommandSender sender, String key,