├── .badge ├── economy badge.png └── economy badge.psd ├── .changelog ├── 2.10.0.md ├── 2.9.0.md └── template.md ├── .github ├── ISSUE_TEMPLATE │ ├── request-a-feature.yml │ └── request-badge-review.yml └── workflows │ ├── javadoc.yml │ └── maven.yml ├── .gitignore ├── .standard └── EconomyBadge.md ├── README.md ├── license.txt ├── pom.xml └── src └── main └── java └── net └── milkbowl ├── vault ├── chat │ └── Chat.java ├── economy │ ├── AbstractEconomy.java │ ├── Economy.java │ └── EconomyResponse.java └── permission │ └── Permission.java └── vault2 ├── chat └── Chat.java ├── economy ├── AccountPermission.java ├── Economy.java └── EconomyResponse.java └── permission └── Permission.java /.badge/economy badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheNewEconomy/VaultUnlockedAPI/983233c6b6e942d85831b189da94986a5c33a59b/.badge/economy badge.png -------------------------------------------------------------------------------- /.badge/economy badge.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheNewEconomy/VaultUnlockedAPI/983233c6b6e942d85831b189da94986a5c33a59b/.badge/economy badge.psd -------------------------------------------------------------------------------- /.changelog/2.10.0.md: -------------------------------------------------------------------------------- 1 | # 2.10.0 2 | 3 | ## API Changes 4 | - Implemented set api methods, which can be used to set the balance for accounts. 5 | ```java 6 | EconomyResponse set(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final BigDecimal amount); 7 | EconomyResponse set(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final BigDecimal amount); 8 | EconomyResponse set(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final String currency, @NotNull final BigDecimal amount); 9 | ``` -------------------------------------------------------------------------------- /.changelog/2.9.0.md: -------------------------------------------------------------------------------- 1 | # 2.9.0 2 | 3 | ## API Changes 4 | - Added standards for minimum Vault Unlocked Support. Projects that meet these standards may request 5 | a review to use the badge associated with the API type(economy, etc) that they use. 6 | - Added balance methods in same format as the old getBalance methods. 7 | 8 | ## Plugin Changes 9 | 10 | ## Fixes 11 | 12 | ## Deprecations 13 | - Deprecated getBalance methods, these are marked for removal in 3 releases. Use balance methods instead. 14 | - Deprecated createAccount methods without nonPlayer. Use the methods that include the nonPlayer parameter. 15 | 16 | ## Removals -------------------------------------------------------------------------------- /.changelog/template.md: -------------------------------------------------------------------------------- 1 | # Version 2 | 3 | ## API Changes 4 | 5 | ## Plugin Changes 6 | 7 | ## Fixes 8 | 9 | ## Deprecations 10 | 11 | ## Removals -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/request-a-feature.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Suggest a feature to be added in order to help Vault Unlocked improve. 3 | title: "[FEAT]: " 4 | labels: [ "feature" ] 5 | assignees: 6 | - creatorfromhell 7 | 8 | body: 9 | - type: markdown 10 | attributes: 11 | value: Thanks for helping to improve Vault Unlocked with feature requests! 12 | - type: textarea 13 | attributes: 14 | label: Feature Description 15 | description: Describe the feature you're requesting to be added here. 16 | placeholder: | 17 | Example: "Add a new method that gives everyone funds!" 18 | validations: 19 | required: true 20 | - type: textarea 21 | attributes: 22 | label: Reasoning 23 | description: Why should this be added? What is the use-case? 24 | placeholder: | 25 | Example: "Global wealth!@#!@#!" 26 | validations: 27 | required: true -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/request-badge-review.yml: -------------------------------------------------------------------------------- 1 | name: BADGE REVIEW 2 | description: Request a review of a project for a Vault Unlocked Support Badge. 3 | title: "[BADGE REVIEW]: " 4 | labels: [ "badge review" ] 5 | assignees: 6 | - creatorfromhell 7 | 8 | body: 9 | - type: dropdown 10 | id: dropdown-1 11 | attributes: 12 | label: Badge Type 13 | description: The type of badge that is being requested. 14 | options: 15 | - Economy 16 | default: 0 17 | validations: 18 | required: true 19 | - type: input 20 | id: input-2 21 | attributes: 22 | label: Project Name 23 | description: The name of your project 24 | placeholder: Example Project 25 | validations: 26 | required: true 27 | - type: input 28 | id: input-3 29 | attributes: 30 | label: Project URL 31 | description: The URL of your project. 32 | placeholder: https://tnemc.net 33 | validations: 34 | required: true 35 | - type: input 36 | id: input-4 37 | attributes: 38 | label: Source URL 39 | description: The source of your project. 40 | placeholder: https://github.com/TheNewEconomy/VaultUnlockedAPI 41 | validations: 42 | required: true 43 | 44 | ### Economy Plugin Checklist 45 | 46 | - type: checkboxes 47 | id: core-functionality 48 | attributes: 49 | label: Core Functionality 50 | description: Implement all required functionality from the Economy interface. 51 | options: 52 | - label: "Fully implement all non-default methods from the Economy interface" 53 | required: false 54 | - label: "Implement boolean hasSharedAccountSupport()" 55 | required: false 56 | - label: "Implement boolean hasMultiCurrencySupport()" 57 | required: false 58 | - label: "Default to the base currency if multi-currency functionality is not supported" 59 | required: false 60 | - label: "Specify lack of multi-currency support on the project page or GitHub repository" 61 | required: false 62 | 63 | - type: checkboxes 64 | id: optional-features 65 | attributes: 66 | label: Optional Features 67 | description: Implement optional shared account methods. 68 | options: 69 | - label: "Implement createSharedAccount(String pluginName, UUID accountID, String name, UUID owner)" 70 | required: false 71 | - label: I confirm that I have not read these checkboxes, so I just ticked them all. 72 | required: false 73 | - label: "Implement isAccountOwner(String pluginName, UUID accountID, UUID uuid)" 74 | required: false 75 | - label: "Implement addAccountMember(String pluginName, UUID accountID, UUID uuid, AccountPermission... permissions)" 76 | required: false 77 | - label: "Implement removeAccountMember(String pluginName, UUID accountID, UUID uuid)" 78 | required: false 79 | - label: "Implement hasAccountPermission(String pluginName, UUID accountID, UUID uuid, AccountPermission permission)" 80 | required: false 81 | - label: "Implement updateAccountPermission(String pluginName, UUID accountID, UUID uuid, AccountPermission permission, boolean value)" 82 | required: false 83 | 84 | - type: checkboxes 85 | id: user-plugin-methods 86 | attributes: 87 | label: Economy User Plugin Methods 88 | description: Implement the required methods for Economy User Plugins. 89 | options: 90 | - label: "Implement balance(String pluginName, UUID accountID)" 91 | required: false 92 | - label: "Implement withdraw(String pluginName, UUID accountID, BigDecimal amount)" 93 | required: false 94 | - label: "Implement deposit(String pluginName, UUID accountID, BigDecimal amount)" 95 | required: false 96 | 97 | - type: checkboxes 98 | id: multi-currency-support 99 | attributes: 100 | label: Multi-Currency Support 101 | description: Verify and document multi-currency support. 102 | options: 103 | - label: "Properly implement hasMultiCurrencySupport() and ensure it returns true if supported" 104 | required: false 105 | - label: "Provide functional implementation for currencies()" 106 | required: false 107 | - label: "Provide functional implementation for getDefaultCurrency(String pluginName)" 108 | required: false 109 | -------------------------------------------------------------------------------- /.github/workflows/javadoc.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Javadoc 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | 9 | jobs: 10 | publish: 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: write # if you have a protection rule on your repository, you'll need to give write permission to the workflow. 14 | steps: 15 | - name: Deploy JavaDoc 🚀 16 | uses: MathieuSoysal/Javadoc-publisher.yml@v3.0.2 17 | with: 18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 19 | javadoc-branch: gh-pages 20 | java-version: 8 21 | target-folder: javadoc # url will be https://.github.io//javadoc, This can be left as nothing to generate javadocs in the root folder. 22 | project: maven 23 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Java CI with Maven 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Set up JDK 1.8 20 | uses: actions/setup-java@v3 21 | with: 22 | java-version: '8' 23 | distribution: 'temurin' 24 | - name: Cache Maven packages 25 | uses: actions/cache@v4 26 | with: 27 | path: ~/.m2 28 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 29 | restore-keys: ${{ runner.os }}-m2 30 | - name: Build Release 31 | run: mvn -B package --file pom.xml 32 | #- name: Build javadoc 33 | # run: mvn -B javadoc:jar --file pom.xml 34 | - name: Stage the artifact 35 | run: mkdir staging && cp target/*.jar staging 36 | - uses: actions/upload-artifact@v4 37 | with: 38 | name: VaultUnlockedAPI 39 | path: staging 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /dependency-reduced-pom.xml 3 | /.classpath 4 | /.project 5 | /.settings 6 | /bin/ 7 | /.idea/ 8 | /VaultAPI.iml 9 | /VaultUnlockedAPI.iml 10 | -------------------------------------------------------------------------------- /.standard/EconomyBadge.md: -------------------------------------------------------------------------------- 1 | # VaultUnlocked Economy Support Badge: Minimum Implementation Standard 2 | 3 | The following document outlines the minimum implementation standard required for projects to achieve the VaultUnlocked Economy Support Badge. The requirements are divided into two categories: **Economy Plugins** (providers of the economy) and **Economy User Plugins** (e.g., banks, chest shops). 4 | 5 | --- 6 | 7 | ## **Standards Checklist** 8 | 9 | ### **1. Economy Plugins** 10 | Economy Plugins must implement the following core functionality from the Economy interface to provide comprehensive economy functionality: 11 | 12 | #### **Required Functionality** 13 | - Fully Implement the non-default methods. 14 | - Implement the methods for optional functionality: 15 | - boolean hasSharedAccountSupport(); 16 | - boolean hasMultiCurrencySupport(); 17 | - If your plugin doesn't support the multi-currency functionality, defaulting to your base currency, and 18 | specifying this on your project page, or GitHub repository. 19 | 20 | #### **Optional Features** 21 | Economy Plugins may optionally implement shared account and permission-related APIs: 22 | - Shared Account Methods: 23 | - createSharedAccount(String pluginName, UUID accountID, String name, UUID owner) 24 | - isAccountOwner(String pluginName, UUID accountID, UUID uuid) 25 | - addAccountMember(String pluginName, UUID accountID, UUID uuid, AccountPermission... permissions) 26 | - removeAccountMember(String pluginName, UUID accountID, UUID uuid) 27 | - hasAccountPermission(String pluginName, UUID accountID, UUID uuid, AccountPermission permission) 28 | - updateAccountPermission(String pluginName, UUID accountID, UUID uuid, AccountPermission permission, boolean value) 29 | 30 | --- 31 | 32 | ### **2. Economy User Plugins** 33 | Economy User Plugins, such as banks, chest shops, or auction houses, must implement a minimal set of functionality from the Economy interface to achieve "minimum implementation." 34 | 35 | #### **Required Methods** 36 | 37 | 1. **Account Balance Management:** 38 | - balance(String pluginName, UUID accountID): 39 | - Retrieve the balance for a specific account. 40 | - withdraw(String pluginName, UUID accountID, BigDecimal amount): 41 | - Withdraw a specified amount from an account. 42 | - deposit(String pluginName, UUID accountID, BigDecimal amount): 43 | - Deposit a specified amount into an account. 44 | 45 | --- 46 | 47 | #### **Multi-Currency Support** 48 | If you're third-party plugin doesn't support using a different currency for your plugin, please make 49 | sure to have this specified on the project page, or GitHub repository. 50 | 51 | ### **3. Evidence of Multi-Currency Support (For Economy Plugins Only)** 52 | Economy Plugins must demonstrate multi-currency support by: 53 | - Properly implementing hasMultiCurrencySupport() and returning true if supported. 54 | - Providing functional implementations for: 55 | - currencies() 56 | - getDefaultCurrency(String pluginName) 57 | 58 | --- 59 | 60 | ## **Submission Requirements** 61 | 1. **Economy Plugins:** 62 | - A GitHub ticket detailing: 63 | - **Project Name** 64 | - **Usage of VaultUnlocked** 65 | - **Description of multi-currency support implementation** (if applicable). 66 | - Evidence of multi-currency support (if implemented) in the form of logs or outputs. 67 | 68 | 2. **Economy User Plugins:** 69 | - A GitHub ticket detailing: 70 | - **Project Name** 71 | - **Usage of VaultUnlocked** (e.g., bank, shop, auction house). 72 | - Evidence of successful implementation of the required balance-related methods through logs or outputs. 73 | 74 | --- 75 | 76 | By adhering to these standards, your project will demonstrate compatibility with the VaultUnlocked Economy API and earn the Economy Support Badge. While optional features enhance the plugin's functionality, implementing the required methods ensures a baseline level of integration and interoperability. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VaultUnlockedAPI - Abstraction Library API for Bukkit Plugins - [![Javadoc](https://img.shields.io/badge/JavaDoc-Online-green)](https://theneweconomy.github.io/VaultUnlockedAPI/javadoc/) [![Build Status](https://ci.codemc.io/job/creatorfromhell/job/VaultUnlockedAPI/badge/icon)](https://ci.codemc.io/job/creatorfromhell/job/VaultUnlockedAPI/) [![Economy Badge](https://github.com/TheNewEconomy/VaultUnlockedAPI/blob/master/.badge/economy%20badge.png)](https://github.com/TheNewEconomy/VaultUnlockedAPI) 2 | 3 | 4 | How to include the API with Maven: 5 | ```xml 6 | 7 | 8 | codemc-repo 9 | https://repo.codemc.org/repository/maven-public 10 | 11 | 12 | 13 | 14 | 15 | net.milkbowl.vault 16 | VaultUnlockedAPI 17 | 2.11 18 | provided 19 | 20 | 21 | ``` 22 | 23 | How to include the API with Gradle: 24 | ```groovy 25 | repositories { 26 | maven { url 'https://repo.codemc.org/repository/maven-public' } 27 | } 28 | dependencies { 29 | compileOnly "net.milkbowl.vault:VaultUnlockedAPI:2.11" 30 | } 31 | ``` 32 | 33 | **Note**: The VaultUnlockedAPI version has 2 numbers (major.minor), unlike Vault, which has 3. The 2 34 | numbers in the VaultUnlockedAPI will always correspond to the 2 beginning numbers in a VaultUnlocked 35 | version to make it clear what versions your plugin will for sure work with. 36 | 37 | ## Why VaultUnlocked? 38 | I have no preference regarding which library is best suited for 39 | your plugin development efforts. I believe a central suite (or "Vault") 40 | of solutions is a more effective approach than focusing on a single 41 | category of plugins. This is the concept behind VaultUnlocked. 42 | 43 | ### Key Features You'll Appreciate 44 | 45 | * **No Source Code Integration Needed** 46 | VaultUnlocked operates as a standalone plugin, so you only need to obtain an instance of it. This prevents conflicts with multiple plugins using the same namespaces. Simply include VaultUnlocked.jar in your download zip file for seamless integration! 47 | * **Extensive Plugin Support** 48 | VaultUnlocked provides an abstraction layer not just for Economic plugins but for Permission plugins as well, ensuring broad compatibility. 49 | * **Freedom of Choice** 50 | One of the best aspects of Bukkit is the freedom to choose what to use. More options benefit developers, so here’s to embracing choice! 51 | 52 | ### Enhanced Features of VaultUnlocked 53 | 54 | * **Multi-Currency Support** 55 | * **More Friendly PR Acceptance** 56 | * **Folia Support** 57 | 58 | Let me know if you need any further modifications! 59 | 60 | ## License 61 | Copyright (C) 2024 Daniel "creatorfromhell" Vidmar 62 | 63 | VaultUnlocked is free software: you can redistribute it and/or modify 64 | it under the terms of the GNU Lesser General Public License as published by 65 | the Free Software Foundation, either version 3 of the License, or 66 | (at your option) any later version. 67 | 68 | VaultUnlocked is distributed in the hope that it will be useful, 69 | but WITHOUT ANY WARRANTY; without even the implied warranty of 70 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 71 | GNU Lesser General Public License for more details. 72 | 73 | You should have received a copy of the GNU Lesser General Public License 74 | along with Vault. If not, see . 75 | 76 | ## Building 77 | VaultUnlockedAPI comes with all libraries needed to build from the current branch. 78 | 79 | ## Plugin Support 80 | While VaultUnlocked works with plugins that support the original Vault, the VaultUnlocked-specific API adds enhanced functionality that plugins must implement specifically. 81 | For this, we have created a VaultUnlocked Support badge, which will be assigned to projects that meet a minimum specification outlined in [Minimum Spec Standard](.standard/EconomyBadge.md). 82 | 83 | ### Economy Plugins 84 | Economy providers that have VaultUnlocked support. 85 | - TheNewEconomy 86 | - Polyconomy 87 | - iConomyUnlocked 88 | 89 | ### Economy User Plugins 90 | Plugins that use VaultUnlocked to interface with Economy Plugins. 91 | 92 | ## Implementing VaultUnlocked 93 | Implementing VaultUnlocked is quite simple. It requires getting the Economy, Permission, or Chat service from the Bukkit ServiceManager. See the example below: 94 | 95 | ```java 96 | package com.example.plugin; 97 | 98 | import java.util.logging.Logger; 99 | 100 | import net.milkbowl.vault2.chat.Chat; 101 | import net.milkbowl.vault2.economy.Economy; 102 | import net.milkbowl.vault2.economy.EconomyResponse; 103 | import net.milkbowl.vault2.permission.Permission; 104 | 105 | import org.bukkit.command.Command; 106 | import org.bukkit.command.CommandSender; 107 | import org.bukkit.entity.Player; 108 | import org.bukkit.plugin.RegisteredServiceProvider; 109 | import org.bukkit.plugin.java.JavaPlugin; 110 | 111 | public class ExamplePlugin extends JavaPlugin { 112 | 113 | private static Economy econ = null; 114 | private static Permission perms = null; 115 | private static Chat chat = null; 116 | 117 | @Override 118 | public void onDisable() { 119 | getLogger().info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion())); 120 | } 121 | 122 | @Override 123 | public void onEnable() { 124 | if (!setupEconomy()) { 125 | getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName())); 126 | getServer().getPluginManager().disablePlugin(this); 127 | return; 128 | } 129 | setupPermissions(); 130 | setupChat(); 131 | } 132 | 133 | private boolean setupEconomy() { 134 | if (getServer().getPluginManager().getPlugin("Vault") == null) { 135 | return false; 136 | } 137 | RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Economy.class); 138 | if (rsp == null) { 139 | return false; 140 | } 141 | econ = rsp.getProvider(); 142 | return econ != null; 143 | } 144 | 145 | private boolean setupChat() { 146 | RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Chat.class); 147 | chat = rsp.getProvider(); 148 | return chat != null; 149 | } 150 | 151 | private boolean setupPermissions() { 152 | RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Permission.class); 153 | perms = rsp.getProvider(); 154 | return perms != null; 155 | } 156 | 157 | public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { 158 | if(!(sender instanceof Player)) { 159 | getLogger().info("Only players are supported for this Example Plugin, but you should not do this!!!"); 160 | return true; 161 | } 162 | 163 | Player player = (Player) sender; 164 | 165 | if(command.getLabel().equals("test-economy")) { 166 | // Lets give the player 1.05 currency (note that SOME economic plugins require rounding!) 167 | sender.sendMessage(String.format("You have %s", econ.format(econ.getBalance(player.getUniqueId())))); 168 | EconomyResponse r = econ.depositPlayer(player.getUniqueId(), new BigDecimal("1.05")); 169 | if(r.transactionSuccess()) { 170 | sender.sendMessage(String.format("You were given %s and now have %s", econ.format(r.amount), econ.format(r.balance))); 171 | } else { 172 | sender.sendMessage(String.format("An error occured: %s", r.errorMessage)); 173 | } 174 | return true; 175 | } else if(command.getLabel().equals("test-permission")) { 176 | // Lets test if user has the node "example.plugin.awesome" to determine if they are awesome or just suck 177 | if(perms.has(player, "example.plugin.awesome")) { 178 | sender.sendMessage("You are awesome!"); 179 | } else { 180 | sender.sendMessage("You suck!"); 181 | } 182 | return true; 183 | } else { 184 | return false; 185 | } 186 | } 187 | 188 | public static Economy getEconomy() { 189 | return econ; 190 | } 191 | 192 | public static Permission getPermissions() { 193 | return perms; 194 | } 195 | 196 | public static Chat getChat() { 197 | return chat; 198 | } 199 | } 200 | ``` 201 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | net.milkbowl.vault 5 | VaultUnlockedAPI 6 | 2.11 7 | 8 | 9 | VaultUnlockedAPI 10 | VaultUnlocked is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves. VaultUnlocked supports all plugins that support Vault 11 | 12 | http://dev.bukkit.org/server-mods/vault/ 13 | 14 | 15 | UTF-8 16 | 1.13.1-R0.1-SNAPSHOT 17 | 18 | 19 | 20 | 21 | 22 | The New Economy 23 | https://tnemc.net 24 | 25 | 26 | 27 | 28 | creatorfromhell 29 | Daniel "creatorfromhell" Vidmar 30 | daniel.viddy@gmail.com 31 | https://cfh.dev 32 | The New Economy 33 | https://tnemc.net 34 | 35 | developer 36 | 37 | America/New_York 38 | 39 | 40 | 41 | 42 | https://github.com/TheNewEconomy/VaultUnlockedAPI 43 | scm:git:git://github.com/TheNewEconomy/VaultUnlockedAPI.git 44 | scm:git:git@github.com:MilkBowl/VaultAPI.git 45 | 46 | 47 | 48 | GitHub 49 | https://github.com/TheNewEconomy/VaultUnlockedAPI/issues 50 | 51 | 52 | 53 | 54 | spigot-repo 55 | https://hub.spigotmc.org/nexus/content/groups/public/ 56 | 57 | 58 | 59 | 60 | 61 | codemc-releases 62 | https://repo.codemc.io/repository/maven-releases/ 63 | 64 | 65 | codemc-snapshots 66 | https://repo.codemc.io/repository/maven-snapshots/ 67 | 68 | 69 | 70 | 71 | 72 | org.bukkit 73 | bukkit 74 | ${bukkitVersion} 75 | provided 76 | 77 | 78 | 79 | junit 80 | junit 81 | 4.13.1 82 | jar 83 | test 84 | true 85 | 86 | 87 | org.jetbrains 88 | annotations 89 | 24.0.0 90 | compile 91 | 92 | 93 | 94 | 95 | clean install 96 | 97 | 98 | org.apache.maven.plugins 99 | maven-compiler-plugin 100 | 3.10.1 101 | 102 | 8 103 | 8 104 | 105 | -parameters 106 | 107 | 108 | 109 | 110 | org.apache.maven.plugins 111 | maven-source-plugin 112 | 3.2.1 113 | 114 | 115 | attach-sources 116 | verify 117 | 118 | jar-no-fork 119 | 120 | 121 | 122 | 123 | 124 | org.apache.maven.plugins 125 | maven-javadoc-plugin 126 | 3.11.2 127 | 128 | public 129 | VaultUnlocked 130 | false 131 | true 132 | true 133 | true 134 | true 135 | TheNewEconomy, 2025]]> 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /src/main/java/net/milkbowl/vault/economy/AbstractEconomy.java: -------------------------------------------------------------------------------- 1 | package net.milkbowl.vault.economy; 2 | 3 | import org.bukkit.OfflinePlayer; 4 | 5 | @SuppressWarnings("deprecation") 6 | public abstract class AbstractEconomy implements Economy { 7 | 8 | @Override 9 | public boolean hasAccount(OfflinePlayer player) { 10 | if (player.getName() == null) return false; 11 | return hasAccount(player.getName()); 12 | } 13 | 14 | @Override 15 | public boolean hasAccount(OfflinePlayer player, String worldName) { 16 | if (player.getName() == null) return false; 17 | return hasAccount(player.getName(), worldName); 18 | } 19 | 20 | @Override 21 | public double getBalance(OfflinePlayer player) { 22 | return getBalance(player.getName()); 23 | } 24 | 25 | @Override 26 | public double getBalance(OfflinePlayer player, String world) { 27 | return getBalance(player.getName(), world); 28 | } 29 | 30 | @Override 31 | public boolean has(OfflinePlayer player, double amount) { 32 | if (player.getName() == null) return false; 33 | return has(player.getName(), amount); 34 | } 35 | 36 | @Override 37 | public boolean has(OfflinePlayer player, String worldName, double amount) { 38 | if (player.getName() == null) return false; 39 | return has(player.getName(), worldName, amount); 40 | } 41 | 42 | @Override 43 | public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) { 44 | return withdrawPlayer(player.getName(), amount); 45 | } 46 | 47 | @Override 48 | public EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount) { 49 | return withdrawPlayer(player.getName(), worldName, amount); 50 | } 51 | 52 | @Override 53 | public EconomyResponse depositPlayer(OfflinePlayer player, double amount) { 54 | return depositPlayer(player.getName(), amount); 55 | } 56 | 57 | @Override 58 | public EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount) { 59 | return depositPlayer(player.getName(), worldName, amount); 60 | } 61 | 62 | @Override 63 | public EconomyResponse createBank(String name, OfflinePlayer player) { 64 | return createBank(name, player.getName()); 65 | } 66 | 67 | @Override 68 | public EconomyResponse isBankOwner(String name, OfflinePlayer player) { 69 | return isBankOwner(name, player.getName()); 70 | } 71 | 72 | @Override 73 | public EconomyResponse isBankMember(String name, OfflinePlayer player) { 74 | return isBankMember(name, player.getName()); 75 | } 76 | 77 | @Override 78 | public boolean createPlayerAccount(OfflinePlayer player) { 79 | return createPlayerAccount(player.getName()); 80 | } 81 | 82 | @Override 83 | public boolean createPlayerAccount(OfflinePlayer player, String worldName) { 84 | return createPlayerAccount(player.getName(), worldName); 85 | } 86 | 87 | } -------------------------------------------------------------------------------- /src/main/java/net/milkbowl/vault/economy/Economy.java: -------------------------------------------------------------------------------- 1 | /* This file is part of Vault. 2 | 3 | Vault is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | Vault is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with Vault. If not, see . 15 | */ 16 | 17 | package net.milkbowl.vault.economy; 18 | 19 | import java.util.List; 20 | 21 | import org.bukkit.OfflinePlayer; 22 | 23 | /** 24 | * The main economy API 25 | * 26 | * @deprecated in lieu of the modern Vault2. To update alter your import to net.milkbowl.vault2.economy and update to use the new UUID-based methods where available. 27 | */ 28 | public interface Economy { 29 | 30 | /** 31 | * Checks if economy method is enabled. 32 | * @return Success or Failure 33 | */ 34 | boolean isEnabled(); 35 | 36 | /** 37 | * Gets name of economy method 38 | * @return Name of Economy Method 39 | */ 40 | String getName(); 41 | 42 | /** 43 | * Returns true if the given implementation supports banks. 44 | * @return true if the implementation supports banks 45 | */ 46 | boolean hasBankSupport(); 47 | 48 | /** 49 | * Some economy plugins round off after a certain number of digits. 50 | * This function returns the number of digits the plugin keeps 51 | * or -1 if no rounding occurs. 52 | * @return number of digits after the decimal point kept 53 | */ 54 | int fractionalDigits(); 55 | 56 | /** 57 | * Format amount into a human readable String This provides translation into 58 | * economy specific formatting to improve consistency between plugins. 59 | * 60 | * @param amount to format 61 | * @return Human readable string describing amount 62 | */ 63 | String format(double amount); 64 | 65 | /** 66 | * Returns the name of the currency in plural form. 67 | * If the economy being used does not support currency names then an empty string will be returned. 68 | * 69 | * @return name of the currency (plural) 70 | */ 71 | String currencyNamePlural(); 72 | 73 | 74 | /** 75 | * Returns the name of the currency in singular form. 76 | * If the economy being used does not support currency names then an empty string will be returned. 77 | * 78 | * @return name of the currency (singular) 79 | */ 80 | String currencyNameSingular(); 81 | 82 | /** 83 | * Checks if this player has an account on the server yet 84 | * This will always return true if the player has joined the server at least once 85 | * as all major economy plugins auto-generate a player account when the player joins the server 86 | * 87 | * @param playerName to check 88 | * @return success true or false 89 | * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer)} instead. 90 | */ 91 | @Deprecated 92 | boolean hasAccount(String playerName); 93 | 94 | /** 95 | * Checks if this player has an account on the server yet 96 | * This will always return true if the player has joined the server at least once 97 | * as all major economy plugins auto-generate a player account when the player joins the server 98 | * 99 | * @param player to check 100 | * @return if the player has an account 101 | */ 102 | boolean hasAccount(OfflinePlayer player); 103 | 104 | /** 105 | * Checks if this player has an account on the server yet on the given world 106 | * This will always return true if the player has joined the server at least once 107 | * as all major economy plugins auto-generate a player account when the player joins the server 108 | * 109 | * @param playerName to check in the world 110 | * @param worldName world-specific account 111 | * @return success true or false 112 | * @deprecated As of VaultAPI 1.4 use {@link #hasAccount(OfflinePlayer, String)} instead. 113 | */ 114 | @Deprecated 115 | boolean hasAccount(String playerName, String worldName); 116 | 117 | /** 118 | * Checks if this player has an account on the server yet on the given world 119 | * This will always return true if the player has joined the server at least once 120 | * as all major economy plugins auto-generate a player account when the player joins the server 121 | * 122 | * @param player to check in the world 123 | * @param worldName world-specific account 124 | * @return if the player has an account 125 | */ 126 | boolean hasAccount(OfflinePlayer player, String worldName); 127 | 128 | /** 129 | * Gets balance of a player 130 | * 131 | * @param playerName of the player 132 | * @return Amount currently held in players account 133 | * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer)} instead. 134 | */ 135 | @Deprecated 136 | double getBalance(String playerName); 137 | 138 | /** 139 | * Gets balance of a player 140 | * 141 | * @param player of the player 142 | * @return Amount currently held in players account 143 | */ 144 | double getBalance(OfflinePlayer player); 145 | 146 | /** 147 | * Gets balance of a player on the specified world. 148 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. 149 | * @param playerName to check 150 | * @param world name of the world 151 | * @return Amount currently held in players account 152 | * @deprecated As of VaultAPI 1.4 use {@link #getBalance(OfflinePlayer, String)} instead. 153 | */ 154 | @Deprecated 155 | double getBalance(String playerName, String world); 156 | 157 | /** 158 | * Gets balance of a player on the specified world. 159 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. 160 | * @param player to check 161 | * @param world name of the world 162 | * @return Amount currently held in players account 163 | */ 164 | double getBalance(OfflinePlayer player, String world); 165 | 166 | /** 167 | * Checks if the player account has the amount - DO NOT USE NEGATIVE AMOUNTS 168 | * 169 | * @param playerName to check 170 | * @param amount to check for 171 | * @return True if player has amount, False else wise 172 | * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, double)} instead. 173 | */ 174 | @Deprecated 175 | boolean has(String playerName, double amount); 176 | 177 | /** 178 | * Checks if the player account has the amount - DO NOT USE NEGATIVE AMOUNTS 179 | * 180 | * @param player to check 181 | * @param amount to check for 182 | * @return True if player has amount, False else wise 183 | */ 184 | boolean has(OfflinePlayer player, double amount); 185 | 186 | /** 187 | * Checks if the player account has the amount in a given world - DO NOT USE NEGATIVE AMOUNTS 188 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. 189 | * 190 | * @param playerName to check 191 | * @param worldName to check with 192 | * @param amount to check for 193 | * @return True if player has amount in the given world, False else wise 194 | * @deprecated As of VaultAPI 1.4 use {@link #has(OfflinePlayer, String, double)} instead. 195 | */ 196 | @Deprecated 197 | boolean has(String playerName, String worldName, double amount); 198 | 199 | /** 200 | * Checks if the player account has the amount in a given world - DO NOT USE NEGATIVE AMOUNTS 201 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. 202 | * 203 | * @param player to check 204 | * @param worldName to check with 205 | * @param amount to check for 206 | * @return True if player has amount in the given world, False else wise 207 | */ 208 | boolean has(OfflinePlayer player, String worldName, double amount); 209 | 210 | /** 211 | * Withdraw an amount from a player - DO NOT USE NEGATIVE AMOUNTS 212 | * 213 | * @param playerName to withdraw from 214 | * @param amount Amount to withdraw 215 | * @return Detailed response of transaction 216 | * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, double)} instead. 217 | */ 218 | @Deprecated 219 | EconomyResponse withdrawPlayer(String playerName, double amount); 220 | 221 | /** 222 | * Withdraw an amount from a player - DO NOT USE NEGATIVE AMOUNTS 223 | * 224 | * @param player to withdraw from 225 | * @param amount Amount to withdraw 226 | * @return Detailed response of transaction 227 | */ 228 | EconomyResponse withdrawPlayer(OfflinePlayer player, double amount); 229 | 230 | /** 231 | * Withdraw an amount from a player on a given world - DO NOT USE NEGATIVE AMOUNTS 232 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. 233 | * @param playerName to withdraw from 234 | * @param worldName - name of the world 235 | * @param amount Amount to withdraw 236 | * @return Detailed response of transaction 237 | * @deprecated As of VaultAPI 1.4 use {@link #withdrawPlayer(OfflinePlayer, String, double)} instead. 238 | */ 239 | @Deprecated 240 | EconomyResponse withdrawPlayer(String playerName, String worldName, double amount); 241 | 242 | /** 243 | * Withdraw an amount from a player on a given world - DO NOT USE NEGATIVE AMOUNTS 244 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. 245 | * @param player to withdraw from 246 | * @param worldName - name of the world 247 | * @param amount Amount to withdraw 248 | * @return Detailed response of transaction 249 | */ 250 | EconomyResponse withdrawPlayer(OfflinePlayer player, String worldName, double amount); 251 | 252 | /** 253 | * Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS 254 | * 255 | * @param playerName to deposit to 256 | * @param amount Amount to deposit 257 | * @return Detailed response of transaction 258 | * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, double)} instead. 259 | */ 260 | @Deprecated 261 | EconomyResponse depositPlayer(String playerName, double amount); 262 | 263 | /** 264 | * Deposit an amount to a player - DO NOT USE NEGATIVE AMOUNTS 265 | * 266 | * @param player to deposit to 267 | * @param amount Amount to deposit 268 | * @return Detailed response of transaction 269 | */ 270 | EconomyResponse depositPlayer(OfflinePlayer player, double amount); 271 | 272 | /** 273 | * Deposit an amount to a player on a given world - DO NOT USE NEGATIVE AMOUNTS 274 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. 275 | * 276 | * @param playerName to deposit to 277 | * @param worldName name of the world 278 | * @param amount Amount to deposit 279 | * @return Detailed response of transaction 280 | * @deprecated As of VaultAPI 1.4 use {@link #depositPlayer(OfflinePlayer, String, double)} instead. 281 | */ 282 | @Deprecated 283 | EconomyResponse depositPlayer(String playerName, String worldName, double amount); 284 | 285 | /** 286 | * Deposit an amount to a player on a given world - DO NOT USE NEGATIVE AMOUNTS 287 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this the global balance will be returned. 288 | * 289 | * @param player to deposit to 290 | * @param worldName name of the world 291 | * @param amount Amount to deposit 292 | * @return Detailed response of transaction 293 | */ 294 | EconomyResponse depositPlayer(OfflinePlayer player, String worldName, double amount); 295 | 296 | /** 297 | * Creates a bank account with the specified name and the player as the owner 298 | * @param name of account 299 | * @param player the account should be linked to 300 | * @return EconomyResponse Object 301 | * @deprecated As of VaultAPI 1.4 use {{@link #createBank(String, OfflinePlayer)} instead. 302 | */ 303 | @Deprecated 304 | EconomyResponse createBank(String name, String player); 305 | 306 | /** 307 | * Creates a bank account with the specified name and the player as the owner 308 | * @param name of account 309 | * @param player the account should be linked to 310 | * @return EconomyResponse Object 311 | */ 312 | EconomyResponse createBank(String name, OfflinePlayer player); 313 | 314 | /** 315 | * Deletes a bank account with the specified name. 316 | * @param name of the back to delete 317 | * @return if the operation completed successfully 318 | */ 319 | EconomyResponse deleteBank(String name); 320 | 321 | /** 322 | * Returns the amount the bank has 323 | * @param name of the account 324 | * @return EconomyResponse Object 325 | */ 326 | EconomyResponse bankBalance(String name); 327 | 328 | /** 329 | * Returns true or false whether the bank has the amount specified - DO NOT USE NEGATIVE AMOUNTS 330 | * 331 | * @param name of the account 332 | * @param amount to check for 333 | * @return EconomyResponse Object 334 | */ 335 | EconomyResponse bankHas(String name, double amount); 336 | 337 | /** 338 | * Withdraw an amount from a bank account - DO NOT USE NEGATIVE AMOUNTS 339 | * 340 | * @param name of the account 341 | * @param amount to withdraw 342 | * @return EconomyResponse Object 343 | */ 344 | EconomyResponse bankWithdraw(String name, double amount); 345 | 346 | /** 347 | * Deposit an amount into a bank account - DO NOT USE NEGATIVE AMOUNTS 348 | * 349 | * @param name of the account 350 | * @param amount to deposit 351 | * @return EconomyResponse Object 352 | */ 353 | EconomyResponse bankDeposit(String name, double amount); 354 | 355 | /** 356 | * Check if a player is the owner of a bank account 357 | * 358 | * @param name of the account 359 | * @param playerName to check for ownership 360 | * @return EconomyResponse Object 361 | * @deprecated As of VaultAPI 1.4 use {{@link #isBankOwner(String, OfflinePlayer)} instead. 362 | */ 363 | @Deprecated 364 | EconomyResponse isBankOwner(String name, String playerName); 365 | 366 | /** 367 | * Check if a player is the owner of a bank account 368 | * 369 | * @param name of the account 370 | * @param player to check for ownership 371 | * @return EconomyResponse Object 372 | */ 373 | EconomyResponse isBankOwner(String name, OfflinePlayer player); 374 | 375 | /** 376 | * Check if the player is a member of the bank account 377 | * 378 | * @param name of the account 379 | * @param playerName to check membership 380 | * @return EconomyResponse Object 381 | * @deprecated As of VaultAPI 1.4 use {@link #isBankMember(String, OfflinePlayer)} instead. 382 | */ 383 | @Deprecated 384 | EconomyResponse isBankMember(String name, String playerName); 385 | 386 | /** 387 | * Check if the player is a member of the bank account 388 | * 389 | * @param name of the account 390 | * @param player to check membership 391 | * @return EconomyResponse Object 392 | */ 393 | EconomyResponse isBankMember(String name, OfflinePlayer player); 394 | 395 | /** 396 | * Gets the list of banks 397 | * @return the List of Banks 398 | */ 399 | List getBanks(); 400 | 401 | /** 402 | * Attempts to create a player account for the given player 403 | * @param playerName username 404 | * @return if the account creation was successful 405 | * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer)} instead. 406 | */ 407 | @Deprecated 408 | boolean createPlayerAccount(String playerName); 409 | 410 | /** 411 | * Attempts to create a player account for the given player 412 | * @param player OfflinePlayer 413 | * @return if the account creation was successful 414 | */ 415 | boolean createPlayerAccount(OfflinePlayer player); 416 | 417 | /** 418 | * Attempts to create a player account for the given player on the specified world 419 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then false will always be returned. 420 | * @param playerName username 421 | * @param worldName String name of the world 422 | * @return if the account creation was successful 423 | * @deprecated As of VaultAPI 1.4 use {@link #createPlayerAccount(OfflinePlayer, String)} instead. 424 | */ 425 | @Deprecated 426 | boolean createPlayerAccount(String playerName, String worldName); 427 | 428 | /** 429 | * Attempts to create a player account for the given player on the specified world 430 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then false will always be returned. 431 | * @param player OfflinePlayer 432 | * @param worldName String name of the world 433 | * @return if the account creation was successful 434 | */ 435 | boolean createPlayerAccount(OfflinePlayer player, String worldName); 436 | } 437 | -------------------------------------------------------------------------------- /src/main/java/net/milkbowl/vault/economy/EconomyResponse.java: -------------------------------------------------------------------------------- 1 | /* This file is part of Vault. 2 | 3 | Vault is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | Vault is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with Vault. If not, see . 15 | */ 16 | package net.milkbowl.vault.economy; 17 | 18 | /** 19 | * Indicates a typical Return for an Economy method. 20 | * It includes a {@link ResponseType} indicating whether the plugin currently being used for Economy actually allows 21 | * the method, or if the operation was a success or failure. 22 | * 23 | * @deprecated in lieu of the modern Vault2. To update alter your import to net.milkbowl.vault2.economy. 24 | */ 25 | public class EconomyResponse { 26 | 27 | /** 28 | * Enum for types of Responses indicating the status of a method call. 29 | */ 30 | public static enum ResponseType { 31 | SUCCESS(1), 32 | FAILURE(2), 33 | NOT_IMPLEMENTED(3); 34 | 35 | private int id; 36 | 37 | ResponseType(int id) { 38 | this.id = id; 39 | } 40 | 41 | int getId() { 42 | return id; 43 | } 44 | } 45 | 46 | /** 47 | * Amount modified by calling method 48 | */ 49 | public final double amount; 50 | /** 51 | * New balance of account 52 | */ 53 | public final double balance; 54 | /** 55 | * Success or failure of call. Using Enum of ResponseType to determine valid 56 | * outcomes 57 | */ 58 | public final ResponseType type; 59 | /** 60 | * Error message if the variable 'type' is ResponseType.FAILURE 61 | */ 62 | public final String errorMessage; 63 | 64 | /** 65 | * Constructor for EconomyResponse 66 | * @param amount Amount modified during operation 67 | * @param balance New balance of account 68 | * @param type Success or failure type of the operation 69 | * @param errorMessage Error message if necessary (commonly null) 70 | */ 71 | public EconomyResponse(double amount, double balance, ResponseType type, String errorMessage) { 72 | this.amount = amount; 73 | this.balance = balance; 74 | this.type = type; 75 | this.errorMessage = errorMessage; 76 | } 77 | 78 | /** 79 | * Checks if an operation was successful 80 | * @return Value 81 | */ 82 | public boolean transactionSuccess() { 83 | return type == ResponseType.SUCCESS; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/net/milkbowl/vault/permission/Permission.java: -------------------------------------------------------------------------------- 1 | /* This file is part of Vault. 2 | 3 | Vault is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | Vault is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with Vault. If not, see . 15 | */ 16 | package net.milkbowl.vault.permission; 17 | 18 | import java.util.logging.Logger; 19 | 20 | import org.bukkit.OfflinePlayer; 21 | import org.bukkit.World; 22 | import org.bukkit.command.CommandSender; 23 | import org.bukkit.entity.Player; 24 | import org.bukkit.permissions.PermissionAttachment; 25 | import org.bukkit.permissions.PermissionAttachmentInfo; 26 | import org.bukkit.plugin.Plugin; 27 | 28 | /** 29 | * The main Permission API - allows for group and player based permission tests 30 | * 31 | * @deprecated in lieu of the modern Vault2. To update alter your import to net.milkbowl.vault2.permission. 32 | */ 33 | public abstract class Permission { 34 | 35 | protected static final Logger log = Logger.getLogger("Minecraft"); 36 | protected Plugin plugin = null; 37 | 38 | /** 39 | * Gets name of permission method 40 | * @return Name of Permission Method 41 | */ 42 | abstract public String getName(); 43 | 44 | /** 45 | * Checks if permission method is enabled. 46 | * @return Success or Failure 47 | */ 48 | abstract public boolean isEnabled(); 49 | 50 | /** 51 | * Returns if the permission system is or attempts to be compatible with super-perms. 52 | * @return True if this permission implementation works with super-perms 53 | */ 54 | abstract public boolean hasSuperPermsCompat(); 55 | 56 | /** 57 | * Checks if player has a permission node. 58 | * Supports NULL value for World if the permission system registered supports global permissions. 59 | * But May return odd values if the servers registered permission system does not have a global permission store. 60 | * 61 | * @param world String world name 62 | * @param player to check 63 | * @param permission Permission node 64 | * @return Success or Failure 65 | * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. 66 | */ 67 | @Deprecated 68 | public boolean has(final String world, final String player, final String permission) { 69 | if (world == null) { 70 | return playerHas((String) null, player, permission); 71 | } 72 | return playerHas(world, player, permission); 73 | } 74 | 75 | /** 76 | * Checks if player has a permission node. 77 | * Supports NULL value for World if the permission system registered supports global permissions. 78 | * But May return odd values if the servers registered permission system does not have a global permission store. 79 | * 80 | * @param world String world name 81 | * @param player to check 82 | * @param permission Permission node 83 | * @return Success or Failure 84 | * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. 85 | */ 86 | @Deprecated 87 | public boolean has(final World world, final String player, final String permission) { 88 | if (world == null) { 89 | return playerHas((String) null, player, permission); 90 | } 91 | return playerHas(world.getName(), player, permission); 92 | } 93 | 94 | /** 95 | * Checks if a CommandSender has a permission node. 96 | * This will return the result of bukkits, generic .hasPermission() method and is identical in all cases. 97 | * This method will explicitly fail if the registered permission system does not register permissions in bukkit. 98 | * 99 | * For easy checking of a commandsender 100 | * @param sender to check permissions on 101 | * @param permission to check for 102 | * @return true if the sender has the permission 103 | */ 104 | public boolean has(final CommandSender sender, final String permission) { 105 | return sender.hasPermission(permission); 106 | } 107 | 108 | /** 109 | * Checks if player has a permission node. (Short for playerHas(...) 110 | * @param player Player Object 111 | * @param permission Permission node 112 | * @return Success or Failure 113 | */ 114 | public boolean has(final Player player, final String permission) { 115 | return player.hasPermission(permission); 116 | } 117 | 118 | /** 119 | * Checks if player has a permission node. 120 | * Supports NULL value for World if the permission system registered supports global permissions. 121 | * But May return odd values if the servers registered permission system does not have a global permission store. 122 | * 123 | * @param world String world name 124 | * @param player to check 125 | * @param permission Permission node 126 | * @return Success or Failure 127 | * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. 128 | */ 129 | @Deprecated 130 | abstract public boolean playerHas(String world, String player, String permission); 131 | 132 | /** 133 | * Checks if player has a permission node. 134 | * Supports NULL value for World if the permission system registered supports global permissions. 135 | * But May return odd values if the servers registered permission system does not have a global permission store. 136 | * 137 | * @param world String world name 138 | * @param player to check 139 | * @param permission Permission node 140 | * @return Success or Failure 141 | * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. 142 | */ 143 | @Deprecated 144 | public boolean playerHas(final World world, final String player, final String permission) { 145 | if (world == null) { 146 | return playerHas((String) null, player, permission); 147 | } 148 | return playerHas(world.getName(), player, permission); 149 | } 150 | 151 | /** 152 | * Checks if player has a permission node. 153 | * Supports NULL value for World if the permission system registered supports global permissions. 154 | * But May return odd values if the servers registered permission system does not have a global permission store. 155 | * 156 | * @param world String world name 157 | * @param player to check 158 | * @param permission Permission node 159 | * @return Success or Failure 160 | */ 161 | public boolean playerHas(final String world, final OfflinePlayer player, final String permission) { 162 | if (world == null) { 163 | return has((String) null, player.getName(), permission); 164 | } 165 | return has(world, player.getName(), permission); 166 | } 167 | 168 | /** 169 | * Checks if player has a permission node. 170 | * Defaults to world-specific permission check if the permission system supports it. 171 | * See {@link #playerHas(String, OfflinePlayer, String)} for explicit global or world checks. 172 | * 173 | * @param player Player Object 174 | * @param permission Permission node 175 | * @return Success or Failure 176 | */ 177 | public boolean playerHas(final Player player, final String permission) { 178 | return has(player, permission); 179 | } 180 | 181 | /** 182 | * @deprecated As of VaultAPI 1.4 use {@link #playerAdd(String, OfflinePlayer, String)} instead. 183 | * Add permission to a player. 184 | * Supports NULL value for World if the permission system registered supports global permissions. 185 | * But May return odd values if the servers registered permission system does not have a global permission store. 186 | * 187 | * @param world World name 188 | * @param player Player name 189 | * @param permission Permission node 190 | * @return Success or Failure 191 | */ 192 | @Deprecated 193 | abstract public boolean playerAdd(String world, String player, String permission); 194 | 195 | /** 196 | * Add permission to a player. 197 | * Supports NULL value for World if the permission system registered supports global permissions. 198 | * But May return odd values if the servers registered permission system does not have a global permission store. 199 | * 200 | * @param world String world name 201 | * @param player to add to 202 | * @param permission Permission node 203 | * @return Success or Failure 204 | * @deprecated As of VaultAPI 1.4 use {@link #playerAdd(String, OfflinePlayer, String)} instead. 205 | */ 206 | @Deprecated 207 | public boolean playerAdd(final World world, final String player, final String permission) { 208 | if (world == null) { 209 | return playerAdd((String) null, player, permission); 210 | } 211 | return playerAdd(world.getName(), player, permission); 212 | } 213 | 214 | /** 215 | * Add permission to a player. 216 | * Supports NULL value for World if the permission system registered supports global permissions. 217 | * But May return odd values if the servers registered permission system does not have a global permission store. 218 | * 219 | * @param world String world name 220 | * @param player to add to 221 | * @param permission Permission node 222 | * @return Success or Failure 223 | */ 224 | public boolean playerAdd(final String world, final OfflinePlayer player, final String permission) { 225 | if (world == null) { 226 | return playerAdd((String) null, player.getName(), permission); 227 | } 228 | return playerAdd(world, player.getName(), permission); 229 | } 230 | 231 | /** 232 | * Add permission to a player ONLY for the world the player is currently on. 233 | * This is a world-specific operation, if you want to add global permission you must explicitly use NULL for the world. 234 | * See {@link #playerAdd(String, OfflinePlayer, String)} for global permission use. 235 | * 236 | * @param player Player Object 237 | * @param permission Permission node 238 | * @return Success or Failure 239 | */ 240 | public boolean playerAdd(final Player player, final String permission) { 241 | return playerAdd(player.getWorld().getName(), player, permission); 242 | } 243 | 244 | /** 245 | * Add transient permission to a player. 246 | * This implementation can be used by any subclass which implements a "pure" superperms plugin, i.e. 247 | * one that only needs the built-in Bukkit API to add transient permissions to a player. 248 | * 249 | * @param player to add to 250 | * @param permission Permission node 251 | * @return Success or Failure 252 | */ 253 | public boolean playerAddTransient(final OfflinePlayer player, final String permission) throws UnsupportedOperationException { 254 | if (player.isOnline()) { 255 | return playerAddTransient((Player) player, permission); 256 | } 257 | throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!"); 258 | } 259 | 260 | /** 261 | * Add transient permission to a player. 262 | * This operation adds a permission onto the player object in bukkit via Bukkit's permission interface. 263 | * 264 | * @param player Player Object 265 | * @param permission Permission node 266 | * @return Success or Failure 267 | */ 268 | public boolean playerAddTransient(final Player player, final String permission) { 269 | for (final PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) { 270 | if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) { 271 | paInfo.getAttachment().setPermission(permission, true); 272 | return true; 273 | } 274 | } 275 | 276 | final PermissionAttachment attach = player.addAttachment(plugin); 277 | attach.setPermission(permission, true); 278 | 279 | return true; 280 | } 281 | 282 | /** 283 | * Adds a world specific transient permission to the player, may only work with some permission managers. 284 | * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! 285 | * 286 | * @param worldName to check on 287 | * @param player to add to 288 | * @param permission to test 289 | * @return Success or Failure 290 | */ 291 | public boolean playerAddTransient(final String worldName, final OfflinePlayer player, final String permission) { 292 | return playerAddTransient(player, permission); 293 | } 294 | 295 | /** 296 | * Adds a world specific transient permission to the player, may only work with some permission managers. 297 | * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! 298 | * 299 | * @param worldName to check on 300 | * @param player to check 301 | * @param permission to check for 302 | * @return Success or Failure 303 | */ 304 | public boolean playerAddTransient(final String worldName, final Player player, final String permission) { 305 | return playerAddTransient(player, permission); 306 | } 307 | 308 | /** 309 | * Removes a world specific transient permission from the player, may only work with some permission managers. 310 | * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! 311 | * 312 | * @param worldName to remove for 313 | * @param player to remove for 314 | * @param permission to remove 315 | * @return Success or Failure 316 | */ 317 | public boolean playerRemoveTransient(final String worldName, final OfflinePlayer player, final String permission) { 318 | return playerRemoveTransient(player, permission); 319 | } 320 | 321 | /** 322 | * Removes a world specific transient permission from the player, may only work with some permission managers. 323 | * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! 324 | * 325 | * @param worldName to check on 326 | * @param player to check 327 | * @param permission to check for 328 | * @return Success or Failure 329 | */ 330 | public boolean playerRemoveTransient(final String worldName, final Player player, final String permission) { 331 | return playerRemoveTransient((OfflinePlayer) player, permission); 332 | } 333 | 334 | /** 335 | * Remove permission from a player. 336 | * Supports NULL value for World if the permission system registered supports global permissions. 337 | * But May return odd values if the servers registered permission system does not have a global permission store. 338 | * 339 | * @param world World name 340 | * @param player OfflinePlayer 341 | * @param permission Permission node 342 | * @return Success or Failure 343 | * @deprecated As of VaultAPI 1.4 use {@link #playerRemove(String, OfflinePlayer, String)} instead. 344 | */ 345 | @Deprecated 346 | abstract public boolean playerRemove(String world, String player, String permission); 347 | 348 | /** 349 | * Remove permission from a player. 350 | * Supports NULL value for World if the permission system registered supports global permissions. 351 | * But May return odd values if the servers registered permission system does not have a global permission store. 352 | * 353 | * @param world World name 354 | * @param player OfflinePlayer 355 | * @param permission Permission node 356 | * @return Success or Failure 357 | */ 358 | public boolean playerRemove(final String world, final OfflinePlayer player, final String permission) { 359 | if (world == null) { 360 | return playerRemove((String) null, player.getName(), permission); 361 | } 362 | return playerRemove(world, player.getName(), permission); 363 | } 364 | 365 | /** 366 | * Remove permission from a player. 367 | * Supports NULL value for World if the permission system registered supports global permissions. 368 | * But May return odd values if the servers registered permission system does not have a global permission store. 369 | * 370 | * @param world World name 371 | * @param player Player name 372 | * @param permission Permission node 373 | * @return Success or Failure 374 | */ 375 | @Deprecated 376 | public boolean playerRemove(final World world, final String player, final String permission) { 377 | if (world == null) { 378 | return playerRemove((String) null, player, permission); 379 | } 380 | return playerRemove(world.getName(), player, permission); 381 | } 382 | 383 | /** 384 | * Remove permission from a player. 385 | * Will attempt to remove permission from the player on the player's current world. This is NOT a global operation. 386 | * 387 | * @param player Player Object 388 | * @param permission Permission node 389 | * @return Success or Failure 390 | */ 391 | public boolean playerRemove(final Player player, final String permission) { 392 | return playerRemove(player.getWorld().getName(), player, permission); 393 | } 394 | 395 | 396 | /** 397 | * Remove transient permission from a player. 398 | * This implementation can be used by any subclass which implements a "pure" superperms plugin, i.e. 399 | * one that only needs the built-in Bukkit API to remove transient permissions from a player. Any subclass 400 | * implementing a plugin which provides its own API for this needs to override this method. 401 | * 402 | * @param player OfflinePlayer 403 | * @param permission Permission node 404 | * @return Success or Failure 405 | */ 406 | public boolean playerRemoveTransient(final OfflinePlayer player, final String permission) { 407 | if (player.isOnline()) { 408 | return playerRemoveTransient((Player) player, permission); 409 | } else { 410 | return false; 411 | } 412 | } 413 | 414 | /** 415 | * Remove transient permission from a player. 416 | * 417 | * @param player Player Object 418 | * @param permission Permission node 419 | * @return Success or Failure 420 | */ 421 | public boolean playerRemoveTransient(final Player player, final String permission) { 422 | for (final PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) { 423 | if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) { 424 | paInfo.getAttachment().unsetPermission(permission); 425 | return true; 426 | } 427 | } 428 | return false; 429 | } 430 | 431 | /** 432 | * Checks if group has a permission node. 433 | * Supports NULL value for World if the permission system registered supports global permissions. 434 | * But May return odd values if the servers registered permission system does not have a global permission store. 435 | * 436 | * @param world World name 437 | * @param group Group name 438 | * @param permission Permission node 439 | * @return Success or Failure 440 | */ 441 | abstract public boolean groupHas(String world, String group, String permission); 442 | 443 | /** 444 | * Checks if group has a permission node. 445 | * Supports NULL value for World if the permission system registered supports global permissions. 446 | * But May return odd values if the servers registered permission system does not have a global permission store. 447 | * 448 | * @param world World Object 449 | * @param group Group name 450 | * @param permission Permission node 451 | * @return Success or Failure 452 | */ 453 | public boolean groupHas(final World world, final String group, final String permission) { 454 | if (world == null) { 455 | return groupHas((String) null, group, permission); 456 | } 457 | return groupHas(world.getName(), group, permission); 458 | } 459 | 460 | /** 461 | * Add permission to a group. 462 | * Supports NULL value for World if the permission system registered supports global permissions. 463 | * But May return odd values if the servers registered permission system does not have a global permission store. 464 | * 465 | * @param world World name 466 | * @param group Group name 467 | * @param permission Permission node 468 | * @return Success or Failure 469 | */ 470 | abstract public boolean groupAdd(String world, String group, String permission); 471 | 472 | /** 473 | * Add permission to a group. 474 | * Supports NULL value for World if the permission system registered supports global permissions. 475 | * But May return odd values if the servers registered permission system does not have a global permission store. 476 | * 477 | * @param world World Object 478 | * @param group Group name 479 | * @param permission Permission node 480 | * @return Success or Failure 481 | */ 482 | public boolean groupAdd(final World world, final String group, final String permission) { 483 | if (world == null) { 484 | return groupAdd((String) null, group, permission); 485 | } 486 | return groupAdd(world.getName(), group, permission); 487 | } 488 | 489 | /** 490 | * Remove permission from a group. 491 | * Supports NULL value for World if the permission system registered supports global permissions. 492 | * But May return odd values if the servers registered permission system does not have a global permission store. 493 | * 494 | * @param world World name 495 | * @param group Group name 496 | * @param permission Permission node 497 | * @return Success or Failure 498 | */ 499 | abstract public boolean groupRemove(String world, String group, String permission); 500 | 501 | /** 502 | * Remove permission from a group. 503 | * Supports NULL value for World if the permission system registered supports global permissions. 504 | * But May return odd values if the servers registered permission system does not have a global permission store. 505 | * 506 | * @param world World Object 507 | * @param group Group name 508 | * @param permission Permission node 509 | * @return Success or Failure 510 | */ 511 | public boolean groupRemove(final World world, final String group, final String permission) { 512 | if (world == null) { 513 | return groupRemove((String) null, group, permission); 514 | } 515 | return groupRemove(world.getName(), group, permission); 516 | } 517 | 518 | /** 519 | * Check if player is member of a group. 520 | * Supports NULL value for World if the permission system registered supports global permissions. 521 | * But May return odd values if the servers registered permission system does not have a global permission store. 522 | * 523 | * @param world World Object 524 | * @param player to check 525 | * @param group Group name 526 | * @return Success or Failure 527 | * @deprecated As of VaultAPI 1.4 use {@link #playerInGroup(String, OfflinePlayer, String)} instead. 528 | */ 529 | @Deprecated 530 | abstract public boolean playerInGroup(String world, String player, String group); 531 | 532 | /** 533 | * Check if player is member of a group. 534 | * Supports NULL value for World if the permission system registered supports global permissions. 535 | * But May return odd values if the servers registered permission system does not have a global permission store. 536 | * 537 | * @param world World Object 538 | * @param player to check 539 | * @param group Group name 540 | * @return Success or Failure 541 | * @deprecated As of VaultAPI 1.4 use {@link #playerInGroup(String, OfflinePlayer, String)} instead. 542 | */ 543 | @Deprecated 544 | public boolean playerInGroup(final World world, final String player, final String group) { 545 | if (world == null) { 546 | return playerInGroup((String) null, player, group); 547 | } 548 | return playerInGroup(world.getName(), player, group); 549 | } 550 | 551 | /** 552 | * Check if player is member of a group. 553 | * Supports NULL value for World if the permission system registered supports global permissions. 554 | * But May return odd values if the servers registered permission system does not have a global permission store. 555 | * 556 | * @param world World Object 557 | * @param player to check 558 | * @param group Group name 559 | * @return Success or Failure 560 | */ 561 | public boolean playerInGroup(final String world, final OfflinePlayer player, final String group) { 562 | if (world == null) { 563 | return playerInGroup((String) null, player.getName(), group); 564 | } 565 | return playerInGroup(world, player.getName(), group); 566 | } 567 | 568 | /** 569 | * Check if player is member of a group. 570 | * This method will ONLY check groups for which the player is in that are defined for the current world. 571 | * This may result in odd return behaviour depending on what permission system has been registered. 572 | * 573 | * @param player Player Object 574 | * @param group Group name 575 | * @return Success or Failure 576 | */ 577 | public boolean playerInGroup(final Player player, final String group) { 578 | return playerInGroup(player.getWorld().getName(), player, group); 579 | } 580 | 581 | /** 582 | * Add player to a group. 583 | * Supports NULL value for World if the permission system registered supports global permissions. 584 | * But May return odd values if the servers registered permission system does not have a global permission store. 585 | * 586 | * @param world String world name 587 | * @param player to add 588 | * @param group Group name 589 | * @return Success or Failure 590 | * @deprecated As of VaultAPI 1.4 use {@link #playerAddGroup(String, OfflinePlayer, String)} instead. 591 | */ 592 | @Deprecated 593 | abstract public boolean playerAddGroup(String world, String player, String group); 594 | 595 | /** 596 | * Add player to a group. 597 | * Supports NULL value for World if the permission system registered supports global permissions. 598 | * But May return odd values if the servers registered permission system does not have a global permission store. 599 | * 600 | * @param world String world name 601 | * @param player to add 602 | * @param group Group name 603 | * @return Success or Failure 604 | * @deprecated As of VaultAPI 1.4 use {@link #playerAddGroup(String, OfflinePlayer, String)} instead. 605 | */ 606 | @Deprecated 607 | public boolean playerAddGroup(final World world, final String player, final String group) { 608 | if (world == null) { 609 | return playerAddGroup((String) null, player, group); 610 | } 611 | return playerAddGroup(world.getName(), player, group); 612 | } 613 | 614 | /** 615 | * Add player to a group. 616 | * Supports NULL value for World if the permission system registered supports global permissions. 617 | * But May return odd values if the servers registered permission system does not have a global permission store. 618 | * 619 | * @param world String world name 620 | * @param player to add 621 | * @param group Group name 622 | * @return Success or Failure 623 | */ 624 | public boolean playerAddGroup(final String world, final OfflinePlayer player, final String group) { 625 | if (world == null) { 626 | return playerAddGroup((String) null, player.getName(), group); 627 | } 628 | return playerAddGroup(world, player.getName(), group); 629 | } 630 | 631 | /** 632 | * Add player to a group. 633 | * This will add a player to the group on the current World. This may return odd results if the permission system 634 | * being used on the server does not support world-specific groups, or if the group being added to is a global group. 635 | * 636 | * @param player Player Object 637 | * @param group Group name 638 | * @return Success or Failure 639 | */ 640 | public boolean playerAddGroup(final Player player, final String group) { 641 | return playerAddGroup(player.getWorld().getName(), player, group); 642 | } 643 | 644 | /** 645 | * Remove player from a group. 646 | * Supports NULL value for World if the permission system registered supports global permissions. 647 | * But May return odd values if the servers registered permission system does not have a global permission store. 648 | * 649 | * @param world World Object 650 | * @param player to remove 651 | * @param group Group name 652 | * @return Success or Failure 653 | * @deprecated As of VaultAPI 1.4 use {@link #playerRemoveGroup(String, OfflinePlayer, String)} instead. 654 | */ 655 | @Deprecated 656 | abstract public boolean playerRemoveGroup(String world, String player, String group); 657 | 658 | /** 659 | * Remove player from a group. 660 | * Supports NULL value for World if the permission system registered supports global permissions. 661 | * But May return odd values if the servers registered permission system does not have a global permission store. 662 | * 663 | * @param world World Object 664 | * @param player to remove 665 | * @param group Group name 666 | * @return Success or Failure 667 | * @deprecated As of VaultAPI 1.4 use {@link #playerRemoveGroup(String, OfflinePlayer, String)} instead. 668 | */ 669 | @Deprecated 670 | public boolean playerRemoveGroup(final World world, final String player, final String group) { 671 | if (world == null) { 672 | return playerRemoveGroup((String) null, player, group); 673 | } 674 | return playerRemoveGroup(world.getName(), player, group); 675 | } 676 | 677 | /** 678 | * Remove player from a group. 679 | * Supports NULL value for World if the permission system registered supports global permissions. 680 | * But May return odd values if the servers registered permission system does not have a global permission store. 681 | * 682 | * @param world World Object 683 | * @param player to remove 684 | * @param group Group name 685 | * @return Success or Failure 686 | */ 687 | public boolean playerRemoveGroup(final String world, final OfflinePlayer player, final String group) { 688 | if (world == null) { 689 | return playerRemoveGroup((String) null, player.getName(), group); 690 | } 691 | return playerRemoveGroup(world, player.getName(), group); 692 | } 693 | 694 | /** 695 | * Remove player from a group. 696 | * This will add a player to the group on the current World. This may return odd results if the permission system 697 | * being used on the server does not support world-specific groups, or if the group being added to is a global group. 698 | * 699 | * @param player Player Object 700 | * @param group Group name 701 | * @return Success or Failure 702 | */ 703 | public boolean playerRemoveGroup(final Player player, final String group) { 704 | return playerRemoveGroup(player.getWorld().getName(), player, group); 705 | } 706 | 707 | /** 708 | * Gets the list of groups that this player has 709 | * Supports NULL value for World if the permission system registered supports global permissions. 710 | * But May return odd values if the servers registered permission system does not have a global permission store. 711 | * 712 | * @param world String world name 713 | * @param player OfflinePlayer 714 | * @return Array of groups 715 | * @deprecated As of VaultAPI 1.4 use {@link #getPlayerGroups(String, OfflinePlayer)} instead. 716 | */ 717 | @Deprecated 718 | abstract public String[] getPlayerGroups(String world, String player); 719 | 720 | /** 721 | * Gets the list of groups that this player has 722 | * Supports NULL value for World if the permission system registered supports global permissions. 723 | * But May return odd values if the servers registered permission system does not have a global permission store. 724 | * 725 | * @param world String world name 726 | * @param player OfflinePlayer 727 | * @return Array of groups 728 | * @deprecated As of VaultAPI 1.4 use {@link #getPlayerGroups(String, OfflinePlayer)} instead. 729 | */ 730 | @Deprecated 731 | public String[] getPlayerGroups(final World world, final String player) { 732 | if (world == null) { 733 | return getPlayerGroups((String) null, player); 734 | } 735 | return getPlayerGroups(world.getName(), player); 736 | } 737 | 738 | /** 739 | * Gets the list of groups that this player has 740 | * Supports NULL value for World if the permission system registered supports global permissions. 741 | * But May return odd values if the servers registered permission system does not have a global permission store. 742 | * 743 | * @param world String world name 744 | * @param player OfflinePlayer 745 | * @return Array of groups 746 | */ 747 | public String[] getPlayerGroups(final String world, final OfflinePlayer player) { 748 | return getPlayerGroups(world, player.getName()); 749 | } 750 | 751 | /** 752 | * Returns a list of world-specific groups that this player is currently in. May return unexpected results if 753 | * you are looking for global groups, or if the registered permission system does not support world-specific groups. 754 | * See {@link #getPlayerGroups(String, OfflinePlayer)} for better control of World-specific or global groups. 755 | * 756 | * @param player Player Object 757 | * @return Array of groups 758 | */ 759 | public String[] getPlayerGroups(final Player player) { 760 | return getPlayerGroups(player.getWorld().getName(), player); 761 | } 762 | 763 | /** 764 | * Gets players primary group 765 | * Supports NULL value for World if the permission system registered supports global permissions. 766 | * But May return odd values if the servers registered permission system does not have a global permission store. 767 | * 768 | * @param world String world name 769 | * @param player to get from 770 | * @return Players primary group 771 | * @deprecated As of VaultAPI 1.4 use {@link #getPrimaryGroup(String, OfflinePlayer)} instead. 772 | */ 773 | @Deprecated 774 | abstract public String getPrimaryGroup(String world, String player); 775 | 776 | /** 777 | * Gets players primary group 778 | * Supports NULL value for World if the permission system registered supports global permissions. 779 | * But May return odd values if the servers registered permission system does not have a global permission store. 780 | * 781 | * @param world String world name 782 | * @param player to get from 783 | * @return Players primary group 784 | * @deprecated As of VaultAPI 1.4 use {@link #getPrimaryGroup(String, OfflinePlayer)} instead. 785 | */ 786 | @Deprecated 787 | public String getPrimaryGroup(final World world, final String player) { 788 | if (world == null) { 789 | return getPrimaryGroup((String) null, player); 790 | } 791 | return getPrimaryGroup(world.getName(), player); 792 | } 793 | 794 | /** 795 | * Gets players primary group 796 | * Supports NULL value for World if the permission system registered supports global permissions. 797 | * But May return odd values if the servers registered permission system does not have a global permission store. 798 | * 799 | * @param world String world name 800 | * @param player to get from 801 | * @return Players primary group 802 | */ 803 | public String getPrimaryGroup(final String world, final OfflinePlayer player) { 804 | return getPrimaryGroup(world, player.getName()); 805 | } 806 | 807 | /** 808 | * Get players primary group. 809 | * Defaults to the players current world, so may return only world-specific groups. 810 | * In most cases {@link #getPrimaryGroup(String, OfflinePlayer)} is preferable. 811 | * 812 | * @param player Player Object 813 | * @return Players primary group 814 | */ 815 | public String getPrimaryGroup(final Player player) { 816 | return getPrimaryGroup(player.getWorld().getName(), player); 817 | } 818 | 819 | /** 820 | * Returns a list of all known groups 821 | * @return an Array of String of all groups 822 | */ 823 | abstract public String[] getGroups(); 824 | 825 | /** 826 | * Returns true if the given implementation supports groups. 827 | * @return true if the implementation supports groups 828 | */ 829 | abstract public boolean hasGroupSupport(); 830 | } -------------------------------------------------------------------------------- /src/main/java/net/milkbowl/vault2/chat/Chat.java: -------------------------------------------------------------------------------- 1 | /* This file is part of Vault. 2 | 3 | Vault is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | Vault is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with Vault. If not, see . 15 | */ 16 | package net.milkbowl.vault2.chat; 17 | 18 | import net.milkbowl.vault2.permission.Permission; 19 | 20 | import org.bukkit.OfflinePlayer; 21 | import org.bukkit.World; 22 | import org.bukkit.entity.Player; 23 | 24 | /** 25 | * The main Chat API - allows for Prefix/Suffix nodes along with generic Info nodes if the linked Chat system supports them 26 | * 27 | */ 28 | public abstract class Chat { 29 | 30 | private Permission perms; 31 | 32 | public Chat(Permission perms) { 33 | this.perms = perms; 34 | } 35 | /** 36 | * Gets name of permission method 37 | * @return Name of Permission Method 38 | */ 39 | abstract public String getName(); 40 | 41 | /** 42 | * Checks if permission method is enabled. 43 | * @return Success or Failure 44 | */ 45 | abstract public boolean isEnabled(); 46 | 47 | /** 48 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerPrefix(String, OfflinePlayer)} instead. 49 | * 50 | * Get players prefix 51 | * @param world World name 52 | * @param player Player name 53 | * @return Prefix 54 | */ 55 | @Deprecated 56 | abstract public String getPlayerPrefix(String world, String player); 57 | 58 | /** 59 | * Get a players prefix in the given world 60 | * Use NULL for world if requesting a global prefix 61 | * 62 | * @param world World name 63 | * @param player OfflinePlayer 64 | * @return Prefix 65 | */ 66 | public String getPlayerPrefix(String world, OfflinePlayer player) { 67 | return getPlayerPrefix(world, player.getName()); 68 | } 69 | 70 | /** 71 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerPrefix(String, OfflinePlayer)} instead. 72 | * 73 | * Get players prefix 74 | * @param world World Object 75 | * @param player Player name 76 | * @return Prefix 77 | */ 78 | @Deprecated 79 | public String getPlayerPrefix(World world, String player) { 80 | return getPlayerPrefix(world.getName(), player); 81 | } 82 | 83 | /** 84 | * Get players prefix from the world they are currently in. 85 | * May or may not return the global prefix depending on implementation. 86 | * 87 | * @param player Player Object 88 | * @return Prefix 89 | */ 90 | public String getPlayerPrefix(Player player) { 91 | return getPlayerPrefix(player.getWorld().getName(), player); 92 | } 93 | 94 | /** 95 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerPrefix(String, OfflinePlayer, String)} instead. 96 | * 97 | * Set players prefix 98 | * @param world World name 99 | * @param player Player name 100 | * @param prefix Prefix 101 | */ 102 | @Deprecated 103 | abstract public void setPlayerPrefix(String world, String player, String prefix); 104 | 105 | /** 106 | * Sets players prefix in the given world. 107 | * Use NULL for world for setting in the Global scope. 108 | * 109 | * @param world World name 110 | * @param player OfflinePlayer 111 | * @param prefix Prefix 112 | */ 113 | public void setPlayerPrefix(String world, OfflinePlayer player, String prefix) { 114 | setPlayerPrefix(world, player.getName(), prefix); 115 | } 116 | 117 | /** 118 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerPrefix(String, OfflinePlayer, String)} instead. 119 | * 120 | * Set players prefix in the given world. 121 | * 122 | * @param world World Object 123 | * @param player Player name 124 | * @param prefix Prefix 125 | */ 126 | @Deprecated 127 | public void setPlayerPrefix(World world, String player, String prefix) { 128 | setPlayerPrefix(world.getName(), player, prefix); 129 | } 130 | 131 | /** 132 | * Set players prefix in the world they are currently in. 133 | * 134 | * @param player Player Object 135 | * @param prefix Prefix 136 | */ 137 | public void setPlayerPrefix(Player player, String prefix) { 138 | setPlayerPrefix(player.getWorld().getName(), player, prefix); 139 | } 140 | 141 | /** 142 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerSuffix(String, OfflinePlayer)} instead. 143 | * 144 | * Get players suffix 145 | * @param world World name 146 | * @param player Player name 147 | * @return Suffix 148 | */ 149 | @Deprecated 150 | abstract public String getPlayerSuffix(String world, String player); 151 | 152 | /** 153 | * Get players suffix in the specified world. 154 | * 155 | * @param world World name 156 | * @param player OfflinePlayer name 157 | * @return Suffix 158 | */ 159 | public String getPlayerSuffix(String world, OfflinePlayer player) { 160 | return getPlayerSuffix(world, player.getName()); 161 | } 162 | 163 | /** 164 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerSuffix(String, OfflinePlayer)} instead. 165 | * 166 | * Get players suffix 167 | * @param world World Object 168 | * @param player Player name 169 | * @return Suffix 170 | */ 171 | @Deprecated 172 | public String getPlayerSuffix(World world, String player) { 173 | return getPlayerSuffix(world.getName(), player); 174 | } 175 | 176 | /** 177 | * Get players suffix in the world they are currently in. 178 | * 179 | * @param player Player Object 180 | * @return Suffix 181 | */ 182 | public String getPlayerSuffix(Player player) { 183 | return getPlayerSuffix(player.getWorld().getName(), player); 184 | } 185 | 186 | /** 187 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerSuffix(String, OfflinePlayer, String)} instead. 188 | * 189 | * Set players suffix 190 | * @param world World name 191 | * @param player Player name 192 | * @param suffix Suffix 193 | */ 194 | @Deprecated 195 | abstract public void setPlayerSuffix(String world, String player, String suffix); 196 | 197 | /** 198 | * Set players suffix for the world specified 199 | * 200 | * @param world World name 201 | * @param player OfflinePlayer 202 | * @param suffix Suffix 203 | */ 204 | public void setPlayerSuffix(String world, OfflinePlayer player, String suffix) { 205 | setPlayerSuffix(world, player.getName(), suffix); 206 | } 207 | 208 | /** 209 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerSuffix(String, OfflinePlayer, String)} instead. 210 | * 211 | * Set players suffix 212 | * @param world World Object 213 | * @param player Player name 214 | * @param suffix Suffix 215 | */ 216 | @Deprecated 217 | public void setPlayerSuffix(World world, String player, String suffix) { 218 | setPlayerSuffix(world.getName(), player, suffix); 219 | } 220 | 221 | /** 222 | * Set players suffix in the world they currently occupy. 223 | * 224 | * @param player Player Object 225 | * @param suffix Suffix 226 | */ 227 | public void setPlayerSuffix(Player player, String suffix) { 228 | setPlayerSuffix(player.getWorld().getName(), player, suffix); 229 | } 230 | 231 | /** 232 | * Get group prefix 233 | * @param world World name 234 | * @param group Group name 235 | * @return Prefix 236 | */ 237 | abstract public String getGroupPrefix(String world, String group); 238 | 239 | /** 240 | * Get group prefix 241 | * @param world World Object 242 | * @param group Group name 243 | * @return Prefix 244 | */ 245 | public String getGroupPrefix(World world, String group) { 246 | return getGroupPrefix(world.getName(), group); 247 | } 248 | 249 | /** 250 | * Set group prefix 251 | * @param world World name 252 | * @param group Group name 253 | * @param prefix Prefix 254 | */ 255 | abstract public void setGroupPrefix(String world, String group, String prefix); 256 | 257 | /** 258 | * Set group prefix 259 | * @param world World Object 260 | * @param group Group name 261 | * @param prefix Prefix 262 | */ 263 | public void setGroupPrefix(World world, String group, String prefix) { 264 | setGroupPrefix(world.getName(), group, prefix); 265 | } 266 | 267 | /** 268 | * Get group suffix 269 | * @param world World name 270 | * @param group Group name 271 | * @return Suffix 272 | */ 273 | abstract public String getGroupSuffix(String world, String group); 274 | 275 | /** 276 | * Get group suffix 277 | * @param world World Object 278 | * @param group Group name 279 | * @return Suffix 280 | */ 281 | public String getGroupSuffix(World world, String group) { 282 | return getGroupSuffix(world.getName(), group); 283 | } 284 | 285 | /** 286 | * Set group suffix 287 | * @param world World name 288 | * @param group Group name 289 | * @param suffix Suffix 290 | */ 291 | abstract public void setGroupSuffix(String world, String group, String suffix); 292 | 293 | /** 294 | * Set group suffix 295 | * @param world World Object 296 | * @param group Group name 297 | * @param suffix Suffix 298 | */ 299 | public void setGroupSuffix(World world, String group, String suffix) { 300 | setGroupSuffix(world.getName(), group, suffix); 301 | } 302 | 303 | /** 304 | * Get a players informational node (Integer) value 305 | * @param world World name 306 | * @param player OfflinePlayer 307 | * @param node Permission node 308 | * @param defaultValue Default value 309 | * @return Value 310 | */ 311 | public int getPlayerInfoInteger(String world, OfflinePlayer player, String node, int defaultValue) { 312 | return getPlayerInfoInteger(world, player.getName(), node, defaultValue); 313 | } 314 | 315 | /** 316 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoInteger(String, OfflinePlayer, String, int)} instead. 317 | * Get a players informational node (Integer) value 318 | * @param world World name 319 | * @param player Player name 320 | * @param node Permission node 321 | * @param defaultValue Default value 322 | * @return Value 323 | */ 324 | @Deprecated 325 | abstract public int getPlayerInfoInteger(String world, String player, String node, int defaultValue); 326 | 327 | /** 328 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoInteger(String, OfflinePlayer, String, int)} instead. 329 | * 330 | * Get a players informational node (Integer) value 331 | * @param world World Object 332 | * @param player Player name 333 | * @param node Permission node 334 | * @param defaultValue Default value 335 | * @return Value 336 | */ 337 | @Deprecated 338 | public int getPlayerInfoInteger(World world, String player, String node, int defaultValue) { 339 | return getPlayerInfoInteger(world.getName(), player, node, defaultValue); 340 | } 341 | 342 | /** 343 | * Get a players informational node (Integer) value 344 | * @param player Player Object 345 | * @param node Permission node 346 | * @param defaultValue Default value 347 | * @return Value 348 | */ 349 | public int getPlayerInfoInteger(Player player, String node, int defaultValue) { 350 | return getPlayerInfoInteger(player.getWorld().getName(), player, node, defaultValue); 351 | } 352 | 353 | /** 354 | * Set a players informational node (Integer) value 355 | * @param world World name 356 | * @param player OfflinePlayer 357 | * @param node Permission node 358 | * @param value Value to set 359 | */ 360 | public void setPlayerInfoInteger(String world, OfflinePlayer player, String node, int value) { 361 | setPlayerInfoInteger(world, player.getName(), node, value); 362 | } 363 | 364 | /** 365 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoInteger(String, OfflinePlayer, String, int)} instead. 366 | * 367 | * Set a players informational node (Integer) value 368 | * @param world World name 369 | * @param player Player name 370 | * @param node Permission node 371 | * @param value Value to set 372 | */ 373 | @Deprecated 374 | abstract public void setPlayerInfoInteger(String world, String player, String node, int value); 375 | 376 | /** 377 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoInteger(String, OfflinePlayer, String, int)} instead. 378 | * 379 | * Set a players informational node (Integer) value 380 | * @param world World Object 381 | * @param player Player name 382 | * @param node Permission node 383 | * @param value Value to set 384 | */ 385 | @Deprecated 386 | public void setPlayerInfoInteger(World world, String player, String node, int value) { 387 | setPlayerInfoInteger(world.getName(), player, node, value); 388 | } 389 | 390 | /** 391 | * Set a players informational node (Integer) value 392 | * @param player Player Object 393 | * @param node Permission node 394 | * @param value Value to set 395 | */ 396 | public void setPlayerInfoInteger(Player player, String node, int value) { 397 | setPlayerInfoInteger(player.getWorld().getName(), player, node, value); 398 | } 399 | 400 | /** 401 | * Get a groups informational node (Integer) value 402 | * @param world World name 403 | * @param group Group name 404 | * @param node Permission node 405 | * @param defaultValue Default value 406 | * @return Value 407 | */ 408 | abstract public int getGroupInfoInteger(String world, String group, String node, int defaultValue); 409 | 410 | /** 411 | * Get a groups informational node (Integer) value 412 | * @param world World Object 413 | * @param group Group name 414 | * @param node Permission node 415 | * @param defaultValue Default value 416 | * @return Value 417 | */ 418 | public int getGroupInfoInteger(World world, String group, String node, int defaultValue) { 419 | return getGroupInfoInteger(world.getName(), group, node, defaultValue); 420 | } 421 | 422 | /** 423 | * Set a groups informational node (Integer) value 424 | * @param world World name 425 | * @param group Group name 426 | * @param node Permission node 427 | * @param value Value to set 428 | */ 429 | abstract public void setGroupInfoInteger(String world, String group, String node, int value); 430 | 431 | /** 432 | * Set a groups informational node (Integer) value 433 | * @param world World Object 434 | * @param group Group name 435 | * @param node Permission node 436 | * @param value Value to set 437 | */ 438 | public void setGroupInfoInteger(World world, String group, String node, int value) { 439 | setGroupInfoInteger(world.getName(), group, node, value); 440 | } 441 | 442 | /** 443 | * Get a players informational node (Double) value 444 | * @param world World name 445 | * @param player OfflinePlayer 446 | * @param node Permission node 447 | * @param defaultValue Default value 448 | * @return Value 449 | */ 450 | public double getPlayerInfoDouble(String world, OfflinePlayer player, String node, double defaultValue) { 451 | return getPlayerInfoDouble(world, player.getName(), node, defaultValue); 452 | } 453 | 454 | /** 455 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoDouble(String, OfflinePlayer, String, double)} instead. 456 | * 457 | * Get a players informational node (Double) value 458 | * @param world World name 459 | * @param player Player name 460 | * @param node Permission node 461 | * @param defaultValue Default value 462 | * @return Value 463 | */ 464 | @Deprecated 465 | abstract public double getPlayerInfoDouble(String world, String player, String node, double defaultValue); 466 | 467 | /** 468 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoDouble(String, OfflinePlayer, String, double)} instead 469 | * 470 | * Get a players informational node (Double) value 471 | * @param world World Object 472 | * @param player Player name 473 | * @param node Permission node 474 | * @param defaultValue Default value 475 | * @return Value 476 | */ 477 | @Deprecated 478 | public double getPlayerInfoDouble(World world, String player, String node, double defaultValue) { 479 | return getPlayerInfoDouble(world.getName(), player, node, defaultValue); 480 | } 481 | 482 | /** 483 | * Get a players informational node (Double) value 484 | * @param player Player Object 485 | * @param node Permission node 486 | * @param defaultValue Default value 487 | * @return Value 488 | */ 489 | public double getPlayerInfoDouble(Player player, String node, double defaultValue) { 490 | return getPlayerInfoDouble(player.getWorld().getName(), player, node, defaultValue); 491 | } 492 | 493 | /** 494 | * Set a players informational node (Double) value 495 | * @param world World name 496 | * @param player OfflinePlayer 497 | * @param node Permission node 498 | * @param value Value to set 499 | */ 500 | public void setPlayerInfoDouble(String world, OfflinePlayer player, String node, double value) { 501 | setPlayerInfoDouble(world, player.getName(), node, value); 502 | } 503 | 504 | /** 505 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoDouble(String, OfflinePlayer, String, double)} instead. 506 | * Set a players informational node (Double) value 507 | * @param world World name 508 | * @param player Player name 509 | * @param node Permission node 510 | * @param value Value to set 511 | */ 512 | @Deprecated 513 | abstract public void setPlayerInfoDouble(String world, String player, String node, double value); 514 | 515 | /** 516 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoDouble(String, OfflinePlayer, String, double)} instead. 517 | * Set a players informational node (Double) value 518 | * @param world World Object 519 | * @param player Player name 520 | * @param node Permission node 521 | * @param value Value to set 522 | */ 523 | @Deprecated 524 | public void setPlayerInfoDouble(World world, String player, String node, double value) { 525 | setPlayerInfoDouble(world.getName(), player, node, value); 526 | } 527 | 528 | /** 529 | * Set a players informational node (Double) value 530 | * @param player Player Object 531 | * @param node Permission node 532 | * @param value Value to set 533 | */ 534 | public void setPlayerInfoDouble(Player player, String node, double value) { 535 | setPlayerInfoDouble(player.getWorld().getName(), player, node, value); 536 | } 537 | 538 | /** 539 | * Get a groups informational node (Double) value 540 | * @param world World name 541 | * @param group Group name 542 | * @param node Permission node 543 | * @param defaultValue Default value 544 | * @return Value 545 | */ 546 | abstract public double getGroupInfoDouble(String world, String group, String node, double defaultValue); 547 | 548 | /** 549 | * Get a groups informational node (Double) value 550 | * @param world World Object 551 | * @param group Group name 552 | * @param node Permission node 553 | * @param defaultValue Default value 554 | * @return Value 555 | */ 556 | public double getGroupInfoDouble(World world, String group, String node, double defaultValue) { 557 | return getGroupInfoDouble(world.getName(), group, node, defaultValue); 558 | } 559 | 560 | /** 561 | * Set a groups informational node (Double) value 562 | * @param world World name 563 | * @param group Group name 564 | * @param node Permission node 565 | * @param value Value to set 566 | */ 567 | abstract public void setGroupInfoDouble(String world, String group, String node, double value); 568 | 569 | /** 570 | * Set a groups informational node (Double) value 571 | * @param world World Object 572 | * @param group Group name 573 | * @param node Permission node 574 | * @param value Value to set 575 | */ 576 | public void setGroupInfoDouble(World world, String group, String node, double value) { 577 | setGroupInfoDouble(world.getName(), group, node, value); 578 | } 579 | 580 | /** 581 | * Get a players informational node (Boolean) value 582 | * @param world World name 583 | * @param player OfflinePlayer 584 | * @param node Permission node 585 | * @param defaultValue Default value 586 | * @return Value 587 | */ 588 | public boolean getPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean defaultValue) { 589 | return getPlayerInfoBoolean(world, player.getName(), node, defaultValue); 590 | } 591 | 592 | /** 593 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoBoolean(String, OfflinePlayer, String, boolean)} instead. 594 | * 595 | * Get a players informational node (Boolean) value 596 | * @param world World name 597 | * @param player Player name 598 | * @param node Permission node 599 | * @param defaultValue Default value 600 | * @return Value 601 | */ 602 | @Deprecated 603 | abstract public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue); 604 | 605 | /** 606 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoBoolean(String, OfflinePlayer, String, boolean)} instead. 607 | * 608 | * Get a players informational node (Boolean) value 609 | * @param world World Object 610 | * @param player Player name 611 | * @param node Permission node 612 | * @param defaultValue Default value 613 | * @return Value 614 | */ 615 | @Deprecated 616 | public boolean getPlayerInfoBoolean(World world, String player, String node, boolean defaultValue) { 617 | return getPlayerInfoBoolean(world.getName(), player, node, defaultValue); 618 | } 619 | 620 | /** 621 | * Get a players informational node (Boolean) value 622 | * @param player Player Object 623 | * @param node Permission node 624 | * @param defaultValue Default value 625 | * @return Value 626 | */ 627 | public boolean getPlayerInfoBoolean(Player player, String node, boolean defaultValue) { 628 | return getPlayerInfoBoolean(player.getWorld().getName(), player, node, defaultValue); 629 | } 630 | 631 | /** 632 | * Set a players informational node (Boolean) value 633 | * @param world World name 634 | * @param player OfflinePlayer 635 | * @param node Permission node 636 | * @param value Value to set 637 | */ 638 | public void setPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean value) { 639 | setPlayerInfoBoolean(world, player.getName(), node, value); 640 | } 641 | 642 | /** 643 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoBoolean(String, OfflinePlayer, String, boolean)} instead. 644 | * Set a players informational node (Boolean) value 645 | * @param world World name 646 | * @param player Player name 647 | * @param node Permission node 648 | * @param value Value to set 649 | */ 650 | @Deprecated 651 | abstract public void setPlayerInfoBoolean(String world, String player, String node, boolean value); 652 | 653 | /** 654 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoBoolean(String, OfflinePlayer, String, boolean)} instead. 655 | * Set a players informational node (Boolean) value 656 | * @param world World Object 657 | * @param player Player name 658 | * @param node Permission node 659 | * @param value Value to set 660 | */ 661 | @Deprecated 662 | public void setPlayerInfoBoolean(World world, String player, String node, boolean value) { 663 | setPlayerInfoBoolean(world.getName(), player, node, value); 664 | } 665 | 666 | /** 667 | * Set a players informational node (Boolean) value 668 | * @param player Player Object 669 | * @param node Permission node 670 | * @param value Value to set 671 | */ 672 | public void setPlayerInfoBoolean(Player player, String node, boolean value) { 673 | setPlayerInfoBoolean(player.getWorld().getName(), player, node, value); 674 | } 675 | 676 | /** 677 | * Get a groups informational node (Boolean) value 678 | * @param world Name of World 679 | * @param group Name of Group 680 | * @param node Permission node 681 | * @param defaultValue Default value 682 | * @return Value 683 | */ 684 | abstract public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue); 685 | 686 | /** 687 | * Set a players informational node (Boolean) value 688 | * @param world World Object 689 | * @param group Group name 690 | * @param node Permission node 691 | * @param defaultValue Default value 692 | * @return Value 693 | */ 694 | public boolean getGroupInfoBoolean(World world, String group, String node, boolean defaultValue) { 695 | return getGroupInfoBoolean(world.getName(), group, node, defaultValue); 696 | } 697 | 698 | /** 699 | * Set a groups informational node (Boolean) value 700 | * @param world World name 701 | * @param group Group name 702 | * @param node Permission node 703 | * @param value Value to set 704 | */ 705 | abstract public void setGroupInfoBoolean(String world, String group, String node, boolean value); 706 | 707 | /** 708 | * Set a players informational node (Boolean) value 709 | * @param world World Object 710 | * @param group Group name 711 | * @param node Permission node 712 | * @param value Value to set 713 | */ 714 | public void setGroupInfoBoolean(World world, String group, String node, boolean value) { 715 | setGroupInfoBoolean(world.getName(), group, node, value); 716 | } 717 | 718 | /** 719 | * Get a players informational node (String) value 720 | * @param world World name 721 | * @param player OfflinePlayer 722 | * @param node Permission node 723 | * @param defaultValue Default value 724 | * @return Value 725 | */ 726 | public String getPlayerInfoString(String world, OfflinePlayer player, String node, String defaultValue) { 727 | return getPlayerInfoString(world, player.getName(), node, defaultValue); 728 | } 729 | 730 | /** 731 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoString(String, OfflinePlayer, String, String)} instead. 732 | * 733 | * Get a players informational node (String) value 734 | * @param world World name 735 | * @param player Player name 736 | * @param node Permission node 737 | * @param defaultValue Default value 738 | * @return Value 739 | */ 740 | @Deprecated 741 | abstract public String getPlayerInfoString(String world, String player, String node, String defaultValue); 742 | 743 | /** 744 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerInfoString(String, OfflinePlayer, String, String)} instead. 745 | * Get a players informational node (String) value 746 | * @param world World Object 747 | * @param player Player name 748 | * @param node Permission node 749 | * @param defaultValue Default value 750 | * @return Value 751 | */ 752 | @Deprecated 753 | public String getPlayerInfoString(World world, String player, String node, String defaultValue) { 754 | return getPlayerInfoString(world.getName(), player, node, defaultValue); 755 | } 756 | 757 | /** 758 | * Get a players informational node (String) value 759 | * @param player Player Object 760 | * @param node Permission node 761 | * @param defaultValue Default value 762 | * @return Value 763 | */ 764 | public String getPlayerInfoString(Player player, String node, String defaultValue) { 765 | return getPlayerInfoString(player.getWorld().getName(), player, node, defaultValue); 766 | } 767 | 768 | /** 769 | * Set a players informational node (String) value 770 | * @param world World name 771 | * @param player OfflinePlayer 772 | * @param node Permission node 773 | * @param value Value to set 774 | */ 775 | public void setPlayerInfoString(String world, OfflinePlayer player, String node, String value) { 776 | setPlayerInfoString(world, player.getName(), node, value); 777 | } 778 | 779 | /** 780 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoString(String, OfflinePlayer, String, String)} instead. 781 | * Set a players informational node (String) value 782 | * @param world World name 783 | * @param player Player name 784 | * @param node Permission node 785 | * @param value Value to set 786 | */ 787 | @Deprecated 788 | abstract public void setPlayerInfoString(String world, String player, String node, String value); 789 | 790 | /** 791 | * @deprecated As of VaultAPI 1.4 use {{@link #setPlayerInfoString(String, OfflinePlayer, String, String)} instead. 792 | * Set a players informational node (String) value 793 | * @param world World name 794 | * @param player Player name 795 | * @param node Permission node 796 | * @param value Value to set 797 | */ 798 | @Deprecated 799 | public void setPlayerInfoString(World world, String player, String node, String value) { 800 | setPlayerInfoString(world.getName(), player, node, value); 801 | } 802 | 803 | /** 804 | * Set a players informational node (String) value 805 | * @param player Player Object 806 | * @param node Permission node 807 | * @param value Value ot set 808 | */ 809 | public void setPlayerInfoString(Player player, String node, String value) { 810 | setPlayerInfoString(player.getWorld().getName(), player, node, value); 811 | } 812 | 813 | /** 814 | * Get a groups informational node (String) value 815 | * @param world Name of World 816 | * @param group Name of Group 817 | * @param node Permission node 818 | * @param defaultValue Default value 819 | * @return Value 820 | */ 821 | abstract public String getGroupInfoString(String world, String group, String node, String defaultValue); 822 | 823 | /** 824 | * Set a players informational node (String) value 825 | * @param world World Object 826 | * @param group Group name 827 | * @param node Permission node 828 | * @param defaultValue Default value 829 | * @return Value 830 | */ 831 | public String getGroupInfoString(World world, String group, String node, String defaultValue) { 832 | return getGroupInfoString(world.getName(), group, node, defaultValue); 833 | } 834 | 835 | /** 836 | * Set a groups informational node (String) value 837 | * @param world World name 838 | * @param group Group name 839 | * @param node Permission node 840 | * @param value Value to set 841 | */ 842 | abstract public void setGroupInfoString(String world, String group, String node, String value); 843 | 844 | /** 845 | * Set a groups informational node (String) value 846 | * @param world World name 847 | * @param group Group name 848 | * @param node Permission node 849 | * @param value Value to set 850 | */ 851 | public void setGroupInfoString(World world, String group, String node, String value) { 852 | setGroupInfoString(world.getName(), group, node, value); 853 | } 854 | 855 | /** 856 | * Check if player is member of a group. 857 | * @param world World name 858 | * @param player OfflinePlayer 859 | * @param group Group name 860 | * @return Success or Failure 861 | */ 862 | public boolean playerInGroup(String world, OfflinePlayer player, String group) { 863 | return perms.playerInGroup(world, player, group); 864 | } 865 | 866 | /** 867 | * @deprecated As of VaultAPI 1.4 use {{@link #playerInGroup(String, OfflinePlayer, String)} instead. 868 | * Check if player is member of a group. 869 | * @param world World name 870 | * @param player Player name 871 | * @param group Group name 872 | * @return Success or Failure 873 | */ 874 | @Deprecated 875 | public boolean playerInGroup(String world, String player, String group) { 876 | return perms.playerInGroup(world, player, group); 877 | } 878 | 879 | /** 880 | * @deprecated As of VaultAPI 1.4 use {{@link #playerInGroup(String, OfflinePlayer, String)} instead. 881 | * Check if player is member of a group. 882 | * @param world World Object 883 | * @param player Player name 884 | * @param group Group name 885 | * @return Success or Failure 886 | */ 887 | @Deprecated 888 | public boolean playerInGroup(World world, String player, String group) { 889 | return playerInGroup(world.getName(), player, group); 890 | } 891 | 892 | /** 893 | * Check if player is member of a group. 894 | * @param player Player Object 895 | * @param group Group name 896 | * @return Success or Failure 897 | */ 898 | public boolean playerInGroup(Player player, String group) { 899 | return playerInGroup(player.getWorld().getName(), player, group); 900 | } 901 | 902 | /** 903 | * Gets the list of groups that this player has 904 | * @param world World name 905 | * @param player OfflinePlayer 906 | * @return Array of groups 907 | */ 908 | public String[] getPlayerGroups(String world, OfflinePlayer player) { 909 | return perms.getPlayerGroups(world, player); 910 | } 911 | 912 | /** 913 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerGroups(String, OfflinePlayer)} instead. 914 | * Gets the list of groups that this player has 915 | * @param world World name 916 | * @param player Player name 917 | * @return Array of groups 918 | */ 919 | @Deprecated 920 | public String[] getPlayerGroups(String world, String player) { 921 | return perms.getPlayerGroups(world, player); 922 | } 923 | 924 | /** 925 | * @deprecated As of VaultAPI 1.4 use {{@link #getPlayerGroups(String, OfflinePlayer)} instead. 926 | * Gets the list of groups that this player has 927 | * @param world World Object 928 | * @param player Player name 929 | * @return Array of groups 930 | */ 931 | @Deprecated 932 | public String[] getPlayerGroups(World world, String player) { 933 | return getPlayerGroups(world.getName(), player); 934 | } 935 | 936 | /** 937 | * Gets the list of groups that this player has 938 | * @param player Player Object 939 | * @return Array of groups 940 | */ 941 | public String[] getPlayerGroups(Player player) { 942 | return getPlayerGroups(player.getWorld().getName(), player); 943 | } 944 | 945 | /** 946 | * Gets players primary group 947 | * @param world World name 948 | * @param player OfflinePlayer 949 | * @return Players primary group 950 | */ 951 | public String getPrimaryGroup(String world, OfflinePlayer player) { 952 | return perms.getPrimaryGroup(world, player); 953 | } 954 | 955 | /** 956 | * @deprecated As of VaultAPI 1.4 use {{@link #getPrimaryGroup(String, OfflinePlayer)} instead. 957 | * Gets players primary group 958 | * @param world World name 959 | * @param player Player name 960 | * @return Players primary group 961 | */ 962 | @Deprecated 963 | public String getPrimaryGroup(String world, String player) { 964 | return perms.getPrimaryGroup(world, player); 965 | } 966 | 967 | /** 968 | * @deprecated As of VaultAPI 1.4 use {{@link #getPrimaryGroup(String, OfflinePlayer)} instead. 969 | * Gets players primary group 970 | * @param world World Object 971 | * @param player Player name 972 | * @return Players primary group 973 | */ 974 | @Deprecated 975 | public String getPrimaryGroup(World world, String player) { 976 | return getPrimaryGroup(world.getName(), player); 977 | } 978 | 979 | /** 980 | * Get players primary group 981 | * @param player Player Object 982 | * @return Players primary group 983 | */ 984 | public String getPrimaryGroup(Player player) { 985 | return getPrimaryGroup(player.getWorld().getName(), player); 986 | } 987 | 988 | /** 989 | * Returns a list of all known groups 990 | * @return an Array of String of all groups 991 | */ 992 | public String[] getGroups() { 993 | return perms.getGroups(); 994 | } 995 | } 996 | -------------------------------------------------------------------------------- /src/main/java/net/milkbowl/vault2/economy/AccountPermission.java: -------------------------------------------------------------------------------- 1 | package net.milkbowl.vault2.economy; 2 | 3 | /* This file is part of Vault. 4 | 5 | Vault is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | Vault is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with Vault. If not, see . 17 | */ 18 | 19 | /** 20 | * AccountPermission 21 | * 22 | * @author creatorfromhell 23 | * @since 2.7 24 | */ 25 | public enum AccountPermission { 26 | 27 | DEPOSIT, 28 | WITHDRAW, 29 | BALANCE, 30 | TRANSFER_OWNERSHIP, 31 | INVITE_MEMBER, 32 | REMOVE_MEMBER, 33 | CHANGE_MEMBER_PERMISSION, 34 | OWNER, 35 | DELETE 36 | } -------------------------------------------------------------------------------- /src/main/java/net/milkbowl/vault2/economy/Economy.java: -------------------------------------------------------------------------------- 1 | /* This file is part of Vault. 2 | 3 | Vault is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | Vault is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with Vault. If not, see . 15 | */ 16 | 17 | package net.milkbowl.vault2.economy; 18 | 19 | import net.milkbowl.vault2.economy.EconomyResponse.ResponseType; 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | import java.math.BigDecimal; 23 | import java.util.Collection; 24 | import java.util.Map; 25 | import java.util.Optional; 26 | import java.util.UUID; 27 | 28 | /** 29 | * The main economy API 30 | * 31 | */ 32 | public interface Economy { 33 | 34 | /* 35 | * Economy plugin-related methods follow. 36 | */ 37 | 38 | /** 39 | * Checks if economy plugin is enabled. 40 | * 41 | * @return true if the server's economy plugin has properly enabled. 42 | */ 43 | boolean isEnabled(); 44 | 45 | /** 46 | * Gets name of the economy plugin. 47 | * 48 | * @return Name of the active economy plugin on the server. 49 | */ 50 | @NotNull 51 | String getName(); 52 | 53 | /** 54 | * Returns true if the economy plugin supports shared accounts. 55 | * 56 | * @return true if the economy plugin supports shared accounts. 57 | */ 58 | boolean hasSharedAccountSupport(); 59 | 60 | /** 61 | * Returns true if the economy plugin supports multiple currencies. 62 | * 63 | * @return true if the economy plugin supports multiple currencies. 64 | */ 65 | boolean hasMultiCurrencySupport(); 66 | 67 | /* 68 | * Currency-related methods follow. 69 | */ 70 | 71 | /** 72 | * Some economy plugins round off after a certain number of digits. This 73 | * function returns the number of digits the plugin keeps or -1 if no rounding 74 | * occurs. 75 | * 76 | * @param pluginName The name of the plugin that is calling the method. 77 | * @return number of digits after the decimal point this plugin supports or -1 78 | * if no rounding occurs. 79 | */ 80 | @NotNull 81 | int fractionalDigits(@NotNull final String pluginName); 82 | 83 | /** 84 | * Plugins use this method to format a given BigDecimal amount into a human-readable 85 | * amount using your economy plugin's currency names/conventions. 86 | * 87 | * @deprecated This method is deprecated as of version 2.8, and has been replaced by {@link #format(String, BigDecimal)}. 88 | * This allows economy plugins to know exactly if the account is a player or not. This may be removed in a future release. 89 | * 90 | * @param amount to format. 91 | * 92 | * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. 93 | */ 94 | @NotNull 95 | @Deprecated 96 | String format(@NotNull final BigDecimal amount); 97 | 98 | /** 99 | * Plugins use this method to format a given BigDecimal amount into a human-readable 100 | * amount using your economy plugin's currency names/conventions. 101 | * 102 | * @param pluginName The name of the plugin that is calling the method. 103 | * @param amount to format. 104 | * 105 | * @return Human-readable String describing amount, ie 5 Dollars or 5.55 Pounds. 106 | */ 107 | @NotNull 108 | String format(@NotNull final String pluginName, @NotNull final BigDecimal amount); 109 | 110 | /** 111 | * Plugins use this method to format a given BigDecimal amount into a human-readable 112 | * amount using your economy plugin's currency names/conventions. 113 | * 114 | * @deprecated This method is deprecated as of version 2.8, and has been replaced by {@link #format(String, BigDecimal, String)}. 115 | * This allows economy plugins to know exactly if the account is a player or not. This may be removed in a future release. 116 | * 117 | * @param amount to format. 118 | * @param currency the currency to use for the format. 119 | * 120 | * @return Human-readable string describing amount, ie 5 Dollars or 5.55 Pounds. 121 | */ 122 | @NotNull 123 | @Deprecated 124 | String format(@NotNull final BigDecimal amount, @NotNull final String currency); 125 | 126 | /** 127 | * Plugins use this method to format a given BigDecimal amount into a human-readable 128 | * amount using your economy plugin's currency names/conventions. 129 | * 130 | * @param pluginName The name of the plugin that is calling the method. 131 | * @param amount to format. 132 | * @param currency the currency to use for the format. 133 | * 134 | * @return Human-readable String describing amount, ie 5 Dollars or 5.55 Pounds. 135 | */ 136 | @NotNull 137 | String format(@NotNull final String pluginName, @NotNull final BigDecimal amount, @NotNull final String currency); 138 | 139 | /** 140 | * Returns true if a currency with the specified name exists. 141 | * 142 | * @param currency the currency to use. 143 | * 144 | * @return true if a currency with the specified name exists. 145 | */ 146 | boolean hasCurrency(@NotNull final String currency); 147 | 148 | /** 149 | * Used to get the default currency. This could be the default currency for the server globally or 150 | * for the default world if the implementation supports multi-world. 151 | * 152 | * @param pluginName The name of the plugin that is calling the method. 153 | * @return The currency that is the default for the server if multi-world support is not available 154 | * otherwise the default for the default world. 155 | * 156 | */ 157 | @NotNull 158 | String getDefaultCurrency(@NotNull final String pluginName); 159 | 160 | /** 161 | * Returns the name of the default currency in plural form. If the economy being used 162 | * does not support currency names then an empty string will be returned. 163 | * 164 | * @param pluginName The name of the plugin that is calling the method. 165 | * @return name of the currency (plural) ie: Dollars or Pounds. 166 | */ 167 | @NotNull 168 | String defaultCurrencyNamePlural(@NotNull final String pluginName); 169 | 170 | /** 171 | * Returns the name of the default currency in singular form. If the economy being used 172 | * does not support currency names then an empty string will be returned. 173 | * 174 | * @param pluginName The name of the plugin that is calling the method. 175 | * @return name of the currency (singular) ie: Dollar or Pound. 176 | */ 177 | @NotNull 178 | String defaultCurrencyNameSingular(@NotNull final String pluginName); 179 | 180 | /** 181 | * Returns a list of currencies used by the economy plugin. These are able to be used 182 | * in the calls in the methods of the API. May not be human-readable. 183 | * 184 | * @return list of currencies used by the economy plugin. These are able to be used 185 | * in the calls in the methods of the API. 186 | */ 187 | @NotNull 188 | Collection currencies(); 189 | 190 | /* 191 | * Account-related methods follow. 192 | */ 193 | 194 | /** 195 | * Attempts to create an account for the given UUID. 196 | * 197 | * @deprecated This method is deprecated as of version 2.8, and has been replaced by {@link #createAccount(UUID, String, String, boolean)}. 198 | * This allows economy plugins to know exactly if the account is a player or not. This may be removed in a future release. 199 | * 200 | * @param accountID UUID associated with the account. 201 | * @param name UUID associated with the account. 202 | * @return true if the account creation was successful. 203 | */ 204 | @Deprecated 205 | boolean createAccount(@NotNull final UUID accountID, @NotNull final String name); 206 | 207 | /** 208 | * Creates a new account with the provided information. 209 | * 210 | * @param accountID The UUID of the account to be created. 211 | * @param name The name associated with the account. 212 | * @param player A flag indicating if the account is a player account. 213 | * 214 | * @return true if the account was successfully created, false otherwise. 215 | */ 216 | boolean createAccount(@NotNull final UUID accountID, @NotNull final String name, final boolean player); 217 | 218 | /** 219 | * Attempts to create an account for the given UUID on the specified world 220 | * IMPLEMENTATION SPECIFIC - if an economy plugin does not support this then 221 | * false will always be returned. 222 | * 223 | * @deprecated This method is deprecated as of version 2.8, and has been replaced by {@link #createAccount(UUID, String, String, boolean)}. 224 | * This allows economy plugins to know exactly if the account is a player or not. This may be removed in a future release. 225 | * 226 | * @param accountID UUID associated with the account. 227 | * @param name UUID associated with the account. 228 | * @param worldName String name of the world. 229 | * @return if the account creation was successful 230 | */ 231 | @Deprecated 232 | boolean createAccount(@NotNull final UUID accountID, @NotNull final String name, @NotNull final String worldName); 233 | 234 | /** 235 | * Creates a new account with the given parameters. 236 | * 237 | * @param accountID The UUID of the account to be created. 238 | * @param name The name of the account holder. 239 | * @param worldName The world name associated with the account. 240 | * @param player A boolean indicating if the account belongs to a player. 241 | * 242 | * @return True if the account was successfully created, false otherwise. 243 | */ 244 | boolean createAccount(@NotNull final UUID accountID, @NotNull final String name, @NotNull final String worldName, final boolean player); 245 | 246 | /** 247 | * Returns a map that represents all the UUIDs which have accounts in the 248 | * plugin, as well as their last-known-name. This is used for Vault's economy 249 | * converter and should be given every account available. 250 | * 251 | * @return a {@link Map} composed of the accounts keyed by their UUID, along 252 | * with their associated last-known-name. 253 | */ 254 | @NotNull 255 | Map getUUIDNameMap(); 256 | 257 | /** 258 | * Gets the last known name of an account owned by the given UUID. Required for 259 | * messages to be more human-readable than UUIDs alone can provide. 260 | * 261 | * @param accountID UUID associated with the account. 262 | * @return An optional containing the last known name if the account exists, otherwise an empty 263 | * optional. 264 | */ 265 | Optional getAccountName(@NotNull final UUID accountID); 266 | 267 | /** 268 | * Checks if this UUID has an account yet. 269 | * 270 | * @param accountID UUID to check for an existing account. 271 | * @return true if the UUID has an account. 272 | */ 273 | boolean hasAccount(@NotNull final UUID accountID); 274 | 275 | /** 276 | * Checks if this UUID has an account yet on the given world. 277 | * 278 | * @param accountID UUID to check for an existing account. 279 | * @param worldName world-specific account. 280 | * @return if the UUID has an account. 281 | */ 282 | boolean hasAccount(@NotNull final UUID accountID, @NotNull final String worldName); 283 | 284 | /** 285 | * A method which changes the name associated with the given UUID in the 286 | * value returned from {@link #getUUIDNameMap()}. 287 | * 288 | * @param accountID UUID whose account is having a name change. 289 | * @param name String name that will be associated with the UUID in the map. 290 | * @return true if the name change is successful. 291 | */ 292 | boolean renameAccount(@NotNull final UUID accountID, @NotNull final String name); 293 | 294 | /** 295 | * Renames the account with the specified ID in the given plugin to the new name. 296 | * 297 | * @param plugin The plugin name where the account exists 298 | * @param accountID The unique identifier of the account to be renamed 299 | * @param name The new name to assign to the account 300 | * 301 | * @return true if the rename operation was successful, false otherwise 302 | */ 303 | boolean renameAccount(@NotNull final String plugin, @NotNull final UUID accountID, @NotNull final String name); 304 | 305 | /** 306 | * Deletes the account associated with the specified UUID. 307 | * 308 | * @param plugin the name of the plugin managing the account 309 | * @param accountID the UUID of the account to be deleted 310 | * @return true if the account was successfully deleted, false otherwise 311 | */ 312 | boolean deleteAccount(@NotNull final String plugin, @NotNull final UUID accountID); 313 | 314 | /* 315 | * Account balance related methods follow. 316 | */ 317 | 318 | /** 319 | * Determines whether an account supports a specific currency. 320 | * 321 | * @param plugin the name of the plugin 322 | * @param accountID the UUID of the account 323 | * @param currency the currency to check support for 324 | * @return true if the account supports the currency, false otherwise 325 | */ 326 | boolean accountSupportsCurrency(@NotNull final String plugin, @NotNull final UUID accountID, @NotNull final String currency); 327 | 328 | /** 329 | * Checks if the given account supports the specified currency in the given world. 330 | * 331 | * @param plugin the name of the plugin requesting the check 332 | * @param accountID the UUID of the player account 333 | * @param currency the currency code to check support for 334 | * @param world the name of the world to check in 335 | * @return true if the account supports the currency in the world, false otherwise 336 | */ 337 | boolean accountSupportsCurrency(@NotNull final String plugin, @NotNull final UUID accountID, @NotNull final String currency, @NotNull final String world); 338 | 339 | /** 340 | * Gets balance of an account associated with a UUID. 341 | * 342 | * @deprecated This method is deprecated as of version 2.9, and has been replaced by {@link #balance(String, UUID)}. 343 | * This allows economy plugins to know exactly if the account is a player or not. This may be removed in a future release. 344 | * 345 | * @param pluginName The name of the plugin that is calling the method. 346 | * @param accountID UUID of the account to get a balance for. 347 | * @return Amount currently held in account associated with the given UUID. 348 | */ 349 | @NotNull 350 | @Deprecated 351 | BigDecimal getBalance(@NotNull final String pluginName, @NotNull final UUID accountID); 352 | 353 | /** 354 | * Gets balance of a UUID on the specified world. IMPLEMENTATION SPECIFIC - if 355 | * an economy plugin does not support this the global balance will be returned. 356 | * 357 | * @deprecated This method is deprecated as of version 2.9, and has been replaced by {@link #balance(String, UUID, String)}. 358 | * This allows economy plugins to know exactly if the account is a player or not. This may be removed in a future release. 359 | * 360 | * @param pluginName The name of the plugin that is calling the method. 361 | * @param accountID UUID of the account to get a balance for. 362 | * @param world name of the world. 363 | * @return Amount currently held in account associated with the given UUID. 364 | */ 365 | @NotNull 366 | @Deprecated 367 | BigDecimal getBalance(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String world); 368 | 369 | /** 370 | * Gets balance of a UUID on the specified world. IMPLEMENTATION SPECIFIC - if 371 | * an economy plugin does not support this the global balance will be returned. 372 | * 373 | * @deprecated This method is deprecated as of version 2.9, and has been replaced by {@link #balance(String, UUID, String, String)}. 374 | * This allows economy plugins to know exactly if the account is a player or not. This may be removed in a future release. 375 | * 376 | * @param pluginName The name of the plugin that is calling the method. 377 | * @param accountID UUID of the account to get a balance for. 378 | * @param world name of the world. 379 | * @param currency the currency to use. 380 | * @return Amount currently held in account associated with the given UUID. 381 | */ 382 | @NotNull 383 | @Deprecated 384 | BigDecimal getBalance(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String world, @NotNull final String currency); 385 | 386 | /** 387 | * Gets balance of an account associated with a UUID. 388 | * 389 | * @param pluginName The name of the plugin that is calling the method. 390 | * @param accountID UUID of the account to get a balance for. 391 | * @return Amount currently held in account associated with the given UUID. 392 | */ 393 | @NotNull 394 | default BigDecimal balance(@NotNull final String pluginName, @NotNull final UUID accountID) { 395 | return getBalance(pluginName, accountID); 396 | } 397 | 398 | /** 399 | * Gets balance of a UUID on the specified world. IMPLEMENTATION SPECIFIC - if 400 | * an economy plugin does not support this the global balance will be returned. 401 | * 402 | * @param pluginName The name of the plugin that is calling the method. 403 | * @param accountID UUID of the account to get a balance for. 404 | * @param world name of the world. 405 | * @return Amount currently held in account associated with the given UUID. 406 | */ 407 | @NotNull 408 | default BigDecimal balance(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String world) { 409 | return getBalance(pluginName, accountID, world); 410 | } 411 | 412 | /** 413 | * Gets balance of a UUID on the specified world. IMPLEMENTATION SPECIFIC - if 414 | * an economy plugin does not support this the global balance will be returned. 415 | * 416 | * @param pluginName The name of the plugin that is calling the method. 417 | * @param accountID UUID of the account to get a balance for. 418 | * @param world name of the world. 419 | * @param currency the currency to use. 420 | * @return Amount currently held in account associated with the given UUID. 421 | */ 422 | @NotNull 423 | default BigDecimal balance(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String world, @NotNull final String currency) { 424 | return getBalance(pluginName, accountID, world, currency); 425 | } 426 | 427 | /** 428 | * Checks if the account associated with the given UUID has the amount - DO NOT 429 | * USE NEGATIVE AMOUNTS. 430 | * 431 | * @param pluginName The name of the plugin that is calling the method. 432 | * @param accountID the UUID associated with the account to check the balance of. 433 | * @param amount the amount to check for. 434 | * @return True if UUID has amount, False else wise. 435 | */ 436 | boolean has(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final BigDecimal amount); 437 | 438 | /** 439 | * Checks if the account associated with the given UUID has the amount in the 440 | * given world - DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an 441 | * economy plugin does not support this the global balance will be returned. 442 | * 443 | * @param pluginName The name of the plugin that is calling the method. 444 | * @param accountID the UUID associated with the account to check the balance of. 445 | * @param worldName the name of the world to check in. 446 | * @param amount the amount to check for. 447 | * @return True if UUID has amount in the given world, 448 | * False else wise. 449 | */ 450 | boolean has(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final BigDecimal amount); 451 | 452 | /** 453 | * Checks if the account associated with the given UUID has the amount in the 454 | * given world - DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an 455 | * economy plugin does not support this the global balance will be returned. 456 | * 457 | * @param pluginName The name of the plugin that is calling the method. 458 | * @param accountID the UUID associated with the account to check the balance of. 459 | * @param worldName the name of the world to check in. 460 | * @param currency the currency to use. 461 | * @param amount the amount to check for. 462 | * @return True if UUID has amount in the given world, 463 | * False else wise. 464 | */ 465 | boolean has(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final String currency, @NotNull final BigDecimal amount); 466 | 467 | /** 468 | * 469 | * Sets the amount of monies for a player. 470 | * 471 | * @param pluginName the name of the plugin setting the currency 472 | * @param accountID the unique identifier of the player's account 473 | * @param amount the amount of currency to set for the player in the specified world 474 | * @return an EconomyResponse object indicating the result of the operation 475 | */ 476 | default EconomyResponse set(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final BigDecimal amount) { 477 | 478 | final BigDecimal balance = balance(pluginName, accountID); 479 | final int compare = balance.compareTo(amount); 480 | if(compare > 0) { 481 | return withdraw(pluginName, accountID, balance.subtract(amount)); 482 | } 483 | 484 | if(compare < 0) { 485 | return deposit(pluginName, accountID, amount.subtract(balance)); 486 | } 487 | 488 | return new EconomyResponse(BigDecimal.ZERO, amount, ResponseType.SUCCESS, ""); 489 | } 490 | 491 | /** 492 | * 493 | * Sets the amount of monies for a player in a specific world. 494 | * 495 | * @param pluginName the name of the plugin setting the currency 496 | * @param accountID the unique identifier of the player's account 497 | * @param worldName the name of the world where the currency amount is being set 498 | * @param amount the amount of currency to set for the player in the specified world 499 | * @return an EconomyResponse object indicating the result of the operation 500 | */ 501 | default EconomyResponse set(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final BigDecimal amount) { 502 | 503 | final BigDecimal balance = balance(pluginName, accountID, worldName); 504 | final int compare = balance.compareTo(amount); 505 | if(compare > 0) { 506 | return withdraw(pluginName, accountID, worldName, balance.subtract(amount)); 507 | } 508 | 509 | if(compare < 0) { 510 | return deposit(pluginName, accountID, worldName, amount.subtract(balance)); 511 | } 512 | 513 | return new EconomyResponse(BigDecimal.ZERO, amount, ResponseType.SUCCESS, ""); 514 | } 515 | 516 | /** 517 | * 518 | * Sets the amount of specified currency for a player in a specific world. 519 | * 520 | * @param pluginName the name of the plugin setting the currency 521 | * @param accountID the unique identifier of the player's account 522 | * @param worldName the name of the world where the currency amount is being set 523 | * @param currency the name of the currency being set 524 | * @param amount the amount of currency to set for the player in the specified world 525 | * @return an EconomyResponse object indicating the result of the operation 526 | */ 527 | default EconomyResponse set(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final String currency, @NotNull final BigDecimal amount) { 528 | 529 | final BigDecimal balance = balance(pluginName, accountID, worldName, currency); 530 | final int compare = balance.compareTo(amount); 531 | if(compare > 0) { 532 | return withdraw(pluginName, accountID, worldName, currency, balance.subtract(amount)); 533 | } 534 | 535 | if(compare < 0) { 536 | return deposit(pluginName, accountID, worldName, currency, amount.subtract(balance)); 537 | } 538 | 539 | return new EconomyResponse(BigDecimal.ZERO, amount, ResponseType.SUCCESS, ""); 540 | } 541 | 542 | /** 543 | * Withdraw an amount from an account associated with a UUID - DO NOT USE 544 | * NEGATIVE AMOUNTS. 545 | * 546 | * @param pluginName The name of the plugin that is calling the method. 547 | * @param accountID the UUID associated with the account to withdraw from. 548 | * @param amount Amount to withdraw. 549 | * @return {@link EconomyResponse} which includes the Economy plugin's 550 | * {@link ResponseType} as to whether the transaction was a Success, 551 | * Failure, Unsupported. 552 | */ 553 | @NotNull 554 | EconomyResponse withdraw(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final BigDecimal amount); 555 | 556 | /** 557 | * Withdraw an amount from an account associated with a UUID on a given world - 558 | * DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an economy plugin 559 | * does not support this the global balance will be returned. 560 | * 561 | * @param pluginName The name of the plugin that is calling the method. 562 | * @param accountID the UUID associated with the account to withdraw from. 563 | * @param worldName the name of the world to check in. 564 | * @param amount Amount to withdraw. 565 | * @return {@link EconomyResponse} which includes the Economy plugin's 566 | * {@link ResponseType} as to whether the transaction was a Success, 567 | * Failure, Unsupported. 568 | */ 569 | @NotNull 570 | EconomyResponse withdraw(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final BigDecimal amount); 571 | 572 | /** 573 | * Withdraw an amount from an account associated with a UUID on a given world - 574 | * DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an economy plugin 575 | * does not support this the global balance will be returned. 576 | * 577 | * @param pluginName The name of the plugin that is calling the method. 578 | * @param accountID the UUID associated with the account to withdraw from. 579 | * @param worldName the name of the world to check in. 580 | * @param currency the currency to use. 581 | * @param amount Amount to withdraw. 582 | * @return {@link EconomyResponse} which includes the Economy plugin's 583 | * {@link ResponseType} as to whether the transaction was a Success, 584 | * Failure, Unsupported. 585 | */ 586 | @NotNull 587 | EconomyResponse withdraw(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final String currency, @NotNull final BigDecimal amount); 588 | 589 | /** 590 | * Deposit an amount to an account associated with the given UUID - DO NOT USE 591 | * NEGATIVE AMOUNTS. 592 | * 593 | * @param pluginName The name of the plugin that is calling the method. 594 | * @param accountID the UUID associated with the account to deposit to. 595 | * @param amount Amount to deposit. 596 | * @return {@link EconomyResponse} which includes the Economy plugin's 597 | * {@link ResponseType} as to whether the transaction was a Success, 598 | * Failure, Unsupported. 599 | */ 600 | @NotNull 601 | EconomyResponse deposit(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final BigDecimal amount); 602 | 603 | /** 604 | * Deposit an amount to an account associated with a UUID on a given world - 605 | * DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an economy plugin 606 | * does not support this the global balance will be returned. 607 | * 608 | * @param pluginName The name of the plugin that is calling the method. 609 | * @param accountID the {@link UUID} associated with the account to deposit to. 610 | * @param worldName the name of the world to check in. 611 | * @param amount Amount to deposit. 612 | * @return {@link EconomyResponse} which includes the Economy plugin's 613 | * {@link ResponseType} as to whether the transaction was a Success, 614 | * Failure, Unsupported. 615 | */ 616 | @NotNull 617 | EconomyResponse deposit(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final BigDecimal amount); 618 | 619 | /** 620 | * Deposit an amount to an account associated with a UUID on a given world - 621 | * DO NOT USE NEGATIVE AMOUNTS IMPLEMENTATION SPECIFIC - if an economy plugin 622 | * does not support this the global balance will be returned. 623 | * 624 | * @param pluginName The name of the plugin that is calling the method. 625 | * @param accountID the {@link UUID} associated with the account to deposit to. 626 | * @param worldName the name of the world to check in. 627 | * @param currency the currency to use. 628 | * @param amount Amount to deposit. 629 | * @return {@link EconomyResponse} which includes the Economy plugin's 630 | * {@link ResponseType} as to whether the transaction was a Success, 631 | * Failure, Unsupported. 632 | */ 633 | @NotNull 634 | EconomyResponse deposit(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String worldName, @NotNull final String currency, @NotNull final BigDecimal amount); 635 | 636 | /* 637 | * Shared Account Methods 638 | */ 639 | 640 | /** 641 | * Creates a shared account with the specified parameters. 642 | * 643 | * @param pluginName the name of the plugin 644 | * @param accountID the {@link UUID} of the account 645 | * @param name the name of the account 646 | * @param owner the {@link UUID} of the account owner 647 | * @return true if the shared account is successfully created, false otherwise 648 | */ 649 | boolean createSharedAccount(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final String name, @NotNull final UUID owner); 650 | 651 | /** 652 | * Determines whether the specified owner ID is the owner of the account associated with the given account ID and plugin name. 653 | * 654 | * @param pluginName the name of the plugin 655 | * @param accountID the {@link UUID} of the account 656 | * @param uuid the {@link UUID} to check for ownership of the account 657 | * @return true if the owner ID is the owner of the account, false otherwise 658 | */ 659 | boolean isAccountOwner(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final UUID uuid); 660 | 661 | /** 662 | * Sets the owner of a specified plugin to the given accountID. 663 | * 664 | * @param pluginName The name of the plugin. 665 | * @param accountID The {@link UUID} of the account 666 | * @param uuid The {@link UUID} of the account to set as the owner. 667 | * @return true if the owner is successfully set, false otherwise. 668 | */ 669 | boolean setOwner(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final UUID uuid); 670 | 671 | /** 672 | * Determines whether a specific member is an account member of a given plugin. 673 | * 674 | * @param pluginName The name of the plugin. 675 | * @param accountID The {@link UUID} of the account. 676 | * @param uuid The {@link UUID} to check for membership. 677 | * @return true if the member is an account member, false otherwise. 678 | */ 679 | boolean isAccountMember(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final UUID uuid); 680 | 681 | /** 682 | * Adds a member to an account. 683 | * 684 | * @param pluginName The name of the plugin. 685 | * @param accountID The {@link UUID} of the account. 686 | * @param uuid The {@link UUID} of the member to be added. 687 | * @return true if the member was successfully added, false otherwise. 688 | */ 689 | boolean addAccountMember(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final UUID uuid); 690 | 691 | /** 692 | * Adds a member to an account with the specified initial permissions. 693 | * 694 | * @param pluginName The name of the plugin. 695 | * @param accountID The {@link UUID} of the account. 696 | * @param uuid The {@link UUID} of the member to be added. 697 | * @param initialPermissions The initial permissions to be assigned to the member. The values for 698 | * these should be assumed to be "true." 699 | * @return true if the member was added successfully, false otherwise. 700 | */ 701 | boolean addAccountMember(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final UUID uuid, @NotNull final AccountPermission... initialPermissions); 702 | 703 | /** 704 | * Removes a member from an account. 705 | * 706 | * @param pluginName the name of the plugin managing the account 707 | * @param accountID the {@link UUID} of the account 708 | * @param uuid the {@link UUID} of the member to be removed 709 | * @return true if the member was successfully removed, false otherwise 710 | */ 711 | boolean removeAccountMember(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final UUID uuid); 712 | 713 | /** 714 | * Checks if the specified account has the given permission for the given plugin. 715 | * 716 | * @param pluginName the name of the plugin to check permission for 717 | * @param accountID the {@link UUID} of the account 718 | * @param uuid the {@link UUID} to check for the permission 719 | * @param permission the permission to check for 720 | * @return true if the account has the specified permission, false otherwise 721 | */ 722 | boolean hasAccountPermission(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final UUID uuid, @NotNull final AccountPermission permission); 723 | 724 | /** 725 | * Updates the account permission for a specific plugin and user. 726 | * 727 | * @param pluginName the name of the plugin 728 | * @param accountID the {@link UUID} of the account 729 | * @param uuid the {@link UUID} to update the permission for 730 | * @param permission the new account permissions to set 731 | * @param value the new permission value to set for this value 732 | * @return true if the account permission was successfully updated, false otherwise 733 | */ 734 | boolean updateAccountPermission(@NotNull final String pluginName, @NotNull final UUID accountID, @NotNull final UUID uuid, @NotNull final AccountPermission permission, final boolean value); 735 | } 736 | -------------------------------------------------------------------------------- /src/main/java/net/milkbowl/vault2/economy/EconomyResponse.java: -------------------------------------------------------------------------------- 1 | /* This file is part of Vault. 2 | 3 | Vault is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | Vault is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with Vault. If not, see . 15 | */ 16 | package net.milkbowl.vault2.economy; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | import java.math.BigDecimal; 21 | 22 | /** 23 | * Indicates a typical Return for an Economy method. It includes a 24 | * {@link ResponseType} indicating whether the plugin currently being used for 25 | * Economy actually allows the method, or if the operation was a success or 26 | * failure. 27 | * 28 | */ 29 | public class EconomyResponse { 30 | 31 | /** 32 | * Enum for types of Responses indicating the status of a method call. 33 | */ 34 | public enum ResponseType { 35 | SUCCESS(1), 36 | FAILURE(2), 37 | NOT_IMPLEMENTED(3); 38 | 39 | private int id; 40 | 41 | ResponseType(final int id) { 42 | this.id = id; 43 | } 44 | 45 | int getId() { 46 | return id; 47 | } 48 | } 49 | 50 | /** 51 | * Amount modified by calling method 52 | */ 53 | public final BigDecimal amount; 54 | /** 55 | * New balance of account 56 | */ 57 | public final BigDecimal balance; 58 | /** 59 | * Success or failure of call. Using Enum of ResponseType to determine valid 60 | * outcomes 61 | */ 62 | public final ResponseType type; 63 | /** 64 | * Error message if the variable 'type' is ResponseType.FAILURE 65 | */ 66 | public final String errorMessage; 67 | 68 | /** 69 | * Constructor for EconomyResponse 70 | * @param amount Amount modified during operation 71 | * @param balance New balance of account 72 | * @param type Success or failure type of the operation 73 | * @param errorMessage Error message if necessary (commonly null) 74 | */ 75 | public EconomyResponse(@NotNull final BigDecimal amount, @NotNull final BigDecimal balance, @NotNull final ResponseType type, @NotNull final String errorMessage) { 76 | this.amount = amount; 77 | this.balance = balance; 78 | this.type = type; 79 | this.errorMessage = errorMessage; 80 | } 81 | 82 | /** 83 | * Checks if an operation was successful 84 | * @return Value 85 | */ 86 | public boolean transactionSuccess() { 87 | switch (type) { 88 | case SUCCESS: 89 | return true; 90 | default: 91 | return false; 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /src/main/java/net/milkbowl/vault2/permission/Permission.java: -------------------------------------------------------------------------------- 1 | /* This file is part of Vault. 2 | 3 | Vault is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Lesser General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | Vault is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with Vault. If not, see . 15 | */ 16 | package net.milkbowl.vault2.permission; 17 | 18 | import java.util.logging.Logger; 19 | 20 | import org.bukkit.OfflinePlayer; 21 | import org.bukkit.World; 22 | import org.bukkit.command.CommandSender; 23 | import org.bukkit.entity.Player; 24 | import org.bukkit.permissions.PermissionAttachment; 25 | import org.bukkit.permissions.PermissionAttachmentInfo; 26 | import org.bukkit.plugin.Plugin; 27 | 28 | /** 29 | * The main Permission API - allows for group and player based permission tests 30 | * 31 | */ 32 | public abstract class Permission { 33 | 34 | protected static final Logger log = Logger.getLogger("Minecraft"); 35 | protected Plugin plugin = null; 36 | 37 | /** 38 | * Gets name of permission method 39 | * @return Name of Permission Method 40 | */ 41 | abstract public String getName(); 42 | 43 | /** 44 | * Checks if permission method is enabled. 45 | * @return Success or Failure 46 | */ 47 | abstract public boolean isEnabled(); 48 | 49 | /** 50 | * Returns if the permission system is or attempts to be compatible with super-perms. 51 | * @return True if this permission implementation works with super-perms 52 | */ 53 | abstract public boolean hasSuperPermsCompat(); 54 | 55 | /** 56 | * Checks if player has a permission node. 57 | * Supports NULL value for World if the permission system registered supports global permissions. 58 | * But May return odd values if the servers registered permission system does not have a global permission store. 59 | * 60 | * @param world String world name 61 | * @param player to check 62 | * @param permission Permission node 63 | * @return Success or Failure 64 | * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. 65 | */ 66 | @Deprecated 67 | public boolean has(final String world, final String player, final String permission) { 68 | if (world == null) { 69 | return playerHas((String) null, player, permission); 70 | } 71 | return playerHas(world, player, permission); 72 | } 73 | 74 | /** 75 | * Checks if player has a permission node. 76 | * Supports NULL value for World if the permission system registered supports global permissions. 77 | * But May return odd values if the servers registered permission system does not have a global permission store. 78 | * 79 | * @param world String world name 80 | * @param player to check 81 | * @param permission Permission node 82 | * @return Success or Failure 83 | * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. 84 | */ 85 | @Deprecated 86 | public boolean has(final World world, final String player, final String permission) { 87 | if (world == null) { 88 | return playerHas((String) null, player, permission); 89 | } 90 | return playerHas(world.getName(), player, permission); 91 | } 92 | 93 | /** 94 | * Checks if a CommandSender has a permission node. 95 | * This will return the result of bukkits, generic .hasPermission() method and is identical in all cases. 96 | * This method will explicitly fail if the registered permission system does not register permissions in bukkit. 97 | * 98 | * For easy checking of a commandsender 99 | * @param sender to check permissions on 100 | * @param permission to check for 101 | * @return true if the sender has the permission 102 | */ 103 | public boolean has(final CommandSender sender, final String permission) { 104 | return sender.hasPermission(permission); 105 | } 106 | 107 | /** 108 | * Checks if player has a permission node. (Short for playerHas(...) 109 | * @param player Player Object 110 | * @param permission Permission node 111 | * @return Success or Failure 112 | */ 113 | public boolean has(final Player player, final String permission) { 114 | return player.hasPermission(permission); 115 | } 116 | 117 | /** 118 | * Checks if player has a permission node. 119 | * Supports NULL value for World if the permission system registered supports global permissions. 120 | * But May return odd values if the servers registered permission system does not have a global permission store. 121 | * 122 | * @param world String world name 123 | * @param player to check 124 | * @param permission Permission node 125 | * @return Success or Failure 126 | * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. 127 | */ 128 | @Deprecated 129 | abstract public boolean playerHas(String world, String player, String permission); 130 | 131 | /** 132 | * Checks if player has a permission node. 133 | * Supports NULL value for World if the permission system registered supports global permissions. 134 | * But May return odd values if the servers registered permission system does not have a global permission store. 135 | * 136 | * @param world String world name 137 | * @param player to check 138 | * @param permission Permission node 139 | * @return Success or Failure 140 | * @deprecated As of VaultAPI 1.4 use {@link #playerHas(String, OfflinePlayer, String)} instead. 141 | */ 142 | @Deprecated 143 | public boolean playerHas(final World world, final String player, final String permission) { 144 | if (world == null) { 145 | return playerHas((String) null, player, permission); 146 | } 147 | return playerHas(world.getName(), player, permission); 148 | } 149 | 150 | /** 151 | * Checks if player has a permission node. 152 | * Supports NULL value for World if the permission system registered supports global permissions. 153 | * But May return odd values if the servers registered permission system does not have a global permission store. 154 | * 155 | * @param world String world name 156 | * @param player to check 157 | * @param permission Permission node 158 | * @return Success or Failure 159 | */ 160 | public boolean playerHas(final String world, final OfflinePlayer player, final String permission) { 161 | if (world == null) { 162 | return has((String) null, player.getName(), permission); 163 | } 164 | return has(world, player.getName(), permission); 165 | } 166 | 167 | /** 168 | * Checks if player has a permission node. 169 | * Defaults to world-specific permission check if the permission system supports it. 170 | * See {@link #playerHas(String, OfflinePlayer, String)} for explicit global or world checks. 171 | * 172 | * @param player Player Object 173 | * @param permission Permission node 174 | * @return Success or Failure 175 | */ 176 | public boolean playerHas(final Player player, final String permission) { 177 | return has(player, permission); 178 | } 179 | 180 | /** 181 | * @deprecated As of VaultAPI 1.4 use {@link #playerAdd(String, OfflinePlayer, String)} instead. 182 | * Add permission to a player. 183 | * Supports NULL value for World if the permission system registered supports global permissions. 184 | * But May return odd values if the servers registered permission system does not have a global permission store. 185 | * 186 | * @param world World name 187 | * @param player Player name 188 | * @param permission Permission node 189 | * @return Success or Failure 190 | */ 191 | @Deprecated 192 | abstract public boolean playerAdd(String world, String player, String permission); 193 | 194 | /** 195 | * Add permission to a player. 196 | * Supports NULL value for World if the permission system registered supports global permissions. 197 | * But May return odd values if the servers registered permission system does not have a global permission store. 198 | * 199 | * @param world String world name 200 | * @param player to add to 201 | * @param permission Permission node 202 | * @return Success or Failure 203 | * @deprecated As of VaultAPI 1.4 use {@link #playerAdd(String, OfflinePlayer, String)} instead. 204 | */ 205 | @Deprecated 206 | public boolean playerAdd(final World world, final String player, final String permission) { 207 | if (world == null) { 208 | return playerAdd((String) null, player, permission); 209 | } 210 | return playerAdd(world.getName(), player, permission); 211 | } 212 | 213 | /** 214 | * Add permission to a player. 215 | * Supports NULL value for World if the permission system registered supports global permissions. 216 | * But May return odd values if the servers registered permission system does not have a global permission store. 217 | * 218 | * @param world String world name 219 | * @param player to add to 220 | * @param permission Permission node 221 | * @return Success or Failure 222 | */ 223 | public boolean playerAdd(final String world, final OfflinePlayer player, final String permission) { 224 | if (world == null) { 225 | return playerAdd((String) null, player.getName(), permission); 226 | } 227 | return playerAdd(world, player.getName(), permission); 228 | } 229 | 230 | /** 231 | * Add permission to a player ONLY for the world the player is currently on. 232 | * This is a world-specific operation, if you want to add global permission you must explicitly use NULL for the world. 233 | * See {@link #playerAdd(String, OfflinePlayer, String)} for global permission use. 234 | * 235 | * @param player Player Object 236 | * @param permission Permission node 237 | * @return Success or Failure 238 | */ 239 | public boolean playerAdd(final Player player, final String permission) { 240 | return playerAdd(player.getWorld().getName(), player, permission); 241 | } 242 | 243 | /** 244 | * Add transient permission to a player. 245 | * This implementation can be used by any subclass which implements a "pure" superperms plugin, i.e. 246 | * one that only needs the built-in Bukkit API to add transient permissions to a player. 247 | * 248 | * @param player to add to 249 | * @param permission Permission node 250 | * @return Success or Failure 251 | */ 252 | public boolean playerAddTransient(final OfflinePlayer player, final String permission) throws UnsupportedOperationException { 253 | if (player.isOnline()) { 254 | return playerAddTransient((Player) player, permission); 255 | } 256 | throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!"); 257 | } 258 | 259 | /** 260 | * Add transient permission to a player. 261 | * This operation adds a permission onto the player object in bukkit via Bukkit's permission interface. 262 | * 263 | * @param player Player Object 264 | * @param permission Permission node 265 | * @return Success or Failure 266 | */ 267 | public boolean playerAddTransient(final Player player, final String permission) { 268 | for (final PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) { 269 | if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) { 270 | paInfo.getAttachment().setPermission(permission, true); 271 | return true; 272 | } 273 | } 274 | 275 | final PermissionAttachment attach = player.addAttachment(plugin); 276 | attach.setPermission(permission, true); 277 | 278 | return true; 279 | } 280 | 281 | /** 282 | * Adds a world specific transient permission to the player, may only work with some permission managers. 283 | * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! 284 | * 285 | * @param worldName to check on 286 | * @param player to add to 287 | * @param permission to test 288 | * @return Success or Failure 289 | */ 290 | public boolean playerAddTransient(final String worldName, final OfflinePlayer player, final String permission) { 291 | return playerAddTransient(player, permission); 292 | } 293 | 294 | /** 295 | * Adds a world specific transient permission to the player, may only work with some permission managers. 296 | * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! 297 | * 298 | * @param worldName to check on 299 | * @param player to check 300 | * @param permission to check for 301 | * @return Success or Failure 302 | */ 303 | public boolean playerAddTransient(final String worldName, final Player player, final String permission) { 304 | return playerAddTransient(player, permission); 305 | } 306 | 307 | /** 308 | * Removes a world specific transient permission from the player, may only work with some permission managers. 309 | * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! 310 | * 311 | * @param worldName to remove for 312 | * @param player to remove for 313 | * @param permission to remove 314 | * @return Success or Failure 315 | */ 316 | public boolean playerRemoveTransient(final String worldName, final OfflinePlayer player, final String permission) { 317 | return playerRemoveTransient(player, permission); 318 | } 319 | 320 | /** 321 | * Removes a world specific transient permission from the player, may only work with some permission managers. 322 | * Defaults to GLOBAL permissions for any permission system that does not support world-specific transient permissions! 323 | * 324 | * @param worldName to check on 325 | * @param player to check 326 | * @param permission to check for 327 | * @return Success or Failure 328 | */ 329 | public boolean playerRemoveTransient(final String worldName, final Player player, final String permission) { 330 | return playerRemoveTransient((OfflinePlayer) player, permission); 331 | } 332 | 333 | /** 334 | * Checks if player has a permission node. 335 | * Supports NULL value for World if the permission system registered supports global permissions. 336 | * But May return odd values if the servers registered permission system does not have a global permission store. 337 | * 338 | * @param world String world name 339 | * @param player to check 340 | * @param permission Permission node 341 | * @return Success or Failure 342 | * @deprecated As of VaultAPI 1.4 use {@link #playerRemove(String, OfflinePlayer, String)} instead. 343 | */ 344 | @Deprecated 345 | abstract public boolean playerRemove(String world, String player, String permission); 346 | 347 | /** 348 | * Remove permission from a player. 349 | * Supports NULL value for World if the permission system registered supports global permissions. 350 | * But May return odd values if the servers registered permission system does not have a global permission store. 351 | * 352 | * @param world World name 353 | * @param player OfflinePlayer 354 | * @param permission Permission node 355 | * @return Success or Failure 356 | */ 357 | public boolean playerRemove(final String world, final OfflinePlayer player, final String permission) { 358 | if (world == null) { 359 | return playerRemove((String) null, player.getName(), permission); 360 | } 361 | return playerRemove(world, player.getName(), permission); 362 | } 363 | 364 | /** 365 | * Remove permission from a player. 366 | * Supports NULL value for World if the permission system registered supports global permissions. 367 | * But May return odd values if the servers registered permission system does not have a global permission store. 368 | * 369 | * @param world World name 370 | * @param player Player name 371 | * @param permission Permission node 372 | * @return Success or Failure 373 | */ 374 | @Deprecated 375 | public boolean playerRemove(final World world, final String player, final String permission) { 376 | if (world == null) { 377 | return playerRemove((String) null, player, permission); 378 | } 379 | return playerRemove(world.getName(), player, permission); 380 | } 381 | 382 | /** 383 | * Remove permission from a player. 384 | * Will attempt to remove permission from the player on the player's current world. This is NOT a global operation. 385 | * 386 | * @param player Player Object 387 | * @param permission Permission node 388 | * @return Success or Failure 389 | */ 390 | public boolean playerRemove(final Player player, final String permission) { 391 | return playerRemove(player.getWorld().getName(), player, permission); 392 | } 393 | 394 | 395 | /** 396 | * Remove transient permission from a player. 397 | * This implementation can be used by any subclass which implements a "pure" superperms plugin, i.e. 398 | * one that only needs the built-in Bukkit API to remove transient permissions from a player. Any subclass 399 | * implementing a plugin which provides its own API for this needs to override this method. 400 | * 401 | * @param player OfflinePlayer 402 | * @param permission Permission node 403 | * @return Success or Failure 404 | */ 405 | public boolean playerRemoveTransient(final OfflinePlayer player, final String permission) { 406 | if (player.isOnline()) { 407 | return playerRemoveTransient((Player) player, permission); 408 | } else { 409 | return false; 410 | } 411 | } 412 | 413 | /** 414 | * Remove transient permission from a player. 415 | * 416 | * @param player Player Object 417 | * @param permission Permission node 418 | * @return Success or Failure 419 | */ 420 | public boolean playerRemoveTransient(final Player player, final String permission) { 421 | for (final PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) { 422 | if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) { 423 | paInfo.getAttachment().unsetPermission(permission); 424 | return true; 425 | } 426 | } 427 | return false; 428 | } 429 | 430 | /** 431 | * Checks if group has a permission node. 432 | * Supports NULL value for World if the permission system registered supports global permissions. 433 | * But May return odd values if the servers registered permission system does not have a global permission store. 434 | * 435 | * @param world World name 436 | * @param group Group name 437 | * @param permission Permission node 438 | * @return Success or Failure 439 | */ 440 | abstract public boolean groupHas(String world, String group, String permission); 441 | 442 | /** 443 | * Checks if group has a permission node. 444 | * Supports NULL value for World if the permission system registered supports global permissions. 445 | * But May return odd values if the servers registered permission system does not have a global permission store. 446 | * 447 | * @param world World Object 448 | * @param group Group name 449 | * @param permission Permission node 450 | * @return Success or Failure 451 | */ 452 | public boolean groupHas(final World world, final String group, final String permission) { 453 | if (world == null) { 454 | return groupHas((String) null, group, permission); 455 | } 456 | return groupHas(world.getName(), group, permission); 457 | } 458 | 459 | /** 460 | * Add permission to a group. 461 | * Supports NULL value for World if the permission system registered supports global permissions. 462 | * But May return odd values if the servers registered permission system does not have a global permission store. 463 | * 464 | * @param world World name 465 | * @param group Group name 466 | * @param permission Permission node 467 | * @return Success or Failure 468 | */ 469 | abstract public boolean groupAdd(String world, String group, String permission); 470 | 471 | /** 472 | * Add permission to a group. 473 | * Supports NULL value for World if the permission system registered supports global permissions. 474 | * But May return odd values if the servers registered permission system does not have a global permission store. 475 | * 476 | * @param world World Object 477 | * @param group Group name 478 | * @param permission Permission node 479 | * @return Success or Failure 480 | */ 481 | public boolean groupAdd(final World world, final String group, final String permission) { 482 | if (world == null) { 483 | return groupAdd((String) null, group, permission); 484 | } 485 | return groupAdd(world.getName(), group, permission); 486 | } 487 | 488 | /** 489 | * Remove permission from a group. 490 | * Supports NULL value for World if the permission system registered supports global permissions. 491 | * But May return odd values if the servers registered permission system does not have a global permission store. 492 | * 493 | * @param world World name 494 | * @param group Group name 495 | * @param permission Permission node 496 | * @return Success or Failure 497 | */ 498 | abstract public boolean groupRemove(String world, String group, String permission); 499 | 500 | /** 501 | * Remove permission from a group. 502 | * Supports NULL value for World if the permission system registered supports global permissions. 503 | * But May return odd values if the servers registered permission system does not have a global permission store. 504 | * 505 | * @param world World Object 506 | * @param group Group name 507 | * @param permission Permission node 508 | * @return Success or Failure 509 | */ 510 | public boolean groupRemove(final World world, final String group, final String permission) { 511 | if (world == null) { 512 | return groupRemove((String) null, group, permission); 513 | } 514 | return groupRemove(world.getName(), group, permission); 515 | } 516 | 517 | /** 518 | * Check if player is member of a group. 519 | * Supports NULL value for World if the permission system registered supports global permissions. 520 | * But May return odd values if the servers registered permission system does not have a global permission store. 521 | * 522 | * @param world World Object 523 | * @param player to check 524 | * @param group Group name 525 | * @return Success or Failure 526 | * @deprecated As of VaultAPI 1.4 use {@link #playerInGroup(String, OfflinePlayer, String)} instead. 527 | */ 528 | @Deprecated 529 | abstract public boolean playerInGroup(String world, String player, String group); 530 | 531 | /** 532 | * Check if player is member of a group. 533 | * Supports NULL value for World if the permission system registered supports global permissions. 534 | * But May return odd values if the servers registered permission system does not have a global permission store. 535 | * 536 | * @param world World Object 537 | * @param player to check 538 | * @param group Group name 539 | * @return Success or Failure 540 | * @deprecated As of VaultAPI 1.4 use {@link #playerInGroup(String, OfflinePlayer, String)} instead. 541 | */ 542 | @Deprecated 543 | public boolean playerInGroup(final World world, final String player, final String group) { 544 | if (world == null) { 545 | return playerInGroup((String) null, player, group); 546 | } 547 | return playerInGroup(world.getName(), player, group); 548 | } 549 | 550 | /** 551 | * Check if player is member of a group. 552 | * Supports NULL value for World if the permission system registered supports global permissions. 553 | * But May return odd values if the servers registered permission system does not have a global permission store. 554 | * 555 | * @param world World Object 556 | * @param player to check 557 | * @param group Group name 558 | * @return Success or Failure 559 | */ 560 | public boolean playerInGroup(final String world, final OfflinePlayer player, final String group) { 561 | if (world == null) { 562 | return playerInGroup((String) null, player.getName(), group); 563 | } 564 | return playerInGroup(world, player.getName(), group); 565 | } 566 | 567 | /** 568 | * Check if player is member of a group. 569 | * This method will ONLY check groups for which the player is in that are defined for the current world. 570 | * This may result in odd return behaviour depending on what permission system has been registered. 571 | * 572 | * @param player Player Object 573 | * @param group Group name 574 | * @return Success or Failure 575 | */ 576 | public boolean playerInGroup(final Player player, final String group) { 577 | return playerInGroup(player.getWorld().getName(), player, group); 578 | } 579 | 580 | /** 581 | * Add player to a group. 582 | * Supports NULL value for World if the permission system registered supports global permissions. 583 | * But May return odd values if the servers registered permission system does not have a global permission store. 584 | * 585 | * @param world String world name 586 | * @param player to add 587 | * @param group Group name 588 | * @return Success or Failure 589 | * @deprecated As of VaultAPI 1.4 use {@link #playerAddGroup(String, OfflinePlayer, String)} instead. 590 | */ 591 | @Deprecated 592 | abstract public boolean playerAddGroup(String world, String player, String group); 593 | 594 | /** 595 | * Add player to a group. 596 | * Supports NULL value for World if the permission system registered supports global permissions. 597 | * But May return odd values if the servers registered permission system does not have a global permission store. 598 | * 599 | * @param world String world name 600 | * @param player to add 601 | * @param group Group name 602 | * @return Success or Failure 603 | * @deprecated As of VaultAPI 1.4 use {@link #playerAddGroup(String, OfflinePlayer, String)} instead. 604 | */ 605 | @Deprecated 606 | public boolean playerAddGroup(final World world, final String player, final String group) { 607 | if (world == null) { 608 | return playerAddGroup((String) null, player, group); 609 | } 610 | return playerAddGroup(world.getName(), player, group); 611 | } 612 | 613 | /** 614 | * Add player to a group. 615 | * Supports NULL value for World if the permission system registered supports global permissions. 616 | * But May return odd values if the servers registered permission system does not have a global permission store. 617 | * 618 | * @param world String world name 619 | * @param player to add 620 | * @param group Group name 621 | * @return Success or Failure 622 | */ 623 | public boolean playerAddGroup(final String world, final OfflinePlayer player, final String group) { 624 | if (world == null) { 625 | return playerAddGroup((String) null, player.getName(), group); 626 | } 627 | return playerAddGroup(world, player.getName(), group); 628 | } 629 | 630 | /** 631 | * Add player to a group. 632 | * This will add a player to the group on the current World. This may return odd results if the permission system 633 | * being used on the server does not support world-specific groups, or if the group being added to is a global group. 634 | * 635 | * @param player Player Object 636 | * @param group Group name 637 | * @return Success or Failure 638 | */ 639 | public boolean playerAddGroup(final Player player, final String group) { 640 | return playerAddGroup(player.getWorld().getName(), player, group); 641 | } 642 | 643 | /** 644 | * Remove player from a group. 645 | * Supports NULL value for World if the permission system registered supports global permissions. 646 | * But May return odd values if the servers registered permission system does not have a global permission store. 647 | * 648 | * @param world World Object 649 | * @param player to remove 650 | * @param group Group name 651 | * @return Success or Failure 652 | * @deprecated As of VaultAPI 1.4 use {@link #playerRemoveGroup(String, OfflinePlayer, String)} instead. 653 | */ 654 | @Deprecated 655 | abstract public boolean playerRemoveGroup(String world, String player, String group); 656 | 657 | /** 658 | * Remove player from a group. 659 | * Supports NULL value for World if the permission system registered supports global permissions. 660 | * But May return odd values if the servers registered permission system does not have a global permission store. 661 | * 662 | * @param world World Object 663 | * @param player to remove 664 | * @param group Group name 665 | * @return Success or Failure 666 | * @deprecated As of VaultAPI 1.4 use {@link #playerRemoveGroup(String, OfflinePlayer, String)} instead. 667 | */ 668 | @Deprecated 669 | public boolean playerRemoveGroup(final World world, final String player, final String group) { 670 | if (world == null) { 671 | return playerRemoveGroup((String) null, player, group); 672 | } 673 | return playerRemoveGroup(world.getName(), player, group); 674 | } 675 | 676 | /** 677 | * Remove player from a group. 678 | * Supports NULL value for World if the permission system registered supports global permissions. 679 | * But May return odd values if the servers registered permission system does not have a global permission store. 680 | * 681 | * @param world World Object 682 | * @param player to remove 683 | * @param group Group name 684 | * @return Success or Failure 685 | */ 686 | public boolean playerRemoveGroup(final String world, final OfflinePlayer player, final String group) { 687 | if (world == null) { 688 | return playerRemoveGroup((String) null, player.getName(), group); 689 | } 690 | return playerRemoveGroup(world, player.getName(), group); 691 | } 692 | 693 | /** 694 | * Remove player from a group. 695 | * This will add a player to the group on the current World. This may return odd results if the permission system 696 | * being used on the server does not support world-specific groups, or if the group being added to is a global group. 697 | * 698 | * @param player Player Object 699 | * @param group Group name 700 | * @return Success or Failure 701 | */ 702 | public boolean playerRemoveGroup(final Player player, final String group) { 703 | return playerRemoveGroup(player.getWorld().getName(), player, group); 704 | } 705 | 706 | /** 707 | * Gets the list of groups that this player has 708 | * Supports NULL value for World if the permission system registered supports global permissions. 709 | * But May return odd values if the servers registered permission system does not have a global permission store. 710 | * 711 | * @param world String world name 712 | * @param player OfflinePlayer 713 | * @return Array of groups 714 | * @deprecated As of VaultAPI 1.4 use {@link #getPlayerGroups(String, OfflinePlayer)} instead. 715 | */ 716 | @Deprecated 717 | abstract public String[] getPlayerGroups(String world, String player); 718 | 719 | /** 720 | * Gets the list of groups that this player has 721 | * Supports NULL value for World if the permission system registered supports global permissions. 722 | * But May return odd values if the servers registered permission system does not have a global permission store. 723 | * 724 | * @param world String world name 725 | * @param player OfflinePlayer 726 | * @return Array of groups 727 | * @deprecated As of VaultAPI 1.4 use {@link #getPlayerGroups(String, OfflinePlayer)} instead. 728 | */ 729 | @Deprecated 730 | public String[] getPlayerGroups(final World world, final String player) { 731 | if (world == null) { 732 | return getPlayerGroups((String) null, player); 733 | } 734 | return getPlayerGroups(world.getName(), player); 735 | } 736 | 737 | /** 738 | * Gets the list of groups that this player has 739 | * Supports NULL value for World if the permission system registered supports global permissions. 740 | * But May return odd values if the servers registered permission system does not have a global permission store. 741 | * 742 | * @param world String world name 743 | * @param player OfflinePlayer 744 | * @return Array of groups 745 | */ 746 | public String[] getPlayerGroups(final String world, final OfflinePlayer player) { 747 | return getPlayerGroups(world, player.getName()); 748 | } 749 | 750 | /** 751 | * Returns a list of world-specific groups that this player is currently in. May return unexpected results if 752 | * you are looking for global groups, or if the registered permission system does not support world-specific groups. 753 | * See {@link #getPlayerGroups(String, OfflinePlayer)} for better control of World-specific or global groups. 754 | * 755 | * @param player Player Object 756 | * @return Array of groups 757 | */ 758 | public String[] getPlayerGroups(final Player player) { 759 | return getPlayerGroups(player.getWorld().getName(), player); 760 | } 761 | 762 | /** 763 | * Gets players primary group 764 | * Supports NULL value for World if the permission system registered supports global permissions. 765 | * But May return odd values if the servers registered permission system does not have a global permission store. 766 | * 767 | * @param world String world name 768 | * @param player to get from 769 | * @return Players primary group 770 | * @deprecated As of VaultAPI 1.4 use {@link #getPrimaryGroup(String, OfflinePlayer)} instead. 771 | */ 772 | @Deprecated 773 | abstract public String getPrimaryGroup(String world, String player); 774 | 775 | /** 776 | * Gets players primary group 777 | * Supports NULL value for World if the permission system registered supports global permissions. 778 | * But May return odd values if the servers registered permission system does not have a global permission store. 779 | * 780 | * @param world String world name 781 | * @param player to get from 782 | * @return Players primary group 783 | * @deprecated As of VaultAPI 1.4 use {@link #getPrimaryGroup(String, OfflinePlayer)} instead. 784 | */ 785 | @Deprecated 786 | public String getPrimaryGroup(final World world, final String player) { 787 | if (world == null) { 788 | return getPrimaryGroup((String) null, player); 789 | } 790 | return getPrimaryGroup(world.getName(), player); 791 | } 792 | 793 | /** 794 | * Gets players primary group 795 | * Supports NULL value for World if the permission system registered supports global permissions. 796 | * But May return odd values if the servers registered permission system does not have a global permission store. 797 | * 798 | * @param world String world name 799 | * @param player to get from 800 | * @return Players primary group 801 | */ 802 | public String getPrimaryGroup(final String world, final OfflinePlayer player) { 803 | return getPrimaryGroup(world, player.getName()); 804 | } 805 | 806 | /** 807 | * Get players primary group. 808 | * Defaults to the players current world, so may return only world-specific groups. 809 | * In most cases {@link #getPrimaryGroup(String, OfflinePlayer)} is preferable. 810 | * 811 | * @param player Player Object 812 | * @return Players primary group 813 | */ 814 | public String getPrimaryGroup(final Player player) { 815 | return getPrimaryGroup(player.getWorld().getName(), player); 816 | } 817 | 818 | /** 819 | * Returns a list of all known groups 820 | * @return an Array of String of all groups 821 | */ 822 | abstract public String[] getGroups(); 823 | 824 | /** 825 | * Returns true if the given implementation supports groups. 826 | * @return true if the implementation supports groups 827 | */ 828 | abstract public boolean hasGroupSupport(); 829 | } --------------------------------------------------------------------------------