Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .pnlibrary/changelogs/1.1.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# pnRelog 1.1.2

- Переход на pnLibrary 0.1.0-dev.8 (API 3): нужна новая библиотека; плагин не будет обновляться на старой.
- Адреса плейсхолдеров `%pnrelog_player_<ник>_<ключ>%` сохранены. Ник с `_` пишется как `~5F`.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ use-placeholderapi: true
- `%pnrelog_damage_dealt%`, `%pnrelog_damage_taken%`.
- `%pnrelog_hits_dealt%`, `%pnrelog_hits_taken%`.
- `%pnrelog_last_attacker%`.
- `%pnrelog_player_Steve_time%` - данные другого игрока.
- `%pnrelog_player_Steve_time%` - данные другого игрока (любой ключ выше; также `_opponents_contains_<ник>` и `_formatted`). Ник с `_` пишите как `~5F`: `Mr~5FX`.
- `%pnrelog_opponents_contains_<ник>%`, `..._formatted` - есть ли ник среди ваших противников.

## API Пример

Expand Down
5 changes: 5 additions & 0 deletions RELEASE-1.1.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# v1.1.2 — Переход на pnLibrary 0.1.0-dev.8

## Изменено
- Переход на pnLibrary 0.1.0-dev.8 (API 3): нужна новая библиотека; плагин не будет обновляться на старой.
- Адреса плейсхолдеров `%pnrelog_player_<ник>_<ключ>%` сохранены. Ник с `_` пишется как `~5F`.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = 'ru.privatenull'
version = '1.1.1'
version = '1.1.2'

base {
archivesName = 'pnRelog'
Expand All @@ -31,7 +31,7 @@ repositories {
}
}

def pnLibraryVersion = '0.1.0-dev.6'
def pnLibraryVersion = '0.1.0-dev.9'

