Skip to content

Commit

Permalink
Spectate 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Chipley committed May 25, 2013
1 parent e8b5b77 commit ebe3b85
Show file tree
Hide file tree
Showing 11 changed files with 1,325 additions and 2,004 deletions.
3 changes: 0 additions & 3 deletions .gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions changelog

This file was deleted.

2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Spectate
main: com.Chipmunk9998.Spectate.Spectate
version: 1.11
version: 2.0
commands:
spectate:
description: Lets you spectate another user
Expand Down
49 changes: 49 additions & 0 deletions src/com/Chipmunk9998/Spectate/PlayerState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.Chipmunk9998.Spectate;

import java.util.ArrayList;

import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

public class PlayerState {

public Player player;
public ItemStack[] inventory;
public ItemStack[] armor;
public int hunger;
public int health;
public int xp;
public int slot;
public Location location;

public ArrayList<Player> vanishedFrom = new ArrayList<Player>();

public PlayerState(Player p) {

player = p;
inventory = p.getInventory().getContents();
armor = p.getInventory().getArmorContents();
hunger = p.getFoodLevel();
health = p.getHealth();
xp = p.getTotalExperience();
slot = p.getInventory().getHeldItemSlot();
location = p.getLocation();

for (Player players : p.getWorld().getPlayers()) {

if (players != p ) {

if (!players.canSee(p)) {

vanishedFrom.add(players);

}

}

}

}

}
129 changes: 41 additions & 88 deletions src/com/Chipmunk9998/Spectate/Spectate.java
Original file line number Diff line number Diff line change
@@ -1,88 +1,41 @@
package com.Chipmunk9998.Spectate;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;

public class Spectate extends JavaPlugin {

FileConfiguration conf;

public SpectateListener Listener = new SpectateListener(this);
public SpectateCommandExecutor CommandExecutor = new SpectateCommandExecutor(this);

public void onEnable() {

SpectateAPI.setPlugin(this);

getServer().getPluginManager().registerEvents(Listener, this);

conf = getConfig();

boolean canspectate = false;

if (conf.get("canspectate Permission Enabled?") != null) {

canspectate = conf.getBoolean("canspectate Permission Enabled?");
conf.set("canspectate Permission Enabled?", null);

}

if (conf.get("cantspectate Permission Enabled?") == null) {

conf.set("cantspectate Permission Enabled?", canspectate);

}

if (conf.get("Disable commands while spectating?") == null) {

conf.set("Disable commands while spectating?", false);

}

saveConfig();

PluginDescriptionFile pdfFile = getDescription();

System.out.println("[" + pdfFile.getName() + "] " + pdfFile.getName() + " v" + pdfFile.getVersion() + " enabled!");

Listener.updatePlayer();

getCommand("spectate").setExecutor(CommandExecutor);
getCommand("spec").setExecutor(CommandExecutor);
//getCommand("control").setExecutor(CommandExecutor);

}

public void onDisable() {

for (Player players : getServer().getOnlinePlayers()) {

if (CommandExecutor.isSpectating.contains(players.getName())) {

players.sendMessage("§7You were forced to stop spectating because of a server reload.");

if (CommandExecutor.isScanning.get(players.getName()) != null) {

if (CommandExecutor.isScanning.get(players.getName())) {

CommandExecutor.isScanning.put(players.getName(), false);

getServer().getScheduler().cancelTask(CommandExecutor.taskId.get(players.getName()));

}

}

SpectateAPI.spectateOff(players);

}

}

System.out.println("Spectate is disabled!");

}

}
package com.Chipmunk9998.Spectate;

import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import com.Chipmunk9998.Spectate.api.SpectateManager;

public class Spectate extends JavaPlugin {

//TODO: Scanning
//TODO: First person/Third person/Third person front/Free roam
//TODO: Control command
//TODO: Fix inventory compatibility (Multiverse Inventories, Mob Arena)

This comment has been minimized.

Copy link
@salaman

salaman May 25, 2013

This is a good one 👍 Spectate is almost unusable with a per-world inventory setup, especially since /spectate inv doesn't survive reboots.

//TODO: Fix players that log in being able to see spectating players (just check in join event)
//TODO: Config

public void onEnable() {

SpectateManager.setPlugin(this);

getServer().getPluginManager().registerEvents(new SpectateListener(this), this);
getCommand("spectate").setExecutor(new SpectateCommandExecutor(this));
SpectateManager.startSpectateTask();

}

public void onDisable() {

for (Player p : SpectateManager.getSpectatingPlayers()) {

SpectateManager.stopSpectating(p, true);
p.sendMessage(ChatColor.GRAY + "You were forced to stop spectating because of a server reload.");

}

SpectateManager.stopSpectateTask();

}

}
Loading

0 comments on commit ebe3b85

Please sign in to comment.