mirror of
https://github.com/lugamii/OtakuFFA.git
synced 2024-11-09 17:51:32 +01:00
Started working on Language.java, a.k.a customizable messages
This commit is contained in:
parent
379232dd05
commit
6e4f5dbd0f
39
src/main/java/dev/lugami/otaku/Language.java
Normal file
39
src/main/java/dev/lugami/otaku/Language.java
Normal file
@ -0,0 +1,39 @@
|
||||
package dev.lugami.otaku;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum Language {
|
||||
|
||||
PEARL_COOLDOWN("COOLDOWN.PEARL"),
|
||||
REKIT_COOLDOWN("COOLDOWN.REKIT");
|
||||
|
||||
private String path;
|
||||
|
||||
public String format(Object... objects) {
|
||||
return new MessageFormat(ChatColor.translateAlternateColorCodes('&',
|
||||
Main.getInstance().getLangConfig().getString(path))).format(objects);
|
||||
}
|
||||
|
||||
public List<String> formatLines(Object... objects) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
if (Main.getInstance().getLangConfig().get(path) instanceof String) {
|
||||
lines.add(new MessageFormat(ChatColor.translateAlternateColorCodes('&',
|
||||
Main.getInstance().getLangConfig().getString(path))).format(objects));
|
||||
} else {
|
||||
for (String string : Main.getInstance().getLangConfig().getStringList(path)) {
|
||||
lines.add(new MessageFormat(ChatColor.translateAlternateColorCodes('&', string))
|
||||
.format(objects));
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
}
|
@ -34,10 +34,7 @@ import java.util.Arrays;
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
@Getter @Setter private static Main instance;
|
||||
@Getter private BasicConfigurationFile mainConfig;
|
||||
@Getter private BasicConfigurationFile scoreboardConfig;
|
||||
@Getter private BasicConfigurationFile profileConfig;
|
||||
@Getter private BasicConfigurationFile kitsConfig;
|
||||
@Getter private BasicConfigurationFile mainConfig, scoreboardConfig, profileConfig, kitsConfig, langConfig;
|
||||
@Getter @Setter private Honcho honcho;
|
||||
@Getter private Essentials essentials;
|
||||
@Getter private Assemble board;
|
||||
@ -53,6 +50,7 @@ public class Main extends JavaPlugin {
|
||||
scoreboardConfig = new BasicConfigurationFile(this, "scoreboard");
|
||||
profileConfig = new BasicConfigurationFile(this, "profiles");
|
||||
kitsConfig = new BasicConfigurationFile(this, "kits");
|
||||
langConfig = new BasicConfigurationFile(this, "lang");
|
||||
board = new Assemble(this, new Board(), 2, false, AssembleStyle.MODIFIED, true);
|
||||
try {
|
||||
saveMethodType = SaveMethodType.valueOf(mainConfig.getString("SAVE_METHOD"));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.lugami.otaku.listener;
|
||||
|
||||
import dev.lugami.otaku.Language;
|
||||
import dev.lugami.otaku.Main;
|
||||
import dev.lugami.otaku.events.FFAJoinEvent;
|
||||
import dev.lugami.otaku.events.FFAQuitEvent;
|
||||
@ -102,7 +103,9 @@ public class FFAListener implements Listener {
|
||||
}
|
||||
if (Profile.getOrCreate(event.getPlayer()).getReKitCooldown() != null && !Profile.getOrCreate(event.getPlayer()).getReKitCooldown().hasExpired()) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(CC.translate(CC.RED + "You're still on cooldown. &7(Cooldown: " + Profile.getOrCreate(event.getPlayer()).getReKitCooldown().getTimeLeft() + ")"));
|
||||
//Profile.getOrCreate(event.getPlayer()).getReKitCooldown().getTimeLeft()
|
||||
//"You're still on cooldown. &7(Cooldown: " + Profile.getOrCreate(event.getPlayer()).getReKitCooldown().getTimeLeft() + ")"
|
||||
event.getPlayer().sendMessage(CC.translate(Language.REKIT_COOLDOWN.format(Profile.getOrCreate(event.getPlayer()).getReKitCooldown().getTimeLeft())));
|
||||
} else {
|
||||
setupKit(event.getPlayer(), event.getKit());
|
||||
Profile.getOrCreate(event.getPlayer()).setReKitCooldown(new Cooldown(60_000));
|
||||
@ -184,7 +187,8 @@ public class FFAListener implements Listener {
|
||||
if (itemStack.getType() == Material.ENDER_PEARL) {
|
||||
if (Profile.getOrCreate(player).getFFA().getKitRules().isEnderpearlCooldown()) {
|
||||
if (Main.getInstance().getEnderpearlManager().isPearlCooldown(player)) {
|
||||
event.getPlayer().sendMessage(CC.RED + "You're still in cooldown!" + CC.GRAY + " (Remaining: " + Main.getInstance().getEnderpearlManager().getPearlCooldown(event.getPlayer()) + "s)");
|
||||
// CC.RED + "You're still in cooldown!" + CC.GRAY + " (Remaining: " + Main.getInstance().getEnderpearlManager().getPearlCooldown(event.getPlayer()) + "s)"
|
||||
event.getPlayer().sendMessage(CC.translate(Language.PEARL_COOLDOWN.format(Main.getInstance().getEnderpearlManager().getPearlCooldown(event.getPlayer()))));
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
Main.getInstance().getEnderpearlManager().setPearlCooldown(player, true);
|
||||
@ -197,25 +201,16 @@ public class FFAListener implements Listener {
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||
Profile profile = Profile.getOrCreate(player);
|
||||
if (profile.getState() == ProfileState.PLAYING) {
|
||||
event.setCancelled(profile.getFFA().getKitRules().isNoFall());
|
||||
if (Profile.getOrCreate((Player) event.getEntity()).getState() == ProfileState.PLAYING) event.setCancelled(Profile.getOrCreate((Player) event.getEntity()).getFFA().getKitRules().isNoFall());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage2(EntityDamageByEntityEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (Profile.getOrCreate(player).getFFA().getKitRules().isNoDamage()) {
|
||||
event.setDamage(0.0);
|
||||
}
|
||||
if (Profile.getOrCreate((Player) event.getEntity()).getFFA().getKitRules().isNoDamage()) event.setDamage(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
3
src/main/resources/lang.yml
Normal file
3
src/main/resources/lang.yml
Normal file
@ -0,0 +1,3 @@
|
||||
COOLDOWN:
|
||||
REKIT: "You're still on re-kit cooldown. &7[{0}s]"
|
||||
PEARL: "You're still on pearl cooldown. &7[{0}s]"
|
Loading…
Reference in New Issue
Block a user