Compare commits
19 Commits
35bee7e3a3
...
73a36846fa
Author | SHA1 | Date |
---|---|---|
OreoKirby | 73a36846fa | |
Andreas Troelsen | 29c5d7f56d | |
Andreas Troelsen | e40fc6ef84 | |
Andreas Troelsen | be6fd85a6d | |
Andreas Troelsen | b881943656 | |
Andreas Troelsen | 8e5d2f0d23 | |
Andreas Troelsen | 3b7b638b00 | |
Andreas Troelsen | eb51a31720 | |
Andreas Troelsen | 82f00c5535 | |
Andreas Troelsen | d8fdbb80c0 | |
Andreas Troelsen | e5ffe169a1 | |
Andreas Troelsen | 798ae0f578 | |
Andreas Troelsen | 84776990b9 | |
Andreas Troelsen | 590f877756 | |
Andreas Troelsen | 932b9de8f2 | |
Andreas Troelsen | 614d95683e | |
Andreas Troelsen | 4c855e6705 | |
OreoKirby | 28863f82ae | |
Shayne | 9968a24fa2 |
|
@ -1,15 +1,20 @@
|
|||
name: build
|
||||
|
||||
on:
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
|
||||
steps:
|
||||
- name: 'Checkout source code'
|
||||
- name: 'Checkout'
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 'Set up JDK'
|
||||
|
@ -19,11 +24,56 @@ jobs:
|
|||
distribution: 'adopt'
|
||||
cache: 'gradle'
|
||||
|
||||
- name: 'Build, test, and package'
|
||||
- name: 'Build'
|
||||
run: ./gradlew build --no-daemon
|
||||
|
||||
- name: 'Upload artifact'
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: MobArena.jar
|
||||
path: build/libs/MobArena.jar
|
||||
path: build/libs/MobArena-*.jar
|
||||
|
||||
- name: 'Output version'
|
||||
id: version
|
||||
run: |
|
||||
version=$(
|
||||
unzip -p build/libs/MobArena-*.jar plugin.yml \
|
||||
| grep '^version: ' \
|
||||
| awk '{printf $2}' \
|
||||
| tr -d "'" \
|
||||
)
|
||||
echo "version=${version}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
draft:
|
||||
needs: build
|
||||
|
||||
if: |
|
||||
needs.build.result == 'success' &&
|
||||
github.ref_name == 'master' &&
|
||||
startsWith(github.event.head_commit.message, 'Release ') &&
|
||||
!endsWith(needs.build.outputs.version, '-SNAPSHOT')
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
VERSION: ${{ needs.build.outputs.version }}
|
||||
|
||||
steps:
|
||||
- name: 'Checkout'
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 'Download artifact'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: MobArena.jar
|
||||
|
||||
- name: 'Extract release notes'
|
||||
run: scripts/extract-release-notes -f github "${VERSION}" > release-notes.md
|
||||
|
||||
- name: 'Create release draft'
|
||||
run: gh release create "${VERSION}" --draft --notes-file release-notes.md MobArena-*.jar
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
name: publish-curseforge
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- 'released'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag_name:
|
||||
description: 'The tag name of the release to publish'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
TAG_NAME: ${{ github.event.release.tag_name || inputs.tag_name }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download release assets
|
||||
run: gh release download "${TAG_NAME}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Publish to CurseForge
|
||||
run: |
|
||||
echo 'Extract release notes'
|
||||
changelog=$(scripts/extract-release-notes -f curse "${TAG_NAME}")
|
||||
|
||||
echo 'Look up game version IDs'
|
||||
game_version_type_id=1
|
||||
game_version_names='"1.20","1.19","1.18","1.17","1.16","1.15","1.14","1.13"'
|
||||
|
||||
type_condition="(.gameVersionTypeID == ${game_version_type_id})"
|
||||
name_condition="(.name | startswith(${game_version_names}))"
|
||||
|
||||
game_version_ids=$(
|
||||
curl -s -X GET 'https://minecraft.curseforge.com/api/game/versions' \
|
||||
-H "X-Api-Token: ${{ secrets.CURSEFORGE_TOKEN }}" \
|
||||
| jq -c ".[] | select(${type_condition} and ${name_condition}) | .id" \
|
||||
| paste -sd, - \
|
||||
)
|
||||
|
||||
echo 'Create metadata file'
|
||||
cat << EOF > metadata.jq
|
||||
{
|
||||
changelog: \$changelog,
|
||||
changelogType: "html",
|
||||
displayName: \$displayName,
|
||||
gameVersions: \$gameVersions,
|
||||
releaseType: "beta"
|
||||
}
|
||||
EOF
|
||||
|
||||
jq -c -n \
|
||||
--arg changelog "${changelog}" \
|
||||
--arg displayName "MobArena v${TAG_NAME}" \
|
||||
--argjson gameVersions "[${game_version_ids}]" \
|
||||
-f metadata.jq \
|
||||
> metadata.json
|
||||
|
||||
echo 'Publish build to CurseForge'
|
||||
base_url='https://minecraft.curseforge.com'
|
||||
project_id=31265
|
||||
|
||||
curl -s -X POST "${base_url}/api/projects/${project_id}/upload-file" \
|
||||
-H "X-Api-Token: ${{ secrets.CURSEFORGE_TOKEN }}" \
|
||||
-F 'metadata=<metadata.json' \
|
||||
-F "file=@MobArena-${TAG_NAME}.jar"
|
|
@ -0,0 +1,79 @@
|
|||
name: publish-hangar
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- 'released'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag_name:
|
||||
description: 'The tag name of the release to publish'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
TAG_NAME: ${{ github.event.release.tag_name || inputs.tag_name }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download release assets
|
||||
run: gh release download "${TAG_NAME}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Publish to Hangar
|
||||
run: |
|
||||
echo 'Extract release notes'
|
||||
changelog=$(scripts/extract-release-notes -f hangar "${TAG_NAME}")
|
||||
|
||||
echo 'Create version upload file'
|
||||
cat << EOF > version-upload.jq
|
||||
{
|
||||
version: \$version,
|
||||
channel: "Release",
|
||||
description: \$changelog,
|
||||
platformDependencies: {
|
||||
"PAPER": [
|
||||
"1.13.x",
|
||||
"1.14.x",
|
||||
"1.15.x",
|
||||
"1.16.x",
|
||||
"1.17.x",
|
||||
"1.18.x",
|
||||
"1.19.x",
|
||||
"1.20.x"
|
||||
]
|
||||
},
|
||||
pluginDependencies: {},
|
||||
files: [
|
||||
{ platforms: ["PAPER"] }
|
||||
]
|
||||
}
|
||||
EOF
|
||||
|
||||
jq -c -n \
|
||||
--arg version "${TAG_NAME}" \
|
||||
--arg changelog "${changelog}" \
|
||||
-f version-upload.jq \
|
||||
> version-upload.json
|
||||
|
||||
echo 'Authenticate with Hangar'
|
||||
base_url='https://hangar.papermc.io/api/v1'
|
||||
key=${{ secrets.HANGAR_TOKEN }}
|
||||
jwt=$(curl -s -X POST "${base_url}/authenticate?apiKey=${key}" | jq -r '.token')
|
||||
|
||||
echo 'Publish build to Hangar'
|
||||
project_slug='MobArena'
|
||||
curl -s -X POST "${base_url}/projects/${project_slug}/upload" \
|
||||
-H "Authorization: ${jwt}" \
|
||||
-F 'versionUpload=<version-upload.json;type=application/json' \
|
||||
-F "files=@MobArena-${TAG_NAME}.jar"
|
|
@ -4,7 +4,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "com.garbagemule"
|
||||
version = "0.107.1-SNAPSHOT"
|
||||
version = "0.108"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
@ -58,7 +58,6 @@ tasks {
|
|||
|
||||
archiveBaseName = "MobArena"
|
||||
archiveClassifier = ""
|
||||
archiveVersion = ""
|
||||
}
|
||||
|
||||
// We're using shadowJar, so we can skip the regular jar task.
|
||||
|
|
|
@ -11,6 +11,8 @@ These changes will (most likely) be included in the next version.
|
|||
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.108] - 2024-01-01
|
||||
### Added
|
||||
- Support for chest references in item syntax. The new `inv` syntax allows for referencing container indices in the config-file. This should help bridge the gap between class chests and various other parts of the config-file, such as rewards and upgrade waves.
|
||||
- Support for saved items. The new `/ma save-item` command can be used to save the currently held item to disk, which allows it to be used in various places in the config-file. This should help bridge the gap between the config-file and class chests for config-file centric setups.
|
||||
|
@ -30,6 +32,7 @@ These changes will (most likely) be included in the next version.
|
|||
- Husks, drowned, piglins, hoglins, and zoglins can now be spawned in their baby versions using the `baby` prefix seen on other monster types (e.g. `baby-zombie`).
|
||||
- Pet names are now per-class configurable via the optional `pet-name` property, which defaults to `<display-name>'s pet` (the `<player-name>` variable is also supported).
|
||||
- New per-arena setting `auto-leave-on-end` can be used to automatically "kick" spectators when the current session ends.
|
||||
- New per-arena setting `monster-glow-delay` can be used to apply a glowing effect per-wave after a specified time making it easier to find monsters in the arena.
|
||||
- New per-arena setting `clear-wave-leeway` allows for tweaking the number of mobs allowed to be alive before the next wave spawns. The setting affects `clear-wave-before-next`, `clear-wave-before-boss`, and the final wave check, and it defaults to 0.
|
||||
- New per-arena setting `auto-ignite-fuse` makes the fuse time for auto-ignited TNT configurable. The unit is ticks and defaults to 80.
|
||||
- Added boss abilities `disorient-all`, `fetch-all`, `pull-all`, and `throw-all`. These abilities work like their target-specific and distance-based counterparts, but affect all players in the arena.
|
||||
|
@ -259,7 +262,8 @@ Thanks to:
|
|||
- Swatacular for help with testing bug fixes
|
||||
- Haileykins for contributions to the code base
|
||||
|
||||
[Unreleased]: https://github.com/garbagemule/MobArena/compare/0.107...HEAD
|
||||
[Unreleased]: https://github.com/garbagemule/MobArena/compare/0.108...HEAD
|
||||
[0.108]: https://github.com/garbagemule/MobArena/compare/0.107...0.108
|
||||
[0.107]: https://github.com/garbagemule/MobArena/compare/0.106...0.107
|
||||
[0.106]: https://github.com/garbagemule/MobArena/compare/0.105...0.106
|
||||
[0.105]: https://github.com/garbagemule/MobArena/compare/0.104.2...0.105
|
||||
|
|
|
@ -0,0 +1,235 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
VERSION_PREFIX = '## '
|
||||
SECTION_PREFIX = '### '
|
||||
LIST_ITEM_PREFIX = '- '
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
lines = extract(args.version)
|
||||
output(lines, args.format)
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'version',
|
||||
help='the version to extract release notes from the changelog for',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--format',
|
||||
'-f',
|
||||
choices=['github', 'hangar', 'spigot', 'curse'],
|
||||
help='the format to output the release notes in',
|
||||
)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def extract(target):
|
||||
filename = 'changelog.md'
|
||||
if not os.path.isfile(filename):
|
||||
filename = os.path.join('..', filename)
|
||||
if not os.path.isfile(filename):
|
||||
print('error: changelog.md not found!')
|
||||
sys.exit(1)
|
||||
|
||||
lines = []
|
||||
|
||||
with open(filename) as changelog:
|
||||
found = False
|
||||
|
||||
for entry in changelog:
|
||||
if entry.startswith(VERSION_PREFIX):
|
||||
if found:
|
||||
break
|
||||
|
||||
i = entry.find('[') + 1
|
||||
j = entry.find(']')
|
||||
version = entry[i:j]
|
||||
|
||||
if version == target:
|
||||
if version[0].isdigit():
|
||||
version = f'v{version}'
|
||||
|
||||
lines.append(f'{VERSION_PREFIX}{version}')
|
||||
lines.append('')
|
||||
found = True
|
||||
|
||||
continue
|
||||
|
||||
if not found:
|
||||
continue
|
||||
|
||||
lines.append(entry.strip())
|
||||
|
||||
if not found:
|
||||
print(f'error: version {target} not found!')
|
||||
sys.exit(1)
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
def output(lines, fmt):
|
||||
if fmt == 'github':
|
||||
output_as_github_markdown(lines)
|
||||
elif fmt == 'hangar':
|
||||
output_as_hangar_markdown(lines)
|
||||
elif fmt == 'spigot':
|
||||
output_as_spigot_bbcode(lines)
|
||||
elif fmt == 'curse':
|
||||
output_as_curseforge_html(lines)
|
||||
else:
|
||||
output_raw(lines)
|
||||
|
||||
|
||||
def output_as_github_markdown(lines):
|
||||
"""
|
||||
GitHub Releases Markdown is printed as the raw output from the changelog
|
||||
except for the version header (the first line), because the version number
|
||||
is already used as the release title, so we don't want it to appear twice.
|
||||
"""
|
||||
output_raw(lines[1:])
|
||||
|
||||
|
||||
def output_as_hangar_markdown(lines):
|
||||
"""
|
||||
Hangar Versions use Markdown in the same format as GitHub Releases, so we
|
||||
don't actually need to do anything else here either. Just strip the first
|
||||
line so we don't get a duplicate header.
|
||||
"""
|
||||
output_raw(lines[1:])
|
||||
|
||||
|
||||
def output_as_spigot_bbcode(lines):
|
||||
"""
|
||||
Spigot uses BBCode for resource update descriptions. It's very similar to
|
||||
regular HTML, which makes it fairly easy to convert from Markdown. We just
|
||||
need to use a [FONT] tag with Courier New for code bits.
|
||||
"""
|
||||
listing = False
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
|
||||
if line.startswith(VERSION_PREFIX):
|
||||
i = len(VERSION_PREFIX)
|
||||
version = line[i:]
|
||||
print(f'[B]{version}[/B]')
|
||||
continue
|
||||
|
||||
if line.startswith(SECTION_PREFIX):
|
||||
if listing:
|
||||
print('[/LIST]')
|
||||
listing = False
|
||||
|
||||
i = len(SECTION_PREFIX)
|
||||
section = line[i:]
|
||||
print(f'[B]{section}:[/B]')
|
||||
continue
|
||||
|
||||
if line.startswith(LIST_ITEM_PREFIX):
|
||||
if not listing:
|
||||
print('[LIST]')
|
||||
listing = True
|
||||
|
||||
i = len(LIST_ITEM_PREFIX)
|
||||
item = line[i:]
|
||||
|
||||
# Replace **bold** text
|
||||
item = re.sub(r'\*\*(.*?)\*\*', r'[B]\1[/B]', item)
|
||||
|
||||
# Replace _italic_ text
|
||||
item = re.sub(r'_(.*?)_', r'[I]\1[/I]', item)
|
||||
|
||||
# Replace `code` text
|
||||
item = re.sub(r'`(.*?)`', r'[FONT=Courier New]\1[/FONT]', item)
|
||||
|
||||
# Replace [links](url)
|
||||
item = re.sub(r'\[([^\]]+)]\(([^)]+)\)', r'[URL=\2]\1[/URL]', item)
|
||||
|
||||
print(f'[*]{item}')
|
||||
continue
|
||||
|
||||
if len(line) > 0:
|
||||
print(line)
|
||||
|
||||
if listing:
|
||||
print('[/LIST]')
|
||||
|
||||
|
||||
def output_as_curseforge_html(lines):
|
||||
"""
|
||||
CurseForge uses regular HTML for file update descriptions, which makes it
|
||||
fairly easy to convert from Markdown. Angled brackets need to be replaced
|
||||
with their HTML entity equivalents, but other than that it's very similar
|
||||
to the Spigot BBCode conversion.
|
||||
"""
|
||||
listing = False
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
|
||||
if line.startswith(VERSION_PREFIX):
|
||||
i = len(VERSION_PREFIX)
|
||||
version = line[i:]
|
||||
print(f'<p><strong>{version}</strong></p>')
|
||||
continue
|
||||
|
||||
if line.startswith(SECTION_PREFIX):
|
||||
if listing:
|
||||
print('</ul>')
|
||||
listing = False
|
||||
|
||||
i = len(SECTION_PREFIX)
|
||||
section = line[i:]
|
||||
print(f'<p><strong>{section}:</strong></p>')
|
||||
continue
|
||||
|
||||
if line.startswith(LIST_ITEM_PREFIX):
|
||||
if not listing:
|
||||
print('<ul>')
|
||||
listing = True
|
||||
|
||||
i = len(LIST_ITEM_PREFIX)
|
||||
item = line[i:]
|
||||
|
||||
# Replace angled brackets
|
||||
item = item.replace('<', '<')
|
||||
item = item.replace('>', '>')
|
||||
|
||||
# Replace **bold** text
|
||||
item = re.sub(r'\*\*(.*?)\*\*', r'<strong>\1</strong>', item)
|
||||
|
||||
# Replace _italic_ text
|
||||
item = re.sub(r'_(.*?)_', r'<emph>\1</emph>', item)
|
||||
|
||||
# Replace `code` text
|
||||
item = re.sub(r'`(.*?)`', r'<code>\1</code>', item)
|
||||
|
||||
# Replace [links](url)
|
||||
item = re.sub(r'\[([^\]]+)]\(([^)]+)\)', r'<a href="\2">\1</a>', item)
|
||||
|
||||
print(f'<li>{item}</li>')
|
||||
continue
|
||||
|
||||
if len(line) > 0:
|
||||
print(line)
|
||||
|
||||
if listing:
|
||||
print('</ul>')
|
||||
|
||||
|
||||
def output_raw(lines):
|
||||
[print(line.strip()) for line in lines]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -9,6 +9,7 @@ import com.garbagemule.MobArena.region.ArenaRegion;
|
|||
import com.garbagemule.MobArena.things.ExperienceThing;
|
||||
import com.garbagemule.MobArena.things.Thing;
|
||||
import com.garbagemule.MobArena.things.ThingPicker;
|
||||
import com.garbagemule.MobArena.util.PotionEffectParser;
|
||||
import com.garbagemule.MobArena.waves.MABoss;
|
||||
import com.garbagemule.MobArena.waves.MACreature;
|
||||
import com.garbagemule.MobArena.waves.Wave;
|
||||
|
@ -24,11 +25,14 @@ import org.bukkit.attribute.Attribute;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class MASpawnThread implements Runnable
|
||||
{
|
||||
|
@ -45,6 +49,7 @@ public class MASpawnThread implements Runnable
|
|||
private int clearLeeway;
|
||||
private int waveInterval;
|
||||
private int nextWaveDelay;
|
||||
private long monsterGlowDelay;
|
||||
|
||||
private BukkitTask task;
|
||||
|
||||
|
@ -81,6 +86,7 @@ public class MASpawnThread implements Runnable
|
|||
wavesAsLevel = arena.getSettings().getBoolean("display-waves-as-level", false);
|
||||
waveInterval = arena.getSettings().getInt("wave-interval", 3);
|
||||
nextWaveDelay = arena.getSettings().getInt("next-wave-delay", 0);
|
||||
monsterGlowDelay = arena.getSettings().getLong("monster-glow-delay", 0L);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
@ -204,6 +210,7 @@ public class MASpawnThread implements Runnable
|
|||
World world = arena.getWorld();
|
||||
int totalSpawnpoints = spawnpoints.size();
|
||||
int index = 0;
|
||||
int waveNumber = waveManager.getWaveNumber();
|
||||
double mul = w.getHealthMultiplier();
|
||||
|
||||
for (Map.Entry<MACreature, Integer> entry : monsters.entrySet()) {
|
||||
|
@ -225,6 +232,9 @@ public class MASpawnThread implements Runnable
|
|||
// Add it to the arena.
|
||||
monsterManager.addMonster(e);
|
||||
|
||||
// Add it to the current wave.
|
||||
monsterManager.addWaveMonster(e, waveNumber);
|
||||
|
||||
// Set the health.
|
||||
int health = (int) Math.max(1D, e.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() * mul);
|
||||
try {
|
||||
|
@ -279,6 +289,12 @@ public class MASpawnThread implements Runnable
|
|||
}
|
||||
}
|
||||
}
|
||||
// Apply a highlighting effect to monsters after monster-glow-delay defined seconds
|
||||
if (Math.round(monsterGlowDelay) > 0) {
|
||||
PotionEffect effect = PotionEffectParser.parsePotionEffect("glowing", true);
|
||||
BukkitRunnable runnable = addGlowMonsters(effect, monsterManager.getWaveMonsters(waveManager.getWaveNumber()));
|
||||
runnable.runTaskLater(plugin, Math.round(monsterGlowDelay) * 20L);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUpgradeWave(Wave w) {
|
||||
|
@ -328,6 +344,20 @@ public class MASpawnThread implements Runnable
|
|||
return true;
|
||||
}
|
||||
|
||||
private BukkitRunnable addGlowMonsters(PotionEffect potionEffect, Set<LivingEntity> entities){
|
||||
BukkitRunnable runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
entities.forEach(entity ->{
|
||||
if(!entity.isDead()){
|
||||
entity.addPotionEffect(potionEffect);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return runnable;
|
||||
}
|
||||
|
||||
private void removeDeadMonsters() {
|
||||
List<Entity> tmp = new ArrayList<>(monsterManager.getMonsters());
|
||||
for (Entity e : tmp) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.Set;
|
|||
public class MonsterManager
|
||||
{
|
||||
private Set<LivingEntity> monsters, sheep, golems;
|
||||
private Map<Integer, Set<LivingEntity>> waveMonsters;
|
||||
private Map<LivingEntity,MABoss> bosses;
|
||||
private Map<LivingEntity,List<ItemStack>> suppliers;
|
||||
private Set<LivingEntity> mounts;
|
||||
|
@ -27,6 +28,7 @@ public class MonsterManager
|
|||
|
||||
public MonsterManager() {
|
||||
this.monsters = new HashSet<>();
|
||||
this.waveMonsters = new HashMap<>();
|
||||
this.sheep = new HashSet<>();
|
||||
this.golems = new HashSet<>();
|
||||
this.bosses = new HashMap<>();
|
||||
|
@ -38,6 +40,7 @@ public class MonsterManager
|
|||
|
||||
public void reset() {
|
||||
monsters.clear();
|
||||
waveMonsters.clear();
|
||||
sheep.clear();
|
||||
golems.clear();
|
||||
bosses.clear();
|
||||
|
@ -88,10 +91,25 @@ public class MonsterManager
|
|||
return monsters;
|
||||
}
|
||||
|
||||
public Set<LivingEntity> getWaveMonsters(int wave) {
|
||||
return waveMonsters.get(wave);
|
||||
}
|
||||
|
||||
public void addMonster(LivingEntity e) {
|
||||
monsters.add(e);
|
||||
}
|
||||
|
||||
public void addWaveMonster(LivingEntity e, int wave) {
|
||||
if(waveMonsters.containsKey(wave)) {
|
||||
waveMonsters.get(wave).add(e);
|
||||
}
|
||||
else {
|
||||
Set<LivingEntity> set = new HashSet<>();
|
||||
set.add(e);
|
||||
waveMonsters.put(wave, set);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeMonster(Entity e) {
|
||||
return monsters.remove(e);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.garbagemule.MobArena.formula;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BinaryOperation extends BiFunction<Double, Double, Double> {
|
||||
public interface BinaryOperation {
|
||||
|
||||
double apply(double left, double right);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.garbagemule.MobArena.formula;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface UnaryOperation extends Function<Double, Double> {
|
||||
public interface UnaryOperation {
|
||||
|
||||
double apply(double value);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.bukkit.World;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class InventoryThingParser implements ThingParser {
|
||||
class InventoryThingParser implements ThingParser {
|
||||
|
||||
private static final String PREFIX = "inv(";
|
||||
private static final String SUFFIX = ")";
|
||||
|
|
|
@ -10,21 +10,17 @@ public class ThingManager implements ThingParser {
|
|||
private final List<ThingParser> parsers;
|
||||
private final ItemStackThingParser items;
|
||||
|
||||
public ThingManager(MobArena plugin, ItemStackThingParser parser) {
|
||||
public ThingManager(MobArena plugin) {
|
||||
parsers = new ArrayList<>();
|
||||
parsers.add(new CommandThingParser());
|
||||
parsers.add(new MoneyThingParser(plugin));
|
||||
parsers.add(new PermissionThingParser(plugin));
|
||||
parsers.add(new PotionEffectThingParser());
|
||||
parsers.add(new InventoryThingParser(plugin.getServer()));
|
||||
items = parser;
|
||||
items = new ItemStackThingParser();
|
||||
items.register(new SavedItemParser(plugin));
|
||||
}
|
||||
|
||||
public ThingManager(MobArena plugin) {
|
||||
this(plugin, new ItemStackThingParser());
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new thing parser in the manager.
|
||||
*
|
||||
|
|
|
@ -24,6 +24,7 @@ max-players: 0
|
|||
max-join-distance: 0
|
||||
join-interrupt-timer: 0
|
||||
first-wave-delay: 5
|
||||
monster-glow-delay: 120
|
||||
next-wave-delay: 0
|
||||
wave-interval: 15
|
||||
final-wave: 0
|
||||
|
|
|
@ -230,8 +230,8 @@ public class FormulaManagerIT {
|
|||
@Parameters(name = "{0} = {1}")
|
||||
public static Iterable<Object[]> data() {
|
||||
return Arrays.asList(new Object[][]{
|
||||
{"1 + +1.2", 1 + +1.2},
|
||||
{"1 + -1.2", 1 + -1.2},
|
||||
{"1 + +1.2", 1 + 1.2},
|
||||
{"1 + -1.2", 1 + (-1.2)},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -259,8 +259,8 @@ public class FormulaManagerIT {
|
|||
@Parameters(name = "{0} = {1}")
|
||||
public static Iterable<Object[]> data() {
|
||||
return Arrays.asList(new Object[][]{
|
||||
{"1+-2", 1 + -2},
|
||||
{"3-+4", 3 - +4},
|
||||
{"1+-2", 1 + (-2)},
|
||||
{"3-+4", 3 - 4},
|
||||
{"3*7.5", 3 * 7.5},
|
||||
{"10/2.5", 10 / 2.5},
|
||||
{"9%4", 9 % 4},
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.hamcrest.TypeSafeMatcher;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
public class LexemeMatcher extends TypeSafeMatcher<Lexeme> {
|
||||
class LexemeMatcher extends TypeSafeMatcher<Lexeme> {
|
||||
|
||||
private final TokenType type;
|
||||
private final String value;
|
||||
|
|
Loading…
Reference in New Issue