@zardoy/flying-squid 0.0.119 → 0.0.120

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,42 +46,6 @@ const server = function (serv, { version }) {
46
46
  setTimeout(() => { throw err; }, 0);
47
47
  }
48
48
  };
49
- serv.commands.add({
50
- base: 'title',
51
- info: 'show title',
52
- op: true,
53
- usage: '/title <targets> (title|subtitle|actionBar) <title>',
54
- parse(str) {
55
- const match = str.match(/([A-Za-z0-9]+( [A-Za-z0-9]+)+) ^(title|subtitle|actionBar)$ \{[^}]*\}/i);
56
- if (!match)
57
- return false;
58
- const players = str.split(/^(title|subtitle|actionBar)$/)[0];
59
- const level = str.match(/^(title|subtitle|actionBar)$/);
60
- const text = str.split(/^(title|subtitle|actionBar)$/)[-1];
61
- if (!players || !level || !text)
62
- return false;
63
- return { playersNamesAndTargetValues: players, level: level[0], text: text };
64
- },
65
- action(data, ctx) {
66
- const selectorString = ctx.player ? ctx.player.selectorString : serv.selectorString;
67
- const isPlayer = (entity) => entity.type === 'player';
68
- const players = selectorString(data.playersNamesAndTargetValues).filter(isPlayer);
69
- switch (data.level) {
70
- case 'title':
71
- serv._writeArray("Title", { "set_title_text": data.text }, players);
72
- break;
73
- case 'subtitle':
74
- serv._writeArray("Title", { "set_title_subtitle": data.text }, players);
75
- break;
76
- case 'actionBar':
77
- serv._writeArray("Title", { "action_bar": data.text }, players);
78
- break;
79
- default:
80
- return "Something went wrong. Try again.";
81
- }
82
- return "Title or action bar should appear";
83
- }
84
- });
85
49
  serv.commands.add({
86
50
  base: 'ping',
87
51
  info: 'to pong!',
@@ -263,10 +263,14 @@ const server = function (serv, { version }) {
263
263
  if (players.length < 1)
264
264
  throw new user_error_1.default('Player not found');
265
265
  const action = mode.toLowerCase();
266
- if (action === 'clear' || action === 'reset') {
266
+ if (action === 'clear') {
267
267
  players.forEach(player => serv.clearTitle(player));
268
268
  return 'Title cleared';
269
269
  }
270
+ if (action === 'reset') {
271
+ players.forEach(player => serv.resetTitle(player));
272
+ return 'Title reset';
273
+ }
270
274
  if (action === 'times') {
271
275
  const [fadeInRaw, stayRaw, fadeOutRaw] = rest.split(/\s+/);
272
276
  const fadeIn = parseInt(fadeInRaw, 10);
@@ -287,7 +291,7 @@ const server = function (serv, { version }) {
287
291
  players.forEach(player => serv.sendTitle(player, '', rest));
288
292
  return 'Subtitle sent';
289
293
  }
290
- if (action === 'actionbar' || action === 'actionBar') {
294
+ if (action === 'actionbar') {
291
295
  players.forEach(player => serv.sendActionBar(player, rest));
292
296
  return 'Action bar sent';
293
297
  }
@@ -5,5 +5,6 @@ declare global {
5
5
  setTitleTimes: (player: Player, fadeIn?: number, stay?: number, fadeOut?: number) => void;
6
6
  sendActionBar: (player: Player, message: string) => void;
7
7
  clearTitle: (player: Player) => void;
8
+ resetTitle: (player: Player) => void;
8
9
  }
9
10
  }
@@ -24,19 +24,21 @@ const server = function (serv, options) {
24
24
  });
25
25
  }
26
26
  else {
27
- // Pre-1.17 uses single title packet
27
+ player._client.write('title', {
28
+ action: 3,
29
+ fadeIn,
30
+ stay,
31
+ fadeOut
32
+ });
28
33
  if (title) {
29
34
  player._client.write('title', {
30
- action: 0, // Set title
31
- text: JSON.stringify({ text: title }),
32
- fadeIn,
33
- stay,
34
- fadeOut
35
+ action: 0,
36
+ text: JSON.stringify({ text: title })
35
37
  });
36
38
  }
37
39
  if (subtitle) {
38
40
  player._client.write('title', {
39
- action: 1, // Set subtitle
41
+ action: 1,
40
42
  text: JSON.stringify({ text: subtitle })
41
43
  });
42
44
  }
@@ -52,7 +54,7 @@ const server = function (serv, options) {
52
54
  }
53
55
  else {
54
56
  player._client.write('title', {
55
- action: 2, // Set times
57
+ action: 3,
56
58
  fadeIn,
57
59
  stay,
58
60
  fadeOut
@@ -75,6 +77,18 @@ const server = function (serv, options) {
75
77
  }
76
78
  };
77
79
  serv.clearTitle = (player) => {
80
+ if (supportsNewTitle) {
81
+ player._client.write('clear_titles', {
82
+ reset: false
83
+ });
84
+ }
85
+ else {
86
+ player._client.write('title', {
87
+ action: 4
88
+ });
89
+ }
90
+ };
91
+ serv.resetTitle = (player) => {
78
92
  if (supportsNewTitle) {
79
93
  player._client.write('clear_titles', {
80
94
  reset: true
@@ -82,7 +96,7 @@ const server = function (serv, options) {
82
96
  }
83
97
  else {
84
98
  player._client.write('title', {
85
- action: 4 // Clear
99
+ action: 5
86
100
  });
87
101
  }
88
102
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zardoy/flying-squid",
3
3
  "description": "A minecraft server written in TS",
4
- "version": "0.0.119",
4
+ "version": "0.0.120",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "bin": "dist/app.js",