Skip to content

Commit dcc494e

Browse files
committed
Misc fixes and style changes
1 parent 7e5d8f3 commit dcc494e

25 files changed

Lines changed: 217 additions & 205 deletions

pvpmanager/src/main/java/me/chancesd/pvpmanager/command/Announce.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import org.bukkit.command.CommandSender;
66
import org.bukkit.command.PluginCommand;
77

8+
import me.chancesd.pvpmanager.setting.Lang;
89
import me.chancesd.pvpmanager.setting.Permissions;
10+
import me.chancesd.pvpmanager.setting.lang.Replacement;
911
import me.chancesd.sdutils.command.ArgumentType;
1012
import me.chancesd.sdutils.command.BaseCommand;
1113
import me.chancesd.sdutils.command.CommandArgument;
@@ -25,7 +27,7 @@ public void execute(final CommandSender sender, final String label, final List<C
2527
final String message = getArgument(args, "message").getValue();
2628

2729
// Broadcast the message to all players
28-
final String colorizedMessage = ChatUtils.colorize(message);
30+
final String colorizedMessage = ChatUtils.colorize(message).replace(Replacement.PREFIX.getPlaceholder(), Lang.PREFIX.msg());
2931
Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage(colorizedMessage));
3032

3133
// Also send to console

pvpmanager/src/main/java/me/chancesd/pvpmanager/player/CombatPlayer.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class CombatPlayer extends EcoPlayer {
3838

3939
private boolean newbie;
4040
private boolean tagged;
41-
private boolean pvpState = Conf.DEFAULT_PVP.asBool() || CombatUtils.isNPC(getPlayer());
41+
private boolean pvpState;
4242
private boolean pvpLogged;
4343
private boolean override;
4444
private boolean loaded;
@@ -59,6 +59,7 @@ public class CombatPlayer extends EcoPlayer {
5959
public CombatPlayer(@NotNull final Player player, final PvPManager plugin) {
6060
super(player, plugin.getDependencyManager().getEconomy());
6161
this.plugin = plugin;
62+
this.pvpState = Conf.DEFAULT_PVP.asBool();
6263
setCombatWorld(plugin.getWorldManager().getWorld(getPlayer().getWorld()));
6364
initializeNameTag();
6465
}
@@ -122,8 +123,12 @@ public final void disableFly() {
122123
}
123124

124125
public final void setNewbie(final boolean newbie) {
126+
setNewbie(newbie, 0);
127+
}
128+
129+
public final void setNewbie(final boolean newbie, final long time) {
125130
if (newbie) {
126-
this.newbieTask = new NewbieTask(this, 0);
131+
this.newbieTask = new NewbieTask(this, time);
127132
} else if (this.newbie && newbieTask != null) {
128133
newbieTask.cancel();
129134
this.newbieTask = null;
@@ -406,13 +411,15 @@ private void initializeNameTag() {
406411
*/
407412
public void applyPlayerData(final PlayerData data) {
408413
// Apply loaded data (overriding defaults)
409-
this.pvpState = data.isPvpEnabled();
414+
this.pvpState = data.isPvpEnabled() || CombatUtils.isNPC(getPlayer());
410415
this.toggleTime = data.getToggleTime();
411416
this.newbie = data.isNewbie();
412417

413-
// Handle newbie task if needed
414-
if (this.newbie && data.getNewbieTimeLeft() > 0) {
415-
this.newbieTask = new NewbieTask(this, data.getNewbieTimeLeft());
418+
if (Conf.NEWBIE_ENABLED.asBool() && (this.newbie && data.getNewbieTimeLeft() > 0 || !getPlayer().hasPlayedBefore())) {
419+
setNewbie(true, data.getNewbieTimeLeft());
420+
} else if (!Conf.NEWBIE_ENABLED.asBool() && this.newbie) {
421+
// If newbie protection is disabled but player has newbie flag, clear it
422+
setNewbie(false);
416423
}
417424

418425
// Apply world-specific PvP rules (these override database values)

pvpmanager/src/main/java/me/chancesd/pvpmanager/player/PlayerData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Map;
44
import java.util.UUID;
55

6+
import me.chancesd.pvpmanager.setting.Conf;
67
import me.chancesd.pvpmanager.storage.fields.UserDataFields;
78
import me.chancesd.pvpmanager.utils.CombatUtils;
89

@@ -104,7 +105,7 @@ public static PlayerData fromMap(Map<String, Object> userData) {
104105
* Creates default PlayerData for new players
105106
*/
106107
public static PlayerData createDefault() {
107-
return new PlayerData(null, null, null, false, 0, false, 0, System.currentTimeMillis());
108+
return new PlayerData(null, null, null, Conf.DEFAULT_PVP.asBool(), 0, false, 0, System.currentTimeMillis());
108109
}
109110

110111
/**

pvpmanager/src/main/java/me/chancesd/pvpmanager/setting/Conf.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public static void initialize(final PvPManager pl, final YamlConfiguration yamlC
317317
try {
318318
setting.loadSetting();
319319
} catch (final Exception ex) {
320-
Log.severe("Error loading the seetings for " + setting.section + "." + setting.configKey, ex);
320+
Log.severe("Error loading settings for " + setting.section + "." + setting.configKey, ex);
321321
}
322322
});
323323
Log.infoColor(ChatColor.GREEN + "Using player nametags: " + ChatColor.AQUA + (NAMETAG_COMBAT_ENABLED.asBool() || TOGGLE_NAMETAG_ENABLED.asBool()));
@@ -327,7 +327,7 @@ private static <R extends Enum<R>> R loadEnum(final Class<R> clazz, final String
327327
try {
328328
return Enum.valueOf(clazz, value);
329329
} catch (final IllegalArgumentException e) {
330-
Log.warning("Error! " + clazz.getSimpleName() + " '" + value + "' does not exist!");
330+
Log.warning("Error! " + clazz.getSimpleName() + " '" + value + "' does not exist! Check your config");
331331
return null;
332332
}
333333
}

pvpmanager/src/main/resources/config.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Combat Tag:
5050
Boss Bar:
5151
Enabled: true
5252
# You can use any PlaceholderAPI placeholders here
53-
Message: '&8&l[&c&lIn Combat&8&l] &e&l<time> seconds'
53+
Message: '&8&l[&c&lCOMBAT&8&l] &e&l<time> seconds'
5454
# See here for bar color options - https://hub.spigotmc.org/javadocs/spigot/org/bukkit/boss/BarColor.html
5555
BarColor: RED
5656
# See here for bar style options - https://hub.spigotmc.org/javadocs/spigot/org/bukkit/boss/BarStyle.html
@@ -86,6 +86,8 @@ Combat Tag:
8686
- 'BUTTON'
8787
- 'BED'
8888
- 'PRESSURE_PLATE'
89+
- 'SLAB'
90+
- 'STAIRS'
8991
- 'CARPET'
9092
# Command whitelist is recursive, allowing 'tell' will allow 'tell' with any number of arguments
9193
Commands:
@@ -120,7 +122,7 @@ Combat Log Punishments:
120122
# List of commands to execute on combat log, use '{player}' for player name
121123
# The 'announce' command can be optionally used to broadcast, you can add more or to disable just delete the command
122124
Commands On Combat Log:
123-
- 'announce {prefix} {player} tried to escape combat and died!'
125+
- 'announce #bf973f{prefix} {player} #361010tried to escape combat!'
124126

125127
######################
126128
#### PvP Toggle ####
@@ -299,8 +301,8 @@ Database:
299301
# PlaceholderAPI boolean formatting
300302
Placeholders:
301303
Boolean Format:
302-
True: '&a'
303-
False: '&c'
304+
True: '#6fc93e'
305+
False: '#c9453e'
304306

305307
# Should PvPManager be allowed to check for updates and tell you about them
306308
# Auto Update - After checking should the update be downloaded automatically for you?

pvpmanager/src/main/resources/locale/messages.properties

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ Prefix = &#992222&lPvP &#FF5555➤
1010
# PvP Toggle
1111
PvP_Disabled = {prefix} &aPvP disabled! You are now protected
1212
PvP_Enabled = {prefix} &cPvP enabled! You can now attack and be attacked
13-
Attack_Denied_You = {prefix} &#CC5555You have PvP protection!
14-
Attack_Denied_Other = {prefix} &f{player} &#CC5555has PvP protection!
13+
Attack_Denied_You = {prefix} &#c9453eYou have PvP protection!
14+
Attack_Denied_Other = {prefix} &f{player} &#c9453ehas PvP protection!
1515
PvP_Force_Enabled_WorldGuard = {prefix} &6PvP protection disabled in this PvP region
1616
PvP_Disabled_Fee = {prefix} &aYou paid a &#FFD700{money} &afee for having PvP disabled
1717
PvP_Disabled_Fee_Not_Enough = {prefix} &6PvP protection disabled - insufficient funds for the fee
1818

1919
# Combat Tag
2020
Tagged_Attacker = {prefix} &7You tagged &f{player}&7! Do not log out!
2121
Tagged_Defender = {prefix} &7Tagged by &f{player}&7! Do not log out!
22-
Out_Of_Combat = {prefix} &aYou are no longer in combat.
22+
Out_Of_Combat = {prefix} &aYou are no longer in combat
2323
Out_Of_Combat_ActionBar = &aYou are no longer in combat
2424
Command_Denied_InCombat = {prefix} &cCommand denied! You are still in combat!
2525
Block_Place_Blocked_InCombat = {prefix} &cYou can't place blocks while in combat!
@@ -34,32 +34,32 @@ Interact_Blocked_InCombat = {prefix} &cYou can't right-click while in combat!
3434
Teleport_Blocked_InCombat = {prefix} &cYou can't teleport while in combat!
3535
Totem_Blocked_InCombat = {prefix} &cTotems of undying are blocked while in combat!
3636
Inventory_Blocked_InCombat = {prefix} &cYou can't open an inventory while in combat!
37-
Pushback_Warning = {prefix} &#CC5555You can't run away to safezones while in combat!
37+
Pushback_Warning = {prefix} &#c9453eYou can't run away to safezones while in combat!
3838

3939
# Newbie Protection
4040
Newbie_Protection = {prefix} &aWelcome! You are protected against PvP for &e{time}
4141
Newbie_Protection_End = {prefix} &6Your PvP protection expired! You can be attacked!
4242
Newbie_Protection_Removed = {prefix} &aYou removed your PvP protection! Be careful
43-
Newbie_Protection_On_Hit = {prefix} &#CC5555You have PvP protection! If you really want to do PvP, remove it with &f/newbie disable
44-
Newbie_Protection_Attacker = {prefix} &#CC5555&f{player} &#CC5555has Newbie protection!
43+
Newbie_Protection_On_Hit = {prefix} &#c9453eYou have PvP protection! If you really want to do PvP, remove it with &f/newbie disable
44+
Newbie_Protection_Attacker = {prefix} &#c9453e&f{player} &#c9453ehas Newbie protection!
4545
Newbie_Time_Check = {prefix} &7You are protected from PvP for &e{time}
4646
Newbie_Time_Check_Other = {prefix} &7&f{player} &7is protected from PvP for another &e{time}
4747
Newbie_Command_Blocked = {prefix} &cYou cannot use this command while you have Newbie protection!
4848
Newbie_Pickup_Items_Blocked = {prefix} &cYou can't pickup items while you have Newbie protection!
4949
Newbie_Force_Removed_WorldGuard = {prefix} &6Your new player protection was removed for being inside a PvP region
5050

5151
# Respawn Protection
52-
Respawn_Protection = {prefix} &#CC5555You have respawn protection!
53-
Respawn_Protection_Other = {prefix} &#CC5555&f{player} &#CC5555has respawn protection!
52+
Respawn_Protection = {prefix} &#c9453eYou have respawn protection!
53+
Respawn_Protection_Other = {prefix} &#c9453e&f{player} &#c9453ehas respawn protection!
5454

5555
# World Protection
56-
World_Protection = {prefix} &#CC5555PvP is disabled in this world!
56+
World_Protection = {prefix} &#c9453ePvP is disabled in this world!
5757

5858
# AFK Protection
59-
AFK_Protection = {prefix} &#CC5555This player can't be attacked while AFK
59+
AFK_Protection = {prefix} &#c9453eThis player can't be attacked while AFK
6060

6161
# Global Protection
62-
Global_Protection = {prefix} &#CC5555PvP combat is globally disabled
62+
Global_Protection = {prefix} &#c9453ePvP combat is globally disabled
6363

6464
# Player Kills
6565
Money_Reward = {prefix} &aYou got &#FFD700{money} &acoins for killing player &f{victim}&a!
@@ -112,8 +112,8 @@ Tag_Timeleft = &7You are in combat for another &e{time}
112112
Tag_Not_In_Combat = &7You are currently not in combat
113113

114114
# Variables
115-
Enabled = &aEnabled
116-
Disabled = &cDisabled
115+
Enabled = #6fc93eEnabled
116+
Disabled = #c9453eDisabled
117117
# The times below are what will show wherever {time} is used
118118
Time_Days = days
119119
Time_Hours = hours

pvpmanager/src/main/resources/locale/messages_ar.properties

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Prefix = &\#992222&lPvP &\#FF5555➤
1010
# PvP Toggle
1111
PvP_Disabled = {prefix} &aPvP disabled\! You are now protected
1212
PvP_Enabled = {prefix} &cPvP enabled\! You can now attack and be attacked
13-
Attack_Denied_You = {prefix} &\#CC5555You have PvP protection\!
14-
Attack_Denied_Other = {prefix} &f{player} &\#CC5555has PvP protection\!
13+
Attack_Denied_You = {prefix} &#c9453eYou have PvP protection\!
14+
Attack_Denied_Other = {prefix} &f{player} &#c9453ehas PvP protection\!
1515
PvP_Force_Enabled_WorldGuard = {prefix} &6PvP force enabled because you are inside a PvP region
1616
PvP_Disabled_Fee = {prefix} &aYou paid a &\#FFD700{money} &afee for having PvP disabled
1717
PvP_Disabled_Fee_Not_Enough = {prefix} &6PvP enabled because you don''t have enough money
@@ -40,26 +40,26 @@ Pushback_Warning = &cYou can't run away to safezones while in combat\!
4040
Newbie_Protection = {prefix} &aWelcome\! You are protected against PvP for&a {time}&a minutes
4141
Newbie_Protection_End = {prefix} &6Your PvP protection has expired\! You can now be attacked\!
4242
Newbie_Protection_Removed = {prefix} &aYou removed your PvP protection\! Be careful
43-
Newbie_Protection_On_Hit = {prefix} &\#CC5555You have PvP protection\! If you really want to do PvP, remove it with &f/newbie disable
44-
Newbie_Protection_Attacker = {prefix} &\#CC5555&f{player} &\#CC5555has Newbie protection\!
43+
Newbie_Protection_On_Hit = {prefix} &#c9453eYou have PvP protection\! If you really want to do PvP, remove it with &f/newbie disable
44+
Newbie_Protection_Attacker = {prefix} &#c9453e&f{player} &#c9453ehas Newbie protection\!
4545
Newbie_Time_Check = {prefix} &7You are protected from PvP for &e{time}
4646
Newbie_Time_Check_Other = {prefix} &7&f{player} &7is protected from PvP for another &e{time}
4747
Newbie_Command_Blocked = {prefix} &cYou cannot use this command while you have newbie protection\!
4848
Newbie_Pickup_Items_Blocked = {prefix} &cYou can''t pickup items while you have newbie protection
4949
Newbie_Force_Removed_WorldGuard = {prefix} &6Your new player protection was removed for being inside a PvP region
5050

5151
# Respawn Protection
52-
Respawn_Protection = {prefix} &\#CC5555You have respawn protection\!
53-
Respawn_Protection_Other = {prefix} &\#CC5555&f{player} &\#CC5555has respawn protection\!
52+
Respawn_Protection = {prefix} &#c9453eYou have respawn protection\!
53+
Respawn_Protection_Other = {prefix} &#c9453e&f{player} &#c9453ehas respawn protection\!
5454

5555
# World Protection
56-
World_Protection = {prefix} &\#CC5555PvP is disabled in this world\!
56+
World_Protection = {prefix} &#c9453ePvP is disabled in this world\!
5757

5858
# AFK Protection
59-
AFK_Protection = {prefix} &\#CC5555This player can''t be attacked while AFK
59+
AFK_Protection = {prefix} &#c9453eThis player can''t be attacked while AFK
6060

6161
# Global Protection
62-
Global_Protection = {prefix} &\#CC5555PvP combat is globally disabled
62+
Global_Protection = {prefix} &#c9453ePvP combat is globally disabled
6363

6464
# Player Kills
6565
Money_Reward = &aYou got &\#FFD700{money} &acoins for killing player &f{victim} &a\!

pvpmanager/src/main/resources/locale/messages_bg.properties

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Prefix = &\#992222&lPvP &\#FF5555➤
1010
# PvP Toggle
1111
PvP_Disabled = {prefix} &aPvP disabled\! You are now protected
1212
PvP_Enabled = {prefix} &cPvP enabled\! You can now attack and be attacked
13-
Attack_Denied_You = {prefix} &\#CC5555Вие имате PvP защита\!
14-
Attack_Denied_Other = {prefix} &f{player} &\#CC5555има PvP защита\!
13+
Attack_Denied_You = {prefix} &#c9453eВие имате PvP защита\!
14+
Attack_Denied_Other = {prefix} &f{player} &#c9453eима PvP защита\!
1515
PvP_Force_Enabled_WorldGuard = {prefix} &6PvP принудително активирано, защото сте в PvP регион
1616
PvP_Disabled_Fee = {prefix} &aПлатихте такса от &\#FFD700{money} &aза деактивиране на PvP
1717
PvP_Disabled_Fee_Not_Enough = {prefix} &6PvP enabled because you don''t have enough money
@@ -40,26 +40,26 @@ Pushback_Warning = &cНе можете да бягате към безопасн
4040
Newbie_Protection = {prefix} &aДобре дошли\! Вие сте защитени срещу PvP за&a {time}&a минути
4141
Newbie_Protection_End = {prefix} &6Вашата PvP защита изтече\! Вече може да бъдете атакувани\!
4242
Newbie_Protection_Removed = {prefix} &aПремахнахте вашата PvP защита\! Бъдете внимателни
43-
Newbie_Protection_On_Hit = {prefix} &\#CC5555You have PvP protection\! If you really want to do PvP, remove it with &f/newbie disable
44-
Newbie_Protection_Attacker = {prefix} &\#CC5555&f{player} &\#CC5555has Newbie protection\!
43+
Newbie_Protection_On_Hit = {prefix} &#c9453eYou have PvP protection\! If you really want to do PvP, remove it with &f/newbie disable
44+
Newbie_Protection_Attacker = {prefix} &#c9453e&f{player} &#c9453ehas Newbie protection\!
4545
Newbie_Time_Check = {prefix} &7Вие сте защитени от PvP за &e{time}
4646
Newbie_Time_Check_Other = {prefix} &7&f{player} &7е защитен от PvP за още &e{time}
4747
Newbie_Command_Blocked = {prefix} &cНе можете да използвате тази команда, докато имате защита за новаци\!
4848
Newbie_Pickup_Items_Blocked = {prefix} &cНе можете да взимате предмети, докато имате защита за новаци
4949
Newbie_Force_Removed_WorldGuard = {prefix} &6Вашата защита за нови играчи беше премахната, защото сте в PvP регион
5050

5151
# Respawn Protection
52-
Respawn_Protection = {prefix} &\#CC5555Имате защита при прераждане\!
53-
Respawn_Protection_Other = {prefix} &\#CC5555&f{player} &\#CC5555има защита при прераждане\!
52+
Respawn_Protection = {prefix} &#c9453eИмате защита при прераждане\!
53+
Respawn_Protection_Other = {prefix} &#c9453e&f{player} &#c9453eима защита при прераждане\!
5454

5555
# World Protection
56-
World_Protection = {prefix} &\#CC5555PvP е изключено в този свят\!
56+
World_Protection = {prefix} &#c9453ePvP е изключено в този свят\!
5757

5858
# AFK Protection
59-
AFK_Protection = {prefix} &\#CC5555Този играч не може да бъде атакуван, докато е AFK
59+
AFK_Protection = {prefix} &#c9453eТози играч не може да бъде атакуван, докато е AFK
6060

6161
# Global Protection
62-
Global_Protection = {prefix} &\#CC5555PvP битката е глобално деактивирана
62+
Global_Protection = {prefix} &#c9453ePvP битката е глобално деактивирана
6363

6464
# Player Kills
6565
Money_Reward = &aYou got &\#FFD700{money} &acoins for killing player &f{victim} &a\!

0 commit comments

Comments
 (0)