Skip to content

Commit

Permalink
0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBrunoRM committed May 30, 2023
1 parent 585053c commit 0376711
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 273 deletions.
220 changes: 113 additions & 107 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,107 +1,113 @@
# Skywars

A Minecraft plugin that adds the Skywars minigame.
Compatible with Bukkit and Spigot, from versions 1.8 upwards.

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/786de08d9dfa4332bc1e15e8f4373bd6)](https://www.codacy.com/gh/TheBrunoRM/Skywars/dashboard?utm_source=github.com&utm_medium=referral&utm_content=TheBrunoRM/Skywars&utm_campaign=Badge_Grade)
[![GitHub last commit](https://img.shields.io/github/last-commit/TheBrunoRM/Skywars.svg)](https://github.com/TheBrunoRM/Skywars/commits/master)
[![version](https://img.shields.io/github/release/TheBrunoRM/Skywars.svg?colorB=7418f5)](https://github.com/TheBrunoRM/Skywars/releases/latest)
[![view on SpigotMC](https://img.shields.io/badge/view%20on-spigotmc-orange.svg)](https://www.spigotmc.org/resources/98709)

# Table of Contents
1. [How to install](#how-to-install)
2. [How to use](#how-to-use)
* [How to play](#how-to-play)
* [Creating an arena](#creating-an-arena)
* [Creating signs](#creating-signs)
3. [Current features](#current-features)
4. [To do](#to-do)
5. [Compatibility issues](#compatibility-issues)

## How to install

To install the plugin, drag the .jar file to your server's **plugins** folder.\
The plugin does not need any other dependencies as it should work by itself.\
You can start or reload the server after installing the plugin.

## How to use

Type **/sw help** to see the available commands.\
The plugin comes with a default arena and kit,\
so you should be able to play right after installing the plugin.

To disable the default lobby scoreboard,\
set the value of **lobby** in the **scoreboard.yml** file to **false**.

If the plugin doesn't have a **main lobby** set,\
players will be teleported to the last location they were at.\
If it is set, then they will be teleported to it.

### How to play

Type **/sw play** to open the arenas menu and click an arena to join.\
Type **/sw start** to start the game countdown.\
Type **/sw forcestart** to start the game immediately.

### Creating an arena

To create an arena, type **/sw create <arena>**\
After creating the arena, type **/sw config <arena>** to open the configuration menu\
You can configurate most of the values of the arena on the configuration menu\
Make sure to select an **schematic** file\
To load an schematic file, put it inside the **schematics** folder inside the plugin folder\
You can set the arena's schematic through the configuration menu

### Creating signs

To create a sign, make it like this:

![Sign image](https://cdn.discordapp.com/attachments/835594221456064544/876946375110189146/unknown.png)

## Plugin hooks
The plugin will hook to other plugins to add extra functionality.
### Economy
#### Current economy features:
* Coins
#### Currently implemented economy plugin APIS ([Skywars.java](https://github.com/TheBrunoRM/Skywars/blob/master/src/main/java/me/brunorm/skywars/Skywars.java#L250)):
* Vault
### Holograms
#### Current hologram features:
* Holograms above chests to indicate refill time.

#### Currently implemented hologram plugins APIs ([HologramController.java](https://github.com/TheBrunoRM/Skywars/blob/master/src/main/java/me/brunorm/skywars/holograms/HologramController.java)):
* HolographicDisplays
* DecentHolograms

## Current features
* Maps
* Kits
* Easy map setup menu
* Custom language file (not 100% of the messages, still working on it)
* Configuration options
* Chest refills
* 1.13+ compatible (still working on it, but it kinda works)
* Vault support (economy)

## To do
* More game events
* More configuration options
* Party options (?)
* Team games
* Custom cases (schematic)
* Ability to buy kits (inside and outside a game)
* Ability to change case (inside and outside a game)
* Game options (time, weather, chests, etc)
* Code optimization
* Plugin API events and methods

## Compatibility issues
* **Schematic files**\
The plugin currently works with both .schematic and .schem file types,\
but there are some problems with some block types and metadata, like with chests.
If you find any way to improve it, you're welcome to help!
* **Actionbar messages on Bukkit**\
do not work because of Bukkit limitations on message sending.\
If you find a way to send an actionbar message on Bukkit, please open an issue or a pull request.

Contact me in Discord: BrunoRM#7316
# Skywars

A Minecraft plugin that adds the Skywars minigame.
Compatible with Bukkit and Spigot, from versions 1.8 upwards.

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/786de08d9dfa4332bc1e15e8f4373bd6)](https://www.codacy.com/gh/TheBrunoRM/Skywars/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=TheBrunoRM/Skywars&amp;utm_campaign=Badge_Grade)
[![GitHub last commit](https://img.shields.io/github/last-commit/TheBrunoRM/Skywars.svg)](https://github.com/TheBrunoRM/Skywars/commits/master)
[![version](https://img.shields.io/github/release/TheBrunoRM/Skywars.svg?colorB=7418f5)](https://github.com/TheBrunoRM/Skywars/releases/latest)
[![view on SpigotMC](https://img.shields.io/badge/view%20on-spigotmc-orange.svg)](https://www.spigotmc.org/resources/98709)

# Table of Contents
1. [How to install](#how-to-install)
2. [How to use](#how-to-use)
* [How to play](#how-to-play)
* [Creating an arena](#creating-an-arena)
* [Creating signs](#creating-signs)
3. [Current features](#current-features)
4. [To do](#to-do)
5. [Compatibility issues](#compatibility-issues)

## How to install

To install the plugin, drag the .jar file to your server's **plugins** folder.\
The plugin does not need any other dependencies as it should work by itself.\
You can start or reload the server after installing the plugin.

## How to use

Type **/sw help** to see the available commands.\
The plugin comes with a default arena and kit,\
so you should be able to play right after installing the plugin.

To disable the default lobby scoreboard,\
set the value of **lobby** in the **scoreboard.yml** file to **false**.

If the plugin doesn't have a **main lobby** set,\
players will be teleported to the last location they were at.\
If it is set, then they will be teleported to it.

### How to play

Type **/sw play** to open the arenas menu and click an arena to join.\
Type **/sw start** to start the game countdown.\
Type **/sw forcestart** to start the game immediately.

### Creating an arena

To create an arena, type **/sw create <arena>**\
After creating the arena, type **/sw config <arena>** to open the configuration menu\
You can configurate most of the values of the arena on the configuration menu\
Make sure to select an **schematic** file\
To load an schematic file, put it inside the **schematics** folder inside the plugin folder\
You can set the arena's schematic through the configuration menu

### Creating signs

To create a sign, make it like this:
* 2nd line: [SkyWars]
* 3rd line: the arena name.

\* The signs are case insensitive, they get parsed and properly formatted after.

![Sign image](https://cdn.discordapp.com/attachments/835594221456064544/876946375110189146/unknown.png)

To remove a sign, sneak (shift) while on creative mode and left click.

## Plugin hooks
The plugin will hook to other plugins to add extra functionality.
### Economy
#### Current economy features:
* Coins
#### Currently implemented economy plugin APIS ([Skywars.java](https://github.com/TheBrunoRM/Skywars/blob/master/src/main/java/me/brunorm/skywars/Skywars.java#L250)):
* Vault
### Holograms
#### Current hologram features:
* Holograms above chests to indicate refill time.

#### Currently implemented hologram plugins APIs ([HologramController.java](https://github.com/TheBrunoRM/Skywars/blob/master/src/main/java/me/brunorm/skywars/holograms/HologramController.java)):
* HolographicDisplays
* DecentHolograms

## Current features
* Maps
* Kits
* Easy map setup menu
* Custom language file (not 100% of the messages, still working on it)
* Configuration options
* Chest refills
* 1.13+ compatible (still working on it, but it kinda works)
* Vault support (economy)

## To do
* More game events
* More configuration options
* Party options (?)
* Team games
* Custom cases (schematic)
* Ability to buy kits (inside and outside a game)
* Ability to change case (inside and outside a game)
* Game options (time, weather, chests, etc)
* Code optimization
* Plugin API events and methods

## Compatibility issues
* **Schematic files**\
The plugin currently works with both .schematic and .schem file types,\
but there are some problems with some block types and metadata, like with chests.
If you find any way to improve it, you're welcome to help!
* **Actionbar messages on Bukkit**\
do not work because of Bukkit limitations on message sending.\
If you find a way to send an actionbar message on Bukkit, please open an issue or a pull request.

Contact me in Discord: BrunoRM#7316
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.brunorm.skywars</groupId>
<artifactId>Skywars</artifactId>
<version>0.4.1</version>
<version>0.4.2</version>
<name>Skywars</name>

<properties>
Expand Down
74 changes: 35 additions & 39 deletions src/main/java/me/brunorm/skywars/InventoryUtils.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
package me.brunorm.skywars;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class InventoryUtils {

public static Inventory addItem(Inventory inventory, ItemStack item, int slot, String displayName,
String... loreLines) {
try {
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName(Messager.color(displayName));
final List<String> lore = new ArrayList<String>();
for (final String line : loreLines)
lore.add(Messager.color("&e" + line));
meta.setLore(lore);
item.setItemMeta(meta);
inventory.setItem(slot, item);
} catch (final Exception e) {
e.printStackTrace();
Skywars.get().sendDebugMessage("Could not set item for inventory.");
}
return inventory;
}

public static Inventory addItem(Inventory inventory, ItemStack item, int slot, String displayName) {
return addItem(inventory, item, slot, displayName);
}

public static Inventory addItem(Inventory inventory, Material material, int slot, String displayName,
String... loreLines) {
return addItem(inventory, new ItemStack(material), slot, displayName, loreLines);
}
}
package me.brunorm.skywars;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class InventoryUtils {

public static Inventory addItem(Inventory inventory, ItemStack item, int slot, String displayName,
String... loreLines) {
try {
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName(Messager.color(displayName));
final List<String> lore = new ArrayList<String>();
for (final String line : loreLines)
lore.add(Messager.color("&e" + line));
meta.setLore(lore);
item.setItemMeta(meta);
inventory.setItem(slot, item);
} catch (final Exception e) {
e.printStackTrace();
Skywars.get().sendDebugMessage("Could not set item for inventory.");
}
return inventory;
}

public static Inventory addItem(Inventory inventory, Material material, int slot, String displayName,
String... loreLines) {
return addItem(inventory, new ItemStack(material), slot, displayName, loreLines);
}
}
48 changes: 48 additions & 0 deletions src/main/java/me/brunorm/skywars/Skywars.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.HashMap;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
Expand Down Expand Up @@ -40,6 +41,7 @@
import me.brunorm.skywars.holograms.HologramController;
import me.brunorm.skywars.holograms.HolographicDisplaysNewController;
import me.brunorm.skywars.holograms.HolographicDisplaysOldController;
import me.brunorm.skywars.managers.ArenaManager;
import me.brunorm.skywars.managers.MapManager;
import me.brunorm.skywars.menus.ConfigMenu;
import me.brunorm.skywars.menus.GameOptionsMenu;
Expand Down Expand Up @@ -168,6 +170,32 @@ public void onEnable() {
this.packageName = this.getServer().getClass().getPackage().getName();
this.serverPackageVersion = this.packageName.substring(this.packageName.lastIndexOf('.') + 1);

final File worldsToDeleteFile = new File(this.getDataFolder(), "delete_worlds.yml");
if (worldsToDeleteFile.exists()) {
final YamlConfiguration deleteWorldsConfig = YamlConfiguration.loadConfiguration(worldsToDeleteFile);
final List<String> list = deleteWorldsConfig.getStringList("worlds");
for (final String worldName : list) {
final World world = Bukkit.getWorld(worldName);
if (world == null) {
this.sendDebugMessage("Could not find word for deletion: " + worldName);
list.remove(worldName);
continue;
}
if (ArenaManager.unloadAndDeleteWorldForMap(world, null))
list.remove(worldName);
else
this.sendDebugMessage("Could not delete world from deletion list: " + worldName);

}
deleteWorldsConfig.set("worlds", list);
try {
deleteWorldsConfig.save(worldsToDeleteFile);
} catch (final IOException e) {
e.printStackTrace();
this.sendMessage("Could not save the world deletion list to file: " + worldsToDeleteFile.getPath());
}
}

// load stuff
if (!this.loadConfig()) {
this.sendMessage("Could not load configuration files! Disabling plugin.");
Expand Down Expand Up @@ -277,8 +305,28 @@ public void onDisable() {
});

this.sendDebugMessage("Stopping arenas...");
// add world names to a file
// to try to delete those worlds
// the next time the plugin starts up
final List<String> worldNames = new ArrayList<String>(this.arenas.size());
for (final Arena arena : this.arenas) {
arena.clear(false);
worldNames.add(arena.getWorldName());
}
final File file = new File(this.getDataFolder(), "delete_worlds.yml");
try {
if (!file.exists()) {
file.createNewFile();
FileUtils.writeStringToFile(file, //
"# these are the worlds that the plugin will" + //
"try to delete the next time it starts up");
}
if (!FileUtils.readLines(file).stream().map(l -> l.split("#")[0]).anyMatch(l -> l.startsWith("worlds:")))
FileUtils.writeStringToFile(file, "worlds:");
FileUtils.writeLines(file, worldNames.stream().map(n -> "- " + n).toList());
} catch (final IOException e) {
e.printStackTrace();
this.sendMessage("Could not write world list to file.");
}
this.arenas.clear();
}
Expand Down
Loading

0 comments on commit 0376711

Please sign in to comment.