├── LICENSE.md ├── README.md ├── plugin.yml ├── resources ├── config.yml └── messages.yml └── src └── ifteam └── UUIDAuth ├── UUIDAuth.php ├── auth ├── Auth.php ├── AuthBase.php ├── AuthLoader.php ├── AuthManager.php ├── base │ ├── AuthBase.php │ └── commands │ │ ├── Command.php │ │ ├── CommandBase.php │ │ ├── LoginBase.php │ │ ├── LogoutBase.php │ │ ├── RegisterBase.php │ │ └── UnregisterBase.php └── network │ ├── NormalAuth.php │ ├── master │ ├── MasterAuth.php │ ├── commands │ │ ├── LoginCommand.php │ │ ├── LogoutCommand.php │ │ ├── RegisterCommand.php │ │ └── UnregisterCommand.php │ └── network │ │ ├── AuthServer.php │ │ ├── PacketProcessor.php │ │ └── process │ │ ├── AckProcess.php │ │ ├── CheckAccountProcess.php │ │ ├── DefaultInfoRequestProcess.php │ │ ├── LoginRequestProcess.php │ │ ├── LogoutRequestProcess.php │ │ ├── OnlineProcess.php │ │ ├── ProcessBase.php │ │ ├── RegisterRequestProcess.php │ │ └── UnregisterRequestProcess.php │ ├── protocol │ ├── AckPacket.php │ ├── CheckAccountPacket.php │ ├── DataPacket.php │ ├── DefaultInfoRequestPacket.php │ ├── LoginRequestPacket.php │ ├── LogoutRequestPacket.php │ ├── OnlinePacket.php │ ├── RegisterRequestPacket.php │ ├── UUIDAuthProtocol.php │ └── UnregisterRequestPacket.php │ └── slave │ └── SlaveAuth.php ├── authdata ├── AuthData.php ├── AuthDataLoader.php └── AuthDataProvider.php ├── database └── PluginData.php ├── event ├── PlayerLoginEvent.php ├── PlayerLogoutEvent.php ├── PlayerRegisterEvent.php ├── PlayerUnRegisterEvent.php └── UUIDAuthEvent.php ├── importer ├── EmailAuth │ └── EmailAuthImporter.php └── SimpleAuth │ ├── DataProvider.php │ ├── DummyDataProvider.php │ ├── MySQLDataProvider.php │ ├── MySQLPingTask.php │ ├── SQLite3DataProvider.php │ ├── SimpleAuthImporter.php │ └── YAMLDataProvider.php ├── listener └── EventListener.php └── task ├── AutoSaveTask.php └── AutoUnloadTask.php /LICENSE.md: -------------------------------------------------------------------------------- 1 | DAZE EULA LICENSE 2 | 소프트웨어 사용권 동의서 3 | 4 | 최종 사용자 라이선스 동의서(EULA) 5 | ================= 6 | 누구라도 본 라이선스를 원문 그대로 복제하고 배포할 수 있다. 그러나 본문에 대한 수정은 허용되지 않는다. 7 | 8 | 서문 9 | ---------------------------------- 10 | DAZE 최종 사용자 라이선스 동의서는 소프트웨어 및 기타 다른 저작물에 대한 카피라이트 라이선스로서, 네트워크 서버 소프트웨어의 경우 개발자의 권리 보장과, 저작물의 비상업적인 활용을 보장하기 위해 특별히 고안되었다. 11 | 12 | 대부분의 소프트웨어와 기타 실용적 저작물에 설정된 라이선스들은 저작물을 자유롭게 공유하거나 수정하는 행위를 제약하기 위해 고안되었다. 반면에 DAZE EULA는 특정 프로그램의 모든 버전을 공유하고 수정할 수 있는 비상업적 자유를 보장하면서, 개발자의 저작물 상업권에 대한 권리 보장을 보장하기 위한 것으로 개발자와 사용자의 권리가 서로 유지될 수 있도록 고안된 것이다. 13 | 14 | 저작권저작물을 사용하기 위해서는 저작재산권자의 이용허락을 받아야 하며, 이 라이선스의 경우엔, 최종 사용자 라이선스 동의(End User License Agreement) 로 대체한다, 만약 라이선스를 어길경우 저작권자의 허락을 받지 않은 활동으로 정의하며, 만약 이러한 목적을 두고 있다면 프로그램의 사용을 포기해야한다. 15 | 16 | 17 | 정의 18 | ---------------------------------- 19 | "본 라이선스"는 DAZE 최종 사용자 라이선스 동의서를 지칭한다. 20 | "저작권"은 반도체 마스크와 같은 다른 종류의 저작물에 적용되는 저작권 유사법률을 포함하는 의미이다. 21 | "프로그램"은 본 라이선스로 사용허가를 받은, 저작권 설정이 가능한 모든 저작물을 지칭한다. "라이선스를 받은 자"와 "수취인"은 개인일 수도 있고 기관일 수도 있다. 22 | "서버"는 이 프로그램을 통해서 다른 서비스를 제공하거나, 이 프로그램을 배포하는 배포자를 지칭한다. "서비스를 제공하는 자"와 "프로그램을 배포하는 자"는 개인일 수도 있고 기관일 수도 있다. 23 | "클라이언트"는 위에서 정의한 서버에서 서비스를 제공받거나 프로그램을 배포받는 자를 지칭한다. 24 | 25 | 저작권을 "수정"하는 것은 저작물을 원본 그대로 복제하는 것을 제외하고, 저작권 허가를 필요로 하는 방식으로 저작물의 전체나 부분을 복제하거나 차용하는 것을 의미한다. 그 결과물은 기존 저작물의 "수정된 버전" 이나 기존 저작물에 "기반한" 저작물이라고 칭한다. 26 | 27 | 저작물의 “소스 코드”란 저작물에 수정을 가하는 행위를 위해 선호되는 저작물의 형태를 의미한다. “오브젝트 코드”란 저작물의 비(非)소스적 형태 전부를 의미한다. 28 | 29 | 실행 가능한 저작물의 “시스템 라이브러리”는 저작물 전체를 제외한 모든 것 중에서, 주요 구성요소를 패키징하는 일반적 형태에 포함되어 있으면서 주요 구성요소의 일부가 아닌 것과 주요 구성요소와의 작동을 가능하게끔 도와주기만 하거나 혹은 표준 인터페이스를 구현하기만 하는 것으로서 그 구현이 대중에게 소스 코드 형태로 제공되는 것을 포함한다. 이 맥락에서 “주요 구성요소”는 실행 가능한 저작물을 구동할 수 있는 특정 운영체계의 주요 필수 구성요소(커널, 윈도우 시스템 등)나 그 저작물을 생산하는데 사용된 컴파일러, 또는 저작물을 실행시키기 위해 사용되는 오브젝트코드 인터프리터를 의미한다. 30 | 31 | 소스 코드 형태를 띤 저작물의 해당 소스는 그 저작물 자체이다. 32 | 33 | 34 | 이 프로그램은 다음과 같은 라이센스를 가진다. 35 | 36 | - 제 1조, 재배포의 허용, 이 프로그램은 다른 조항을 어기지 않는다면 배포 및 재배포가 가능하며, 수정 후 배포역시 가능하다. 37 | - 제 2조, 코드공개의 강제성, 이 프로그램을 사용 중인 서버는 프로그램의 사용유무를 반드시 유저가 알 수 있게 해야하며, 프로그램의 코드를 다른 유저가 받을 수 있도록 해야한다. 38 | - 제 3조, 변경된 코드공개의 강제성, 이 프로그램을 사용 중인 서버는 프로그램의 코드를 변경해서 쓰고 있다고 하더라도 프로그램의 코드를 다른 유저가 받을 수 있게 해야 한다. 39 | - 제 4조, 소프트웨어 사용권 동의서 첨부의무, 이 프로그램을 배포 시엔 LICENSE.md 파일을 반드시 첨부해야한다. 40 | - 제 5조, 소프트웨어의 법적 보호성, 이 프로그램의 소스 코드는 저작권 및 특허권에 의해 보호받는다. 41 | - 제 6조, 무단상업적 사용의 금지, 사전에 저작권자를 통해서 허용되지 아니한 모든 상업적 사용을 금지한다. 이것은 재배포시나 수정 시에도 유효하며, 상업적 사용의 범주는 아래 호에서 다룬다. 42 | - 제 7조, 2차 3차 저작물에 대한 권리, 재배포 되어진 저작물과 수정된 저작물 역시 1차 저작권자에게 권리가 주어지며, 2차 3차 개발자의 권리는 1차저작권자에게 주어진다. 따라서 2차 3차 저작물이 저작권침해를 당한경우, 1차저작권자가 2차 3차 저작물에 대해서도 권리 침해를 주장할 수 있다. 43 | 44 | 상업적 사용의 범주 45 | ---------------------------------- 46 | - 프로그램을 상업적으로 전달하거나 전달 받는 모든 행위 47 | - 프로그램을 이용해서 어떠한 상업적인 이득을 얻는 모든 행위 48 | - 프로그램의 코드를 상업적으로 쓰이거나 쓰일 프로그램에 첨부하는 행위 49 | 50 | 상업적 사용의 경우 반드시 사전에 저작권자와의 합의를 해야하며, 사전합의가 이뤄지지 않은 행위는 저작권 침해로 간주한다. 51 | 52 | 라이센스 위반에 대한 경고 53 | ---------------------------------- 54 | 만약 프로그램의 라이센스를 위반하는 행위가 있을 경우 저작권자는 이를 중단을 요청할 권리가 있다. 만약 이러한 권리를 직접적으로 지키지 않거나 간접적으로 지키지 않으려 하는 경우 지적재산권 침해행위 혹은 지적재산권 침해 방조책임을 민형사적으로 지게될 수 있다. 55 | 56 | Copyrightⓒ All Rights Reserved 57 | 58 | 소프트웨어의 지적재산권과 라이센스 59 | ---------------------------------- 60 | 현재 소프트웨어는 다음과 같이 저작권, 특허권, 영업비밀, 상표 등의 지적재산권법에 의해 보호받고 있다. 61 | 62 | 저작권 : 어떤 프로그래머가 특정 소프트웨어를 개발하게 되면 컴퓨터프로그램저작권이 자동적으로 발생하며, 프로그래머 또는 그가 속한 회사에 부여된다. 저작권(copyright)은 시, 소설, 노래 등 저작물에 대해 부여되는 권리로서 그 표현(expression)의 결과물을 보호하는 것이다. 누구도 원 저작자나 저작권자의 허가가 없이는 해당 저작물을 복사, 개작, 재배포할 수 없다. 63 | 64 | 특허권 : 특허는 하드웨어에 구현되거나 소프트웨어에 의해 동작이 구현되는 발명(invention)을 보호한다. 특허권은 자동으로 부여되는 것이 아니고 법에 정해진 절차에 의해 출원을 하여야 하며, 심사를 통해 부여되는 권리이다. 특허 기술을 구현(implementation)하기 위해서는 반드시 특허권자의 허락을 득하여야만 한다. 특허 소유자는 소유자가 허가하지 않은 사람이 해당 특허를 활용한 제품을 만들거나, 사용하거나, 판해하는 것을 막을 수 있다. 특허는 무엇인가 유용한 것을 하도록 하는 방식(method)이므로 소프트웨어의 경우 특허받은 방식을 구현하는 소프트웨어라면 프로그래밍 언어가 다르거나 소스코드가 다르더라도 해당 특허권자의 명시적인 허가를 받아야 하며 이는 OpenSource 소프트웨어, 독점소프트웨어에 공통으로 해당된다. 65 | 66 | 영업비밀 : 영업비밀이란 공연히 알려져 있지 아니하고 독립된 경제적 가치를 지니는 것으로서 상당한 노력에 의하여 비밀로 유지되는 생산 방법, 판매 방법, 기타 영업 활동에 유용한 기술상/영업상의 정보로 정의되어 있다. 이러한 영업비밀은 "부정경쟁방지 및 영업비밀보호에 관한 법률"에 의하여 보호받고 있으며, 이와 같은 영업비밀을 부당한 수단으로 취득하거나, 비밀유지의무가 있음에도 다른 사람에게 누출하는 것은 처벌받게 된다. 67 | 68 | 이상과 같은 지적재산권에 의해 권리자는 소프트웨어에 대한 배타적인 권리를 가지게 되며, 원칙적으로 권리자만이 소프트웨어를 사용, 복제, 배포, 수정할 수 있다. 하지만 다양한 필요에 의해 이들 권리자가 다른 사람에게 일정한 내용을 조건으로 하여 특정 행위를 할 수 있는 권한을 부여할 필요가 있는데, 이와 같은 권한을 보통 '라이센스(license, 사용허가권)'라고 한다. 이러한 의미에서 라이센스는 물건을 판매하는 매매와는 차이가 있으며, 소프트웨어에 대한 지적재산권은 여전히 원래의 권리자에게 남아있고 일부 사용에 대한 권리만을 부여하는 것이다. 마이크로소프트, 오라클 등 일반적인 독점(proprietary)소프트웨어 업체의 라이센스는 고객이 소프트웨어 권리자에게 대금을 지급하고 소프트웨어의 ‘사용’ 권한만을 허락하는 것이 일반적이다. 따라서 허락을 얻지 않고 소프트웨어를 복제, 배포, 수정하는 행위는 라이센스를 위반함과 동시에 불법에 해당한다. 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UUIDAuth 2 | UUID auth in PocketMine 3 | -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | name: UUIDAuth 2 | main: ifteam\UUIDAuth\UUIDAuth 3 | version: 1.0-Test 4 | author: hm 5 | api: 6 | - 1.0.0 7 | - 1.4.0 8 | - 1.12.0 9 | - 1.13.0 10 | - 2.0.0 -------------------------------------------------------------------------------- /resources/config.yml: -------------------------------------------------------------------------------- 1 | #AUTH SETTINGS 2 | #----------------------------------------------------- 3 | #Minimum password length 4 | minPasswordLength: 5 5 | 6 | #Sign up disabled 7 | disableRegister: false 8 | 9 | #Default Server Prefix 10 | default-prefix: "[ 서버 ]" 11 | 12 | #Time to wait for authentication 13 | authenticateTimeout: 60 14 | 15 | #NormalAuth 16 | authentication: "NormalAuth" 17 | #----------------------------------------------------- 18 | 19 | #CUSTOMPACKET SETTINGS 20 | #----------------------------------------------------- 21 | #Whether using a custom packet 22 | #type : null || true || false 23 | usecustompacket: null 24 | 25 | #Set servermode 26 | #type : null || master || slave 27 | servermode: null 28 | 29 | passcode: null 30 | masterip: null 31 | masterport: null 32 | #----------------------------------------------------- -------------------------------------------------------------------------------- /resources/messages.yml: -------------------------------------------------------------------------------- 1 | # IF YOU NEED A SOME OTHER LANGUAGE SETTINGS # 2 | # YOU SHOULD MODIFY THIS MESSAGE.YML FILE -! # 3 | 4 | #PLEASE SET HERE TO YOUR LANGUAGE PREFIX 5 | m_version: 1 6 | 7 | #(EN) ENGLISH 8 | eng: true 9 | eng-default-prefix: "[UUIDAuth]" 10 | eng-login: "login" 11 | eng-login-help: "Log in to the server" 12 | eng-logout: "logout" 13 | eng-logout-help: "Logout in to the server" 14 | eng-register: "register" 15 | eng-register-help: "Register in to the server" 16 | eng-unregister: "unregister" 17 | eng-unregister-help: "unregister in to the server" 18 | eng-manage-help: "Manage the UUIDAuth" 19 | eng-adminMail-doesnt-exist: "adminEmail doesn't exist! test failed!" 20 | eng-adminEmailHost-doesnt-exist: "adminEmailHost doesn't exist! test failed!" 21 | eng-adminEmailPort-doesnt-exist: "adminEmailPort doesn't exist! test failed!" 22 | eng-adminEmailPassword-doesnt-exist: "adminEmailPassword doesn't exist! test failed!" 23 | eng-adminMail-setup-complete: "adminEmail set-up complete!" 24 | eng-adminEmailHost-setup-complete: "adminEmailHost set-up complete!" 25 | eng-adminEmailPort-setup-complete: "adminEmailPort set-up complete!" 26 | eng-adminEmailPassword-setup-complete: "adminEmailPassword set-up complete!" 27 | eng-auth-help-setup: "/uuidauth setup - Config Setup" 28 | eng-auth-help-test: "/uuidauth test - SendMail Test" 29 | eng-auth-help-domain: "/uuidauth domain - DomainLock Setup" 30 | eng-auth-help-length: "/uuidauth length - Set a Minimum pass length" 31 | eng-auth-help-whitelist: "/uuidauth whitelist - Disable a Register" 32 | eng-setup-help-mail: "/uuidauth setup mail - MAIL ADDRESS" 33 | eng-setup-help-pass: "/uuidauth setup pass - MAIL PASSWORD" 34 | eng-setup-help-host: "/uuidauth setup host - MAIL HOSTDOMAIN" 35 | eng-setup-help-port: "/uuidauth setup port - MAIL HOSTPORT" 36 | eng-setup-complete: "check your e-mail, if PocketMine mail is exist, now you can use UUIDAuth!" 37 | eng-setup-failed: "Failed sending email, please check that the settings are incorrect." 38 | eng-automatic-ip-logined: "You are logged automatically! (IP Auth)" 39 | eng-uuidauth-notification: "This server is under way to account protection via UUIDAuth" 40 | eng-you-need-a-login: "Please proceed to Login! /login " 41 | eng-you-need-a-register: "/register " 42 | kor-you-needReAuthMessage: "/register " 43 | eng-already-logined: "You are already logged in!" 44 | eng-logout-complete: "log-out is complete!" 45 | eng-unregister-is-complete: "unregister is complete!" 46 | eng-login-is-success: "successfully logged in !" 47 | eng-login-is-failed: "Login failed!" 48 | eng-register-complete: "Register is Complete!" 49 | eng-wrong-authcode: "The verification number is invalid Sign Up Failed!" 50 | eng-wrong-password: "The password is invalid Sign Up Failed!" 51 | eng-authcode-doesnt-exist: "The authentication code does not exist! Please enter your email address correctly" 52 | eng-mail-has-been-sent: "Mail has been sent to the authorization number! Please check your email after signing up!" 53 | eng-too-short-password: "Password is too short! Sign Up Failed!" 54 | eng-this-account-cant-use: "This account can not be used! Login failed!" 55 | eng-you-can-use-email-domain: "Currently, only *@%domain% email Sign up possible!" 56 | eng-you-can-activate-custompacket: "/ uuidauth custompacket - Can enable a interworking with custompacket!" 57 | eng-custompacket-enabled: "Custom packet interworking is enabled!" 58 | eng-custompacket-disabled: "Custom packet interworking have been disabled!" 59 | 60 | eng-please-choose-mode: "Please select the server mode (master / slave)" 61 | eng-master-mode-selected: "The Master mode is selected." 62 | eng-slave-mode-selected: "Slave mode has been selected." 63 | eng-please-choose-passcode: "Please enter the passcode for communications security (at least 8 characters)." 64 | eng-too-short-passcode: "The passcode must be eight characters abnormalities" 65 | eng-wrong-passcode: "The password code can not be used." 66 | eng-passcode-selected: "Communication for password security codes have been set." 67 | eng-wrong-port: "Invalid port, please choose from the range 31-65534" 68 | eng-wrong-ip: "Invalid IP, please enter 000.000.000.000" 69 | eng-please-type-master-ip: "Please enter the IP of the master server." 70 | eng-please-type-master-port: "Please enter the port on the master server." 71 | eng-master-ip-selected: "Master server IP has been set." 72 | eng-master-port-selected: "the master server ports have been set." 73 | eng-all-setup-complete: "All the settings are completed." 74 | 75 | #(KO) KOREAN 76 | kor: true 77 | eng-default-prefix: "[UUIDAuth]" 78 | kor-login: "로그인" 79 | kor-login-help: "서버에 로그인합니다" 80 | kor-logout: "로그아웃" 81 | kor-logout-help: "서버에 로그아웃합니다" 82 | kor-register: "가입" 83 | kor-register-help: "서버에 가입합니다" 84 | kor-unregister: "탈퇴" 85 | kor-unregister-help: "서버에 탈퇴합니다" 86 | kor-otp: "otp" 87 | kor-otp-help: "일회용암호를 발급받거나 사용합니다." 88 | kor-manage-help: "UUIDAuth를 관리합니다" 89 | kor-adminMail-doesnt-exist: "관리자 이메일이 등록되지 않았습니다 !" 90 | kor-adminEmailHost-doesnt-exist: "관리자 이메일 호스트가 등록되지 않았습니다 !" 91 | kor-adminEmailPort-doesnt-exist: "관리자 이메일 포트가 등록되지 않았습니다 !" 92 | kor-adminEmailPassword-doesnt-exist: "관리자 이메일 암호가 등록되지 않았습니다 !" 93 | kor-adminMail-setup-complete: "관리자 이메일을 등록했습니다 !" 94 | kor-adminEmailHost-setup-complete: "관리자 이메일 호스트를 등록했습니다 !" 95 | kor-adminEmailPort-setup-complete: "관리자 이메일 포트를 등록했습니다 !" 96 | kor-adminEmailPassword-setup-complete: "관리자 이메일 암호를 등록했습니다 !" 97 | kor-auth-help-setup: "uuidauth setup - 기초환경설정" 98 | kor-auth-help-test: "/uuidauth test - 메일전송테스트" 99 | kor-auth-help-domain: "/uuidauth domain - 가입제한도메인설정" 100 | kor-auth-help-length: "/uuidauth length - 암호최소길이설정" 101 | kor-auth-help-whitelist: "/uuidauth whitelist - 가입금지" 102 | kor-setup-help-mail: "/uuidauth setup mail - 메일주소입력" 103 | kor-setup-help-pass: "/uuidauth setup pass - 메일암호입력" 104 | kor-setup-help-host: "/uuidauth setup host - 메일호스트도메인입력" 105 | kor-setup-help-port: "/uuidauth setup port - 메일호스트포트입력" 106 | kor-setup-complete: "본인의 이메일을 확인해주세요, 만약 포켓마인의 이메일이 존재하면, UUIDAuth를 정상적으로 사용가능합니다" 107 | kor-setup-failed: "이메일 전송에 실패했습니다, 잘못된 설정이 있는지 체크해주세요" 108 | kor-automatic-ip-logined: "자동으로 로그인되었습니다! (IP 로그인)" 109 | kor-uuidauth-notification: "이 서버는 UUIDAuth를 통한 계정보호를 진행중입니다." 110 | kor-you-need-a-login: "로그인을 진행해주세요 ! /로그인 <설정한암호>" 111 | kor-you-can-use-otp: "암호를 잊었으면, /otp 로 이메일에 임시암호 발급가능" 112 | kor-you-need-a-register: "/가입 <이메일 또는 인증번호> <원하는암호>" 113 | kor-you-needReAuthMessage: "/가입 <이메일 또는 인증번호> <설정했던 암호>" 114 | kor-whitelist-enabled: "화이트리스트가 활성화 되었습니다 !" 115 | kor-whitelist-disabled: "화이트리스트가 비활성화 되었습니다 !" 116 | kor-already-logined: "이미 로그인되어 있습니다 !" 117 | kor-logout-complete: "로그아웃이 완료되었습니다 !" 118 | kor-logout-failed: "로그아웃에 실패했습니다 !" 119 | kor-unregister-is-complete: "회원탈퇴가 완료되었습니다 !" 120 | kor-login-is-success: "로그인에 성공했습니다 !" 121 | kor-login-is-failed: "로그인에 실패했습니다 !" 122 | kor-wrong-email-type: "잘못된 이메일 형식입니다 ! 가입실패!" 123 | kor-register-complete: "회원가입이 완료되었습니다 !" 124 | kor-register-failed: "회원가입에 실패했습니다 !" 125 | kor-unregister-is-fail: "회원탈퇴에 실패했습니다 ! 관리자에게 문의해주세요 !" 126 | kor-wrong-authcode: "인증번호가 잘못되었습니다 ! 가입 실패!" 127 | kor-wrong-password: "비밀번호가 다릅니다 ! 가입 실패!" 128 | kor-authcode-doesnt-exist: "인증코드가 존재하지않습니다!, 이메일을 정확히 입력해주세요" 129 | kor-authcode-resetted: "인증코드가 초기화되었습니다. 인증절차를 다시 시작해주세요" 130 | kor-mail-has-been-sent: "메일로 인증번호를 전송했습니다! 이메일을 확인후 가입해주세요!" 131 | kor-too-short-password: "비밀번호가 너무 짧습니다 ! 가입실패!" 132 | kor-this-account-cant-use: "이 계정은 사용하실 수 없습니다 ! 로그인 실패 !" 133 | kor-you-can-use-email-domain: "현재 *@%domain% 이메일로만 가입가능합니다!" 134 | kor-you-can-activate-custompacket: "/uuidauth custompacket 으로 커스텀패킷 연동 활성화 가능!" 135 | kor-custompacket-enabled: "커스텀패킷 연동이 활성화 되었습니다 !" 136 | kor-custompacket-disabled: "커스텀패킷 연동이 비활성화 되었습니다 !" 137 | 138 | kor-please-choose-mode: "서버모드를 선택해주세요 (master/slave)" 139 | kor-master-mode-selected: "마스터모드가 선택되었습니다" 140 | kor-slave-mode-selected: "슬레이브모드가 선택되었습니다" 141 | kor-please-choose-passcode: "통신보안용 암호코드를 입력해주세요 (8자이상)" 142 | kor-too-short-passcode: "암호코드는 8자 이상이여야합니다" 143 | kor-wrong-passcode: "해당 암호코드는 사용하실 수 없습니다" 144 | kor-passcode-selected: "통신보안용 암호코드가 설정되었습니다" 145 | kor-wrong-port: "잘못된 포트입니다, 31~65534 범위에서 선택해주세요" 146 | kor-wrong-ip: "잘못된 아이피입니다, 000.000.000.000 과같이 입력해주세요" 147 | kor-please-type-master-ip: "마스터서버의 아이피를 입력해주세요" 148 | kor-please-type-master-port: "마스터서버의 포트를 입력해주세요" 149 | kor-master-ip-selected: "마스터서버 아이피가 설정되었습니다" 150 | kor-master-port-selected: "마스터서버 포트가 설정되었습니다" 151 | kor-all-setup-complete: "모든 설정이 완료되었습니다" 152 | kor-slavemode-first-connected: "서버에 정상연결되었습니다." 153 | kor-mastermode-first-connected: "서버가 연결되었습니다." 154 | kor-please-wait-a-certification-process: "인증절차가 곧 시작됩니다. 기다려주세요." 155 | kor-automatically-login: "자동으로 로그인 되었습니다 ! (IP로그인)" 156 | kor-already-connected: "이미 다른서버에 연결되어있음" 157 | kor-proceed-to-login-please-wait: "로그인을 진행합니다. 기다려주세요.." 158 | kor-proceed-to-logout-please-wait: "로그아웃을 진행합니다. 기다려주세요.." 159 | kor-proceed-to-register-please-wait: "회원가입을 진행합니다. 기다려주세요.." 160 | kor-proceed-to-unregister-please-wait: "회원탈퇴를 진행합니다. 기다려주세요.." 161 | kor-start-the-certification-process: "인증절차를 시작합니다!" 162 | kor-check-email-registered: "이메일 가입여부를 확인합니다.." 163 | kor-that-email-is-already-registered: "이 이메일은 가입되어있습니다 ! 사용불가 !" 164 | kor-issuing-an-authorization-code: "이메일 인증코드 발급을 요청합니다.." 165 | kor-request-an-authorization-code: "이메일 인증코드 인증을 요청합니다.." 166 | kor-rejected-an-authorization-code: "잘못된 이메일형식이거나, 이미가입되어있습니다 !" 167 | kor-password-is-too-long: "암호가 너무 깁니다 ! 사용불가 !" 168 | kor-youre-not-yet-login: "아직 로그인하지 않았습니다 ! 사용불가 !" 169 | kor-complete-unregister: "회원탈퇴완료" 170 | kor-banned-brute-force: "과다접근 시도로 400초 밴처리 !" 171 | kor-otp-logined: "로그인 처리되었습니다 ! (OTP로그인)" 172 | kor-otp-is-generated: "OTP가 발급되었습니다, 이메일을 확인해주세요 !" 173 | kor-otp-is-not-generated: "이전 OTP가 쓰이지 않음, OTP 발급 거부 !" 174 | kor-otp-access-denied: "오래되었거나 잘못된 OTP입니다, 접근 불가 !" 175 | kor-request-generate-otp: "서버에 OTP 발급을 요청합니다.." 176 | kor-request-using-otp: "서버에 OTP 사용을 요청합니다.." 177 | 178 | # AND YOU CAN PROVIDE YOUR TRANSLATION # 179 | # https://github.com/HmHmmHm/UUIDAuth/tree/master/resources/messages.yml -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/UUIDAuth.php: -------------------------------------------------------------------------------- 1 | database = new PluginData ( $this ); 31 | 32 | $this->authDataLoader = new AuthDataLoader ( $this ); 33 | $this->authDataProvider = new AuthDataProvider ( $this ); 34 | $this->authManager = new AuthManager ( $this->authDataProvider, $this->getServer (), $this ); 35 | $this->eventListener = new EventListener ( $this ); 36 | 37 | $this->saveResource ( "config.yml", false ); 38 | $this->database->initMessage (); 39 | 40 | $this->database->registerCommand ( $this->database->get ( "otp" ), "UUIDAuth.otp", $this->database->get ( "otp-help" ), "/" . $this->database->get ( "otp" ) ); 41 | $this->database->registerCommand ( "uuidauth", "UUIDAuth.manage", $this->database->get ( "manage-help" ), "/uuidauth" ); 42 | 43 | if (file_exists ( $this->getDataFolder () . "SimpleAuth/players" )) 44 | SimpleAuthImporter::getSimpleAuthData ( $this ); 45 | 46 | $this->getServer ()->getPluginManager ()->registerEvents ( $this, $this ); 47 | // $this->getServer ()->getScheduler ()->scheduleRepeatingTask ( new AutoSaveTask ( $this ), 12000 ); 48 | } 49 | /** 50 | * Called when the plugin is disabled Use this to free open things and finish actions 51 | * 52 | * @see \pocketmine\plugin\PluginBase::onDisable() 53 | */ 54 | public function onDisable() { 55 | $this->save (); 56 | } 57 | /** 58 | * Save plug-in configs 59 | * 60 | * @param string $async 61 | */ 62 | public function save($async = false) { 63 | $this->database->save ( $async ); 64 | } 65 | /** 66 | * Handles the received command 67 | * 68 | * @see \pocketmine\plugin\PluginBase::onCommand() 69 | */ 70 | public function onCommand(CommandSender $sender, Command $command, $label, array $args) { 71 | // TODO 72 | } 73 | /** 74 | * Return Plug-in Database 75 | */ 76 | public function getDataBase() { 77 | return $this->database; 78 | } 79 | /** 80 | * Return Plug-in Event Listener 81 | */ 82 | public function getEventListener() { 83 | return $this->eventListener; 84 | } 85 | public function getAuthLoader() { 86 | return $this->authDataLoader; 87 | } 88 | public function getAuthProvider() { 89 | return $this->authDataProvider; 90 | } 91 | } 92 | 93 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/Auth.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/AuthBase.php: -------------------------------------------------------------------------------- 1 | provider = $provider; 19 | $this->server = $server; 20 | $this->plugin = $plugin; 21 | $this->onLoad (); 22 | } 23 | public function onLoad() { 24 | } 25 | public function authenticatePlayer($player) { 26 | } 27 | public function deauthenticatePlayer($player) { 28 | } 29 | public function cueAuthenticatePlayer($player) { 30 | } 31 | public function onCommand(CommandSender $player, Command $command, $label, array $args) { 32 | } 33 | /** 34 | * Uses SHA-512 [http://en.wikipedia.org/wiki/SHA-2] and Whirlpool [http://en.wikipedia.org/wiki/Whirlpool_(cryptography)] 35 | * 36 | * Both of them have an output of 512 bits. Even if one of them is broken in the future, you have to break both of them 37 | * at the same time due to being hashed separately and then XORed to mix their results equally. 38 | * 39 | * @param string $salt 40 | * @param string $password 41 | * 42 | * @return string[128] hex 512-bit hash 43 | */ 44 | public final function hash($salt, $password) { 45 | return bin2hex ( hash ( "sha512", $password . $salt, true ) ^ hash ( "whirlpool", $salt . $password, true ) ); 46 | } 47 | /** 48 | * 49 | * @return \pocketmine\Server 50 | */ 51 | public final function getServer() { 52 | return $this->server; 53 | } 54 | /** 55 | * 56 | * @return \ifteam\UUIDAuth\auth\AuthDataProvider 57 | */ 58 | public final function getAuthProvider() { 59 | return $this->provider; 60 | } 61 | /** 62 | * 63 | * @return \ifteam\UUIDAuth\UUIDAuth 64 | */ 65 | public final function getPlugin() { 66 | return $this->plugin; 67 | } 68 | } 69 | 70 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/AuthLoader.php: -------------------------------------------------------------------------------- 1 | provider = $provider; 17 | $this->server = $server; 18 | $this->plugin = $plugin; 19 | } 20 | public function onLoad() { 21 | } 22 | public function getAuthBase() { 23 | } 24 | /** 25 | * 26 | * @return \pocketmine\Server 27 | */ 28 | public final function getServer() { 29 | return $this->server; 30 | } 31 | /** 32 | * 33 | * @return \ifteam\UUIDAuth\auth\AuthDataProvider 34 | */ 35 | public final function getProvider() { 36 | return $this->provider; 37 | } 38 | /** 39 | * 40 | * @return \ifteam\UUIDAuth\UUIDAuth 41 | */ 42 | public final function getPlugin() { 43 | return $this->plugin; 44 | } 45 | } 46 | 47 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/AuthManager.php: -------------------------------------------------------------------------------- 1 | server = $server; 23 | $this->provider = $provider; 24 | $this->plugin = $plugin; 25 | 26 | $this->registerAuthentications (); 27 | } 28 | 29 | /** 30 | * 31 | * @param string $name 32 | * 33 | * @return null|Auth 34 | */ 35 | public function getAuthentication($name) { 36 | if (isset ( $this->auths [$name] )) 37 | return $this->auths [$name]; 38 | return \null; 39 | } 40 | public function registerAuthentication($class) { 41 | $this->auths [strtolower ( get_class ( $class ) )] = $class; 42 | 43 | return \true; 44 | } 45 | public function loadAuthentication($class) { 46 | if (isset ( $this->auths [strtolower ( get_class ( $class ) )] )) { 47 | $auth = $this->auths [strtolower ( get_class ( $class ) )]; 48 | if ($auth instanceof AuthBase) { 49 | $auth->init ( $this->provider, $this->server, $this->plugin ); 50 | return true; 51 | } 52 | } 53 | return false; 54 | } 55 | public function loadAuthentications() { 56 | foreach ( $this->auths as $auth ) 57 | $this->loadAuthentication ( $auth ); 58 | } 59 | public function registerAuthentications() { 60 | $normalAuth = new NormalAuth (); 61 | $normalAuth->init ( $this->provider, $this->server, $this->plugin ); 62 | $normalAuth->onLoad (); 63 | 64 | $this->loadAuthentication ( $normalAuth->getAuthBase () ); 65 | $this->registerAuthentication ( $normalAuth->getAuthBase () ); 66 | // TODO Email SMS SNS or etc... 67 | } 68 | /** 69 | * 70 | * @return null|Auth 71 | */ 72 | public function getAuthBase() { 73 | $authentication = $this->plugin->getConfig ()->get ( "authentication", null ); 74 | return $this->getAuthentication ( strtolower ( $authentication ) ); 75 | } 76 | /** 77 | * 78 | * @return Auth[] 79 | */ 80 | public function getAuths() { 81 | return $this->auths; 82 | } 83 | /** 84 | * 85 | * @return AuthManager 86 | */ 87 | public static function getInstance() { 88 | return self::$instance; 89 | } 90 | } 91 | 92 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/base/AuthBase.php: -------------------------------------------------------------------------------- 1 | provider = $provider; 22 | $this->server = $server; 23 | $this->plugin = $plugin; 24 | $this->onLoad (); 25 | } 26 | public function onLoad() { 27 | } 28 | public function authenticatePlayer(Player $player) { 29 | } 30 | public function deauthenticatePlayer(Player $player) { 31 | } 32 | public function cueAuthenticatePlayer(Player $player) { 33 | } 34 | public function onCommand(CommandSender $player, Command $command, $label, array $args) { 35 | if (isset ( $this->commands [$command->getName ()] )) { 36 | $command = $this->commands [$command->getName ()]; 37 | 38 | if ($command instanceof \ifteam\UUIDAuth\auth\base\commands\Command) { 39 | $command->onCommand ( $player, $command, $label, $args ); 40 | } 41 | } 42 | } 43 | /** 44 | * 45 | * @param \ifteam\UUIDAuth\auth\base\commands\Command $command 46 | */ 47 | public function registerCommand(\ifteam\UUIDAuth\auth\base\commands\Command $command) { 48 | $this->commands [$command->getCommand ()->getName ()] = $command; 49 | } 50 | /** 51 | * Uses SHA-512 [http://en.wikipedia.org/wiki/SHA-2] and Whirlpool [http://en.wikipedia.org/wiki/Whirlpool_(cryptography)] 52 | * 53 | * Both of them have an output of 512 bits. Even if one of them is broken in the future, you have to break both of them 54 | * at the same time due to being hashed separately and then XORed to mix their results equally. 55 | * 56 | * @param string $salt 57 | * @param string $password 58 | * 59 | * @return string[128] hex 512-bit hash 60 | */ 61 | public final function hash($salt, $password) { 62 | return bin2hex ( hash ( "sha512", $password . $salt, true ) ^ hash ( "whirlpool", $salt . $password, true ) ); 63 | } 64 | /** 65 | * 66 | * @return \pocketmine\Server 67 | */ 68 | public final function getServer() { 69 | return $this->server; 70 | } 71 | /** 72 | * 73 | * @return \ifteam\UUIDAuth\auth\AuthDataProvider 74 | */ 75 | public final function getAuthProvider() { 76 | return $this->provider; 77 | } 78 | /** 79 | * 80 | * @return \ifteam\UUIDAuth\UUIDAuth 81 | */ 82 | public final function getPlugin() { 83 | return $this->plugin; 84 | } 85 | } 86 | 87 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/base/commands/Command.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/base/commands/CommandBase.php: -------------------------------------------------------------------------------- 1 | auth = $auth; 25 | $this->command = $this->registerCommand (); 26 | } 27 | public function registerCommand() { 28 | } 29 | public function onCommand(CommandSender $player, \pocketmine\command\Command $command, $label, array $args) { 30 | } 31 | /** 32 | * 33 | * @return AuthBase 34 | */ 35 | public function getAuth() { 36 | return $this->auth; 37 | } 38 | /** 39 | * 40 | * @return Command 41 | */ 42 | public function getCommand() { 43 | return $this->command; 44 | } 45 | } 46 | 47 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/base/commands/LoginBase.php: -------------------------------------------------------------------------------- 1 | registerCommand ( $database->get ( "login" ), "UUIDAuth.login", $database->get ( "login-help" ), "/" . $database->get ( "login" ) ); 12 | } 13 | public function onCommand(CommandSender $player, \pocketmine\command\Command $command, $label, array $args) { 14 | } 15 | } 16 | 17 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/base/commands/LogoutBase.php: -------------------------------------------------------------------------------- 1 | registerCommand ( $database->get ( "logout" ), "UUIDAuth.logout", $database->get ( "logout-help" ), "/" . $database->get ( "logout" ) ); 12 | } 13 | public function onCommand(CommandSender $player, \pocketmine\command\Command $command, $label, array $args) { 14 | } 15 | } 16 | 17 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/base/commands/RegisterBase.php: -------------------------------------------------------------------------------- 1 | registerCommand ( $database->get ( "register" ), "UUIDAuth.register", $database->get ( "register-help" ), "/" . $database->get ( "register" ) ); 12 | } 13 | public function onCommand(CommandSender $player, \pocketmine\command\Command $command, $label, array $args) { 14 | } 15 | } 16 | 17 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/base/commands/UnregisterBase.php: -------------------------------------------------------------------------------- 1 | registerCommand ( $database->get ( "unregister" ), "UUIDAuth.unregister", $database->get ( "unregister-help" ), "/" . $database->get ( "unregister" ) ); 12 | } 13 | public function onCommand(CommandSender $player, \pocketmine\command\Command $command, $label, array $args) { 14 | } 15 | } 16 | 17 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/NormalAuth.php: -------------------------------------------------------------------------------- 1 | useCustomPacket = $this->getPlugin ()->getConfig ()->get ( "usecustompacket", null ); 14 | $this->serverMode = $this->getPlugin ()->getConfig ()->get ( "servermode", null ); 15 | } 16 | public function getAuthBase() { 17 | return ($this->useCustomPacket == true and $this->serverMode == "slave") ? new SlaveAuth () : new MasterAuth (); 18 | } 19 | } 20 | 21 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/MasterAuth.php: -------------------------------------------------------------------------------- 1 | getServer ()->getPluginManager ()->registerEvents ( $this, $this->getPlugin () ); 18 | 19 | $this->registerCommand ( new LoginCommand ( $this ) ); 20 | $this->registerCommand ( new LogoutCommand ( $this ) ); 21 | $this->registerCommand ( new RegisterCommand ( $this ) ); 22 | $this->registerCommand ( new UnregisterCommand ( $this ) ); 23 | 24 | new AuthServer ( $this->getPlugin () ); 25 | } 26 | public function authenticatePlayer(Player $player) { 27 | } 28 | public function deauthenticatePlayer(Player $player) { 29 | } 30 | public function cueAuthenticatePlayer(Player $player) { 31 | } 32 | } 33 | 34 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/commands/LoginCommand.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/commands/LogoutCommand.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/commands/RegisterCommand.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/commands/UnregisterCommand.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/AuthServer.php: -------------------------------------------------------------------------------- 1 | server = Server::getInstance (); 31 | $this->plugin = $plugin; 32 | $this->auth = $auth; 33 | 34 | $this->customPacket = $this->server->getPluginManager ()->getPlugin ( "CustomPacket" ); 35 | 36 | if (! $this->customPacket instanceof \ifteam\CustomPacket\MainLoader) 37 | return; 38 | 39 | $this->server->getPluginManager ()->registerEvents ( $this, $plugin ); 40 | 41 | if (self::$instance === null) 42 | self::$instance = $this; 43 | 44 | new PacketProcessor ( $auth ); 45 | $this->packetProcessor = PacketProcessor::getInstance (); 46 | } 47 | public function onCustomPacketReceiveEvent(CustomPacketReceiveEvent $event) { 48 | $packet = ( array ) json_decode ( $ev->getPacket ()->data, true ); 49 | 50 | if (! is_array ( $packet ) or $packet [0] != $this->plugin->getConfig ()->get ( "passcode", false )) 51 | return; 52 | if (! isset ( $packet [4] )) 53 | return; 54 | 55 | /* $packet [0] = passcode */ 56 | /* $packet [1] = pid */ 57 | /* $packet [2] = needACK */ 58 | /* $packet [3] = identifier */ 59 | /* $packet [...] = etc */ 60 | $dataPacket = $this->getPacket ( $packet [1] ); 61 | 62 | if (! $dataPacket instanceof DataPacket) 63 | return; 64 | 65 | $dataPacket->decode ( $packet ); 66 | $this->packetProcessor->process ( $dataPacket ); 67 | } 68 | /** 69 | * 70 | * @param unknown $pid 71 | */ 72 | public function getPacket($pid) { 73 | $packet = null; 74 | 75 | switch ($pid) { 76 | case Info::ONLINE : 77 | $packet = new OnlinePacket (); 78 | break; 79 | case Info::ACK : 80 | $packet = new AckPacket (); 81 | break; 82 | case Info::CHECK_ACCOUNT : 83 | $packet = new CheckAccountPacket (); 84 | break; 85 | case Info::DEFAULT_INFO_REQUEST : 86 | $packet = new DefaultPacketRequestPacket (); 87 | break; 88 | case Info::LOGIN_REQUEST : 89 | $packet = new LoginRequestPacket (); 90 | break; 91 | case Info::LOGOUT_REQUEST : 92 | $packet = new LogoutRequestPacket (); 93 | break; 94 | case Info::REGISTER_REQUEST : 95 | $packet = new RegisterRequestPacket (); 96 | break; 97 | case Info::UNREGISTER_REQUEST : 98 | $packet = new UnregisterRequestPacket (); 99 | break; 100 | } 101 | 102 | return $packet; 103 | } 104 | public static function getInstance() { 105 | return self::$instance; 106 | } 107 | } 108 | 109 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/PacketProcessor.php: -------------------------------------------------------------------------------- 1 | auth = $auth; 27 | $this->registerProcessors (); 28 | } 29 | public function registerProcessors() { 30 | $this->processor [AckProcess::getPid ()] = new AckProcess ( $this->auth ); 31 | $this->processor [CheckAccountProcess::getPid ()] = new CheckAccountProcess ( $this->auth ); 32 | $this->processor [DefaultInfoRequestProcess::getPid ()] = new DefaultInfoRequestProcess ( $this->auth ); 33 | $this->processor [LoginRequestProcess::getPid ()] = new LoginRequestProcess ( $this->auth ); 34 | $this->processor [LogoutRequestProcess::getPid ()] = new LogoutRequestProcess ( $this->auth ); 35 | $this->processor [OnlineProcess::getPid ()] = new OnlineProcess ( $this->auth ); 36 | $this->processor [RegisterRequestProcess::getPid ()] = new RegisterRequestProcess ( $this->auth ); 37 | $this->processor [UnregisterRequestProcess::getPid ()] = new UnregisterRequestProcess ( $this->auth ); 38 | } 39 | /** 40 | * 41 | * @param int $pid 42 | * @return ProcessBase 43 | */ 44 | public function getProcessor($pid) { 45 | if (! isset ( $this->processor [$pid] )) 46 | return null; 47 | return $this->processor [$pid]; 48 | } 49 | public function process(DataPacket $packet) { 50 | switch ($packet->pid) { 51 | case Info::ONLINE : 52 | case Info::ACK : 53 | case Info::CHECK_ACCOUNT : 54 | case Info::DEFAULT_INFO_REQUEST : 55 | case Info::LOGIN_REQUEST : 56 | case Info::LOGOUT_REQUEST : 57 | case Info::REGISTER_REQUEST : 58 | case Info::UNREGISTER_REQUEST : 59 | $this->getProcessor ( $packet->pid )->process ( $packet ); 60 | break; 61 | } 62 | } 63 | public static function getInstance() { 64 | return self::$instance; 65 | } 66 | } 67 | 68 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/process/AckProcess.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/process/CheckAccountProcess.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/process/DefaultInfoRequestProcess.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/process/LoginRequestProcess.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/process/LogoutRequestProcess.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/process/OnlineProcess.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/process/ProcessBase.php: -------------------------------------------------------------------------------- 1 | authServer = AuthServer::getInstance (); 17 | $this->authManager = AuthManager::getInstance (); 18 | $this->authBase = $auth; 19 | } 20 | public function process(DataPacket $packet) { 21 | } 22 | /** 23 | * 24 | * @return AuthServer 25 | */ 26 | public function getAuthServer() { 27 | return $this->authServer; 28 | } 29 | /** 30 | * 31 | * @return AuthManager 32 | */ 33 | public function getAuthManager() { 34 | return $this->authManager; 35 | } 36 | /** 37 | * 38 | * @return AuthBase 39 | */ 40 | public function getAuthBase() { 41 | return $this->authBase; 42 | } 43 | } 44 | 45 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/process/RegisterRequestProcess.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/master/network/process/UnregisterRequestProcess.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/AckPacket.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/CheckAccountPacket.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/DataPacket.php: -------------------------------------------------------------------------------- 1 | passcode = array_shift ( $array ); 18 | $this->pid = array_shift ( $array ); 19 | $this->needACK = array_shift ( $array ); 20 | $this->identifier = array_shift ( $array ); 21 | 22 | $this->decodeSub ( $array ); 23 | } 24 | public function decodeString($string) { 25 | $this->decode ( ( array ) json_decode ( $string, true ) ); 26 | } 27 | public function encode() { 28 | $encode = [ 29 | $this->passcode, 30 | $this->pid, 31 | $this->needACK, 32 | null 33 | ]; 34 | 35 | $encodeSub = $this->encodeSub (); 36 | 37 | if ($this->needACK) { 38 | $encode [3] = $this->crc32 ( json_encode ( $encodeSub ) ); 39 | } 40 | 41 | $encoded = json_encode ( array_merge ( $encode, $encodeSub ) ); 42 | 43 | if ($this->needACK) { 44 | // $encode [3] 45 | // $encoded; 46 | 47 | // TODO checkACK and process 48 | } 49 | 50 | return $encoded; 51 | } 52 | public function decodeSub(array $array) { 53 | } 54 | /** 55 | * 56 | * @return array 57 | */ 58 | public function encodeSub() { 59 | } 60 | public final function crc32($string) { 61 | return bin2hex ( hash ( "crc32", $string, true ) ); 62 | } 63 | } 64 | 65 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/DefaultInfoRequestPacket.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/LoginRequestPacket.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/LogoutRequestPacket.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/OnlinePacket.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/RegisterRequestPacket.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/UUIDAuthProtocol.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/protocol/UnregisterRequestPacket.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/auth/network/slave/SlaveAuth.php: -------------------------------------------------------------------------------- 1 | getServer ()->getPluginManager ()->registerEvents ( $this, $this->getPlugin () ); 13 | } 14 | public function authenticatePlayer($player) { 15 | } 16 | public function deauthenticatePlayer($player) { 17 | } 18 | public function cueAuthenticatePlayer($player) { 19 | } 20 | public function onCommand(CommandSender $player, Command $command, $label, array $args) { 21 | } 22 | } 23 | 24 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/authdata/AuthData.php: -------------------------------------------------------------------------------- 1 | userName = $userName; 16 | $this->dataFolder = $dataFolder . substr ( $userName, 0, 1 ) . "/"; 17 | 18 | if (! file_exists ( $this->dataFolder )) 19 | @mkdir ( $this->dataFolder ); 20 | 21 | $this->load (); 22 | } 23 | public function load() { 24 | $this->data = (new Config ( $this->dataFolder . $this->userName . ".json", Config::JSON, [ ] ))->getAll (); 25 | } 26 | public function save($async = false) { 27 | $data = new Config ( $this->dataFolder . $this->userName . ".json", Config::JSON ); 28 | $data->setAll ( $this->data ); 29 | $data->save ( $async ); 30 | } 31 | public function setIp($ip) { 32 | $this->data ["ip"] = $ip; 33 | } 34 | public function setPassWordHash($hash) { 35 | $this->data ["password"] = $hash; 36 | } 37 | public function setUUID($uuid) { 38 | $this->data ["uuid"] = $uuid; 39 | } 40 | public function getIp() { 41 | return $this->data ["ip"]; 42 | } 43 | public function getPassWordHash() { 44 | return $this->data ["password"]; 45 | } 46 | public function getUUID() { 47 | return $this->data ["uuid"]; 48 | } 49 | public function logout(Player $player) { 50 | $this->setIp ( $player ); 51 | $this->setUUID ( $player->getUniqueId () ); 52 | } 53 | } 54 | 55 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/authdata/AuthDataLoader.php: -------------------------------------------------------------------------------- 1 | server = Server::getInstance (); 33 | $this->plugin = $plugin; 34 | 35 | $this->server->getScheduler ()->scheduleRepeatingTask ( new AutoUnloadTask ( $this ), 12000 ); 36 | } 37 | /** 38 | * Create a default setting 39 | * 40 | * @param string $userName 41 | */ 42 | public function loadAuth($userName) { 43 | $userName = strtolower ( $userName ); 44 | $alpha = substr ( $userName, 0, 1 ); 45 | 46 | if (isset ( $this->users [$userName] )) 47 | return $this->users [$userName]; 48 | 49 | if (! file_exists ( $this->plugin->getDataFolder () . "player/" )) 50 | @mkdir ( $this->plugin->getDataFolder () . "player/" ); 51 | 52 | return $this->users [$userName] = new AuthData ( $userName, $this->plugin->getDataFolder () . "player/" ); 53 | } 54 | public function unloadAuth($userName = null) { 55 | if ($userName === null) { 56 | foreach ( $this->users as $userName => $authData ) { 57 | if ($this->users [$userName] instanceof AuthData) 58 | $this->users [$userName]->save ( true ); 59 | unset ( $this->users [$userName] ); 60 | } 61 | return true; 62 | } 63 | 64 | $userName = strtolower ( $userName ); 65 | if (! isset ( $this->users [$userName] )) 66 | return false; 67 | if ($this->users [$userName] instanceof AuthData) { 68 | $this->users [$userName]->save ( true ); 69 | } 70 | unset ( $this->users [$userName] ); 71 | return true; 72 | } 73 | public function removeAuth($userName) { 74 | $this->unloadAuth ( $userName ); 75 | @unlink ( $this->plugin->getDataFolder () . "player/" . $userName . ".json" ); 76 | } 77 | /** 78 | * Get Auth Data 79 | * 80 | * @param Player $player 81 | * @return AuthData 82 | */ 83 | public function getAuth(Player $player) { 84 | $userName = strtolower ( $player->getName () ); 85 | if (! isset ( $this->users [$userName] )) 86 | $this->loadAuth ( $userName ); 87 | return $this->users [$userName]; 88 | } 89 | /** 90 | * Get Auth Data 91 | * 92 | * @param string $player 93 | * @return AuthData 94 | */ 95 | public function getAuthToName($name) { 96 | $userName = strtolower ( $name ); 97 | if (! isset ( $this->users [$userName] )) 98 | $this->loadAuth ( $userName ); 99 | return $this->users [$userName]; 100 | } 101 | public function checkToExistDataToName($name) { 102 | $userName = strtolower ( $name ); 103 | return isset ( $this->users [$userName] ) ? true : false; 104 | } 105 | public function save($async = false) { 106 | foreach ( $this->users as $userName => $authData ) 107 | if ($authData instanceof AuthData) 108 | $authData->save ( $async ); 109 | } 110 | /** 111 | * 112 | * @return AreaLoader 113 | */ 114 | public static function getInstance() { 115 | return static::$instance; 116 | } 117 | } 118 | 119 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/authdata/AuthDataProvider.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 35 | $this->loader = $plugin->getAuthLoader (); 36 | $this->server = Server::getInstance (); 37 | } 38 | 39 | /** 40 | * Create a default setting 41 | * 42 | * @param string $userName 43 | */ 44 | public function loadAuth($userName) { 45 | return $this->loader->loadAuth ( $userName ); 46 | } 47 | public function unloadAuth($userName = null) { 48 | return $this->loader->unloadAuth ( $userName ); 49 | } 50 | public function removeAuth($userName) { 51 | return $this->loader->removeAuth ( $userName ); 52 | } 53 | /** 54 | * Get Auth Data 55 | * 56 | * @param Player $player 57 | * @return AuthData 58 | */ 59 | public function getAuth(Player $player) { 60 | return $this->loader->getAuth ( $player ); 61 | } 62 | /** 63 | * Get Auth Data 64 | * 65 | * @param string $player 66 | * @return AuthData 67 | */ 68 | public function getAuthToName($name) { 69 | return $this->loader->getAuthToName ( $name ); 70 | } 71 | public function checkToExistDataToName($name) { 72 | return $this->loader->checkToExistDataToName ( $name ); 73 | } 74 | public static function getInstance() { 75 | return static::$instance; 76 | } 77 | } 78 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/database/PluginData.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 39 | $this->server = Server::getInstance (); 40 | $this->messages = $this->initMessage (); 41 | $this->db = $this->initDatabase (); 42 | } 43 | /** 44 | * Register the plug-in command 45 | * 46 | * @param string $name 47 | * @param string $permission 48 | * @param string $description 49 | * @param string $usage 50 | */ 51 | public function registerCommand($name, $permission, $description = "", $usage = "") { 52 | $commandMap = $this->getServer ()->getCommandMap (); 53 | $command = new PluginCommand ( $name, $this->plugin ); 54 | $command->setDescription ( $description ); 55 | $command->setPermission ( $permission ); 56 | $command->setUsage ( $usage ); 57 | $commandMap->register ( $name, $command ); 58 | return $command; 59 | } 60 | /** 61 | * Gets a translated message 62 | * 63 | * @param string $var 64 | */ 65 | public function get($var) { 66 | if (isset ( $this->messages [$this->getServer ()->getLanguage ()->getLang ()] )) { 67 | $lang = $this->getServer ()->getLanguage ()->getLang (); 68 | } else { 69 | return null; 70 | } 71 | return $this->messages [$lang . "-" . $var]; 72 | } 73 | /** 74 | * Print the message 75 | * 76 | * @param CommandSender $player 77 | * @param string $text 78 | * @param string $mark 79 | */ 80 | public function message(CommandSender $player, $text = "", $mark = null) { 81 | if ($mark == null) 82 | $mark = $this->get ( "default-prefix" ); 83 | $player->sendMessage ( TextFormat::DARK_AQUA . $mark . " " . $text ); 84 | } 85 | /** 86 | * Print the alert 87 | * 88 | * @param CommandSender $player 89 | * @param string $text 90 | * @param string $mark 91 | */ 92 | public function alert(CommandSender $player, $text = "", $mark = null) { 93 | if ($mark == null) 94 | $mark = $this->get ( "default-prefix" ); 95 | $player->sendMessage ( TextFormat::RED . $mark . " " . $text ); 96 | } 97 | /** 98 | * Save the message file to the server 99 | */ 100 | public function initMessage() { 101 | $this->getPlugin ()->saveResource ( "messages.yml", false ); 102 | $this->messagesUpdate ( "messages.yml" ); 103 | return (new Config ( $this->getPlugin ()->getDataFolder () . "messages.yml", Config::YAML ))->getAll (); 104 | } 105 | /** 106 | * Save the database file (.json) to the server 107 | */ 108 | public function initDatabase() { 109 | @mkdir ( $this->getPlugin ()->getDataFolder () ); 110 | return (new Config ( $this->getPlugin ()->getDataFolder () . "pluginDB.json", Config::JSON, [ ] ))->getAll (); 111 | } 112 | /** 113 | * Updating the message file stored at the server 114 | * 115 | * @param string $targetYmlName 116 | */ 117 | public function messagesUpdate($targetYmlName) { 118 | $targetYml = (new Config ( $this->getPlugin ()->getDataFolder () . $targetYmlName, Config::YAML ))->getAll (); 119 | if (! isset ( $targetYml ["m_version"] )) { 120 | $this->getPlugin ()->saveResource ( $targetYmlName, true ); 121 | } else if ($targetYml ["m_version"] < $this->m_version) { 122 | $this->getPlugin ()->saveResource ( $targetYmlName, true ); 123 | } 124 | } 125 | /** 126 | * Save plug-in database 127 | * 128 | * @param boolean $async 129 | */ 130 | public function save($async = false) { 131 | $save = new Config ( $this->getPlugin ()->getDataFolder () . "pluginDB.json", Config::JSON ); 132 | $save->setAll ( $this->db ); 133 | $save->save ( $async ); 134 | } 135 | /** 136 | * Return the server instance 137 | * 138 | * @return Server 139 | */ 140 | private function getServer() { 141 | return $this->server; 142 | } 143 | /** 144 | * Return the plug-in instance 145 | */ 146 | private function getPlugin() { 147 | return $this->plugin; 148 | } 149 | /** 150 | * Return this plug-in database instance 151 | */ 152 | public static function getInstance() { 153 | return static::$instance; 154 | } 155 | public function addAuthReady($name, $hash) { 156 | $name = strtolower ( $name ); 157 | if (AuthDataProvider::getInstance ()->checkToExistDataToName ( $name ) != false) 158 | return; 159 | if (! isset ( $this->db ["authready"] [$name] )) 160 | $this->db ["authready"] [$name] = $hash; 161 | } 162 | public function checkAuthReady($name) { 163 | $name = strtolower ( $name ); 164 | return isset ( $this->db ["authready"] [$name] ) ? true : false; 165 | } 166 | public function completeAuthReady($name) { 167 | $name = strtolower ( $name ); 168 | if (isset ( $this->db ["authready"] [$name] )) 169 | unset ( $this->db ["authready"] [$name] ); 170 | } 171 | } 172 | 173 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/event/PlayerLoginEvent.php: -------------------------------------------------------------------------------- 1 | player = $player; 25 | parent::__construct ( $plugin ); 26 | } 27 | 28 | /** 29 | * 30 | * @return Player 31 | */ 32 | public function getPlayer() { 33 | return $this->player; 34 | } 35 | } 36 | 37 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/event/PlayerLogoutEvent.php: -------------------------------------------------------------------------------- 1 | player = $player; 24 | parent::__construct ( $plugin ); 25 | } 26 | 27 | /** 28 | * 29 | * @return IPlayer 30 | */ 31 | public function getPlayer() { 32 | return $this->player; 33 | } 34 | } 35 | 36 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/event/PlayerRegisterEvent.php: -------------------------------------------------------------------------------- 1 | player = $player; 25 | parent::__construct ( $plugin ); 26 | } 27 | 28 | /** 29 | * 30 | * @return IPlayer 31 | */ 32 | public function getPlayer() { 33 | return $this->player; 34 | } 35 | } 36 | 37 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/event/PlayerUnRegisterEvent.php: -------------------------------------------------------------------------------- 1 | player = $player; 25 | parent::__construct ( $plugin ); 26 | } 27 | 28 | /** 29 | * 30 | * @return IPlayer 31 | */ 32 | public function getPlayer() { 33 | return $this->player; 34 | } 35 | } 36 | 37 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/event/UUIDAuthEvent.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/importer/EmailAuth/EmailAuthImporter.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/importer/SimpleAuth/DataProvider.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | namespace ifteam\UUIDAuth\importer\SimpleAuth; 18 | 19 | use pocketmine\IPlayer; 20 | 21 | interface DataProvider { 22 | 23 | /** 24 | * 25 | * @param IPlayer $player 26 | * 27 | * @return array, or null if it does not exist 28 | */ 29 | public function getPlayer(IPlayer $player); 30 | 31 | /** 32 | * 33 | * @param IPlayer $player 34 | * 35 | * @return bool 36 | */ 37 | public function isPlayerRegistered(IPlayer $player); 38 | 39 | /** 40 | * 41 | * @param IPlayer $player 42 | * @param string $hash 43 | * 44 | * @return array, or null if error happened 45 | */ 46 | public function registerPlayer(IPlayer $player, $hash); 47 | 48 | /** 49 | * 50 | * @param IPlayer $player 51 | */ 52 | public function unregisterPlayer(IPlayer $player); 53 | 54 | /** 55 | * 56 | * @param IPlayer $player 57 | * @param array $config 58 | */ 59 | public function savePlayer(IPlayer $player, array $config); 60 | 61 | /** 62 | * 63 | * @param IPlayer $player 64 | * @param string $lastId 65 | * @param int $loginDate 66 | */ 67 | public function updatePlayer(IPlayer $player, $lastId = null, $loginDate = null); 68 | public function close(); 69 | } 70 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/importer/SimpleAuth/DummyDataProvider.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | namespace ifteam\UUIDAuth\importer\SimpleAuth; 18 | 19 | use pocketmine\IPlayer; 20 | use pocketmine\plugin\Plugin; 21 | 22 | class DummyDataProvider implements DataProvider { 23 | 24 | /** 25 | * 26 | * @var EmailAuth 27 | */ 28 | protected $plugin; 29 | public function __construct(Plugin $plugin) { 30 | $this->plugin = $plugin; 31 | } 32 | public function getPlayer(IPlayer $player) { 33 | return null; 34 | } 35 | public function isPlayerRegistered(IPlayer $player) { 36 | return false; 37 | } 38 | public function registerPlayer(IPlayer $player, $hash) { 39 | return null; 40 | } 41 | public function unregisterPlayer(IPlayer $player) { 42 | } 43 | public function savePlayer(IPlayer $player, array $config) { 44 | } 45 | public function updatePlayer(IPlayer $player, $lastIP = null, $loginDate = null) { 46 | } 47 | public function close() { 48 | } 49 | } -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/importer/SimpleAuth/MySQLDataProvider.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | namespace ifteam\UUIDAuth\importer\SimpleAuth; 18 | 19 | use pocketmine\IPlayer; 20 | use pocketmine\plugin\Plugin; 21 | 22 | class MySQLDataProvider implements DataProvider { 23 | 24 | /** 25 | * 26 | * @var Plugin 27 | */ 28 | protected $plugin; 29 | 30 | /** 31 | * 32 | * @var \mysqli 33 | */ 34 | protected $database; 35 | public function __construct(Plugin $plugin) { 36 | $this->plugin = $plugin; 37 | $config = $this->plugin->getConfig ()->get ( "dataProviderSettings" ); 38 | 39 | if (! isset ( $config ["host"] ) or ! isset ( $config ["user"] ) or ! isset ( $config ["password"] ) or ! isset ( $config ["database"] )) { 40 | $this->plugin->getLogger ()->critical ( "Invalid MySQL settings" ); 41 | $this->plugin->setDataProvider ( new DummyDataProvider ( $this->plugin ) ); 42 | return; 43 | } 44 | 45 | $this->database = new \mysqli ( $config ["host"], $config ["user"], $config ["password"], $config ["database"], isset ( $config ["port"] ) ? $config ["port"] : 3306 ); 46 | if ($this->database->connect_error) { 47 | $this->plugin->getLogger ()->critical ( "Couldn't connect to MySQL: " . $this->database->connect_error ); 48 | $this->plugin->setDataProvider ( new DummyDataProvider ( $this->plugin ) ); 49 | return; 50 | } 51 | 52 | $resource = $this->plugin->getResource ( "mysql.sql" ); 53 | $this->database->query ( stream_get_contents ( $resource ) ); 54 | fclose ( $resource ); 55 | 56 | $this->plugin->getServer ()->getScheduler ()->scheduleRepeatingTask ( new MySQLPingTask ( $this->plugin, $this->database ), 600 ); // Each 30 seconds 57 | $this->plugin->getLogger ()->info ( "Connected to MySQL server" ); 58 | } 59 | public function getPlayer(IPlayer $player) { 60 | $name = trim ( strtolower ( $player->getName () ) ); 61 | 62 | $result = $this->database->query ( "SELECT * FROM simpleauth_players WHERE name = '" . $this->database->escape_string ( $name ) . "'" ); 63 | 64 | if ($result instanceof \mysqli_result) { 65 | $data = $result->fetch_assoc (); 66 | $result->free (); 67 | if (isset ( $data ["name"] ) and strtolower ( $data ["name"] ) === $name) { 68 | unset ( $data ["name"] ); 69 | return $data; 70 | } 71 | } 72 | 73 | return null; 74 | } 75 | public function isPlayerRegistered(IPlayer $player) { 76 | return $this->getPlayer ( $player ) !== null; 77 | } 78 | public function unregisterPlayer(IPlayer $player) { 79 | $name = trim ( strtolower ( $player->getName () ) ); 80 | $this->database->query ( "DELETE FROM simpleauth_players WHERE name = '" . $this->database->escape_string ( $name ) . "'" ); 81 | } 82 | public function registerPlayer(IPlayer $player, $hash) { 83 | $name = trim ( strtolower ( $player->getName () ) ); 84 | $data = [ 85 | "registerdate" => time (), 86 | "logindate" => time (), 87 | "lastip" => null, 88 | "hash" => $hash 89 | ]; 90 | 91 | $this->database->query ( "INSERT INTO simpleauth_players 92 | (name, registerdate, logindate, lastip, hash) 93 | VALUES 94 | ('" . $this->database->escape_string ( $name ) . "', " . intval ( $data ["registerdate"] ) . ", " . intval ( $data ["logindate"] ) . ", '', '" . $hash . "') 95 | " ); 96 | 97 | return $data; 98 | } 99 | public function savePlayer(IPlayer $player, array $config) { 100 | $name = trim ( strtolower ( $player->getName () ) ); 101 | $this->database->query ( "UPDATE simpleauth_players SET registerdate = " . intval ( $config ["registerdate"] ) . ", logindate = " . intval ( $config ["logindate"] ) . ", lastip = '" . $this->database->escape_string ( $config ["lastip"] ) . "', hash = '" . $this->database->escape_string ( $config ["hash"] ) . "' WHERE name = '" . $this->database->escape_string ( $name ) . "'" ); 102 | } 103 | public function updatePlayer(IPlayer $player, $lastIP = null, $loginDate = null) { 104 | $name = trim ( strtolower ( $player->getName () ) ); 105 | if ($lastIP !== null) { 106 | $this->database->query ( "UPDATE simpleauth_players SET lastip = '" . $this->database->escape_string ( $lastIP ) . "' WHERE name = '" . $this->database->escape_string ( $name ) . "'" ); 107 | } 108 | if ($loginDate !== null) { 109 | $this->database->query ( "UPDATE simpleauth_players SET logindate = " . intval ( $loginDate ) . " WHERE name = '" . $this->database->escape_string ( $name ) . "'" ); 110 | } 111 | } 112 | public function close() { 113 | $this->database->close (); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/importer/SimpleAuth/MySQLPingTask.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | namespace ifteam\UUIDAuth\importer\SimpleAuth; 18 | 19 | use pocketmine\scheduler\PluginTask; 20 | use pocketmine\plugin\Plugin; 21 | 22 | class MySQLPingTask extends PluginTask { 23 | 24 | /** 25 | * 26 | * @var \mysqli 27 | */ 28 | private $database; 29 | public function __construct(Plugin $owner, \mysqli $database) { 30 | parent::__construct ( $owner ); 31 | $this->database = $database; 32 | } 33 | public function onRun($currentTick) { 34 | $this->database->ping (); 35 | } 36 | } 37 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/importer/SimpleAuth/SQLite3DataProvider.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | namespace ifteam\UUIDAuth\importer\SimpleAuth; 18 | 19 | use pocketmine\IPlayer; 20 | use pocketmine\plugin\Plugin; 21 | 22 | class SQLite3DataProvider implements DataProvider { 23 | 24 | /** 25 | * 26 | * @var SimpleAuth 27 | */ 28 | protected $plugin; 29 | 30 | /** 31 | * 32 | * @var \SQLite3 33 | */ 34 | protected $database; 35 | public function __construct(Plugin $plugin) { 36 | $this->plugin = $plugin; 37 | if (! file_exists ( $this->plugin->getDataFolder () . "players.db" )) { 38 | $this->database = new \SQLite3 ( $this->plugin->getDataFolder () . "players.db", SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE ); 39 | $resource = $this->plugin->getResource ( "sqlite3.sql" ); 40 | $this->database->exec ( stream_get_contents ( $resource ) ); 41 | fclose ( $resource ); 42 | } else { 43 | $this->database = new \SQLite3 ( $this->plugin->getDataFolder () . "players.db", SQLITE3_OPEN_READWRITE ); 44 | } 45 | } 46 | public function getPlayer(IPlayer $player) { 47 | $name = trim ( strtolower ( $player->getName () ) ); 48 | 49 | $prepare = $this->database->prepare ( "SELECT * FROM players WHERE name = :name" ); 50 | $prepare->bindValue ( ":name", $name, SQLITE3_TEXT ); 51 | 52 | $result = $prepare->execute (); 53 | 54 | if ($result instanceof \SQLite3Result) { 55 | $data = $result->fetchArray ( SQLITE3_ASSOC ); 56 | $result->finalize (); 57 | if (isset ( $data ["name"] ) and $data ["name"] === $name) { 58 | unset ( $data ["name"] ); 59 | $prepare->close (); 60 | return $data; 61 | } 62 | } 63 | $prepare->close (); 64 | 65 | return null; 66 | } 67 | public function isPlayerRegistered(IPlayer $player) { 68 | return $this->getPlayer ( $player ) !== null; 69 | } 70 | public function unregisterPlayer(IPlayer $player) { 71 | $name = trim ( strtolower ( $player->getName () ) ); 72 | $prepare = $this->database->prepare ( "DELETE FROM players WHERE name = :name" ); 73 | $prepare->bindValue ( ":name", $name, SQLITE3_TEXT ); 74 | $prepare->execute (); 75 | } 76 | public function registerPlayer(IPlayer $player, $hash) { 77 | $name = trim ( strtolower ( $player->getName () ) ); 78 | $data = [ 79 | "registerdate" => time (), 80 | "logindate" => time (), 81 | "lastip" => null, 82 | "hash" => $hash 83 | ]; 84 | $prepare = $this->database->prepare ( "INSERT INTO players (name, registerdate, logindate, lastip, hash) VALUES (:name, :registerdate, :logindate, :lastip, :hash)" ); 85 | $prepare->bindValue ( ":name", $name, SQLITE3_TEXT ); 86 | $prepare->bindValue ( ":registerdate", $data ["registerdate"], SQLITE3_INTEGER ); 87 | $prepare->bindValue ( ":logindate", $data ["logindate"], SQLITE3_INTEGER ); 88 | $prepare->bindValue ( ":lastip", null, SQLITE3_TEXT ); 89 | $prepare->bindValue ( ":hash", $hash, SQLITE3_TEXT ); 90 | $prepare->execute (); 91 | 92 | return $data; 93 | } 94 | public function savePlayer(IPlayer $player, array $config) { 95 | $name = trim ( strtolower ( $player->getName () ) ); 96 | $prepare = $this->database->prepare ( "UPDATE players SET registerdate = :registerdate, logindate = :logindate, lastip = :lastip, hash = :hash WHERE name = :name" ); 97 | $prepare->bindValue ( ":name", $name, SQLITE3_TEXT ); 98 | $prepare->bindValue ( ":registerdate", $config ["registerdate"], SQLITE3_INTEGER ); 99 | $prepare->bindValue ( ":logindate", $config ["logindate"], SQLITE3_INTEGER ); 100 | $prepare->bindValue ( ":lastip", $config ["lastip"], SQLITE3_TEXT ); 101 | $prepare->bindValue ( ":hash", $config ["hash"], SQLITE3_TEXT ); 102 | $prepare->execute (); 103 | } 104 | public function updatePlayer(IPlayer $player, $lastIP = null, $loginDate = null) { 105 | $name = trim ( strtolower ( $player->getName () ) ); 106 | if ($lastIP !== null) { 107 | $prepare = $this->database->prepare ( "UPDATE players SET lastip = :lastip WHERE name = :name" ); 108 | $prepare->bindValue ( ":name", $name, SQLITE3_TEXT ); 109 | $prepare->bindValue ( ":lastip", $lastIP, SQLITE3_TEXT ); 110 | $prepare->execute (); 111 | } 112 | if ($loginDate !== null) { 113 | $prepare = $this->database->prepare ( "UPDATE players SET logindate = :logindate WHERE name = :name" ); 114 | $prepare->bindValue ( ":name", $name, SQLITE3_TEXT ); 115 | $prepare->bindValue ( ":logindate", $loginDate, SQLITE3_TEXT ); 116 | $prepare->execute (); 117 | } 118 | } 119 | public function close() { 120 | $this->database->close (); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/importer/SimpleAuth/SimpleAuthImporter.php: -------------------------------------------------------------------------------- 1 | getDataFolder () . "SimpleAuth/players" )) 12 | return; 13 | $config = (new Config ( $plugin->getDataFolder () . "SimpleAuth/config.yml", Config::YAML ))->getAll (); 14 | $provider = $config ["dataProvider"]; 15 | switch (strtolower ( $provider )) { 16 | case "yaml" : 17 | $plugin->getLogger ()->debug ( "Using YAML data provider" ); 18 | $provider = new YAMLDataProvider ( $plugin ); 19 | break; 20 | case "sqlite3" : 21 | $plugin->getLogger ()->debug ( "Using SQLite3 data provider" ); 22 | $provider = new SQLite3DataProvider ( $plugin ); 23 | break; 24 | case "mysql" : 25 | $plugin->getLogger ()->debug ( "Using MySQL data provider" ); 26 | $provider = new MySQLDataProvider ( $plugin ); 27 | break; 28 | case "none" : 29 | default : 30 | $provider = new DummyDataProvider ( $plugin ); 31 | break; 32 | } 33 | $folderList = self::getFolderList ( $plugin->getDataFolder () . "SimpleAuth/players", "folder" ); 34 | foreach ( $folderList as $alphabet ) { 35 | $ymlList = self::getFolderList ( $plugin->getDataFolder () . "SimpleAuth/players/" . $alphabet, "file" ); 36 | foreach ( $ymlList as $ymlName ) { 37 | $yml = (new Config ( $plugin->getDataFolder () . "SimpleAuth/players/" . $alphabet . "/" . $ymlName, Config::YAML ))->getAll (); 38 | $name = explode ( ".", $ymlName ) [0]; 39 | if ($db instanceof PluginData) 40 | $db->addAuthReady ( mb_convert_encoding ( $name, "UTF-8" ), $yml ["hash"] ); 41 | } 42 | } 43 | self::rmdirAll ( $plugin->getDataFolder () . "SimpleAuth" ); 44 | } 45 | /** 46 | * 47 | * It gets a list of folders or files 48 | * 49 | * @param string $rootDir 50 | * @param string $filter 51 | * = "folder" || "file" || null 52 | * 53 | * @return array $rList 54 | */ 55 | public function getFolderList($rootDir, $filter = "") { 56 | $handler = opendir ( $rootDir ); 57 | $rList = array (); 58 | $fCounter = 0; 59 | while ( $file = readdir ( $handler ) ) { 60 | if ($file != '.' && $file != '..') { 61 | if ($filter == "folder") { 62 | if (is_dir ( $rootDir . "/" . $file )) { 63 | $rList [$fCounter ++] = $file; 64 | } 65 | } else if ($filter == "file") { 66 | if (! is_dir ( $rootDir . "/" . $file )) { 67 | $rList [$fCounter ++] = $file; 68 | } 69 | } else { 70 | $rList [$fCounter ++] = $file; 71 | } 72 | } 73 | } 74 | closedir ( $handler ); 75 | return $rList; 76 | } 77 | /** 78 | * 79 | * Delete the folder to the subfolders 80 | * 81 | * @param string $dir 82 | * 83 | */ 84 | public function rmdirAll($dir) { 85 | $dirs = dir ( $dir ); 86 | while ( false !== ($entry = $dirs->read ()) ) { 87 | if (($entry != '.') && ($entry != '..')) { 88 | if (is_dir ( $dir . '/' . $entry )) { 89 | self::rmdirAll ( $dir . '/' . $entry ); 90 | } else { 91 | @unlink ( $dir . '/' . $entry ); 92 | } 93 | } 94 | } 95 | $dirs->close (); 96 | @rmdir ( $dir ); 97 | } 98 | } 99 | 100 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/importer/SimpleAuth/YAMLDataProvider.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | */ 17 | namespace ifteam\UUIDAuth\importer\SimpleAuth; 18 | 19 | use pocketmine\IPlayer; 20 | use pocketmine\utils\Config; 21 | use pocketmine\plugin\Plugin; 22 | 23 | class YAMLDataProvider implements DataProvider { 24 | 25 | /** 26 | * 27 | * @var Plugin 28 | */ 29 | protected $plugin; 30 | public function __construct(Plugin $plugin) { 31 | $this->plugin = $plugin; 32 | if (! file_exists ( $this->plugin->getDataFolder () . "players/" )) { 33 | @mkdir ( $this->plugin->getDataFolder () . "players/" ); 34 | } 35 | } 36 | public function getPlayer(IPlayer $player) { 37 | $name = trim ( strtolower ( $player->getName () ) ); 38 | if ($name === "") { 39 | return null; 40 | } 41 | $path = $this->plugin->getDataFolder () . "players/" . $name {0} . "/$name.yml"; 42 | if (! file_exists ( $path )) { 43 | return null; 44 | } else { 45 | $config = new Config ( $path, Config::YAML ); 46 | return $config->getAll (); 47 | } 48 | } 49 | public function isPlayerRegistered(IPlayer $player) { 50 | $name = trim ( strtolower ( $player->getName () ) ); 51 | 52 | return file_exists ( $this->plugin->getDataFolder () . "players/" . $name {0} . "/$name.yml" ); 53 | } 54 | public function unregisterPlayer(IPlayer $player) { 55 | $name = trim ( strtolower ( $player->getName () ) ); 56 | @unlink ( $this->plugin->getDataFolder () . "players/" . $name {0} . "/$name.yml" ); 57 | } 58 | public function registerPlayer(IPlayer $player, $hash) { 59 | $name = trim ( strtolower ( $player->getName () ) ); 60 | @mkdir ( $this->plugin->getDataFolder () . "players/" . $name {0} . "/" ); 61 | $data = new Config ( $this->plugin->getDataFolder () . "players/" . $name {0} . "/$name.yml", Config::YAML ); 62 | $data->set ( "registerdate", time () ); 63 | $data->set ( "logindate", time () ); 64 | $data->set ( "lastip", null ); 65 | $data->set ( "hash", $hash ); 66 | $data->save (); 67 | 68 | return $data->getAll (); 69 | } 70 | public function savePlayer(IPlayer $player, array $config) { 71 | $name = trim ( strtolower ( $player->getName () ) ); 72 | $data = new Config ( $this->plugin->getDataFolder () . "players/" . $name {0} . "/$name.yml", Config::YAML ); 73 | $data->setAll ( $config ); 74 | $data->save (); 75 | } 76 | public function updatePlayer(IPlayer $player, $lastIP = null, $loginDate = null) { 77 | $data = $this->getPlayer ( $player ); 78 | if ($data !== null) { 79 | if ($lastIP !== null) { 80 | $data ["lastip"] = $lastIP; 81 | } 82 | if ($loginDate !== null) { 83 | $data ["logindate"] = $loginDate; 84 | } 85 | $this->savePlayer ( $player, $data ); 86 | } 87 | } 88 | public function close() { 89 | } 90 | } -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/listener/EventListener.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 24 | $this->db = PluginData::getInstance (); 25 | $this->server = Server::getInstance (); 26 | $this->getServer ()->getPluginManager ()->registerEvents ( $this, $plugin ); 27 | } 28 | public function getServer() { 29 | return $this->server; 30 | } 31 | } 32 | 33 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/task/AutoSaveTask.php: -------------------------------------------------------------------------------- 1 | getOwner ()->save ( true ); 15 | } 16 | } 17 | ?> -------------------------------------------------------------------------------- /src/ifteam/UUIDAuth/task/AutoUnloadTask.php: -------------------------------------------------------------------------------- 1 | owner = $owner; 12 | } 13 | public function onRun($currentTick) { 14 | $this->owner->unloadAuth (); 15 | } 16 | } 17 | ?> --------------------------------------------------------------------------------