Skip to content

Commit

Permalink
4.1.0 (#23)
Browse files Browse the repository at this point in the history
Added sounds to events of the game (join, leave, watch, teleport, victory, death)
Added ACTION BAR message with the remaining opponents count when a player dies
Added Prizes for the killer
Added config to block commands for EVERYONE during a game
Added color for the , and & on lists
Added Russian translation
Every command and subcommand is now editable
Cleaned the ConfigManager
Fixed attacks cancelled on group mode
  • Loading branch information
RoinujNosde committed Dec 21, 2020
1 parent d18bb00 commit 3f75f6e
Show file tree
Hide file tree
Showing 22 changed files with 497 additions and 386 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.roinujnosde</groupId>
<artifactId>TitansBattle</artifactId>
<version>4.0.1-beta</version>
<version>4.1.0-beta</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -129,7 +129,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<version>1.9.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
48 changes: 28 additions & 20 deletions src/main/java/me/roinujnosde/titansbattle/TitansBattle.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
Expand All @@ -43,10 +44,7 @@

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
import java.util.*;
import java.util.stream.Collectors;

/**
Expand All @@ -68,6 +66,7 @@ public final class TitansBattle extends JavaPlugin {

@Override
public void onEnable() {
saveDefaultConfig();
ConfigurationSerialization.registerClass(GameConfiguration.class);
ConfigurationSerialization.registerClass(Kit.class);
ConfigurationSerialization.registerClass(Prizes.class);
Expand All @@ -84,12 +83,12 @@ public void onEnable() {
databaseManager.setup();

loadGroupsPlugin();
saveDefaultConfig();
setupEconomy();

pcm = new PaperCommandManager(this);
pcm.enableUnstableAPI("help");
configureCommands();
registerEvents();
databaseManager.loadDataToMemory();
gameManager.startOrSchedule();
}
Expand All @@ -99,16 +98,27 @@ private void configureCommands() {
registerDependencies();
registerCompletions();
registerContexts();
registerCommands();
registerReplacements();
registerConditions();
registerEvents();
registerCommands();
}

private void setDefaultLocale() {
String[] s = configManager.getLanguage().split("_");
pcm.getLocales().setDefaultLocale(new Locale(s[0]));
}

private void registerReplacements() {
ConfigurationSection commandsSection = getConfig().getConfigurationSection("commands");
if (commandsSection == null) {
return;
}
Set<String> commands = commandsSection.getKeys(false);
for (String command : commands) {
pcm.getCommandReplacements().addReplacement(command, commandsSection.getString(command) + "|" + command);
}
}

private void registerContexts() {
pcm.getCommandContexts().registerIssuerOnlyContext(Game.class, supplier -> gameManager.getCurrentGame());
pcm.getCommandContexts().registerContext(Date.class, supplier -> {
Expand Down Expand Up @@ -207,7 +217,7 @@ private void setupEconomy() {

@Override
public void onDisable() {
gameManager.finishGame(null, null, null);
gameManager.finishGame(null, null, null, null);
databaseManager.close();
}

Expand Down Expand Up @@ -252,13 +262,13 @@ public LanguageManager getLanguageManager() {
* @param config a FileConfiguration to access
* @return the language from the config, with its color codes (&) translated
*/
public @NotNull String getLang(String path, @Nullable FileConfiguration config) {
if (config == null) {
config = getLanguageManager().getConfig();
public @NotNull String getLang(@NotNull String path, @Nullable FileConfiguration config) {
String language = null;
if (config != null) {
language = config.getString("language." + path);
}
String language = config.getString(path);
if (language == null) {
return path;
language = getLanguageManager().getConfig().getString(path, "Missing key: " + path);
}
return ChatColor.translateAlternateColorCodes('&', language);
}
Expand All @@ -269,7 +279,7 @@ public LanguageManager getLanguageManager() {
* @param path where the String is
* @return the language from the default language file
*/
public String getLang(String path) {
public String getLang(@NotNull String path) {
return getLang(path, (FileConfiguration) null);
}

Expand All @@ -281,14 +291,12 @@ public String getLang(String path) {
* @return the overrider language if found, or from the default language
* file
*/
public String getLang(String path, @Nullable Game game) {
public String getLang(@NotNull String path, @Nullable Game game) {
YamlConfiguration configFile = null;
if (game != null) {
YamlConfiguration configFile = gameConfigurationDao.getConfigFile(game.getConfig());
if (configFile != null) {
getLang("language." + path, configFile);
}
configFile = gameConfigurationDao.getConfigFile(game.getConfig());
}
return getLang(path);
return getLang(path, configFile);
}

/**
Expand Down
Loading

0 comments on commit 3f75f6e

Please sign in to comment.