Made badges configurable
This commit is contained in:
		
							parent
							
								
									bfadbc9340
								
							
						
					
					
						commit
						21fb971a40
					
				|  | @ -1,9 +1,9 @@ | ||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||||||
|   <modelVersion>4.0.0</modelVersion> |   <modelVersion>4.0.0</modelVersion> | ||||||
|   <groupId>FPChatX</groupId> |   <groupId>FPChat</groupId> | ||||||
|   <artifactId>FPChatX</artifactId> |   <artifactId>FPChat</artifactId> | ||||||
|   <version>1.0.5-BETA</version> |   <version>1.1</version> | ||||||
|   <build> |   <build> | ||||||
|     <sourceDirectory>src/main/java</sourceDirectory> |     <sourceDirectory>src/main/java</sourceDirectory> | ||||||
|     <resources> |     <resources> | ||||||
|  | @ -58,59 +58,25 @@ | ||||||
|       <id>bungeecord-repo</id> |       <id>bungeecord-repo</id> | ||||||
|       <url>https://oss.sonatype.org/content/repositories/snapshots</url> |       <url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||||||
|     </repository> |     </repository> | ||||||
|     <repository> |  | ||||||
|       <id>placeholderapi</id> |  | ||||||
|       <url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url> |  | ||||||
|     </repository> |  | ||||||
|   </repositories> |   </repositories> | ||||||
|   <dependencies> |   <dependencies> | ||||||
|     <dependency> |     <dependency> | ||||||
|       <groupId>org.spigotmc</groupId> |       <groupId>org.spigotmc</groupId> | ||||||
|       <artifactId>spigot-api</artifactId> |       <artifactId>spigot-api</artifactId> | ||||||
|       <version>1.15.1-R0.1-SNAPSHOT</version> |       <version>1.16.2-R0.1-SNAPSHOT</version> | ||||||
|       <scope>compile</scope> |       <scope>compile</scope> | ||||||
|     </dependency> |     </dependency> | ||||||
|     <dependency> |  | ||||||
|       <groupId>org.bukkit</groupId> |  | ||||||
|       <artifactId>bukkit</artifactId> |  | ||||||
|       <version>1.15.1-R0.1-SNAPSHOT</version> |  | ||||||
|       <scope>compile</scope> |  | ||||||
|     </dependency> |  | ||||||
|     <dependency> |  | ||||||
|       <groupId>net.md-5</groupId> |  | ||||||
|       <artifactId>bungeecord-api</artifactId> |  | ||||||
|       <version>1.15-SNAPSHOT</version> |  | ||||||
|       <scope>provided</scope> |  | ||||||
|       <exclusions> |  | ||||||
|         <exclusion> |  | ||||||
|           <artifactId>bungeecord-config</artifactId> |  | ||||||
|           <groupId>net.md-5</groupId> |  | ||||||
|         </exclusion> |  | ||||||
|         <exclusion> |  | ||||||
|           <artifactId>bungeecord-event</artifactId> |  | ||||||
|           <groupId>net.md-5</groupId> |  | ||||||
|         </exclusion> |  | ||||||
|         <exclusion> |  | ||||||
|           <artifactId>bungeecord-protocol</artifactId> |  | ||||||
|           <groupId>net.md-5</groupId> |  | ||||||
|         </exclusion> |  | ||||||
|         <exclusion> |  | ||||||
|           <artifactId>netty-transport-native-unix-common</artifactId> |  | ||||||
|           <groupId>io.netty</groupId> |  | ||||||
|         </exclusion> |  | ||||||
|       </exclusions> |  | ||||||
|     </dependency> |  | ||||||
|     <dependency> |     <dependency> | ||||||
|       <groupId>com.github.MilkBowl</groupId> |       <groupId>com.github.MilkBowl</groupId> | ||||||
|       <artifactId>VaultAPI</artifactId> |       <artifactId>VaultAPI</artifactId> | ||||||
|       <version>1.7</version> |       <version>1.7</version> | ||||||
|       <scope>provided</scope> |       <scope>provided</scope> | ||||||
|     </dependency> |       <exclusions> | ||||||
|     <dependency> |         <exclusion> | ||||||
|       <groupId>me.clip</groupId> |           <artifactId>bukkit</artifactId> | ||||||
|       <artifactId>placeholderapi</artifactId> |           <groupId>org.bukkit</groupId> | ||||||
|       <version>2.10.4</version> |         </exclusion> | ||||||
|       <scope>provided</scope> |       </exclusions> | ||||||
|     </dependency> |     </dependency> | ||||||
|   </dependencies> |   </dependencies> | ||||||
| </project> | </project> | ||||||
|  |  | ||||||
							
								
								
									
										30
									
								
								pom.xml
								
								
								
								
							
							
						
						
									
										30
									
								
								pom.xml
								
								
								
								
							|  | @ -2,9 +2,9 @@ | ||||||
| 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
| 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||||
| 	<modelVersion>4.0.0</modelVersion> | 	<modelVersion>4.0.0</modelVersion> | ||||||
| 	<groupId>FPChatX</groupId> | 	<groupId>FPChat</groupId> | ||||||
| 	<artifactId>FPChatX</artifactId> | 	<artifactId>FPChat</artifactId> | ||||||
| 	<version>1.0.6-BETA</version> | 	<version>1.1</version> | ||||||
| 	<repositories> | 	<repositories> | ||||||
| 		<repository> | 		<repository> | ||||||
| 			<id>spigot-repo</id> | 			<id>spigot-repo</id> | ||||||
|  | @ -18,10 +18,6 @@ | ||||||
| 			<id>bungeecord-repo</id> | 			<id>bungeecord-repo</id> | ||||||
| 			<url>https://oss.sonatype.org/content/repositories/snapshots</url> | 			<url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||||||
| 		</repository> | 		</repository> | ||||||
| 		<repository> |  | ||||||
| 			<id>placeholderapi</id> |  | ||||||
| 			<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url> |  | ||||||
| 		</repository> |  | ||||||
| 	</repositories> | 	</repositories> | ||||||
| 	<build> | 	<build> | ||||||
| 		<sourceDirectory>src/main/java</sourceDirectory> | 		<sourceDirectory>src/main/java</sourceDirectory> | ||||||
|  | @ -75,19 +71,7 @@ | ||||||
| 		<dependency> | 		<dependency> | ||||||
| 			<groupId>org.spigotmc</groupId> | 			<groupId>org.spigotmc</groupId> | ||||||
| 			<artifactId>spigot-api</artifactId> | 			<artifactId>spigot-api</artifactId> | ||||||
| 			<version>1.15.1-R0.1-SNAPSHOT</version> | 			<version>1.16.2-R0.1-SNAPSHOT</version> | ||||||
| 		</dependency> |  | ||||||
| 		<dependency> |  | ||||||
| 			<groupId>org.bukkit</groupId> |  | ||||||
| 			<artifactId>bukkit</artifactId> |  | ||||||
| 			<version>1.15.1-R0.1-SNAPSHOT</version> |  | ||||||
| 		</dependency> |  | ||||||
| 		<dependency> |  | ||||||
| 			<groupId>net.md-5</groupId> |  | ||||||
| 			<artifactId>bungeecord-api</artifactId> |  | ||||||
| 			<version>1.15-SNAPSHOT</version> |  | ||||||
| 			<type>jar</type> |  | ||||||
| 			<scope>provided</scope> |  | ||||||
| 		</dependency> | 		</dependency> | ||||||
| 		<dependency> | 		<dependency> | ||||||
| 			<groupId>com.github.MilkBowl</groupId> | 			<groupId>com.github.MilkBowl</groupId> | ||||||
|  | @ -95,11 +79,5 @@ | ||||||
| 			<version>1.7</version> | 			<version>1.7</version> | ||||||
| 			<scope>provided</scope> | 			<scope>provided</scope> | ||||||
| 		</dependency> | 		</dependency> | ||||||
| 		<dependency> |  | ||||||
| 			<groupId>me.clip</groupId> |  | ||||||
| 			<artifactId>placeholderapi</artifactId> |  | ||||||
| 			<version>2.10.4</version> |  | ||||||
| 			<scope>provided</scope> |  | ||||||
| 		</dependency> |  | ||||||
| 	</dependencies> | 	</dependencies> | ||||||
| </project> | </project> | ||||||
|  | @ -14,7 +14,7 @@ import org.bukkit.plugin.java.JavaPlugin; | ||||||
| import org.bukkit.scheduler.BukkitRunnable; | import org.bukkit.scheduler.BukkitRunnable; | ||||||
| import org.bukkit.scheduler.BukkitTask; | import org.bukkit.scheduler.BukkitTask; | ||||||
| 
 | 
 | ||||||
| import com.fpghoti.fpchatx.badge.BadgeList; | import com.fpghoti.fpchatx.badge.Badge; | ||||||
| import com.fpghoti.fpchatx.chat.ChatChannel; | import com.fpghoti.fpchatx.chat.ChatChannel; | ||||||
| import com.fpghoti.fpchatx.chat.ChatFilter; | import com.fpghoti.fpchatx.chat.ChatFilter; | ||||||
| import com.fpghoti.fpchatx.chat.ShoutChannel; | import com.fpghoti.fpchatx.chat.ShoutChannel; | ||||||
|  | @ -54,9 +54,7 @@ import com.fpghoti.fpchatx.player.FPlayer; | ||||||
| import com.fpghoti.fpchatx.util.VaultUtil; | import com.fpghoti.fpchatx.util.VaultUtil; | ||||||
| 
 | 
 | ||||||
