Skip to content

Commit

Permalink
Merge pull request #10 from MetallicGoat/Tweaks_2.0
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
MetallicGoat authored Jul 10, 2022
2 parents 74fa17f + 9bec554 commit ae11195
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 25 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion>

<groupId>me.metallicgoat</groupId>
<artifactId>TweaksAndFeatures</artifactId>
<version>2.0.0-Pre-4</version>
<artifactId>MBedwarsTweaks</artifactId>
<version>2.0.0</version>

<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public class ConfigValue {
)) : new ArrayList<>();
public static String gen_tiers_start_tier = "&eTier &cI";

public static boolean gen_tiers_scoreboard_updating_enabled = false;
public static boolean gen_tiers_scoreboard_updating_enabled_in_game = false;
public static boolean gen_tiers_scoreboard_updating_enabled_in_lobby = false;
public static int gen_tiers_scoreboard_updating_interval = 5;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private static void save() throws Exception{
config.addComment("Speed (How often an item drops (in seconds))");
config.addComment("Time (time until action - NOTE time starts after the last action)");
config.addComment("Message (chat message sent on trigger)");
config.addComment("Earn-Sound (sound played on trigger) (You have to add this config if you want it)");

config.addEmptyLine();

Expand Down
18 changes: 10 additions & 8 deletions src/main/java/me/metallicgoat/tweaksaddon/config/MainConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import de.marcely.bedwars.api.game.spawner.DropType;
import de.marcely.bedwars.tools.Helper;
import de.marcely.bedwars.tools.YamlConfigurationDescriptor;
import me.metallicgoat.tweaksaddon.Console;
import me.metallicgoat.tweaksaddon.MBedwarsTweaksPlugin;
import me.metallicgoat.tweaksaddon.Util;
import org.bukkit.ChatColor;
Expand All @@ -24,7 +25,7 @@

public class MainConfig {

public static final byte VERSION = 1;
public static final byte VERSION = 0;
public static int CURRENT_VERSION = -1;

private static File getFile(){
Expand Down Expand Up @@ -171,7 +172,8 @@ public static void loadUnchecked() throws Exception {

ConfigValue.papi_team_you_placeholder = config.getString("Team-You-Placeholder", ConfigValue.papi_team_you_placeholder);

ConfigValue.gen_tiers_scoreboard_updating_enabled = config.getBoolean("Force-Scoreboard-Updating.Enabled", false);
ConfigValue.gen_tiers_scoreboard_updating_enabled_in_game = config.getBoolean("Force-Scoreboard-Updating.Enabled-In-Game", false);
ConfigValue.gen_tiers_scoreboard_updating_enabled_in_lobby = config.getBoolean("Force-Scoreboard-Updating.Enabled-In-Lobby", false);
ConfigValue.gen_tiers_scoreboard_updating_interval = config.getInt("Force-Scoreboard-Updating.Interval", 5);

ConfigValue.fireball_whitelist_enabled = config.getBoolean("FireballWhitelist.Enabled", false);
Expand Down Expand Up @@ -289,16 +291,16 @@ public static void loadUnchecked() throws Exception {
CURRENT_VERSION = config.getInt("file-version", -1);

if(CURRENT_VERSION == -1) {
Console.printInfo("Attempting to update Tweaks v1 configs!");
updateV1Configs(config);
save();
return;
}

// TODO uncomment before v2 releases
//if(CURRENT_VERSION != VERSION) {
if(CURRENT_VERSION != VERSION) {
updateV2Configs(config);
save();
//}
}
}
}

Expand Down Expand Up @@ -463,12 +465,12 @@ private static void save() throws Exception {

config.addEmptyLine();

// TODO lobby/game configs?
config.addComment("If set to true, the scoreboard will be force updated to refresh PAPI placeholders");
config.addComment("Scoreboard will update every X amount of seconds");
config.addComment("We recommended keeping at 5 or 10 seconds to reduce flicker");
config.addComment("WARNING: Force updating the MBedwars scoreboard may cause scoreboard flicker");
config.set("Force-Scoreboard-Updating.Enabled", ConfigValue.gen_tiers_scoreboard_updating_enabled);
config.set("Force-Scoreboard-Updating.Enabled-In-Game", ConfigValue.gen_tiers_scoreboard_updating_enabled_in_game);
config.set("Force-Scoreboard-Updating.Enabled-In-Lobby", ConfigValue.gen_tiers_scoreboard_updating_enabled_in_lobby);
config.set("Force-Scoreboard-Updating.Interval", ConfigValue.gen_tiers_scoreboard_updating_interval);

config.addEmptyLine();
Expand Down Expand Up @@ -675,7 +677,7 @@ public static void updateV1Configs(FileConfiguration config) {
if(config.contains("No-Top-Killers-Message"))
ConfigValue.no_top_killer_message = config.getStringList("No-Top-Killers-Message");

ConfigValue.gen_tiers_scoreboard_updating_enabled = config.getBoolean("Scoreboard-Updating");
ConfigValue.gen_tiers_scoreboard_updating_enabled_in_game = config.getBoolean("Scoreboard-Updating");
ConfigValue.gen_tiers_scoreboard_updating_interval = config.getInt("Scoreboard-Updating-Interval", 5);

ConfigValue.lock_team_chest_enabled = config.getBoolean("Lock-Team-Chest", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ private static void updateV1Configs(FileConfiguration config){

if (material != null)
ConfigValue.anti_drop_materials.add(material);

}
}
}
Expand All @@ -273,7 +272,6 @@ private static void updateV1Configs(FileConfiguration config){

if (material != null)
ConfigValue.sword_drop_materials.add(material);

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import de.marcely.bedwars.api.arena.ArenaStatus;
import de.marcely.bedwars.api.event.arena.RoundEndEvent;
import de.marcely.bedwars.api.event.player.PlayerJoinArenaEvent;
import de.marcely.bedwars.api.message.Message;
import me.clip.placeholderapi.PlaceholderAPI;
import me.metallicgoat.tweaksaddon.MBedwarsTweaksPlugin;
import me.metallicgoat.tweaksaddon.config.ConfigValue;
Expand Down Expand Up @@ -55,11 +56,12 @@ private static BukkitTask startUpdatingTime() {

return Bukkit.getServer().getScheduler().runTaskTimer(MBedwarsTweaksPlugin.getInstance(), () -> {
for (Arena arena : BedwarsAPI.getGameAPI().getArenas()) {

if ((arena.getStatus() == ArenaStatus.RUNNING && ConfigValue.custom_action_bar_in_game) ||
(arena.getStatus() == ArenaStatus.LOBBY && ConfigValue.custom_action_bar_in_lobby)) {

for (Player player : arena.getPlayers()) {
BedwarsAPI.getNMSHelper().showActionbar(player, PlaceholderAPI.setPlaceholders(player, ConfigValue.custom_action_bar_message));
BedwarsAPI.getNMSHelper().showActionbar(player, Message.build(PlaceholderAPI.setPlaceholders(player, ConfigValue.custom_action_bar_message)).done());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

public class GenTiers implements Listener {

// TODO Sounds option

public static HashMap<Arena, String> nextTierMap = new HashMap<>();
public static HashMap<Arena, Long> timeToNextUpdate = new HashMap<>();
private final HashMap<Arena, BukkitTask> tasksToKill = new HashMap<>();
Expand Down Expand Up @@ -146,21 +144,28 @@ private void scheduleTier(Arena arena, int key) {
}
}

// TODO improve (why is this a part of gen-tier?) (shit code)
private static BukkitTask startUpdatingTime() {
return Bukkit.getServer().getScheduler().runTaskTimer(MBedwarsTweaksPlugin.getInstance(), () -> {
if (timeToNextUpdate.isEmpty())
return;

timeToNextUpdate.forEach((arena, integer) -> {
if (arena.getStatus() != ArenaStatus.RUNNING)
return;
if (arena.getStatus() == ArenaStatus.RUNNING) {

if (MBedwarsTweaksPlugin.papiEnabled)
timeToNextUpdate.replace(arena, integer, integer - 20);

if (MBedwarsTweaksPlugin.papiEnabled)
timeToNextUpdate.replace(arena, integer, integer - 20);
if (ConfigValue.gen_tiers_scoreboard_updating_enabled_in_game
&& ((integer - 20) / 20) % ConfigValue.gen_tiers_scoreboard_updating_interval == 0)
arena.updateScoreboard();

if (ConfigValue.gen_tiers_scoreboard_updating_enabled
&& ((integer - 20) / 20) % ConfigValue.gen_tiers_scoreboard_updating_interval == 0)
arena.updateScoreboard();
} else if (arena.getStatus() == ArenaStatus.LOBBY){

if (ConfigValue.gen_tiers_scoreboard_updating_enabled_in_lobby
&& ((integer - 20) / 20) % ConfigValue.gen_tiers_scoreboard_updating_interval == 0)
arena.updateScoreboard();
}

});
}, 0L, 20L);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2.0.0-Pre-4
version: 2.0.0
name: MBedwarsTweaks
author: MetallicGoat
main: me.metallicgoat.tweaksaddon.MBedwarsTweaksPlugin
description: Tweaks and Features for MBedwars
description: Adds some extra features to MBedwars
api-version: 1.13
depend: [MBedwars]
softdepend:
Expand Down

0 comments on commit ae11195

Please sign in to comment.