Fix badge removing and make plugin tag configurable
This commit is contained in:
parent
21fb971a40
commit
11bb1e903b
|
@ -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>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -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>
|
||||||
|
|
|
@ -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();
|
||||||
|
@ -91,7 +93,7 @@ public class FPChat extends JavaPlugin {
|
||||||
}
|
}
|
||||||
log(Level.INFO, desc.getName() + " version " + desc.getVersion() + " enabled.");
|
log(Level.INFO, desc.getName() + " version " + desc.getVersion() + " enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
for(FPlayer p : FPlayer.getPlayers()) {
|
for(FPlayer p : FPlayer.getPlayers()) {
|
||||||
p.cleanup();
|
p.cleanup();
|
||||||
|
@ -113,12 +115,13 @@ public class FPChat extends JavaPlugin {
|
||||||
if(config.mySQLEnabled()) {
|
if(config.mySQLEnabled()) {
|
||||||
sql.disconnect();
|
sql.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(FPlayer p : FPlayer.getPlayers()) {
|
for(FPlayer p : FPlayer.getPlayers()) {
|
||||||
p.cleanup();
|
p.cleanup();
|
||||||
}
|
}
|
||||||
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() {
|
||||||
|
@ -200,10 +203,17 @@ public class FPChat extends JavaPlugin {
|
||||||
public static FPChat getPlugin(){
|
public static FPChat getPlugin(){
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPluginTag() {
|
||||||
|
return pluginTag;
|
||||||
|
}
|
||||||
|
|
||||||
public static String logo() {
|
public static String logo() {
|
||||||
return "" + ChatColor.DARK_RED + "[" + ChatColor.GREEN + ChatColor.BOLD + "FPChat" + ChatColor.RESET + ChatColor.DARK_RED + "]" + ChatColor.RESET ;
|
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
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ public class Badge {
|
||||||
public String getPerm() {
|
public String getPerm() {
|
||||||
return "fpchat.badge." + perm;
|
return "fpchat.badge." + perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRawPerm() {
|
public String getRawPerm() {
|
||||||
return perm;
|
return perm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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!");
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -116,7 +116,11 @@ public class MainConfig {
|
||||||
if (config.get("DefaultChannel")==null){
|
if (config.get("DefaultChannel")==null){
|
||||||
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) {
|
||||||
|
@ -254,5 +258,9 @@ public class MainConfig {
|
||||||
public String getDistinguishedShout() {
|
public String getDistinguishedShout() {
|
||||||
return config.getString("DistinguishedShout");
|
return config.getString("DistinguishedShout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPluginTag() {
|
||||||
|
return ChatColor.translateAlternateColorCodes('&',config.getString("PluginTag"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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(){
|
||||||
|
|
Loading…
Reference in New Issue