This commit is contained in:
Brandon 2023-10-15 18:52:19 +01:00
parent a75a54d613
commit f63d748a3d
85 changed files with 3178 additions and 0 deletions

12
.classpath Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="D:/SPigot Depends/SwiftHub Depends/EzQueueSpigot.jar"/>
<classpathentry kind="lib" path="D:/SPigot Depends/SwiftHub Depends/Vault.jar"/>
<classpathentry kind="lib" path="D:/SPigot Depends/AHCF depends/WorldEdit.jar"/>
<classpathentry kind="lib" path="D:/Exem Old Dedi/hub/break.jar"/>
<classpathentry kind="lib" path="D:/SPigot Depends/AHCF depends/Lombok-1.6.6.jar"/>
<classpathentry kind="lib" path="D:/Exem Old Dedi/hub/plugins/PermissionsEx-1.22.10.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HoundPvP Hub</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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

80
bin/config.yml Normal file
View File

@ -0,0 +1,80 @@
scoreboard:
- '&7&m--------------------'
- '&5&lConnected Players:'
- '&7%online%'
- ''
- '&5&lNetwork Rank'
- '&7%rank%'
- ''
- '&7&ostore.exempvp.net'
- '&7&m--------------------'
scoreboard-inqueue:
- '&7&m--------------------'
- '&5&lConnected Players:'
- '&7%online%'
- ''
- '&5&lQueue Info:'
- ' &7%position%/%inqueue%'
- ''
- '&5&lNetwork Rank'
- '&7%rank%'
- ''
- '&7&ostore.exempvp.net'
- '&7&m--------------------'
server-selector:
oghcf:
type: GOLD_SWORD
name: '&5Practice'
server: practice
lore:
- ''
- '&cOur practice server is currently being developed'
- '&cStay Tuned'
- ''
- '&5Connected Players: &7%count%/1000'
- '&5Click here to connect'
- ''
slot: 11
newhcf:
type: DIAMOND_SWORD
name: '&5HCF (Squads)'
server: HCF
lore:
- ''
- '&7- &5MapKit: &7S1, P1'
- '&7- &5Border: &7Quite big I think'
- '&7- &5Faction Size: &75-Man'
- '&7- &5Faction Allies: &70'
- ''
- '&7- &7Events will take place daily'
- ''
- '&5Connected Players: &7%count%/1000'
- '&5Click here to connect'
- ''
slot: 13
kitmap:
type: FISHING_ROD
name: '&5Kits'
lore:
- ''
- '&7- &5MapKit: &7S1, P1'
- '&7- &5Border: &7Quite big I think'
- '&7- &5Faction Size: &75-Man'
- '&7- &5Faction Allies: &70'
- ''
- '&7- &7Events will take place daily'
- ''
- '&5Connected Players: &7%count%/1000'
- '&7Click here to connect'
- ''
slot: 15
server: kitmap
selector-name: '&7Select a server'
chat-format: '%prefix% %player%&7: %message%'
spawn:
x: -1625.0
y: 198.0
z: 1665.0
yaw: 0.0
pitch: 0.0
world: world

22
bin/plugin.yml Normal file
View File

@ -0,0 +1,22 @@
name: Hub
version: 1.0
main: com.houndpvp.hub.Hub
commands:
builder:
setspawn:
rawcast:
gamemode:
gmc:
sounds:
aliases: [togglesounds, toggles]
gms:
gma:
msg:
aliases: [tell, message, t, w, wisper]
reply:
aliases: [r]
togglepm:
sounds:
invselector:
tp:
clear:

72
config.yml Normal file
View File

@ -0,0 +1,72 @@
scoreboard:
- '&7&m--------------------'
- '&3&lOnline'
- '&7%online%'
- ''
- '&3&lRank'
- '&7%rank%'
- ''
- '&7&ostore.exempvp.net'
- '&7&m--------------------'
scoreboard-inqueue:
- '&7&m--------------------'
- '&3&lOnline'
- '&7%online%'
- ''
- '&3&lQueue'
- ' &7%position%/%inqueue%'
- ''
- '&3&lRank'
- '&7%rank%'
- ''
- '&7&ostore.exempvp.net'
- '&7&m--------------------'
server-selector:
oghcf:
type: GOLD_SWORD
name: '&9Legacy HCF'
server: practice
lore:
- '&3Players: %count%/1000'
- ''
- '&8* &75 man factions, 0 allies'
- '&8* &7MineHQ Style HCF'
- '&8* &7Weekly events and games'
- ''
- '&3Click here to connect'
slot: 11
newhcf:
type: DIAMOND_SWORD
name: '&9Regular HCF'
server: HCF
lore:
- '&3Players: %count%/1000'
- ''
- '&8* &75 man factions, 0 allies'
- '&8* &7MineHQ Style HCF'
- '&8* &7Weekly events and games'
- ''
- '&3Click here to connect'
slot: 13
kitmap:
type: DIAMOND_PICKAXE
name: '&9Kitmap'
lore:
- '&3Players: %count%/1000'
- ''
- '&8* &75 man factions, 0 allies'
- '&8* &7MineHQ Style HCF'
- '&8* &7Weekly events and games'
- ''
- '&3Click here to connect'
slot: 15
server: kitmap
selector-name: '&7Select a server'
chat-format: "%prefix% %player%&7: %message%"
spawn:
x: -1625.0
y: 198.0
z: 1665.0
yaw: 0.0
pitch: 0.0
world: 'world'

BIN
out/HoundHub.jar Normal file

Binary file not shown.

22
plugin.yml Normal file
View File

@ -0,0 +1,22 @@
name: Hub
version: 1.0
main: com.houndpvp.hub.Hub
commands:
builder:
setspawn:
rawcast:
gamemode:
gmc:
sounds:
aliases: [togglesounds, toggles]
gms:
gma:
msg:
aliases: [tell, message, t, w, wisper]
reply:
aliases: [r]
togglepm:
sounds:
invselector:
tp:
clear:

View File

@ -0,0 +1,107 @@
package com.houndpvp.hub;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import com.houndpvp.hub.commands.BuilderCommand;
import com.houndpvp.hub.commands.ClearCommand;
import com.houndpvp.hub.commands.GamemodeCommand;
import com.houndpvp.hub.commands.InvSelectorCommand;
import com.houndpvp.hub.commands.MsgCommand;
import com.houndpvp.hub.commands.RawcastCommand;
import com.houndpvp.hub.commands.ReplyCommand;
import com.houndpvp.hub.commands.SetSpawnCommand;
import com.houndpvp.hub.commands.SoundsCommand;
import com.houndpvp.hub.commands.TeleportCommand;
import com.houndpvp.hub.listeners.DoubleJumpListener;
import com.houndpvp.hub.listeners.Listeners;
import com.houndpvp.hub.scoreboard.ScoreboardProvider;
import com.houndpvp.hub.scoreboard.providers.ScoreboardManager;
import com.houndpvp.hub.tablist.Azazel;
import com.houndpvp.hub.tablist.tab.Provider.TabProvider;
import com.houndpvp.hub.utils.Bungee;
import com.houndpvp.hub.utils.SpawnUtils;
import lombok.Getter;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
public class Hub extends JavaPlugin {
@Getter
static Hub instance;
@Getter
Permission perms = null;
@Getter
Chat chat = null;
@Getter
Bungee bungee;
private SpawnUtils spawn;
@Override
public void onEnable() {
Bukkit.getLogger().warning("----------------------------");
Bukkit.getLogger().warning("This hub core has been made");
Bukkit.getLogger().warning("for the ExemPvP Network by");
Bukkit.getLogger().warning("the development team!");
Bukkit.getLogger().warning("----------------------------");
(spawn = new SpawnUtils(this)).load();
instance = this;
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
bungee = new Bungee(this);
Bukkit.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", bungee);
setupPermissions();
setupChat();
getConfig().options().copyDefaults(true);
saveConfig();
new Azazel(this, new TabProvider());
new ScoreboardManager(this, new ScoreboardProvider(this), "§5§lExemPVP §7| §7Hub-1");
Bukkit.getPluginManager().registerEvents(new Listeners(), this);
Bukkit.getPluginManager().registerEvents(new DoubleJumpListener(), this);
getCommand("builder").setExecutor(new BuilderCommand());
getCommand("setspawn").setExecutor(new SetSpawnCommand(this));
getCommand("rawcast").setExecutor(new RawcastCommand());
getCommand("msg").setExecutor(new MsgCommand());
getCommand("reply").setExecutor(new ReplyCommand());
getCommand("sounds").setExecutor(new SoundsCommand());
getCommand("gamemode").setExecutor(new GamemodeCommand());
getCommand("invselector").setExecutor(new InvSelectorCommand());
getCommand("tp").setExecutor(new TeleportCommand());
getCommand("clear").setExecutor(new ClearCommand());
}
@Override
public void onDisable() {
for (Player pp : Bukkit.getOnlinePlayers()) {
pp.kickPlayer("§5ExemPvP §7| Our Hub is Restarting");
}
}
public SpawnUtils getSpawn() {
return this.spawn;
}
public void setSpawn(SpawnUtils spawn) {
this.spawn = spawn;
}
private boolean setupPermissions() { RegisteredServiceProvider<Permission>
rsp = getServer().getServicesManager().getRegistration(Permission.class);
perms = rsp.getProvider(); return perms != null; }
private boolean setupChat() { RegisteredServiceProvider<Chat> rsp =
getServer().getServicesManager().getRegistration(Chat.class); chat =
rsp.getProvider(); return chat != null; }
}

View File

@ -0,0 +1,47 @@
package com.houndpvp.hub.commands;
import java.util.ArrayList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import lombok.Getter;
public class BuilderCommand implements CommandExecutor {
@Getter public static ArrayList<Player> builders = new ArrayList<Player>();
@Override
public boolean onCommand(CommandSender sender, Command cmd, String c, String[] args) {
if(!(sender instanceof Player)) {
sender.sendMessage("§cYou must be a player to use this command.");
return true;
}
Player p = (Player) sender;
if(!p.hasPermission("houndpvp.builder")) {
p.sendMessage("§cYou do not have permission for this command.");
return true;
}
if(builders.contains(p)) {
builders.remove(p);
p.sendMessage("§cYou have disabled builder mode.");
return true;
} else if(!builders.contains(p)) {
builders.add(p);
p.sendMessage("§aYou have enabled builder mode.");
return true;
}
return true;
}
}

View File

@ -0,0 +1,19 @@
package com.houndpvp.hub.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
public class ClearCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player) sender;
p.getInventory().clear();
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aYour inventory has been cleared!"));
return true;
}
}

View File

