@takaro/modules 0.0.1
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.
- package/README.md +3 -0
- package/dist/BuiltinModule.d.ts +49 -0
- package/dist/BuiltinModule.js +194 -0
- package/dist/BuiltinModule.js.map +1 -0
- package/dist/dto/base.d.ts +6 -0
- package/dist/dto/base.js +28 -0
- package/dist/dto/base.js.map +1 -0
- package/dist/dto/discordEvents.d.ts +31 -0
- package/dist/dto/discordEvents.js +92 -0
- package/dist/dto/discordEvents.js.map +1 -0
- package/dist/dto/gameEvents.d.ts +84 -0
- package/dist/dto/gameEvents.js +190 -0
- package/dist/dto/gameEvents.js.map +1 -0
- package/dist/dto/index.d.ts +37 -0
- package/dist/dto/index.js +18 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/takaroEvents.d.ts +150 -0
- package/dist/dto/takaroEvents.js +422 -0
- package/dist/dto/takaroEvents.js.map +1 -0
- package/dist/main.d.ts +4 -0
- package/dist/main.js +31 -0
- package/dist/main.js.map +1 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.js +18 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.js.map +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.js +14 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.js +9 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +9 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -0
- package/dist/modules/chatBridge/index.d.ts +4 -0
- package/dist/modules/chatBridge/index.js +54 -0
- package/dist/modules/chatBridge/index.js.map +1 -0
- package/dist/modules/economyUtils/commands/balance.d.ts +1 -0
- package/dist/modules/economyUtils/commands/balance.js +7 -0
- package/dist/modules/economyUtils/commands/balance.js.map +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.d.ts +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.js +38 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.js.map +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.js +31 -0
- package/dist/modules/economyUtils/commands/grantCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.js +31 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.js +22 -0
- package/dist/modules/economyUtils/commands/topCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/transfer.d.ts +1 -0
- package/dist/modules/economyUtils/commands/transfer.js +55 -0
- package/dist/modules/economyUtils/commands/transfer.js.map +1 -0
- package/dist/modules/economyUtils/index.d.ts +4 -0
- package/dist/modules/economyUtils/index.js +117 -0
- package/dist/modules/economyUtils/index.js.map +1 -0
- package/dist/modules/geoBlock/hooks/IPDetected.d.ts +1 -0
- package/dist/modules/geoBlock/hooks/IPDetected.js +50 -0
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -0
- package/dist/modules/geoBlock/index.d.ts +8 -0
- package/dist/modules/geoBlock/index.js +321 -0
- package/dist/modules/geoBlock/index.js.map +1 -0
- package/dist/modules/gimme/commands/gimme.d.ts +1 -0
- package/dist/modules/gimme/commands/gimme.js +23 -0
- package/dist/modules/gimme/commands/gimme.js.map +1 -0
- package/dist/modules/gimme/index.d.ts +4 -0
- package/dist/modules/gimme/index.js +43 -0
- package/dist/modules/gimme/index.js.map +1 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts +1 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.js +54 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.js.map +1 -0
- package/dist/modules/highPingKicker/index.d.ts +4 -0
- package/dist/modules/highPingKicker/index.js +34 -0
- package/dist/modules/highPingKicker/index.js.map +1 -0
- package/dist/modules/lottery/commands/buyTicket.d.ts +1 -0
- package/dist/modules/lottery/commands/buyTicket.js +54 -0
- package/dist/modules/lottery/commands/buyTicket.js.map +1 -0
- package/dist/modules/lottery/commands/nextDraw.d.ts +1 -0
- package/dist/modules/lottery/commands/nextDraw.js +34 -0
- package/dist/modules/lottery/commands/nextDraw.js.map +1 -0
- package/dist/modules/lottery/commands/viewTickets.d.ts +1 -0
- package/dist/modules/lottery/commands/viewTickets.js +23 -0
- package/dist/modules/lottery/commands/viewTickets.js.map +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.d.ts +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.js +96 -0
- package/dist/modules/lottery/cronJobs/drawLottery.js.map +1 -0
- package/dist/modules/lottery/index.d.ts +4 -0
- package/dist/modules/lottery/index.js +73 -0
- package/dist/modules/lottery/index.js.map +1 -0
- package/dist/modules/playerOnboarding/commands/starterkit.d.ts +1 -0
- package/dist/modules/playerOnboarding/commands/starterkit.js +34 -0
- package/dist/modules/playerOnboarding/commands/starterkit.js.map +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.js +11 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.js.map +1 -0
- package/dist/modules/playerOnboarding/index.d.ts +4 -0
- package/dist/modules/playerOnboarding/index.js +51 -0
- package/dist/modules/playerOnboarding/index.js.map +1 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.d.ts +1 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.js +9 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.js.map +1 -0
- package/dist/modules/serverMessages/index.d.ts +4 -0
- package/dist/modules/serverMessages/index.js +35 -0
- package/dist/modules/serverMessages/index.js.map +1 -0
- package/dist/modules/teleports/commands/deletetp.d.ts +1 -0
- package/dist/modules/teleports/commands/deletetp.js +20 -0
- package/dist/modules/teleports/commands/deletetp.js.map +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.js +54 -0
- package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/listwaypoints.d.ts +1 -0
- package/dist/modules/teleports/commands/listwaypoints.js +36 -0
- package/dist/modules/teleports/commands/listwaypoints.js.map +1 -0
- package/dist/modules/teleports/commands/setprivate.d.ts +1 -0
- package/dist/modules/teleports/commands/setprivate.js +31 -0
- package/dist/modules/teleports/commands/setprivate.js.map +1 -0
- package/dist/modules/teleports/commands/setpublic.d.ts +1 -0
- package/dist/modules/teleports/commands/setpublic.js +55 -0
- package/dist/modules/teleports/commands/setpublic.js.map +1 -0
- package/dist/modules/teleports/commands/settp.d.ts +1 -0
- package/dist/modules/teleports/commands/settp.js +42 -0
- package/dist/modules/teleports/commands/settp.js.map +1 -0
- package/dist/modules/teleports/commands/setwaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/setwaypoint.js +88 -0
- package/dist/modules/teleports/commands/setwaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/teleport.d.ts +1 -0
- package/dist/modules/teleports/commands/teleport.js +74 -0
- package/dist/modules/teleports/commands/teleport.js.map +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.js +50 -0
- package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/tplist.d.ts +1 -0
- package/dist/modules/teleports/commands/tplist.js +45 -0
- package/dist/modules/teleports/commands/tplist.js.map +1 -0
- package/dist/modules/teleports/functions/utils.d.ts +2 -0
- package/dist/modules/teleports/functions/utils.js +18 -0
- package/dist/modules/teleports/functions/utils.js.map +1 -0
- package/dist/modules/teleports/index.d.ts +4 -0
- package/dist/modules/teleports/index.js +184 -0
- package/dist/modules/teleports/index.js.map +1 -0
- package/dist/modules/utils/commands/help.d.ts +1 -0
- package/dist/modules/utils/commands/help.js +29 -0
- package/dist/modules/utils/commands/help.js.map +1 -0
- package/dist/modules/utils/commands/ping.d.ts +1 -0
- package/dist/modules/utils/commands/ping.js +6 -0
- package/dist/modules/utils/commands/ping.js.map +1 -0
- package/dist/modules/utils/index.d.ts +4 -0
- package/dist/modules/utils/index.js +35 -0
- package/dist/modules/utils/index.js.map +1 -0
- package/dist/modules.json +478 -0
- package/package.json +26 -0
- package/scripts/buildBuiltinJson.ts +14 -0
- package/src/BuiltinModule.ts +125 -0
- package/src/__tests__/aliases.integration.test.ts +54 -0
- package/src/__tests__/builtinmodule.unit.test.ts +13 -0
- package/src/__tests__/commandArgs.integration.test.ts +285 -0
- package/src/__tests__/economyUtils.integration.test.ts +488 -0
- package/src/__tests__/geoblock.integration.test.ts +380 -0
- package/src/__tests__/gimme.integration.test.ts +97 -0
- package/src/__tests__/help.integration.test.ts +133 -0
- package/src/__tests__/lottery.integration.test.ts +332 -0
- package/src/__tests__/modulePermission.integration.test.ts +192 -0
- package/src/__tests__/onboarding.integration.test.ts +123 -0
- package/src/__tests__/ping.integration.test.ts +36 -0
- package/src/__tests__/roleExpiry.integration.test.ts +74 -0
- package/src/__tests__/serverMessages.integration.test.ts +104 -0
- package/src/__tests__/systemConfigCost.integration.test.ts +196 -0
- package/src/__tests__/teleports/listtp.integration.test.ts +115 -0
- package/src/__tests__/teleports/publicteleports.integration.test.ts +350 -0
- package/src/__tests__/teleports/teleport.integration.test.ts +109 -0
- package/src/__tests__/teleports/tpManagement.integration.test.ts +175 -0
- package/src/__tests__/teleports/waypoints.integration.test.ts +613 -0
- package/src/dto/base.ts +13 -0
- package/src/dto/discordEvents.ts +69 -0
- package/src/dto/gameEvents.ts +154 -0
- package/src/dto/index.ts +25 -0
- package/src/dto/takaroEvents.ts +290 -0
- package/src/main.ts +36 -0
- package/src/modules/.eslintrc +5 -0
- package/src/modules/chatBridge/hooks/DiscordToGame.js +18 -0
- package/src/modules/chatBridge/hooks/GameToDiscord.js +18 -0
- package/src/modules/chatBridge/hooks/PlayerConnected.js +11 -0
- package/src/modules/chatBridge/hooks/PlayerDisconnected.js +11 -0
- package/src/modules/chatBridge/index.ts +59 -0
- package/src/modules/economyUtils/commands/balance.js +8 -0
- package/src/modules/economyUtils/commands/confirmTransfer.js +55 -0
- package/src/modules/economyUtils/commands/grantCurrency.js +38 -0
- package/src/modules/economyUtils/commands/revokeCurrency.js +38 -0
- package/src/modules/economyUtils/commands/topCurrency.js +29 -0
- package/src/modules/economyUtils/commands/transfer.js +73 -0
- package/src/modules/economyUtils/index.ts +125 -0
- package/src/modules/geoBlock/hooks/IPDetected.js +52 -0
- package/src/modules/geoBlock/index.ts +331 -0
- package/src/modules/gimme/commands/gimme.js +28 -0
- package/src/modules/gimme/index.ts +49 -0
- package/src/modules/highPingKicker/cronJobs/Ping check.js +66 -0
- package/src/modules/highPingKicker/index.ts +39 -0
- package/src/modules/lottery/commands/buyTicket.js +68 -0
- package/src/modules/lottery/commands/nextDraw.js +45 -0
- package/src/modules/lottery/commands/viewTickets.js +32 -0
- package/src/modules/lottery/cronJobs/drawLottery.js +124 -0
- package/src/modules/lottery/index.ts +80 -0
- package/src/modules/playerOnboarding/commands/starterkit.js +47 -0
- package/src/modules/playerOnboarding/hooks/playerConnected.js +14 -0
- package/src/modules/playerOnboarding/index.ts +58 -0
- package/src/modules/serverMessages/cronJobs/Automated message.js +12 -0
- package/src/modules/serverMessages/index.ts +40 -0
- package/src/modules/teleports/commands/deletetp.js +25 -0
- package/src/modules/teleports/commands/deletewaypoint.js +77 -0
- package/src/modules/teleports/commands/listwaypoints.js +55 -0
- package/src/modules/teleports/commands/setprivate.js +39 -0
- package/src/modules/teleports/commands/setpublic.js +71 -0
- package/src/modules/teleports/commands/settp.js +54 -0
- package/src/modules/teleports/commands/setwaypoint.js +112 -0
- package/src/modules/teleports/commands/teleport.js +93 -0
- package/src/modules/teleports/commands/teleportwaypoint.js +72 -0
- package/src/modules/teleports/commands/tplist.js +61 -0
- package/src/modules/teleports/functions/utils.js +20 -0
- package/src/modules/teleports/index.ts +193 -0
- package/src/modules/utils/commands/help.js +38 -0
- package/src/modules/utils/commands/ping.js +7 -0
- package/src/modules/utils/index.ts +40 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +9 -0
- package/typedoc.json +3 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { BuiltinModule, IHook, IPermission } from '../../BuiltinModule.js';
|
|
2
|
+
import { HookEvents } from '../../dto/index.js';
|
|
3
|
+
import { Duration } from 'luxon';
|
|
4
|
+
|
|
5
|
+
// temporary solution
|
|
6
|
+
export const countryCodes = [
|
|
7
|
+
{ code: 'AF', name: 'Afghanistan' },
|
|
8
|
+
{ code: 'AX', name: 'Aland Islands' },
|
|
9
|
+
{ code: 'AL', name: 'Albania' },
|
|
10
|
+
{ code: 'DZ', name: 'Algeria' },
|
|
11
|
+
{ code: 'AS', name: 'American Samoa' },
|
|
12
|
+
{ code: 'AD', name: 'Andorra' },
|
|
13
|
+
{ code: 'AO', name: 'Angola' },
|
|
14
|
+
{ code: 'AI', name: 'Anguilla' },
|
|
15
|
+
{ code: 'AQ', name: 'Antarctica' },
|
|
16
|
+
{ code: 'AG', name: 'Antigua And Barbuda' },
|
|
17
|
+
{ code: 'AR', name: 'Argentina' },
|
|
18
|
+
{ code: 'AM', name: 'Armenia' },
|
|
19
|
+
{ code: 'AW', name: 'Aruba' },
|
|
20
|
+
{ code: 'AU', name: 'Australia' },
|
|
21
|
+
{ code: 'AT', name: 'Austria' },
|
|
22
|
+
{ code: 'AZ', name: 'Azerbaijan' },
|
|
23
|
+
{ code: 'BS', name: 'Bahamas' },
|
|
24
|
+
{ code: 'BH', name: 'Bahrain' },
|
|
25
|
+
{ code: 'BD', name: 'Bangladesh' },
|
|
26
|
+
{ code: 'BB', name: 'Barbados' },
|
|
27
|
+
{ code: 'BY', name: 'Belarus' },
|
|
28
|
+
{ code: 'BE', name: 'Belgium' },
|
|
29
|
+
{ code: 'BZ', name: 'Belize' },
|
|
30
|
+
{ code: 'BJ', name: 'Benin' },
|
|
31
|
+
{ code: 'BM', name: 'Bermuda' },
|
|
32
|
+
{ code: 'BT', name: 'Bhutan' },
|
|
33
|
+
{ code: 'BO', name: 'Bolivia' },
|
|
34
|
+
{ code: 'BA', name: 'Bosnia And Herzegovina' },
|
|
35
|
+
{ code: 'BW', name: 'Botswana' },
|
|
36
|
+
{ code: 'BV', name: 'Bouvet Island' },
|
|
37
|
+
{ code: 'BR', name: 'Brazil' },
|
|
38
|
+
{ code: 'IO', name: 'British Indian Ocean Territory' },
|
|
39
|
+
{ code: 'BN', name: 'Brunei Darussalam' },
|
|
40
|
+
{ code: 'BG', name: 'Bulgaria' },
|
|
41
|
+
{ code: 'BF', name: 'Burkina Faso' },
|
|
42
|
+
{ code: 'BI', name: 'Burundi' },
|
|
43
|
+
{ code: 'KH', name: 'Cambodia' },
|
|
44
|
+
{ code: 'CM', name: 'Cameroon' },
|
|
45
|
+
{ code: 'CA', name: 'Canada' },
|
|
46
|
+
{ code: 'CV', name: 'Cape Verde' },
|
|
47
|
+
{ code: 'KY', name: 'Cayman Islands' },
|
|
48
|
+
{ code: 'CF', name: 'Central African Republic' },
|
|
49
|
+
{ code: 'TD', name: 'Chad' },
|
|
50
|
+
{ code: 'CL', name: 'Chile' },
|
|
51
|
+
{ code: 'CN', name: 'China' },
|
|
52
|
+
{ code: 'CX', name: 'Christmas Island' },
|
|
53
|
+
{ code: 'CC', name: 'Cocos (Keeling) Islands' },
|
|
54
|
+
{ code: 'CO', name: 'Colombia' },
|
|
55
|
+
{ code: 'KM', name: 'Comoros' },
|
|
56
|
+
{ code: 'CG', name: 'Congo' },
|
|
57
|
+
{ code: 'CD', name: 'Congo, Democratic Republic' },
|
|
58
|
+
{ code: 'CK', name: 'Cook Islands' },
|
|
59
|
+
{ code: 'CR', name: 'Costa Rica' },
|
|
60
|
+
// eslint-disable-next-line quotes
|
|
61
|
+
{ code: 'CI', name: "Cote D'Ivoire" },
|
|
62
|
+
{ code: 'HR', name: 'Croatia' },
|
|
63
|
+
{ code: 'CU', name: 'Cuba' },
|
|
64
|
+
{ code: 'CY', name: 'Cyprus' },
|
|
65
|
+
{ code: 'CZ', name: 'Czech Republic' },
|
|
66
|
+
{ code: 'DK', name: 'Denmark' },
|
|
67
|
+
{ code: 'DJ', name: 'Djibouti' },
|
|
68
|
+
{ code: 'DM', name: 'Dominica' },
|
|
69
|
+
{ code: 'DO', name: 'Dominican Republic' },
|
|
70
|
+
{ code: 'EC', name: 'Ecuador' },
|
|
71
|
+
{ code: 'EG', name: 'Egypt' },
|
|
72
|
+
{ code: 'SV', name: 'El Salvador' },
|
|
73
|
+
{ code: 'GQ', name: 'Equatorial Guinea' },
|
|
74
|
+
{ code: 'ER', name: 'Eritrea' },
|
|
75
|
+
{ code: 'EE', name: 'Estonia' },
|
|
76
|
+
{ code: 'ET', name: 'Ethiopia' },
|
|
77
|
+
{ code: 'FK', name: 'Falkland Islands (Malvinas)' },
|
|
78
|
+
{ code: 'FO', name: 'Faroe Islands' },
|
|
79
|
+
{ code: 'FJ', name: 'Fiji' },
|
|
80
|
+
{ code: 'FI', name: 'Finland' },
|
|
81
|
+
{ code: 'FR', name: 'France' },
|
|
82
|
+
{ code: 'GF', name: 'French Guiana' },
|
|
83
|
+
{ code: 'PF', name: 'French Polynesia' },
|
|
84
|
+
{ code: 'TF', name: 'French Southern Territories' },
|
|
85
|
+
{ code: 'GA', name: 'Gabon' },
|
|
86
|
+
{ code: 'GM', name: 'Gambia' },
|
|
87
|
+
{ code: 'GE', name: 'Georgia' },
|
|
88
|
+
{ code: 'DE', name: 'Germany' },
|
|
89
|
+
{ code: 'GH', name: 'Ghana' },
|
|
90
|
+
{ code: 'GI', name: 'Gibraltar' },
|
|
91
|
+
{ code: 'GR', name: 'Greece' },
|
|
92
|
+
{ code: 'GL', name: 'Greenland' },
|
|
93
|
+
{ code: 'GD', name: 'Grenada' },
|
|
94
|
+
{ code: 'GP', name: 'Guadeloupe' },
|
|
95
|
+
{ code: 'GU', name: 'Guam' },
|
|
96
|
+
{ code: 'GT', name: 'Guatemala' },
|
|
97
|
+
{ code: 'GG', name: 'Guernsey' },
|
|
98
|
+
{ code: 'GN', name: 'Guinea' },
|
|
99
|
+
{ code: 'GW', name: 'Guinea-Bissau' },
|
|
100
|
+
{ code: 'GY', name: 'Guyana' },
|
|
101
|
+
{ code: 'HT', name: 'Haiti' },
|
|
102
|
+
// { code: 'HM', name: 'Heard Island & Mcdonald Islands' },
|
|
103
|
+
{ code: 'VA', name: 'Holy See (Vatican City State)' },
|
|
104
|
+
{ code: 'HN', name: 'Honduras' },
|
|
105
|
+
{ code: 'HK', name: 'Hong Kong' },
|
|
106
|
+
{ code: 'HU', name: 'Hungary' },
|
|
107
|
+
{ code: 'IS', name: 'Iceland' },
|
|
108
|
+
{ code: 'IN', name: 'India' },
|
|
109
|
+
{ code: 'ID', name: 'Indonesia' },
|
|
110
|
+
{ code: 'IR', name: 'Iran, Islamic Republic Of' },
|
|
111
|
+
{ code: 'IQ', name: 'Iraq' },
|
|
112
|
+
{ code: 'IE', name: 'Ireland' },
|
|
113
|
+
{ code: 'IM', name: 'Isle Of Man' },
|
|
114
|
+
{ code: 'IL', name: 'Israel' },
|
|
115
|
+
{ code: 'IT', name: 'Italy' },
|
|
116
|
+
{ code: 'JM', name: 'Jamaica' },
|
|
117
|
+
{ code: 'JP', name: 'Japan' },
|
|
118
|
+
{ code: 'JE', name: 'Jersey' },
|
|
119
|
+
{ code: 'JO', name: 'Jordan' },
|
|
120
|
+
{ code: 'KZ', name: 'Kazakhstan' },
|
|
121
|
+
{ code: 'KE', name: 'Kenya' },
|
|
122
|
+
{ code: 'KI', name: 'Kiribati' },
|
|
123
|
+
{ code: 'KR', name: 'Korea' },
|
|
124
|
+
{ code: 'KW', name: 'Kuwait' },
|
|
125
|
+
{ code: 'KG', name: 'Kyrgyzstan' },
|
|
126
|
+
// eslint-disable-next-line quotes
|
|
127
|
+
{ code: 'LA', name: "Lao People's Democratic Republic" },
|
|
128
|
+
{ code: 'LV', name: 'Latvia' },
|
|
129
|
+
{ code: 'LB', name: 'Lebanon' },
|
|
130
|
+
{ code: 'LS', name: 'Lesotho' },
|
|
131
|
+
{ code: 'LR', name: 'Liberia' },
|
|
132
|
+
{ code: 'LY', name: 'Libyan Arab Jamahiriya' },
|
|
133
|
+
{ code: 'LI', name: 'Liechtenstein' },
|
|
134
|
+
{ code: 'LT', name: 'Lithuania' },
|
|
135
|
+
{ code: 'LU', name: 'Luxembourg' },
|
|
136
|
+
{ code: 'MO', name: 'Macao' },
|
|
137
|
+
{ code: 'MK', name: 'Macedonia' },
|
|
138
|
+
{ code: 'MG', name: 'Madagascar' },
|
|
139
|
+
{ code: 'MW', name: 'Malawi' },
|
|
140
|
+
{ code: 'MY', name: 'Malaysia' },
|
|
141
|
+
{ code: 'MV', name: 'Maldives' },
|
|
142
|
+
{ code: 'ML', name: 'Mali' },
|
|
143
|
+
{ code: 'MT', name: 'Malta' },
|
|
144
|
+
{ code: 'MH', name: 'Marshall Islands' },
|
|
145
|
+
{ code: 'MQ', name: 'Martinique' },
|
|
146
|
+
{ code: 'MR', name: 'Mauritania' },
|
|
147
|
+
{ code: 'MU', name: 'Mauritius' },
|
|
148
|
+
{ code: 'YT', name: 'Mayotte' },
|
|
149
|
+
{ code: 'MX', name: 'Mexico' },
|
|
150
|
+
{ code: 'FM', name: 'Micronesia, Federated States Of' },
|
|
151
|
+
{ code: 'MD', name: 'Moldova' },
|
|
152
|
+
{ code: 'MC', name: 'Monaco' },
|
|
153
|
+
{ code: 'MN', name: 'Mongolia' },
|
|
154
|
+
{ code: 'ME', name: 'Montenegro' },
|
|
155
|
+
{ code: 'MS', name: 'Montserrat' },
|
|
156
|
+
{ code: 'MA', name: 'Morocco' },
|
|
157
|
+
{ code: 'MZ', name: 'Mozambique' },
|
|
158
|
+
{ code: 'MM', name: 'Myanmar' },
|
|
159
|
+
{ code: 'NA', name: 'Namibia' },
|
|
160
|
+
{ code: 'NR', name: 'Nauru' },
|
|
161
|
+
{ code: 'NP', name: 'Nepal' },
|
|
162
|
+
{ code: 'NL', name: 'Netherlands' },
|
|
163
|
+
{ code: 'NC', name: 'New Caledonia' },
|
|
164
|
+
{ code: 'NZ', name: 'New Zealand' },
|
|
165
|
+
{ code: 'NI', name: 'Nicaragua' },
|
|
166
|
+
{ code: 'NE', name: 'Niger' },
|
|
167
|
+
{ code: 'NG', name: 'Nigeria' },
|
|
168
|
+
{ code: 'NU', name: 'Niue' },
|
|
169
|
+
{ code: 'NF', name: 'Norfolk Island' },
|
|
170
|
+
{ code: 'MP', name: 'Northern Mariana Islands' },
|
|
171
|
+
{ code: 'NO', name: 'Norway' },
|
|
172
|
+
{ code: 'OM', name: 'Oman' },
|
|
173
|
+
{ code: 'PK', name: 'Pakistan' },
|
|
174
|
+
{ code: 'PW', name: 'Palau' },
|
|
175
|
+
{ code: 'PS', name: 'Palestinian Territory, Occupied' },
|
|
176
|
+
{ code: 'PA', name: 'Panama' },
|
|
177
|
+
{ code: 'PG', name: 'Papua New Guinea' },
|
|
178
|
+
{ code: 'PY', name: 'Paraguay' },
|
|
179
|
+
{ code: 'PE', name: 'Peru' },
|
|
180
|
+
{ code: 'PH', name: 'Philippines' },
|
|
181
|
+
{ code: 'PN', name: 'Pitcairn' },
|
|
182
|
+
{ code: 'PL', name: 'Poland' },
|
|
183
|
+
{ code: 'PT', name: 'Portugal' },
|
|
184
|
+
{ code: 'PR', name: 'Puerto Rico' },
|
|
185
|
+
{ code: 'QA', name: 'Qatar' },
|
|
186
|
+
{ code: 'RE', name: 'Reunion' },
|
|
187
|
+
{ code: 'RO', name: 'Romania' },
|
|
188
|
+
{ code: 'RU', name: 'Russian Federation' },
|
|
189
|
+
{ code: 'RW', name: 'Rwanda' },
|
|
190
|
+
{ code: 'BL', name: 'Saint Barthelemy' },
|
|
191
|
+
{ code: 'SH', name: 'Saint Helena' },
|
|
192
|
+
{ code: 'KN', name: 'Saint Kitts And Nevis' },
|
|
193
|
+
{ code: 'LC', name: 'Saint Lucia' },
|
|
194
|
+
{ code: 'MF', name: 'Saint Martin' },
|
|
195
|
+
{ code: 'PM', name: 'Saint Pierre And Miquelon' },
|
|
196
|
+
{ code: 'VC', name: 'Saint Vincent And Grenadines' },
|
|
197
|
+
{ code: 'WS', name: 'Samoa' },
|
|
198
|
+
{ code: 'SM', name: 'San Marino' },
|
|
199
|
+
{ code: 'ST', name: 'Sao Tome And Principe' },
|
|
200
|
+
{ code: 'SA', name: 'Saudi Arabia' },
|
|
201
|
+
{ code: 'SN', name: 'Senegal' },
|
|
202
|
+
{ code: 'RS', name: 'Serbia' },
|
|
203
|
+
{ code: 'SC', name: 'Seychelles' },
|
|
204
|
+
{ code: 'SL', name: 'Sierra Leone' },
|
|
205
|
+
{ code: 'SG', name: 'Singapore' },
|
|
206
|
+
{ code: 'SK', name: 'Slovakia' },
|
|
207
|
+
{ code: 'SI', name: 'Slovenia' },
|
|
208
|
+
{ code: 'SB', name: 'Solomon Islands' },
|
|
209
|
+
{ code: 'SO', name: 'Somalia' },
|
|
210
|
+
{ code: 'ZA', name: 'South Africa' },
|
|
211
|
+
// { code: 'GS', name: 'South Georgia And Sandwich Isl.' },
|
|
212
|
+
{ code: 'ES', name: 'Spain' },
|
|
213
|
+
{ code: 'LK', name: 'Sri Lanka' },
|
|
214
|
+
{ code: 'SD', name: 'Sudan' },
|
|
215
|
+
{ code: 'SR', name: 'Suriname' },
|
|
216
|
+
// { code: 'SJ', name: 'Svalbard And Jan Mayen' },
|
|
217
|
+
{ code: 'SZ', name: 'Swaziland' },
|
|
218
|
+
{ code: 'SE', name: 'Sweden' },
|
|
219
|
+
{ code: 'CH', name: 'Switzerland' },
|
|
220
|
+
{ code: 'SY', name: 'Syrian Arab Republic' },
|
|
221
|
+
{ code: 'TW', name: 'Taiwan' },
|
|
222
|
+
{ code: 'TJ', name: 'Tajikistan' },
|
|
223
|
+
{ code: 'TZ', name: 'Tanzania' },
|
|
224
|
+
{ code: 'TH', name: 'Thailand' },
|
|
225
|
+
{ code: 'TL', name: 'Timor-Leste' },
|
|
226
|
+
{ code: 'TG', name: 'Togo' },
|
|
227
|
+
{ code: 'TK', name: 'Tokelau' },
|
|
228
|
+
{ code: 'TO', name: 'Tonga' },
|
|
229
|
+
{ code: 'TT', name: 'Trinidad And Tobago' },
|
|
230
|
+
{ code: 'TN', name: 'Tunisia' },
|
|
231
|
+
{ code: 'TR', name: 'Turkey' },
|
|
232
|
+
{ code: 'TM', name: 'Turkmenistan' },
|
|
233
|
+
// { code: 'TC', name: 'Turks And Caicos Islands' },
|
|
234
|
+
{ code: 'TV', name: 'Tuvalu' },
|
|
235
|
+
{ code: 'UG', name: 'Uganda' },
|
|
236
|
+
{ code: 'UA', name: 'Ukraine' },
|
|
237
|
+
{ code: 'AE', name: 'United Arab Emirates' },
|
|
238
|
+
{ code: 'GB', name: 'United Kingdom' },
|
|
239
|
+
{ code: 'US', name: 'United States' },
|
|
240
|
+
// { code: 'UM', name: 'United States Outlying Islands' },
|
|
241
|
+
{ code: 'UY', name: 'Uruguay' },
|
|
242
|
+
{ code: 'UZ', name: 'Uzbekistan' },
|
|
243
|
+
{ code: 'VU', name: 'Vanuatu' },
|
|
244
|
+
{ code: 'VE', name: 'Venezuela' },
|
|
245
|
+
{ code: 'VN', name: 'Vietnam' },
|
|
246
|
+
// { code: 'VG', name: 'Virgin Islands, British' },
|
|
247
|
+
// { code: 'VI', name: 'Virgin Islands, U.S.' },
|
|
248
|
+
// { code: 'WF', name: 'Wallis And Futuna' },
|
|
249
|
+
{ code: 'EH', name: 'Western Sahara' },
|
|
250
|
+
{ code: 'YE', name: 'Yemen' },
|
|
251
|
+
{ code: 'ZM', name: 'Zambia' },
|
|
252
|
+
{ code: 'ZW', name: 'Zimbabwe' },
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
export class GeoBlock extends BuiltinModule<GeoBlock> {
|
|
256
|
+
constructor() {
|
|
257
|
+
super(
|
|
258
|
+
'geoBlock',
|
|
259
|
+
'Block players from certain countries from joining the server.',
|
|
260
|
+
JSON.stringify({
|
|
261
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
262
|
+
type: 'object',
|
|
263
|
+
properties: {
|
|
264
|
+
mode: {
|
|
265
|
+
title: 'Mode',
|
|
266
|
+
type: 'string',
|
|
267
|
+
description:
|
|
268
|
+
'If set to allow, only players from the specified countries will be allowed to join. If set to deny, players from the specified countries will be banned from the server.',
|
|
269
|
+
enum: ['allow', 'deny'],
|
|
270
|
+
default: 'deny',
|
|
271
|
+
},
|
|
272
|
+
countries: {
|
|
273
|
+
title: 'Countries',
|
|
274
|
+
description: 'List of country',
|
|
275
|
+
type: 'array',
|
|
276
|
+
uniqueItems: true,
|
|
277
|
+
'x-component': 'country',
|
|
278
|
+
items: {
|
|
279
|
+
type: 'string',
|
|
280
|
+
anyOf: countryCodes.map(({ code, name }) => ({ const: code, title: name })),
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
ban: {
|
|
284
|
+
title: 'Ban',
|
|
285
|
+
description:
|
|
286
|
+
'Ban players from the server when they are detected. When false, players will be kicked instead.',
|
|
287
|
+
type: 'boolean',
|
|
288
|
+
default: true,
|
|
289
|
+
},
|
|
290
|
+
banDuration: {
|
|
291
|
+
title: 'Ban duration',
|
|
292
|
+
description: 'Duration of the ban.',
|
|
293
|
+
'x-component': 'duration',
|
|
294
|
+
type: 'number',
|
|
295
|
+
minimum: 0,
|
|
296
|
+
default: Duration.fromObject({ days: 1 }).as('milliseconds'),
|
|
297
|
+
},
|
|
298
|
+
message: {
|
|
299
|
+
title: 'Message',
|
|
300
|
+
type: 'string',
|
|
301
|
+
description: 'Message to send to the player when they are kicked or banned.',
|
|
302
|
+
default: 'Your IP address is banned.',
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
required: ['countries'],
|
|
306
|
+
additionalProperties: false,
|
|
307
|
+
}),
|
|
308
|
+
JSON.stringify({
|
|
309
|
+
banDuration: { 'ui:widget': 'duration' },
|
|
310
|
+
})
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
this.permissions = [
|
|
314
|
+
new IPermission({
|
|
315
|
+
permission: 'GEOBLOCK_IMMUNITY',
|
|
316
|
+
friendlyName: 'GeoBlock immunity',
|
|
317
|
+
description: 'Players with this permission will not be kicked or banned by GeoBlock.',
|
|
318
|
+
canHaveCount: false,
|
|
319
|
+
}),
|
|
320
|
+
];
|
|
321
|
+
|
|
322
|
+
this.commands = [];
|
|
323
|
+
this.hooks = [
|
|
324
|
+
new IHook({
|
|
325
|
+
eventType: HookEvents.PLAYER_NEW_IP_DETECTED,
|
|
326
|
+
name: 'IPDetected',
|
|
327
|
+
function: this.loadFn('hooks', 'IPDetected'),
|
|
328
|
+
}),
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { takaro, data, TakaroUserError } from '@takaro/helpers';
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
const items = data.module.userConfig.items;
|
|
5
|
+
const commands = data.module.userConfig.commands;
|
|
6
|
+
|
|
7
|
+
if (items.length + commands.length === 0) {
|
|
8
|
+
throw new TakaroUserError(
|
|
9
|
+
'No items or commands configured, please ask your server administrator to configure this module.'
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// pick a random item between 0 and the length of both the items and commands arrays
|
|
14
|
+
const randomIndex = Math.floor(Math.random() * (items.length + commands.length));
|
|
15
|
+
const randomOption = items.concat(commands)[randomIndex];
|
|
16
|
+
|
|
17
|
+
if (randomIndex < items.length) {
|
|
18
|
+
await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
|
|
19
|
+
name: randomOption,
|
|
20
|
+
amount: 1,
|
|
21
|
+
});
|
|
22
|
+
await data.player.pm(`You received ${randomOption}!`);
|
|
23
|
+
} else {
|
|
24
|
+
await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: randomOption });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await main();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BuiltinModule, ICommand } from '../../BuiltinModule.js';
|
|
2
|
+
|
|
3
|
+
export class Gimme extends BuiltinModule<Gimme> {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(
|
|
6
|
+
'gimme',
|
|
7
|
+
'Randomly selects an item from a list of items.',
|
|
8
|
+
JSON.stringify({
|
|
9
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
items: {
|
|
13
|
+
'x-component': 'item',
|
|
14
|
+
type: 'array',
|
|
15
|
+
title: 'Items',
|
|
16
|
+
description: 'List of items that a player can receive.',
|
|
17
|
+
uniqueItems: true,
|
|
18
|
+
items: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
commands: {
|
|
23
|
+
title: 'Commands',
|
|
24
|
+
type: 'array',
|
|
25
|
+
default: ['say hello from gimme'],
|
|
26
|
+
items: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ['items'],
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
}),
|
|
34
|
+
JSON.stringify({
|
|
35
|
+
items: { 'ui:widget': 'item' },
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
this.commands = [
|
|
40
|
+
new ICommand({
|
|
41
|
+
function: this.loadFn('commands', 'gimme'),
|
|
42
|
+
name: 'gimme',
|
|
43
|
+
trigger: 'gimme',
|
|
44
|
+
helpText: 'Randomly selects item from a list of items and entities.',
|
|
45
|
+
arguments: [],
|
|
46
|
+
}),
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { takaro, data } from '@takaro/helpers';
|
|
2
|
+
|
|
3
|
+
const VARIABLE_KEY = 'highPingKicker:warnings';
|
|
4
|
+
|
|
5
|
+
async function main() {
|
|
6
|
+
const currentPlayers = await takaro.gameserver.gameServerControllerGetPlayers(data.gameServerId);
|
|
7
|
+
|
|
8
|
+
await Promise.all(
|
|
9
|
+
currentPlayers.data.data.map(async (player) => {
|
|
10
|
+
if (player.ping > data.module.userConfig.pingThreshold) {
|
|
11
|
+
const takaroPlayerRes = await takaro.player.playerControllerSearch({
|
|
12
|
+
filters: {
|
|
13
|
+
steamId: player.steamId,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const takaroPlayer = takaroPlayerRes.data.data[0];
|
|
18
|
+
|
|
19
|
+
const currentWarningsRes = await takaro.variable.variableControllerFind({
|
|
20
|
+
filters: {
|
|
21
|
+
playerId: takaroPlayer.id,
|
|
22
|
+
key: VARIABLE_KEY,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const currentWarningsRecords = currentWarningsRes.data.data;
|
|
27
|
+
|
|
28
|
+
let currentWarnings = 1;
|
|
29
|
+
if (!currentWarningsRecords.length) {
|
|
30
|
+
await takaro.variable.variableControllerCreate({
|
|
31
|
+
playerId: takaroPlayer.id,
|
|
32
|
+
key: VARIABLE_KEY,
|
|
33
|
+
value: '1',
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
currentWarnings = parseInt(currentWarningsRecords[0].value, 10);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (currentWarningsRecords.length === 1) {
|
|
40
|
+
await takaro.variable.variableControllerUpdate(currentWarningsRecords[0].id, {
|
|
41
|
+
value: (currentWarnings + 1).toString(),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {
|
|
45
|
+
message: `Your ping (${player.ping}) is too high. Warning ${currentWarnings}/${data.module.userConfig.warningsBeforeKick}`,
|
|
46
|
+
opts: {
|
|
47
|
+
recipient: {
|
|
48
|
+
gameId: player.gameId,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (currentWarnings >= data.module.userConfig.warningsBeforeKick) {
|
|
55
|
+
await takaro.gameserver.gameServerControllerKickPlayer(data.gameServerId, takaroPlayer.id, {
|
|
56
|
+
reason: `Your ping (${player.ping}) is too high, please try again later.`,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
await takaro.variable.variableControllerDelete(currentWarningsRecords[0].id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
await main();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BuiltinModule, ICronJob } from '../../BuiltinModule.js';
|
|
2
|
+
|
|
3
|
+
export class HighPingKicker extends BuiltinModule<HighPingKicker> {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(
|
|
6
|
+
'highPingKicker',
|
|
7
|
+
'Automatically kick players with high ping, with warnings and configurable thresholds.',
|
|
8
|
+
JSON.stringify({
|
|
9
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
pingThreshold: {
|
|
13
|
+
type: 'number',
|
|
14
|
+
title: 'Ping threshold',
|
|
15
|
+
description: 'A ping value that is deemed too high and prompts a warning.',
|
|
16
|
+
default: 200,
|
|
17
|
+
minimum: 0,
|
|
18
|
+
},
|
|
19
|
+
warningsBeforeKick: {
|
|
20
|
+
type: 'number',
|
|
21
|
+
title: 'Kick warnings',
|
|
22
|
+
description: 'Number of warnings before a player is kicked.',
|
|
23
|
+
default: 3,
|
|
24
|
+
minimum: 0,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: [],
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
this.cronJobs = [
|
|
32
|
+
new ICronJob({
|
|
33
|
+
name: 'Ping check',
|
|
34
|
+
temporalValue: '*/5 * * * *',
|
|
35
|
+
function: this.loadFn('cronJobs', 'Ping check'),
|
|
36
|
+
}),
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
const { pog, gameServerId, arguments: args, module: mod } = data;
|
|
5
|
+
|
|
6
|
+
const varKey = 'lottery_tickets_bought';
|
|
7
|
+
|
|
8
|
+
if (!checkPermission(pog, 'LOTTERY_BUY')) {
|
|
9
|
+
throw new TakaroUserError('You do not have permission to buy lottery tickets.');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (args.amount < 1) {
|
|
13
|
+
throw new TakaroUserError('You must buy at least 1 ticket.');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const tickets = (
|
|
17
|
+
await takaro.variable.variableControllerSearch({
|
|
18
|
+
filters: {
|
|
19
|
+
gameServerId: [gameServerId],
|
|
20
|
+
key: [varKey],
|
|
21
|
+
moduleId: [mod.moduleId],
|
|
22
|
+
playerId: [pog.playerId],
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
).data.data;
|
|
26
|
+
|
|
27
|
+
// Player already has some tickets bought
|
|
28
|
+
if (tickets.length > 0) {
|
|
29
|
+
const ticketsBought = tickets[0];
|
|
30
|
+
|
|
31
|
+
const ticketsBoughtAmount = parseInt(JSON.parse(ticketsBought.value).amount, 10);
|
|
32
|
+
|
|
33
|
+
await takaro.variable.variableControllerUpdate(ticketsBought.id, {
|
|
34
|
+
key: varKey,
|
|
35
|
+
playerId: pog.playerId,
|
|
36
|
+
moduleId: mod.moduleId,
|
|
37
|
+
gameServerId,
|
|
38
|
+
value: JSON.stringify({ amount: ticketsBoughtAmount + args.amount }),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
// Player has no tickets bought
|
|
42
|
+
else {
|
|
43
|
+
await takaro.variable.variableControllerCreate({
|
|
44
|
+
key: varKey,
|
|
45
|
+
value: JSON.stringify({
|
|
46
|
+
amount: args.amount,
|
|
47
|
+
}),
|
|
48
|
+
gameServerId,
|
|
49
|
+
moduleId: mod.moduleId,
|
|
50
|
+
playerId: pog.playerId,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const ticketPrice = args.amount * mod.systemConfig.commands.buyTicket.cost;
|
|
55
|
+
|
|
56
|
+
// The price of the first ticket is deducted by the command execution itself.
|
|
57
|
+
if (args.amount > 1) {
|
|
58
|
+
await takaro.playerOnGameserver.playerOnGameServerControllerDeductCurrency(gameServerId, pog.playerId, {
|
|
59
|
+
currency: ticketPrice - 1,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;
|
|
64
|
+
|
|
65
|
+
await pog.pm(`You have successfully bought ${args.amount} tickets for ${ticketPrice} ${currencyName}. Good luck!`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
await main();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { nextCronJobRun, data } from '@takaro/helpers';
|
|
2
|
+
|
|
3
|
+
function formatTimeToReach(cronJob) {
|
|
4
|
+
const targetDate = nextCronJobRun(cronJob);
|
|
5
|
+
|
|
6
|
+
// Get the current date and time
|
|
7
|
+
const currentDate = new Date();
|
|
8
|
+
|
|
9
|
+
// Calculate the time difference in milliseconds
|
|
10
|
+
const delta = targetDate - currentDate;
|
|
11
|
+
|
|
12
|
+
// Calculate days, hours, minutes, and seconds
|
|
13
|
+
const days = Math.floor(delta / (1000 * 60 * 60 * 24));
|
|
14
|
+
const hours = Math.floor((delta % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
15
|
+
const minutes = Math.floor((delta % (1000 * 60 * 60)) / (1000 * 60));
|
|
16
|
+
const seconds = Math.floor((delta % (1000 * 60)) / 1000);
|
|
17
|
+
|
|
18
|
+
// Build the formatted string
|
|
19
|
+
let formattedString = '';
|
|
20
|
+
|
|
21
|
+
if (days > 0) {
|
|
22
|
+
formattedString += `${days} day${days > 1 ? 's' : ''} `;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (hours > 0) {
|
|
26
|
+
formattedString += `${hours} hour${hours > 1 ? 's' : ''} `;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (minutes > 0) {
|
|
30
|
+
formattedString += `${minutes} minute${minutes > 1 ? 's' : ''} `;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (seconds > 0) {
|
|
34
|
+
formattedString += `${seconds} second${seconds > 1 ? 's' : ''} `;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return formattedString.trim();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function main() {
|
|
41
|
+
const { player, module: mod } = data;
|
|
42
|
+
await player.pm(`The next lottery draw is in about ${formatTimeToReach(mod.systemConfig.cronJobs.drawLottery)}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
await main();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
const { pog, gameServerId, module: mod } = data;
|
|
5
|
+
|
|
6
|
+
const varKey = 'lottery_tickets_bought';
|
|
7
|
+
|
|
8
|
+
if (!checkPermission(pog, 'LOTTERY_VIEW_TICKETS')) {
|
|
9
|
+
throw new TakaroUserError('You do not have permission to view lottery tickets.');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const tickets = (
|
|
13
|
+
await takaro.variable.variableControllerSearch({
|
|
14
|
+
filters: {
|
|
15
|
+
gameServerId,
|
|
16
|
+
key: varKey,
|
|
17
|
+
moduleId: mod.id,
|
|
18
|
+
playerId: pog.playerId,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
).data.data;
|
|
22
|
+
|
|
23
|
+
let ticketsBought = 0;
|
|
24
|
+
|
|
25
|
+
if (tickets.length === 1) {
|
|
26
|
+
ticketsBought = parseInt(JSON.parse(tickets[0].value).amount, 10);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await pog.pm(`You have bought ${ticketsBought} tickets.`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await main();
|