Compare commits
20 Commits
7b7b4bea93
...
0958aec5e1
Author | SHA1 | Date |
---|---|---|
JL-III | 0958aec5e1 | |
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 | |
JL-III | 685479e1b1 | |
JL-III | a654cbb45e | |
JL-III | 2806b9d9fa |
|
@ -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.
|
||||
|
@ -259,7 +261,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()
|
|
@ -2,6 +2,7 @@ package com.garbagemule.MobArena;
|
|||
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
import com.garbagemule.MobArena.things.Thing;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -15,6 +16,8 @@ public class RewardManager
|
|||
{
|
||||
private Map<Player,List<Thing>> players;
|
||||
private Set<Player> rewarded;
|
||||
private static final String PREFIX_LONG = "money:";
|
||||
private static final String PREFIX_SHORT = "$";
|
||||
|
||||
public RewardManager(Arena arena) {
|
||||
this.players = new HashMap<>();
|
||||
|
@ -38,13 +41,31 @@ public class RewardManager
|
|||
|
||||
List<Thing> rewards = players.get(p);
|
||||
if (rewards == null) return;
|
||||
Double moneyTotal = 0.00;
|
||||
|
||||
for (Thing reward : rewards) {
|
||||
if (reward == null) {
|
||||
continue;
|
||||
}
|
||||
reward.giveTo(p);
|
||||
String moneyHolder = trimPrefix(reward.toString());
|
||||
if (moneyHolder == null) continue;
|
||||
if (moneyHolder.contains(",")) {
|
||||
moneyHolder = moneyHolder.replaceAll(",","");
|
||||
}
|
||||
moneyTotal += Double.parseDouble(moneyHolder);
|
||||
}
|
||||
p.sendMessage(ChatColor.GREEN + "You were rewarded with: " + ChatColor.YELLOW + "$" + moneyTotal);
|
||||
rewarded.add(p);
|
||||
}
|
||||
|
||||
private String trimPrefix(String s) {
|
||||
if (s.startsWith(PREFIX_SHORT)) {
|
||||
return s.substring(PREFIX_SHORT.length());
|
||||
}
|
||||
if (s.startsWith(PREFIX_LONG)) {
|
||||
return s.substring(PREFIX_LONG.length());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
package com.garbagemule.MobArena.listeners;
|
||||
|
||||
import com.garbagemule.MobArena.ArenaPlayerStatistics;
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
import com.garbagemule.MobArena.PluginVersionCheck;
|
||||
import com.garbagemule.MobArena.events.ArenaKillEvent;
|
||||
import com.garbagemule.MobArena.events.ArenaPlayerDeathEvent;
|
||||
import com.garbagemule.MobArena.events.NewWaveEvent;
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||
import com.garbagemule.MobArena.leaderboards.Stats;
|
||||
import com.garbagemule.MobArena.things.Thing;
|
||||
import com.garbagemule.MobArena.things.ThingPicker;
|
||||
import com.garbagemule.MobArena.util.inventory.InventoryManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Instrument;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -397,8 +406,60 @@ public class MAGlobalListener implements Listener
|
|||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// PER KILL REWARDS //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void kill(ArenaKillEvent event){
|
||||
if (!plugin.getConfig().getBoolean( "arenas." + event.getArena().configName() + ".settings." + "custom-reward-per-kill")) return;
|
||||
Player player = event.getPlayer();
|
||||
Arena arena = event.getArena();
|
||||
int wave = arena.getWaveManager().getWaveNumber();
|
||||
String rewardPath;
|
||||
if (wave < 5) {
|
||||
rewardPath = "custom-reward-per-kill-0-5";
|
||||
} else if (wave <= 10) {
|
||||
rewardPath = "custom-reward-per-kill-5-10";
|
||||
} else {
|
||||
rewardPath = "custom-reward-per-kill-10+";
|
||||
}
|
||||
try {
|
||||
ThingPicker picker = am.getPlugin().getThingPickerManager().parse(plugin.getConfig().getString("arenas." + event.getArena().configName() + ".settings." + rewardPath));
|
||||
Thing thing = picker.pick();
|
||||
arena.getRewardManager().addReward(player, thing);
|
||||
event.getVictim().setCustomName(ChatColor.YELLOW + "+" + ChatColor.GREEN + thing.toString());
|
||||
event.getVictim().setCustomNameVisible(true);
|
||||
player.playNote(player.getLocation(), Instrument.CHIME, Note.natural(1, Note.Tone.A));
|
||||
player.playSound(player.getLocation(), Sound.ITEM_ARMOR_EQUIP_CHAIN,5,1);
|
||||
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("Failed to reward " + player.getName() + " for kill.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void WaveEvent(NewWaveEvent event) {
|
||||
if (event.getWaveNumber() > 1){
|
||||
for (Player player : event.getArena().getPlayersInArena()) {
|
||||
ArenaPlayerStatistics aps = event.getArena().getArenaPlayer(player).getStats();
|
||||
player.sendMessage("Total Kills: " + ChatColor.YELLOW + aps.getInt("kills"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ArenaDeath(ArenaPlayerDeathEvent event) {
|
||||
Arena arena = event.getArena();
|
||||
ArenaPlayerStatistics aps = arena.getArenaPlayer(event.getPlayer()).getStats();
|
||||
event.getPlayer().sendMessage("Total Kills on death: " + ChatColor.YELLOW + aps.getInt("kills"));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// WORLD EVENTS //
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -49,3 +49,7 @@ announcer-type: title
|
|||
global-join-announce: false
|
||||
global-end-announce: false
|
||||
show-death-messages: true
|
||||
custom-reward-per-kill: false
|
||||
custom-reward-per-kill-0-5: $5
|
||||
custom-reward-per-kill-5-10: $7.5
|
||||
custom-reward-per-kill-10+: $10
|
|
@ -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