@ -0,0 +1,125 @@
package com.houndpvp.hub.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
public class GamemodeCommand implements CommandExecutor, TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String c, String[] args) {
if(!(sender instanceof Player)) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou must be a player to use this command."));
return true;
}
Player p = (Player) sender;
if (p.hasPermission("hub.command.gamemode")) {
if(c.equalsIgnoreCase("gmc")) {
p.setGameMode(GameMode.CREATIVE);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&eYour gamemode has been set to &9%gamemode%")
.replace("%gamemode%", p.getGameMode().toString()));
return true;
}
if(c.equalsIgnoreCase("gms")) {
p.setGameMode(GameMode.SURVIVAL);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&eYour gamemode has been set to &9%gamemode%")
.replace("%gamemode%", p.getGameMode().toString()));
return true;
}
if(c.equalsIgnoreCase("gma")) {
p.setGameMode(GameMode.ADVENTURE);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&eYour gamemode has been set to &9%gamemode%")
.replace("%gamemode%", p.getGameMode().toString()));
return true;
}
if(c.equalsIgnoreCase("gmc")) {
p.setGameMode(GameMode.CREATIVE);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&eYour gamemode has been set to &9%gamemode%")
.replace("%gamemode%", p.getGameMode().toString()));
return true;
}
if(c.equalsIgnoreCase("gamemode")) {
if(args.length == 0) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cUsage: /" + c + " <gamemode> <player>"));
return true;
}
if(args.length == 1) {
if(matchGameMode(args[0]) == null) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c" + args[0] + " is not a valid gamemode."));
} else {
p.setGameMode(matchGameMode(args[0]));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&eYour gamemode has been set to &9%gamemode%")
.replace("%gamemode%", p.getGameMode().toString()));
}
return true;
}
if(args.length == 2) {
if(matchGameMode(args[0]) == null) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c" + args[0] + " is not a valid gamemode."));
return true;
}
Player target = Bukkit.getPlayer(args[1]);
if(target != null && !target.isOnline()) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c" + args[1] + " is not online."));
return true;
}
target.setGameMode(matchGameMode(args[0]));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9%player%s &egamemode has been set to &9%gamemode%")
.replace("%player%", target.getName())
.replace("%gamemode%", p.getGameMode().toString()));
}
}
}
else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cNo permission"));
}
return true;
}
private GameMode matchGameMode(String modeString) {
GameMode mode = null;
if(modeString.substring(0, 1).equals("s") || modeString.contains("" + 0)) {
mode = GameMode.SURVIVAL;
} else if(modeString.substring(0, 1).equals("c") || modeString.contains("" + 1)) {
mode = GameMode.CREATIVE;
} else if(modeString.substring(0, 1).equals("a") || modeString.contains("" + 2)) {
mode = GameMode.ADVENTURE;
}
return mode;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String c, String[] args) {
if(args.length == 1) {
GameMode mode = matchGameMode(args[0]);
if(mode != null) {
return Arrays.asList(mode.toString().toLowerCase());
}
}
return Arrays.asList("creative", "survival", "adventure");
}
}

View File

@ -0,0 +1,26 @@
package com.houndpvp.hub.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.houndpvp.hub.inventory.SelectorInventory;
public class InvSelectorCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String c, String[] args) {
if(!(sender instanceof Player)) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou must be a player to use this command."));
return true;
}
Player p = (Player) sender;
SelectorInventory.openInventory(p);
return true;
}
}

View File

@ -0,0 +1,93 @@
package com.houndpvp.hub.commands;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
import ru.tehkode.permissions.bukkit.PermissionsEx;
public class MsgCommand implements CommandExecutor {
public static HashMap<UUID, String> lastplayer;
public static HashMap<UUID, Boolean> sounds;
public static HashMap<UUID, Boolean> toggle;
public MsgCommand() {
lastplayer = new HashMap<UUID, String>();
sounds = new HashMap<UUID, Boolean>();
toggle = new HashMap<UUID, Boolean>();
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String c, String[] args) {
Player p = (Player) sender;
StringBuilder str = new StringBuilder();
if(c.equalsIgnoreCase("msg")
|| c.equalsIgnoreCase("m")
|| c.equalsIgnoreCase("message")
|| c.equalsIgnoreCase("tell")
|| c.equalsIgnoreCase("w")) {
if(args.length == 0) {
p.sendMessage("§cUsage: /" + c + " <player> <message>");
} else if(args.length == 1) {
p.sendMessage("§cUsage: /" + c + " <player> <message>");
} else if(args.length >= 2) {
for (int i = 1; i < args.length; i++) {
str.append(args[i] + " ");
}
String message = str.toString();
Player target = Bukkit.getPlayer(args[0]);
if(target != null) {
if(target.isOnline()) {
if (!toggle.containsKey(p.getUniqueId())) {
toggle.put(p.getUniqueId(), true);
}
if (!toggle.containsKey(target.getUniqueId())) {
toggle.put(target.getUniqueId(), true);
}
if(toggle.get(p.getUniqueId())) {
if(toggle.get(target.getUniqueId())) {
target.sendMessage(ChatColor.translateAlternateColorCodes('&',
"&7(From &f%player%&7) %msg%".
replace("%player%", PermissionsEx.getUser(p).getSuffix() + p.getName()).
replace("%msg%", message)));
p.sendMessage(ChatColor.translateAlternateColorCodes('&',
"&7(To &f%player%&7) %msg%".
replace("%player%", PermissionsEx.getUser(target).getSuffix() + target.getName())).
replace("%msg%", message));
lastplayer.put(p.getUniqueId(), target.getName());
lastplayer.put(target.getUniqueId(), p.getName());
if (!sounds.containsKey(target.getUniqueId())) {
sounds.put(target.getUniqueId(), true);
}
if(sounds.get(target.getUniqueId())) {
target.playSound(target.getLocation(), Sound.SUCCESSFUL_HIT, 10, 1);
}
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "§c" + target.getName() + " has private messages off."));
}
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "§cYou can't message someone with your PMs toggled"));
}
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "§cThat player is not online"));
}
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "§cThat player is not online"));
}
}
}
return true;
}
}

View File

@ -0,0 +1,48 @@
package com.houndpvp.hub.commands;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class RawcastCommand
implements CommandExecutor
{
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length < 1)
{
sender.sendMessage(ChatColor.RED + "Usage: " + "/rawcast");
return true;
}
String arg;
String requiredNode;
int position = 0;
if ((args.length > 2) && ((arg = args[0]).startsWith("-p")))
{
int position1 = 1;
requiredNode = arg.substring(2, arg.length());
}
else
{
position = 0;
requiredNode = null;
}
String message = StringUtils.join(args, ' ', position, args.length);
if (message.length() < 3)
{
sender.sendMessage(ChatColor.RED + "Broadcasts must be at least 3 characters.");
return true;
}
message = ChatColor.translateAlternateColorCodes('&', message);
if (requiredNode != null) {
Bukkit.broadcast(message, requiredNode);
} else {
Bukkit.broadcastMessage(message);
}
return true;
}
}

View File

@ -0,0 +1,47 @@
package com.houndpvp.hub.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
import ru.tehkode.permissions.bukkit.PermissionsEx;
public class ReplyCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String c, String[] args) {
Player p = (Player) sender;
if(c.equalsIgnoreCase("r") || c.equalsIgnoreCase("reply")) {
if(args.length == 0) {
p.sendMessage("§cUsage: /" + c + " <Message..>");
} else if (args.length >= 1) {
String message = "";
for (int i = 0; i < args.length; i++) {
if (message != "") message += " ";
String part = args[i];
message += part;
}
if(MsgCommand.lastplayer.get(p.getUniqueId()) != null) {
Player target = Bukkit.getPlayer(MsgCommand.lastplayer.get(p.getUniqueId()));
if(target != null) {
if(target.isOnline()) {
target.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7(From &f%player%&7) %msg%".replace("%player%", PermissionsEx.getUser(p).getSuffix() + p.getName()).replace("%msg%", message)));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7(To &f%player%&7) %msg%".replace("%player%", PermissionsEx.getUser(target).getSuffix() + target.getName()).replace("%msg%", message)));
} else {
p.sendMessage("§cThat player is not online.");
}
} else {
p.sendMessage("§cThat player is not online.");
}
} else {
p.sendMessage("§cYou have not messaged anyone.");
}
}
}
return true;
}
}

View File

@ -0,0 +1,27 @@
package com.houndpvp.hub.commands;
import com.houndpvp.hub.*;
import org.bukkit.Location;
import org.bukkit.command.*;
import org.bukkit.entity.*;
public class SetSpawnCommand implements CommandExecutor {
private Hub hub;
public SetSpawnCommand(Hub Hub) {
this.hub = Hub;
}
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (commandSender instanceof Player && commandSender.hasPermission("command.setspawn")) {
Player player = (Player)commandSender;
player.sendMessage(("§aYou have set the spawn location."));
hub.getSpawn().setSpawn(player.getLocation());
hub.getSpawn().save();
return true;
}
return false;
}
}

View File

@ -0,0 +1,31 @@
package com.houndpvp.hub.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SoundsCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String c, String[] args) {
Player p = (Player) sender;
if(c.equalsIgnoreCase("sounds")) {
if (!MsgCommand.sounds.containsKey(p.getUniqueId())) {
MsgCommand.sounds.put(p.getUniqueId(), true);
}
if(MsgCommand.sounds.get(p.getUniqueId()).equals(true)) {
MsgCommand.sounds.remove(p.getUniqueId());
MsgCommand.sounds.put(p.getUniqueId(), false);
p.sendMessage("§cYou will no longer hear message sounds.");
} else {
MsgCommand.sounds.remove(p.getUniqueId());
MsgCommand.sounds.put(p.getUniqueId(), true);
p.sendMessage("§aYou will now hear message sounds.");
}
}
return true;
}
}

View File

@ -0,0 +1,71 @@
package com.houndpvp.hub.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
public class TeleportCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender s, Command c, String lbl, String[] args) {
Player p = (Player) s;
if (args.length == 2) {
if (args[0].equalsIgnoreCase("here")) {
if (p.hasPermission("hub.tphere")) {
Player t = Bukkit.getPlayer(args[1]);
if (t == null) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cThe player " + args[1] + " could not be found."));
} else {
t.teleport(p);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&eTeleported &9" + t.getName() + "&e to your location."));
}
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', " &cno permission."));
}
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cinvalid arguments."));
}
} else if (args.length == 1) {
if (args[0].equalsIgnoreCase("all")) {
if (p.hasPermission("hcessentials.tpall")) {
if (!(Bukkit.getOnlinePlayers().length == 1)) {
for (Player allPlayers : Bukkit.getOnlinePlayers()) {
allPlayers.teleport(p);
}
Integer playerCount = Bukkit.getOnlinePlayers().length-1;
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&eTeleported &9" + playerCount + "&e players to your location."));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cThere are not enough players to do /tp all"));
}
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cno permission."));
}
} else {
Player t = Bukkit.getPlayer(args[0]);
if (t == null) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cThe player " + args[0] + " could not be found."));
} else {
p.teleport(t);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&3Teleported to player &9" + t.getName()));
}
}
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&m----------------------------------------"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', " &9Teleport Help"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', " &3* &7/tp [player] &f- &eteleports you the the player."));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', " &3* &7/tp all &f- &eteleports everyone to you."));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', " &3* &7/tp here [player] &f- &eteleports player to you."));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&m----------------------------------------"));
}
return true;
}
}

View File

