/MCStreamClient/src/org/wyrez/StreamClient/StreamClient.java
https://bitbucket.org/DarthAffe/mcreplay · Java · 65 lines · 54 code · 7 blank · 4 comment · 10 complexity · e14e902eb907f6eac577b4e8aa73f6f5 MD5 · raw file
- package org.wyrez.StreamClient;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.wyrez.Replay.Replay;
- import org.wyrez.Replay.ReplayManager;
- import org.wyrez.StreamClient.network.NetworkManager;
- import org.wyrez.StreamClient.npc.PlayerManager;
- import org.wyrez.StreamClient.replay.ReplayPlayer;
- /**
- *
- * @author Darth Affe
- */
- public class StreamClient extends JavaPlugin {
- public static final String WORLD = "world";
- public static final Logger LOG = Logger.getLogger("Minecraft");
- private NetworkManager network;
- private PlayerManager playerManager;
- private ReplayManager replayManager;
- private ReplayPlayer rp;
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (command.getName().equalsIgnoreCase("replay")) {
- if (args.length == 1) {
- loadReplay(args[0]);
- return true;
- }
- } else if (command.getName().equalsIgnoreCase("rabbrechen")) {
- if (rp != null) {
- rp.exit();
- }
- }
- return false;
- }
- private void loadReplay(String name) {
- replayManager = new ReplayManager();
- Bukkit.broadcastMessage("loading " + name + "...");
- Replay r = replayManager.load(name);
- if (r == null) {
- Bukkit.broadcastMessage("failed!");
- } else {
- rp = new ReplayPlayer(r, playerManager, Bukkit.getWorld(WORLD), name);
- Bukkit.broadcastMessage("running!");
- rp.start();
- }
- }
- @Override
- public void onDisable() {
- LOG.info("StreamClient has been disabled.");
- }
- @Override
- public void onEnable() {
- playerManager = new PlayerManager(Bukkit.getWorld(WORLD));
- network = new NetworkManager(Bukkit.getWorld(WORLD), playerManager);
- LOG.info("StreamClient has been enabled.");
- }
- }