This commit is contained in:
Disclearing 2019-04-12 19:03:09 +01:00
commit 119e1d54f6
16 changed files with 1013 additions and 0 deletions

8
.classpath Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="C:/Users/Real/Desktop/src/ReaperMC/ReaperFactionsHCF/depends/PermissionsEx-1.23.3.jar"/>
<classpathentry kind="lib" path="C:/Users/Real/Desktop/src/ReaperMC/ReaperFactionsHCF -Custom spigot/depends/custom.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/bin/

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Reaper-StaffMode</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

11
plugin.yml Normal file
View File

@ -0,0 +1,11 @@
name: ReaperSTAFFMODE
version: 1.0
author: Rainnny
main: com.Rainnny.Reaper.StaffMode
softdepend: [WorldEdit]
commands:
staffmode:
aliases: [staff, mod, modmode, h]
vanish:
aliases: [v]
hidestaff:

View File

@ -0,0 +1,24 @@
package com.Rainnny.Reaper.API;
import org.bukkit.entity.Player;
import com.Rainnny.Reaper.StaffMode;
public class API {
public API() {
instance = this;
}
private static API instance;
public boolean isInStaffMode(Player player) {
return new StaffMode().isInStaffMode(player);
}
}

View File

@ -0,0 +1,52 @@
package com.Rainnny.Reaper.Commands;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.Rainnny.Reaper.StaffMode;
import com.Rainnny.Reaper.Utils.ColorUtil;
public class HideStaffCmd implements CommandExecutor {
private StaffMode core;
public HideStaffCmd(StaffMode core) {
this.core = core;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!sender.hasPermission("hide.staff") || !(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "No permission.");
return true;
}
if(args.length != 0) {
sender.sendMessage(ChatColor.DARK_RED + "Usage: /hidestaff");
return true;
}
Player p = (Player) sender;
if(!core.hiddenStaff.contains(p)) {
if(!core.getStaffOnline().isEmpty()) {
for(Player staff : core.getStaffOnline()) {
p.hidePlayer(staff);
core.hiddenStaff.add(p);
}
}
p.sendMessage("§cSuccesfully disabled visibility of all staff.");
} else {
if(!core.getStaffOnline().isEmpty()) {
for(Player staff : core.getStaffOnline()) {
p.showPlayer(staff);
core.hiddenStaff.remove(p);
}
}
p.sendMessage("§cSuccesfully enabled visibility of all staff.");
}
return true;
}
}

View File

@ -0,0 +1,39 @@
package com.Rainnny.Reaper.Commands;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.Rainnny.Reaper.StaffMode;
import com.Rainnny.Reaper.Utils.ColorUtil;
public class StaffModeCmd implements CommandExecutor {
private StaffMode core;
public StaffModeCmd(StaffMode core) {
this.core = core;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!sender.hasPermission("railed.staff") || !(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You don't have permission to use this.");
return true;
}
if(args.length == 0) {
Player p = (Player) sender;
if(!core.inStaffMode.contains(p)) {
core.setStaffMode(p, true);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Your staff mode has been &aenabled" + StaffMode.O + "!"));
} else {
core.setStaffMode(p, false);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Your staff mode has been &cdisabled" + StaffMode.O + "!"));
}
}
return true;
}
}

View File