@ -0,0 +1,32 @@
package com.houndpvp.hub.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
public class TogglePMCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String c, String[] args) {
Player p = (Player) sender;
if (c.equalsIgnoreCase("togglepm")) {
if (!MsgCommand.toggle.containsKey(p.getUniqueId())) {
MsgCommand.toggle.put(p.getUniqueId(), true);
}
if (MsgCommand.toggle.get(p.getUniqueId()) == true) {
MsgCommand.toggle.put(p.getUniqueId(), false);
p.sendMessage(ChatColor.translateAlternateColorCodes('&',
"&7You have toggled your messages &coff"));
} else {
MsgCommand.toggle.put(p.getUniqueId(), true);
p.sendMessage(ChatColor.translateAlternateColorCodes('&',
"&7You have toggled your messages &aon"));
}
}
return true;
}
}

View File

@ -0,0 +1,50 @@
package com.houndpvp.hub.inventory;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.houndpvp.hub.Hub;
import com.houndpvp.hub.listeners.Listeners;
import com.houndpvp.hub.utils.Bungee;
import com.houndpvp.hub.utils.ItemBuilder;
import com.houndpvp.hub.utils.SpigotUtils;
import net.md_5.bungee.api.ChatColor;
public class SelectorInventory {
public static void openInventory(Player p) {
Inventory inv = Bukkit.createInventory(null, 27);
for(int x = 0; x < 27; x ++) {
inv.setItem(x, new ItemBuilder(Material.STAINED_GLASS_PANE).setName(" §7")
.setDurability((short) 15)
.toItemStack());
}
ConfigurationSection cs = Hub.getInstance().getConfig().getConfigurationSection("server-selector");
for(String s : cs.getKeys(false)) {
ItemStack item = new ItemBuilder(Material.valueOf(cs.getString(s + ".type")))
.setName(ChatColor.translateAlternateColorCodes('&', cs.getString(s + ".name")))
.setLore(SpigotUtils.replaceArray(SpigotUtils.colorArray(cs.getStringList(s + ".lore")), "%count%", Bungee.getCount(cs.getString(s + ".server")) + ""))
.addEnchant(Enchantment.DURABILITY, 1)
.toItemStack();
inv.setItem(cs.getInt(s + ".slot"), item);
}
p.openInventory(inv);
}
}

View File

@ -0,0 +1,66 @@
package com.houndpvp.hub.listeners;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.plugin.Plugin;
import com.houndpvp.hub.Hub;
public class DoubleJumpListener implements Listener {
@EventHandler
public void onPlayerToggleFlight(final PlayerToggleFlightEvent event) {
final Player player = event.getPlayer();
final Sound sound = Sound.BLAZE_HIT;
final Effect effect = Effect.EXPLOSION;
if (player.getGameMode() == GameMode.CREATIVE) {
return;
}
event.setCancelled(true);
player.setAllowFlight(false);
player.setFlying(false);
player.setVelocity(player.getLocation().getDirection().multiply(1.5).setY(1));
player.playSound(player.getLocation(), sound, 1.0f, 0.0f);
player.playEffect(player.getLocation(), effect, (Object)null);
}
@EventHandler
public void onPlayerMove(final PlayerMoveEvent event) {
final Player player = event.getPlayer();
if (player.getGameMode() != GameMode.CREATIVE && player.getLocation().subtract(0.0, 1.0, 0.0).getBlock().getType() != Material.AIR && !player.isFlying()) {
player.setAllowFlight(true);
}
}
@EventHandler
public void onFallDamage(final EntityDamageEvent e) {
if (e.getEntity() instanceof Player && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
e.setCancelled(true);
}
}
@EventHandler
public void move(final PlayerMoveEvent e) {
final Player f = e.getPlayer();
if (e.getTo().getY() < 2.0) {
Hub.getInstance().getServer().getScheduler().scheduleSyncDelayedTask((Plugin)Hub.getInstance(), (Runnable)new Runnable() {
@Override
public void run() {
final double y = f.getLocation().getY() - 2.0;
final Location l = new Location(f.getLocation().getWorld(), f.getLocation().getX(), y, f.getLocation().getZ(), f.getLocation().getYaw(), f.getLocation().getPitch());
f.getWorld().playEffect(l, Effect.ENDER_SIGNAL, 50, 30);
}
}, 10L);
}
}
}

View File

@ -0,0 +1,275 @@
package com.houndpvp.hub.listeners;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
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.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemDamageEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import com.houndpvp.hub.Hub;
import com.houndpvp.hub.commands.BuilderCommand;
import com.houndpvp.hub.inventory.SelectorInventory;
import com.houndpvp.hub.utils.Bungee;
import com.houndpvp.hub.utils.ItemBuilder;
import com.houndpvp.hub.utils.SpigotUtils;
import lombok.Getter;
import me.signatured.ezqueuespigot.EzQueueAPI;
import net.md_5.bungee.api.ChatColor;
public class Listeners implements Listener {
@EventHandler
public void inventoryClick(InventoryClickEvent e) {
if(BuilderCommand.getBuilders().contains(e.getWhoClicked())) {
return;
}
e.setCancelled(true);
}
@EventHandler
public void onMove(PlayerMoveEvent e) {
Player player = e.getPlayer();
player.setFoodLevel(20);
player.setSaturation(20.0f);
}
@EventHandler
public void inventoryDrag(InventoryDragEvent e) {
if(BuilderCommand.getBuilders().contains(e.getWhoClicked())) {
return;
}
e.setCancelled(true);
}
@EventHandler
public void onDrop(PlayerDropItemEvent e) {
e.setCancelled(true);
}
@EventHandler
public void onDamage(PlayerItemDamageEvent e) {
e.setCancelled(true);
}
@EventHandler public void onChat(AsyncPlayerChatEvent e) { Player p =
e.getPlayer(); String group =
Hub.getInstance().getPerms().getPrimaryGroup(p); String prefix =
Hub.getInstance().getChat().getGroupPrefix(p.getWorld(), group);
e.setFormat(ChatColor.translateAlternateColorCodes('&',
Hub.getInstance().getConfig().getString("chat-format") .replace("%prefix%",
prefix) .replace("%player%", p.getName()) .replace("%message%",
ChatColor.stripColor(e.getMessage()))));
}
@EventHandler
public void onBreak(BlockBreakEvent e) {
if(BuilderCommand.getBuilders().contains(e.getPlayer())) {
return;
}
e.setCancelled(true);
}
@EventHandler
public void onPlace(BlockPlaceEvent e) {
if(BuilderCommand.getBuilders().contains(e.getPlayer())) {
return;
}
e.setCancelled(true);
}
@EventHandler
public void onClick(PlayerInteractEvent e) {
Player player = e.getPlayer();
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(e.getItem() != null && e.getItem().isSimilar(selector)) {
SelectorInventory.openInventory(e.getPlayer());
} else if(e.getItem() != null && e.getItem().isSimilar(enderbutt)) {
e.setCancelled(true);
Item item = player.getWorld().dropItem(player.getLocation().add(0.0D, 0.5D, 0.0D), new ItemStack(Material.ENDER_PEARL, 16));
item.setPickupDelay(10000);
item.setVelocity(player.getLocation().getDirection().normalize().multiply(1.5F));
item.setPassenger(player);
player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1.0F, 1.0F);
this.setupEnderpearlRunnable(item);
player.updateInventory();
}
}
}
@EventHandler
public void onPearl(ProjectileLaunchEvent e) {
Entity projectile = (Entity) e.getEntity();
if(e.getEntityType() == EntityType.ENDER_PEARL) {
Player p = (Player) e.getEntity().getShooter();
projectile.setPassenger(p);
}
}
@EventHandler
public void mobSpawn(CreatureSpawnEvent e) {
e.setCancelled(true);
}
@EventHandler
public void damageEvent(EntityDamageEvent e) {
Entity entity = e.getEntity();
if(entity instanceof Player) {
e.setCancelled(true);
}
}
@EventHandler
public void invClick(InventoryClickEvent e) {
ConfigurationSection cs = Hub.getInstance().getConfig().getConfigurationSection("server-selector");
if(e.getCurrentItem() == null) {
return;
}
for(String s : cs.getKeys(false)) {
ItemStack item = new ItemBuilder(Material.valueOf(cs.getString(s + ".type")))
.setName(ChatColor.translateAlternateColorCodes('&', cs.getString(s + ".name")))
.setLore(SpigotUtils.replaceArray(SpigotUtils.colorArray(cs.getStringList(s + ".lore")), "%count%", Bungee.getCount(cs.getString(s + ".server")) + ""))
.addEnchant(Enchantment.DURABILITY, 1)
.toItemStack();
if(e.getCurrentItem().isSimilar(item)) {
EzQueueAPI.addToQueue((Player) e.getWhoClicked(), s);
}
}
}
@Getter static ItemStack selector = new ItemBuilder(Material.BOOK)
.setName("§5Server Selector §7(Right Click)")
.toItemStack();
@Getter static ItemStack enderbutt = new ItemBuilder(Material.ENDER_PEARL)
.setName("§5Enderpearl §7(Right Click)")
.toItemStack();
@EventHandler
public void onWeatherChange(WeatherChangeEvent e) {
e.setCancelled(true);
}
@EventHandler
public void FoodLevelChange(FoodLevelChangeEvent e) {
Player player = (Player) e.getEntity();
player.setFoodLevel(20);
player.setSaturation(20.0f);
player.setHealth(20.0);
player.setSaturation(10.0f);
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
e.setJoinMessage(null);
p.getInventory().clear();
p.getInventory().setItem(4, selector);
p.getInventory().setItem(0, enderbutt);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&m---------------------------------"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7Welcome &5" + p.getName() + " &7to the &5ExemPvP Network"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', ""));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&5* &7Website: &fexempvp.net"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&5* &7Store: &fstore.exempvp.net"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&5* &7Discord: &fexempvp.net/discord"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&5* &7Teamspeak: &fts.exempvp.net"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&m---------------------------------"));
p.teleport(Hub.getInstance().getSpawn().getSpawn());
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 3));
p.setGameMode(GameMode.ADVENTURE);
p.setHealth(20);
p.setFoodLevel(20);
}
@EventHandler
public void onJoin(PlayerQuitEvent e) {
Player p = e.getPlayer();
e.setQuitMessage(null);
}
public void setupEnderpearlRunnable(final Item item) {
(new BukkitRunnable() {
public void run() {
if (item.isDead()) {
this.cancel();
}
if (item.getVelocity().getX() == 0.0D || item.getVelocity().getY() == 0.0D || item.getVelocity().getZ() == 0.0D) {
Player player = (Player)item.getPassenger();
item.remove();
if (player != null) {
player.teleport(player.getLocation().add(0.0D, 0.5D, 0.0D));
}
this.cancel();
}
}
}).runTaskTimer(Hub.getInstance(), 2L, 1L);
}
}

View File

