-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocationlimit.js
More file actions
33 lines (30 loc) · 839 Bytes
/
locationlimit.js
File metadata and controls
33 lines (30 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var stat = 0 // 0 - blacklist / 1 - whitelist
var regions = ['US','RU'] // https://www.artlebedev.ru/country-list/ u may check region codes here
var reason = 'U have been kicked' // kick reason
function lol(status,result){
if (!file.exists(path)) {
file.writeTo(path, '')}
let ipinf = JSON.parse(result)
if (stat == 1){
if (regions.includes(ipinf.countryCode) == false){
file.writeTo(path, '1')
}
}else{
if (regions.includes(ipinf.countryCode)){
file.writeTo(path, '1')
}
}
}
mc.listen("onPreJoin",function(player){
file.writeTo(path, '0')
let dv = player.getDevice()
let ip = dv.ip.split(':',2)
network.httpGet('http://ip-api.com/json/' + ip[0],lol)
setTimeout(() => {
let kck = file.readFrom(path)
if (kck == '1'){
player.kick(reason)
}
},500)
})
var path = './plugins/temp/locationlimit.json'