-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,325 additions
and
2,004 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Sorry, something went wrong. |
||
//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(); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.
This is a good one 👍 Spectate is almost unusable with a per-world inventory setup, especially since /spectate inv doesn't survive reboots.