parent
bce31de137
commit
838fa9fe03
11 changed files with 399 additions and 414 deletions
|
@ -1,25 +1,25 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AnnouncerThread {
|
||||
private static int AnnounceMessageIndex = 0;
|
||||
|
||||
public static void Run() {
|
||||
while (!PluginMain.Instance.stop) {
|
||||
try {
|
||||
Thread.sleep(PluginMain.AnnounceTime);
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
if (PluginMain.AnnounceMessages.size() > AnnounceMessageIndex) {
|
||||
for (Player player : PluginMain.GetPlayers())
|
||||
player.sendMessage(PluginMain.AnnounceMessages
|
||||
.get(AnnounceMessageIndex));
|
||||
AnnounceMessageIndex++;
|
||||
if (AnnounceMessageIndex == PluginMain.AnnounceMessages.size())
|
||||
AnnounceMessageIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AnnouncerThread {
|
||||
private static int AnnounceMessageIndex = 0;
|
||||
|
||||
public static void Run() {
|
||||
while (!PluginMain.Instance.stop) {
|
||||
try {
|
||||
Thread.sleep(PluginMain.AnnounceTime);
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
if (PluginMain.AnnounceMessages.size() > AnnounceMessageIndex) {
|
||||
for (Player player : PluginMain.GetPlayers())
|
||||
player.sendMessage(PluginMain.AnnounceMessages
|
||||
.get(AnnounceMessageIndex));
|
||||
AnnounceMessageIndex++;
|
||||
if (AnnounceMessageIndex == PluginMain.AnnounceMessages.size())
|
||||
AnnounceMessageIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
|
||||
public class Channel {
|
||||
public final String DisplayName;
|
||||
public final String Color;
|
||||
public final String Command;
|
||||
|
||||
public Channel(String displayname, String color, String command) {
|
||||
DisplayName = displayname;
|
||||
Color = color;
|
||||
Command = command;
|
||||
}
|
||||
|
||||
public static Channel GlobalChat = new Channel("§fg§f", "white", "g");
|
||||
public static Channel TownChat = new Channel("§3TC§f", "dark_aqua", "tc");
|
||||
public static Channel NationChat = new Channel("§6NC§f", "gold", "nc");
|
||||
public static Channel AdminChat = new Channel("§cADMIN§f", "red", "a");
|
||||
public static Channel ModChat = new Channel("§9MOD§f", "blue", "mod");
|
||||
}
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
public class Channel {
|
||||
public final String DisplayName;
|
||||
public final String Color;
|
||||
public final String Command;
|
||||
|
||||
public Channel(String displayname, String color, String command) {
|
||||
DisplayName = displayname;
|
||||
Color = color;
|
||||
Command = command;
|
||||
}
|
||||
|
||||
public static Channel GlobalChat = new Channel("§fg§f", "white", "g");
|
||||
public static Channel TownChat = new Channel("§3TC§f", "dark_aqua", "tc");
|
||||
public static Channel NationChat = new Channel("§6NC§f", "gold", "nc");
|
||||
public static Channel AdminChat = new Channel("§cADMIN§f", "red", "a");
|
||||
public static Channel ModChat = new Channel("§9MOD§f", "blue", "mod");
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import io.github.norbipeti.thebuttonmc.commands.UnlolCommand;
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.UnlolCommand;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
|
@ -1,4 +1,4 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -214,21 +214,6 @@ public class Commands implements CommandExecutor {
|
|||
if (player == null || player.isOp()
|
||||
|| player.getName().equals("NorbiPeti")) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "add":
|
||||
if (args.length < 3) {
|
||||
SendMessage(player, "§cUsage: /u announce add <message>");
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
sb.append(args[i]);
|
||||
if (i != args.length - 1)
|
||||
sb.append(" ");
|
||||
}
|
||||
String finalmessage = sb.toString().replace('&', '§');
|
||||
PluginMain.AnnounceMessages.add(finalmessage);
|
||||
SendMessage(player, "§bAnnouncement added.§r");
|
||||
break;
|
||||
case "remove":
|
||||
if (args.length < 3) {
|
||||
SendMessage(player, "§cUsage: /u announce remove <index>");
|
|
@ -1,77 +1,77 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import au.com.mineauz.minigames.MinigamePlayer;
|
||||
import au.com.mineauz.minigames.events.StartMinigameEvent;
|
||||
import au.com.mineauz.minigames.gametypes.MinigameType;
|
||||
import au.com.mineauz.minigames.mechanics.GameMechanicBase;
|
||||
import au.com.mineauz.minigames.minigame.Minigame;
|
||||
import au.com.mineauz.minigames.minigame.modules.MinigameModule;
|
||||
|
||||
public class CreativeGlobalMechanic extends GameMechanicBase {
|
||||
|
||||
@Override
|
||||
public boolean checkCanStart(Minigame arg0, MinigamePlayer arg1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinigameModule displaySettings(Minigame arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endMinigame(Minigame arg0, List<MinigamePlayer> arg1,
|
||||
List<MinigamePlayer> arg2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMechanic() {
|
||||
return "creativeglobal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinMinigame(Minigame mg, MinigamePlayer mp) {
|
||||
mp.setCanFly(true);
|
||||
mp.setAllowTeleport(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitMinigame(Minigame mg, MinigamePlayer mp, boolean forced) {
|
||||
mg.getBlockRecorder().clearRestoreData();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startMinigame(Minigame mg, MinigamePlayer mp) {
|
||||
mp.setAllowTeleport(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopMinigame(Minigame arg0, MinigamePlayer arg1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<MinigameType> validTypes() {
|
||||
return EnumSet.of(MinigameType.MULTIPLAYER);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void minigameStart(StartMinigameEvent event) {
|
||||
if (event.getMinigame().getMechanicName().equals(getMechanic())) {
|
||||
final List<MinigamePlayer> players = event.getPlayers();
|
||||
// final Minigame minigame = event.getMinigame();
|
||||
for (MinigamePlayer player : players) {
|
||||
player.setCanFly(true);
|
||||
player.setAllowTeleport(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import au.com.mineauz.minigames.MinigamePlayer;
|
||||
import au.com.mineauz.minigames.events.StartMinigameEvent;
|
||||
import au.com.mineauz.minigames.gametypes.MinigameType;
|
||||
import au.com.mineauz.minigames.mechanics.GameMechanicBase;
|
||||
import au.com.mineauz.minigames.minigame.Minigame;
|
||||
import au.com.mineauz.minigames.minigame.modules.MinigameModule;
|
||||
|
||||
public class CreativeGlobalMechanic extends GameMechanicBase {
|
||||
|
||||
@Override
|
||||
public boolean checkCanStart(Minigame arg0, MinigamePlayer arg1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinigameModule displaySettings(Minigame arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endMinigame(Minigame arg0, List<MinigamePlayer> arg1,
|
||||
List<MinigamePlayer> arg2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMechanic() {
|
||||
return "creativeglobal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinMinigame(Minigame mg, MinigamePlayer mp) {
|
||||
mp.setCanFly(true);
|
||||
mp.setAllowTeleport(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitMinigame(Minigame mg, MinigamePlayer mp, boolean forced) {
|
||||
mg.getBlockRecorder().clearRestoreData();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startMinigame(Minigame mg, MinigamePlayer mp) {
|
||||
mp.setAllowTeleport(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopMinigame(Minigame arg0, MinigamePlayer arg1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<MinigameType> validTypes() {
|
||||
return EnumSet.of(MinigameType.MULTIPLAYER);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void minigameStart(StartMinigameEvent event) {
|
||||
if (event.getMinigame().getMechanicName().equals(getMechanic())) {
|
||||
final List<MinigamePlayer> players = event.getPlayers();
|
||||
// final Minigame minigame = event.getMinigame();
|
||||
for (MinigamePlayer player : players) {
|
||||
player.setCanFly(true);
|
||||
player.setAllowTeleport(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
|
||||
public enum FlairStates {
|
||||
Accepted, Ignored, Recognised, Commented, NoComment
|
||||
}
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
public enum FlairStates {
|
||||
Accepted, Ignored, Recognised, Commented, NoComment
|
||||
}
|
|
@ -1,90 +1,90 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public class JarUtils {
|
||||
|
||||
public static boolean extractFromJar(final String fileName,
|
||||
final String dest) throws IOException {
|
||||
if (getRunningJar() == null) {
|
||||
return false;
|
||||
}
|
||||
final File file = new File(dest);
|
||||
if (file.isDirectory()) {
|
||||
file.mkdir();
|
||||
return false;
|
||||
}
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
final JarFile jar = getRunningJar();
|
||||
final Enumeration<JarEntry> e = jar.entries();
|
||||
while (e.hasMoreElements()) {
|
||||
final JarEntry je = e.nextElement();
|
||||
if (!je.getName().contains(fileName)) {
|
||||
continue;
|
||||
}
|
||||
final InputStream in = new BufferedInputStream(
|
||||
jar.getInputStream(je));
|
||||
final OutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(file));
|
||||
copyInputStream(in, out);
|
||||
jar.close();
|
||||
return true;
|
||||
}
|
||||
jar.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
private final static void copyInputStream(final InputStream in,
|
||||
final OutputStream out) throws IOException {
|
||||
try {
|
||||
final byte[] buff = new byte[4096];
|
||||
int n;
|
||||
while ((n = in.read(buff)) > 0) {
|
||||
out.write(buff, 0, n);
|
||||
}
|
||||
} finally {
|
||||
out.flush();
|
||||
out.close();
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static URL getJarUrl(final File file) throws IOException {
|
||||
return new URL("jar:" + file.toURI().toURL().toExternalForm() + "!/");
|
||||
}
|
||||
|
||||
public static JarFile getRunningJar() throws IOException {
|
||||
if (!RUNNING_FROM_JAR) {
|
||||
return null; // null if not running from jar
|
||||
}
|
||||
String path = new File(JarUtils.class.getProtectionDomain()
|
||||
.getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||
path = URLDecoder.decode(path, "UTF-8");
|
||||
return new JarFile(path);
|
||||
}
|
||||
|
||||
private static boolean RUNNING_FROM_JAR = false;
|
||||
|
||||
static {
|
||||
final URL resource = JarUtils.class.getClassLoader().getResource(
|
||||
"plugin.yml");
|
||||
if (resource != null) {
|
||||
RUNNING_FROM_JAR = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public class JarUtils {
|
||||
|
||||
public static boolean extractFromJar(final String fileName,
|
||||
final String dest) throws IOException {
|
||||
if (getRunningJar() == null) {
|
||||
return false;
|
||||
}
|
||||
final File file = new File(dest);
|
||||
if (file.isDirectory()) {
|
||||
file.mkdir();
|
||||
return false;
|
||||
}
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
final JarFile jar = getRunningJar();
|
||||
final Enumeration<JarEntry> e = jar.entries();
|
||||
while (e.hasMoreElements()) {
|
||||
final JarEntry je = e.nextElement();
|
||||
if (!je.getName().contains(fileName)) {
|
||||
continue;
|
||||
}
|
||||
final InputStream in = new BufferedInputStream(
|
||||
jar.getInputStream(je));
|
||||
final OutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(file));
|
||||
copyInputStream(in, out);
|
||||
jar.close();
|
||||
return true;
|
||||
}
|
||||
jar.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
private final static void copyInputStream(final InputStream in,
|
||||
final OutputStream out) throws IOException {
|
||||
try {
|
||||
final byte[] buff = new byte[4096];
|
||||
int n;
|
||||
while ((n = in.read(buff)) > 0) {
|
||||
out.write(buff, 0, n);
|
||||
}
|
||||
} finally {
|
||||
out.flush();
|
||||
out.close();
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static URL getJarUrl(final File file) throws IOException {
|
||||
return new URL("jar:" + file.toURI().toURL().toExternalForm() + "!/");
|
||||
}
|
||||
|
||||
public static JarFile getRunningJar() throws IOException {
|
||||
if (!RUNNING_FROM_JAR) {
|
||||
return null; // null if not running from jar
|
||||
}
|
||||
String path = new File(JarUtils.class.getProtectionDomain()
|
||||
.getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||
path = URLDecoder.decode(path, "UTF-8");
|
||||
return new JarFile(path);
|
||||
}
|
||||
|
||||
private static boolean RUNNING_FROM_JAR = false;
|
||||
|
||||
static {
|
||||
final URL resource = JarUtils.class.getClassLoader().getResource(
|
||||
"plugin.yml");
|
||||
if (resource != null) {
|
||||
RUNNING_FROM_JAR = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,165 +1,165 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MaybeOfflinePlayer {
|
||||
public String PlayerName;
|
||||
public String UserName;
|
||||
public List<String> UserNames;
|
||||
private short FlairTime;
|
||||
public FlairStates FlairState;
|
||||
public boolean RPMode = true;
|
||||
public boolean PressedF;
|
||||
public Location SavedLocation;
|
||||
public boolean Working;
|
||||
// public int Tables = 10;
|
||||
public Channel CurrentChannel = Channel.GlobalChat;
|
||||
public int FCount;
|
||||
public boolean SendingLink = false;
|
||||
public int FDeaths;
|
||||
public boolean RainbowPresserColorMode = false;
|
||||
public String OtherColorMode = "";
|
||||
public boolean ChatOnly = false;
|
||||
public boolean FlairCheater = false;
|
||||
public int LoginWarningCount = 0;
|
||||
public static final short FlairTimeNonPresser = -1;
|
||||
public static final short FlairTimeCantPress = -2;
|
||||
public static final short FlairTimeNone = -3;
|
||||
|
||||
public UUID UUID;
|
||||
|
||||
public static HashMap<UUID, MaybeOfflinePlayer> AllPlayers = new HashMap<>();
|
||||
|
||||
public static MaybeOfflinePlayer AddPlayerIfNeeded(UUID uuid) {
|
||||
if (!AllPlayers.containsKey(uuid)) {
|
||||
MaybeOfflinePlayer player = new MaybeOfflinePlayer();
|
||||
player.UUID = uuid;
|
||||
player.FlairTime = FlairTimeNone;
|
||||
player.FlairState = FlairStates.NoComment;
|
||||
player.UserNames = new ArrayList<>();
|
||||
AllPlayers.put(uuid, player);
|
||||
return player;
|
||||
}
|
||||
return AllPlayers.get(uuid);
|
||||
}
|
||||
|
||||
public static void Load(YamlConfiguration yc) {
|
||||
ConfigurationSection cs = yc.getConfigurationSection("players");
|
||||
for (String key : cs.getKeys(false)) {
|
||||
ConfigurationSection cs2 = cs.getConfigurationSection(key);
|
||||
MaybeOfflinePlayer mp = AddPlayerIfNeeded(java.util.UUID
|
||||
.fromString(cs2.getString("uuid")));
|
||||
mp.UserName = cs2.getString("username");
|
||||
String tmp = cs2.getString("flairtime");
|
||||
if (tmp.equals("--"))
|
||||
mp.FlairTime = FlairTimeNonPresser;
|
||||
else if (tmp.equals("??"))
|
||||
mp.FlairTime = FlairTimeCantPress;
|
||||
else if (tmp.length() > 0)
|
||||
mp.FlairTime = Short.parseShort(tmp);
|
||||
String flairstate = cs2.getString("flairstate");
|
||||
if (flairstate != null)
|
||||
mp.FlairState = FlairStates.valueOf(flairstate);
|
||||
else
|
||||
mp.FlairState = FlairStates.NoComment;
|
||||
mp.PlayerName = cs2.getString("playername");
|
||||
mp.UserNames = cs2.getStringList("usernames");
|
||||
mp.FCount = cs2.getInt("fcount");
|
||||
mp.FDeaths = cs2.getInt("fdeaths");
|
||||
mp.FlairCheater = cs2.getBoolean("flaircheater");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save(YamlConfiguration yc) {
|
||||
ConfigurationSection cs = yc.createSection("players");
|
||||
for (MaybeOfflinePlayer mp : MaybeOfflinePlayer.AllPlayers.values()) {
|
||||
ConfigurationSection cs2 = cs.createSection(mp.UUID.toString());
|
||||
cs2.set("playername", mp.PlayerName);
|
||||
cs2.set("username", mp.UserName);
|
||||
cs2.set("flairtime", mp.FlairTime);
|
||||
cs2.set("flairstate", mp.FlairState.toString());
|
||||
cs2.set("uuid", mp.UUID.toString());
|
||||
cs2.set("usernames", mp.UserNames);
|
||||
cs2.set("fcount", mp.FCount);
|
||||
cs2.set("fdeaths", mp.FDeaths);
|
||||
cs2.set("flaircheater", mp.FlairCheater);
|
||||
}
|
||||
}
|
||||
|
||||
public static MaybeOfflinePlayer GetFromName(String name) {
|
||||
Player p = Bukkit.getPlayer(name);
|
||||
if (p != null)
|
||||
return AllPlayers.get(p.getUniqueId());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public String GetFormattedFlair() {
|
||||
if (FlairTime == FlairTimeCantPress)
|
||||
return String.format("§r(--s)§r");
|
||||
if (FlairTime == FlairTimeNonPresser)
|
||||
return String.format("§7(--s)§r");
|
||||
if (FlairTime == FlairTimeNone)
|
||||
return "";
|
||||
return String.format("§%x(%ss)§r", GetFlairColor(), FlairTime);
|
||||
}
|
||||
|
||||
public void SetFlair(short time) {
|
||||
FlairTime = time;
|
||||
FlairUpdate();
|
||||
}
|
||||
|
||||
public void SetFlair(short time, boolean cheater) {
|
||||
FlairTime = time;
|
||||
FlairCheater = cheater;
|
||||
FlairUpdate();
|
||||
}
|
||||
|
||||
public void FlairUpdate() {
|
||||
|
||||
// Flairs from Command Block The Button - Teams
|
||||
// PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard().getTeams().add()
|
||||
Player p = Bukkit.getPlayer(UUID);
|
||||
p.setPlayerListName(String.format("%s%s", p.getName(),
|
||||
GetFormattedFlair()));
|
||||
}
|
||||
|
||||
public short GetFlairColor() {
|
||||
if (FlairCheater)
|
||||
return 0x5;
|
||||
if (FlairTime == -1)
|
||||
return 0x7;
|
||||
else if (FlairTime == -2)
|
||||
return 0xf;
|
||||
else if (FlairTime <= 60 && FlairTime >= 52)
|
||||
return 0x5;
|
||||
else if (FlairTime <= 51 && FlairTime >= 42)
|
||||
return 0x9;
|
||||
else if (FlairTime <= 41 && FlairTime >= 32)
|
||||
return 0xa;
|
||||
else if (FlairTime <= 31 && FlairTime >= 22)
|
||||
return 0xe;
|
||||
else if (FlairTime <= 21 && FlairTime >= 11)
|
||||
return 0x6;
|
||||
else if (FlairTime <= 11 && FlairTime >= 0)
|
||||
return 0xc;
|
||||
return 0xf;
|
||||
}
|
||||
|
||||
public short GetFlairTime() {
|
||||
return FlairTime;
|
||||
}
|
||||
|
||||
public static MaybeOfflinePlayer GetFromPlayer(Player p) {
|
||||
return MaybeOfflinePlayer.AllPlayers.get(p.getUniqueId());
|
||||
}
|
||||
}
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MaybeOfflinePlayer {
|
||||
public String PlayerName;
|
||||
public String UserName;
|
||||
public List<String> UserNames;
|
||||
private short FlairTime;
|
||||
public FlairStates FlairState;
|
||||
public boolean RPMode = true;
|
||||
public boolean PressedF;
|
||||
public Location SavedLocation;
|
||||
public boolean Working;
|
||||
// public int Tables = 10;
|
||||
public Channel CurrentChannel = Channel.GlobalChat;
|
||||
public int FCount;
|
||||
public boolean SendingLink = false;
|
||||
public int FDeaths;
|
||||
public boolean RainbowPresserColorMode = false;
|
||||
public String OtherColorMode = "";
|
||||
public boolean ChatOnly = false;
|
||||
public boolean FlairCheater = false;
|
||||
public int LoginWarningCount = 0;
|
||||
public static final short FlairTimeNonPresser = -1;
|
||||
public static final short FlairTimeCantPress = -2;
|
||||
public static final short FlairTimeNone = -3;
|
||||
|
||||
public UUID UUID;
|
||||
|
||||
public static HashMap<UUID, MaybeOfflinePlayer> AllPlayers = new HashMap<>();
|
||||
|
||||
public static MaybeOfflinePlayer AddPlayerIfNeeded(UUID uuid) {
|
||||
if (!AllPlayers.containsKey(uuid)) {
|
||||
MaybeOfflinePlayer player = new MaybeOfflinePlayer();
|
||||
player.UUID = uuid;
|
||||
player.FlairTime = FlairTimeNone;
|
||||
player.FlairState = FlairStates.NoComment;
|
||||
player.UserNames = new ArrayList<>();
|
||||
AllPlayers.put(uuid, player);
|
||||
return player;
|
||||
}
|
||||
return AllPlayers.get(uuid);
|
||||
}
|
||||
|
||||
public static void Load(YamlConfiguration yc) {
|
||||
ConfigurationSection cs = yc.getConfigurationSection("players");
|
||||
for (String key : cs.getKeys(false)) {
|
||||
ConfigurationSection cs2 = cs.getConfigurationSection(key);
|
||||
MaybeOfflinePlayer mp = AddPlayerIfNeeded(java.util.UUID
|
||||
.fromString(cs2.getString("uuid")));
|
||||
mp.UserName = cs2.getString("username");
|
||||
String tmp = cs2.getString("flairtime");
|
||||
if (tmp.equals("--"))
|
||||
mp.FlairTime = FlairTimeNonPresser;
|
||||
else if (tmp.equals("??"))
|
||||
mp.FlairTime = FlairTimeCantPress;
|
||||
else if (tmp.length() > 0)
|
||||
mp.FlairTime = Short.parseShort(tmp);
|
||||
String flairstate = cs2.getString("flairstate");
|
||||
if (flairstate != null)
|
||||
mp.FlairState = FlairStates.valueOf(flairstate);
|
||||
else
|
||||
mp.FlairState = FlairStates.NoComment;
|
||||
mp.PlayerName = cs2.getString("playername");
|
||||
mp.UserNames = cs2.getStringList("usernames");
|
||||
mp.FCount = cs2.getInt("fcount");
|
||||
mp.FDeaths = cs2.getInt("fdeaths");
|
||||
mp.FlairCheater = cs2.getBoolean("flaircheater");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save(YamlConfiguration yc) {
|
||||
ConfigurationSection cs = yc.createSection("players");
|
||||
for (MaybeOfflinePlayer mp : MaybeOfflinePlayer.AllPlayers.values()) {
|
||||
ConfigurationSection cs2 = cs.createSection(mp.UUID.toString());
|
||||
cs2.set("playername", mp.PlayerName);
|
||||
cs2.set("username", mp.UserName);
|
||||
cs2.set("flairtime", mp.FlairTime);
|
||||
cs2.set("flairstate", mp.FlairState.toString());
|
||||
cs2.set("uuid", mp.UUID.toString());
|
||||
cs2.set("usernames", mp.UserNames);
|
||||
cs2.set("fcount", mp.FCount);
|
||||
cs2.set("fdeaths", mp.FDeaths);
|
||||
cs2.set("flaircheater", mp.FlairCheater);
|
||||
}
|
||||
}
|
||||
|
||||
public static MaybeOfflinePlayer GetFromName(String name) {
|
||||
Player p = Bukkit.getPlayer(name);
|
||||
if (p != null)
|
||||
return AllPlayers.get(p.getUniqueId());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public String GetFormattedFlair() {
|
||||
if (FlairTime == FlairTimeCantPress)
|
||||
return String.format("§r(--s)§r");
|
||||
if (FlairTime == FlairTimeNonPresser)
|
||||
return String.format("§7(--s)§r");
|
||||
if (FlairTime == FlairTimeNone)
|
||||
return "";
|
||||
return String.format("§%x(%ss)§r", GetFlairColor(), FlairTime);
|
||||
}
|
||||
|
||||
public void SetFlair(short time) {
|
||||
FlairTime = time;
|
||||
FlairUpdate();
|
||||
}
|
||||
|
||||
public void SetFlair(short time, boolean cheater) {
|
||||
FlairTime = time;
|
||||
FlairCheater = cheater;
|
||||
FlairUpdate();
|
||||
}
|
||||
|
||||
public void FlairUpdate() {
|
||||
|
||||
// Flairs from Command Block The Button - Teams
|
||||
// PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard().getTeams().add()
|
||||
Player p = Bukkit.getPlayer(UUID);
|
||||
p.setPlayerListName(String.format("%s%s", p.getName(),
|
||||
GetFormattedFlair()));
|
||||
}
|
||||
|
||||
public short GetFlairColor() {
|
||||
if (FlairCheater)
|
||||
return 0x5;
|
||||
if (FlairTime == -1)
|
||||
return 0x7;
|
||||
else if (FlairTime == -2)
|
||||
return 0xf;
|
||||
else if (FlairTime <= 60 && FlairTime >= 52)
|
||||
return 0x5;
|
||||
else if (FlairTime <= 51 && FlairTime >= 42)
|
||||
return 0x9;
|
||||
else if (FlairTime <= 41 && FlairTime >= 32)
|
||||
return 0xa;
|
||||
else if (FlairTime <= 31 && FlairTime >= 22)
|
||||
return 0xe;
|
||||
else if (FlairTime <= 21 && FlairTime >= 11)
|
||||
return 0x6;
|
||||
else if (FlairTime <= 11 && FlairTime >= 0)
|
||||
return 0xc;
|
||||
return 0xf;
|
||||
}
|
||||
|
||||
public short GetFlairTime() {
|
||||
return FlairTime;
|
||||
}
|
||||
|
||||
public static MaybeOfflinePlayer GetFromPlayer(Player p) {
|
||||
return MaybeOfflinePlayer.AllPlayers.get(p.getUniqueId());
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
public abstract class PlayerJoinTimerTask extends TimerTask {
|
||||
|
||||
@Override
|
||||
public abstract void run();
|
||||
|
||||
public MaybeOfflinePlayer mp;
|
||||
|
||||
}
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
public abstract class PlayerJoinTimerTask extends TimerTask {
|
||||
|
||||
@Override
|
||||
public abstract void run();
|
||||
|
||||
public MaybeOfflinePlayer mp;
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
|
@ -1,4 +1,4 @@
|
|||
package io.github.norbipeti.thebuttonmc;
|
||||
package io.github.norbipeti.thebuttonmcchat;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
@ -25,7 +25,7 @@ import com.palmergames.bukkit.towny.object.Nation;
|
|||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||
|
||||
import io.github.norbipeti.thebuttonmc.commands.TBMCCommandBase;
|
||||
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.String;
|
Loading…
Reference in a new issue