@ -0,0 +1,115 @@
package com.Rainnny.Reaper.Commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.permissions.Permissible;
import com.Rainnny.Reaper.StaffMode;
import com.Rainnny.Reaper.Utils.ColorUtil;
import ru.tehkode.permissions.bukkit.PermissionsEx;
public class Vanish implements CommandExecutor {
private StaffMode core;
public Vanish(StaffMode core) {
this.core = core;
}
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!(sender instanceof Player) || !sender.hasPermission("railed.staff") || !sender.hasPermission("essentials.vanish")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to use this.");
return true;
}
Player p = (Player) sender;
if(args.length == 0) {
if(core.isInStaffMode(p)) {
if(core.isVanished(p)) {
ItemStack vanish = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 8);
ItemMeta vanishMeta = vanish.getItemMeta();
vanishMeta.setDisplayName(ChatColor.DARK_RED + "Vanish");
vanishMeta.setLore(core.vanishLore());
vanish.setItemMeta(vanishMeta);
p.getInventory().setItem(8, vanish);
p.updateInventory();
core.setVanished(p, false);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Your vanish has been &cdisabled" + StaffMode.O + "!"));
} else {
ItemStack vanish = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 10);
ItemMeta vanishMeta = vanish.getItemMeta();
vanishMeta.setDisplayName(ChatColor.DARK_RED + "Vanish");
vanishMeta.setLore(core.vanishLore());
vanish.setItemMeta(vanishMeta);
p.getInventory().setItem(8, vanish);
p.updateInventory();
core.setVanished(p, true);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Your vanish has been &aenabled" + StaffMode.O + "!"));
}
} else {
if(core.isVanished(p)) {
core.setVanished(p, false);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Your vanish has been &cdisabled" + StaffMode.O + "!"));
} else {
core.setVanished(p, true);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Your vanish has been &aenabled" + StaffMode.O + "!"));
}
}
} else {
if(args.length == 1) {
Player argsPlayer = Bukkit.getPlayer(args[0]);
if(core.isInStaffMode(argsPlayer)) {
if(core.isVanished(p)) {
ItemStack vanish = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 8);
ItemMeta vanishMeta = vanish.getItemMeta();
vanishMeta.setDisplayName(ChatColor.DARK_RED + "Vanish");
vanishMeta.setLore(core.vanishLore());
vanish.setItemMeta(vanishMeta);
p.getInventory().setItem(8, vanish);
p.updateInventory();
core.setVanished(argsPlayer, false);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Set " + PermissionsEx.getUser(argsPlayer.getName()).getSuffix() + argsPlayer.getName() + "'s vanish to &cfalse"));
argsPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9&oYou have been put into vanish by " + p.getName() + "."));
} else {
ItemStack vanish = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 10);
ItemMeta vanishMeta = vanish.getItemMeta();
vanishMeta.setDisplayName(ChatColor.DARK_RED + "Vanish");
vanishMeta.setLore(core.vanishLore());
vanish.setItemMeta(vanishMeta);
p.getInventory().setItem(8, vanish);
p.updateInventory();
core.setVanished(argsPlayer, true);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Set " + PermissionsEx.getUser(argsPlayer.getName()).getSuffix() + argsPlayer.getName() + "'s vanish to &atrue"));
argsPlayer.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Your vanish has been set to &atrue" + StaffMode.O + " by " + PermissionsEx.getUser(argsPlayer.getName()).getSuffix() + argsPlayer.getName()));
}
} else {
if(core.isVanished(p)) {
core.setVanished(argsPlayer, false);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Set " + PermissionsEx.getUser(argsPlayer.getName()).getSuffix() + argsPlayer.getName() + "'s vanish to &cfalse"));
argsPlayer.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Your vanish has been set to &cfalse" + StaffMode.O + " by " + PermissionsEx.getUser(argsPlayer.getName()).getSuffix() + argsPlayer.getName()));
} else {
core.setVanished(argsPlayer, true);
p.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Set " + PermissionsEx.getUser(argsPlayer.getName()).getSuffix() + argsPlayer.getName() + "'s vanish to &atrue"));
argsPlayer.sendMessage(ColorUtil.color(StaffMode.PREFIX + "Your vanish has been set to &atrue" + StaffMode.O + " by " + PermissionsEx.getUser(argsPlayer.getName()).getSuffix() + argsPlayer.getName()));
}
}
return true;
}
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cError: &7Too many arguments! &4&oUse /vanish <player>"));
}
return true;
}
}

View File

