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