Skip to content

Commit

Permalink
Merge pull request #61 from VoxCrafterLP/main
Browse files Browse the repository at this point in the history
Release v1.2.1
  • Loading branch information
VoxCrafterLP authored Aug 8, 2021
2 parents 3f5373f + a2e3a00 commit f3c4366
Show file tree
Hide file tree
Showing 18 changed files with 301 additions and 36 deletions.
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
[![build](https://github.com/VoxCrafterLP/JumpRace/actions/workflows/maven.yml/badge.svg)](https://github.com/VoxCrafterLP/JumpRace/actions/workflows/maven.yml)
![GitHub release (latest by date)](https://img.shields.io/github/downloads/VoxCrafterLP/JumpRace/total?label=Downloads)
![GitHub](https://img.shields.io/github/license/VoxCrafterLP/JumpRace)
![GitHub milestone](https://img.shields.io/github/milestones/progress/VoxCrafterLP/JumpRace/3)
![GitHub milestone](https://img.shields.io/github/milestones/progress/VoxCrafterLP/JumpRace/4)
![MV version](https://img.shields.io/badge/Minecraft%20version-1.8.x-brightgreen)
![bStats Servers](https://img.shields.io/bstats/servers/11049)

This is a spigot based jumpandrun minigame. It's almost like the gamemode 'JumpLeague' on the gommehd.net server but with a few changes. The plugin contains its own building system, which can be used to build your own modules.
This is a spigot based Jump 'n' Run minigame. It's almost like the gamemode 'JumpLeague' on the GommeHD.net server but with a few changes. The plugin contains its own building system, which can be used to build your own modules.

**Important**! It is highly recommended to use this plugin in a cloud-system based environment like [CloudNET](https://cloudnetservice.eu/).
**Important**! It is highly recommended using this plugin in a cloud-system based environment like [CloudNET](https://cloudnetservice.eu/).

## Features

Expand All @@ -17,33 +18,47 @@ This is a spigot based jumpandrun minigame. It's almost like the gamemode 'JumpL
- Quick editor
- API
- Holograms
- Particle system
- Small head database
- Multiple maps
- Fully customizable
- Multiple languages

## Installation

This plugin only requires a properly set up spigot server, but it's recommended to use the latest build of the 1.8.8.
You can learn here how to use the [latest build](https://www.spigotmc.org/wiki/buildtools/#1-8-8).
This plugin only requires a properly set up Spigot server, but it's recommended to use the latest build of version 1.8.8.
You can learn how to use the latest build [here](https://www.spigotmc.org/wiki/buildtools/#1-8-8).

1. Download the latest JAR file from the [releases tab](https://github.com/VoxCrafterLP/JumpRace/releases).
2. Move the JAR file into your plugins folder.
2. Move the JAR file into your `plugins` folder.
3. Restart your server.
4. Check the console to ensure that the plugin is working properly.
5. Locate and open the config file in `/plugins/JumpRace/config.yml`.
5. Locate and open the config file in `plugins/JumpRace/config.yml`.
6. Configure the plugin to your needs.
7. Have fun!

## Updating

To update the plugin, please make sure that you follow these steps:

1. Download the latest JAR file from the [releases tab](https://github.com/VoxCrafterLP/JumpRace/releases) and put it into the `plugins` folder.
2. Delete the old plugin JAR file.
3. Delete the `languages` folder in the `plugins/JumpRace/` folder.
4. Make a backup of you current `config.yml` file.
5. Delete the `config.yml` file from the `plugins/JumpRace/` folder.
6. Start the server.
7. Update your `config.yml` file with the settings from your backup file.
8. Have fun!

## API

### Maven dependency

```xml

<dependency>
<groupId>com.voxcrafterlp</groupId>
<artifactId>JumpRace</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.2.1-RELEASE</version>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -99,12 +114,12 @@ At the moment these languages are available:
- de_CH (Swiss German)
```

If you want to add your own language file, you can copy an existing translation file from the `/plugins/JumpRace/languages` folder and translate it.
If you want to add your own language file, you can copy an existing translation file from the `plugins/JumpRace/languages` folder and translate it.
**Important! You have to encode the translation file in ISO-8859-1.**
To enable the translation, you have to switch the language file in the config.
To enable the translation, you have to change the language file in the config.


## Contributers
## Contributors

- [MakeItGame](https://www.youtube.com/channel/UCk8ROONMzJ3wlZ66vyyffJg) (German translation)
- [Lezurex](https://github.com/Lezurex) (Swiss German translation)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<groupId>com.voxcrafterlp</groupId>
<artifactId>JumpRace</artifactId>
<name>JumpRace</name>
<version>1.2.0-RELEASE</version>
<version>1.2.1-RELEASE</version>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.voxcrafterlp.jumprace.builderserver.commands;

import com.google.common.collect.Lists;
import com.voxcrafterlp.jumprace.JumpRace;
import com.voxcrafterlp.jumprace.builderserver.objects.ModuleSetup;
import com.voxcrafterlp.jumprace.modules.objects.Module;
Expand All @@ -9,9 +10,12 @@
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;

import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;

/**
* This file was created by VoxCrafter_LP!
Expand All @@ -20,7 +24,7 @@
* Project: JumpRace
*/

public class JumpRaceCommand implements CommandExecutor {
public class JumpRaceCommand implements CommandExecutor, TabCompleter {

@Override
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
Expand Down Expand Up @@ -60,6 +64,17 @@ public boolean onCommand(CommandSender commandSender, Command command, String la
player.sendMessage(JumpRace.getInstance().getLanguageLoader().getTranslationByKeyWithPrefix("command-jumprace-list"));
modules.forEach(module -> player.sendMessage(JumpRace.getInstance().getPrefix() + "§8- §b" + module.getName()));
break;
case "reload":
JumpRace.getInstance().getModuleLoader().reloadModules();

if(JumpRace.getInstance().getModuleLoader().getModuleList().isEmpty()) {
player.sendMessage(JumpRace.getInstance().getLanguageLoader().getTranslationByKeyWithPrefix("no-modules-found"));
return false;
}

player.sendMessage(JumpRace.getInstance().getLanguageLoader().getTranslationByKeyWithPrefix("command-jumprace-reload-success",
String.valueOf(JumpRace.getInstance().getModuleLoader().getModuleList().size())));
break;
default:
this.listCommands(player);
break;
Expand Down Expand Up @@ -93,9 +108,6 @@ public boolean onCommand(CommandSender commandSender, Command command, String la

new ModuleEditor(player, module).startEditor();
break;
default:
this.listCommands(player);
break;
}
break;

Expand All @@ -112,7 +124,67 @@ private void listCommands(Player player) {
player.sendMessage(JumpRace.getInstance().getLanguageLoader().getTranslationByKeyWithPrefix("command-jumprace-help-2"));
player.sendMessage(JumpRace.getInstance().getLanguageLoader().getTranslationByKeyWithPrefix("command-jumprace-help-3"));
player.sendMessage(JumpRace.getInstance().getLanguageLoader().getTranslationByKeyWithPrefix("command-jumprace-help-4"));
player.sendMessage(JumpRace.getInstance().getLanguageLoader().getTranslationByKeyWithPrefix("command-jumprace-help-5"));
player.sendMessage("§8===================================");
}


@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] args) {

if(!(commandSender instanceof Player)) return Collections.emptyList();
final Player player = (Player) commandSender;

if(command.getName().equalsIgnoreCase("jumprace")
|| command.getName().equalsIgnoreCase("jr")){

if(!player.hasPermission(JumpRace.getInstance().getJumpRaceConfig().getBuilderPermission())
&& !player.hasPermission(JumpRace.getInstance().getJumpRaceConfig().getAdminPermission()))
return Collections.emptyList();

final List<String> completions = Lists.newCopyOnWriteArrayList();

int length = args.length;

for(String string : args) {
if(string.equals("") || string.equals(" "))
length--;
}

switch (length) {
case 0:
completions.add("newmodule");
completions.add("list");
completions.add("edit");
completions.add("reload");
break;
case 1:
if(args[0].equalsIgnoreCase("edit")) {
JumpRace.getInstance().getModuleLoader().getModuleList()
.forEach(module -> completions.add(module.getName()));

return completions;
}

final String search = args[0].toLowerCase();
Stream.of("newmodule", "list", "edit", "reload")
.filter(string -> string.toLowerCase().startsWith(search))
.forEach(completions::add);
break;
case 2:
if(args[0].equalsIgnoreCase("edit")) {
final String searchModule = args[1].toLowerCase();
JumpRace.getInstance().getModuleLoader().getModuleList().stream()
.filter(module -> module.getName().toLowerCase().startsWith(searchModule))
.forEach(module -> completions.add(module.getName()));
}
break;
default:
System.out.println("test3");
break;
}
return completions;
}
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class JumpRaceConfig {

private final int jumpTime, deathmatchTime;

private final boolean autoDeleteWorld;

private final List<String> headValues;

private final String adminPermission, builderPermission, setupPermission, mapSwitchPermission, startPermission;
Expand All @@ -49,6 +51,8 @@ public JumpRaceConfig() {

this.maxLives = this.configuration.getInt("max-lives");

this.autoDeleteWorld = this.configuration.getBoolean("auto-delete-world");

this.headValues = this.configuration.getStringList("head-values");

this.adminPermission = this.configuration.getString("admin-permission");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
package com.voxcrafterlp.jumprace.minigameserver.commands;

import com.google.common.collect.Lists;
import com.voxcrafterlp.jumprace.JumpRace;
import com.voxcrafterlp.jumprace.minigameserver.setup.objects.MapSetup;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;

import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;

/**
* This file was created by VoxCrafter_LP!
* Date: 25.02.2021
* Time: 14:45
* Project: JumpRace
*/

public class SetupCommand implements CommandExecutor {
public class SetupCommand implements CommandExecutor, TabCompleter {

@Override
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
Expand Down Expand Up @@ -66,4 +72,42 @@ private void listCommands(Player player) {
player.sendMessage(JumpRace.getInstance().getLanguageLoader().getTranslationByKeyWithPrefix("setup-help-3"));
player.sendMessage(JumpRace.getInstance().getLanguageLoader().getTranslationByKey("setup-help-4"));
}

@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] args) {

if(!(commandSender instanceof Player)) return Collections.emptyList();
final Player player = (Player) commandSender;

if(command.getName().equalsIgnoreCase("setup")) {

if(!player.hasPermission(JumpRace.getInstance().getJumpRaceConfig().getSetupPermission())
&& !player.hasPermission(JumpRace.getInstance().getJumpRaceConfig().getAdminPermission()))
return Collections.emptyList();

final List<String> completions = Lists.newCopyOnWriteArrayList();

int length = args.length;

for(String string : args) {
if(string.equals("") || string.equals(" "))
length--;
}

switch (length) {
case 0:
completions.add("lobby");
completions.add("map");
break;
case 1:
final String search = args[0].toLowerCase();
Stream.of("lobby", "map")
.filter(string -> string.toLowerCase().startsWith(search))
.forEach(completions::add);
break;
}
return completions;
}
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.scheduler.BukkitScheduler;

import java.io.File;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -88,6 +89,7 @@ public GameManager() {
Bukkit.getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 1, 4));
});
this.preDeathMatchCountdown = new Countdown(Countdown.Type.PRE_DEATHMATCH, () -> {
if(this.checkTeams()) return;
this.deathMatchCountdown.startCountdown();
Bukkit.getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 1, 4));
});
Expand Down Expand Up @@ -192,10 +194,14 @@ public void handlePlayerQuit(Player player) {

/**
* End the game if there are not enough players online
* @return Returns if the game should end
*/
private void checkTeams() {
if((int) this.registeredTeams.stream().filter(team -> team.getMembers().size() >= 1).count() < 2)
private boolean checkTeams() {
if((int) this.registeredTeams.stream().filter(team -> team.getMembers().size() >= 1).count() < 2) {
this.endGame(this.registeredTeams.stream().filter(Team::isAlive).findAny().get());
return true;
}
return false;
}

private void endGame(Team winningTeam) {
Expand All @@ -218,6 +224,8 @@ private void endGame(Team winningTeam) {
this.firework();
Bukkit.getPluginManager().callEvent(new TeamWinEvent(winningTeam));
this.endingCountdown.startCountdown();

this.deleteWorld();
}

/**
Expand Down Expand Up @@ -432,4 +440,27 @@ public void calculateWinner() {
this.endGame(this.getTeamFromPlayer(winner));
}

private void deleteWorld() {
if(JumpRace.getInstance().getJumpRaceConfig().isAutoDeleteWorld()) {
Bukkit.getConsoleSender().sendMessage("§aDeleting jumprace world... (This can take a while)");

Bukkit.getConsoleSender().sendMessage("§aUnloading world...");
Bukkit.unloadWorld("jumprace", false);

Bukkit.getConsoleSender().sendMessage("§aRestoring blocks...");
JumpRace.getInstance().getLocationManager().getSelectedMap().restoreOldBlocks();

new Thread(() -> {
try {
Thread.sleep(5000);
if(new File("jumprace").delete())
Bukkit.getConsoleSender().sendMessage("§aSuccessfully deleted jumprace world.");
else
Bukkit.getConsoleSender().sendMessage("§cAn error occurred while deleting the jumprace world!");
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
}
}
Loading

0 comments on commit f3c4366

Please sign in to comment.