@ -0,0 +1,51 @@
package com.Rainnny.Reaper.Listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import com.Rainnny.Reaper.StaffMode;
public class HideVanishListener implements Listener {
private StaffMode core;
public HideVanishListener(StaffMode core) {
this.core = core;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
if(core.inVanish.size() > 0) {
for(Player p : core.inVanish) {
e.getPlayer().hidePlayer(p);
}
}
if(e.getPlayer().hasPermission("railed.staff")) {
if(core.hiddenStaff.contains(e.getPlayer())) {
for(Player staff : core.getStaffOnline()) {
if(staff != e.getPlayer()) {
e.getPlayer().hidePlayer(staff);
}
}
}
for(Player staff : core.hiddenStaff) {
staff.hidePlayer(e.getPlayer());
}
}
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent e) {
if(core.isVanished(e.getPlayer())) {
core.setStaffMode(e.getPlayer(), false);
}
}
}

View File

@ -0,0 +1,188 @@
package com.Rainnny.Reaper.Listeners;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Chest;
import org.bukkit.entity.Damageable;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import com.Rainnny.Reaper.StaffMode;
public class StaffModeItems implements Listener {
private StaffMode core;
public StaffModeItems(StaffMode core) {
this.core = core;
}
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack itemInHand = p.getItemInHand();
Inventory rm = Bukkit.createInventory(null, 54, "Silent Chest");
if(core.isInStaffMode(p)) {
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(itemInHand.getType().equals(Material.WATCH) && itemInHand.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.DARK_RED + "Random Teleport")) {
if(core.toTeleportTo.size() > 0) {
Random r = new Random();
int index = r.nextInt(core.toTeleportTo.size());
p.teleport(core.toTeleportTo.get(index).getLocation());
p.sendMessage(ChatColor.GRAY + "Teleported to " + ChatColor.WHITE + core.toTeleportTo.get(index).getDisplayName());
} else {
p.sendMessage(ChatColor.RED + "Prevented teleportation since there is nobody to teleport to.");
}
}
if(itemInHand.getType().equals(Material.INK_SACK) && itemInHand.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.DARK_RED + "Vanish")) {
Bukkit.dispatchCommand(p, "vanish");
}
if(itemInHand.getType().equals(Material.SKULL_ITEM) && itemInHand.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.DARK_RED + "Staff Online")) {
core.staffOnlineGUI.open(p);
}
}
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(e.getClickedBlock().getType().equals(Material.CHEST) || e.getClickedBlock().getType().equals(Material.TRAPPED_CHEST)) {
Chest chest = (Chest) e.getClickedBlock().getState();
p.sendMessage(ChatColor.GRAY + "Opened chest silently.");
rm.setContents(chest.getInventory().getContents());
p.openInventory(rm);
e.setCancelled(true);
}
}
e.setCancelled(true);
}
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
if(core.isInStaffMode(e.getPlayer())) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
if(core.isInStaffMode(e.getPlayer())) {
e.setCancelled(true);
}
}
@EventHandler
public void onInventoryDrop(PlayerDropItemEvent e) {
if(core.isInStaffMode(e.getPlayer())) {
e.setCancelled(true);
}
}
@EventHandler
public void onInvPickup(PlayerPickupItemEvent e) {
if(core.isInStaffMode(e.getPlayer())) {
e.setCancelled(true);
}
}
@EventHandler
public void onInvMove(InventoryClickEvent e) {
if(core.isInStaffMode((Player) e.getWhoClicked())) {
e.setCancelled(true);
}
}
@EventHandler
public void onAttack(EntityDamageByEntityEvent e) {
if(e.getDamager() instanceof Player) {
if(core.isInStaffMode((Player) e.getDamager())) {
Player p = (Player) e.getDamager();
e.setCancelled(true);
p.sendMessage(ChatColor.RED + "Get out of staff mode to pvp!");
return;
}
if(core.isVanished((Player) e.getDamager())) {
Player p = (Player) e.getDamager();
e.setCancelled(true);
p.sendMessage(ChatColor.RED + "Get out of vanish to pvp!");
return;
}
}
}
@EventHandler
public void onInteractEntity(PlayerInteractEntityEvent e) {
Player p = e.getPlayer();
ItemStack itemInHand = p.getItemInHand();
if(core.inStaffMode.contains(p)) {
if(itemInHand.getType().equals(Material.ICE)) {
if(e.getRightClicked() instanceof Player) {
Player clicked = (Player) e.getRightClicked();
Bukkit.dispatchCommand(p, "freeze " + clicked.getName());
}
}
if(itemInHand.getType().equals(Material.BOOK)) {
if(e.getRightClicked() instanceof Player) {
Player clicked = (Player) e.getRightClicked();
Damageable clickedd = clicked;
Inventory rm = Bukkit.createInventory(null, 54, clicked.getName());
rm.setContents(clicked.getInventory().getContents());
for(int i = 36; i < 45 ; i++) {
rm.setItem(i, new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 5));
}
ItemStack health = new ItemStack(Material.SPECKLED_MELON, 1);
ItemMeta healthMeta = health.getItemMeta();
healthMeta.setDisplayName(ChatColor.RED.toString() + clickedd.getHealth() / 2 + "™¥");
health.setItemMeta(healthMeta);
ItemStack hunger = new ItemStack(Material.COOKED_CHICKEN, 1);
ItemMeta hungerMeta = health.getItemMeta();
hungerMeta.setDisplayName(ChatColor.RED.toString() + clicked.getFoodLevel() + " Hunger");
hunger.setItemMeta(hungerMeta);
ItemStack potions = new ItemStack(Material.POTION, 1);
ItemMeta potionsMeta = potions.getItemMeta();
ArrayList<String> effects = new ArrayList<String>();
effects.add(" ");
for(PotionEffect effect : clicked.getActivePotionEffects()) {
if(clicked.getActivePotionEffects() != null) {
effects.add(ChatColor.WHITE + effect.getType().getName() + " " + effect.getDuration());
}
}
potionsMeta.setLore(effects);
potionsMeta.setDisplayName(ChatColor.RED + "Potion Effects");
potions.setItemMeta(potionsMeta);
rm.setItem(45, health);
rm.setItem(46, hunger);
rm.setItem(47, potions);
p.openInventory(rm);
}
}
}
e.setCancelled(true);
}
}