@ -0,0 +1,57 @@
package com.houndpvp.hub.scoreboard;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import com.houndpvp.hub.Hub;
import com.houndpvp.hub.scoreboard.providers.ScoreboardEntryProvider;
import com.houndpvp.hub.utils.Bungee;
import me.signatured.ezqueuespigot.EzQueueAPI;
import net.minecraft.util.org.apache.commons.lang3.text.WordUtils;
import ru.tehkode.permissions.bukkit.PermissionsEx;
public class ScoreboardProvider implements ScoreboardEntryProvider
{
private Hub plugin;
private List<String> template = new ArrayList<>();
public static String lastline;
public ScoreboardProvider(final Hub plugin) {
this.plugin = plugin;
}
@Override
public List<String> getScoreboardEntries(final Player player) {
List<String> lines = new ArrayList<String>();
if(EzQueueAPI.getQueue(player.getName()) == null) {
for(String s : Hub.getInstance().getConfig().getStringList("scoreboard")) {
lines.add(ChatColor.translateAlternateColorCodes('&', s
.replace("%online%", Bungee.getCount("ALL") + "")
.replace("%rank%", Hub.getInstance().getChat().getGroupSuffix(player.getWorld(), Hub.getInstance().getPerms().getPrimaryGroup(player)) + WordUtils.capitalize(Hub.getInstance().getPerms().getPrimaryGroup(player))))
.replace("%user%", player.getName()));
}
} else {
for(String s : Hub.getInstance().getConfig().getStringList("scoreboard-inqueue")) {
lines.add(ChatColor.translateAlternateColorCodes('&', s
.replace("%position%", EzQueueAPI.getPosition(player) + "")
.replace("%inqueue%", EzQueueAPI.getPlayersInQueue(EzQueueAPI.getQueue(player)).size() + "")
.replace("%online%", Bungee.getCount("ALL") + "")
.replace("%rank%", Hub.getInstance().getChat().getGroupSuffix(player.getWorld(), Hub.getInstance().getPerms().getPrimaryGroup(player)) + WordUtils.capitalize(Hub.getInstance().getPerms().getPrimaryGroup(player))))
.replace("%user%", player.getName()));
}
}
return lines;
}
}

View File

@ -0,0 +1,112 @@
package com.houndpvp.hub.scoreboard.providers;
import org.bukkit.entity.*;
import com.houndpvp.hub.scoreboard.providers.reflection.ReflectionConstants;
import org.bukkit.craftbukkit.v1_7_R4.entity.*;
import net.minecraft.server.v1_7_R4.*;
import org.apache.commons.lang.*;
import java.util.*;
import org.bukkit.*;
public class PlayerScoreboard
{
public static final String[] TEAM_NAMES;
private final Player player;
private final PlayerConnection connection;
private final String objectiveName;
private int lastSent;
private boolean valid;
@SuppressWarnings("unchecked")
public PlayerScoreboard(final Player player) {
lastSent = 0;
valid = true;
this.player = player;
connection = ((CraftPlayer)player).getHandle().playerConnection;
objectiveName = "Sidebar-" + RandomStringUtils.random(8, "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789$_?*+-/()[]{}%!=&@<>~");
final PacketPlayOutScoreboardObjective objective = new PacketPlayOutScoreboardObjective();
ReflectionConstants.SCOREBOARD_OBJECTIVE_NAME.set(objective, objectiveName);
ReflectionConstants.SCOREBOARD_OBJECTIVE_TITLE.set(objective, ScoreboardManager.instance.getTitle());
ReflectionConstants.SCOREBOARD_OBJECTIVE_ACTION.set(objective, 0);
this.connection.sendPacket((Packet)objective);
final PacketPlayOutScoreboardDisplayObjective displayObjective = new PacketPlayOutScoreboardDisplayObjective();
ReflectionConstants.SCOREBOARD_DISPLAY_OBJECTIVE_NAME.set(displayObjective, this.objectiveName);
ReflectionConstants.SCOREBOARD_DISPLAY_OBJECTIVE_POSITION.set(displayObjective, 1);
connection.sendPacket((Packet)displayObjective);
for (int i = 0; i < 15; ++i) {
final PacketPlayOutScoreboardTeam team = new PacketPlayOutScoreboardTeam();
ReflectionConstants.SCOREBOARD_TEAM_NAME.set(team, PlayerScoreboard.TEAM_NAMES[i]);
ReflectionConstants.SCOREBOARD_TEAM_PLAYERS.get(team).add(PlayerScoreboard.TEAM_NAMES[i]);
this.connection.sendPacket((Packet)team);
}
}
public void send() {
if (!this.valid) {
return;
}
final List<String> lines = ScoreboardManager.instance.getProvider().getScoreboardEntries(this.player);
if (this.lastSent != lines.size()) {
for (int i = 0; i < 15; ++i) {
final PacketPlayOutScoreboardScore score = new PacketPlayOutScoreboardScore();
ReflectionConstants.SCOREBOARD_SCORE_NAME.set(score, PlayerScoreboard.TEAM_NAMES[i]);
ReflectionConstants.SCOREBOARD_SCORE_OBJECTIVE.set(score, this.objectiveName);
ReflectionConstants.SCOREBOARD_SCORE_ACTION.set(score, 1);
this.connection.sendPacket((Packet)score);
}
}
for (int i = 0; i < Math.min(lines.size(), 15); ++i) {
final String line = lines.get(i);
String right = "";
String left;
if (line.length() < 17) {
left = line;
}
else {
left = line.substring(0, 16);
right = line.substring(16, line.length());
if (left.endsWith("§")) {
left = left.substring(0, left.length() - 1);
right = "§" + right;
}
final String lastColors = ChatColor.getLastColors(left);
right = lastColors + right;
}
final PacketPlayOutScoreboardTeam team = new PacketPlayOutScoreboardTeam();
ReflectionConstants.SCOREBOARD_TEAM_NAME.set(team, PlayerScoreboard.TEAM_NAMES[i]);
ReflectionConstants.SCOREBOARD_TEAM_PREFIX.set(team, left);
ReflectionConstants.SCOREBOARD_TEAM_SUFFIX.set(team, StringUtils.left(right, 16));
ReflectionConstants.SCOREBOARD_TEAM_ACTION.set(team, 2);
this.connection.sendPacket((Packet)team);
final PacketPlayOutScoreboardScore score2 = new PacketPlayOutScoreboardScore();
ReflectionConstants.SCOREBOARD_SCORE_NAME.set(score2, PlayerScoreboard.TEAM_NAMES[i]);
ReflectionConstants.SCOREBOARD_SCORE_SCORE.set(score2, 15 - i);
ReflectionConstants.SCOREBOARD_SCORE_OBJECTIVE.set(score2, this.objectiveName);
this.connection.sendPacket((Packet)score2);
}
this.lastSent = lines.size();
}
public void clean() {
for (int i = 0; i < 15; ++i) {
final PacketPlayOutScoreboardTeam team = new PacketPlayOutScoreboardTeam();
ReflectionConstants.SCOREBOARD_TEAM_NAME.set(team, PlayerScoreboard.TEAM_NAMES[i]);
ReflectionConstants.SCOREBOARD_TEAM_ACTION.set(team, 4);
this.connection.sendPacket((Packet)team);
}
this.player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
this.valid = false;
}
static {
TEAM_NAMES = new String[15];
final ChatColor[] colors = ChatColor.values();
for (int i = 0; i < 15; ++i) {
final ChatColor left = colors[i];
final ChatColor right = colors[15 - i];
PlayerScoreboard.TEAM_NAMES[i] = left.toString() + ChatColor.RESET + right.toString() + ChatColor.RESET;
}
}
}

View File

@ -0,0 +1,9 @@
package com.houndpvp.hub.scoreboard.providers;
import org.bukkit.entity.*;
import java.util.*;
public interface ScoreboardEntryProvider
{
List<String> getScoreboardEntries(final Player p0);
}

View File

@ -0,0 +1,94 @@
package com.houndpvp.hub.scoreboard.providers;
import java.util.*;
import org.bukkit.plugin.java.*;
import java.util.concurrent.*;
import org.bukkit.*;
import org.bukkit.plugin.*;
import org.bukkit.entity.*;
import org.bukkit.event.player.*;
import org.bukkit.event.server.*;
import org.bukkit.event.*;
public class ScoreboardManager implements Listener
{
public static ScoreboardManager instance;
public final ScoreboardEntryProvider provider;
private final String title;
private final Map<UUID, PlayerScoreboard> scoreboards;
private final JavaPlugin plugin;
public boolean debugging;
public ScoreboardManager(final JavaPlugin plugin, final ScoreboardEntryProvider provider, final String title) {
ScoreboardManager.instance = this;
this.plugin = plugin;
this.provider = provider;
this.debugging = true;
this.title = title;
this.scoreboards = new ConcurrentHashMap<UUID, PlayerScoreboard>();
Bukkit.getPluginManager().registerEvents((Listener)this, (Plugin)plugin);
UUID uniqueId;
for(Player pp : Bukkit.getOnlinePlayers()) {
if (this.debugging) {
plugin.getLogger().info("[ScoreboardManager] Loaded scoreboard for " + pp.getName() + "[" + pp.getUniqueId().toString() + "]");
}
uniqueId = pp.getUniqueId();
this.scoreboards.putIfAbsent(uniqueId, new PlayerScoreboard(pp));
}
Bukkit.getScheduler().runTaskTimer(plugin, this::update, 0, 1L);
}
@EventHandler
public void onJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
final UUID uuid = player.getUniqueId();
Bukkit.getScheduler().runTaskLater((Plugin)this.plugin, () -> {
if (this.debugging) {
this.plugin.getLogger().info("[ScoreboardManager] Loaded scoreboard for " + player.getName() + "[" + player.getUniqueId().toString() + "]");
}
this.scoreboards.putIfAbsent(uuid, new PlayerScoreboard(player));
}, 2L);
}
@EventHandler
public void onQuit(final PlayerQuitEvent event) {
final Player player = event.getPlayer();
final UUID uniqueId = player.getUniqueId();
final PlayerScoreboard scoreboard;
if ((scoreboard = this.scoreboards.remove(uniqueId)) != null) {
if (this.debugging) {
this.plugin.getLogger().info("[ScoreboardManager] Deleted scoreboard of " + player.getName() + "[" + player.getUniqueId().toString() + "]");
}
scoreboard.clean();
}
}
@EventHandler
public void onDisable(final PluginDisableEvent event) {
if (event.getPlugin() == this.plugin) {
this.scoreboards.forEach((id, board) -> board.clean());
this.scoreboards.clear();
HandlerList.unregisterAll((Listener)this);
}
}
public void update() {
this.scoreboards.forEach((id, board) -> board.send());
}
public static ScoreboardManager getInstance() {
return ScoreboardManager.instance;
}
public ScoreboardEntryProvider getProvider() {
return this.provider;
}
public String getTitle() {
return this.title;
}
public Map<UUID, PlayerScoreboard> getScoreboards() {
return this.scoreboards;
}
}

View File

