Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 972bd02

Browse files
authored
Merge pull request #17 from VectorNetworkProject/develop
Develop
2 parents e514444 + d0450e6 commit 972bd02

File tree

4 files changed

+53
-13
lines changed

4 files changed

+53
-13
lines changed

README.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
11
# DataProvider
22
[![Build Status](https://scrutinizer-ci.com/g/VectorNetworkProject/DataProvider/badges/build.png?b=master)](https://scrutinizer-ci.com/g/VectorNetworkProject/DataProvider/build-status/master)
33

4-
データを格納するためのプラグイン
4+
データを格納するためのプラグイン
5+
## テーブル
56

6-
##使い方
7+
### **accounts**
78

9+
| Column | Type | Description |
10+
| :----: | :---: | :---------: |
11+
| id | int | 登録したときに自動的に付与されます |
12+
|name |string |プレイヤーの名前です。 |
13+
14+
 UserdataProviderで基本となる情報を扱うテーブルです。ここに記載されたIDをもとに各テーブルの管理を行います。
15+
 sqlite.sql上ではidをメインにやり取りしていますが、デベロッパーが扱う際はラップしたクラス群の関数を使ってください。
16+
17+
### **ffapvp**
18+
19+
| Column | Type | Description |
20+
| :----: | :---: | :---------: |
21+
| id | int | プレイヤーと対応するaccountsテーブルのid |
22+
| kill | int | キル数 |
23+
| death | int | デス数 |
24+
| exp | int | EXP |
25+
26+
### **dual**
27+
28+
| Column | Type | Description |
29+
| :----: | :---: | :---------: |
30+
| id | int | プレイヤーと対応するaccountsテーブルのid |
31+
| kill | int | キル数 |
32+
| death | int | デス数 |
33+
| win | int | 勝利数 |
34+
| lose | int| 敗北数 |
35+
36+
## 使い方
837
```PHP
938
public function onEnable()
1039
{
@@ -15,10 +44,21 @@ public funciton onPlayerJoin(PlayerJoinEvent $event)
1544
{
1645
$this->accounts->get(
1746
$event->player,
18-
function (array $rows) use($player)
47+
function(array $rows) use($player): void
1948
{
20-
$player->sendMessage("あなたのIDは$raws[0][id]です");
49+
if($rows[0] !== null)
50+
{
51+
$player->sendMessage("あなたのIDは$raws[0][id]です");
52+
}
53+
},
54+
function(SqlError $error, ?Exception $trace): void //https://github.com/poggit/libasynql/blob/master/libasynql/src/poggit/libasynql/base/DataConnectorImpl.php#L196
55+
{
56+
var_dump($error, $trace);
2157
}
2258
);
2359
}
24-
``````
60+
```
61+
62+
 クエリの終了時、またはエラー時の際の処理をクロージャで渡してください。
63+
 終了時の引数は`array $rows`で結果が`$rows[<順番>][<カラム名>]`で格納されます。エラー時の引数は上記の通り`SqlError $error, ?Ecxeption $trace`となります。`SqlError`については[SqlError](https://github.com/poggit/libasynql/blob/master/libasynql/src/poggit/libasynql/SqlError.php)を参照してください。
64+
 `$raws[<int>]`に格納されているデータは基本的に`accounts``name`カラムとそれぞれのテーブルのカラムを複合したものになります。`

plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: DataProvider
2-
version: 0.0.1
2+
version: 0.1.0
33
api: 3.2.3
44
main: VectorNetworkProject\DataProvider\Main
55
prefix: DataProvider

resources/sqlite.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- # { init
55
CREATE TABLE IF NOT EXISTS accounts(
66
id INTEGER PRIMARY KEY AUTOINCREMENT,
7-
name TEXT PRIMARY KEY
7+
name TEXT UNIQUE
88
);
99
-- # }
1010
-- # { register

src/VectorNetworkProject/DataProvider/Tables/Dual/Dual.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
class Dual extends TableBase
1515
{
16-
public const INIT = 'userdataprovider.dual.init';
17-
public const REGISTER = 'userdataprovider.dual.register';
18-
public const UNREGISTER = 'userdataprovider.dual.unregister';
19-
public const GET = 'userdataprovider.dual.get';
20-
public const ADD_COUNT = 'userdataprovider.dual.addcount';
21-
public const GET_RANKING = 'userdataprovider.dual.getrankingbywin';
16+
public const INIT = 'userdataprovider.duel.init';
17+
public const REGISTER = 'userdataprovider.duel.register';
18+
public const UNREGISTER = 'userdataprovider.duel.unregister';
19+
public const GET = 'userdataprovider.duel.get';
20+
public const ADD_COUNT = 'userdataprovider.duel.addcount';
21+
public const GET_RANKING = 'userdataprovider.duel.getrankingbywin';
2222

2323
public function init(): void
2424
{

0 commit comments

Comments
 (0)