View File

@ -0,0 +1,32 @@
package com.Rainnny.Reaper.Listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import com.Rainnny.Reaper.StaffMode;
import net.md_5.bungee.api.ChatColor;
public class StaffModeOnJoin implements Listener {
private StaffMode core;
public StaffModeOnJoin(StaffMode core) {
this.core = core;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if(core.isStaff(p) || !core.isVanished(p)) {
p.sendMessage(ChatColor.GRAY.toString() + ChatColor.ITALIC + "You were automatically put in vanish since you joined!");
core.setVanished(p, true);
} else {
if(core.isStaff(p) || !core.inStaffMode.contains(p)) {
core.setStaffMode(p, true);
}
}
}
}

View File

@ -0,0 +1,38 @@
package com.Rainnny.Reaper.Listeners;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import com.Rainnny.Reaper.StaffMode;
public class StaffOnlineListener implements Listener {
private StaffMode core;
public StaffOnlineListener(StaffMode core) {
this.core = core;
}
//Adds staff to online list on join.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if(!core.staffOnline.contains(p) && p.hasPermission("railed.staff")) {
core.staffOnline.add(p);
}
}
//Removes staff from online list on quit.
@EventHandler
public void onPlayerLeave(PlayerQuitEvent e) {
Player p = e.getPlayer();
if(p.hasPermission("railed.staff") && core.staffOnline.contains(p)) {
e.getPlayer().setGameMode(GameMode.SURVIVAL);
core.staffOnline.remove(p);
}
}
}

View File