| public class FPChat extends JavaPlugin { | public class FPChat extends JavaPlugin { | ||||||
| 
 | 	private static Logger log = Logger.getLogger("FPChat"); | ||||||
| 	private static Logger log = Logger.getLogger("Minecraft"); |  | ||||||
| 	private static Logger chatLog = Logger.getLogger("FPChat"); |  | ||||||
| 	private MainConfig config; | 	private MainConfig config; | ||||||
| 	private MySQLConnection sql; | 	private MySQLConnection sql; | ||||||
| 	private static FPChat plugin; | 	private static FPChat plugin; | ||||||
|  | @ -85,10 +83,7 @@ public class FPChat extends JavaPlugin { | ||||||
| 		ChatChannel.loadChannels(); | 		ChatChannel.loadChannels(); | ||||||
| 		ChatChannel.setShout(new ShoutChannel(this)); | 		ChatChannel.setShout(new ShoutChannel(this)); | ||||||
| 		ChatChannel.setDefault(config.getDefaultChannel()); | 		ChatChannel.setDefault(config.getDefaultChannel()); | ||||||
| 		BadgeList.setupBadges(); | 		Badge.loadBadges(); | ||||||
| 		for(int i : BadgeList.badgelist.keySet()) { |  | ||||||
| 			BadgeList.badgelist.put(i, BadgeList.badgelist.get(i).replace("&", "§")); |  | ||||||
| 		} |  | ||||||
| 		cache = new PlayerCache(this); | 		cache = new PlayerCache(this); | ||||||
| 		ChatFilter.loadFilter(); | 		ChatFilter.loadFilter(); | ||||||
| 		for(Player bp : Bukkit.getOnlinePlayers()){ | 		for(Player bp : Bukkit.getOnlinePlayers()){ | ||||||
|  | @ -122,7 +117,6 @@ public class FPChat extends JavaPlugin { | ||||||
| 		for(FPlayer p : FPlayer.getPlayers()) { | 		for(FPlayer p : FPlayer.getPlayers()) { | ||||||
| 			p.cleanup(); | 			p.cleanup(); | ||||||
| 		} | 		} | ||||||
| 		BadgeList.purge(); |  | ||||||
| 		FPlayer.purge(); | 		FPlayer.purge(); | ||||||
| 		config = new MainConfig(this); | 		config = new MainConfig(this); | ||||||
| 		if(config.mySQLEnabled()) { | 		if(config.mySQLEnabled()) { | ||||||
|  | @ -133,10 +127,7 @@ public class FPChat extends JavaPlugin { | ||||||
| 		ChatChannel.loadChannels(); | 		ChatChannel.loadChannels(); | ||||||
| 		ChatChannel.setShout(new ShoutChannel(this)); | 		ChatChannel.setShout(new ShoutChannel(this)); | ||||||
| 		ChatChannel.setDefault(config.getDefaultChannel()); | 		ChatChannel.setDefault(config.getDefaultChannel()); | ||||||
| 		BadgeList.setupBadges(); | 		Badge.loadBadges(); | ||||||
| 		for(int i : BadgeList.badgelist.keySet()) { |  | ||||||
| 			BadgeList.badgelist.put(i, BadgeList.badgelist.get(i).replace("&", "§")); |  | ||||||
| 		} |  | ||||||
| 		cache = new PlayerCache(this); | 		cache = new PlayerCache(this); | ||||||
| 		ChatFilter.loadFilter(); | 		ChatFilter.loadFilter(); | ||||||
| 		for(Player bp : Bukkit.getOnlinePlayers()){ | 		for(Player bp : Bukkit.getOnlinePlayers()){ | ||||||
|  | @ -198,12 +189,12 @@ public class FPChat extends JavaPlugin { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void log(Level level, String msg) { | 	public void log(Level level, String msg) { | ||||||
| 		log.log(level, "[FPChatX] " + msg.replaceAll("§[0-9A-FK-OR]", "")); | 		log.log(level, "[FPChat] " + msg.replaceAll("§[0-9A-FK-OR]", "")); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	public void logChat(String msg) { | 	public void logChat(String msg) { | ||||||
| 		chatLog.info(msg.replaceAll("§[0-9A-FK-OR]", "")); | 		log.info(msg.replaceAll("§[0-9A-FK-OR]", "")); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public static FPChat getPlugin(){ | 	public static FPChat getPlugin(){ | ||||||
|  | @ -211,7 +202,7 @@ public class FPChat extends JavaPlugin { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public static String logo() { | 	public static String logo() { | ||||||
| 		return "" + ChatColor.DARK_RED + "[" + ChatColor.GREEN + ChatColor.BOLD + "FPChatX" + ChatColor.RESET + ChatColor.DARK_RED + "]" + ChatColor.RESET ; | 		return "" + ChatColor.DARK_RED + "[" + ChatColor.GREEN + ChatColor.BOLD + "FPChat" + ChatColor.RESET + ChatColor.DARK_RED + "]" + ChatColor.RESET ; | ||||||
| 
 | 
 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,84 @@ | ||||||
|  | package com.fpghoti.fpchatx.badge; | ||||||
|  | 
 | ||||||
|  | import com.fpghoti.fpchatx.FPChat; | ||||||
|  | import com.fpghoti.fpchatx.config.BadgeConfig; | ||||||
|  | 
 | ||||||
|  | public class Badge { | ||||||
|  | 	 | ||||||
|  | 	private static BadgeList badges; | ||||||
|  | 	private static BadgeConfig bconfig = null; | ||||||
|  | 	 | ||||||
|  | 	public static void loadBadges() { | ||||||
|  | 		 badges = new BadgeList(); | ||||||
|  | 		 bconfig = null; | ||||||
|  | 		 getBadgeConfig().loadBadges(badges); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public static BadgeConfig getBadgeConfig() { | ||||||
|  | 		if(bconfig == null) { | ||||||
|  | 			bconfig = new BadgeConfig(FPChat.getPlugin()); | ||||||
|  | 		} | ||||||
|  | 		return bconfig; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public static BadgeList getList() { | ||||||
|  | 		return badges; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private int id; | ||||||
|  | 	private String name; | ||||||
|  | 	private String contents; | ||||||
|  | 	private String perm; | ||||||
|  | 	private boolean enabled; | ||||||
|  | 	private int slotUnlock; | ||||||
|  | 	 | ||||||
|  | 	public Badge(int id, String name, String contents, String perm, boolean enabled) { | ||||||
|  | 		this(id, name, contents, perm, enabled, -1); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public Badge(int id, String name, String contents, String perm, boolean enabled, int slotUnlock) { | ||||||
|  | 		this.id = id; | ||||||
|  | 		this.name = name; | ||||||
|  | 		this.contents = contents.replace("&", "§"); | ||||||
|  | 		this.perm = perm; | ||||||
|  | 		this.enabled = enabled; | ||||||
|  | 		this.slotUnlock = slotUnlock; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public int getId() { | ||||||
|  | 		return this.id; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String getName() { | ||||||
|  | 		return this.name; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String getContents() { | ||||||
|  | 		return this.contents; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String getPerm() { | ||||||
|  | 		return "fpchat.badge." + perm; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String getRawPerm() { | ||||||
|  | 		return perm; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public boolean unlocksSlot(int slot) { | ||||||
|  | 		return slot == slotUnlock; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public int getSlotUnlock() { | ||||||
|  | 		return slotUnlock; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public boolean isEnabled() { | ||||||
|  | 		return enabled; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void setEnabled(boolean value) { | ||||||
|  | 		enabled = value; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -1,49 +0,0 @@ | ||||||
| package com.fpghoti.fpchatx.badge; |  | ||||||
| 
 |  | ||||||
| import java.util.UUID; |  | ||||||
| 
 |  | ||||||
| import com.fpghoti.fpchatx.FPChat; |  | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; |  | ||||||
| import com.fpghoti.fpchatx.util.Util; |  | ||||||
| 
 |  | ||||||
| public class BadgeGetter { |  | ||||||
| 
 |  | ||||||
| 	public static Integer[] getBadges(FPlayer p){ |  | ||||||
| 		UUID id = p.getUniqueId(); |  | ||||||
| 		String uuid = id.toString(); |  | ||||||
| 		Integer badge1 = 0, badge2 = 0, badge3 = 0; |  | ||||||
| 		Util.connect(); |  | ||||||
| 		if(!FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable())){ |  | ||||||
| 			BadgeSet.createPlayer(p); |  | ||||||
| 		} |  | ||||||
| 		badge1 = (Integer) FPChat.getPlugin().getMySQLConnection().get("badge_slot1", "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable()); |  | ||||||
| 		badge2 = (Integer)FPChat.getPlugin().getMySQLConnection().get("badge_slot2", "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable()); |  | ||||||
| 		badge3 = (Integer)FPChat.getPlugin().getMySQLConnection().get("badge_slot3", "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable()); |  | ||||||
| 		Integer[] badges = {badge1, badge2, badge3}; |  | ||||||
| 		return badges; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public static Boolean hasBadge(FPlayer p, int id){ |  | ||||||
| 		if(id == 0) { |  | ||||||
| 			return true; |  | ||||||
| 		} |  | ||||||
| 		return p.hasPermission("fpchat.badge" + BadgeList.badgeperm.get(id)) || p.isSynced(id); |  | ||||||
| 	} |  | ||||||
| 	 |  | ||||||
| 	public static Boolean canUseSlot(FPlayer p, int slotid){ |  | ||||||
| 		if(slotid == 1){ |  | ||||||
| 			return p.hasPermission("fpchat.slot1"); |  | ||||||
| 		}else if(slotid == 2){ |  | ||||||
| 			if(hasBadge(p,33) || hasBadge(p,34) || hasBadge(p,35) || hasBadge(p,52)){ |  | ||||||
| 				return true; |  | ||||||
| 			} |  | ||||||
| 			return p.hasPermission("fpchat.slot2"); |  | ||||||
| 		}else if(slotid == 3){ |  | ||||||
| 			if(hasBadge(p,53)){ |  | ||||||
| 				return true; |  | ||||||
| 			} |  | ||||||
| 			return p.hasPermission("fpchat.slot3"); |  | ||||||
| 		} |  | ||||||
| 		return false; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  | @ -1,324 +1,114 @@ | ||||||
| package com.fpghoti.fpchatx.badge; | package com.fpghoti.fpchatx.badge; | ||||||
| 
 | 
 | ||||||
| import java.util.HashMap; | import java.util.ArrayList; | ||||||
| import java.util.LinkedHashMap; | import java.util.Iterator; | ||||||
| 
 |  | ||||||
| import org.bukkit.ChatColor; |  | ||||||
| 
 |  | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; |  | ||||||
| 
 |  | ||||||
| public class BadgeList { |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	public static HashMap<Integer, String> badgelist = new LinkedHashMap<>(); | public class BadgeList implements Iterable<Badge>{ | ||||||
| 	public static HashMap<Integer, String> badgename = new LinkedHashMap<>(); |  | ||||||
| 	public static HashMap<Integer, String> badgeperm = new LinkedHashMap<>(); |  | ||||||
| 	 | 	 | ||||||
| 	public static HashMap<FPlayer, Integer> pageInstance = new HashMap<>(); | 	private ArrayList<Badge> list = new ArrayList<Badge>(); | ||||||
|  | 	private Badge empty = new Badge(0, "Empty", "", "", false); | ||||||
| 	 | 	 | ||||||
| 	 | 	@Override | ||||||
| 	public static void purge() { | 	public Iterator<Badge> iterator() { | ||||||
| 		badgelist = new LinkedHashMap<>(); | 		return new ArrayList<Badge>(list).iterator(); | ||||||
| 		badgename = new LinkedHashMap<>(); |  | ||||||
| 		badgeperm = new LinkedHashMap<>(); |  | ||||||
| 
 |  | ||||||
| 		pageInstance = new HashMap<>(); |  | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static void badgeList(FPlayer p , int page){ | 	public void add(Badge badge) { | ||||||
| 		p.sendMessage(""); | 		if(badge.getId() < 1) { | ||||||
| 		p.sendMessage(ChatColor.RED + "HOW TO USE:" + ChatColor.YELLOW + " You can equip badges with " + ChatColor.DARK_AQUA + "/equip <slot number> <badge number>" + ChatColor.YELLOW +". To unequip all badges, use " + ChatColor.DARK_AQUA + "/badgesclear" + ChatColor.YELLOW + "."); | 			return; | ||||||
| 		p.sendMessage(ChatColor.AQUA + "------------------- Your Badges -------------------"); |  | ||||||
| 		p.sendMessage(""); |  | ||||||
| 		int eventnum = 0; |  | ||||||
| 		//for(Integer item : badgelist.keySet()){ |  | ||||||
| 		for(int i = 0; i < badgelist.size(); i++){ |  | ||||||
| 				eventnum = eventnum + 1; |  | ||||||
| 		} | 		} | ||||||
| 		double dp = (float)eventnum / 10.0; | 		if(overwrites(badge)) { | ||||||
| 		int pagenum = (int)Math.ceil(dp); | 			remove(badge.getId()); | ||||||
| 		if(page <= pagenum && page > 0){ | 		} | ||||||
| 			pageInstance.put(p,0); | 		list.add(badge); | ||||||
| 			int pageten = (page * 10)- 10; | 	} | ||||||
| 			for(Integer entry : badgelist.keySet()){ | 	 | ||||||
| 				if(pageInstance.get(p) == pageten || pageInstance.get(p) == pageten + 1 || pageInstance.get(p) == pageten + 2 || pageInstance.get(p) == pageten + 3 || pageInstance.get(p) == pageten + 4 || pageInstance.get(p) == pageten + 5 || pageInstance.get(p) == pageten + 6 || pageInstance.get(p) == pageten + 7 || pageInstance.get(p) == pageten + 8 || pageInstance.get(p) == pageten + 9){ | 	public void remove(int id) { | ||||||
| 					if(entry == 0){ | 		ArrayList<Badge> rl = new ArrayList<Badge>(list); | ||||||
| 					}else if(p.hasPermission("fpchat.badge" + badgeperm.get(entry)) || p.isSynced(entry)){ | 		for(Badge b : rl) { | ||||||
| 						p.sendMessage(badgelist.get(entry) + ChatColor.GOLD + " Badge #" + entry + ": " + ChatColor.GREEN + " - " + badgename.get(entry) + ChatColor.GOLD + " - UNLOCKED"); | 			if(b.getId() == id) { | ||||||
| 					}else{ | 				list.remove(b); | ||||||
| 						p.sendMessage(badgelist.get(entry) + ChatColor.GOLD + " Badge #" + entry + ": " + ChatColor.GREEN + " - " + badgename.get(entry) + ChatColor.RED + " - LOCKED"); |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 				pageInstance.put(p,(pageInstance.get(p)+1)); |  | ||||||
| 			} | 			} | ||||||
| 			p.sendMessage(ChatColor.AQUA + ""); |  | ||||||
| 			p.sendMessage(ChatColor.YELLOW + "Page " + Integer.toString(page) + " of " + Integer.toString(pagenum)); |  | ||||||
| 			p.sendMessage(ChatColor.AQUA + "---------------------------------------------------"); |  | ||||||
| 			pageInstance.remove(p); |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static void setupBadges(){ | 	public void remove(Badge badge) { | ||||||
| 		 | 		remove(badge.getId()); | ||||||
| 		//DO NOT CHANGE ANY OF THE BADGEID NUMBERS. THIS WILL REALLY SCREW UP PEOPLES BADGE PERMISSIONS IN GAME. I WILL SOON ADD SOMETHING FOR PEOPLE TO MORE EASILY SEE THEIR UNLOCKED BADGES |  | ||||||
| 		 |  | ||||||
| 		//These are the designs used in game of each badge |  | ||||||
| 		 |  | ||||||
| 		badgelist.put(0, ""); |  | ||||||
| 		badgelist.put(1, "&6{✮}"); |  | ||||||
| 		badgelist.put(2, "&b{&7❂&b}"); |  | ||||||
| 		badgelist.put(3, "&c[0G]"); |  | ||||||
| 		badgelist.put(4, "&8{&9Ⓜ&8}"); |  | ||||||
| 		badgelist.put(5, "&b(✌)"); |  | ||||||
| 		badgelist.put(6, "&3{☹}"); |  | ||||||
| 		badgelist.put(7, "&4<&8➳&4>"); |  | ||||||
| 		badgelist.put(8, "&a(รɦṁ)"); |  | ||||||
| 		badgelist.put(9, "&e[Ⓒ]"); |  | ||||||
| 		badgelist.put(10, "&8[&f☠&8]"); |  | ||||||
| 		badgelist.put(11, "&b{&f☃&b}"); |  | ||||||
| 		badgelist.put(12, "&d{&6❀&d}"); |  | ||||||
| 		badgelist.put(13, "&e<&a☣&e>"); |  | ||||||
| 		badgelist.put(14, "&5(&3☔&5)"); |  | ||||||
| 		badgelist.put(15, "&a{☎}"); |  | ||||||
| 		badgelist.put(16, "&7{&b♫&7}"); |  | ||||||
| 		badgelist.put(17, "&e<&6⚡&e>"); |  | ||||||
| 		badgelist.put(18, "&3(&c⍤&3)"); |  | ||||||
| 		badgelist.put(19, "&f[&c♛&f]"); |  | ||||||
| 		badgelist.put(20, "&b[&a✦&b]"); |  | ||||||
| 		badgelist.put(21, "&e[&7♜&e]"); |  | ||||||
| 		badgelist.put(22, "&6[&7⚒&6]"); |  | ||||||
| 		badgelist.put(23, "&3[&7❖&3]"); |  | ||||||
| 		badgelist.put(24, "&2[&7⧈&2]"); |  | ||||||
| 		badgelist.put(25, "&5(&d⚉&5)"); |  | ||||||
| 		badgelist.put(26, "&1[&4β&1]"); |  | ||||||
| 		badgelist.put(27, "&b{&3&lᴮᵀ&b}"); |  | ||||||
| 		badgelist.put(28, "&c{&b&lᴴᴮᵀ&c}"); |  | ||||||
| 		badgelist.put(29, "&8{&6&lᴮ&a&lᵒ&6&lᵒ&8}"); |  | ||||||
| 		badgelist.put(30, "&3<&eᵒᵒᶠ&3>"); |  | ||||||
| 		badgelist.put(31, "&b&l{&f&l✔&b&l}"); |  | ||||||
| 		badgelist.put(32, "&a|PR0|"); |  | ||||||
| 		badgelist.put(33, "&1⦅&b&lx2&r&1⦆"); |  | ||||||
| 		badgelist.put(34, "&a«&2&lx2&r&a»"); |  | ||||||
| 		badgelist.put(35, "&e⦉&6x2&e⦊"); |  | ||||||
| 		badgelist.put(36, "&6﴾&cⰀ&6﴿"); |  | ||||||
| 		badgelist.put(37, "&7﴾※﴿"); |  | ||||||
| 		badgelist.put(38, "&7⌈&f◉&d⩐&f◉&7⌉"); |  | ||||||
| 		badgelist.put(39, "&8[&7༗&8]"); |  | ||||||
| 		badgelist.put(40, "&8[&bⒺ➀&8]"); |  | ||||||
| 		badgelist.put(41, "&8[&eⒺ➁&8]"); |  | ||||||
| 		badgelist.put(42, "&8[&2Ⓔ➂&8]"); |  | ||||||
| 		badgelist.put(43, "&8[&6Ⓔ&c➃&8]"); |  | ||||||
| 		badgelist.put(44, "&8[&bⒺ&a➄&8]"); |  | ||||||
| 		badgelist.put(45, "&8[&cⒺ&b➅&8]"); |  | ||||||
| 		badgelist.put(46, "&5{&dᴠɪᴘ&5}"); |  | ||||||
| 		badgelist.put(47, "&5{&4ᴠ&eɪ&9ᴘ&a⁺&5}"); |  | ||||||
| 		badgelist.put(48, "&6{&bᴠ&c⁺&a⁺&6}"); |  | ||||||
| 		badgelist.put(49, "&3{&bᴛᴏᴘ&3}"); |  | ||||||
| 		badgelist.put(50, "&6{&eᴘʟᴀᴛ&6}"); |  | ||||||
| 		badgelist.put(51, "&8{&7ᴛɪ&8}"); |  | ||||||
| 		badgelist.put(52, "&c⦉&4x2&c⦊"); |  | ||||||
| 		badgelist.put(53, "&b⦅&1&lx3&r&b⦆"); |  | ||||||
| 		badgelist.put(54, "&8[&5✥&8]"); |  | ||||||
| 		badgelist.put(55, "&8{&bⒶ&8}"); |  | ||||||
| 		badgelist.put(56, "&8{&3ᴼᴾ&8}"); |  | ||||||
| 		badgelist.put(57, "&8{&4&l♔&8}"); |  | ||||||
| 		badgelist.put(58, "&7{&9☯&7}"); |  | ||||||
| 		badgelist.put(59, "&f⟦&6&o&l0G&8&f⟧"); |  | ||||||
| 		badgelist.put(60, "&6ヽ( •_)ᕗ"); |  | ||||||
| 		badgelist.put(61, "&c⦇&6☕&c⦈"); |  | ||||||
| 		badgelist.put(62, "&b&l⦍&c&lF&b&l⦐"); |  | ||||||
| 		badgelist.put(63, "&a⦇&e⧔⧕&d⦈"); |  | ||||||
| 		badgelist.put(64, "&2[&c❒&2]"); |  | ||||||
| 		badgelist.put(65, "&4{&e▼&4}"); |  | ||||||
| 		badgelist.put(66, "&e{&d☞&e}"); |  | ||||||
| 		badgelist.put(67, "&f<&7✄&f>"); |  | ||||||
| 		badgelist.put(68, "&5⸨&d◕‿‿◕&5⸩"); |  | ||||||
| 		badgelist.put(69, "&d⌇&4❤&d⌇"); |  | ||||||
| 		badgelist.put(70, "&6ʕ•ᴥ•ʔ"); |  | ||||||
| 		badgelist.put(71, "&f<&9☆彡&f>"); |  | ||||||
| 		badgelist.put(72, "&a(&5✿&a}"); |  | ||||||
| 		badgelist.put(73, "&a&k!&e&k!&c&k!&b&k!&c&k!&e&k!&a&k!&r"); |  | ||||||
| 		badgelist.put(74, "&a[&f[&6Ⱑ&f]&a]"); |  | ||||||
| 		badgelist.put(75, "&4]&8⸮&4["); |  | ||||||
| 		badgelist.put(76, "&0【&7&l〆&r&0】"); |  | ||||||
| 		badgelist.put(77, "&9[&2⸙&9]"); |  | ||||||
| 		badgelist.put(78, "&8⸠⨷⸡"); |  | ||||||
| 		badgelist.put(79, "&a⦑&4⚐&9⚑&a⦒"); |  | ||||||
| 		badgelist.put(80, "p"); |  | ||||||
| 		 |  | ||||||
| 		// These are the badge names listed in the badge menu. |  | ||||||
| 		// See notes here for possible badge uses |  | ||||||
| 		 |  | ||||||
| 		badgename.put(0, "Empty"); //Represents an empty badge slot. Equipping removes whatever badge is in that slot. |  | ||||||
| 		badgename.put(1, "Gold Star"); //We have given these to people who win contests or in game events we have |  | ||||||
| 		badgename.put(2, "Silver Star"); //We've used this as a voting reward in the past |  | ||||||
| 		badgename.put(3, "Original Player"); //I've tried to reserve this one but people started giving it out, but we can still give this to old donors. |  | ||||||
| 		badgename.put(4, "Staff"); //Staff only |  | ||||||
| 		badgename.put(5, "Peace"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(6, "Boo-hoo"); //Obtainable by easter egg in one of the spawn vaults |  | ||||||
| 		badgename.put(7, "Hunter"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(8, "Shmeckle"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(9, "Copyright"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(10, "Skull"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(11, "Snowman"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(12, "Flower"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(13, "Radioactive"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(14, "Rainy"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(15, "Telephone"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(16, "Music"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(17, "Lightning"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(18, "Wow"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(19, "Monarch"); //Give to old creative donor with Monarch |  | ||||||
| 		badgename.put(20, "Baron"); //Give to old creative donor with Baron |  | ||||||
| 		badgename.put(21, "Artificer"); // Give to old creative donor with Artificer |  | ||||||
| 		badgename.put(22, "Craftsman"); // Give to old creative donor with Craftsman |  | ||||||
| 		badgename.put(23, "Journeyman"); // Give to old creative donor with Journeyman |  | ||||||
| 		badgename.put(24, "Carpenter"); // Give to old creative donor with Carpenter |  | ||||||
| 		badgename.put(25, "Pig"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(26, "Beta"); // Reserve for contests or special gift from staff |  | ||||||
| 		badgename.put(27, "Build Team"); // Reserve for Build team |  | ||||||
| 		badgename.put(28, "Head Builder"); // May not have any use anymore, but not really something for players |  | ||||||
| 		badgename.put(29, "Boo"); //Sell in-game or on the donor shop (OR give to players at Halloween) |  | ||||||
| 		badgename.put(30, "OOF!"); //Obtainable easteregg |  | ||||||
| 		badgename.put(31, "Trusted / Verified Player"); //Give to trusted/ex staff/ build team |  | ||||||
| 		badgename.put(32, "Professional Player"); //Can make a reward for parkour. We've associated this badge with an achievement in the past |  | ||||||
| 		badgename.put(33, "x2 Slots (Blue)"); // Anyone with this badge can equip a badge to a second slot |  | ||||||
| 		badgename.put(34, "x2 Slots (Green)"); // Same as #33 but green |  | ||||||
| 		badgename.put(35, "x2 Slots (Yellow)"); // same as #33 and #34 but yellow |  | ||||||
| 		badgename.put(36, "Gilded Crest"); //I've typically only given this one to staff |  | ||||||
| 		badgename.put(37, "Silver Crest"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(38, "Derp"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(39, "Hawk-Eye");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(40, "Expert Level 1"); // Survival can make unlockable with rank progression |  | ||||||
| 		badgename.put(41, "Expert Level 2"); // Survival can make unlockable with rank progression |  | ||||||
| 		badgename.put(42, "Expert Level 3"); // Survival can make unlockable with rank progression |  | ||||||
| 		badgename.put(43, "Expert Level 4"); // Survival can make unlockable with rank progression |  | ||||||
| 		badgename.put(44, "Expert Level 5"); // Survival can make unlockable with rank progression |  | ||||||
| 		badgename.put(45, "Expert Level 6"); // Survival can make unlockable with rank progression |  | ||||||
| 		badgename.put(46, "VIP"); // Give to old main donors |  | ||||||
| 		badgename.put(47, "VIP+"); // Give to old main donors |  | ||||||
| 		badgename.put(48, "VIP++"); // Give to old main donors |  | ||||||
| 		badgename.put(49, "Topaz"); // Give to old main donors |  | ||||||
| 		badgename.put(50, "Platinum"); // Give to old main donors |  | ||||||
| 		badgename.put(51, "Titanium"); // Give to old main donors |  | ||||||
| 		badgename.put(52, "x2 Slots (Red)"); // Same as #33, #34, and #35 but red |  | ||||||
| 		badgename.put(53, "x3 Slots (Blue)"); // Anyone with this badge can equip 3 badges |  | ||||||
| 		badgename.put(54, "Architect"); //Can make unlockable on creative |  | ||||||
| 		badgename.put(55, "Admin"); // Reserved for staff |  | ||||||
| 		badgename.put(56, "Operator"); // Reserved for staff |  | ||||||
| 		badgename.put(57, "Owner"); // I wonder who this is for |  | ||||||
| 		badgename.put(58, "PvP Legend"); // Can give to old PvP donors and maybe even kitpvp donors |  | ||||||
| 		badgename.put(59, "Gold OG"); // Can give to old donors who had some of the higher ranks |  | ||||||
| 		badgename.put(60, "Dab"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(61, "Coffee"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(62, "F"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(63, "Candy"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(64, "Box"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(65, "Pizza"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(66, "Pointer"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(67, "Scissors"); //Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(68, "Grin");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(69, "Heart"); //Can give away for Valentine's day |  | ||||||
| 		badgename.put(70, "Bear");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(71, "Comet");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(72, "Tropical Flower");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(73, "Magic");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(74, "Sealed");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(75, "Backwards");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(76, "Dagger");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(77, "Leaf");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(78, "Starship");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(79, "Flags");//Sell in-game or on the donor shop |  | ||||||
| 		badgename.put(80, "Stunned");//Sell in-game or on the donor shop |  | ||||||
| 		 |  | ||||||
| 		 |  | ||||||
| 		// BADGE PERMS |  | ||||||
| 		// These are the specific perm for each badge. They go like this: |  | ||||||
| 		// fpchat.badge.<badgeperm>   I.E fpchat.badge.goldstar |  | ||||||
| 		// See notes above for badges use ideas |  | ||||||
| 		 |  | ||||||
| 		badgeperm.put(0, ""); |  | ||||||
| 		badgeperm.put(1, ".goldstar"); |  | ||||||
| 		badgeperm.put(2, ".silverstar"); |  | ||||||
| 		badgeperm.put(3, ".og"); |  | ||||||
| 		badgeperm.put(4, ".staff"); |  | ||||||
| 		badgeperm.put(5, ".peace"); |  | ||||||
| 		badgeperm.put(6, ".boohoo"); |  | ||||||
| 		badgeperm.put(7, ".hunter"); |  | ||||||
| 		badgeperm.put(8, ".shmeckle"); |  | ||||||
| 		badgeperm.put(9, ".copyright"); |  | ||||||
| 		badgeperm.put(10, ".skull"); |  | ||||||
| 		badgeperm.put(11, ".snowman"); |  | ||||||
| 		badgeperm.put(12, ".flower"); |  | ||||||
| 		badgeperm.put(13, ".radioactive"); |  | ||||||
| 		badgeperm.put(14, ".rainy"); |  | ||||||
| 		badgeperm.put(15, ".telephone"); |  | ||||||
| 		badgeperm.put(16, ".music"); |  | ||||||
| 		badgeperm.put(17, ".lightning"); |  | ||||||
| 		badgeperm.put(18, ".wow"); |  | ||||||
| 		badgeperm.put(19, ".monarch"); |  | ||||||
| 		badgeperm.put(20, ".baron"); |  | ||||||
| 		badgeperm.put(21, ".artificer"); |  | ||||||
| 		badgeperm.put(22, ".craftsman"); |  | ||||||
| 		badgeperm.put(23, ".journeyman"); |  | ||||||
| 		badgeperm.put(24, ".carpenter"); |  | ||||||
| 		badgeperm.put(25, ".pig"); |  | ||||||
| 		badgeperm.put(26, ".fpn"); |  | ||||||
| 		badgeperm.put(27, ".bt"); |  | ||||||
| 		badgeperm.put(28, ".hbt"); |  | ||||||
| 		badgeperm.put(29, ".boo"); |  | ||||||
| 		badgeperm.put(30, ".oof"); |  | ||||||
| 		badgeperm.put(31, ".verified"); |  | ||||||
| 		badgeperm.put(32, ".pro"); |  | ||||||
| 		badgeperm.put(33, ".2blue"); |  | ||||||
| 		badgeperm.put(34, ".2green"); |  | ||||||
| 		badgeperm.put(35, ".2yellow"); |  | ||||||
| 		badgeperm.put(36, ".gildedcrest"); |  | ||||||
| 		badgeperm.put(37, ".silvercrest"); |  | ||||||
| 		badgeperm.put(38, ".derp"); |  | ||||||
| 		badgeperm.put(39, ".hawkeye"); |  | ||||||
| 		badgeperm.put(40, ".expert1"); |  | ||||||
| 		badgeperm.put(41, ".expert2"); |  | ||||||
| 		badgeperm.put(42, ".expert3"); |  | ||||||
| 		badgeperm.put(43, ".expert4"); |  | ||||||
| 		badgeperm.put(44, ".expert5"); |  | ||||||
| 		badgeperm.put(45, ".expert6"); |  | ||||||
| 		badgeperm.put(46, ".vip"); |  | ||||||
| 		badgeperm.put(47, ".vip+"); |  | ||||||
| 		badgeperm.put(48, ".vip++"); |  | ||||||
| 		badgeperm.put(49, ".topaz"); |  | ||||||
| 		badgeperm.put(50, ".platinum"); |  | ||||||
| 		badgeperm.put(51, ".titanium"); |  | ||||||
| 		badgeperm.put(52, ".2red"); |  | ||||||
| 		badgeperm.put(53, ".3blue"); |  | ||||||
| 		badgeperm.put(54, ".architect"); |  | ||||||
| 		badgeperm.put(55, ".admin"); |  | ||||||
| 		badgeperm.put(56, ".operator"); |  | ||||||
| 		badgeperm.put(57, ".owner"); |  | ||||||
| 		badgeperm.put(58, ".pvplegend"); |  | ||||||
| 		badgeperm.put(59, ".goldog"); |  | ||||||
| 		badgeperm.put(60, ".dab"); |  | ||||||
| 		badgeperm.put(61, ".coffee"); |  | ||||||
| 		badgeperm.put(62, ".f"); |  | ||||||
| 		badgeperm.put(63, ".candy"); |  | ||||||
| 		badgeperm.put(64, ".box"); |  | ||||||
| 		badgeperm.put(65, ".pizza"); |  | ||||||
| 		badgeperm.put(66, ".pointer"); |  | ||||||
| 		badgeperm.put(67, ".scissors"); |  | ||||||
| 		badgeperm.put(68, ".grin"); |  | ||||||
| 		badgeperm.put(69, ".heart"); |  | ||||||
| 		badgeperm.put(70, ".bear"); |  | ||||||
| 		badgeperm.put(71, ".comet"); |  | ||||||
| 		badgeperm.put(72, ".tropicalflower"); |  | ||||||
| 		badgeperm.put(73, ".magic"); |  | ||||||
| 		badgeperm.put(74, ".sealed"); |  | ||||||
| 		badgeperm.put(75, ".backwards"); |  | ||||||
| 		badgeperm.put(76, ".dagger"); |  | ||||||
| 		badgeperm.put(77, ".leaf"); |  | ||||||
| 		badgeperm.put(78, ".starship"); |  | ||||||
| 		badgeperm.put(79, ".flags"); |  | ||||||
| 		badgeperm.put(80, ".stunned"); |  | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public boolean containsId(int id) { | ||||||
|  | 		for(Badge b : list) { | ||||||
|  | 			if(b.getId() == id) { | ||||||
|  | 				return true; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return false; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public boolean overwrites(Badge badge) { | ||||||
|  | 		return containsId(badge.getId()); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public Badge get(int id) { | ||||||
|  | 		if(id <= 0 || !containsId(id)) { | ||||||
|  | 			return empty; | ||||||
|  | 		} | ||||||
|  | 		for(Badge b : list) { | ||||||
|  | 			if(b.getId() == id) { | ||||||
|  | 				return b; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return empty; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public Badge getIndex(int index) { | ||||||
|  | 		return list.get(index); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public int getLastId() { | ||||||
|  | 		int last = 0; | ||||||
|  | 		for(Badge b : list) { | ||||||
|  | 			int id = b.getId(); | ||||||
|  | 			if(id > last) { | ||||||
|  | 				last = id; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return last; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public int getListSize() { | ||||||
|  | 		return list.size(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public int size() { | ||||||
|  | 		return getLastId() + 1; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public boolean isEmpty() { | ||||||
|  | 		return list.isEmpty(); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public BadgeList getEnabledBadges() { | ||||||
|  | 		BadgeList enabled = new BadgeList(); | ||||||
|  | 		for(int i = 0; i < size(); i++) { | ||||||
|  | 			Badge b = get(i); | ||||||
|  | 			if(b.isEnabled()) { | ||||||
|  | 				enabled.add(b); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return enabled; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public BadgeList getSlotUnlockBadges(int slot) { | ||||||
|  | 		BadgeList slotBadges = new BadgeList(); | ||||||
|  | 		for(int i = 0; i < size(); i++) { | ||||||
|  | 			Badge b = get(i); | ||||||
|  | 			if(b.isEnabled() && b.getSlotUnlock() == slot) { | ||||||
|  | 				slotBadges.add(b); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return slotBadges; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,32 +0,0 @@ | ||||||
| package com.fpghoti.fpchatx.badge; |  | ||||||
| 
 |  | ||||||
| import com.fpghoti.fpchatx.FPChat; |  | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; |  | ||||||
| import com.fpghoti.fpchatx.util.Util; |  | ||||||
| 
 |  | ||||||
| public class BadgeSet { |  | ||||||
| 
 |  | ||||||
| 	public static void setBadge(FPlayer p, int slot, int badgeId){ |  | ||||||
| 		if(slot > 3){ |  | ||||||
| 			slot = 3; |  | ||||||
| 		}else if(slot < 1){ |  | ||||||
| 			slot = 1; |  | ||||||
| 		} |  | ||||||
| 		String uuid = p.getUniqueId().toString(); |  | ||||||
| 		Util.connect(); |  | ||||||
| 		if(!FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable())){ |  | ||||||
| 			createPlayer(p); |  | ||||||
| 		} |  | ||||||
| 		FPChat.getPlugin().getMySQLConnection().set("badge_slot" + String.valueOf(slot), badgeId, "player_uuid", "=", uuid,  FPChat.getPlugin().getMainConfig().getChatFeatureTable()); |  | ||||||
| 		BadgeGetter.getBadges(p); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public static void createPlayer(FPlayer p){ |  | ||||||
| 		String uuid = p.getUniqueId().toString(); |  | ||||||
| 		Util.connect(); |  | ||||||
| 		if(!FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable())){ |  | ||||||
| 			FPChat.getPlugin().getMySQLConnection().insertInto("player_uuid, badge_slot1, badge_slot2, badge_slot3", " '" + uuid + "', '0', '0', '0' ",  FPChat.getPlugin().getMainConfig().getChatFeatureTable()); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
|  | @ -0,0 +1,96 @@ | ||||||
|  | package com.fpghoti.fpchatx.badge; | ||||||
|  | 
 | ||||||
|  | public class DefaultBadges { | ||||||
|  | 	 | ||||||
|  | 	private static void populate(BadgeList badges) { | ||||||
|  | 		 | ||||||
|  | 		badges.add(new Badge(1, "Gold Star", "&6{✮}", "goldstar", true)); | ||||||
|  | 		badges.add(new Badge(2, "Silver Star", "&b{&7❂&b}", "silverstar", true)); | ||||||
|  | 		badges.add(new Badge(3, "OG", "&c[0G]", "og", true)); | ||||||
|  | 		badges.add(new Badge(4, "Staff", "&8{&9Ⓜ&8}", "staff", true)); | ||||||
|  | 		badges.add(new Badge(5, "Peace", "&b(✌)", "peace", true)); | ||||||
|  | 		badges.add(new Badge(6, "Boo-hoo", "&3{☹}", "boohoo", true)); | ||||||
|  | 		badges.add(new Badge(7, "Hunter", "&4<&8➳&4>", "hunter", true)); | ||||||
|  | 		badges.add(new Badge(8, "Shmeckle", "&a(รɦṁ)", "shmeckle", true)); | ||||||
|  | 		badges.add(new Badge(9, "Copyright", "&e[Ⓒ]", "copyright", true)); | ||||||
|  | 		badges.add(new Badge(10, "Skull", "&8[&f☠&8]", "skull", true)); | ||||||
|  | 		badges.add(new Badge(11, "Snowman", "&b{&f☃&b}", "snowman", true)); | ||||||
|  | 		badges.add(new Badge(12, "Flower", "&d{&6❀&d}", "flower", true)); | ||||||
|  | 		badges.add(new Badge(13, "Radioactive", "&e<&a☣&e>", "radioactive", true)); | ||||||
|  | 		badges.add(new Badge(14, "Rainy", "&5(&3☔&5)", "rainy", true)); | ||||||
|  | 		badges.add(new Badge(15, "Telephone", "&a{☎}", "telephone", true)); | ||||||
|  | 		badges.add(new Badge(16, "Music", "&7{&b♫&7}", "music", true)); | ||||||
|  | 		badges.add(new Badge(17, "Lightning", "&e<&6⚡&e>", "lightning", true)); | ||||||
|  | 		badges.add(new Badge(18, "Wow", "&3(&c⍤&3)", "wow", true)); | ||||||
|  | 		badges.add(new Badge(19, "Monarch", "&f[&c♛&f]", "monarch", true)); | ||||||
|  | 		badges.add(new Badge(20, "Green Sparkle", "&b[&a✦&b]", "greensparkle", true)); | ||||||
|  | 		badges.add(new Badge(21, "Castle", "&e[&7♜&e]", "castle", true)); | ||||||
|  | 		badges.add(new Badge(22, "Tools", "&6[&7⚒&6]", "tools", true)); | ||||||
|  | 		badges.add(new Badge(23, "Window", "&3[&7❖&3]", "window", true)); | ||||||
|  | 		badges.add(new Badge(24, "Squares", "&2[&7⧈&2]", "squares", true)); | ||||||
|  | 		badges.add(new Badge(25, "Pig", "&5(&d⚉&5)", "pig", true)); | ||||||
|  | 		badges.add(new Badge(26, "Beta", "&1[&4β&1]", "beta", true)); | ||||||
|  | 		badges.add(new Badge(27, "Build Team", "&b{&3&lᴮᵀ&b}", "buildteam", true)); | ||||||
|  | 		badges.add(new Badge(28, "Head Builder", "&c{&b&lᴴᴮᵀ&c}", "headbuildteam", true)); | ||||||
|  | 		badges.add(new Badge(29, "Boo", "&8{&6&lᴮ&a&lᵒ&6&lᵒ&8}", "boo", true)); | ||||||
|  | 		badges.add(new Badge(30, "OOF!", "&3<&eᵒᵒᶠ&3>", "oof", true)); | ||||||
|  | 		badges.add(new Badge(31, "Verified", "&b&l{&f&l✔&b&l}", "verified", true)); | ||||||
|  | 		badges.add(new Badge(32, "Pro", "&a|PR0|", "pro", true)); | ||||||
|  | 		badges.add(new Badge(33, "x2 Slots (Blue)", "&1⦅&b&lx2&r&1⦆", "2blue", true, 2)); | ||||||
|  | 		badges.add(new Badge(34, "x2 Slots (Green)", "&a«&2&lx2&r&a»", "2green", true, 2)); | ||||||
|  | 		badges.add(new Badge(35, "x2 Slots (Yellow)", "&e⦉&6x2&e⦊", "2yellow", true, 2)); | ||||||
|  | 		badges.add(new Badge(36, "Gilded Crest", "&6﴾&cⰀ&6﴿", "gildedcrest", true)); | ||||||
|  | 		badges.add(new Badge(37, "Silver Crest", "&7﴾※﴿", "silvercrest", true)); | ||||||
|  | 		badges.add(new Badge(38, "Derp", "&7⌈&f◉&d⩐&f◉&7⌉", "derp", true)); | ||||||
|  | 		badges.add(new Badge(39, "Hawk-Eye", "&8[&7༗&8]", "hawkeye", true)); | ||||||
|  | 		badges.add(new Badge(40, "Expert Level 1", "&8[&bⒺ➀&8]", "expert1", true)); | ||||||
|  | 		badges.add(new Badge(41, "Expert Level 2", "&8[&eⒺ➁&8]", "expert2", true)); | ||||||
|  | 		badges.add(new Badge(42, "Expert Level 3", "&8[&2Ⓔ➂&8]", "expert3", true)); | ||||||
|  | 		badges.add(new Badge(43, "Expert Level 4", "&8[&6Ⓔ&c➃&8]", "expert4", true)); | ||||||
|  | 		badges.add(new Badge(44, "Expert Level 5", "&8[&bⒺ&a➄&8]", "expert5", true)); | ||||||
|  | 		badges.add(new Badge(45, "Expert Level 6", "&8[&cⒺ&b➅&8]", "expert6", true)); | ||||||
|  | 		badges.add(new Badge(46, "VIP", "&5{&dᴠɪᴘ&5}", "vip", true)); | ||||||
|  | 		badges.add(new Badge(47, "Super VIP", "&5{&4ᴠ&eɪ&9ᴘ&a⁺&5}", "supervip", true)); | ||||||
|  | 		badges.add(new Badge(48, "Ultra VIP", "&6{&bᴠ&c⁺&a⁺&6}", "ultravip", true)); | ||||||
|  | 		badges.add(new Badge(49, "Top Player", "&3{&bᴛᴏᴘ&3}", "topplayer", true)); | ||||||
|  | 		badges.add(new Badge(50, "Platinum", "&6{&eᴘʟᴀᴛ&6}", "platinum", true)); | ||||||
|  | 		badges.add(new Badge(51, "Titanium", "&8{&7ᴛɪ&8}", "titanium", true)); | ||||||
|  | 		badges.add(new Badge(52, "x2 Slots (Red)", "&c⦉&4x2&c⦊", "2red", true, 2)); | ||||||
|  | 		badges.add(new Badge(53, "x3 Slots (Blue)", "&b⦅&1&lx3&r&b⦆", "3blue", true, 3)); | ||||||
|  | 		badges.add(new Badge(54, "Architect", "&8[&5✥&8]", "architect", true)); | ||||||
|  | 		badges.add(new Badge(55, "Admin", "&8{&bⒶ&8}", "admin", true)); | ||||||
|  | 		badges.add(new Badge(56, "Operator", "&8{&3ᴼᴾ&8}", "operator", true)); | ||||||
|  | 		badges.add(new Badge(57, "Owner", "&8{&4&l♔&8}", "owner", true)); | ||||||
|  | 		badges.add(new Badge(58, "PvP Legend", "&7{&9☯&7}", "pvplegend", true)); | ||||||
|  | 		badges.add(new Badge(59, "Gold OG", "&f⟦&6&o&l0G&8&f⟧", "goldog", true)); | ||||||
|  | 		badges.add(new Badge(60, "Dab", "&6ヽ( •_)ᕗ", "dab", true)); | ||||||
|  | 		badges.add(new Badge(61, "Coffee", "&c⦇&6☕&c⦈", "coffee", true)); | ||||||
|  | 		badges.add(new Badge(62, "F", "&b&l⦍&c&lF&b&l⦐", "f", true)); | ||||||
|  | 		badges.add(new Badge(63, "Candy", "&a⦇&e⧔⧕&d⦈", "candy", true)); | ||||||
|  | 		badges.add(new Badge(64, "Box", "&2[&c❒&2]", "box", true)); | ||||||
|  | 		badges.add(new Badge(65, "Pizza", "&4{&e▼&4}", "pizza", true)); | ||||||
|  | 		badges.add(new Badge(66, "Pointer", "&e{&d☞&e}", "pointer", true)); | ||||||
|  | 		badges.add(new Badge(67, "Scissors", "&f<&7✄&f>", "scissors", true)); | ||||||
|  | 		badges.add(new Badge(68, "Grin", "&5⸨&d◕‿‿◕&5⸩", "grin", true)); | ||||||
|  | 		badges.add(new Badge(69, "Heart", "&d⌇&4❤&d⌇", "heart", true)); | ||||||
|  | 		badges.add(new Badge(70, "Bear", "&6ʕ•ᴥ•ʔ", "bear", true)); | ||||||
|  | 		badges.add(new Badge(71, "Comet", "&f<&9☆彡&f>", "comet", true)); | ||||||
|  | 		badges.add(new Badge(72, "Tropical Flower", "&a(&5✿&a}", "tropicalflower", true)); | ||||||
|  | 		badges.add(new Badge(73, "Magic", "&a&k!&e&k!&c&k!&b&k!&c&k!&e&k!&a&k!&r", "magic", true)); | ||||||
|  | 		badges.add(new Badge(74, "Sealed", "&a[&f[&6Ⱑ&f]&a]", "sealed", true)); | ||||||
|  | 		badges.add(new Badge(75, "Backwards", "&4]&8⸮&4[", "backwards", true)); | ||||||
|  | 		badges.add(new Badge(76, "Dagger", "&0【&7&l〆&r&0】", "dagger", true)); | ||||||
|  | 		badges.add(new Badge(77, "Leaf", "&9[&2⸙&9]", "leaf", true)); | ||||||
|  | 		badges.add(new Badge(78, "Starship", "&8⸠⨷⸡", "starship", true)); | ||||||
|  | 		badges.add(new Badge(79, "Flags", "&a⦑&4⚐&9⚑&a⦒", "flags", true)); | ||||||
|  | 		badges.add(new Badge(80, "Stunned", "&4[x_x]", "stunned", true)); | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public static BadgeList getDefaultBadges() { | ||||||
|  | 		BadgeList badges = new BadgeList(); | ||||||
|  | 		populate(badges); | ||||||
|  | 		return badges; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -1,10 +1,47 @@ | ||||||
| package com.fpghoti.fpchatx.badge; | package com.fpghoti.fpchatx.badge; | ||||||
| 
 | 
 | ||||||
|  | import java.util.UUID; | ||||||
|  | 
 | ||||||
| import com.fpghoti.fpchatx.FPChat; | import com.fpghoti.fpchatx.FPChat; | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; | import com.fpghoti.fpchatx.player.FPlayer; | ||||||
| import com.fpghoti.fpchatx.util.Util; | import com.fpghoti.fpchatx.util.Util; | ||||||
| 
 | 
 | ||||||
| public class SyncSet { | public class Sync { | ||||||
|  | 	 | ||||||
|  | 	public static void syncBadges(FPlayer p, boolean create){ | ||||||
|  | 		UUID id = p.getUniqueId(); | ||||||
|  | 		String uuid = id.toString(); | ||||||
|  | 		Util.connect(); | ||||||
|  | 		if(create && !FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ | ||||||
|  | 			createPlayer(p); | ||||||
|  | 		} | ||||||
|  | 		String raw = (String) FPChat.getPlugin().getMySQLConnection().get("badges", "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable()); | ||||||
|  | 		if(raw != null && raw.length() > 0 && raw.charAt(0) == ','){ | ||||||
|  | 			raw = raw.substring(1); | ||||||
|  | 		} | ||||||
|  | 		if(raw != null && !raw.equals("")) { | ||||||
|  | 			String list[] = Util.stripLast(raw).split(","); | ||||||
|  | 			for(String item : list) { | ||||||
|  | 				if(!item.equals("")) { | ||||||
|  | 					Integer badgeId = Integer.parseInt(item); | ||||||
|  | 					p.addSyncedBadge(badgeId); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public static Boolean syncExists(FPlayer p){ | ||||||
|  | 		Boolean check = false; | ||||||
|  | 		if(p == null) { | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
|  | 		String uuid = p.getUniqueId().toString(); | ||||||
|  | 		Util.connect(); | ||||||
|  | 		if(FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ | ||||||
|  | 			check = true; | ||||||
|  | 		} | ||||||
|  | 		return check; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	public static void update(FPlayer p) { | 	public static void update(FPlayer p) { | ||||||
| 		update(p, true); | 		update(p, true); | ||||||
|  | @ -16,7 +53,7 @@ public class SyncSet { | ||||||
| 		if(create && !FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ | 		if(create && !FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ | ||||||
| 			createPlayer(p); | 			createPlayer(p); | ||||||
| 		} | 		} | ||||||
| 		SyncGetter.syncBadges(p, false); | 		syncBadges(p, false); | ||||||
| 		String nl = ""; | 		String nl = ""; | ||||||
| 		String nl2 = ""; | 		String nl2 = ""; | ||||||
| 		String permstring = getBadgeString(p); | 		String permstring = getBadgeString(p); | ||||||
|  | @ -35,7 +72,7 @@ public class SyncSet { | ||||||
| 		} | 		} | ||||||
| 		nl = nl + nl2; | 		nl = nl + nl2; | ||||||
| 		FPChat.getPlugin().getMySQLConnection().set("badges", nl, "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable()); | 		FPChat.getPlugin().getMySQLConnection().set("badges", nl, "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable()); | ||||||
| 		SyncGetter.syncBadges(p,false); | 		syncBadges(p,false); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static void revoke(FPlayer p) { | 	public static void revoke(FPlayer p) { | ||||||
|  | @ -48,10 +85,10 @@ public class SyncSet { | ||||||
| 		if(create && !FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ | 		if(create && !FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ | ||||||
| 			createPlayer(p); | 			createPlayer(p); | ||||||
| 		} | 		} | ||||||
| 		SyncGetter.syncBadges(p, false); | 		syncBadges(p, false); | ||||||
| 		String nl = ""; | 		String nl = ""; | ||||||
| 		FPChat.getPlugin().getMySQLConnection().set("badges", nl, "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable()); | 		FPChat.getPlugin().getMySQLConnection().set("badges", nl, "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable()); | ||||||
| 		SyncGetter.syncBadges(p, false); | 		syncBadges(p, false); | ||||||
| 	} | 	} | ||||||
| 	public static void revoke(FPlayer p, int badgeId){ | 	public static void revoke(FPlayer p, int badgeId){ | ||||||
| 		revoke(p, badgeId, true); | 		revoke(p, badgeId, true); | ||||||
|  | @ -64,7 +101,7 @@ public class SyncSet { | ||||||
| 		if(create && !FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ | 		if(create && !FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ | ||||||
| 			createPlayer(p); | 			createPlayer(p); | ||||||
| 		} | 		} | ||||||
| 		SyncGetter.syncBadges(p,  false); | 		syncBadges(p,  false); | ||||||
| 		String nl = ""; | 		String nl = ""; | ||||||
| 		String nl2 = ""; | 		String nl2 = ""; | ||||||
| 		for(String item : revokeBadgeString(p, badgeId).split(",")){ | 		for(String item : revokeBadgeString(p, badgeId).split(",")){ | ||||||
|  | @ -83,19 +120,20 @@ public class SyncSet { | ||||||
| 		} | 		} | ||||||
| 		nl = nl + nl2; | 		nl = nl + nl2; | ||||||
| 		FPChat.getPlugin().getMySQLConnection().set("badges", nl, "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable()); | 		FPChat.getPlugin().getMySQLConnection().set("badges", nl, "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable()); | ||||||
| 		SyncGetter.syncBadges(p, false); | 		syncBadges(p, false); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static String getBadgeString(FPlayer p){ | 	public static String getBadgeString(FPlayer p){ | ||||||
| 		String list = ""; | 		String list = ""; | ||||||
| 		for(int i = 1; i < BadgeList.badgeperm.size(); i++){ | 		for(Badge badge : Badge.getList()){ | ||||||
| 			if(p.hasPermission("fpchat.badge" + BadgeList.badgeperm.get(i))){ | 			int id = badge.getId(); | ||||||
| 				String add = Integer.toString(i) + ","; | 			if(badge.isEnabled() && p.hasPermission("fpchat.badge." + badge.getPerm())){ | ||||||
|  | 				String add = Integer.toString(id) + ","; | ||||||
| 				list = list + add; | 				list = list + add; | ||||||
| 			}else if(p.getBadgeQueue().contains(i)) { | 			}else if(p.getBadgeQueue().contains(id)) { | ||||||
| 				String add = Integer.toString(i) + ","; | 				String add = Integer.toString(id) + ","; | ||||||
| 				list = list + add; | 				list = list + add; | ||||||
| 				p.unqueueBadge(i); | 				p.unqueueBadge(id); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -104,10 +142,11 @@ public class SyncSet { | ||||||
| 
 | 
 | ||||||
| 	public static String revokeBadgeString(FPlayer p, int badgeId){ | 	public static String revokeBadgeString(FPlayer p, int badgeId){ | ||||||
| 		String list = ""; | 		String list = ""; | ||||||
| 		for(int i = 1; i < BadgeList.badgeperm.size(); i++){ | 		for(Badge badge : Badge.getList()){ | ||||||
| 			if(p.hasPermission("fpchat.badge" + BadgeList.badgeperm.get(i))){ | 			int id = badge.getId(); | ||||||
| 				if(i != badgeId){ | 			if(p.hasPermission("fpchat.badge." + badge.getPerm())){ | ||||||
| 					String add = Integer.toString(i) + ","; | 				if(id != badgeId){ | ||||||
|  | 					String add = Integer.toString(id) + ","; | ||||||
| 					list = list + add; | 					list = list + add; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  | @ -1,46 +0,0 @@ | ||||||
| package com.fpghoti.fpchatx.badge; |  | ||||||
| 
 |  | ||||||
| import java.util.UUID; |  | ||||||
| 
 |  | ||||||
| import com.fpghoti.fpchatx.FPChat; |  | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; |  | ||||||
| import com.fpghoti.fpchatx.util.Util; |  | ||||||
| 
 |  | ||||||
| public class SyncGetter { |  | ||||||
| 
 |  | ||||||
| 	public static void syncBadges(FPlayer p, boolean create){ |  | ||||||
| 		UUID id = p.getUniqueId(); |  | ||||||
| 		String uuid = id.toString(); |  | ||||||
| 		Util.connect(); |  | ||||||
| 		if(create && !FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ |  | ||||||
| 			SyncSet.createPlayer(p); |  | ||||||
| 		} |  | ||||||
| 		String raw = (String) FPChat.getPlugin().getMySQLConnection().get("badges", "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable()); |  | ||||||
| 		if(raw != null && raw.length() > 0 && raw.charAt(0) == ','){ |  | ||||||
| 			raw = raw.substring(1); |  | ||||||
| 		} |  | ||||||
| 		if(raw != null && !raw.equals("")) { |  | ||||||
| 			String list[] = Util.stripLast(raw).split(","); |  | ||||||
| 			for(String item : list) { |  | ||||||
| 				if(!item.equals("")) { |  | ||||||
| 					Integer badgeId = Integer.parseInt(item); |  | ||||||
| 					p.addSyncedBadge(badgeId); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	public static Boolean syncExists(FPlayer p){ |  | ||||||
| 		Boolean check = false; |  | ||||||
| 		if(p == null) { |  | ||||||
| 			return false; |  | ||||||
| 		} |  | ||||||
| 		String uuid = p.getUniqueId().toString(); |  | ||||||
| 		Util.connect(); |  | ||||||
| 		if(FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getPermSyncTable())){ |  | ||||||
| 			check = true; |  | ||||||
| 		} |  | ||||||
| 		return check; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
|  | @ -10,7 +10,7 @@ import org.bukkit.OfflinePlayer; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
| 
 | 
 | ||||||
| import com.fpghoti.fpchatx.FPChat; | import com.fpghoti.fpchatx.FPChat; | ||||||
| import com.fpghoti.fpchatx.badge.BadgeList; | import com.fpghoti.fpchatx.badge.Badge; | ||||||
| import com.fpghoti.fpchatx.config.ChannelFile; | import com.fpghoti.fpchatx.config.ChannelFile; | ||||||
| import com.fpghoti.fpchatx.customcodes.BubbleCode; | import com.fpghoti.fpchatx.customcodes.BubbleCode; | ||||||
| import com.fpghoti.fpchatx.customcodes.Codify; | import com.fpghoti.fpchatx.customcodes.Codify; | ||||||
|  | @ -81,12 +81,7 @@ public abstract class ChatChannel { | ||||||
| 				if(configFile.delete()) { | 				if(configFile.delete()) { | ||||||
| 					FPChat.getPlugin().log(Level.INFO, "Channel file for " + cname + " successfully deleted."); | 					FPChat.getPlugin().log(Level.INFO, "Channel file for " + cname + " successfully deleted."); | ||||||
| 				} else { | 				} else { | ||||||
| 					FPChat.getPlugin().log(Level.SEVERE, "======================================================"); | 					FPChat.getPlugin().log(Level.SEVERE, "Channel not properly removed. File deletion error."); | ||||||
| 					FPChat.getPlugin().log(Level.SEVERE, "| ------------------ FPCHATX ERROR ----------------- |"); |  | ||||||
| 					FPChat.getPlugin().log(Level.SEVERE, "======================================================"); |  | ||||||
| 					FPChat.getPlugin().log(Level.SEVERE, "| Channel not properly removed. File deletion error. |"); |  | ||||||
| 					FPChat.getPlugin().log(Level.SEVERE, "| ---------- Check the file and try again. --------- |"); |  | ||||||
| 					FPChat.getPlugin().log(Level.SEVERE, "======================================================"); |  | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
| 			}else { | 			}else { | ||||||
|  | @ -316,9 +311,9 @@ public abstract class ChatChannel { | ||||||
| 		} | 		} | ||||||
| 		if(plugin.getMainConfig().mySQLEnabled()){ | 		if(plugin.getMainConfig().mySQLEnabled()){ | ||||||
| 			Integer[] badges = p.getBadges(); | 			Integer[] badges = p.getBadges(); | ||||||
| 			slot1 = BadgeList.badgelist.get(badges[0]); | 			slot1 = Badge.getList().get(badges[0]).getContents(); | ||||||
| 			slot2 = BadgeList.badgelist.get(badges[1]); | 			slot2 = Badge.getList().get(badges[1]).getContents(); | ||||||
| 			slot3 = BadgeList.badgelist.get(badges[2]); | 			slot3 = Badge.getList().get(badges[2]).getContents(); | ||||||
| 		} | 		} | ||||||
| 		String filler = ""; | 		String filler = ""; | ||||||
| 		if(plugin.getMainConfig().chatFilterEnabled()){ | 		if(plugin.getMainConfig().chatFilterEnabled()){ | ||||||
|  |  | ||||||
|  | @ -5,7 +5,6 @@ import org.bukkit.command.CommandSender; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
| 
 | 
 | ||||||
| import com.fpghoti.fpchatx.FPChat; | import com.fpghoti.fpchatx.FPChat; | ||||||
| import com.fpghoti.fpchatx.badge.BadgeSet; |  | ||||||
| import com.fpghoti.fpchatx.command.Commands; | import com.fpghoti.fpchatx.command.Commands; | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; | import com.fpghoti.fpchatx.player.FPlayer; | ||||||
| 
 | 
 | ||||||
|  | @ -39,9 +38,9 @@ public class BadgeClearCommand extends Commands { | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		FPlayer p = FPlayer.getPlayer((Player)sender); | 		FPlayer p = FPlayer.getPlayer((Player)sender); | ||||||
| 		BadgeSet.setBadge(p, 1, 0); | 		p.setBadge(1, 0); | ||||||
| 		BadgeSet.setBadge(p, 2, 0); | 		p.setBadge(2, 0); | ||||||
| 		BadgeSet.setBadge(p, 3, 0); | 		p.setBadge(3, 0); | ||||||
| 		p.sendMessage(FPChat.logo() + ChatColor.YELLOW + " Unequipped all badges!"); | 		p.sendMessage(FPChat.logo() + ChatColor.YELLOW + " Unequipped all badges!"); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -5,9 +5,7 @@ import org.bukkit.command.CommandSender; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
| 
 | 
 | ||||||
| import com.fpghoti.fpchatx.FPChat; | import com.fpghoti.fpchatx.FPChat; | ||||||
| import com.fpghoti.fpchatx.badge.BadgeGetter; | import com.fpghoti.fpchatx.badge.Badge; | ||||||
| import com.fpghoti.fpchatx.badge.BadgeList; |  | ||||||
| import com.fpghoti.fpchatx.badge.BadgeSet; |  | ||||||
| import com.fpghoti.fpchatx.command.Commands; | import com.fpghoti.fpchatx.command.Commands; | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; | import com.fpghoti.fpchatx.player.FPlayer; | ||||||
| import com.fpghoti.fpchatx.util.Util; | import com.fpghoti.fpchatx.util.Util; | ||||||
|  | @ -44,9 +42,9 @@ public class BadgeEquipCommand extends Commands { | ||||||
| 		if(Util.isDigit(args[0]) && Util.isDigit(args[1])){ | 		if(Util.isDigit(args[0]) && Util.isDigit(args[1])){ | ||||||
| 
 | 
 | ||||||
| 			Integer slot = Integer.parseInt(args[0]), badgeId = Integer.parseInt(args[1]); | 			Integer slot = Integer.parseInt(args[0]), badgeId = Integer.parseInt(args[1]); | ||||||
| 			if(BadgeGetter.canUseSlot(p, slot)){ | 			if(p.canUseSlot(slot)){ | ||||||
| 				if(BadgeList.badgelist.containsKey(badgeId) && BadgeGetter.hasBadge(p, badgeId)){ | 				if(Badge.getList().containsId(badgeId) && Badge.getList().get(badgeId).isEnabled() && p.hasBadge(badgeId)){ | ||||||
| 					BadgeSet.setBadge(p, slot, badgeId); | 					p.setBadge(slot, badgeId); | ||||||
| 					p.updateBadges(slot, badgeId); | 					p.updateBadges(slot, badgeId); | ||||||
| 					p.sendMessage( FPChat.logo() + ChatColor.YELLOW + " You have equipped a badge!"); | 					p.sendMessage( FPChat.logo() + ChatColor.YELLOW + " You have equipped a badge!"); | ||||||
| 				}else{ | 				}else{ | ||||||
|  |  | ||||||
|  | @ -5,8 +5,10 @@ import org.bukkit.command.CommandSender; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
| 
 | 
 | ||||||
| import com.fpghoti.fpchatx.FPChat; | import com.fpghoti.fpchatx.FPChat; | ||||||
|  | import com.fpghoti.fpchatx.badge.Badge; | ||||||
| import com.fpghoti.fpchatx.badge.BadgeList; | import com.fpghoti.fpchatx.badge.BadgeList; | ||||||
| import com.fpghoti.fpchatx.command.Commands; | import com.fpghoti.fpchatx.command.Commands; | ||||||
|  | import com.fpghoti.fpchatx.permission.Permission; | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; | import com.fpghoti.fpchatx.player.FPlayer; | ||||||
| import com.fpghoti.fpchatx.util.Util; | import com.fpghoti.fpchatx.util.Util; | ||||||
| 
 | 
 | ||||||
|  | @ -28,9 +30,9 @@ public class BadgeListCommand extends Commands { | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public void execute(CommandSender sender, String[] args) { | 	public void execute(CommandSender sender, String[] args) { | ||||||
| 		if(!(sender instanceof Player)) { | 		FPlayer p = null; | ||||||
| 			FPlayer.errMsg(null, "This command is for players only."); | 		if(sender instanceof Player) { | ||||||
| 			return; | 			p = FPlayer.getPlayer((Player)sender); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if(!plugin.getMainConfig().mySQLEnabled()) { | 		if(!plugin.getMainConfig().mySQLEnabled()) { | ||||||
|  | @ -38,12 +40,45 @@ public class BadgeListCommand extends Commands { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		FPlayer p = FPlayer.getPlayer((Player)sender); | 		int pg = 1; | ||||||
| 		if(args.length == 0 || !Util.isDigit(args[0])){ | 		if (args.length > 0) { | ||||||
| 			BadgeList.badgeList(p, 1); | 			if(Util.isDigit(args[0])) { | ||||||
| 		}else{ | 				pg = Integer.parseInt(args[0]); | ||||||
| 			BadgeList.badgeList(p,  Integer.parseInt(args[0])); | 			}else { | ||||||
|  | 				FPlayer.errMsg(p, syntax); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
|  | 		BadgeList list = p.getSyncedBadgeList(); | ||||||
|  | 
 | ||||||
|  | 		int pageCount = (int) Math.ceil((double) list.getListSize() / 8); | ||||||
|  | 		if (pg > pageCount) { | ||||||
|  | 			pg = pageCount; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		FPlayer.plainMsg(p, ""); | ||||||
|  | 
 | ||||||
|  | 		FPlayer.plainMsg(p, ChatColor.GREEN + "Equip badges with " + ChatColor.DARK_AQUA + "/equip <slot id> <badge id>" + ChatColor.GREEN + "."); | ||||||
|  | 		FPlayer.plainMsg(p, ChatColor.GREEN + "Unequip all badges with " + ChatColor.DARK_AQUA + "/badgesclear" + ChatColor.GREEN + "."); | ||||||
|  | 		FPlayer.plainMsg(p, ChatColor.GOLD + "[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] "  + ChatColor.YELLOW + "Badges:"); | ||||||
|  | 		FPlayer.plainMsg(p, ChatColor.GOLD + "======================"); | ||||||
|  | 		for (int i = 0; i < 8; i++) { | ||||||
|  | 			int index = (pg - 1) * 8 + i; | ||||||
|  | 			if (index < list.getListSize()) { | ||||||
|  | 				Badge badge = list.getIndex(index); | ||||||
|  | 				int id = badge.getId(); | ||||||
|  | 				String name = badge.getName(); | ||||||
|  | 				String contents = badge.getContents(); | ||||||
|  | 				String perm = badge.getPerm(); | ||||||
|  | 				String msg = ChatColor.DARK_AQUA + "ID: " + ChatColor.AQUA + id + ChatColor.DARK_AQUA + " - " + ChatColor.RESET + contents + | ||||||
|  | 						ChatColor.RESET + ChatColor.DARK_AQUA + " - " + ChatColor.WHITE + ChatColor.BOLD + name; | ||||||
|  | 				if(Permission.isAdmin(p)) { | ||||||
|  | 					msg = msg + " " + ChatColor.YELLOW + perm; | ||||||
|  | 				} | ||||||
|  | 				FPlayer.plainMsg(p, msg); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -5,8 +5,8 @@ import org.bukkit.command.CommandSender; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
| 
 | 
 | ||||||
| import com.fpghoti.fpchatx.FPChat; | import com.fpghoti.fpchatx.FPChat; | ||||||
| import com.fpghoti.fpchatx.badge.BadgeList; | import com.fpghoti.fpchatx.badge.Badge; | ||||||
| import com.fpghoti.fpchatx.badge.SyncSet; | import com.fpghoti.fpchatx.badge.Sync; | ||||||
| import com.fpghoti.fpchatx.command.Commands; | import com.fpghoti.fpchatx.command.Commands; | ||||||
| import com.fpghoti.fpchatx.permission.Permission; | import com.fpghoti.fpchatx.permission.Permission; | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; | import com.fpghoti.fpchatx.player.FPlayer; | ||||||
|  | @ -45,10 +45,10 @@ public class GiveBadgeCommand extends Commands { | ||||||
| 				FPlayer.errMsg(p,"That player cannot be found."); | 				FPlayer.errMsg(p,"That player cannot be found."); | ||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
| 			if(Util.isDigit(args[1]) && BadgeList.badgeperm.containsKey(Integer.parseInt(args[1]))) { | 			if(Util.isDigit(args[1]) && Badge.getList().containsId(Integer.parseInt(args[1]))) { | ||||||
| 				int id = Integer.parseInt(args[1]); | 				int id = Integer.parseInt(args[1]); | ||||||
| 				toGive.queueBadgeAdd(id); | 				toGive.queueBadgeAdd(id); | ||||||
| 				SyncSet.update(toGive); | 				Sync.update(toGive); | ||||||
| 				toGive.addSyncedBadge(id); | 				toGive.addSyncedBadge(id); | ||||||
| 				FPlayer.goodMsg(p, "Badge granted."); | 				FPlayer.goodMsg(p, "Badge granted."); | ||||||
| 			}else { | 			}else { | ||||||
|  |  | ||||||
|  | @ -72,7 +72,7 @@ public class HelpCommand extends Commands { | ||||||
| 		ctype = ChatColor.DARK_AQUA + "Channel Type: " + ChatColor.GREEN + ctype; | 		ctype = ChatColor.DARK_AQUA + "Channel Type: " + ChatColor.GREEN + ctype; | ||||||
| 		String online = ChatColor.DARK_AQUA + "Members Online: " + ChatColor.GREEN + ccount; | 		String online = ChatColor.DARK_AQUA + "Members Online: " + ChatColor.GREEN + ccount; | ||||||
| 		if(args.length == 0) { | 		if(args.length == 0) { | ||||||
| 			FPlayer.plainMsg(p, ChatColor.GOLD + "[INFO] "  + ChatColor.YELLOW + "FPChatX:"); | 			FPlayer.plainMsg(p, ChatColor.GOLD + "[INFO] "  + ChatColor.YELLOW + "FPChat:"); | ||||||
| 			FPlayer.plainMsg(p,name); | 			FPlayer.plainMsg(p,name); | ||||||
| 			FPlayer.plainMsg(p,primary); | 			FPlayer.plainMsg(p,primary); | ||||||
| 			FPlayer.plainMsg(p,ctype); | 			FPlayer.plainMsg(p,ctype); | ||||||
|  | @ -81,7 +81,7 @@ public class HelpCommand extends Commands { | ||||||
| 			FPlayer.plainMsg(p, ChatColor.GRAY + "Use " + ChatColor.WHITE + "/fpc help <page number> " + ChatColor.GRAY + "for a list of commands."); | 			FPlayer.plainMsg(p, ChatColor.GRAY + "Use " + ChatColor.WHITE + "/fpc help <page number> " + ChatColor.GRAY + "for a list of commands."); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		FPlayer.plainMsg(p, ChatColor.GOLD + "[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] "  + ChatColor.YELLOW + "FPChatX Commands:"); | 		FPlayer.plainMsg(p, ChatColor.GOLD + "[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] "  + ChatColor.YELLOW + "FPChat Commands:"); | ||||||
| 		for (int i = 0; i < 8; i++) { | 		for (int i = 0; i < 8; i++) { | ||||||
| 			int index = (pg - 1) * 8 + i; | 			int index = (pg - 1) * 8 + i; | ||||||
| 			if (index < commands.size()) { | 			if (index < commands.size()) { | ||||||
|  |  | ||||||
|  | @ -9,9 +9,8 @@ import org.bukkit.command.CommandSender; | ||||||
| import org.bukkit.entity.Player; | import org.bukkit.entity.Player; | ||||||
| 
 | 
 | ||||||
| import com.fpghoti.fpchatx.FPChat; | import com.fpghoti.fpchatx.FPChat; | ||||||
| import com.fpghoti.fpchatx.badge.BadgeList; | import com.fpghoti.fpchatx.badge.Badge; | ||||||
| import com.fpghoti.fpchatx.badge.SyncGetter; | import com.fpghoti.fpchatx.badge.Sync; | ||||||
| import com.fpghoti.fpchatx.badge.SyncSet; |  | ||||||
| import com.fpghoti.fpchatx.command.Commands; | import com.fpghoti.fpchatx.command.Commands; | ||||||
| import com.fpghoti.fpchatx.permission.Permission; | import com.fpghoti.fpchatx.permission.Permission; | ||||||
| import com.fpghoti.fpchatx.player.FPlayer; | import com.fpghoti.fpchatx.player.FPlayer; | ||||||
|  | @ -50,16 +49,16 @@ public class RevokeBadgeCommand extends Commands { | ||||||
| 			OfflinePlayer o = Bukkit.getOfflinePlayer(u); | 			OfflinePlayer o = Bukkit.getOfflinePlayer(u); | ||||||
| 			if(o != null) { | 			if(o != null) { | ||||||
| 				FPlayer toRevoke = FPlayer.getPlayer(o,true); | 				FPlayer toRevoke = FPlayer.getPlayer(o,true); | ||||||
| 				if(SyncGetter.syncExists(toRevoke) && (Util.isDigit(args[1]) || args[1].equals("*") )){ | 				if(Sync.syncExists(toRevoke) && (Util.isDigit(args[1]) || args[1].equals("*") )){ | ||||||
| 
 | 
 | ||||||
| 					if(args[1].equals("*")) { | 					if(args[1].equals("*")) { | ||||||
| 						SyncSet.revoke(toRevoke); | 						Sync.revoke(toRevoke); | ||||||
| 						FPlayer.goodMsg(p, "All badges revoked from the specified player."); | 						FPlayer.goodMsg(p, "All badges revoked from the specified player."); | ||||||
| 					}else { | 					}else { | ||||||
| 
 | 
 | ||||||
| 						if(Integer.parseInt(args[1]) < BadgeList.badgeperm.size()) { | 						if(Badge.getList().containsId(Integer.parseInt(args[1]))) { | ||||||
| 							int id = Integer.parseInt(args[1]); | 							int id = Integer.parseInt(args[1]); | ||||||
| 							SyncSet.revoke(toRevoke, id); | 							Sync.revoke(toRevoke, id); | ||||||
| 							toRevoke.removeSyncedBadge(id); | 							toRevoke.removeSyncedBadge(id); | ||||||
| 							toRevoke.clearUnownedBadges(); | 							toRevoke.clearUnownedBadges(); | ||||||
| 							FPlayer.goodMsg(p, "Badge revoked from the specified player."); | 							FPlayer.goodMsg(p, "Badge revoked from the specified player."); | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ public class ShoutToggleCommand extends Commands { | ||||||
|         labels.add("fpchat shouttoggle"); |         labels.add("fpchat shouttoggle"); | ||||||
|         labels.add("ch shouttoggle"); |         labels.add("ch shouttoggle"); | ||||||
|         labels.add("shouttoggle"); |         labels.add("shouttoggle"); | ||||||
|         labels.add("frankoffshout"); |         labels.add("foffshout"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|  |  | ||||||
|  | @ -0,0 +1,118 @@ | ||||||
|  | package com.fpghoti.fpchatx.config; | ||||||
|  | 
 | ||||||
|  | import java.io.File; | ||||||
|  | import java.io.IOException; | ||||||
|  | 
 | ||||||
|  | import org.bukkit.configuration.file.FileConfiguration; | ||||||
|  | import org.bukkit.configuration.file.YamlConfiguration; | ||||||
|  | 
 | ||||||
|  | import com.fpghoti.fpchatx.FPChat; | ||||||
|  | import com.fpghoti.fpchatx.badge.Badge; | ||||||
|  | import com.fpghoti.fpchatx.badge.BadgeList; | ||||||
|  | import com.fpghoti.fpchatx.badge.DefaultBadges; | ||||||
|  | import com.fpghoti.fpchatx.util.Util; | ||||||
|  | 
 | ||||||
|  | public class BadgeConfig { | ||||||
|  | 
 | ||||||
|  | 	private FPChat plugin; | ||||||
|  | 	private File configFile; | ||||||
|  | 	private FileConfiguration config; | ||||||
|  | 
 | ||||||
|  | 	public BadgeConfig(FPChat plugin) { | ||||||
|  | 		this.plugin = plugin; | ||||||
|  | 		this.configFile = new File(this.plugin.getDataFolder(), "badges.yml"); | ||||||
|  | 		this.config = YamlConfiguration.loadConfiguration(configFile); | ||||||
|  | 		generate(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private void generate(){ | ||||||
|  | 		if (config.get("Config-Generated")==null) { | ||||||
|  | 			config.options().header("" | ||||||
|  | 					+ "This plugin supports up to three badges being equipped at the same time using slots 1, 2, or 3. FPChat\n" | ||||||
|  | 					+ "requires MySQL to be enabled to use badges. For syncing across multiple servers, KEEP THE IDS CONSISTANT.\n" | ||||||
|  | 					+ "Changing the permission or replacing a badge will NOT revoke the badge id from users who have unlocked\n" | ||||||
|  | 					+ "it already in the database. When you are retiring a badge, it is recommended that you disable the badge\n" | ||||||
|  | 					+ "and add a new one at the end.\n" | ||||||
|  | 					+ "\n" | ||||||
|  | 					+ "Usage:\n" | ||||||
|  | 					+ "ID-Number:\n" | ||||||
|  | 					+ "  Name: Set the name of the badge here.\n" | ||||||
|  | 					+ "  Contents: This is what the badge displays as in game.\n" | ||||||
|  | 					+ "  Permission: The permission for the badge. Grant in game by giving a player \"fpchat.badge.<what you put in this section>\".\n" | ||||||
|  | 					+ "  Enabled: Set to false to disable the badge." | ||||||
|  | 					+ "  UnlockSlot: Set to 1, 2, or 3 to give players access to the corresponding badge slot for all badges when unlocking this badge or set to -1 to not unlock a slot with the badge.\n"); | ||||||
|  | 			BadgeList list = DefaultBadges.getDefaultBadges(); | ||||||
|  | 			config.createSection("Config-Generated"); | ||||||
|  | 			config.set("Config-Generated", true); | ||||||
|  | 			for(int i = 1; i < list.size(); i++) { | ||||||
|  | 				Badge badge = list.get(i); | ||||||
|  | 				String path = Integer.toString(i); | ||||||
|  | 				if(config.getInt(path) == 0) { | ||||||
|  | 					config.createSection(path); | ||||||
|  | 				} | ||||||
|  | 				if(config.getString(path + ".Name") == null) { | ||||||
|  | 					config.createSection(path + ".Name"); | ||||||
|  | 					config.set(path + ".Name", badge.getName()); | ||||||
|  | 				} | ||||||
|  | 				if(config.getString(path + ".Contents") == null) { | ||||||
|  | 					config.createSection(path + ".Contents"); | ||||||
|  | 					config.set(path + ".Contents", badge.getContents().replace("§", "&")); | ||||||
|  | 				} | ||||||
|  | 				if(config.getString(path + ".Permission") == null) { | ||||||
|  | 					config.createSection(path + ".Permission"); | ||||||
|  | 					config.set(path + ".Permission", badge.getRawPerm()); | ||||||
|  | 				} | ||||||
|  | 				if(config.getString(path + ".Enabled") == null) { | ||||||
|  | 					config.createSection(path + ".Enabled"); | ||||||
|  | 					config.set(path + ".Enabled", badge.isEnabled()); | ||||||
|  | 				} | ||||||
|  | 				if(config.getString(path + ".UnlockSlot") == null) { | ||||||
|  | 					config.createSection(path + ".UnlockSlot"); | ||||||
|  | 					config.set(path + ".UnlockSlot", badge.getSlotUnlock()); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		try { | ||||||
|  | 			config.save(configFile); | ||||||
|  | 		} catch (IOException e) { | ||||||
|  | 			e.printStackTrace(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void loadBadges(BadgeList list) { | ||||||
|  | 		for(String key : config.getKeys(false)) { | ||||||
|  | 			if(Util.isDigit(key)) { | ||||||
|  | 				int id = Integer.parseInt(key); | ||||||
|  | 				String name = null; | ||||||
|  | 				String contents = null; | ||||||
|  | 				String permission = null; | ||||||
|  | 				boolean enabled = false; | ||||||
|  | 				int unlockSlot = 0; | ||||||
|  | 				 | ||||||
|  | 				String item = config.getString(key + ".Name"); | ||||||
|  | 				if(item != null) { | ||||||
|  | 					name = item; | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 				item = config.getString(key + ".Contents"); | ||||||
|  | 				if(item != null) { | ||||||
|  | 					contents = item; | ||||||
|  | 				} | ||||||
|  | 				 | ||||||
|  | 
 | ||||||
|  | 				item = config.getString(key + ".Permission"); | ||||||
|  | 				if(item != null) { | ||||||
|  | 					permission = item; | ||||||
|  | 				} | ||||||
|  | 				 | ||||||
|  | 				enabled = config.getBoolean(key + ".Enabled"); | ||||||
|  | 				 | ||||||
|  | 				unlockSlot = config.getInt(key + ".UnlockSlot"); | ||||||
|  | 				 | ||||||
|  | 				Badge badge = new Badge(id, name, contents, permission, enabled, unlockSlot); | ||||||
|  | 				list.add(badge); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -2,6 +2,7 @@ package com.fpghoti.fpchatx.player; | ||||||
| 
 | 
 | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
|  | import java.util.Collections; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.HashSet; | import java.util.HashSet; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  | @ -15,9 +16,9 @@ import org.bukkit.entity.Player; | ||||||
| import org.bukkit.event.player.AsyncPlayerChatEvent; | import org.bukkit.event.player.AsyncPlayerChatEvent; | ||||||
| 
 | 
 | ||||||
| import com.fpghoti.fpchatx.FPChat; | import com.fpghoti.fpchatx.FPChat; | ||||||
| import com.fpghoti.fpchatx.badge.BadgeGetter; | import com.fpghoti.fpchatx.badge.Badge; | ||||||
| import com.fpghoti.fpchatx.badge.BadgeSet; | import com.fpghoti.fpchatx.badge.BadgeList; | ||||||
| import com.fpghoti.fpchatx.badge.SyncSet; | import com.fpghoti.fpchatx.badge.Sync; | ||||||
| import com.fpghoti.fpchatx.chat.ChatChannel; | import com.fpghoti.fpchatx.chat.ChatChannel; | ||||||
| import com.fpghoti.fpchatx.chat.ChatFilter; | import com.fpghoti.fpchatx.chat.ChatFilter; | ||||||
| import com.fpghoti.fpchatx.chat.PrepareChat; | import com.fpghoti.fpchatx.chat.PrepareChat; | ||||||
|  | @ -173,8 +174,8 @@ public class FPlayer { | ||||||
| 		} | 		} | ||||||
| 		if(FPChat.getPlugin().getMainConfig().mySQLEnabled()) { | 		if(FPChat.getPlugin().getMainConfig().mySQLEnabled()) { | ||||||
| 			Util.connect(); | 			Util.connect(); | ||||||
| 			SyncSet.update(this); | 			Sync.update(this); | ||||||
| 			this.badges = BadgeGetter.getBadges(this); | 			this.badges = getSQLBadges(); | ||||||
| 		}else { | 		}else { | ||||||
| 			Integer[] empt = {0,0,0}; | 			Integer[] empt = {0,0,0}; | ||||||
| 			this.badges = empt; | 			this.badges = empt; | ||||||
|  | @ -190,24 +191,95 @@ public class FPlayer { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void updateBadges(int slot, int id) { | 	public void updateBadges(int slot, int id) { | ||||||
|  | 		if(!Badge.getList().get(id).isEnabled()) { | ||||||
|  | 			badges[slot-1] = 0; | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
| 		badges[slot-1] = id; | 		badges[slot-1] = id; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void clearUnownedBadges() { | 	public void clearUnownedBadges() { | ||||||
| 		if(!BadgeGetter.hasBadge(this, badges[0])) { | 		if(!hasBadge(badges[0]) || !Badge.getList().get(badges[0]).isEnabled()) { | ||||||
| 			BadgeSet.setBadge(this, 1, 0); | 			setBadge(1, 0); | ||||||
| 			updateBadges(1,0); | 			updateBadges(1,0); | ||||||
| 		} | 		} | ||||||
| 		if(!BadgeGetter.hasBadge(this, badges[1])) { | 		if(!hasBadge(badges[1])|| !Badge.getList().get(badges[1]).isEnabled()) { | ||||||
| 			BadgeSet.setBadge(this, 2, 0); | 			setBadge(2, 0); | ||||||
| 			updateBadges(2,0); | 			updateBadges(2,0); | ||||||
| 		} | 		} | ||||||
| 		if(!BadgeGetter.hasBadge(this, badges[2])) { | 		if(!hasBadge(badges[2])|| !Badge.getList().get(badges[2]).isEnabled()) { | ||||||
| 			BadgeSet.setBadge(this, 3, 0); | 			setBadge(3, 0); | ||||||
| 			updateBadges(3,0); | 			updateBadges(3,0); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	public Integer[] getSQLBadges(){ | ||||||
|  | 		UUID id = uuid; | ||||||
|  | 		String uuid = id.toString(); | ||||||
|  | 		Integer badge1 = 0, badge2 = 0, badge3 = 0; | ||||||
|  | 		Util.connect(); | ||||||
|  | 		if(!FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable())){ | ||||||
|  | 			createPlayer(); | ||||||
|  | 		} | ||||||
|  | 		badge1 = (Integer) FPChat.getPlugin().getMySQLConnection().get("badge_slot1", "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable()); | ||||||
|  | 		badge2 = (Integer)FPChat.getPlugin().getMySQLConnection().get("badge_slot2", "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable()); | ||||||
|  | 		badge3 = (Integer)FPChat.getPlugin().getMySQLConnection().get("badge_slot3", "player_uuid", "=", uuid, FPChat.getPlugin().getMainConfig().getChatFeatureTable()); | ||||||
|  | 		Integer[] badges = {badge1, badge2, badge3}; | ||||||
|  | 		return badges; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public Boolean hasBadge(int id){ | ||||||
|  | 		if(id == 0) { | ||||||
|  | 			return true; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		return hasPermission("fpchat.badge." + Badge.getList().get(id).getPerm()) || isSynced(id); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void setBadge(int slot, int badgeId){ | ||||||
|  | 		if(!Badge.getList().get(badgeId).isEnabled()) { | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		if(slot > 3){ | ||||||
|  | 			slot = 3; | ||||||
|  | 		}else if(slot < 1){ | ||||||
|  | 			slot = 1; | ||||||
|  | 		} | ||||||
|  | 		Util.connect(); | ||||||
|  | 		if(!FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid.toString(), FPChat.getPlugin().getMainConfig().getChatFeatureTable())){ | ||||||
|  | 			createPlayer(); | ||||||
|  | 		} | ||||||
|  | 		FPChat.getPlugin().getMySQLConnection().set("badge_slot" + String.valueOf(slot), badgeId, "player_uuid", "=", uuid.toString(),  FPChat.getPlugin().getMainConfig().getChatFeatureTable()); | ||||||
|  | 		getBadges(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void createPlayer(){ | ||||||
|  | 		Util.connect(); | ||||||
|  | 		if(!FPChat.getPlugin().getMySQLConnection().itemExists("player_uuid", uuid.toString(), FPChat.getPlugin().getMainConfig().getChatFeatureTable())){ | ||||||
|  | 			FPChat.getPlugin().getMySQLConnection().insertInto("player_uuid, badge_slot1, badge_slot2, badge_slot3", " '" + uuid + "', '0', '0', '0' ",  FPChat.getPlugin().getMainConfig().getChatFeatureTable()); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public Boolean canUseSlot(int slotid){ | ||||||
|  | 		if(slotid == 1){ | ||||||
|  | 			return hasPermission("fpchat.slot1") || hasSlotBadge(1); | ||||||
|  | 		}else if(slotid == 2){ | ||||||
|  | 			return hasPermission("fpchat.slot2") || hasSlotBadge(2); | ||||||
|  | 		}else if(slotid == 3){ | ||||||
|  | 			return hasPermission("fpchat.slot3") || hasSlotBadge(3); | ||||||
|  | 		} | ||||||
|  | 		return false; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private boolean hasSlotBadge(int slot) { | ||||||
|  | 		for(Badge b : Badge.getList().getSlotUnlockBadges(slot)) { | ||||||
|  | 			if(hasBadge(b.getId())) { | ||||||
|  | 				return true; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return false; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	public void addSyncedBadge(Integer id) { | 	public void addSyncedBadge(Integer id) { | ||||||
| 		if(!synced.contains(id)) { | 		if(!synced.contains(id)) { | ||||||
| 			this.synced.add(id); | 			this.synced.add(id); | ||||||
|  | @ -226,6 +298,19 @@ public class FPlayer { | ||||||
| 		return this.synced; | 		return this.synced; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	public BadgeList getSyncedBadgeList() { | ||||||
|  | 		BadgeList list = new BadgeList(); | ||||||
|  | 		ArrayList<Integer> sc = new ArrayList<Integer>(synced); | ||||||
|  | 		Collections.sort(sc); | ||||||
|  | 		for(Integer i : sc) { | ||||||
|  | 			Badge badge = Badge.getList().get(i); | ||||||
|  | 			if(badge.isEnabled()) { | ||||||
|  | 				list.add(badge); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return list; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	public int getShoutCooldown() { | 	public int getShoutCooldown() { | ||||||
| 		return this.shoutCooldown; | 		return this.shoutCooldown; | ||||||
| 	} | 	} | ||||||
|  | @ -285,7 +370,7 @@ public class FPlayer { | ||||||
| 
 | 
 | ||||||
| 	public boolean setSuffix(String suffix) { | 	public boolean setSuffix(String suffix) { | ||||||
| 		if(isOnline() && getPlayer() != null) { | 		if(isOnline() && getPlayer() != null) { | ||||||
| 			VaultUtil.chat.setPlayerPrefix(getPlayer(), suffix); | 			VaultUtil.chat.setPlayerSuffix(getPlayer(), suffix); | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| 		return false; | 		return false; | ||||||
|  | @ -305,7 +390,7 @@ public class FPlayer { | ||||||
| 
 | 
 | ||||||
| 	public Integer[] getBadges() { | 	public Integer[] getBadges() { | ||||||
| 		if(badges[0] == null || badges[1] == null || badges[2] == null) { | 		if(badges[0] == null || badges[1] == null || badges[2] == null) { | ||||||
| 			badges = BadgeGetter.getBadges(this); | 			badges = getSQLBadges(); | ||||||
| 		} | 		} | ||||||
| 		return this.badges; | 		return this.badges; | ||||||
| 	} | 	} | ||||||
|  | @ -657,7 +742,10 @@ public class FPlayer { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void queueBadgeAdd(int id) { | 	public void queueBadgeAdd(int id) { | ||||||
| 		if(!BadgeGetter.hasBadge(this, id) && !giveBadgeQueue.contains(id)) { | 		if(!Badge.getList().get(id).isEnabled()) { | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		if(!hasBadge( id) && !giveBadgeQueue.contains(id)) { | ||||||
| 			giveBadgeQueue.add(id); | 			giveBadgeQueue.add(id); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -1,9 +1,8 @@ | ||||||
| name: FPChatX | name: FPChat | ||||||
| version: ${project.version} | version: ${project.version} | ||||||
| main: com.fpghoti.fpchatx.FPChat | main: com.fpghoti.fpchatx.FPChat | ||||||
| description: Chat plugin for 1.12+ | description: Chat plugin for 1.12+ | ||||||
| depend: [Vault] | depend: [Vault] | ||||||
| softdepend: [PlaceholderAPI] |  | ||||||
| commands: | commands: | ||||||
|   fpc: |   fpc: | ||||||
|     aliases: [fpchat,ch] |     aliases: [fpchat,ch] | ||||||
|  | @ -58,7 +57,7 @@ commands: | ||||||
|     description: Grants player a badge. |     description: Grants player a badge. | ||||||
|     usage: /<command> player badge# |     usage: /<command> player badge# | ||||||
|   shouttoggle: |   shouttoggle: | ||||||
|     aliases: [frankoffshout] |     aliases: [foffshout] | ||||||
|     description: Toggles ability to see shout. |     description: Toggles ability to see shout. | ||||||
|     usage: /<command> player badge# |     usage: /<command> player badge# | ||||||
|   tempchat: |   tempchat: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue