Skip to content

Commit

Permalink
#patch API revamp and bug fixes (#75)
Browse files Browse the repository at this point in the history
* Bump version from 2.0.7 to 2.0.7-SNAPSHOT0

* feat: API rework compatibility

* fix: clean up code

* Bump version from 2.0.7-SNAPSHOT0 to 2.0.7-SNAPSHOT1

---------

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 Jun 20, 2024
1 parent c42fa51 commit 3bbabca
Show file tree
Hide file tree
Showing 21 changed files with 205 additions and 218 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ repositories {
}

dependencies {
implementation("plugily.projects:MiniGamesBox-Classic:1.3.8") { isTransitive = false }
compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
implementation("plugily.projects:MiniGamesBox-Classic:1.3.9") { isTransitive = false }
compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:24.0.1")
compileOnly(files("lib/CorpseReborn.jar"))
}

group = "plugily.projects"
version = "2.0.7"
version = "2.0.7-SNAPSHOT1"
description = "MurderMystery"

java {
Expand Down
16 changes: 1 addition & 15 deletions src/main/java/plugily/projects/murdermystery/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@

package plugily.projects.murdermystery;

import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.jetbrains.annotations.TestOnly;
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.utils.services.metrics.Metrics;
import plugily.projects.murdermystery.arena.Arena;
import plugily.projects.murdermystery.arena.ArenaEvents;
import plugily.projects.murdermystery.arena.ArenaManager;
import plugily.projects.murdermystery.arena.ArenaRegistry;
import plugily.projects.murdermystery.arena.ArenaUtils;
import plugily.projects.murdermystery.arena.*;
import plugily.projects.murdermystery.arena.special.SpecialBlockEvents;
import plugily.projects.murdermystery.arena.special.mysterypotion.MysteryPotionRegistry;
import plugily.projects.murdermystery.arena.special.pray.PrayerRegistry;
Expand All @@ -45,8 +39,6 @@
import plugily.projects.murdermystery.handlers.trails.BowTrailsHandler;
import plugily.projects.murdermystery.handlers.trails.TrailsManager;

import java.io.File;

/**
* Created by Tigerpanzer_02 on 13.03.2022
*/
Expand All @@ -65,12 +57,6 @@ public Main() {
super();
}

@TestOnly
protected Main(
JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
super(loader, description, dataFolder, file);
}

@Override
public void onEnable() {
long start = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import plugily.projects.minigamesbox.classic.api.event.PlugilyEvent;
import plugily.projects.minigamesbox.api.events.PlugilyEvent;
import plugily.projects.murdermystery.arena.Arena;

/**
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/plugily/projects/murdermystery/arena/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import plugily.projects.minigamesbox.classic.arena.ArenaState;
import plugily.projects.minigamesbox.api.arena.IArenaState;
import plugily.projects.minigamesbox.api.user.IUser;
import plugily.projects.minigamesbox.classic.arena.PluginArena;
import plugily.projects.minigamesbox.classic.arena.managers.PluginMapRestorerManager;
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
import plugily.projects.minigamesbox.classic.user.User;
import plugily.projects.minigamesbox.classic.utils.hologram.ArmorStandHologram;
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
import plugily.projects.murdermystery.HookManager;
import plugily.projects.murdermystery.Main;
import plugily.projects.murdermystery.arena.corpse.Corpse;
import plugily.projects.murdermystery.arena.corpse.Stand;
import plugily.projects.murdermystery.arena.managers.MapRestorerManager;
import plugily.projects.murdermystery.arena.managers.ScoreboardManager;
import plugily.projects.murdermystery.arena.role.Role;
import plugily.projects.murdermystery.arena.special.SpecialBlock;
import plugily.projects.murdermystery.arena.states.InGameState;
import plugily.projects.murdermystery.arena.states.RestartingState;
import plugily.projects.murdermystery.arena.states.StartingState;
import plugily.projects.murdermystery.HookManager;
import plugily.projects.murdermystery.arena.special.SpecialBlock;
import plugily.projects.murdermystery.arena.states.WaitingState;

import java.util.*;
Expand Down Expand Up @@ -73,7 +73,7 @@ public class Arena extends PluginArena {
private boolean hideChances;
private boolean goldVisuals = false;
private final Map<CharacterType, Player> gameCharacters = new EnumMap<>(CharacterType.class);
private MapRestorerManager mapRestorerManager;
private final MapRestorerManager mapRestorerManager;
private ArmorStandHologram bowHologram;

public Arena(String id) {
Expand All @@ -82,10 +82,10 @@ public Arena(String id) {
setScoreboardManager(new ScoreboardManager(this));
mapRestorerManager = new MapRestorerManager(this);
setMapRestorerManager(mapRestorerManager);
addGameStateHandler(ArenaState.IN_GAME, new InGameState());
addGameStateHandler(ArenaState.RESTARTING, new RestartingState());
addGameStateHandler(ArenaState.STARTING, new StartingState());
addGameStateHandler(ArenaState.WAITING_FOR_PLAYERS, new WaitingState());
addGameStateHandler(IArenaState.IN_GAME, new InGameState());
addGameStateHandler(IArenaState.RESTARTING, new RestartingState());
addGameStateHandler(IArenaState.STARTING, new StartingState());
addGameStateHandler(IArenaState.WAITING_FOR_PLAYERS, new WaitingState());
}

public static void init(Main plugin) {
Expand Down Expand Up @@ -178,7 +178,7 @@ public void startGoldVisuals() {
return;
}
visualTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
if(!goldVisuals || !plugin.isEnabled() || goldSpawnPoints.isEmpty() || getArenaState() != ArenaState.WAITING_FOR_PLAYERS) {
if(!goldVisuals || !plugin.isEnabled() || goldSpawnPoints.isEmpty() || getArenaState() != IArenaState.WAITING_FOR_PLAYERS) {
//we need to cancel it that way as the arena class is an task
visualTask.cancel();
return;
Expand Down Expand Up @@ -234,7 +234,7 @@ public int getTotalRoleChances(Role role) {
int totalRoleChances = 0;

for(Player p : getPlayers()) {
User user = getPlugin().getUserManager().getUser(p);
IUser user = getPlugin().getUserManager().getUser(p);
totalRoleChances += getContributorValue(role, user);
}
//avoid division / 0
Expand Down Expand Up @@ -387,22 +387,22 @@ public void setPlayerSpawnPoints(@NotNull List<Location> playerSpawnPoints) {
this.playerSpawnPoints = playerSpawnPoints;
}

public void adjustContributorValue(Role role, User user, int number) {
public void adjustContributorValue(Role role, IUser user, int number) {
user.adjustStatistic("CONTRIBUTION_" + role.name(), number);
}

private Map<User, Integer> murdererContributions = new HashMap<>();
private Map<User, Integer> detectiveContributions = new HashMap<>();
private final Map<IUser, Integer> murdererContributions = new HashMap<>();
private final Map<IUser, Integer> detectiveContributions = new HashMap<>();

public Map<User, Integer> getMurdererContributions() {
public Map<IUser, Integer> getMurdererContributions() {
return murdererContributions;
}

public Map<User, Integer> getDetectiveContributions() {
public Map<IUser, Integer> getDetectiveContributions() {
return detectiveContributions;
}

public int getContributorValue(Role role, User user) {
public int getContributorValue(Role role, IUser user) {
if(role == Role.MURDERER && murdererContributions.containsKey(user)) {
return murdererContributions.get(user);
} else if(detectiveContributions.containsKey(user)) {
Expand All @@ -421,7 +421,7 @@ public int getContributorValue(Role role, User user) {
return calculatedContributor;
}

public void resetContributorValue(Role role, User user) {
public void resetContributorValue(Role role, IUser user) {
user.setStatistic("CONTRIBUTION_" + role.name(), 1);
}

Expand Down
59 changes: 30 additions & 29 deletions src/main/java/plugily/projects/murdermystery/arena/ArenaEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
Expand All @@ -40,14 +39,13 @@
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.spigotmc.event.entity.EntityDismountEvent;
import plugily.projects.minigamesbox.classic.arena.ArenaState;
import plugily.projects.minigamesbox.classic.arena.PluginArena;
import plugily.projects.minigamesbox.api.arena.IArenaState;
import plugily.projects.minigamesbox.api.arena.IPluginArena;
import plugily.projects.minigamesbox.api.user.IUser;
import plugily.projects.minigamesbox.classic.arena.PluginArenaEvents;
import plugily.projects.minigamesbox.classic.handlers.items.SpecialItem;
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
import plugily.projects.minigamesbox.classic.handlers.language.TitleBuilder;
import plugily.projects.minigamesbox.classic.user.User;
import plugily.projects.minigamesbox.classic.utils.misc.complement.ComplementAccessor;
import plugily.projects.minigamesbox.classic.utils.version.ServerVersion;
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
Expand Down Expand Up @@ -75,13 +73,13 @@ public ArenaEvents(Main plugin) {
}

@Override
public void handleIngameVoidDeath(Player victim, PluginArena arena) {
public void handleIngameVoidDeath(Player victim, IPluginArena arena) {
Arena pluginArena = plugin.getArenaRegistry().getArena(arena.getId());
if(pluginArena == null) {
return;
}
victim.damage(1000.0);
if(arena.getArenaState() == ArenaState.IN_GAME) {
if(arena.getArenaState() == IArenaState.IN_GAME) {
VersionUtils.teleport(victim, pluginArena.getPlayerSpawnPoints().get(0));
}
}
Expand All @@ -92,7 +90,7 @@ public void onBowShot(EntityShootBowEvent event) {
return;
}
Player player = (Player) event.getEntity();
User user = plugin.getUserManager().getUser(player);
IUser user = plugin.getUserManager().getUser(player);
if(!Role.isRole(Role.ANY_DETECTIVE, user)) {
return;
}
Expand Down Expand Up @@ -127,7 +125,7 @@ public void onItemPickup(PlugilyEntityPickupItemEvent e) {
if(arena == null) {
return;
}
User user = plugin.getUserManager().getUser(player);
IUser user = plugin.getUserManager().getUser(player);
e.setCancelled(true);
if(arena.getBowHologram() != null
&& e.getItem().equals(arena.getBowHologram().getEntityItem())) {
Expand All @@ -138,7 +136,7 @@ public void onItemPickup(PlugilyEntityPickupItemEvent e) {
e.getItem().remove();

for(Player loopPlayer : arena.getPlayersLeft()) {
User loopUser = plugin.getUserManager().getUser(loopPlayer);
IUser loopUser = plugin.getUserManager().getUser(loopPlayer);
if(Role.isRole(Role.INNOCENT, loopUser)) {
ItemPosition.setItem(loopUser, ItemPosition.BOW_LOCATOR, new ItemStack(Material.AIR, 1));
}
Expand All @@ -157,7 +155,7 @@ public void onItemPickup(PlugilyEntityPickupItemEvent e) {
return;
}

if(user.isSpectator() || arena.getArenaState() != ArenaState.IN_GAME) {
if(user.isSpectator() || arena.getArenaState() != IArenaState.IN_GAME) {
return;
}

Expand Down Expand Up @@ -215,9 +213,9 @@ public void onMurdererDamage(EntityDamageByEntityEvent e) {
return;
}
Player attacker = (Player) e.getDamager();
User userAttacker = plugin.getUserManager().getUser(attacker);
IUser userAttacker = plugin.getUserManager().getUser(attacker);
Player victim = (Player) e.getEntity();
User userVictim = plugin.getUserManager().getUser(victim);
IUser userVictim = plugin.getUserManager().getUser(victim);
if(!ArenaUtils.areInSameArena(attacker, victim)) {
return;
}
Expand Down Expand Up @@ -256,10 +254,10 @@ public void onMurdererDamage(EntityDamageByEntityEvent e) {
plugin.getRewardsHandler().performReward(attacker, plugin.getRewardsHandler().getRewardType("KILL_DETECTIVE"));
}

XSound.ENTITY_PLAYER_DEATH.play(victim.getLocation(), 50, 1);
XSound.ENTITY_PLAYER_DEATH.play(victim.getLocation());
victim.damage(100.0);

User user = plugin.getUserManager().getUser(attacker);
IUser user = plugin.getUserManager().getUser(attacker);

user.adjustStatistic("KILLS", 1);
user.adjustStatistic("LOCAL_KILLS", 1);
Expand All @@ -286,7 +284,7 @@ public void onArrowDamage(EntityDamageByEntityEvent e) {
return;
}
Player attacker = (Player) ((Arrow) e.getDamager()).getShooter();
User userAttacker = plugin.getUserManager().getUser(attacker);
IUser userAttacker = plugin.getUserManager().getUser(attacker);
if(plugin.getArenaRegistry().isInArena(attacker)) {
e.setCancelled(true);
e.getDamager().remove();
Expand All @@ -295,7 +293,7 @@ public void onArrowDamage(EntityDamageByEntityEvent e) {
return;
}
Player victim = (Player) e.getEntity();
User userVictim = plugin.getUserManager().getUser(victim);
IUser userVictim = plugin.getUserManager().getUser(victim);
if(!ArenaUtils.areInSameArena(attacker, victim)) {
return;
}
Expand All @@ -310,11 +308,14 @@ public void onArrowDamage(EntityDamageByEntityEvent e) {
return;
}
Arena arena = plugin.getArenaRegistry().getArena(attacker);
if (arena == null) {
return;
}
//we need to set it before the victim die, because of hero character
if(Role.isRole(Role.MURDERER, userVictim)) {
arena.setCharacter(Arena.CharacterType.HERO, attacker);
}
XSound.ENTITY_PLAYER_DEATH.play(victim.getLocation(), 50, 1);
XSound.ENTITY_PLAYER_DEATH.play(victim.getLocation());
victim.damage(100.0);


Expand Down Expand Up @@ -362,15 +363,15 @@ public void onPlayerDie(PlayerDeathEvent e) {
if(arena == null) {
return;
}
User user = plugin.getUserManager().getUser(player);
IUser user = plugin.getUserManager().getUser(player);
ComplementAccessor.getComplement().setDeathMessage(e, "");
e.getDrops().clear();
e.setDroppedExp(0);
plugin.getCorpseHandler().spawnCorpse(player, arena);
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 3 * 20, 0));
if(arena.getArenaState() == ArenaState.STARTING) {
if(arena.getArenaState() == IArenaState.STARTING) {
return;
} else if(arena.getArenaState() == ArenaState.ENDING || arena.getArenaState() == ArenaState.RESTARTING) {
} else if(arena.getArenaState() == IArenaState.ENDING || arena.getArenaState() == IArenaState.RESTARTING) {
player.getInventory().clear();
player.setFlying(false);
player.setAllowFlight(false);
Expand Down Expand Up @@ -400,7 +401,7 @@ public void onPlayerDie(PlayerDeathEvent e) {
new MessageBuilder(MessageBuilder.ActionType.DEATH).player(player).arena(arena).sendArena();
}

if(arena.getArenaState() != ArenaState.ENDING && arena.getArenaState() != ArenaState.RESTARTING) {
if(arena.getArenaState() != IArenaState.ENDING && arena.getArenaState() != IArenaState.RESTARTING) {
arena.addDeathPlayer(player);
}
//we must call it ticks later due to instant respawn bug
Expand All @@ -417,16 +418,16 @@ public void onRespawn(PlayerRespawnEvent event) {
if(arena == null) {
return;
}
if(arena.getArenaState() == ArenaState.STARTING || arena.getArenaState() == ArenaState.WAITING_FOR_PLAYERS) {
if(arena.getArenaState() == IArenaState.STARTING || arena.getArenaState() == IArenaState.WAITING_FOR_PLAYERS) {
event.setRespawnLocation(arena.getLobbyLocation());
return;
}
if(arena.getArenaState() == ArenaState.RESTARTING) {
if(arena.getArenaState() == IArenaState.RESTARTING) {
event.setRespawnLocation(arena.getEndLocation());
return;
}
if(arena.getPlayers().contains(player)) {
User user = plugin.getUserManager().getUser(player);
IUser user = plugin.getUserManager().getUser(player);
org.bukkit.Location firstSpawn = arena.getPlayerSpawnPoints().get(0);

if(player.getLocation().getWorld().equals(firstSpawn.getWorld())) {
Expand Down Expand Up @@ -454,12 +455,12 @@ public void locatorDistanceUpdate(PlayerMoveEvent event) {
if(arena == null) {
return;
}
User user = plugin.getUserManager().getUser(player);
IUser user = plugin.getUserManager().getUser(player);
//skip spectators
if(user.isSpectator()) {
return;
}
if(arena.getArenaState() == ArenaState.IN_GAME) {
if(arena.getArenaState() == IArenaState.IN_GAME) {
if(Role.isRole(Role.INNOCENT, user, arena)) {
if(player.getInventory().getItem(ItemPosition.BOW_LOCATOR.getOtherRolesItemPosition()) != null) {
ItemStack bowLocator = new ItemStack(Material.COMPASS, 1);
Expand All @@ -475,7 +476,7 @@ public void locatorDistanceUpdate(PlayerMoveEvent event) {
ItemMeta innocentMeta = innocentLocator.getItemMeta();
for(Player p : arena.getPlayersLeft()) {
Arena playerArena = plugin.getArenaRegistry().getArena(p);
User playerUser = plugin.getUserManager().getUser(p);
IUser playerUser = plugin.getUserManager().getUser(p);

if(Role.isRole(Role.INNOCENT, playerUser, playerArena) || Role.isRole(Role.ANY_DETECTIVE, playerUser, playerArena)) {
ComplementAccessor.getComplement().setDisplayName(innocentMeta, new MessageBuilder("IN_GAME_MESSAGES_ARENA_LOCATOR_INNOCENT").asKey().player(player).arena(arena).build() + " §7| §a" + (int) Math.round(player.getLocation().distance(p.getLocation())));
Expand All @@ -489,7 +490,7 @@ public void locatorDistanceUpdate(PlayerMoveEvent event) {

@EventHandler
public void onDrop(PlayerDropItemEvent event) {
if(plugin.getArenaRegistry().getArena(event.getPlayer()) != null && plugin.getArenaRegistry().getArena(event.getPlayer()).getArenaState() == ArenaState.IN_GAME) {
if(plugin.getArenaRegistry().getArena(event.getPlayer()) != null && plugin.getArenaRegistry().getArena(event.getPlayer()).getArenaState() == IArenaState.IN_GAME) {
event.setCancelled(true);
}
}
Expand Down
Loading

0 comments on commit 3bbabca

Please sign in to comment.