@ -0,0 +1,352 @@
package com.Rainnny.Reaper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import com.Rainnny.Reaper.Commands.HideStaffCmd;
import com.Rainnny.Reaper.Commands.StaffModeCmd;
import com.Rainnny.Reaper.Commands.Vanish;
import com.Rainnny.Reaper.Listeners.HideVanishListener;
import com.Rainnny.Reaper.Listeners.StaffModeItems;
import com.Rainnny.Reaper.Listeners.StaffOnlineListener;
import com.Rainnny.Reaper.Utils.StaffOnlineGUI;
public class StaffMode extends JavaPlugin {
public ArrayList<Player> inStaffMode = new ArrayList<Player>();
public ArrayList<Player> staffOnline = new ArrayList<Player>();
public ArrayList<Player> inVanish = new ArrayList<Player>();
public HashMap<Player, ItemStack[]> staffInventories = new HashMap<Player, ItemStack[]>();
public HashMap<Player, GameMode> staffLastGamemodes = new HashMap<Player, GameMode>();
public ArrayList<Player> onlinePlayers = new ArrayList<Player>();
public ArrayList<Player> hiddenStaff = new ArrayList<Player>();
public ArrayList<Player> toTeleportTo = new ArrayList<Player>();
public ArrayList<Player> miningPlayers = new ArrayList<Player>();
public static String PREFIX;
public static ChatColor M;
public static ChatColor M2;
public static ChatColor O;
public static StaffMode instance;
public StaffOnlineGUI staffOnlineGUI;
public ArrayList<Player> getStaffInMode() {
return inStaffMode;
}
public ArrayList<Player> getStaffOnline() {
return staffOnline;
}
public ArrayList<Player> inVanish() {
return inVanish;
}
public HashMap<Player, ItemStack[]> getStaffInvs() {
return staffInventories;
}
public void setStaffMode(Player player, boolean inStaffMode) {
if(inStaffMode == true) {
this.getStaffInMode().add(player);
if(!isVanished(player)) {
this.setVanished(player, true);
player.sendMessage(ChatColor.GRAY.toString() + ChatColor.ITALIC + "You were automatically put into vanish since you weren't already.");
}
this.giveItems(player);
staffLastGamemodes.put(player, player.getGameMode());
player.setGameMode(GameMode.CREATIVE);
} else {
this.getStaffInMode().remove(player);
this.returnOldInv(player);
this.setVanished(player, false);
player.sendMessage(ChatColor.GRAY.toString() + ChatColor.ITALIC + "Automatically removed your vanish mode.");
if(player.isOp() && staffLastGamemodes.get(player) == GameMode.CREATIVE) {
player.setGameMode(staffLastGamemodes.get(player));
} else {
if(staffLastGamemodes.get(player) == GameMode.CREATIVE) {
player.setGameMode(GameMode.SURVIVAL);
return;
}
player.setGameMode(staffLastGamemodes.get(player));
}
}
}
public boolean isInStaffMode(Player player) {
return getStaffInMode().contains(player);
}
private List<String> compassLore() {
List<String> lore = new ArrayList<String>();
lore.add(ChatColor.translateAlternateColorCodes('&', "§4&lRIGHT CLICK &cto teleport through blocks."));
lore.add(ChatColor.translateAlternateColorCodes('&', "§4&lLEFT CLICK &cto jump through blocks."));
return lore;
}
private List<String> inspectLore() {
List<String> lore = new ArrayList<String>();
lore.add(ChatColor.translateAlternateColorCodes('&', "§4&lRIGHT CLICK &cto inspect a player's inventory."));
return lore;
}
private List<String> worldeditLore() {
List<String> lore = new ArrayList<String>();
lore.add("§4§lLEFT CLICK §cto select position 1");
lore.add("§4§lRIGHT CLICK §cto select position 2");
return lore;
}
private List<String> freezeLore() {
List<String> lore = new ArrayList<String>();
lore.add(ChatColor.translateAlternateColorCodes('&', "&4&lRIGHT CLICK &ca player to freeze them."));
return lore;
}
private List<String> randomLore() {
List<String> lore = new ArrayList<String>();
lore.add(ChatColor.translateAlternateColorCodes('&', "&4&lRIGHT CLICK &cto randomly teleport to a player!"));
return lore;
}
public List<String> vanishLore() {
List<String> lore = new ArrayList<String>();
lore.add(ChatColor.translateAlternateColorCodes('&', "&4&lRIGHT CLICK &cto toggle your vanish."));
return lore;
}
private List<String> staffOnlineLore() {
List<String> lore = new ArrayList<String>();
lore.add(ChatColor.translateAlternateColorCodes('&', "&4&lRIGHT CLICK &cto view online staff."));
return lore;
}
public void giveItems(Player player) {
ItemStack compass = new ItemStack(Material.COMPASS);
ItemMeta compassMeta = compass.getItemMeta();
compassMeta.setDisplayName(ChatColor.DARK_RED + "Teleport");
compassMeta.setLore(compassLore());
compass.setItemMeta(compassMeta);
ItemStack inspect = new ItemStack(Material.BOOK);
ItemMeta inspectMeta = compass.getItemMeta();
inspectMeta.setDisplayName(ChatColor.DARK_RED + "Inspect Tool");
inspectMeta.setLore(inspectLore());
inspect.setItemMeta(inspectMeta);
ItemStack worldedit = new ItemStack(Material.WOOD_AXE);
ItemMeta worldeditMeta = worldedit.getItemMeta();
worldeditMeta.setDisplayName("§4WorldEdit Wand");
worldeditMeta.setLore(worldeditLore());
worldedit.setItemMeta(worldeditMeta);
ItemStack freeze = new ItemStack(Material.ICE);
ItemMeta freezeMeta = freeze.getItemMeta();
freezeMeta.setDisplayName(ChatColor.DARK_RED + "Freeze Player");
freezeMeta.setLore(freezeLore());
freeze.setItemMeta(freezeMeta);
ItemStack randomtp = new ItemStack(Material.WATCH, 1);
ItemMeta randomtpMeta = randomtp.getItemMeta();
randomtpMeta.setDisplayName(ChatColor.DARK_RED + "Random Teleport");
randomtpMeta.setLore(randomLore());
randomtp.setItemMeta(randomtpMeta);
ItemStack vanish = new ItemStack(Material.INK_SACK, 1, (short)0, (byte) 8);
if(isVanished(player)) {
vanish = new ItemStack(Material.INK_SACK, 1, (short)0, (byte) 10);
}
ItemMeta vanishMeta = vanish.getItemMeta();
vanishMeta.setDisplayName(ChatColor.BLUE + "Vanish");
vanishMeta.setLore(vanishLore());
vanish.setItemMeta(vanishMeta);
ItemStack staffOnline = new ItemStack(Material.SKULL_ITEM, 1, (short)0, (byte) 3);
ItemMeta staffOnlineMeta = staffOnline.getItemMeta();
staffOnlineMeta.setDisplayName(ChatColor.BLUE + "Staff Online");
staffOnlineMeta.setLore(staffOnlineLore());
staffOnline.setItemMeta(staffOnlineMeta);
staffInventories.put(player, player.getInventory().getContents());
player.getInventory().clear();
player.getInventory().setItem(0, compass);
player.getInventory().setItem(1, inspect);
player.getInventory().setItem(2, worldedit);
player.getInventory().setItem(3, freeze);
player.getInventory().setItem(7, randomtp);
player.getInventory().setItem(8, vanish);
}
public boolean isStaff(Player player) {
return player.hasPermission("reaper.staff");
}
public void returnOldInv(Player player) {
player.getInventory().clear();
player.getInventory().setContents(getStaffInvs().get(player));
}
public void setVanished(Player player, boolean inVanish) {
if(inVanish == true) {
for(Player online : Bukkit.getOnlinePlayers()) {
online.hidePlayer(player);
}
for(Player staff : this.staffOnline) {
staff.canSee(player);
}
this.inVanish.add(player);
} else {
for(Player online : Bukkit.getOnlinePlayers()) {
online.showPlayer(player);
}
this.inVanish.remove(player);
}
}
public boolean isVanished(Player player) {
return inVanish.contains(player);
}
public void onEnable() {
//Config
//File file = new File(getDataFolder(), "config.yml");
//if(!file.exists()) {
//getConfig().addDefault("Inventory", "");
//getConfig().options().copyDefaults(true);
//saveConfig();
//}
instance = this;
//Registered Commands
this.getCommand("staffmode").setExecutor(new StaffModeCmd(this));
this.getCommand("vanish").setExecutor(new Vanish(this));
this.getCommand("hidestaff").setExecutor(new HideStaffCmd(this));
//Registering Listeners
Bukkit.getPluginManager().registerEvents(new StaffModeItems(this), this);
Bukkit.getPluginManager().registerEvents(new StaffOnlineListener(this), this);
Bukkit.getPluginManager().registerEvents(new StaffOnlineListener(this), this);
Bukkit.getPluginManager().registerEvents(new HideVanishListener(this), this);
//Online player updater
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
if(Bukkit.getOnlinePlayers().length != 0) {
for(int all = 0 ; all < onlinePlayers.size() ; all++) {
onlinePlayers.remove(all);
}
for(Player online : Bukkit.getOnlinePlayers()) {
onlinePlayers.add(online);
}
for(Player staff : staffOnline) {
onlinePlayers.remove(staff);
}
}
staffOnline.clear();
miningPlayers.clear();
for(Player online : Bukkit.getOnlinePlayers()) {
if(online.hasPermission("railed.staff")) {
staffOnline.add(online);
}
}
for(Player online : Bukkit.getOnlinePlayers()) {
if(online.getLocation().getBlockY() <= 20) {
miningPlayers.add(online);
}
}
if(!inVanish.isEmpty() && !staffOnline.isEmpty()) {
for(Player staff : staffOnline) {
for(Player vanished : inVanish) {
staff.showPlayer(vanished);
}
for(Player ops : Bukkit.getOnlinePlayers()) {
if(isVanished(ops) && ops.isOp() && !staff.isOp()) {
staff.hidePlayer(ops);
}
}
}
}
if(!hiddenStaff.isEmpty() && !staffOnline.isEmpty()) {
for(Player staff : inStaffMode) {
for(Player hidden : hiddenStaff) {
hidden.hidePlayer(staff);
}
}
}
if(Bukkit.getOnlinePlayers().length != 0) {
for(int i = 0 ; i < toTeleportTo.size() ; i++) {
toTeleportTo.remove(i);
}
for(Player online : Bukkit.getOnlinePlayers()) {
toTeleportTo.add(online);
}
}
if(!staffOnline.isEmpty()) {
for(Player staff : staffOnline) {
toTeleportTo.remove(staff);
}
}
}
}, 20L, 20L);
//Registering Utils
staffOnlineGUI = new StaffOnlineGUI(this);
}
static {
StaffMode.PREFIX = "§4Railed §8» §7";
StaffMode.M = ChatColor.DARK_RED;
StaffMode.M2 = ChatColor.RED;
StaffMode.O = ChatColor.GRAY;
}
public void onDisable() {
for(Player pp : Bukkit.getOnlinePlayers()) {
if(isInStaffMode(pp)) {
setStaffMode(pp, false);
}
}
}
}