dependencies {
implementation("io.github.pnfolder:pnlibrary-bootstrap-bukkit:${pnLibraryVersion}")
Expand All @@ -43,6 +43,8 @@ dependencies {
implementation('net.kyori:adventure-text-minimessage:4.17.0')
implementation('net.kyori:adventure-text-serializer-legacy:4.17.0')

testImplementation("io.github.pnfolder:pnlibrary-core:${pnLibraryVersion}") { transitive = false }
testImplementation('org.jetbrains:annotations:24.1.0')
testImplementation('org.junit.jupiter:junit-jupiter:5.11.4')
testRuntimeOnly('org.junit.platform:junit-platform-launcher:1.11.4')
testImplementation('com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT')
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/ru/privatenull/pnrelog/integration/Formatted.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ru.privatenull.pnrelog.integration;

import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholder;
import org.pnfolder.pnlibrary.api.placeholders.reply.Reply;

/** Ветка {@code formatted}: тот же ответ в виде из настроек ({@code placeholders.*} в config.yml). */
public final class Formatted {
private final String text;

Formatted(String text) {
this.text = text;
}

@Placeholder("Вид из настроек")
public Reply<String> formatted() {
return Reply.value(text);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ru.privatenull.pnrelog.integration;

import org.pnfolder.pnlibrary.api.placeholders.annotation.Argument;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholder;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholders;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Viewer;
import org.pnfolder.pnlibrary.api.placeholders.argument.ArgumentValue;
import org.pnfolder.pnlibrary.api.placeholders.info.ViewerInfo;
import org.pnfolder.pnlibrary.api.placeholders.reply.Reply;

/** {@code %pnrelog_opponents_contains_<ник>_formatted%}: тот же ответ в виде из настроек. */
@Placeholders("opponents")
public final class OpponentsFormat {
private final PnRelogPlaceholders values;

public OpponentsFormat(PnRelogPlaceholders values) {
this.values = values;
}

@Placeholder
public Reply<Formatted> contains(@Viewer ViewerInfo viewer, @Argument ArgumentValue<String> name) {
boolean has = viewer.getPlayerId() != null && values.hasOpponent(viewer.getPlayerId(), name.required());
return Reply.next(new Formatted(values.yesNo(has)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ru.privatenull.pnrelog.integration;

import org.pnfolder.pnlibrary.api.placeholders.annotation.Argument;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholder;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholders;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Viewer;
import org.pnfolder.pnlibrary.api.placeholders.argument.ArgumentValue;
import org.pnfolder.pnlibrary.api.placeholders.info.ViewerInfo;
import org.pnfolder.pnlibrary.api.placeholders.reply.Reply;

/**
* {@code %pnrelog_opponents_contains_<ник>%}: есть ли ник среди противников зрителя. Сам {@code %pnrelog_opponents%}
* регистрируется отдельно. Вид {@code _formatted} лежит в {@link OpponentsFormat}: тот же путь, другой класс.
*/
@Placeholders("opponents")
public final class OpponentsValues {
private final PnRelogPlaceholders values;

public OpponentsValues(PnRelogPlaceholders values) {
this.values = values;
}

@Placeholder("Есть ли ник среди противников")
public Reply<String> contains(@Viewer ViewerInfo viewer, @Argument ArgumentValue<String> name) {
boolean has = viewer.getPlayerId() != null && values.hasOpponent(viewer.getPlayerId(), name.required());
return Reply.value(Boolean.toString(has));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package ru.privatenull.pnrelog.integration;

import org.pnfolder.pnlibrary.api.placeholders.annotation.Argument;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholder;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholders;
import org.pnfolder.pnlibrary.api.placeholders.argument.ArgumentValue;
import org.pnfolder.pnlibrary.api.placeholders.reply.Reply;

import java.util.UUID;

/** Третья часть группы {@code player}: {@code opponents_contains_<ник>_formatted}. */
@Placeholders("player")
public final class PlayerContainsFormat {
private final PnRelogPlaceholders values;

public PlayerContainsFormat(PnRelogPlaceholders values) {
this.values = values;
}

@Placeholder(bare = true)
public Reply<View> player(@Argument ArgumentValue<String> name) {
return Reply.next(new View(values, values.idOf(name.required())));
}

/** {@code opponents.contains.<ник>.formatted}. */
public static final class View {
private final PnRelogPlaceholders values;
private final UUID id;

View(PnRelogPlaceholders values, UUID id) {
this.values = values;
this.id = id;
}

@Placeholder
public Reply<Contains> opponents() {
return Reply.next(new Contains(values, id));
}
}

public static final class Contains {
private final PnRelogPlaceholders values;
private final UUID id;

Contains(PnRelogPlaceholders values, UUID id) {
this.values = values;
this.id = id;
}

@Placeholder
public Reply<Formatted> contains(@Argument ArgumentValue<String> name) {
return Reply.next(new Formatted(values.yesNo(values.hasOpponent(id, name.required()))));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package ru.privatenull.pnrelog.integration;

import org.pnfolder.pnlibrary.api.placeholders.annotation.Argument;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholder;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholders;
import org.pnfolder.pnlibrary.api.placeholders.argument.ArgumentValue;
import org.pnfolder.pnlibrary.api.placeholders.reply.Reply;

import java.util.UUID;

/** Вторая часть группы {@code player}: {@code in_formatted}, {@code time_formatted} и {@code opponents_contains_<ник>}. */
@Placeholders("player")
public final class PlayerFormats {
private final PnRelogPlaceholders values;

public PlayerFormats(PnRelogPlaceholders values) {
this.values = values;
}

@Placeholder(bare = true)
public Reply<View> player(@Argument ArgumentValue<String> name) {
return Reply.next(new View(values, values.idOf(name.required())));
}

/** {@code in.formatted}, {@code time.formatted}, {@code opponents.contains.<ник>}. */
public static final class View {
private final PnRelogPlaceholders values;
private final UUID id;

View(PnRelogPlaceholders values, UUID id) {
this.values = values;
this.id = id;
}

@Placeholder
public Reply<Formatted> in() {
return Reply.next(new Formatted(values.value(id, "in_formatted")));
}

@Placeholder
public Reply<Formatted> time() {
return Reply.next(new Formatted(values.formattedTime(id)));
}

@Placeholder
public Reply<Contains> opponents() {
return Reply.next(new Contains(values, id));
}
}

/** {@code contains.<ник>}: есть ли ник среди противников, {@code true} или {@code false}. */
public static final class Contains {
private final PnRelogPlaceholders values;
private final UUID id;

Contains(PnRelogPlaceholders values, UUID id) {
this.values = values;
this.id = id;
}

@Placeholder("Есть ли ник среди противников")
public Reply<String> contains(@Argument ArgumentValue<String> name) {
return Reply.value(Boolean.toString(values.hasOpponent(id, name.required())));
}
}
}
130 changes: 130 additions & 0 deletions src/main/java/ru/privatenull/pnrelog/integration/PlayerValues.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package ru.privatenull.pnrelog.integration;

import org.pnfolder.pnlibrary.api.placeholders.annotation.Argument;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholder;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Placeholders;
import org.pnfolder.pnlibrary.api.placeholders.argument.ArgumentValue;
import org.pnfolder.pnlibrary.api.placeholders.info.ViewerInfo;
import org.pnfolder.pnlibrary.api.placeholders.annotation.Viewer;
import org.pnfolder.pnlibrary.api.placeholders.reply.Reply;

import java.util.UUID;

/**
* {@code %pnrelog_player_<ник>_<ключ>%}: бой другого игрока, ключи те же, что у своих. Один адрес собран из трёх
* классов группы {@code player} ({@link PlayerValues}, {@link PlayerFormats}, {@link PlayerContainsFormat}):
* у значения и у его вида {@code _formatted} один и тот же путь, а в одном классе имя занять дважды нельзя.
*/
@Placeholders("player")
public final class PlayerValues {
private final PnRelogPlaceholders values;

public PlayerValues(PnRelogPlaceholders values) {
this.values = values;
}

@Placeholder(value = "player.<ник>.<ключ>: бой другого игрока", bare = true)
public Reply<View> player(@Argument ArgumentValue<String> name) {
return Reply.next(new View(values, values.idOf(name.required())));
}

/** Простые ключи боя игрока. */
public static final class View {
private final PnRelogPlaceholders values;
private final UUID id;

View(PnRelogPlaceholders values, UUID id) {
this.values = values;
this.id = id;
}

@Placeholder
public Reply<String> active() {
return Reply.value(values.value(id, "active"));
}

@Placeholder
public Reply<String> in() {
return Reply.value(values.value(id, "in"));
}

@Placeholder
public Reply<String> time() {
return Reply.value(values.value(id, "time"));
}

@Placeholder
public Reply<String> opponents() {
return Reply.value(values.value(id, "opponents"));
}

@Placeholder
public Reply<Count> opponent() {
return Reply.next(new Count(values.value(id, "opponent_count")));
}

@Placeholder
public Reply<Pair> damage() {
return Reply.next(new Pair(values.value(id, "damage_dealt"), values.value(id, "damage_taken")));
}

@Placeholder
public Reply<Pair> hits() {
return Reply.next(new Pair(values.value(id, "hits_dealt"), values.value(id, "hits_taken")));
}

@Placeholder
public Reply<Last> last() {
return Reply.next(new Last(values.value(id, "last_attacker")));
}
}

/** {@code opponent.count}. */
public static final class Count {
private final String count;

Count(String count) {
this.count = count;
}

@Placeholder
public Reply<String> count() {
return Reply.value(count);
}
}

/** {@code damage.dealt/taken} и {@code hits.dealt/taken}. */
public static final class Pair {
private final String dealt;
private final String taken;

Pair(String dealt, String taken) {
this.dealt = dealt;
this.taken = taken;
}

@Placeholder
public Reply<String> dealt() {
return Reply.value(dealt);
}

@Placeholder
public Reply<String> taken() {
return Reply.value(taken);
}
}

/** {@code last.attacker}. */
public static final class Last {
private final String attacker;

Last(String attacker) {
this.attacker = attacker;
}

@Placeholder
public Reply<String> attacker() {
return Reply.value(attacker);
}
}
}
Loading
Loading