@ -0,0 +1,200 @@
package com.houndpvp.hub.scoreboard.providers.reflection;
import java.util.*;
import java.lang.reflect.*;
import java.util.regex.*;
import org.bukkit.*;
public final class Reflection {
private static String OBC_PREFIX;
private static String NMS_PREFIX;
private static String VERSION;
private static Pattern MATCH_VARIABLE;
public static <T> FieldAccessor<T> getField(final Class<?> target, final String name, final Class<T> fieldType) {
return getField(target, name, fieldType, 0);
}
public static <T> FieldAccessor<T> getField(final String className, final String name, final Class<T> fieldType) {
return getField(getClass(className), name, fieldType, 0);
}
public static <T> FieldAccessor<T> getField(final Class<?> target, final Class<T> fieldType, final int index) {
return getField(target, null, fieldType, index);
}
public static <T> FieldAccessor<T> getField(final String className, final Class<T> fieldType, final int index) {
return getField(getClass(className), fieldType, index);
}
@SuppressWarnings("unchecked")
private static <T> FieldAccessor<T> getField(final Class<?> target, final String name, final Class<T> fieldType,
int index) {
for (final Field field : target.getDeclaredFields()) {
if ((name == null || field.getName().equals(name)) && fieldType.isAssignableFrom(field.getType())
&& index-- <= 0) {
field.setAccessible(true);
return new FieldAccessor<T>() {
@Override
public T get(final Object target) {
try {
return (T) field.get(target);
} catch (IllegalAccessException e) {
throw new RuntimeException("Cannot access reflection.", e);
}
}
@Override
public void set(final Object target, final Object value) {
try {
field.set(target, value);
} catch (IllegalAccessException e) {
throw new RuntimeException("Cannot access reflection.", e);
}
}
@Override
public boolean hasField(final Object target) {
return field.getDeclaringClass().isAssignableFrom(target.getClass());
}
};
}
}
if (target.getSuperclass() != null) {
return (FieldAccessor<T>) getField(target.getSuperclass(), name, (Class<Object>) fieldType, index);
}
throw new IllegalArgumentException("Cannot find field with type " + fieldType);
}
public static MethodInvoker getMethod(final String className, final String methodName, final Class<?>... params) {
return getTypedMethod(getClass(className), methodName, null, params);
}
public static MethodInvoker getMethod(final Class<?> clazz, final String methodName, final Class<?>... params) {
return getTypedMethod(clazz, methodName, null, params);
}
public static MethodInvoker getTypedMethod(final Class<?> clazz, final String methodName, final Class<?> returnType,
final Class<?>... params) {
for (final Method method : clazz.getDeclaredMethods()) {
if ((methodName == null || method.getName().equals(methodName))
&& (returnType == null || method.getReturnType().equals(returnType))
&& Arrays.equals(method.getParameterTypes(), params)) {
method.setAccessible(true);
return new MethodInvoker() {
@Override
public Object invoke(final Object target, final Object... arguments) {
try {
return method.invoke(target, arguments);
} catch (Exception e) {
throw new RuntimeException("Cannot invoke method " + method, e);
}
}
};
}
}
if (clazz.getSuperclass() != null) {
return getMethod(clazz.getSuperclass(), methodName, params);
}
throw new IllegalStateException(
String.format("Unable to find method %s (%s).", methodName, Arrays.asList(params)));
}
public static ConstructorInvoker getConstructor(final String className, final Class<?>... params) {
return getConstructor(getClass(className), params);
}
public static ConstructorInvoker getConstructor(final Class<?> clazz, final Class<?>... params) {
for (final Constructor<?> constructor : clazz.getDeclaredConstructors()) {
if (Arrays.equals(constructor.getParameterTypes(), params)) {
constructor.setAccessible(true);
return new ConstructorInvoker() {
@Override
public Object invoke(final Object... arguments) {
try {
return constructor.newInstance(arguments);
} catch (Exception e) {
throw new RuntimeException("Cannot invoke constructor " + constructor, e);
}
}
};
}
}
throw new IllegalStateException(
String.format("Unable to find constructor for %s (%s).", clazz, Arrays.asList(params)));
}
@SuppressWarnings("unchecked")
public static Class<Object> getUntypedClass(final String lookupName) {
final Class<Object> clazz = (Class<Object>) getClass(lookupName);
return clazz;
}
public static Class<?> getClass(final String lookupName) {
return getCanonicalClass(expandVariables(lookupName));
}
public static Class<?> getMinecraftClass(final String name) {
return getCanonicalClass(Reflection.NMS_PREFIX + "." + name);
}
public static Class<?> getCraftBukkitClass(final String name) {
return getCanonicalClass(Reflection.OBC_PREFIX + "." + name);
}
private static Class<?> getCanonicalClass(final String canonicalName) {
try {
return Class.forName(canonicalName);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Cannot find " + canonicalName, e);
}
}
private static String expandVariables(final String name) {
final StringBuffer output = new StringBuffer();
final Matcher matcher = Reflection.MATCH_VARIABLE.matcher(name);
while (matcher.find()) {
final String variable = matcher.group(1);
String replacement;
if ("nms".equalsIgnoreCase(variable)) {
replacement = Reflection.NMS_PREFIX;
} else if ("obc".equalsIgnoreCase(variable)) {
replacement = Reflection.OBC_PREFIX;
} else {
if (!"version".equalsIgnoreCase(variable)) {
throw new IllegalArgumentException("Unknown variable: " + variable);
}
replacement = Reflection.VERSION;
}
if (replacement.length() > 0 && matcher.end() < name.length() && name.charAt(matcher.end()) != '.') {
replacement += ".";
}
matcher.appendReplacement(output, Matcher.quoteReplacement(replacement));
}
matcher.appendTail(output);
return output.toString();
}
static {
Reflection.OBC_PREFIX = Bukkit.getServer().getClass().getPackage().getName();
Reflection.NMS_PREFIX = Reflection.OBC_PREFIX.replace("org.bukkit.craftbukkit", "net.minecraft.server");
Reflection.VERSION = Reflection.OBC_PREFIX.replace("org.bukkit.craftbukkit", "").replace(".", "");
Reflection.MATCH_VARIABLE = Pattern.compile("\\{([^\\}]+)\\}");
}
public interface FieldAccessor<T> {
T get(final Object p0);
void set(final Object p0, final Object p1);
boolean hasField(final Object p0);
}
public interface MethodInvoker {
Object invoke(final Object p0, final Object... p1);
}
public interface ConstructorInvoker {
Object invoke(final Object... p0);
}
}

View File

@ -0,0 +1,60 @@
package com.houndpvp.hub.scoreboard.providers.reflection;
import java.util.*;
public class ReflectionConstants
{
public static final Class<?> SCOREBOARD_OBJECTIVE_CLASS;
public static final Reflection.ConstructorInvoker SCOREBOARD_OBJECTIVE_CONSTRUCTOR;
public static final Reflection.FieldAccessor<String> SCOREBOARD_OBJECTIVE_NAME;
public static final Reflection.FieldAccessor<String> SCOREBOARD_OBJECTIVE_TITLE;
public static final Reflection.FieldAccessor<Integer> SCOREBOARD_OBJECTIVE_ACTION;
public static final Class<?> SCOREBOARD_DISPLAY_OBJECTIVE_CLASS;
public static final Reflection.ConstructorInvoker SCOREBOARD_DISPLAY_OBJECTIVE_CONSTRUCTOR;
public static final Reflection.FieldAccessor<String> SCOREBOARD_DISPLAY_OBJECTIVE_NAME;
public static final Reflection.FieldAccessor<Integer> SCOREBOARD_DISPLAY_OBJECTIVE_POSITION;
public static final Class<?> SCOREBOARD_TEAM_CLASS;
public static final Reflection.ConstructorInvoker SCOREBOARD_TEAM_CONSTRUCTOR;
public static final Reflection.FieldAccessor<String> SCOREBOARD_TEAM_NAME;
public static final Reflection.FieldAccessor<String> SCOREBOARD_TEAM_DISPLAY_NAME;
public static final Reflection.FieldAccessor<String> SCOREBOARD_TEAM_PREFIX;
public static final Reflection.FieldAccessor<String> SCOREBOARD_TEAM_SUFFIX;
@SuppressWarnings("rawtypes")
public static final Reflection.FieldAccessor<Collection> SCOREBOARD_TEAM_PLAYERS;
public static final Reflection.FieldAccessor<Integer> SCOREBOARD_TEAM_ACTION;
public static final Reflection.FieldAccessor<Integer> SCOREBOARD_TEAM_OPTIONS;
public static final Class<?> SCOREBOARD_SCORE_CLASS;
public static final Reflection.ConstructorInvoker SCOREBOARD_SCORE_CONSTRUCTOR;
public static final Reflection.FieldAccessor<String> SCOREBOARD_SCORE_NAME;
public static final Reflection.FieldAccessor<String> SCOREBOARD_SCORE_OBJECTIVE;
public static final Reflection.FieldAccessor<Integer> SCOREBOARD_SCORE_SCORE;
public static final Reflection.FieldAccessor<?> SCOREBOARD_SCORE_ACTION;
static {
SCOREBOARD_OBJECTIVE_CLASS = Reflection.getMinecraftClass("PacketPlayOutScoreboardObjective");
SCOREBOARD_OBJECTIVE_CONSTRUCTOR = Reflection.getConstructor(ReflectionConstants.SCOREBOARD_OBJECTIVE_CLASS, (Class<?>[])new Class[0]);
SCOREBOARD_OBJECTIVE_NAME = Reflection.getField(ReflectionConstants.SCOREBOARD_OBJECTIVE_CLASS, String.class, 0);
SCOREBOARD_OBJECTIVE_TITLE = Reflection.getField(ReflectionConstants.SCOREBOARD_OBJECTIVE_CLASS, String.class, 1);
SCOREBOARD_OBJECTIVE_ACTION = Reflection.getField(ReflectionConstants.SCOREBOARD_OBJECTIVE_CLASS, Integer.TYPE, 0);
SCOREBOARD_DISPLAY_OBJECTIVE_CLASS = Reflection.getMinecraftClass("PacketPlayOutScoreboardDisplayObjective");
SCOREBOARD_DISPLAY_OBJECTIVE_CONSTRUCTOR = Reflection.getConstructor(ReflectionConstants.SCOREBOARD_DISPLAY_OBJECTIVE_CLASS, (Class<?>[])new Class[0]);
SCOREBOARD_DISPLAY_OBJECTIVE_NAME = Reflection.getField(ReflectionConstants.SCOREBOARD_DISPLAY_OBJECTIVE_CLASS, String.class, 0);
SCOREBOARD_DISPLAY_OBJECTIVE_POSITION = Reflection.getField(ReflectionConstants.SCOREBOARD_DISPLAY_OBJECTIVE_CLASS, Integer.TYPE, 0);
SCOREBOARD_TEAM_CLASS = Reflection.getMinecraftClass("PacketPlayOutScoreboardTeam");
SCOREBOARD_TEAM_CONSTRUCTOR = Reflection.getConstructor(ReflectionConstants.SCOREBOARD_TEAM_CLASS, (Class<?>[])new Class[0]);
SCOREBOARD_TEAM_NAME = Reflection.getField(ReflectionConstants.SCOREBOARD_TEAM_CLASS, String.class, 0);
SCOREBOARD_TEAM_DISPLAY_NAME = Reflection.getField(ReflectionConstants.SCOREBOARD_TEAM_CLASS, String.class, 1);
SCOREBOARD_TEAM_PREFIX = Reflection.getField(ReflectionConstants.SCOREBOARD_TEAM_CLASS, String.class, 2);
SCOREBOARD_TEAM_SUFFIX = Reflection.getField(ReflectionConstants.SCOREBOARD_TEAM_CLASS, String.class, 3);
SCOREBOARD_TEAM_PLAYERS = Reflection.getField(ReflectionConstants.SCOREBOARD_TEAM_CLASS, Collection.class, 0);
SCOREBOARD_TEAM_ACTION = Reflection.getField(ReflectionConstants.SCOREBOARD_TEAM_CLASS, Integer.TYPE, 0);
SCOREBOARD_TEAM_OPTIONS = Reflection.getField(ReflectionConstants.SCOREBOARD_TEAM_CLASS, Integer.TYPE, 1);
SCOREBOARD_SCORE_CLASS = Reflection.getMinecraftClass("PacketPlayOutScoreboardScore");
SCOREBOARD_SCORE_CONSTRUCTOR = Reflection.getConstructor(ReflectionConstants.SCOREBOARD_SCORE_CLASS, (Class<?>[])new Class[0]);
SCOREBOARD_SCORE_NAME = Reflection.getField(ReflectionConstants.SCOREBOARD_SCORE_CLASS, String.class, 0);
SCOREBOARD_SCORE_OBJECTIVE = Reflection.getField(ReflectionConstants.SCOREBOARD_SCORE_CLASS, String.class, 1);
SCOREBOARD_SCORE_SCORE = Reflection.getField(ReflectionConstants.SCOREBOARD_SCORE_CLASS, Integer.TYPE, 0);
SCOREBOARD_SCORE_ACTION = Reflection.getField(ReflectionConstants.SCOREBOARD_SCORE_CLASS, (Class<?>)Integer.TYPE, 1);
}
}

