Skip to content

Commit

Permalink
Some Fixes again
Browse files Browse the repository at this point in the history
  • Loading branch information
sammwyy committed Oct 22, 2021
1 parent 407f8ff commit 944b9de
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 74 deletions.
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.5] - 2021-10-18
## [0.1.6] - 2021-10-11

### Added

- Declaring the only player alive in play as the winner is now configurable.

### Fixed

- Fixed class not found "particles".
- Fixed 1.8 glass break sound (again)
- Fixed arena starting time config path.
- Reduced code redundancy.

## [0.1.5] - 2021-10-21

### Fixed

- Fixed 1.8 glass break sound
- Fixed bedrock generation instead glass
- Fixed 1.8 glass break sound.
- Fixed bedrock generation instead glass.

## [0.1.4] - 2021-10-18

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- Plugin Information -->
<name>SquidGame</name>
<description>This is just an example plugin</description>
<version>0.1.5</version>
<version>0.1.6</version>
<url>https://twitter.com/sammwy</url>

<properties>
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/dev/_2lstudios/jelly/utils/BlockUtils.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
package dev._2lstudios.jelly.utils;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;

public class BlockUtils {
public static void destroyBlockGroup(final Block block, final boolean useParticles) {
final Material target = block.getType();

final Block up = block.getRelative(BlockFace.SOUTH);
final Block down = block.getRelative(BlockFace.NORTH);
final Block left = block.getRelative(BlockFace.EAST);
final Block right = block.getRelative(BlockFace.WEST);

if (useParticles) {
final Location loc = block.getLocation();
final World world = loc.getWorld();
world.spawnParticle(Particle.BLOCK_CRACK, loc, 10, 0.5, 0.5, 0.5, 0.1, block.getBlockData());
block.breakNaturally();
} else {
block.setType(Material.AIR);
}
block.setType(Material.AIR);

if (up.getType() == target) {
destroyBlockGroup(up, useParticles);
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/dev/_2lstudios/squidgame/arena/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ public void killPlayer(final SquidPlayer player, boolean setSpectator) {
}

else if (this.calculateWinner() != null) {
this.finishArena(ArenaFinishReason.ONE_PLAYER_IN_ARENA);
final boolean allowVictory = this.mainConfig
.getBoolean("game-settings.allow-victory-before-completing-game", false);
final boolean isLastGame = this.currentGame != null && this.currentGame instanceof G7SquidGame;

if (isLastGame || allowVictory) {
this.finishArena(ArenaFinishReason.ONE_PLAYER_IN_ARENA);
}
}
}

Expand Down
38 changes: 19 additions & 19 deletions src/main/java/dev/_2lstudios/squidgame/arena/ArenaHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void handlePlayerJoin(final SquidPlayer player) {

if (arena.getState() == ArenaState.WAITING) {
if (arena.getPlayers().size() >= arena.getMinPlayers()) {
arena.setInternalTime(this.mainConfig.getInt("arena.starting-time", 30));
arena.setInternalTime(this.mainConfig.getInt("game-settings.starting-time", 30));
arena.setState(ArenaState.STARTING);
arena.broadcastMessage("arena.starting");
}
Expand Down Expand Up @@ -118,24 +118,24 @@ public void handleArenaFinish(final ArenaFinishReason reason) {
this.arena.setInternalTime(this.mainConfig.getInt("game-settings.finishing-time", 5));

switch (reason) {
case ALL_PLAYERS_DEATH:
this.arena.broadcastTitle("events.finish.draw.title", "events.finish.draw.subtitle");
return;
case ONE_PLAYER_IN_ARENA:
this.arena.broadcastTitle("events.finish.winner.title", "events.finish.winner.subtitle");

// Give rewards
final List<String> rewardCommands = this.mainConfig.getStringList("game-settings.rewards",
new ArrayList<>());

for (final String reward : rewardCommands) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
reward.replace("{winner}", arena.calculateWinner().getBukkitPlayer().getName()));
}

break;
case PLUGIN_STOP:
break;
case ALL_PLAYERS_DEATH:
this.arena.broadcastTitle("events.finish.draw.title", "events.finish.draw.subtitle");
return;
case ONE_PLAYER_IN_ARENA:
this.arena.broadcastTitle("events.finish.winner.title", "events.finish.winner.subtitle");

// Give rewards
final List<String> rewardCommands = this.mainConfig.getStringList("game-settings.rewards",
new ArrayList<>());

for (final String reward : rewardCommands) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
reward.replace("{winner}", arena.calculateWinner().getBukkitPlayer().getName()));
}

break;
case PLUGIN_STOP:
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void generateTiles(final Material material) {
final int groundHeight = (useZAsIndex ? differenceBetweenZ : differenceBetweenX) + 1;

// Parametros de las paltaformas
final int size = groundWidth < 5 ? 1 : groundWidth < 8 ? 2 : 3;
final int size = groundWidth < 5 ? 1 : groundWidth < 7 ? 2 : 3;
final int spaceXBetweenPlatforms = groundWidth - (size * 2);
final int spaceZBetweenPlatforms = 3;

Expand All @@ -97,60 +97,46 @@ private void generateTiles(final Material material) {
// Is first pair item a fake block?
boolean isFirstFake = BooleanUtils.randomBoolean();

// En caso que la coordenada Z deba de usarse como un indice:
if (useZAsIndex) {
// Por cada posición relativa X de la plataforma
for (int xPadding = 0; xPadding < size; xPadding++) {
// Por cada posición relativa Y de la plataforma
for (int zPadding = 0; zPadding < size; zPadding++) {
// Por cada posición relativa X de la plataforma
for (int xPadding = 0; xPadding < size; xPadding++) {
// Por cada posición relativa Y de la plataforma
for (int zPadding = 0; zPadding < size; zPadding++) {
// Define blocks
Block firstRowBlock, secondRowBlock;

// En caso que la coordenada Z deba de usarse como un indice:
if (useZAsIndex) {
// Sumarle valor relativo x padding al valor absoluto x start
int x = xStart + xPadding;
// Sumarle el valor del indice Z al valor relativo z padding
int z = shouldIncreaseIndex ? blockIndex + zPadding : blockIndex - zPadding;

// Generar bloque en las coordenadas dadas X Y Z
final Block firstRowBlock = world.getBlockAt(x, yStart, z);
firstRowBlock.setType(material);
firstRowBlock = world.getBlockAt(x, yStart, z);

// Generar bloque en la misma posicion que el de arriba pero con una separación
final Block secondRowBlock = world.getBlockAt(x + spaceXBetweenPlatforms + size, yStart, z);
secondRowBlock.setType(material);

if (material != Material.AIR) {
if (isFirstFake) {
this.fakeBlocks.add(firstRowBlock);
} else {
this.fakeBlocks.add(secondRowBlock);
}
}
}
}

// En caso que la coordenada X deba de usarse como un indice:
} else {
// Por cada posición relativa X de la plataforma
for (int xPadding = 0; xPadding < size; xPadding++) {
// Por cada posición relativa Y de la plataforma
for (int zPadding = 0; zPadding < size; zPadding++) {
secondRowBlock = world.getBlockAt(x + spaceXBetweenPlatforms + size, yStart, z);
} else {
// Sumarle el valor del indice X al valor relativo x padding
int x = shouldIncreaseIndex ? blockIndex + xPadding : blockIndex - xPadding;
// Sumarle valor relativo z padding al valor absoluto z start
int z = zStart + zPadding;

// Generar bloque en las coordenadas dadas X Y Z
final Block firstRowBlock = world.getBlockAt(x, yStart, z);
firstRowBlock.setType(Material.BEDROCK);
firstRowBlock = world.getBlockAt(x, yStart, z);

// Generar bloque en la misma posicion que el de arriba pero con una separación
final Block secondRowBlock = world.getBlockAt(x, yStart, z + spaceXBetweenPlatforms + size);
secondRowBlock.setType(Material.BEDROCK);

if (material != Material.AIR) {
if (isFirstFake) {
this.fakeBlocks.add(firstRowBlock);
} else {
this.fakeBlocks.add(secondRowBlock);
}
secondRowBlock = world.getBlockAt(x, yStart, z + spaceXBetweenPlatforms + size);
}

firstRowBlock.setType(material);
secondRowBlock.setType(material);

if (material != Material.AIR) {
if (isFirstFake) {
this.fakeBlocks.add(firstRowBlock);
} else {
this.fakeBlocks.add(secondRowBlock);
}
}
}
Expand All @@ -159,7 +145,6 @@ private void generateTiles(final Material material) {
final int separation = spaceZBetweenPlatforms + size;
blockIndex = shouldIncreaseIndex ? blockIndex + separation : blockIndex - separation;
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ else if (arena.getCurrentGame() instanceof G6GlassesGame) {

if (block != null && block.getType() == Material.GLASS) {
final G6GlassesGame game = (G6GlassesGame) arena.getCurrentGame();

if (game.isFakeBlock(loc.getBlock())) {
arena.broadcastSound(
this.plugin.getMainConfig().getSound("game-settings.sounds.glass-break", "glass"));
BlockUtils.destroyBlockGroup(loc.getBlock());
arena.broadcastSound(
this.plugin.getMainConfig().getSound("game-settings.sounds.glass-break", "GLASS"));
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
game-settings:
allow-victory-before-completing-game: false
min-players: 2
max-players: 12
starting-time: 30
Expand Down

0 comments on commit 944b9de

Please sign in to comment.