Fix badge removing and make plugin tag configurable

This commit is contained in:
Ghoti 2020-09-09 11:24:09 -05:00
parent 21fb971a40
commit 11bb1e903b
9 changed files with 35 additions and 13 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>FPChat</groupId> <groupId>FPChat</groupId>
<artifactId>FPChat</artifactId> <artifactId>FPChat</artifactId>
<version>1.1</version> <version>1.1.1</version>
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
<resources> <resources>

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>FPChat</groupId> <groupId>FPChat</groupId>
<artifactId>FPChat</artifactId> <artifactId>FPChat</artifactId>
<version>1.1</version> <version>1.1.1</version>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>

View File

@ -58,6 +58,7 @@ public class FPChat extends JavaPlugin {
private MainConfig config; private MainConfig config;
private MySQLConnection sql; private MySQLConnection sql;
private static FPChat plugin; private static FPChat plugin;
private String pluginTag;
private int mysqlTimer = 1140; private int mysqlTimer = 1140;
private BukkitTask refresh = null; private BukkitTask refresh = null;
private PlayerListener listener = null; private PlayerListener listener = null;
@ -70,6 +71,7 @@ public class FPChat extends JavaPlugin {
vault.setupEconomy(); vault.setupEconomy();
vault.setupPermissions(); vault.setupPermissions();
config = new MainConfig(this); config = new MainConfig(this);
pluginTag = config.getPluginTag();
if(config.mySQLEnabled()) { if(config.mySQLEnabled()) {
sql = new MySQLConnection(this); sql = new MySQLConnection(this);
sql.generate(); sql.generate();
@ -119,6 +121,7 @@ public class FPChat extends JavaPlugin {
} }
FPlayer.purge(); FPlayer.purge();
config = new MainConfig(this); config = new MainConfig(this);
pluginTag = config.getPluginTag();
if(config.mySQLEnabled()) { if(config.mySQLEnabled()) {
sql = new MySQLConnection(this); sql = new MySQLConnection(this);
sql.generate(); sql.generate();
@ -137,7 +140,7 @@ public class FPChat extends JavaPlugin {
listener.enable(); listener.enable();
} }
Commands.allowCommands(); Commands.allowCommands();
log(Level.INFO, "FPChatX reloaded."); log(Level.INFO, "FPChat reloaded.");
} }
private void registerEvents() { private void registerEvents() {
@ -201,9 +204,16 @@ public class FPChat extends JavaPlugin {
return plugin; return plugin;
} }
public static String logo() { public String getPluginTag() {
return "" + ChatColor.DARK_RED + "[" + ChatColor.GREEN + ChatColor.BOLD + "FPChat" + ChatColor.RESET + ChatColor.DARK_RED + "]" + ChatColor.RESET ; return pluginTag;
}
public static String logo() {
String pluginTag = FPChat.getPlugin().getPluginTag();
if(pluginTag == null) {
return "" + ChatColor.DARK_RED + "[" + ChatColor.GREEN + ChatColor.BOLD + "FPChat" + ChatColor.RESET + ChatColor.DARK_RED + "]" + ChatColor.RESET ;
}
return "" + ChatColor.DARK_RED + "[" + pluginTag + ChatColor.RESET + ChatColor.DARK_RED + "]" + ChatColor.RESET ;
} }
@Override @Override

View File

@ -2,6 +2,7 @@ package com.fpghoti.fpchatx.badge;
import com.fpghoti.fpchatx.FPChat; import com.fpghoti.fpchatx.FPChat;
import com.fpghoti.fpchatx.config.BadgeConfig; import com.fpghoti.fpchatx.config.BadgeConfig;
import com.fpghoti.fpchatx.player.FPlayer;
public class Badge { public class Badge {

View File

@ -39,8 +39,11 @@ public class BadgeClearCommand extends Commands {
FPlayer p = FPlayer.getPlayer((Player)sender); FPlayer p = FPlayer.getPlayer((Player)sender);
p.setBadge(1, 0); p.setBadge(1, 0);
p.updateBadges(1, 0);
p.setBadge(2, 0); p.setBadge(2, 0);
p.updateBadges(2, 0);
p.setBadge(3, 0); p.setBadge(3, 0);
p.updateBadges(3, 0);
p.sendMessage(FPChat.logo() + ChatColor.YELLOW + " Unequipped all badges!"); p.sendMessage(FPChat.logo() + ChatColor.YELLOW + " Unequipped all badges!");
} }

View File

@ -43,7 +43,7 @@ public class BadgeEquipCommand extends Commands {
Integer slot = Integer.parseInt(args[0]), badgeId = Integer.parseInt(args[1]); Integer slot = Integer.parseInt(args[0]), badgeId = Integer.parseInt(args[1]);
if(p.canUseSlot(slot)){ if(p.canUseSlot(slot)){
if(Badge.getList().containsId(badgeId) && Badge.getList().get(badgeId).isEnabled() && p.hasBadge(badgeId)){ if(badgeId == 0 || (Badge.getList().containsId(badgeId) && Badge.getList().get(badgeId).isEnabled() && p.hasBadge(badgeId))){
p.setBadge(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!");

View File

@ -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 + "FPChat:"); FPlayer.plainMsg(p, ChatColor.GOLD + "[INFO] " + plugin.getPluginTag() + ChatColor.YELLOW + ":");
FPlayer.plainMsg(p,name); FPlayer.plainMsg(p,name);
FPlayer.plainMsg(p,primary); FPlayer.plainMsg(p,primary);
FPlayer.plainMsg(p,ctype); FPlayer.plainMsg(p,ctype);

View File

@ -117,6 +117,10 @@ public class MainConfig {
config.createSection("DefaultChannel"); config.createSection("DefaultChannel");
config.set("DefaultChannel", "Default"); config.set("DefaultChannel", "Default");
} }
if (config.get("PluginTag")==null){
config.createSection("PluginTag");
config.set("PluginTag", "&a&lFPChat&r");
}
try { try {
config.save(configFile); config.save(configFile);
} catch (IOException e) { } catch (IOException e) {
@ -255,4 +259,8 @@ public class MainConfig {
return config.getString("DistinguishedShout"); return config.getString("DistinguishedShout");
} }
public String getPluginTag() {
return ChatColor.translateAlternateColorCodes('&',config.getString("PluginTag"));
}
} }

View File

@ -237,7 +237,7 @@ public class FPlayer {
} }
public void setBadge(int slot, int badgeId){ public void setBadge(int slot, int badgeId){
if(!Badge.getList().get(badgeId).isEnabled()) { if(!Badge.getList().get(badgeId).isEnabled() && badgeId != 0) {
return; return;
} }
if(slot > 3){ if(slot > 3){
@ -250,7 +250,7 @@ public class FPlayer {
createPlayer(); createPlayer();
} }
FPChat.getPlugin().getMySQLConnection().set("badge_slot" + String.valueOf(slot), badgeId, "player_uuid", "=", uuid.toString(), FPChat.getPlugin().getMainConfig().getChatFeatureTable()); FPChat.getPlugin().getMySQLConnection().set("badge_slot" + String.valueOf(slot), badgeId, "player_uuid", "=", uuid.toString(), FPChat.getPlugin().getMainConfig().getChatFeatureTable());
getBadges(); getSQLBadges();
} }
public void createPlayer(){ public void createPlayer(){