View File

@ -0,0 +1,101 @@
package com.houndpvp.hub.tablist;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
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 org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import com.houndpvp.hub.tablist.tab.Tab;
import com.houndpvp.hub.tablist.tab.TabAdapter;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
public class Azazel implements Listener {
@Getter private final JavaPlugin plugin;
private final Map<UUID, Tab> tabs;
@Setter private TabAdapter adapter;
@SuppressWarnings("deprecation")
public Azazel(JavaPlugin plugin) {
this.plugin = plugin;
this.tabs = new ConcurrentHashMap<>();
if (Bukkit.getMaxPlayers() < 60) {
Bukkit.getLogger().severe("There aren't 60 player slots, this will fuck up the tab list."); //TODO: Possibly set max players to 60?
}
for (Player player : Bukkit.getOnlinePlayers()) {
if (((CraftPlayer)player).getHandle().playerConnection.networkManager.getVersion() < 47) {
if (!(tabs.containsKey(player.getUniqueId()))) {
tabs.put(player.getUniqueId(), new Tab(player, true, this));
}
}
}
new AzazelTask(this, plugin);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public Azazel(JavaPlugin plugin, TabAdapter adapter) {
this(plugin);
this.adapter = adapter;
}
public Tab getTabByPlayer(Player player) {
return tabs.get(player.getUniqueId());
}
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent event) {
for (Player player : Bukkit.getOnlinePlayers()) {
PacketPlayOutPlayerInfo packet = PacketPlayOutPlayerInfo.removePlayer(((CraftPlayer)event.getPlayer()).getHandle());
((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
}
new BukkitRunnable() {
@Override
public void run() {
tabs.put(event.getPlayer().getUniqueId(), new Tab(event.getPlayer(), true, Azazel.this));
}
}.runTaskLater(plugin, 20L);
}
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerQuitEvent(PlayerQuitEvent event) {
tabs.remove(event.getPlayer().getUniqueId());
for (Player other : Bukkit.getOnlinePlayers()) {
EntityPlayer entityPlayer = ((CraftPlayer)other).getHandle();
if (entityPlayer.playerConnection.networkManager.getVersion() >= 47) {
Tab tab = getTabByPlayer(event.getPlayer());
if (tab != null && tab.getElevatedTeam() != null) {
tab.getElevatedTeam().removeEntry(event.getPlayer().getName());
}
}
}
}
public TabAdapter getAdapter() {
return adapter;
}
}

View File

@ -0,0 +1,105 @@
package com.houndpvp.hub.tablist;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scoreboard.Team;
import com.houndpvp.hub.tablist.tab.Tab;
import com.houndpvp.hub.tablist.tab.TabAdapter;
import com.houndpvp.hub.tablist.tab.TabTemplate;
import java.util.*;
/*
TODO: Clean this thing up
*/
public class AzazelTask extends BukkitRunnable {
private final Azazel azazel;
public AzazelTask(Azazel azazel, JavaPlugin plugin) {
this.azazel = azazel;
runTaskTimerAsynchronously(plugin, 0L, 5L);
}
@Override
public void run() {
TabAdapter adapter = azazel.getAdapter();
if (adapter != null) {
for (Player player : Bukkit.getOnlinePlayers()) {
Tab tab = azazel.getTabByPlayer(player);
if (tab != null) {
TabTemplate template = adapter.getTemplate(player);
if (template == null || (template.getLeft().isEmpty() && template.getMiddle().isEmpty() && template.getRight().isEmpty())) {
for (Tab.TabEntryPosition position : tab.getPositions()) {
Team team = player.getScoreboard().getTeam(position.getKey());
if (team != null) {
if (team.getPrefix() != null && !team.getPrefix().isEmpty()) {
team.setPrefix("");
}
if (team.getSuffix() != null && !team.getSuffix().isEmpty()) {
team.setSuffix("");
}
}
}
continue;
}
for (int i = 0; i < 20 - template.getLeft().size(); i++) {
template.left("");
}
for (int i = 0; i < 20 - template.getMiddle().size(); i++) {
template.middle("");
}
for (int i = 0; i < 20 - template.getRight().size(); i++) {
template.right("");
}
List<List<String>> rows = Arrays.asList(template.getLeft(), template.getMiddle(), template.getRight(), template.getFarRight());
for (int l = 0; l < rows.size(); l++) {
for (int i = 0; i < rows.get(l).size(); i++) {
Team team = tab.getByLocation(l, i);
if (team != null) {
Map.Entry<String, String> prefixAndSuffix = getPrefixAndSuffix(rows.get(l).get(i));
String prefix = prefixAndSuffix.getKey();
String suffix = prefixAndSuffix.getValue();
if (team.getPrefix().equals(prefix) && team.getSuffix().equals(suffix)) {
continue;
}
team.setPrefix(prefix);
team.setSuffix(suffix);
}
}
}
}
}
}
}
private Map.Entry<String, String> getPrefixAndSuffix(String text) {
String prefix, suffix;
text = ChatColor.translateAlternateColorCodes('&', text);
if (text.length() > 16){
int splitAt = text.charAt(15) == ChatColor.COLOR_CHAR ? 15 : 16;
prefix = text.substring(0, splitAt);
String suffixTemp = ChatColor.getLastColors(prefix) + text.substring(splitAt);
suffix = (suffixTemp.substring(0, Math.min(suffixTemp.length(), 16)));
} else {
prefix = text;
suffix = "";
}
return new AbstractMap.SimpleEntry<>(prefix, suffix);
}
}

View File

@ -0,0 +1,60 @@
package com.houndpvp.hub.tablist.tab.Provider;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.entity.Player;
import com.houndpvp.hub.tablist.tab.TabAdapter;
import com.houndpvp.hub.tablist.tab.TabTemplate;
import com.houndpvp.hub.utils.Bungee;
import net.md_5.bungee.api.ChatColor;
public class TabProvider implements TabAdapter {
public TabTemplate getTemplate(Player p) {
TabTemplate template = new TabTemplate();
UUID id = p.getUniqueId();
// FIRST COLUMN
template.left("");
template.left("");
template.left("");
template.left("§5Kitmap");
template.left("§7Online: §f" + Bungee.getCount("kitmap"));
template.left("");
template.left("");
template.left("§5§lTeamspeak");
template.left("§7ts.exempvp.net");
// MIDDLE
template.middle("§5§lExemPvP");
template.middle("");
template.middle("");
template.middle("§5Practice");
template.middle("§7Online: §f" + Bungee.getCount("practice"));
template.middle("");
template.middle("");
template.middle("§5§lDiscord");
template.middle("§7discord.exempvp.net");
template.middle("");
template.middle("");
// RIGHT COLUMN
template.right("");
template.right("");
template.right("");
template.right("§5HCF");
template.right("§7Online: §f" + Bungee.getCount("HCF"));
template.right("");
template.right("");
template.right("§5§lStore");
template.right("§7store.exempvp.net");
return template;
}
}

View File

@ -0,0 +1,218 @@
package com.houndpvp.hub.tablist.tab;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import com.houndpvp.hub.tablist.Azazel;
public class Tab {
private Scoreboard scoreboard;
private Team elevatedTeam;
private Map<TabEntryPosition, String> entries;
public Scoreboard getScoreboard() {
return this.scoreboard;
}
public Team getElevatedTeam() {
return this.elevatedTeam;
}
public void setElevatedTeam(Team elevatedTeam) {
this.elevatedTeam = elevatedTeam;
}
@SuppressWarnings("deprecation")
public Tab(Player player, boolean hook, Azazel azazel) {
this.entries = new ConcurrentHashMap<TabEntryPosition, String>();
this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
if ((hook) && (!player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard()))) {
this.scoreboard = player.getScoreboard();
}
this.elevatedTeam = this.scoreboard.registerNewTeam((String) getBlanks().get(getBlanks().size() - 1));
for (Player other : Bukkit.getOnlinePlayers()) {
getElevatedTeam(other, azazel).addEntry(other.getName());
Tab tab = azazel.getTabByPlayer(other);
if (tab != null) {
tab.getElevatedTeam(player, azazel).addEntry(player.getName());
}
PacketPlayOutPlayerInfo packet = PacketPlayOutPlayerInfo.removePlayer(((CraftPlayer) other).getHandle());
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
player.setScoreboard(this.scoreboard);
initialize(player);
}
public Team getElevatedTeam(Player player, Azazel azazel) {
if (player.hasMetadata("HydrogenPrefix")) {
String prefix = ChatColor.getLastColors(player.getDisplayName().replace(ChatColor.RESET + "", ""));
String name = (String) getBlanks().get(getBlanks().size() - 1) + prefix;
if (name.length() > 16) {
name = name.substring(0, 15);
}
Team team = this.scoreboard.getTeam(name);
if (team == null) {
team = this.scoreboard.registerNewTeam(name);
team.setPrefix(prefix);
}
return team;
}
return this.elevatedTeam;
}
public Set<TabEntryPosition> getPositions() {
return this.entries.keySet();
}
public Team getByLocation(int x, int y) {
for (TabEntryPosition position : this.entries.keySet()) {
if ((position.getX() == x) && (position.getY() == y)) {
return this.scoreboard.getTeam(position.getKey());
}
}
return null;
}
private void initialize(Player player) {
if (((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() >= 47) {
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 20; y++) {
String key = getNextBlank();
TabEntryPosition position = new TabEntryPosition(x, y, key, this.scoreboard);
this.entries.put(position, key);
((CraftPlayer) player).getHandle().playerConnection
.sendPacket(getPlayerPacket((String) this.entries.get(position)));
Team team = this.scoreboard.getTeam(position.getKey());
if (team == null) {
team = this.scoreboard.registerNewTeam(position.getKey());
}
team.addEntry((String) this.entries.get(position));
}
}
} else {
for (int i = 0; i < 60; i++) {
int x = i % 3;
int y = i / 3;
String key = getNextBlank();
TabEntryPosition position = new TabEntryPosition(x, y, key, this.scoreboard);
this.entries.put(position, key);
((CraftPlayer) player).getHandle().playerConnection
.sendPacket(getPlayerPacket((String) this.entries.get(position)));
Team team = this.scoreboard.getTeam(position.getKey());
if (team == null) {
team = this.scoreboard.registerNewTeam(position.getKey());
}
team.addEntry((String) this.entries.get(position));
}
}
}
private String getNextBlank() {
for (String blank : getBlanks()) {
if (this.scoreboard.getTeam(blank) == null) {
Iterator<String> localIterator2 = this.entries.values().iterator();
for (;;) {
if (!localIterator2.hasNext()) {
break;
}
String identifier = (String) localIterator2.next();
if (identifier.equals(blank)) {
break;
}
}
return blank;
}
}
return null;
}
public List<String> getBlanks() {
List<String> toReturn = new ArrayList<String>();
for (ChatColor color : ChatColor.values()) {
for (int i = 0; i < 4; i++) {
String identifier = StringUtils.repeat(new StringBuilder().append(color).append("").toString(), 4 - i)
+ ChatColor.RESET;
toReturn.add(identifier);
}
}
return toReturn;
}
private static Packet getPlayerPacket(String name) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
try {
Field action = PacketPlayOutPlayerInfo.class.getDeclaredField("action");
Field username = PacketPlayOutPlayerInfo.class.getDeclaredField("username");
Field player = PacketPlayOutPlayerInfo.class.getDeclaredField("player");
action.setAccessible(true);
username.setAccessible(true);
player.setAccessible(true);
action.set(packet, Integer.valueOf(0));
username.set(packet, name);
player.set(packet, new GameProfile(UUID.randomUUID(), name));
} catch (NoSuchFieldException e) {
e.printStackTrace();
return null;
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return packet;
}
public static class TabEntryPosition {
private final int x;
private final int y;
private final String key;
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public String getKey() {
return this.key;
}
public TabEntryPosition(int x, int y, String key, Scoreboard scoreboard) {
this.x = x;
this.y = y;
this.key = key;
}
}
public static class UpdatedPacketPlayOutPlayerInfo extends PacketPlayOutPlayerInfo {
}
}

View File

@ -0,0 +1,9 @@
package com.houndpvp.hub.tablist.tab;
import org.bukkit.entity.Player;
public interface TabAdapter {
TabTemplate getTemplate(Player player);
}

View File

@ -0,0 +1,104 @@
package com.houndpvp.hub.tablist.tab;
import java.util.ArrayList;
import java.util.List;
public class TabTemplate
{
private final List<String> left;
private final List<String> middle;
private final List<String> right;
private final List<String> farRight;
public List<String> getLeft()
{
return this.left;
}
public List<String> getMiddle()
{
return this.middle;
}
public List<String> getRight()
{
return this.right;
}
public List<String> getFarRight()
{
return this.farRight;
}
public TabTemplate()
{
this.left = new ArrayList<String>();
this.middle = new ArrayList<String>();
this.right = new ArrayList<String>();
this.farRight = new ArrayList<String>();
}
public TabTemplate farRight(String string)
{
return farRight(this.farRight.size(), string);
}
public TabTemplate farRight(int index, String string)
{
if (index > this.farRight.size()) {
for (int i = this.farRight.size(); i < index; i++) {
this.farRight.add("");
}
}
this.farRight.add(index, string);
return this;
}
public TabTemplate left(String string)
{
return left(this.left.size(), string);
}
public TabTemplate middle(String string)
{
return middle(this.middle.size(), string);
}
public TabTemplate right(String string)
{
return right(this.right.size(), string);
}
public TabTemplate left(int index, String string)
{
if (index > this.left.size()) {
for (int i = this.left.size(); i < index; i++) {
this.left.add("");
}
}
this.left.add(index, string);
return this;
}
public TabTemplate middle(int index, String string)
{
if (index > this.middle.size()) {
for (int i = this.middle.size(); i < index; i++) {
this.middle.add("");
}
}
this.middle.add(index, string);
return this;
}
public TabTemplate right(int index, String string)
{
if (index > this.right.size()) {
for (int i = this.right.size(); i < index; i++) {
this.right.add("");
}
}
this.right.add(index, string);
return this;
}
}

View File

@ -0,0 +1,122 @@
package com.houndpvp.hub.utils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.houndpvp.hub.Hub;
import lombok.Getter;
public class Bungee implements PluginMessageListener {
public Hub plugin;
@Getter static public List<String> servers = new ArrayList<String>();
@Getter static public HashMap<String, Integer> counts = new HashMap<String, Integer>();
@Getter static public HashMap<String, String> ips = new HashMap<String, String>();
public Bungee(Hub plugin) {
this.plugin = plugin;
new BukkitRunnable() {
@Override
public void run() {
if(Bukkit.getOnlinePlayers().length == 0) {
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("GetServers");
Player player = Bukkit.getOnlinePlayers()[0];
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
}.runTaskTimer(plugin, 0L, 20 * 5L);
new BukkitRunnable() {
@Override
public void run() {
if(Bukkit.getOnlinePlayers().length == 0) {
return;
}
for(String s : servers) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("PlayerCount");
out.writeUTF(s);
Player player = Bukkit.getOnlinePlayers()[0];
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
out = ByteStreams.newDataOutput();
out.writeUTF("ServerIP");
out.writeUTF(s);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("PlayerCount");
out.writeUTF("ALL");
Player player = Bukkit.getOnlinePlayers()[0];
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
}.runTaskTimer(plugin, 0, 20L);
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals("PlayerCount")) {
String server = in.readUTF();
int count = in.readInt();
if(server != null) {
counts.put(server, count);
}
} else if(subchannel.equals("GetServers")) {
servers = Arrays.asList(in.readUTF().split(", "));
} else if(subchannel.equals("ServerIP")) {
String serverName = in.readUTF();
String ip = in.readUTF();
int port = in.readUnsignedShort();
ips.put(serverName, ip + ":" + port);
}
}
public static void sendServer(Player p, String server) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(server);
p.sendPluginMessage(Hub.getInstance(), "BungeeCord", out.toByteArray());
}
public static int getCount(String server) {
if(counts.containsKey(server)) {
return counts.get(server);
}
return 0;
}
}

View File

@ -0,0 +1,249 @@
package com.houndpvp.hub.utils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
/**
* Easily create itemstacks, without messing your hands.
* <i>Note that if you do use this in one of your projects, leave this notice.</i>
* <i>Please do credit me if you do use this in one of your projects.</i>
* @author NonameSL
*/
public class ItemBuilder {
private ItemStack is;
/**
* Create a new ItemBuilder from scratch.
* @param m The material to create the ItemBuilder with.
*/
public ItemBuilder(Material m) {
this(m, 1);
}
/**
* Create a new ItemBuilder over an existing itemstack.
* @param is The itemstack to create the ItemBuilder over.
*/
public ItemBuilder(ItemStack is) {
this.is = is;
}
/**
* Create a new ItemBuilder from scratch.
* @param m The material of the item.
* @param amount The amount of the item.
*/
public ItemBuilder(Material m, int amount) {
is = new ItemStack(m, amount);
}
/**
* Create a new ItemBuilder from scratch.
* @param m The material of the item.
* @param amount The amount of the item.
* @param durability The durability of the item.
*/
public ItemBuilder(Material m, int amount, byte durability) {
is = new ItemStack(m, amount, durability);
}
/**
* Clone the ItemBuilder into a new one.
* @return The cloned instance.
*/
public ItemBuilder clone() {
return new ItemBuilder(is);
}
/**
* Change the durability of the item.
* @param dur The durability to set it to.
*/
public ItemBuilder setDurability(short dur) {
is.setDurability(dur);
return this;
}
/**
* Set the displayname of the item.
* @param name The name to change it to.
*/
public ItemBuilder setName(String name) {
ItemMeta im = is.getItemMeta();
im.setDisplayName(name);
is.setItemMeta(im);
return this;
}
/**
* Add an unsafe enchantment.
* @param ench The enchantment to add.
* @param level The level to put the enchant on.
*/
public ItemBuilder addUnsafeEnchantment(Enchantment ench, int level) {
is.addUnsafeEnchantment(ench, level);
return this;
}
/**
* Remove a certain enchant from the item.
* @param ench The enchantment to remove
*/
public ItemBuilder removeEnchantment(Enchantment ench) {
is.removeEnchantment(ench);
return this;
}
/**
* Set the skull owner for the item. Works on skulls only.
* @param owner The name of the skull's owner.
*/
public ItemBuilder setSkullOwner(String owner) {
try {
SkullMeta im = (SkullMeta) is.getItemMeta();
im.setOwner(owner);
is.setItemMeta(im);
} catch (ClassCastException expected) {}
return this;
}
/**
* Add an enchant to the item.
* @param ench The enchant to add
* @param level The level
*/
public ItemBuilder addEnchant(Enchantment ench, int level) {
ItemMeta im = is.getItemMeta();
im.addEnchant(ench, level, true);
is.setItemMeta(im);
return this;
}
/**
* Add multiple enchants at once.
* @param enchantments The enchants to add.
*/
public ItemBuilder addEnchantments(Map < Enchantment, Integer > enchantments) {
is.addEnchantments(enchantments);
return this;
}
/**
* Sets infinity durability on the item by setting the durability to Short.MAX_VALUE.
*/
public ItemBuilder setInfinityDurability() {
is.setDurability(Short.MAX_VALUE);
return this;
}
/**
* Re-sets the lore.
* @param lore The lore to set it to.
*/
public ItemBuilder setLore(String...lore) {
ItemMeta im = is.getItemMeta();
im.setLore(Arrays.asList(lore));
is.setItemMeta(im);
return this;
}
/**
* Re-sets the lore.
* @param lore The lore to set it to.
*/
public ItemBuilder setLore(List < String > lore) {
ItemMeta im = is.getItemMeta();
im.setLore(lore);
is.setItemMeta(im);
return this;
}
/**
* Remove a lore line.
* @param lore The lore to remove.
*/
public ItemBuilder removeLoreLine(String line) {
ItemMeta im = is.getItemMeta();
List < String > lore = new ArrayList < > (im.getLore());
if (!lore.contains(line)) return this;
lore.remove(line);
im.setLore(lore);
is.setItemMeta(im);
return this;
}
/**
* Remove a lore line.
* @param index The index of the lore line to remove.
*/
public ItemBuilder removeLoreLine(int index) {
ItemMeta im = is.getItemMeta();
List < String > lore = new ArrayList < > (im.getLore());
if (index < 0 || index > lore.size()) return this;
lore.remove(index);
im.setLore(lore);
is.setItemMeta(im);
return this;
}
/**
* Add a lore line.
* @param line The lore line to add.
*/
public ItemBuilder addLoreLine(String line) {
ItemMeta im = is.getItemMeta();
List < String > lore = new ArrayList < > ();
if (im.hasLore()) lore = new ArrayList < > (im.getLore());
lore.add(line);
im.setLore(lore);
is.setItemMeta(im);
return this;
}
/**
* Add a lore line.
* @param line The lore line to add.
* @param pos The index of where to put it.
*/
public ItemBuilder addLoreLine(String line, int pos) {
ItemMeta im = is.getItemMeta();
List < String > lore = new ArrayList < > (im.getLore());
lore.set(pos, line);
im.setLore(lore);
is.setItemMeta(im);
return this;
}
/**
* Sets the dye color on an item.
* <b>* Notice that this doesn't check for item type, sets the literal data of the dyecolor as durability.</b>
* @param color The color to put.
*/
@SuppressWarnings("deprecation")
public ItemBuilder setDyeColor(DyeColor color) {
this.is.setDurability(color.getData());
return this;
}
/**
* Sets the dye color of a wool item. Works only on wool.
* @deprecated As of version 1.2 changed to setDyeColor.
* @see ItemBuilder@setDyeColor(DyeColor)
* @param color The DyeColor to set the wool item to.
*/
@Deprecated
public ItemBuilder setWoolColor(DyeColor color) {
if (!is.getType().equals(Material.WOOL)) return this;
this.is.setDurability(color.getData());
return this;
}
/**
* Sets the armor color of a leather armor piece. Works only on leather armor pieces.
* @param color The color to set it to.
*/
public ItemBuilder setLeatherArmorColor(Color color) {
try {
LeatherArmorMeta im = (LeatherArmorMeta) is.getItemMeta();
im.setColor(color);
is.setItemMeta(im);
} catch (ClassCastException expected) {}
return this;
}
/**
* Retrieves the itemstack from the ItemBuilder.
* @return The itemstack created/modified by the ItemBuilder instance.
*/
public ItemStack toItemStack() {
return is;
}
}

View File

@ -0,0 +1,52 @@
package com.houndpvp.hub.utils;
import com.houndpvp.hub.*;
import org.bukkit.*;
public class SpawnUtils {
private Location location;
private Hub hub;
public SpawnUtils(Hub Hub) {
hub = Hub;
}
public void setSpawn(Location location) {
location = location;
}
public void load() {
double x = hub.getConfig().getDouble("spawn.x");
double y = hub.getConfig().getDouble("spawn.y");
double z = hub.getConfig().getDouble("spawn.z");
int yaw = hub.getConfig().getInt("spawn.yaw");
int pitch = hub.getConfig().getInt("spawn.pitch");
World world = Bukkit.getWorld(hub.getConfig().getString("spawn.world"));
if (location == null) {
location = new Location(world, x, y, z, yaw, pitch);
}
}
public void save() {
if (location == null) {
location = new Location(Bukkit.getWorld("world"), 1.0, 100.0, 1.0, 1.0f, 1.0f);
}
hub.getConfig().set("spawn.x", location.getX());
hub.getConfig().set("spawn.y", location.getY());
hub.getConfig().set("spawn.z", location.getZ());
hub.getConfig().set("spawn.yaw", location.getYaw());
hub.getConfig().set("spawn.pitch", location.getPitch());
hub.getConfig().set("spawn.world", location.getWorld().getName());
hub.getConfig().set("spawn.isset", true);
hub.saveConfig();
}
public Location getSpawn() {
if (location == null) {
return new Location(Bukkit.getWorld("world"), 0.0, 100.0, 0.0, 0.0f, 0.0f);
}
return location;
}
}

View File

@ -0,0 +1,224 @@
package com.houndpvp.hub.utils;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import net.md_5.bungee.api.ChatColor;
public class SpigotUtils {
static String UUIDAPI = "https://api.mojang.com/users/profiles/minecraft/";
/*
* Used to get the uuid of a player from the mojang servers
*
* @param The player you want to get the uuid from
*
* @return the players uuid
*/
public static UUID getUUID(Player p) {
try {
URL url = new URL(UUIDAPI + p.getName());
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line = in.readLine();
line = line.replace("}", "").replace("{", "").substring(6, 38);
line = line.substring(0, 8) + "-" + line.substring(8, 12) + "-" + line.substring(12, 16) + "-"
+ line.substring(16, 20) + '-' + line.substring(20);
return UUID.fromString(line);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static boolean isItem(ItemStack item, ItemStack item1) {
if(item != null && item1 != null) {
if(item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
if(item1.hasItemMeta() && item1.getItemMeta().hasDisplayName()) {
if(item.getItemMeta().getDisplayName().equalsIgnoreCase(item1.getItemMeta().getDisplayName())) {
return true;
}
}
}
}
return false;
}
/*
* Used to get the uuid of a player from the mojang servers
*
* @param The players name you want to get the uuid from
*
* @return the players uuid
*/
public static UUID getUUID(String p) {
try {
URL url = new URL(UUIDAPI + p);
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line = in.readLine();
line = line.replace("}", "").replace("{", "").substring(6, 38);
line = line.substring(0, 8) + "-" + line.substring(8, 12) + "-" + line.substring(12, 16) + "-"
+ line.substring(16, 20) + '-' + line.substring(20);
return UUID.fromString(line);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String formatLocation(Location l) {
if (l == null)
return "None";
return l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ();
}
public static String formatLocationWithWorld(Location l) {
if (l == null)
return "None";
return l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ() + " (" + l.getWorld().getName() + ")";
}
/*
* Used to get a players ping in milliseconds
*
* @param The player whose ping your retrieving
*
* @return The players ping in MiliSeconds
*/
public static int getPing(Player p) {
CraftPlayer cp = (CraftPlayer) p;
return cp.getHandle().ping;
}
public static int roundToNine(int x) {
if(x < 9) {
return 9;
}
if(x < 18) {
return 18;
}
if(x < 27) {
return 27;
}
if(x < 36) {
return 36;
}
return 9;
}
/*
* Used to ChatColor each line in an ArrayList
*
* @param The ArrayList to convert
*
* @return The coloured ArrayList
*/
public static ArrayList<String> colorArray(List<String> array) {
ArrayList<String> newarray = new ArrayList<>();
for (String s : array) {
newarray.add(ChatColor.translateAlternateColorCodes('&', s));
}
return newarray;
}
/*
* Used to ChatColor each line in an ArrayList
*
* @param The String list to convert
*
* @return The coloured String list
*/
public static String[] colorArray(String[] array) {
ArrayList<String> newarray = new ArrayList<>();
for (String s : array) {
newarray.add(ChatColor.translateAlternateColorCodes('&', s));
}
return newarray.toArray(new String[0]);
}
/*
* Used to replace Strings in an ArrayList
*/
public static ArrayList<String> replaceArray(List<String> array, String oldChar, String newChar) {
ArrayList<String> newarray = new ArrayList<>();
for (String s : array) {
newarray.add(s.replaceAll(oldChar, newChar));
}
return newarray;
}
/*
* Calculate chance out of 100
*
* @param The chance
*
* @return whether the outcome happened
*/
public static Boolean chance(int chance) {
Random rnd = new Random();
int i = rnd.nextInt(100) + 1;
if (i <= chance) {
return true;
} else {
return false;
}
}
public static String getCountry(String ip) {
try {
URL url = new URL("http://ip-api.com/json/" + ip);
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line = in.readLine();
line = line.replace("}", "");
line = line.replace("{", "");
line = line.replace(line.substring(0, 1), "");
HashMap<String, String> info = new HashMap<>();
String[] lines = line.split(",");
for (String s : lines) {
String[] split = s.split(":");
info.put(split[0], split[1]);
}
return info.get("country");
} catch (Exception e) {
return null;
}
}
public static void clearInventory(Player p) {
PlayerInventory inv = p.getInventory();
inv.clear();
inv.setHelmet(null);
inv.setChestplate(null);
inv.setLeggings(null);
inv.setBoots(null);
}
}

80
src/config.yml Normal file
View File

@ -0,0 +1,80 @@
scoreboard:
- '&7&m--------------------'
- '&5&lConnected Players:'
- '&7%online%'
- ''
- '&5&lNetwork Rank'
- '&7%rank%'
- ''
- '&7&ostore.exempvp.net'
- '&7&m--------------------'
scoreboard-inqueue:
- '&7&m--------------------'
- '&5&lConnected Players:'
- '&7%online%'
- ''
- '&5&lQueue Info:'
- ' &7%position%/%inqueue%'
- ''
- '&5&lNetwork Rank'
- '&7%rank%'
- ''
- '&7&ostore.exempvp.net'
- '&7&m--------------------'
server-selector:
oghcf:
type: GOLD_SWORD
name: '&5Practice'
server: practice
lore:
- ''
- '&cOur practice server is currently being developed'
- '&cStay Tuned'
- ''
- '&5Connected Players: &7%count%/1000'
- '&5Click here to connect'
- ''
slot: 11
newhcf:
type: DIAMOND_SWORD
name: '&5HCF (Squads)'
server: HCF
lore:
- ''
- '&7- &5MapKit: &7S1, P1'
- '&7- &5Border: &7Quite big I think'
- '&7- &5Faction Size: &75-Man'
- '&7- &5Faction Allies: &70'
- ''
- '&7- &7Events will take place daily'
- ''
- '&5Connected Players: &7%count%/1000'
- '&5Click here to connect'
- ''
slot: 13
kitmap:
type: FISHING_ROD
name: '&5Kits'
lore:
- ''
- '&7- &5MapKit: &7S1, P1'
- '&7- &5Border: &7Quite big I think'
- '&7- &5Faction Size: &75-Man'
- '&7- &5Faction Allies: &70'
- ''
- '&7- &7Events will take place daily'
- ''
- '&5Connected Players: &7%count%/1000'
- '&7Click here to connect'
- ''
slot: 15
server: kitmap
selector-name: '&7Select a server'
chat-format: '%prefix% %player%&7: %message%'
spawn:
x: -1625.0
y: 198.0
z: 1665.0
yaw: 0.0
pitch: 0.0
world: world

22
src/plugin.yml Normal file
View File

@ -0,0 +1,22 @@
name: Hub
version: 1.0
main: com.houndpvp.hub.Hub
commands:
builder:
setspawn:
rawcast:
gamemode:
gmc:
sounds:
aliases: [togglesounds, toggles]
gms:
gma:
msg:
aliases: [tell, message, t, w, wisper]
reply:
aliases: [r]
togglepm:
sounds:
invselector:
tp:
clear: