Skip to content

Commit

Permalink
Added option to disable spectating on bungee servers
Browse files Browse the repository at this point in the history
  • Loading branch information
Despical committed May 16, 2023
1 parent 438f79d commit 7542777
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The project isn't in the Central Repository yet, so specifying a repository is n
<dependency>
<groupId>com.github.Despical</groupId>
<artifactId>OITC</artifactId>
<version>2.3.2</version>
<version>2.3.3</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -56,7 +56,7 @@ repositories {
```
```
dependencies {
compileOnly group: "com.github.Despical", name: "OITC", version: "2.3.2";
compileOnly group: "com.github.Despical", name: "OITC", version: "2.3.3";
}
```
</details>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>me.despical</groupId>
<artifactId>one-in-the-chamber</artifactId>
<version>2.3.2</version>
<version>2.3.3</version>
<name>One In The Chamber</name>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/despical/oitc/ConfigPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ BLOCK_COMMANDS, BOSS_BAR_ENABLED, BUNGEE_ENABLED(false), CHAT_FORMAT_ENABLED, DA
DISABLE_FALL_DAMAGE(false), DISABLE_LEAVE_COMMAND(false), DISABLE_SEPARATE_CHAT(false),
ENABLE_SHORT_COMMANDS, IGNORE_WARNING_MESSAGES(false), INVENTORY_MANAGER_ENABLED, NAME_TAGS_HIDDEN,
REWARDS_ENABLED(false), SEND_SETUP_TIPS, SIGNS_BLOCK_STATES_ENABLED, UPDATE_NOTIFIER_ENABLED,
REGEN_ENABLED(false), LEVEL_COUNTDOWN_ENABLED(false);
REGEN_ENABLED(false), LEVEL_COUNTDOWN_ENABLED(false), DISABLE_SPECTATING_ON_BUNGEE(false);

final String path;
final boolean def;
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/me/despical/oitc/arena/ArenaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,18 @@ public static void joinAttempt(Player player, Arena arena) {
return;
}

User user = plugin.getUserManager().getUser(player);

if (!plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
if (!plugin.getPermissionsManager().hasJoinPerm(player, arena.getId())) {
player.sendMessage(chatManager.prefixedMessage("In-Game.Join-No-Permission").replace("%permission%", plugin.getPermissionsManager().getJoinPerm().replace("<arena>", arena.getId())));
return;
}
} else if (plugin.getConfigPreferences().getOption(ConfigPreferences.Option.DISABLE_SPECTATING_ON_BUNGEE) && arena.getArenaState() == ArenaState.IN_GAME) {
if (user.isSpectator()) {
player.sendMessage(chatManager.prefixedMessage("In-Game.Spectating-Disabled-On-Bungee"));
return;
}
}

if (arena.getArenaState() == ArenaState.RESTARTING) {
Expand Down Expand Up @@ -131,7 +138,6 @@ public static void joinAttempt(Player player, Arena arena) {
AttributeUtils.healPlayer(player);
PlayerUtils.setGlowing(player, false);

User user = plugin.getUserManager().getUser(player);
user.addGameItem("leave-item");
user.resetStats();

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ Regen-Enabled: false
# Should we change player's level with timer?
Level-Countdown-Enabled: false

# Should we allow spectating on bungee mode?
Disable-Spectating-On-Bungee: false

# Should we fire some cool fireworks at location of every player after the game ends?
Firework-When-Game-Ends: true

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ In-Game:
Full-Game-No-Permission: "&cYou don't have the permission to join full games!"
No-Slots-For-Premium: "&cThis game is already full of premium players! Sorry"
You-Are-Spectator: "&cYou're now a spectator! You can fly now!"
Spectating-Disabled-On-Bungee: "&cSpectating is now allowing on this server!"
Only-Command-Ingame-Is-Leave: "&cYou have to leave the game first to perform commands. The only command that works is /oitc leave!"
# Join cancelled via external plugin that uses OITC API.
Join-Cancelled-Via-API: "&cYou can't join this game!"
Expand Down

0 comments on commit 7542777

Please sign in to comment.