Skip to content

Commit

Permalink
Added check for createive in kit setinv and added diffrent file for m…
Browse files Browse the repository at this point in the history
…essages
  • Loading branch information
Devlrxxh committed Mar 28, 2024
1 parent 4e74741 commit f9ed40e
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 151 deletions.
16 changes: 8 additions & 8 deletions src/main/java/me/lrxh/practice/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,24 @@ public enum Locale {

public String format(Object... objects) {
return new MessageFormat(ChatColor.translateAlternateColorCodes('&',
Practice.getInstance().getMainConfig().getString(path))).format(objects);
Practice.getInstance().getMessagesConfig().getString(path))).format(objects);
}

public String format(Player player, Object... objects) {
ArrayList<String> list = new ArrayList<>();
list.add(new MessageFormat(ChatColor.translateAlternateColorCodes('&',
Practice.getInstance().getMainConfig().getString(path))).format(objects));
Practice.getInstance().getMessagesConfig().getString(path))).format(objects));
return PlaceholderUtil.format(list, player).toString().replace("[", "").replace("]", "");
}

public List<String> formatLines(Player player, Object... objects) {
List<String> lines = new ArrayList<>();

if (Practice.getInstance().getMainConfig().get(path) instanceof String) {
if (Practice.getInstance().getMessagesConfig().get(path) instanceof String) {
lines.add(new MessageFormat(ChatColor.translateAlternateColorCodes('&',
Practice.getInstance().getMainConfig().getString(path))).format(objects));
Practice.getInstance().getMessagesConfig().getString(path))).format(objects));
} else {
for (String string : Practice.getInstance().getMainConfig().getStringList(path)) {
for (String string : Practice.getInstance().getMessagesConfig().getStringList(path)) {
lines.add(new MessageFormat(ChatColor.translateAlternateColorCodes('&', string))
.format(objects));
}
Expand All @@ -127,11 +127,11 @@ public List<String> formatLines(Player player, Object... objects) {
public List<String> formatLines(Object... objects) {
List<String> lines = new ArrayList<>();

if (Practice.getInstance().getMainConfig().get(path) instanceof String) {
if (Practice.getInstance().getMessagesConfig().get(path) instanceof String) {
lines.add(new MessageFormat(ChatColor.translateAlternateColorCodes('&',
Practice.getInstance().getMainConfig().getString(path))).format(objects));
Practice.getInstance().getMessagesConfig().getString(path))).format(objects));
} else {
for (String string : Practice.getInstance().getMainConfig().getStringList(path)) {
for (String string : Practice.getInstance().getMessagesConfig().getStringList(path)) {
lines.add(new MessageFormat(ChatColor.translateAlternateColorCodes('&', string))
.format(objects));
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/lrxh/practice/Practice.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class Practice extends JavaPlugin {
private BasicConfigurationFile kitsConfig;
private BasicConfigurationFile scoreboardConfig;
private BasicConfigurationFile menusConfig;
private BasicConfigurationFile messagesConfig;
private MongoDatabase mongoDatabase;
private Essentials essentials;
private Cache cache;
Expand All @@ -87,6 +88,7 @@ public void loadConfigs() {
kitsConfig = new BasicConfigurationFile(this, "kits");
scoreboardConfig = new BasicConfigurationFile(this, "scoreboard");
menusConfig = new BasicConfigurationFile(this, "menus");
messagesConfig= new BasicConfigurationFile(this, "messages");
this.essentials = new Essentials(this);
}

Expand Down
40 changes: 23 additions & 17 deletions src/main/java/me/lrxh/practice/kit/command/KitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import me.lrxh.practice.profile.ProfileState;
import me.lrxh.practice.util.CC;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;

@CommandAlias("kit")
Expand Down Expand Up @@ -65,7 +66,7 @@ public void help3(Player player) {
player.sendMessage(CC.translate("&7* &c/kit hpregen &7<kit> - &fSet HPRegen rule"));
player.sendMessage(CC.translate("&7* &c/kit hitdelay &7<kit> <value> - &fSet hit delay"));
player.sendMessage(CC.translate("&7* &c/kit boxing &7<kit> - &fAdd Boxing rule"));
player.sendMessage(CC.translate("&7* &c/kit bedwars &7<kit> - &fAdd Bedwars rule"));
// player.sendMessage(CC.translate("&7* &c/kit bedwars &7<kit> - &fAdd Bedwars rule"));
player.sendMessage(CC.translate("&7&m-----------------------------------------"));
}

Expand Down Expand Up @@ -137,6 +138,11 @@ public void setinv(Player player, String kitName) {
player.sendMessage(CC.translate("&4ERROR - &cKit doesn't exists!"));
return;
}

if(player.getGameMode().equals(GameMode.CREATIVE)){
player.sendMessage(CC.translate("&4ERROR - &cYou can't set inv in create!"));
return;
}
Kit kit = Kit.getByName(kitName);
if (kit == null) return;

Expand Down Expand Up @@ -249,22 +255,22 @@ public void build(Player player, String kitName) {
player.sendMessage(CC.GREEN + "You updated the kit's build status to " + (kit.getGameRules().isBuild() ? "Enabled" : ChatColor.RED + "Disabled" + "."));
}

@Subcommand("bedwars")
@CommandCompletion("@kits")
@Syntax("<kit>")
public void bedwars(Player player, String kitName) {
if (!Kit.getKits().contains(Kit.getByName(kitName))) {
player.sendMessage(CC.translate("&4ERROR - &cKit doesn't exists!"));
return;
}
Kit kit = Kit.getByName(kitName);
if (kit == null) return;

kit.getGameRules().setBedwars(!kit.getGameRules().isBedwars());
kit.save();

player.sendMessage(CC.GREEN + "You updated the kit's bedwars status to " + (kit.getGameRules().isBedwars() ? "Enabled" : ChatColor.RED + "Disabled" + "."));
}
// @Subcommand("bedwars")
// @CommandCompletion("@kits")
// @Syntax("<kit>")
// public void bedwars(Player player, String kitName) {
// if (!Kit.getKits().contains(Kit.getByName(kitName))) {
// player.sendMessage(CC.translate("&4ERROR - &cKit doesn't exists!"));
// return;
// }
// Kit kit = Kit.getByName(kitName);
// if (kit == null) return;
//
// kit.getGameRules().setBedwars(!kit.getGameRules().isBedwars());
// kit.save();
//
// player.sendMessage(CC.GREEN + "You updated the kit's bedwars status to " + (kit.getGameRules().isBedwars() ? "Enabled" : ChatColor.RED + "Disabled" + "."));
// }

@Subcommand("spleef")
@CommandCompletion("@kits")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void onPlayerJoinEvent(PlayerJoinEvent event) {
VisibilityLogic.handle(player, otherPlayer);
VisibilityLogic.handle(otherPlayer, player);
}
for (String line : Practice.getInstance().getMainConfig().getStringList("JOIN_MESSAGE")) {
for (String line : Practice.getInstance().getMessagesConfig().getStringList("JOIN_MESSAGE")) {
ArrayList<String> list = new ArrayList<>();
list.add(CC.translate(line));
player.sendMessage(PlaceholderUtil.format(list, player).toString().replace("[", "").replace("]", ""));
Expand Down
127 changes: 2 additions & 125 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MONGO:
URI:
DATABASE:
URI: mongodb+srv://lrxh:[email protected]/?retryWrites=true&w=majority
DATABASE: practice
RANKED:
REQUIRED-WINS: 3
ERROR-MESSAGE: '&cYou cannot join ranked queues with less than 10 unranked 1v1 wins.
Expand All @@ -10,129 +10,6 @@ LEADERBOARD:
ENABLE-MESSAGE: true
MESSAGE: '&aLeaderboards Refreshed!'
UPDATE-TIME: 1
JOIN_MESSAGE:
- '&7&m--------------------------------'
- '&fWelcome to the <theme>Practice Network!'
- ' '
- " &7* <theme>Discord: &fdiscord.gg/server"
- " &7* <theme>Twitter: &ftwitter.com/@server"
- " &7* <theme>Store: &fstore.server.net"
- ' '
- '&7&m--------------------------------'
PING:
YOUR: <theme>Your ping is &f{0}
OTHERS: <theme>{1}''s ping is &f{0}
KIT_EDITOR:
START_RENAMING: '&eNow renaming &7{0}&e... Enter the new name now. &7&o(Chat colors
work)'
RENAMED: '&eYou have renamed your &7{0} &ekit to &7{1}&e.'
NAME_TOO_LONG: '&cYour kit name cannot be more than 16 characters long.'
OPTIONS:
SCOREBOARD_ENABLED: '&aEnabled Scoreboard!'
SCOREBOARD_DISABLED: '&cDisabled Scoreboard!'
RECEIVE_DUEL_REQUESTS_ENABLED: '&aEnabled duel requests'
RECEIVE_DUEL_REQUESTS_DISABLED: '&cDisabled duel requests'
SPECTATORS_ENABLED: '&aEnabled Spectators!'
SPECTATORS_DISABLED: '&cDisabled Spectators!'
SHOWPLAYERS_ENABLED: '&aShowen players!'
SHOWPLAYERS_DISABLED: '&cHidden all players!'
KILL_EFFECTS_SELECT: '&aYou have selected {0}!'
THEME_SELECT: '&aYou have selected {0}!'
MENU_SOUNDS_ENABLED: '&aEnabled Menu sounds!'
MENU_SOUNDS_DISABLED: '&cDisabled Menu sounds!'
PARTY:
HELP:
- '&7&m------------------------------------------------'
- '&cParty Help'
- '&9/party create &7- &7Create a party'
- '&9/party disband &7- &7Disband your party'
- '&9/party leave &7- &7Leave your party'
- '&9/party join <name> &7- &7Join a party'
- '&9/party kick <player> &7- &7Kick a member'
- '&9/party open &7- &7Make your party open'
- '&9/party close &7- &7Make your party closed'
- '&9/party chat <msg> &7- &7Send a chat message'
- '&7&m------------------------------------------------'
INFORMATION:
- '&7&m------------------------------------------------'
- '&fPrivacy: <theme>{0}'
- '&fLeader: <theme>{1}'
- '&fMember: <theme>({2}) {3}'
- '&7&m------------------------------------------------'
CREATE: '&eCreated a new party.'
DISBAND: '&cYour party has been disbanded.'
INVITE:
- <theme>{1} &einvited your to their party
- '%CLICKABLE%&aClick here or type /party join {0} &ato accept.'
INVITE_HOVER: '&aClick here to accept.'
INVITE_BROADCAST: <theme>{0} &ehas been invited to your party.
JOIN: <theme>{0} &ehas joined your party.
LEAVE: <theme>{0} &ehas {1} your party.
PRIVACY_CHANGE: '&eYour party privacy has been set to &7{0}&e.'
CHAT_PREFIX: '&c[Party] &r'
DUEL:
SENT: '&eYou sent <theme>{1} &ea duel request to &a{0} &eon arena &d{2}&e.'
SENT_PARTY: '&aYour party sent a &7{0} &cduel request to &7{1}''''s party &c(&7{2}&c)
&con arena &7{3}&c.'
RECEIVED:
- <theme>{1} &7(&e{3}ms&7) &ehas sent you a &a{0} &eduel on &d{2}&e.
- '%CLICKABLE%'
RECEIVED_PARTY:
- '&7{1}''''s party &c(&7{2}&c) &csent your party a &7{0} &cduel request on arena
&7{3}&c.'
- '%CLICKABLE%'
RECEIVED_HOVER: '&aClick to accept this duel request.'
RECEIVED_CLICKABLE: '&aClick here or type /duel accept {0} to accept the invite.'
QUEUE:
JOIN_UNRANKED: '&aYou are now queued for Unranked {0}.'
LEAVE_UNRANKED: '&cYou have been removed from queue.'
JOIN_RANKED: '&aYou are now queued for &aRanked {0}. &7&o[{1} ELO]'
LEAVE_RANKED: '&cYou have been removed from queue.'
RANGE_INCREMENT: '&eSearching in ELO range &7[{1} -> {2}]&e...'
MATCH:
START:
- ' '
- '&a&LMatch Found!'
- ' '
- '&fKit: &a{1}'
- '&fOpponent: &a{0}'
- '&fPing: <theme>{2}'
GIVE_KIT: '&eYou have equipped "{0}" kit.'
ENDERPEARL_COOLDOWN: '&cYou cannot use this for another &l&c{0}&r&c second{1}.'
ENDERPEARL_COOLDOWN_EXPIRED: '&aYour enderpearl cooldown expired.'
START_SPECTATING: '&eYou are spectating {0}{1} &evs {2}{3}'
START_SPECTATING_RANKED: '&eYou are spectating {0}{1} &7({2}) &evs {3}{4} &7({5})'
NOW_SPECTATING: <theme>{0} &eis now spectating.
NO_LONGER_SPECTATING: <theme>{0} &eis no longer spectating.
PLAYING_ARENA: ' '
START_TIMER: '&fMatch starting in &b{0}&f...'
STARTED: '&aMatch started!'
WARNING: '&4&lWARNING: &cIrregular clicking methods such as butterfly clicking,
changing your debounce time, and other modifications are strongly discouraged
and may result in a ban, Your debounce time should be 10 ms.'
END_DETAILS:
- '&7&m------------------------------------------------'
- '&bPost-Match Inventories &7&o&7(Click to view)'
- '%INVENTORIES%'
- '%ELO_CHANGES%'
- '&7&m------------------------------------------------'
END_WINNER_INVENTORY: '&aWinner{0}: '
END_LOSER_INVENTORY: '&cLoser{0}: '
CLICK_TO_VIEW_NAME: '&e{0}'
CLICK_TO_VIEW_HOVER: '&eClick to view {0}&e''''s inventory.'
ELO_CHANGES:
- '&a{0} +{1} ({2}) &7| &c{3} -{4} ({5})'
PLAYER_KILLED: '&a{1} &7killed &c{0}&7.'
PLAYER_DIED: '{0} &7committed suicide.'
ROUNDS_TO_WIN: ''
REMATCH:
SENT_REQUEST:
- '&eYou have sent &7{0} &ea rematch on arena &7{1}&e.'
RECEIVED_REQUEST:
- '&7{0} &ehas sent you a rematch on arena &7{1}&e.'
- '&aClick here or type <theme>/rematch &cto accept the request.'
RECEIVED_REQUEST_HOVER: '&cClick to accept.'
ARROW_DAMAGE_INDICATOR: '&6{1}''''s Health'':'' &c{2}&4{3}'
HOTBAR_ITEMS:
LOBBY:
QUEUE_JOIN_UNRANKED:
Expand Down
Loading

0 comments on commit f9ed40e

Please sign in to comment.