Skip to content

Commit

Permalink
Various fixes (#61)
Browse files Browse the repository at this point in the history
For reference
Changed default ingame time to 900 from 270, bow cooldown to 3 from 5; 
Added Natural-Regeneration config option
Renamed Food-Lose to Hunger-Lose
Adjusted language; Removed You can't move



* Bump version from 2.0.5 to 2.0.5-SNAPSHOT0

* Bump version from 2.0.5-SNAPSHOT0 to 2.0.5-SNAPSHOT1

* Replaced with isEmpty statement

Took 2 minutes

* Added debug messages

Took 2 minutes

* Added debug messages

Took 5 minutes

* Added debug messages

Took 59 seconds

* Bump version from 2.0.5-SNAPSHOT1 to 2.0.5-SNAPSHOT2

* Fixed issue with kit registry

Took 10 minutes

* Manual version bump

Took 19 seconds

* Bump version from 2.0.5-SNAPSHOT2 to 2.0.5-SNAPSHOT3

* Added default kit config option

Took 9 minutes

* Fix for a kit handling issue

Took 18 minutes

* Bump version from 2.0.5-SNAPSHOT3 to 2.0.5-SNAPSHOT4

* Moved default kit config option

Took 3 minutes

* Bump version from 2.0.5-SNAPSHOT4 to 2.0.5-SNAPSHOT5

* Manual version bump

Took 32 seconds

* Updated mincraft version

Took 3 minutes

* Updated dependency

I made this change earlier, why did it revert????

Took 2 minutes

* Manual version bump

Took 6 minutes

* Bump version from 2.0.5-SNAPSHOT6 to 2.0.5-SNAPSHOT7

* Correct spelling mistake

Took 5 minutes

* Bump version from 2.0.5-SNAPSHOT7 to 2.0.5-SNAPSHOT8

* Manual version bump (MiniGames box update)

Took 15 minutes

* Bump version from 2.0.5-SNAPSHOT8 to 2.0.5-SNAPSHOT9

* Manual version bump

Took 26 minutes

* Fixed kits handling items issue

Took 15 seconds

* Manual version bump

Took 20 seconds

* Bump version from 2.0.5-SNAPSHOT11 to 2.0.5-SNAPSHOT12

* Fix for handling items in kits

Took 6 minutes

* Bump version from 2.0.5-SNAPSHOT12 to 2.0.5-SNAPSHOT13

* Removal of user debug message

Took 3 minutes

* Feature update

Took 34 minutes

* Bump version from 2.0.5-SNAPSHOT13 to 2.0.5-SNAPSHOT14

* Manual version bump

Took 21 minutes

* Added redundancy checks for kits.

Took 27 seconds

* Bump version from 2.0.5-SNAPSHOT16 to 2.0.5-SNAPSHOT17

* Removed you can't move because you can move.

Took 4 minutes

* Bump version from 2.0.5-SNAPSHOT17 to 2.0.5-SNAPSHOT18

---------

Co-authored-by: version-bump[github-action] <41898282+version-bump[github-action]@users.noreply.github.com>
  • Loading branch information
Lagggpixel and version-bump[github-action] authored Jan 13, 2024
1 parent 7bf7aa4 commit 008b90c
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 33 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ repositories {
}

dependencies {
implementation("plugily.projects:MiniGamesBox-Classic:1.3.5") { isTransitive = false }
compileOnly("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT")
implementation("plugily.projects:MiniGamesBox-Classic:1.3.5-SNAPSHOT1") { isTransitive = false }
compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:24.0.1")
}

group = "plugily.projects"
version = "2.0.5-SNAPSHOT0"
version = "2.0.5-SNAPSHOT18"
description = "TheBridge"

java {
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/plugily/projects/thebridge/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import plugily.projects.minigamesbox.classic.PluginMain;
import plugily.projects.minigamesbox.classic.handlers.setup.SetupInventory;
import plugily.projects.minigamesbox.classic.handlers.setup.categories.PluginSetupCategoryManager;
import plugily.projects.minigamesbox.classic.kits.basekits.Kit;
import plugily.projects.minigamesbox.classic.utils.services.metrics.Metrics;
import plugily.projects.thebridge.arena.*;
import plugily.projects.thebridge.arena.base.BaseMenuHandler;
Expand All @@ -20,6 +21,8 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.stream.Collectors;

/**
* Created by Tigerpanzer_02 on 13.03.2022
Expand Down Expand Up @@ -75,8 +78,12 @@ public void initializePluginClasses() {


public void addKits() {
if (!getConfigPreferences().getOption("KITS")) {
// Kits are disabled, no kits will be loaded
return;
}
long start = System.currentTimeMillis();
getDebugger().debug("Adding kits...");
getDebugger().performance("Kit", "Adding kits...");
addFileName("kits/archer");
addFileName("kits/bridge");
addFileName("kits/hardcore");
Expand All @@ -94,10 +101,15 @@ public void addKits() {

getKitRegistry().setHandleItem((player, item) -> KitUtils.handleItem(this, player, item));
getKitRegistry().registerKits(optionalConfigurations);
getDebugger().debug(Level.INFO, "Kits loaded: ");
for (Kit kit : getKitRegistry().getKits()) {
getDebugger().debug(kit.getName());
}

getKitRegistry().setDefaultKit("bridge");
getDebugger().debug("Kit adding finished took {0}ms", System.currentTimeMillis() - start);
}


private void addPluginMetrics() {
getMetrics().addCustomChart(new Metrics.SimplePie("hooked_addons", () -> {
if(getServer().getPluginManager().getPlugin("TheBridge-Enlargement") != null) {
Expand Down
33 changes: 27 additions & 6 deletions src/main/java/plugily/projects/thebridge/arena/ArenaEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.*;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerMoveEvent;
Expand Down Expand Up @@ -73,6 +70,28 @@ public ArenaEvents(Main plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}

@EventHandler
public void onNaturalRegeneration(EntityRegainHealthEvent event) {
if (plugin.getConfigPreferences().getOption("NATURAL_REGENERATION")) {
return;
}
if (!(event.getEntity() instanceof Player player)) {
return;
}
Arena arena = plugin.getArenaRegistry().getArena(player);
if(arena == null) {
return;
}
if(arena.getArenaState() != ArenaState.IN_GAME) {
return;
}
if (event.getRegainReason() == EntityRegainHealthEvent.RegainReason.SATIATED ||
event.getRegainReason() == EntityRegainHealthEvent.RegainReason.REGEN ||
event.getRegainReason() == EntityRegainHealthEvent.RegainReason.EATING) {
event.setCancelled(true);
}
}

@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreakEvent(BlockBreakEvent event) {
Player player = event.getPlayer();
Expand Down Expand Up @@ -106,8 +125,10 @@ public void onBlockBreakEvent(BlockBreakEvent event) {
event.setCancelled(true);
return;
}
event.getBlock().getDrops().clear();
event.getBlock().setType(XMaterial.AIR.parseMaterial());
if (!plugin.getConfigPreferences().getOption("BLOCK_BREAK_DROP")) {
event.getBlock().getDrops().clear();
event.getBlock().setType(XMaterial.AIR.parseMaterial());
}
event.setCancelled(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import plugily.projects.thebridge.arena.ArenaUtils;
import plugily.projects.thebridge.arena.base.Base;

import java.util.logging.Level;

/**
* @author Plajer
* <p>Created at 03.06.2019
Expand All @@ -52,6 +54,7 @@ public void handleCall(PluginArena arena) {
pluginArena.setWinner(highestValue);

getPlugin().getArenaManager().stopGame(false, arena);
getPlugin().getDebugger().debug(Level.INFO, "[{0}] Game stopped due to timer ended", arena.getId());
}
if (arena.getTimer() == 30 || arena.getTimer() == 60 || arena.getTimer() == 120) {
new TitleBuilder("IN_GAME_MESSAGES_ARENA_TIME_LEFT").asKey().arena(pluginArena).sendArena();
Expand All @@ -78,8 +81,10 @@ public void handleCall(PluginArena arena) {
}

// no players - stop game
if (pluginArena.getPlayersLeft().size() == 0) {
if (pluginArena.getPlayersLeft().isEmpty()) {
getPlugin().getArenaManager().stopGame(false, pluginArena);
getPlugin().getDebugger().debug(Level.INFO, "[{0}] Game stopped due to no players left", arena.getId());
getPlugin().getDebugger().debug(Level.INFO, "[{0}] Class InGameState, pluginArena.getPlayersLeft().isEmpty() is true");
} else {
// winner check
for (Base base : pluginArena.getBases()) {
Expand All @@ -97,6 +102,8 @@ public void handleCall(PluginArena arena) {
}
}
getPlugin().getArenaManager().stopGame(false, pluginArena);
getPlugin().getDebugger().debug(Level.INFO, "[{0}] Game stopped due {1} having {2} points.", arena.getId(), base.getColor(), base.getPoints());
getPlugin().getDebugger().debug(Level.INFO, "[{0}] Class InGameState, pluginArena.getMode() == Arena.Mode.POINTS");
break;
}
}
Expand All @@ -115,6 +122,8 @@ public void handleCall(PluginArena arena) {
}
}
getPlugin().getArenaManager().stopGame(false, pluginArena);
getPlugin().getDebugger().debug(Level.INFO, "[{0}] Game stopped due {1} being winner.", arena.getId(), pluginArena.getWinner().getColor());
getPlugin().getDebugger().debug(Level.INFO, "[{0}] Class InGameState, pluginArena.getMode() == Arena.Mode.HEARTS");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void handleCall(PluginArena arena) {
}
super.handleCall(arena);
if(arenaStart) {
//needs to be executed after handle call as start location does not exists on thebridge
//needs to be executed after handle call as start location does not exist on thebridge
pluginArena.teleportAllToBaseLocation();
for (Base base : pluginArena.getBases()) {
base.addCage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public AdditionalValueInitializer(Main plugin) {
}

private void registerConfigOptions() {
getConfigPreferences().registerOption("FOOD_LOSE", new ConfigOption("Food-Lose", true));
getConfigPreferences().registerOption("HUNGER_LOSE", new ConfigOption("Hunger-Lose", false));
getConfigPreferences().registerOption("NATURAL_REGENERATION", new ConfigOption("Natural-Regeneration", false));
getConfigPreferences().registerOption("CAGE_ONLY_FLOOR", new ConfigOption("Cage.Only-Floor", false));
getConfigPreferences().registerOption("BLOCK_BREAK_DROP", new ConfigOption("Block-Break-Drop", true));
}

private void registerStatistics() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void onFoodLevelChange(FoodLevelChangeEvent event) {
if (arena == null) {
return;
}
if (plugin.getConfigPreferences().getOption("FOOD_LOSE")) {
if (plugin.getConfigPreferences().getOption("HUNGER_LOSE")) {
event.setCancelled(true);
event.setFoodLevel(20);
}
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/plugily/projects/thebridge/kits/KitUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.inventory.meta.LeatherArmorMeta;
import plugily.projects.minigamesbox.classic.PluginMain;
import plugily.projects.minigamesbox.classic.utils.misc.ColorUtil;
import plugily.projects.minigamesbox.classic.utils.version.xseries.XItemStack;
import plugily.projects.minigamesbox.classic.utils.version.xseries.XMaterial;
import plugily.projects.thebridge.arena.Arena;

Expand All @@ -15,28 +16,31 @@

public class KitUtils {

public static ItemStack handleItem(PluginMain plugin, Player player, ItemStack itemStack) {

public static ItemStack handleItem(PluginMain plugin, Player player, ItemStack itemOriginal) {
Arena arena = (Arena) plugin.getArenaRegistry().getArena(player);
ItemStack itemStack = itemOriginal.clone();

if (arena == null) {
plugin.getDebugger().performance("Kit", "Handle item method called for player {1} item stack {2} but the arena was null.", player, itemStack);
return itemStack;
}
plugin.getDebugger().performance("Kit", "Arena {0} Handle item method called for player {1} item stack {2}.", arena.getId(), player, itemStack);

// Replaces white terracotta with coloured terracotta if the player is in a team
if (itemStack.getType().equals(Material.RED_TERRACOTTA) || itemStack.getType().equals(Material.WHITE_TERRACOTTA)) {
if (itemStack.getType().equals(XMaterial.WHITE_TERRACOTTA.parseMaterial())) {
Optional<XMaterial> material = XMaterial.matchXMaterial(arena.getBase(player).getMaterialColor().toUpperCase() + "_TERRACOTTA");
material.ifPresent(xMaterial -> itemStack.setType(Objects.requireNonNull(xMaterial.parseMaterial())));
player.sendMessage("§aYour terracotta has been changed to §6" + arena.getBase(player).getMaterialColor().toUpperCase() + "_TERRACOTTA");
plugin.getDebugger().performance("Kit", "Arena {0} Changing terracotta to {1}.", arena.getId(), arena.getBase(player).getMaterialColor().toUpperCase() + "_TERRACOTTA");
return itemStack;
}

// Replaces leather armour with the coloured leather armour if the player is in a team
if (itemStack.getType().equals(Material.LEATHER_HELMET) || itemStack.getType().equals(Material.LEATHER_CHESTPLATE) || itemStack.getType().equals(Material.LEATHER_LEGGINGS) || itemStack.getType().equals(Material.LEATHER_BOOTS)) {
if (itemStack.getType().equals(XMaterial.LEATHER_HELMET.parseMaterial()) || itemStack.getType().equals(XMaterial.LEATHER_CHESTPLATE.parseMaterial()) || itemStack.getType().equals(XMaterial.LEATHER_LEGGINGS.parseMaterial()) || itemStack.getType().equals(XMaterial.LEATHER_BOOTS.parseMaterial())) {
LeatherArmorMeta itemMeta = (LeatherArmorMeta) itemStack.getItemMeta();
assert itemMeta != null;
itemMeta.setColor(ColorUtil.fromChatColor(ChatColor.valueOf(arena.getBase(player).getColor().toUpperCase())));
itemStack.setItemMeta(itemMeta);
plugin.getDebugger().performance("Kit", "Arena {0} Changing armour to {1}.", arena.getId(), arena.getBase(player).getColor().toUpperCase());
return itemStack;
}

Expand Down
37 changes: 25 additions & 12 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Bossbar:
Interval: 10


# Should we hook into bungeecord? (If you wanna use arena per server option)
# Should we hook into bungeecord? (If you want to use arena per server option)
# This option will let you access bungee.yml and its options.
# You STILL need to use external addon for HUB server game signs
# Check here for more info: https://wiki.plugily.xyz/
Expand All @@ -35,6 +35,14 @@ Bungee-Mode: false
# Saved elements: max health, health, food, experience, full inventory, armor contents, fire ticks, active potions
Inventory-Manager: true

# Kits configuration
# A server restart is required for changes to apply
Kit:
# Should we load kits?
Enabled: true
# What is the default kit for players?
# This should be the same name as the file name of the kits file in the kits folder (no .yml)
Default-Kit: bridge

Commands:
# Commands which can be used in game, remove all of them to disable (only works if Block.In-Game.Commands = true)
Expand Down Expand Up @@ -85,7 +93,7 @@ Database: false

# Should we enable in game rewards? See rewards.yml for more...
# You should also check out our script engine tutorial for rewards! https://tutorial.plugily.xyz
Rewards: true
Rewards: false


# Enable in game (eg. '[KIT][LEVEL] Tigerpanzer_02: hey') special formatting?
Expand All @@ -109,11 +117,11 @@ Firework: true

# Should blocks behind game signs change their color based on game state?
# They will change color to:
# - white (waiting for players) stained glass
# - yellow (starting) stained glass
# - orange (in game) stained glass
# - gray (ending) stained glass
# - black (restarting) stained glass
# - white (waiting for players) stained-glass
# - yellow (starting) stained-glass
# - orange (in game) stained-glass
# - gray (ending) stained-glass
# - black (restarting) stained-glass
# or define your own at signs.yml!
Sign-Block-States: true

Expand Down Expand Up @@ -170,20 +178,25 @@ Time-Manager:
Starting: 60
Shorten-Waiting-Full: 15
Shorten-Waiting-Force: 5
In-Game: 270
In-Game: 900
Ending: 10
Restarting: 5


# Change the Bow Cooldown
Bow-Cooldown: 5
Bow-Cooldown: 3

# Allow spectators on arena instances
Spectators: true

# Should players naturally regenerate health during a game
Natural-Regeneration: false

# Should players lose hunger during a game
Hunger-Lose: false

#Disable Food lose
Food-Lose: true
# Should blocks when broken drop items during a game
Block-Break-Drop: true


# Which type should be the Blocks players get. Make sure to use colored blocks here as the format is color + this string
Expand All @@ -192,7 +205,7 @@ Colored-Block-Material: "_TERRACOTTA"

# Settings about cages on all bases
Cage:
# Should only be the cagefloor removed on cage removal? (still the full cage should be selected!)
# Should only be the cage-floor removed on cage removal? (still the full cage should be selected!)
Only-Floor: false


Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/locales/language_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ In-Game:
Start: "%plugin_prefix% Prepare to jump into the opponents portal"
Reset: "%plugin_prefix% Movement is disabled while round reset"
Run: "%plugin_prefix% &aGO! &7Lets jump into the portals!!"
Title: "5,20,5;You can't move - Start in...;%number%"
Title: "5,20,5;Start in...;%number%"
#
# Sign messages
#
Expand Down

0 comments on commit 008b90c

Please sign in to comment.