View File

@ -0,0 +1,10 @@
package com.Rainnny.Reaper.Utils;
import org.bukkit.ChatColor;
public class ColorUtil
{
public static String color(final String message) {
return ChatColor.translateAlternateColorCodes('&', message);
}
}

View File

@ -0,0 +1,64 @@
package com.Rainnny.Reaper.Utils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.Plugin;
import com.Rainnny.Reaper.StaffMode;
public class StaffOnlineGUI implements Listener {
private Inventory rm;
private ItemStack skullHead;
private StaffMode core;
public StaffOnlineGUI(StaffMode p) {
this.core = p;
}
public void create_inventory() {
rm = Bukkit.createInventory(null, 18, "Staff Online");
if (core.staffOnline == null) {
return;
}
for(Player staff : core.staffOnline) {
for(int i = 0; i < core.staffOnline.size() ; i++) {
skullHead = addStaff(staff.getName());
rm.setItem(i, skullHead);
}
}
}
private ItemStack addStaff(String name) {
ItemStack i = new ItemStack(Material.SKULL, 1, (short) 0, (byte) 3);
SkullMeta im = (SkullMeta) i.getItemMeta();
im.setDisplayName(ChatColor.RED + name);
im.setOwner(Bukkit.getPlayer(name).getName());
i.setItemMeta(im);
return i;
}
public void open(Player player) {
create_inventory();
player.openInventory(rm);
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
if (!e.getInventory().getName().equalsIgnoreCase(rm.getName())) return;
if (e.getCurrentItem().getItemMeta() == null) return;
e.setCancelled(true);
}
}